[freeside-commits] branch master updated. 4466b9790181b76b2955cf522562231228047054
Mitch Jackson
mitch at freeside.biz
Tue Nov 27 13:42:40 PST 2018
The branch, master has been updated
via 4466b9790181b76b2955cf522562231228047054 (commit)
via 28051580bf12b079a4631647a5c0defc7f55c9dc (commit)
via 0339cd666b4c39ef3772f1d28dc3a5f30f422966 (commit)
from 0df9455e5c155bc7aea4f515876111825f1931b9 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 4466b9790181b76b2955cf522562231228047054
Author: Mitch Jackson <mitch at freeside.biz>
Date: Tue Nov 27 16:40:52 2018 -0500
RT# 81706 CSS Sub-Menu Fix for jQuery-ui upgrade
diff --git a/httemplate/elements/dropdown-menu.html b/httemplate/elements/dropdown-menu.html
index 1ba4c00cc..8c99db07f 100644
--- a/httemplate/elements/dropdown-menu.html
+++ b/httemplate/elements/dropdown-menu.html
@@ -5,6 +5,12 @@
border: none;
}
+#<% $opt{id} %> .ui-state-active {
+ color: inherit;
+ background-color: transparent;
+ border-color: transparent;
+}
+
#<% $opt{id} %> li {
float: left;
padding: .25em;
commit 28051580bf12b079a4631647a5c0defc7f55c9dc
Author: Mitch Jackson <mitch at freeside.biz>
Date: Tue Nov 27 15:39:01 2018 -0500
RT# 32243 Package Bulk Edit UI Update
diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index f29ab9fc0..d39dbbbcd 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -5614,6 +5614,8 @@ sub _X_show_zero {
=item order CUSTNUM, PKGPARTS_ARYREF, [ REMOVE_PKGNUMS_ARYREF [ RETURN_CUST_PKG_ARRAYREF [ REFNUM ] ] ]
+=item order \%PARAMS
+
Bulk cancel + order subroutine. Perhaps slightly deprecated, only used by the
bulk cancel+order in the web UI and nowhere else (edit/process/cust_pkg.cgi)
@@ -5638,10 +5640,25 @@ setting I<refnum> to an array reference of refnums or a hash reference with
refnums as keys. If no I<refnum> is defined, a default FS::pkg_referral
record will be created corresponding to cust_main.refnum.
+LOCATIONNUM, if specified, will be set on newly created cust_pkg records
+
=cut
sub order {
- my ($custnum, $pkgparts, $remove_pkgnum, $return_cust_pkg, $refnum) = @_;
+ my ($custnum, $pkgparts, $remove_pkgnum, $return_cust_pkg, $refnum,
+ $locationnum);
+
+ if ( ref $_[0] ) {
+ my $args = $_[0];
+ $custnum = $args->{custnum};
+ $pkgparts = $args->{pkgparts};
+ $remove_pkgnum = $args->{remove_pkgnum};
+ $return_cust_pkg = $args->{return_cust_pkg};
+ $refnum = $args->{refnum};
+ $locationnum = $args->{locationnum};
+ } else {
+ ($custnum, $pkgparts, $remove_pkgnum, $return_cust_pkg, $refnum) = @_;
+ }
my $conf = new FS::Conf;
@@ -5685,6 +5702,8 @@ sub order {
}
+ $hash{locationnum} = $locationnum if $locationnum;
+
# Create the new packages.
foreach my $pkgpart (@$pkgparts) {
diff --git a/httemplate/edit/cust_pkg.cgi b/httemplate/edit/cust_pkg.cgi
index 7ffbb1fc0..4e4f4d2b2 100755
--- a/httemplate/edit/cust_pkg.cgi
+++ b/httemplate/edit/cust_pkg.cgi
@@ -1,115 +1,207 @@
-<% include('/elements/header.html', "Add/Edit Packages", '') %>
+<%doc>
+ Bulk package Edit Page
+
+</%doc>
+<& /elements/header-cust_main.html,
+ view => 'packages',
+ cust_main => $cust_main,
+ include_selectize => 1,
+&>
<% include('/elements/error.html') %>
-<FORM ACTION="<% $p1 %>process/cust_pkg.cgi" METHOD=POST>
-<INPUT TYPE="hidden" NAME="action" VALUE="bulk">
-<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
-
-%#current packages
-%if (@cust_pkg) {
-
- Current packages - select to remove (services are moved to a new package below)
- <TABLE>
- <TR STYLE="background-color: #cccccc;">
- <TH COLSPAN="2">Pkg #</TH>
- <TH>Package description</TH>
- </TR>
- <BR><BR>
-%
-% foreach ( @main_pkgs ) {
-% my($pkgnum,$pkgpart)=( $_->getfield('pkgnum'), $_->getfield('pkgpart') );
-% my $checked = $remove_pkg{$pkgnum} ? ' CHECKED' : '';
-%
-%
-
-
- <TR>
- <TD><INPUT TYPE="checkbox" NAME="remove_pkg" VALUE="<% $pkgnum %>"<% $checked %>></TD>
- <TD ALIGN="right"><% $pkgnum %>:</TD>
- <TD><% $all_pkg{$pkgpart} |h %> - <% $all_comment{$pkgpart} |h %></TD>
- </TR>
-% foreach my $supp_pkg ( @{ $supp_pkgs_of{$pkgnum} } ) {
- <TR>
- <TD></TD>
- <TD></TD>
- <TD>+ <% $all_pkg{$supp_pkg->pkgpart} |h %> - <% $all_comment{$supp_pkg->pkgpart} |h %></TD>
- </TR>
+<script>
+
+ let locationnum = "<% $cust_main->ship_locationnum %>";
+
+ function location_changed(e) {
+ locationnum = $(e).val();
+ $('tr[data-locationnum]').find('input').prop('checked', false);
+ $('tr[data-locationnum]').each( function() {
+ let tr_el = $(this);
+ tr_el.css(
+ 'display',
+ locationnum == tr_el.data('locationnum') ? 'table-row' : 'none'
+ );
+ });
+ }
+
+ function pkg_class_filter_onchange( selected ) {
+ if ( selected.length == 0 ) {
+ $('tr[data-classnum]').css('display', 'table-row');
+ } else {
+ $('tr[data-classnum]').each( function() {
+ let tr_el = $(this);
+ let classnum = tr_el.data('classnum');
+ let is_displayed = $.grep( selected, function( item ) {
+ return item == classnum;
+ });
+ let display = is_displayed.length ? 'table-row' : 'none';
+ tr_el.css( 'display', is_displayed.length ? 'table-row' : 'none' );
+ });
+ }
+ }
+
+ function confirm_form() {
+ let cust_pkg_removed = [];
+ let pkg_part_added = [];
+
+ $('input[data-locationnum]:checked').each( function() {
+ let this_el = $(this);
+ cust_pkg_removed.push(
+ '#' + this_el.data('pkgnum') + ' ' + this_el.data('pkg')
+ );
+ });
+
+ $('input[data-pkgpart]').each( function() {
+ qty_el = $(this);
+ qty = qty_el.val();
+
+ if ( qty < 1 ) { return; }
+
+ pkg_part_added.push( qty + ' x ' + qty_el.data('pkg') );
+ });
+
+ if ( cust_pkg_removed.length == 0 ) {
+ cust_pkg_removed.push('No Existing Packages Selected');
+ }
+ if ( pkg_part_added.length == 0 ) {
+ pkg_part_added.push('No New Packages Selected');
+ }
+
+ console.log( cust_pkg_removed );
+ console.log( pkg_part_added );
+
+ confirm_html =
+ '<div style="margin: 1em;">'
+ + '<b><u>Removed Packages:</u></b><br>'
+ + cust_pkg_removed.join('<br>')
+ + '<br><br>'
+ + '<b><u>Replacement Packages:</u></b><br>'
+ + pkg_part_added.join('<br>')
+ + '<br><br>'
+ + '<input type="button" role="button" onclick="submit_form();" value="Confirm Order">'
+ + '</div>';
+
+ overlib(
+ confirm_html,
+ CAPTION, 'Confirm bulk change',
+ STICKY,
+ AUTOSTATUSCAP,
+ MIDX, 0,
+ MIDY, 0,
+ WIDTH, 300,
+ HEIGHT, 200,
+ TEXTSIZE, 3,
+ BGCOLOR, '#ff0000',
+ CGCOLOR, '#ff0000'
+ );
+ }
+
+ function submit_form() {
+ $('#formBulkEdit').submit();
+ }
+</script>
+
+<form action="<% $fsurl %>edit/process/cust_pkg.cgi" method="POST" id="formBulkEdit">
+<input type="hidden" name="custnum" value="<% $custnum %>">
+<input type="hidden" name="action" value="bulk">
+
+<p style="margin-bottom: 2em;">
+ <label for="locationnum">Service Location</label>
+ <% include( '/elements/select-cust_location.html',
+ cust_main => $cust_main,
+ addnew => 0,
+ onchange => 'javascript:location_changed(this);',
+ ) %><br>
+ <span style="font-size: .8em; padding-left: 1em;">
+ Bulk-edit works with one customer location at a time
+ </span>
+</p>
+
+<table style="margin-bottom: 2em;">
+ <thead>
+ <tr style="background-color: #ccc;">
+ <th colspan="2" style="text-align: left;">
+ Pkg #
+ </th>
+ <th style="text-align: left;">
+ Current Packages<br>
+ <div style="font-size: .8em; padding-left: 1em; font-weight: normal;">
+ Selected packages are removed.<br>
+ Attached services are moved to the new package selected below
+ </span>
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+% for my $cust_pkg ( @cust_pkg ) {
+% my $id = sprintf 'remove_cust_pkg[%s]', $cust_pkg->pkgnum;
+% my $is_displayed = $cust_main->ship_locationnum == $cust_pkg->locationnum ? 1 : 0;
+ <tr data-locationnum="<% $cust_pkg->locationnum %>" data-pkg="<% $cust_pkg->pkg |h %>" style="display: <% $is_displayed ? 'table-row' : 'none' %>;">
+ <td>
+ <input type="checkbox"
+ name="<% $id %>"
+ id="<% $id %>"
+ data-pkgnum="<% $cust_pkg->pkgnum %>"
+ data-locationnum="<% $cust_pkg->locationnum %>"
+ data-pkg="<% $part_pkg{ $cust_pkg->pkgpart }->pkg |h %>">
+ </td>
+ <td>#<% $cust_pkg->pkgnum %></td>
+ <td>
+ <label for="<% $id %>">
+ <% $part_pkg{ $cust_pkg->pkgpart }->pkg %><br>
+% for my $cust_pkg_supp ( @{ $cust_pkg_supp_of{ $cust_pkg->pkgnum }} ) {
+ <span style="font-size: .8em; padding-left: 1em;">
+ <b>Supplementary:</b> <% $part_pkg{ $cust_pkg_supp->pkgpart }->pkg %>
+ </span>
+ </label>
+% }
+ </td>
+ </tr>
% }
-% }
-
-
- </TABLE>
- <BR><BR>
-% }
-
-
-Order new packages
-<BR><BR>
-
-%my $cust_main = qsearchs('cust_main',{'custnum'=>$custnum});
-%my $agent = qsearchs('agent',{'agentnum'=> $cust_main->agentnum });
-%
-%my %agent_pkgs = map { ( $_->pkgpart => $all_pkg{$_->pkgpart} ) }
-% ( qsearch('type_pkgs',{ typenum => $agent->typenum }),
-% qsearch('part_pkg', { agentnum => $cust_main->agentnum }),
-% );
-%
-%my $count = 0;
-%my $pkgparts = 0;
-
-<TABLE>
- <TR STYLE="background-color: #cccccc;">
- <TH>Qty.</TH>
- <TH COLSPAN="2">Package Description</TH>
- </TR>
-%
-%#foreach my $type_pkgs ( qsearch('type_pkgs',{'typenum'=> $agent->typenum }) ) {
-%foreach my $pkgpart ( sort { $agent_pkgs{$a} cmp $agent_pkgs{$b} }
-% keys(%agent_pkgs) ) {
-% $pkgparts++;
-% next unless exists $pkg{$pkgpart}; #skip disabled ones
-% #print qq!<TR>! if ( $count == 0 );
-% my $value = $cgi->param("pkg$pkgpart") || 0;
-%
-
-
- <TR>
- <TD>
- <INPUT TYPE="text" NAME="<% "pkg$pkgpart" %>" VALUE="<% $value %>" SIZE="2" MAXLENGTH="2">
- </TD>
- <TD ALIGN="right"><% $pkgpart %>:</TD>
- <TD><% $pkg{$pkgpart} |h %> - <% $comment{$pkgpart} |h %></TD>
- </TR>
-%
-% $count ++ ;
-% #if ( $count == 2 ) {
-% # print qq!</TR>\n! ;
-% # $count = 0;
-% #}
-%}
-%
-
-
-</TABLE>
-% unless ( $pkgparts ) {
-% my $p2 = popurl(2);
-% my $typenum = $agent->typenum;
-% my $agent_type = qsearchs( 'agent_type', { 'typenum' => $typenum } );
-% my $atype = $agent_type->atype;
-%
-
-
- (No <A HREF="<% $p2 %>browse/part_pkg.cgi">package definitions</A>,
- or agent type
- <A HREF="<% $p2 %>edit/agent_type.cgi?<% $typenum %>"><% $atype %></a>
- is not allowed to purchase any packages.)
-% }
-
-
-<P><INPUT TYPE="submit" VALUE="Order">
-
-</FORM>
+ </tbody>
+</table>
+
+<table style="margin-bottom: 2em;">
+ <thead>
+ <tr style="background-color: #ccc;">
+ <th colspan="3">
+ <% include('/elements/selectize/select-multiple-pkg_class.html',
+ id => 'filter_pkg_class',
+ onchange => 'pkg_class_filter_onchange',
+ ) %>
+ </th>
+ </tr>
+ <tr style="background-color: #ccc;">
+ <th>Qty</th>
+ <th>Class</th>
+ <th style="text-align: left;">Order New Packages</th>
+ </tr>
+ </thead>
+ <tbody>
+% for my $part_pkg ( @part_pkg_enabled ) {
+% my $id = sprintf 'qty_part_pkg[%s]', $part_pkg->pkgpart;
+ <tr data-classnum="<% $part_pkg->classnum %>">
+ <td>
+ <input type="text"
+ name="<% $id %>"
+ id="<% $id %>"
+ value="0"
+ size="2"
+ data-pkgpart="<% $part_pkg->pkgpart %>"
+ data-pkg="<% $part_pkg->pkg %>">
+ </td>
+ <td><% $part_pkg->classname || '(none)' %></td>
+ <td><% $part_pkg->pkg %></td>
+ </tr>
+% }
+ </tbody>
+</table>
+
+<input type="button" role="button" value="Order" onclick="confirm_form();">
+
+</form>
<% include('/elements/footer.html') %>
@@ -118,53 +210,41 @@ Order new packages
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Bulk change customer packages');
-my %pkg = ();
-my %comment = ();
-my %all_pkg = ();
-my %all_comment = ();
-#foreach (qsearch('part_pkg', { 'disabled' => '' })) {
-# $pkg{ $_ -> getfield('pkgpart') } = $_->getfield('pkg');
-# $comment{ $_ -> getfield('pkgpart') } = $_->getfield('comment');
-#}
-foreach (qsearch('part_pkg', {} )) {
- $all_pkg{ $_ -> getfield('pkgpart') } = $_->getfield('pkg');
- $all_comment{ $_ -> getfield('pkgpart') } = $_->custom_comment;
- next if $_->disabled;
- $pkg{ $_ -> getfield('pkgpart') } = $_->getfield('pkg');
- $comment{ $_ -> getfield('pkgpart') } = $_->custom_comment;
-}
+my $custnum = $cgi->param('keywords') || $cgi->param('custnum');
+$custnum =~ /^\d+$/
+ or die "Invalid custnum($custnum)";
-my($custnum, %remove_pkg);
-if ( $cgi->param('error') ) {
- $custnum = $cgi->param('custnum');
- %remove_pkg = map { $_ => 1 } $cgi->param('remove_pkg');
-} else {
- my($query) = $cgi->keywords;
- $query =~ /^(\d+)$/;
- $custnum = $1;
- %remove_pkg = ();
-}
+my $cust_main = qsearchs( cust_main => { custnum => $custnum })
+ or die "Invalid custnum ($custnum)";
-my $p1 = popurl(1);
+my %part_pkg;
+my @part_pkg_enabled;
-my @cust_pkg = qsearch('cust_pkg', { 'custnum' => $custnum, 'cancel' => '' } );
-my @main_pkgs;
-my %supp_pkgs_of; # main pkgnum => arrayref of cust_pkgs
-
-
-foreach my $cust_pkg
- ( sort { $all_pkg{ $a->pkgpart } cmp $all_pkg{ $b->getfield('pkgpart') } }
- @cust_pkg
+for my $part_pkg ( qsearch( part_pkg => {} )) {
+ $part_pkg{ $part_pkg->pkgpart } = $part_pkg;
+ push @part_pkg_enabled, $part_pkg
+ unless $part_pkg->disabled;
+}
+ at part_pkg_enabled =
+ sort { $a->classname cmp $b->classname || $a->pkg cmp $b->pkg }
+ @part_pkg_enabled;
+
+my @cust_pkg;
+my %cust_pkg_supp_of;
+for my $cust_pkg (
+ qsearch(
+ cust_pkg => {
+ custnum => $custnum,
+ cancel => '',
+ }
)
- # XXX does not properly handle recursive supplemental links
-{
+) {
if ( my $main_pkgnum = $cust_pkg->main_pkgnum ) {
- $supp_pkgs_of{$main_pkgnum} ||= [];
- push @{ $supp_pkgs_of{$main_pkgnum} }, $cust_pkg;
+ $cust_pkg_supp_of{ $main_pkgnum } //= [];
+ push @{ $cust_pkg_supp_of{ $main_pkgnum } }, $cust_pkg;
} else {
- push @main_pkgs, $cust_pkg;
- $supp_pkgs_of{$cust_pkg->pkgnum} ||= [];
+ $cust_pkg_supp_of{ $cust_pkg->pkgnum } //= [];
+ push @cust_pkg, $cust_pkg;
}
}
-
</%init>
diff --git a/httemplate/edit/process/cust_pkg.cgi b/httemplate/edit/process/cust_pkg.cgi
index c564c417e..82a9e2375 100755
--- a/httemplate/edit/process/cust_pkg.cgi
+++ b/httemplate/edit/process/cust_pkg.cgi
@@ -5,38 +5,61 @@
<% $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum") %>
% }
<%init>
-
+use Data::Dumper;
+my $DEBUG = 0;
my $curuser = $FS::CurrentUser::CurrentUser;
die "access denied"
unless $curuser->access_right('Bulk change customer packages');
my $error = '';
+my %param = $cgi->Vars;
+
+my $custnum = $param{custnum};
+$error = "Invalid custnum ($custnum)" if $custnum =~ /\D/;
+
+my $locationnum = $param{locationnum};
+$error = "Invalid locationnum ($locationnum)" if $locationnum =~ /\D/;
+
+my @remove_pkgnum =
+ map { $_ =~ /remove_cust_pkg\[(\d+)\]/ ? $1 : () }
+ keys %param;
+
+my @pkgparts;
+for my $k ( keys %param ) {
+ next unless $k =~ /qty_part_pkg\[(\d+)\]/;
+ my $pkgpart = $1;
+ my $qty = $param{$k};
+ $qty =~ s/(^\s+|\s+$)//g;
-#untaint custnum
-$cgi->param('custnum') =~ /^(\d+)$/;
-my $custnum = $1;
-
-my @remove_pkgnums = map {
- /^(\d+)$/ or die "Illegal remove_pkg value!";
- $1;
-} $cgi->param('remove_pkg');
-
-my( $action, $error_redirect ) = ( '', '' );
-my @pkgparts = ();
-
-foreach my $pkgpart ( map /^pkg(\d+)$/ ? $1 : (), $cgi->param ) {
- if ( $cgi->param("pkg$pkgpart") =~ /^(\d+)$/ ) {
- my $num_pkgs = $1;
- while ( $num_pkgs-- ) {
- push @pkgparts,$pkgpart;
- }
- } else {
- $error = "Illegal quantity";
+ warn "k($k) param{k}($param{$k}) pkgpart($pkgpart) qty($qty)\n"
+ if $DEBUG;
+
+ if ( $qty =~ /\D/ ) {
+ $error = "Invalid quantity $qty for pkgpart $pkgpart - please use a number";
last;
}
+
+ next if $qty == 0;
+
+ push ( @pkgparts, $pkgpart ) for ( 1..$qty );
+}
+
+if ( $DEBUG ) {
+ warn Dumper({
+ custnum => $custnum,
+ locationnum => $locationnum,
+ remove_pkgnum => \@remove_pkgnum,
+ pkgparts => \@pkgparts,
+ param => \%param,
+ });
}
-$error ||= FS::cust_pkg::order($custnum,\@pkgparts,\@remove_pkgnums);
+$error ||= FS::cust_pkg::order({
+ custnum => $custnum,
+ pkgparts => \@pkgparts,
+ remove_pkgnum => \@remove_pkgnum,
+ locationnum => $locationnum,
+});
</%init>
diff --git a/httemplate/elements/header-cust_main.html b/httemplate/elements/header-cust_main.html
index c094f950f..f29f32567 100644
--- a/httemplate/elements/header-cust_main.html
+++ b/httemplate/elements/header-cust_main.html
@@ -10,12 +10,12 @@ Examples:
</%doc>
<& /elements/header.html, {
- 'title' => $title,
- 'title_noescape' => $title_noescape,
- #'nobr' => 1,
- 'etc' => $opt{'etc'},
- }
-&>
+ 'title' => $title,
+ 'title_noescape' => $title_noescape,
+ #'nobr' => 1,
+ 'etc' => $opt{'etc'},
+ include_selectize => $opt{include_selectize} ? 1 : 0,
+} &>
% my @part_tag = $cust_main->part_tag;
% if ( $conf->config('cust_tag-location') eq 'top' && @part_tag ) {
commit 0339cd666b4c39ef3772f1d28dc3a5f30f422966
Author: Mitch Jackson <mitch at freeside.biz>
Date: Sun Nov 18 02:46:00 2018 -0500
RT# 32243 Implement Selectize.js library
diff --git a/httemplate/elements/header-full.html b/httemplate/elements/header-full.html
index b459a11cf..08e20c875 100644
--- a/httemplate/elements/header-full.html
+++ b/httemplate/elements/header-full.html
@@ -53,6 +53,11 @@ Example:
<SCRIPT SRC="<% $fsurl %>elements/printtofit.js"></SCRIPT>
% }
% }
+% if ( $include_selectize ) {
+ <script src="<% $fsurl %>elements/selectize/selectize.min.js"></script>
+ <link href="<% $fsurl %>elements/selectize/selectize.css" type="text/css" rel="stylesheet">
+ <link href="<% $fsurl %>elements/selectize/selectize-freeside.css" type="text/css" rel="stylesheet">
+% }
<% include('init_overlib.html') |n %>
<% include('rs_init_object.html') |n %>
<script type="text/javascript" src="<% $fsurl %>elements/topreload.js"></script>
@@ -221,6 +226,7 @@ my( $title, $title_noescape, $menubar, $etc, $head ) = ( '', '', '', '', '' );
my( $nobr, $nocss, $no_jquery ) = ( 0, 0, 0 );
my $mobile;
+my $include_selectize;
if ( ref($_[0]) ) {
my $opt = shift;
@@ -233,6 +239,7 @@ if ( ref($_[0]) ) {
$nocss = $opt->{nocss};
$mobile = $opt->{mobile};
$no_jquery = $opt->{no_jquery};
+ $include_selectize = $opt->{include_selectize} ? 1 : 0;
} else {
($title, $menubar) = ( shift, shift );
$etc = @_ ? shift : ''; #$etc is for things like onLoad= etc.
diff --git a/httemplate/elements/selectize/select-multiple-pkg_class.html b/httemplate/elements/selectize/select-multiple-pkg_class.html
new file mode 100644
index 000000000..10c2163f1
--- /dev/null
+++ b/httemplate/elements/selectize/select-multiple-pkg_class.html
@@ -0,0 +1,46 @@
+<%doc>
+
+ Render a Selectize.js multiple-select to choose from
+ package classes
+
+ Selectize js and css must be included in the page header.
+ Use the include_selectize option on header.html
+
+
+ Parameters:
+ * id - id of the <select> element
+ * name - name of the <select> element
+ * onchange - name of a javascript function
+ * placeholder - Text displayed when no options are selected
+
+</%doc>
+<label for="<% $opt{id} %>" class="selectize-label">Package Classes</label>
+<select id="<% $opt{id} %>" multiple placeholder="<% $opt{placeholder} %>">
+ <option value="">(none)</option>
+% for my $pkg_class ( @pkg_class ) {
+ <option value="<% $pkg_class->classnum %>"><% $pkg_class->classname %></option>
+% }
+</select>
+<script>
+ $('#<% $opt{id} %>').selectize({
+ plugins: ['remove_button'],
+ sortField: 'text',
+ create: false,
+ highlight: true,
+ allowEmptyOption: true,
+ <% $opt{onchange} ? "onChange: $opt{onchange}," : '' %>
+ });
+</script>
+
+<%init>
+
+my %opt = (
+ id => 'selectize-pkg_class',
+ name => 'selectize_pkg_class',
+ placeholder => 'Filter Package Classes',
+ @_
+);
+
+my @pkg_class = qsearch( pkg_class => { disabled => '' } );
+
+</%init>
\ No newline at end of file
diff --git a/httemplate/elements/selectize/selectize-freeside.css b/httemplate/elements/selectize/selectize-freeside.css
new file mode 100644
index 000000000..298c4a03b
--- /dev/null
+++ b/httemplate/elements/selectize/selectize-freeside.css
@@ -0,0 +1,37 @@
+/**
+* Freeside CSS theme overrides for selectize.js
+*
+*/
+
+.selectize-label {
+ display: none !important;
+}
+
+.selectize-input {
+ border-radius: 0 !important;
+ padding: 1px !important;
+ display: inline-block;
+ width: 250px;
+ text-align: left !important;
+}
+
+.selectize-input .item {
+ margin: 2px !important;
+ text-align: left !important;
+}
+
+.selectize-input .optgroup-header {
+ font-weight: bold;
+ background-color: #eee;
+ border-bottom: solid 1px #ccc;
+ text-align: left !important;
+}
+
+.selectize-dropdown .option {
+ text-align: left !important;
+}
+
+.selectize-input .optgroup .option {
+ padding-left: 1em;
+ text-align: left !important;
+}
diff --git a/httemplate/elements/selectize/selectize.css b/httemplate/elements/selectize/selectize.css
new file mode 100644
index 000000000..3ec90ad0e
--- /dev/null
+++ b/httemplate/elements/selectize/selectize.css
@@ -0,0 +1,333 @@
+/**
+ * selectize.css (v0.12.6)
+ * Copyright (c) 2013–2015 Brian Reavis & contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
+ * file except in compliance with the License. You may obtain a copy of the License at:
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
+ * ANY KIND, either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ *
+ * @author Brian Reavis <brian at thirdroute.com>
+ */
+
+.selectize-control.plugin-drag_drop.multi > .selectize-input > div.ui-sortable-placeholder {
+ visibility: visible !important;
+ background: #f2f2f2 !important;
+ background: rgba(0, 0, 0, 0.06) !important;
+ border: 0 none !important;
+ -webkit-box-shadow: inset 0 0 12px 4px #fff;
+ box-shadow: inset 0 0 12px 4px #fff;
+}
+.selectize-control.plugin-drag_drop .ui-sortable-placeholder::after {
+ content: '!';
+ visibility: hidden;
+}
+.selectize-control.plugin-drag_drop .ui-sortable-helper {
+ -webkit-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
+ box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
+}
+.selectize-dropdown-header {
+ position: relative;
+ padding: 5px 8px;
+ border-bottom: 1px solid #d0d0d0;
+ background: #f8f8f8;
+ -webkit-border-radius: 3px 3px 0 0;
+ -moz-border-radius: 3px 3px 0 0;
+ border-radius: 3px 3px 0 0;
+}
+.selectize-dropdown-header-close {
+ position: absolute;
+ right: 8px;
+ top: 50%;
+ color: #303030;
+ opacity: 0.4;
+ margin-top: -12px;
+ line-height: 20px;
+ font-size: 20px !important;
+}
+.selectize-dropdown-header-close:hover {
+ color: #000000;
+}
+.selectize-dropdown.plugin-optgroup_columns .optgroup {
+ border-right: 1px solid #f2f2f2;
+ border-top: 0 none;
+ float: left;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+.selectize-dropdown.plugin-optgroup_columns .optgroup:last-child {
+ border-right: 0 none;
+}
+.selectize-dropdown.plugin-optgroup_columns .optgroup:before {
+ display: none;
+}
+.selectize-dropdown.plugin-optgroup_columns .optgroup-header {
+ border-top: 0 none;
+}
+.selectize-control.plugin-remove_button [data-value] {
+ position: relative;
+ padding-right: 24px !important;
+}
+.selectize-control.plugin-remove_button [data-value] .remove {
+ z-index: 1;
+ /* fixes ie bug (see #392) */
+ position: absolute;
+ top: 0;
+ right: 0;
+ bottom: 0;
+ width: 17px;
+ text-align: center;
+ font-weight: bold;
+ font-size: 12px;
+ color: inherit;
+ text-decoration: none;
+ vertical-align: middle;
+ display: inline-block;
+ padding: 2px 0 0 0;
+ border-left: 1px solid #d0d0d0;
+ -webkit-border-radius: 0 2px 2px 0;
+ -moz-border-radius: 0 2px 2px 0;
+ border-radius: 0 2px 2px 0;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+.selectize-control.plugin-remove_button [data-value] .remove:hover {
+ background: rgba(0, 0, 0, 0.05);
+}
+.selectize-control.plugin-remove_button [data-value].active .remove {
+ border-left-color: #cacaca;
+}
+.selectize-control.plugin-remove_button .disabled [data-value] .remove:hover {
+ background: none;
+}
+.selectize-control.plugin-remove_button .disabled [data-value] .remove {
+ border-left-color: #ffffff;
+}
+.selectize-control.plugin-remove_button .remove-single {
+ position: absolute;
+ right: 0;
+ top: 0;
+ font-size: 23px;
+}
+.selectize-control {
+ position: relative;
+}
+.selectize-dropdown,
+.selectize-input,
+.selectize-input input {
+ color: #303030;
+ font-family: inherit;
+ font-size: 13px;
+ line-height: 18px;
+ -webkit-font-smoothing: inherit;
+}
+.selectize-input,
+.selectize-control.single .selectize-input.input-active {
+ background: #fff;
+ cursor: text;
+ display: inline-block;
+}
+.selectize-input {
+ border: 1px solid #d0d0d0;
+ padding: 8px 8px;
+ display: inline-block;
+ width: 100%;
+ overflow: hidden;
+ position: relative;
+ z-index: 1;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+ -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.1);
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.1);
+ -webkit-border-radius: 3px;
+ -moz-border-radius: 3px;
+ border-radius: 3px;
+}
+.selectize-control.multi .selectize-input.has-items {
+ padding: 6px 8px 3px;
+}
+.selectize-input.full {
+ background-color: #fff;
+}
+.selectize-input.disabled,
+.selectize-input.disabled * {
+ cursor: default !important;
+}
+.selectize-input.focus {
+ -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15);
+ box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15);
+}
+.selectize-input.dropdown-active {
+ -webkit-border-radius: 3px 3px 0 0;
+ -moz-border-radius: 3px 3px 0 0;
+ border-radius: 3px 3px 0 0;
+}
+.selectize-input > * {
+ vertical-align: baseline;
+ display: -moz-inline-stack;
+ display: inline-block;
+ zoom: 1;
+ *display: inline;
+}
+.selectize-control.multi .selectize-input > div {
+ cursor: pointer;
+ margin: 0 3px 3px 0;
+ padding: 2px 6px;
+ background: #f2f2f2;
+ color: #303030;
+ border: 0 solid #d0d0d0;
+}
+.selectize-control.multi .selectize-input > div.active {
+ background: #e8e8e8;
+ color: #303030;
+ border: 0 solid #cacaca;
+}
+.selectize-control.multi .selectize-input.disabled > div,
+.selectize-control.multi .selectize-input.disabled > div.active {
+ color: #7d7d7d;
+ background: #ffffff;
+ border: 0 solid #ffffff;
+}
+.selectize-input > input {
+ display: inline-block !important;
+ padding: 0 !important;
+ min-height: 0 !important;
+ max-height: none !important;
+ max-width: 100% !important;
+ margin: 0 2px 0 0 !important;
+ text-indent: 0 !important;
+ border: 0 none !important;
+ background: none !important;
+ line-height: inherit !important;
+ -webkit-user-select: auto !important;
+ -webkit-box-shadow: none !important;
+ box-shadow: none !important;
+}
+.selectize-input > input::-ms-clear {
+ display: none;
+}
+.selectize-input > input:focus {
+ outline: none !important;
+}
+.selectize-input::after {
+ content: ' ';
+ display: block;
+ clear: left;
+}
+.selectize-input.dropdown-active::before {
+ content: ' ';
+ display: block;
+ position: absolute;
+ background: #f0f0f0;
+ height: 1px;
+ bottom: 0;
+ left: 0;
+ right: 0;
+}
+.selectize-dropdown {
+ position: absolute;
+ z-index: 10;
+ border: 1px solid #d0d0d0;
+ background: #fff;
+ margin: -1px 0 0 0;
+ border-top: 0 none;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+ -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
+ -webkit-border-radius: 0 0 3px 3px;
+ -moz-border-radius: 0 0 3px 3px;
+ border-radius: 0 0 3px 3px;
+}
+.selectize-dropdown [data-selectable] {
+ cursor: pointer;
+ overflow: hidden;
+}
+.selectize-dropdown [data-selectable] .highlight {
+ background: rgba(125, 168, 208, 0.2);
+ -webkit-border-radius: 1px;
+ -moz-border-radius: 1px;
+ border-radius: 1px;
+}
+.selectize-dropdown .option,
+.selectize-dropdown .optgroup-header {
+ padding: 5px 8px;
+}
+.selectize-dropdown .option,
+.selectize-dropdown [data-disabled],
+.selectize-dropdown [data-disabled] [data-selectable].option {
+ cursor: inherit;
+ opacity: 0.5;
+}
+.selectize-dropdown [data-selectable].option {
+ opacity: 1;
+}
+.selectize-dropdown .optgroup:first-child .optgroup-header {
+ border-top: 0 none;
+}
+.selectize-dropdown .optgroup-header {
+ color: #303030;
+ background: #fff;
+ cursor: default;
+}
+.selectize-dropdown .active {
+ background-color: #f5fafd;
+ color: #495c68;
+}
+.selectize-dropdown .active.create {
+ color: #495c68;
+}
+.selectize-dropdown .create {
+ color: rgba(48, 48, 48, 0.5);
+}
+.selectize-dropdown-content {
+ overflow-y: auto;
+ overflow-x: hidden;
+ max-height: 200px;
+ -webkit-overflow-scrolling: touch;
+}
+.selectize-control.single .selectize-input,
+.selectize-control.single .selectize-input input {
+ cursor: pointer;
+}
+.selectize-control.single .selectize-input.input-active,
+.selectize-control.single .selectize-input.input-active input {
+ cursor: text;
+}
+.selectize-control.single .selectize-input:after {
+ content: ' ';
+ display: block;
+ position: absolute;
+ top: 50%;
+ right: 15px;
+ margin-top: -3px;
+ width: 0;
+ height: 0;
+ border-style: solid;
+ border-width: 5px 5px 0 5px;
+ border-color: #808080 transparent transparent transparent;
+}
+.selectize-control.single .selectize-input.dropdown-active:after {
+ margin-top: -4px;
+ border-width: 0 5px 5px 5px;
+ border-color: transparent transparent #808080 transparent;
+}
+.selectize-control.rtl.single .selectize-input:after {
+ left: 15px;
+ right: auto;
+}
+.selectize-control.rtl .selectize-input > input {
+ margin: 0 4px 0 -2px !important;
+}
+.selectize-control .selectize-input.disabled {
+ opacity: 0.5;
+ background-color: #fafafa;
+}
diff --git a/httemplate/elements/selectize/selectize.min.js b/httemplate/elements/selectize/selectize.min.js
new file mode 100644
index 000000000..43046c90d
--- /dev/null
+++ b/httemplate/elements/selectize/selectize.min.js
@@ -0,0 +1,4 @@
+/*! selectize.js - v0.12.6 | https://github.com/selectize/selectize.js | Apache License (v2) */
+
+!function(a,b){"function"==typeof define&&define.amd?define("sifter",b):"object"==typeof exports?module.exports=b():a.Sifter=b()}(this,function(){var a=function(a,b){this.items=a,this.settings=b||{diacritics:!0}};a.prototype.tokenize=function(a){if(!(a=e(String(a||"").toLowerCase()))||!a.length)return[];var b,c,d,g,i=[],j=a.split(/ +/);for(b=0,c=j.length;b<c;b++){if(d=f(j[b]),this.settings.diacritics)for(g in h)h.hasOwnProperty(g)&&(d=d.replace(new RegExp(g,"g"),h[g]));i.push({string:j[b],regex:new RegExp(d,"i")})}return i},a.prototype.iterator=function(a,b){var c;c=g(a)?Array.prototype.forEach||function(a){for(var b=0,c=this.length;b<c;b++)a(this[b],b,this)}:function(a){for(var b in this)this.hasOwnProperty(b)&&a(this[b],b,this)},c.apply(a,[b])},a.prototype.getScoreFunction=function(a,b){var c,e,f,g,h;c=this,a=c.prepareSearch(a,b),f=a.tokens,e=a.options.fields,g=f.length,h=a.options.nesting;var i=function(a,b){var c,d;return a?(a=String(a||""),-1===(d=a.search(b.regex))?0:(c=b.stri
ng.length/a.length,0===d&&(c+=.5),c)):0},j=function(){var a=e.length;return a?1===a?function(a,b){return i(d(b,e[0],h),a)}:function(b,c){for(var f=0,g=0;f<a;f++)g+=i(d(c,e[f],h),b);return g/a}:function(){return 0}}();return g?1===g?function(a){return j(f[0],a)}:"and"===a.options.conjunction?function(a){for(var b,c=0,d=0;c<g;c++){if((b=j(f[c],a))<=0)return 0;d+=b}return d/g}:function(a){for(var b=0,c=0;b<g;b++)c+=j(f[b],a);return c/g}:function(){return 0}},a.prototype.getSortFunction=function(a,c){var e,f,g,h,i,j,k,l,m,n,o;if(g=this,a=g.prepareSearch(a,c),o=!a.query&&c.sort_empty||c.sort,m=function(a,b){return"$score"===a?b.score:d(g.items[b.id],a,c.nesting)},i=[],o)for(e=0,f=o.length;e<f;e++)(a.query||"$score"!==o[e].field)&&i.push(o[e]);if(a.query){for(n=!0,e=0,f=i.length;e<f;e++)if("$score"===i[e].field){n=!1;break}n&&i.unshift({field:"$score",direction:"desc"})}else for(e=0,f=i.length;e<f;e++)if("$score"===i[e].field){i.splice(e,1);break}for(l=[],e=0,f=i.length;e<f;e++)l.push("de
sc"===i[e].direction?-1:1);return j=i.length,j?1===j?(h=i[0].field,k=l[0],function(a,c){return k*b(m(h,a),m(h,c))}):function(a,c){var d,e,f;for(d=0;d<j;d++)if(f=i[d].field,e=l[d]*b(m(f,a),m(f,c)))return e;return 0}:null},a.prototype.prepareSearch=function(a,b){if("object"==typeof a)return a;b=c({},b);var d=b.fields,e=b.sort,f=b.sort_empty;return d&&!g(d)&&(b.fields=[d]),e&&!g(e)&&(b.sort=[e]),f&&!g(f)&&(b.sort_empty=[f]),{options:b,query:String(a||"").toLowerCase(),tokens:this.tokenize(a),total:0,items:[]}},a.prototype.search=function(a,b){var c,d,e,f,g=this;return d=this.prepareSearch(a,b),b=d.options,a=d.query,f=b.score||g.getScoreFunction(d),a.length?g.iterator(g.items,function(a,e){c=f(a),(!1===b.filter||c>0)&&d.items.push({score:c,id:e})}):g.iterator(g.items,function(a,b){d.items.push({score:1,id:b})}),e=g.getSortFunction(d,b),e&&d.items.sort(e),d.total=d.items.length,"number"==typeof b.limit&&(d.items=d.items.slice(0,b.limit)),d};var b=function(a,b){return"number"==typeof a&&"
number"==typeof b?a>b?1:a<b?-1:0:(a=i(String(a||"")),b=i(String(b||"")),a>b?1:b>a?-1:0)},c=function(a,b){var c,d,e,f;for(c=1,d=arguments.length;c<d;c++)if(f=arguments[c])for(e in f)f.hasOwnProperty(e)&&(a[e]=f[e]);return a},d=function(a,b,c){if(a&&b){if(!c)return a[b];for(var d=b.split(".");d.length&&(a=a[d.shift()]););return a}},e=function(a){return(a+"").replace(/^\s+|\s+$|/g,"")},f=function(a){return(a+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")},g=Array.isArray||"undefined"!=typeof $&&$.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)},h={a:"[aḀḁĂăÂâǍǎȺⱥȦȧẠạÄäÀàÁáĀāÃãÅåąĄÃąĄ]",b:"[b␢βΒB฿𐌁ᛒ]",c:"[cĆćĈĉČčĊċC̄c̄ÇçḈḉȻȼƇƈɕᴄCc]",d:"[dĎďḊḋḐḑḌḍḒḓḎḏĐđD̦d̦ƉɖƊɗƋƌᵭᶁᶑȡᴅDdð]",e:"[eÉéÈèÊêḘḙĚěĔĕẼẽḚḛẺẻĖėËëĒēȨȩĘęᶒɆɇȄȅẾếỀềỄễỂểḜḝḖḗḔḕȆȇẸẹỆệⱸᴇEeɘǝƏƐε]",f:"[fƑ
Æá¸á¸]",g:"[gÉ¢â²Ç¤Ç¥ÄÄÄÄĢģÆÉ Ä Ä¡]",h:"[hĤĥĦħḨḩáºáºá¸¤á¸¥á¸¢á¸£É¦Ê°Ç¶Æ]",i:"[iÃÃÃìĬÄÃîÇÇÃïḮḯĨĩĮįĪīá»á»ÈÈÈÈá»á»á¸¬á¸ÆɨɨÌáµ»á¶Ä°iIıɪIï½]",j:"[jȷĴĵÉÉÊÉʲ]",k:"[kÆÆêêḰḱǨǩḲḳḴḵκϰâ]",l:"[lÅÅĽľĻļĹĺḶḷḸḹḼḽḺḻĿÅȽÆⱠⱡⱢɫɬá¶
ÉÈ´ÊLï½]",n:"[nÅÅǸǹÅÅÃñá¹á¹
Å
Åá¹á¹á¹á¹á¹á¹NÌnÌÆÉ²È Æáµ°á¶É³ÈµÉ´ï¼®ï½ÅÅ]",o:"[oÃøÃöÃóÃòÃôÇÇÅÅÅÅȮȯá»á»ÆÉµÆ Æ¡á»á»ÅÅÃõǪǫÈÈÕÖ
]",p:"[pá¹á¹á¹á¹â±£áµ½Æ¤Æ¥áµ±]",q:"[qêêÊ ÉÉêêqÌ]",r:"[rÅÅÉÉÅÅÅÅá¹á¹ÈÈÈÈá¹á¹â±¤É½]",s:"[sÅÅṠṡṢṣê¨ê©ÅÅÅ Å¡ÅÅÈÈSÌsÌ]",t:"[tŤťṪṫŢţṬá¹Æ®ÊÈÈṰṱṮṯƬÆ]",u:"[uŬÅÉÊỤụÃüÃúÃùÃûÇÇŰűŬÅƯưỦủŪūŨũŲųÈÈâª]",v:"[vṼṽṾṿƲÊêêâ±±Ê]",w:"[wáºáºáºáºÅ´Åµáºáº
áºáºáºáº]",x:"[xáºáºáºáºÏ]",y:"[yÃýỲỳŶŷŸÿỸỹáºáºá»´á»µÉÉƳƴ]",z:"[zŹźáºáºÅ½Å¾Å»Å¼áº
áºáºáºÆµÆ¶]"},i=function(){var a,b,c,d,e="",f={};for(c in h)if(h.hasOwnProperty(c))for(d=h[c].substring(2,h[c].length-1),e+=d,a=0,b=d.length;a<b;a++)f[d.charAt(a)]=c;var g=new RegExp("["+e+"]","g");return function(a){return a.replace(g,function(a){return f[a]}).toLowerCase()}}();return a}),function(a,b){"function"==typeof define&&define.amd?define("microplugin",b):"object"==typeof exports?module.exports=b():a.MicroPlugin=b()}(this,function(){var a={};a.mixin=function(a){a.plugins={},a.prototype.initializePlugins=function(a){var c,d,e,f=this,g=[];if(f.plugins={names:[],settings:{},requested:{},loaded:{}},b.isArray(a))for(c=0,d=a.length;c<d;c++)"string"==typeof a[c]?g.push(a[c]):(f.plugins.settings[a[c].name]=a[c].options,g.push(a[c].name));else if(a)for(e in a)a.hasOwnProperty(e)&&(f.plugins.settings[e]=a[e],g.push(e));for(;g.length;)f.require(g.shift())},a.prototype.loadPlugin=function(b){var c=this,d=c.plugins,e=a.plugins[b];if(!a.plugins.hasOwnProperty(b))throw new Error('Unab
le to find "'+b+'" plugin');d.requested[b]=!0,d.loaded[b]=e.fn.apply(c,[c.plugins.settings[b]||{}]),d.names.push(b)},a.prototype.require=function(a){var b=this,c=b.plugins;if(!b.plugins.loaded.hasOwnProperty(a)){if(c.requested[a])throw new Error('Plugin has circular dependency ("'+a+'")');b.loadPlugin(a)}return c.loaded[a]},a.define=function(b,c){a.plugins[b]={name:b,fn:c}}};var b={isArray:Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)}};return a}),function(a,b){"function"==typeof define&&define.amd?define("selectize",["jquery","sifter","microplugin"],b):"object"==typeof exports?module.exports=b(require("jquery"),require("sifter"),require("microplugin")):a.Selectize=b(a.jQuery,a.Sifter,a.MicroPlugin)}(this,function(a,b,c){"use strict";var d=function(a,b){if("string"!=typeof b||b.length){var c="string"==typeof b?new RegExp(b,"i"):b,d=function(a){var b=0;if(3===a.nodeType){var e=a.data.search(c);if(e>=0&&a.data.length>0){var f=a.data.match(c),g=d
ocument.createElement("span");g.className="highlight";var h=a.splitText(e),i=(h.splitText(f[0].length),h.cloneNode(!0));g.appendChild(i),h.parentNode.replaceChild(g,h),b=1}}else if(1===a.nodeType&&a.childNodes&&!/(script|style)/i.test(a.tagName)&&("highlight"!==a.className||"SPAN"!==a.tagName))for(var j=0;j<a.childNodes.length;++j)j+=d(a.childNodes[j]);return b};return a.each(function(){d(this)})}};a.fn.removeHighlight=function(){return this.find("span.highlight").each(function(){this.parentNode.firstChild.nodeName;var a=this.parentNode;a.replaceChild(this.firstChild,this),a.normalize()}).end()};var e=function(){};e.prototype={on:function(a,b){this._events=this._events||{},this._events[a]=this._events[a]||[],this._events[a].push(b)},off:function(a,b){var c=arguments.length;return 0===c?delete this._events:1===c?delete this._events[a]:(this._events=this._events||{},void(a in this._events!=!1&&this._events[a].splice(this._events[a].indexOf(b),1)))},trigger:function(a){if(this._events=
this._events||{},a in this._events!=!1)for(var b=0;b<this._events[a].length;b++)this._events[a][b].apply(this,Array.prototype.slice.call(arguments,1))}},e.mixin=function(a){for(var b=["on","off","trigger"],c=0;c<b.length;c++)a.prototype[b[c]]=e.prototype[b[c]]};var f=/Mac/.test(navigator.userAgent),g=f?91:17,h=f?18:17,i=!/android/i.test(window.navigator.userAgent)&&!!document.createElement("input").validity,j=function(a){return void 0!==a},k=function(a){return void 0===a||null===a?null:"boolean"==typeof a?a?"1":"0":a+""},l=function(a){return(a+"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")},m={};m.before=function(a,b,c){var d=a[b];a[b]=function(){return c.apply(a,arguments),d.apply(a,arguments)}},m.after=function(a,b,c){var d=a[b];a[b]=function(){var b=d.apply(a,arguments);return c.apply(a,arguments),b}};var n=function(a){var b=!1;return function(){b||(b=!0,a.apply(this,arguments))}},o=function(a,b){var c;return function(){var d=this,e=arg
uments;window.clearTimeout(c),c=window.setTimeout(function(){a.apply(d,e)},b)}},p=function(a,b,c){var d,e=a.trigger,f={};a.trigger=function(){var c=arguments[0];if(-1===b.indexOf(c))return e.apply(a,arguments);f[c]=arguments},c.apply(a,[]),a.trigger=e;for(d in f)f.hasOwnProperty(d)&&e.apply(a,f[d])},q=function(a,b,c,d){a.on(b,c,function(b){for(var c=b.target;c&&c.parentNode!==a[0];)c=c.parentNode;return b.currentTarget=c,d.apply(this,[b])})},r=function(a){var b={};if("selectionStart"in a)b.start=a.selectionStart,b.length=a.selectionEnd-b.start;else if(document.selection){a.focus();var c=document.selection.createRange(),d=document.selection.createRange().text.length;c.moveStart("character",-a.value.length),b.start=c.text.length-d,b.length=d}return b},s=function(a,b,c){var d,e,f={};if(c)for(d=0,e=c.length;d<e;d++)f[c[d]]=a.css(c[d]);else f=a.css();b.css(f)},t=function(b,c){return b?(w.$testInput||(w.$testInput=a("<span />").css({position:"absolute",top:-99999,left:-99999,width:"auto",
padding:0,whiteSpace:"pre"}).appendTo("body")),w.$testInput.text(b),s(c,w.$testInput,["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"]),w.$testInput.width()):0},u=function(a){var b=null,c=function(c,d){var e,f,g,h,i,j,k,l;c=c||window.event||{},d=d||{},c.metaKey||c.altKey||(d.force||!1!==a.data("grow"))&&(e=a.val(),c.type&&"keydown"===c.type.toLowerCase()&&(f=c.keyCode,g=f>=48&&f<=57||f>=65&&f<=90||f>=96&&f<=111||f>=186&&f<=222||32===f,46===f||8===f?(l=r(a[0]),l.length?e=e.substring(0,l.start)+e.substring(l.start+l.length):8===f&&l.start?e=e.substring(0,l.start-1)+e.substring(l.start+1):46===f&&void 0!==l.start&&(e=e.substring(0,l.start)+e.substring(l.start+1))):g&&(j=c.shiftKey,k=String.fromCharCode(c.keyCode),k=j?k.toUpperCase():k.toLowerCase(),e+=k)),h=a.attr("placeholder"),!e&&h&&(e=h),(i=t(e,a)+4)!==b&&(b=i,a.width(i),a.triggerHandler("resize")))};a.on("keydown keyup update blur",c),c()},v=function(a){var b=document.createElement("div");return b.appendChild(
a.cloneNode(!0)),b.innerHTML},w=function(c,d){var e,f,g,h,i=this;h=c[0],h.selectize=i;var j=window.getComputedStyle&&window.getComputedStyle(h,null);if(g=j?j.getPropertyValue("direction"):h.currentStyle&&h.currentStyle.direction,g=g||c.parents("[dir]:first").attr("dir")||"",a.extend(i,{order:0,settings:d,$input:c,tabIndex:c.attr("tabindex")||"",tagType:"select"===h.tagName.toLowerCase()?1:2,rtl:/rtl/i.test(g),eventNS:".selectize"+ ++w.count,highlightedValue:null,isBlurring:!1,isOpen:!1,isDisabled:!1,isRequired:c.is("[required]"),isInvalid:!1,isLocked:!1,isFocused:!1,isInputHidden:!1,isSetup:!1,isShiftDown:!1,isCmdDown:!1,isCtrlDown:!1,ignoreFocus:!1,ignoreBlur:!1,ignoreHover:!1,hasOptions:!1,currentResults:null,lastValue:"",caretPos:0,loading:0,loadedSearches:{},$activeOption:null,$activeItems:[],optgroups:{},options:{},userOptions:{},items:[],renderCache:{},onSearchChange:null===d.loadThrottle?i.onSearchChange:o(i.onSearchChange,d.loadThrottle)}),i.sifter=new b(this.options,{diacri
tics:d.diacritics}),i.settings.options){for(e=0,f=i.settings.options.length;e<f;e++)i.registerOption(i.settings.options[e]);delete i.settings.options}if(i.settings.optgroups){for(e=0,f=i.settings.optgroups.length;e<f;e++)i.registerOptionGroup(i.settings.optgroups[e]);delete i.settings.optgroups}i.settings.mode=i.settings.mode||(1===i.settings.maxItems?"single":"multi"),"boolean"!=typeof i.settings.hideSelected&&(i.settings.hideSelected="multi"===i.settings.mode),i.initializePlugins(i.settings.plugins),i.setupCallbacks(),i.setupTemplates(),i.setup()};return e.mixin(w),void 0!==c?c.mixin(w):function(a,b){b||(b={});console.error("Selectize: "+a),b.explanation&&(console.group&&console.group(),console.error(b.explanation),console.group&&console.groupEnd())}("Dependency MicroPlugin is missing",{explanation:'Make sure you either: (1) are using the "standalone" version of Selectize, or (2) require MicroPlugin before you load Selectize.'}),a.extend(w.prototype,{setup:function(){var b,c,d,e,j
,k,l,m,n,o,p=this,r=p.settings,s=p.eventNS,t=a(window),v=a(document),w=p.$input;if(l=p.settings.mode,m=w.attr("class")||"",b=a("<div>").addClass(r.wrapperClass).addClass(m).addClass(l),c=a("<div>").addClass(r.inputClass).addClass("items").appendTo(b),d=a('<input type="text" autocomplete="off" />').appendTo(c).attr("tabindex",w.is(":disabled")?"-1":p.tabIndex),k=a(r.dropdownParent||b),e=a("<div>").addClass(r.dropdownClass).addClass(l).hide().appendTo(k),j=a("<div>").addClass(r.dropdownContentClass).appendTo(e),(o=w.attr("id"))&&(d.attr("id",o+"-selectized"),a("label[for='"+o+"']").attr("for",o+"-selectized")),p.settings.copyClassesToDropdown&&e.addClass(m),b.css({width:w[0].style.width}),p.plugins.names.length&&(n="plugin-"+p.plugins.names.join(" plugin-"),b.addClass(n),e.addClass(n)),(null===r.maxItems||r.maxItems>1)&&1===p.tagType&&w.attr("multiple","multiple"),p.settings.placeholder&&d.attr("placeholder",r.placeholder),!p.settings.splitOn&&p.settings.delimiter){var x=p.settings.de
limiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&");p.settings.splitOn=new RegExp("\\s*"+x+"+\\s*")}w.attr("autocorrect")&&d.attr("autocorrect",w.attr("autocorrect")),w.attr("autocapitalize")&&d.attr("autocapitalize",w.attr("autocapitalize")),d[0].type=w[0].type,p.$wrapper=b,p.$control=c,p.$control_input=d,p.$dropdown=e,p.$dropdown_content=j,e.on("mouseenter mousedown click","[data-disabled]>[data-selectable]",function(a){a.stopImmediatePropagation()}),e.on("mouseenter","[data-selectable]",function(){return p.onOptionHover.apply(p,arguments)}),e.on("mousedown click","[data-selectable]",function(){return p.onOptionSelect.apply(p,arguments)}),q(c,"mousedown","*:not(input)",function(){return p.onItemSelect.apply(p,arguments)}),u(d),c.on({mousedown:function(){return p.onMouseDown.apply(p,arguments)},click:function(){return p.onClick.apply(p,arguments)}}),d.on({mousedown:function(a){a.stopPropagation()},keydown:function(){return p.onKeyDown.apply(p,arguments)},keyup:function(){return p.onKe
yUp.apply(p,arguments)},keypress:function(){return p.onKeyPress.apply(p,arguments)},resize:function(){p.positionDropdown.apply(p,[])},blur:function(){return p.onBlur.apply(p,arguments)},focus:function(){return p.ignoreBlur=!1,p.onFocus.apply(p,arguments)},paste:function(){return p.onPaste.apply(p,arguments)}}),v.on("keydown"+s,function(a){p.isCmdDown=a[f?"metaKey":"ctrlKey"],p.isCtrlDown=a[f?"altKey":"ctrlKey"],p.isShiftDown=a.shiftKey}),v.on("keyup"+s,function(a){a.keyCode===h&&(p.isCtrlDown=!1),16===a.keyCode&&(p.isShiftDown=!1),a.keyCode===g&&(p.isCmdDown=!1)}),v.on("mousedown"+s,function(a){if(p.isFocused){if(a.target===p.$dropdown[0]||a.target.parentNode===p.$dropdown[0])return!1;p.$control.has(a.target).length||a.target===p.$control[0]||p.blur(a.target)}}),t.on(["scroll"+s,"resize"+s].join(" "),function(){p.isOpen&&p.positionDropdown.apply(p,arguments)}),t.on("mousemove"+s,function(){p.ignoreHover=!1}),this.revertSettings={$children:w.children().detach(),tabindex:w.attr("tabin
dex")},w.attr("tabindex",-1).hide().after(p.$wrapper),a.isArray(r.items)&&(p.setValue(r.items),delete r.items),i&&w.on("invalid"+s,function(a){a.preventDefault(),p.isInvalid=!0,p.refreshState()}),p.updateOriginalInput(),p.refreshItems(),p.refreshState(),p.updatePlaceholder(),p.isSetup=!0,w.is(":disabled")&&p.disable(),p.on("change",this.onChange),w.data("selectize",p),w.addClass("selectized"),p.trigger("initialize"),!0===r.preload&&p.onSearchChange("")},setupTemplates:function(){var b=this,c=b.settings.labelField,d=b.settings.optgroupLabelField,e={optgroup:function(a){return'<div class="optgroup">'+a.html+"</div>"},optgroup_header:function(a,b){return'<div class="optgroup-header">'+b(a[d])+"</div>"},option:function(a,b){return'<div class="option">'+b(a[c])+"</div>"},item:function(a,b){return'<div class="item">'+b(a[c])+"</div>"},option_create:function(a,b){return'<div class="create">Add <strong>'+b(a.input)+"</strong>…</div>"}};b.settings.render=a.extend({},e,b.settings.rende
r)},setupCallbacks:function(){var a,b,c={initialize:"onInitialize",change:"onChange",item_add:"onItemAdd",item_remove:"onItemRemove",clear:"onClear",option_add:"onOptionAdd",option_remove:"onOptionRemove",option_clear:"onOptionClear",optgroup_add:"onOptionGroupAdd",optgroup_remove:"onOptionGroupRemove",optgroup_clear:"onOptionGroupClear",dropdown_open:"onDropdownOpen",dropdown_close:"onDropdownClose",type:"onType",load:"onLoad",focus:"onFocus",blur:"onBlur"};for(a in c)c.hasOwnProperty(a)&&(b=this.settings[c[a]])&&this.on(a,b)},onClick:function(a){var b=this;b.isFocused&&b.isOpen||(b.focus(),a.preventDefault())},onMouseDown:function(b){var c=this,d=b.isDefaultPrevented();a(b.target);if(c.isFocused){if(b.target!==c.$control_input[0])return"single"===c.settings.mode?c.isOpen?c.close():c.open():d||c.setActiveItem(null),!1}else d||window.setTimeout(function(){c.focus()},0)},onChange:function(){this.$input.trigger("change")},onPaste:function(b){var c=this;if(c.isFull()||c.isInputHidden||
c.isLocked)return void b.preventDefault();c.settings.splitOn&&setTimeout(function(){var b=c.$control_input.val();if(b.match(c.settings.splitOn))for(var d=a.trim(b).split(c.settings.splitOn),e=0,f=d.length;e<f;e++)c.createItem(d[e])},0)},onKeyPress:function(a){if(this.isLocked)return a&&a.preventDefault();var b=String.fromCharCode(a.keyCode||a.which);return this.settings.create&&"multi"===this.settings.mode&&b===this.settings.delimiter?(this.createItem(),a.preventDefault(),!1):void 0},onKeyDown:function(a){var b=(a.target,this.$control_input[0],this);if(b.isLocked)return void(9!==a.keyCode&&a.preventDefault());switch(a.keyCode){case 65:if(b.isCmdDown)return void b.selectAll();break;case 27:return void(b.isOpen&&(a.preventDefault(),a.stopPropagation(),b.close()));case 78:if(!a.ctrlKey||a.altKey)break;case 40:if(!b.isOpen&&b.hasOptions)b.open();else if(b.$activeOption){b.ignoreHover=!0;var c=b.getAdjacentOption(b.$activeOption,1);c.length&&b.setActiveOption(c,!0,!0)}return void a.preve
ntDefault();case 80:if(!a.ctrlKey||a.altKey)break;case 38:if(b.$activeOption){b.ignoreHover=!0;var d=b.getAdjacentOption(b.$activeOption,-1);d.length&&b.setActiveOption(d,!0,!0)}return void a.preventDefault();case 13:return void(b.isOpen&&b.$activeOption&&(b.onOptionSelect({currentTarget:b.$activeOption}),a.preventDefault()));case 37:return void b.advanceSelection(-1,a);case 39:return void b.advanceSelection(1,a);case 9:return b.settings.selectOnTab&&b.isOpen&&b.$activeOption&&(b.onOptionSelect({currentTarget:b.$activeOption}),b.isFull()||a.preventDefault()),void(b.settings.create&&b.createItem()&&a.preventDefault());case 8:case 46:return void b.deleteSelection(a)}return!b.isFull()&&!b.isInputHidden||(f?a.metaKey:a.ctrlKey)?void 0:void a.preventDefault()},onKeyUp:function(a){var b=this;if(b.isLocked)return a&&a.preventDefault();var c=b.$control_input.val()||"";b.lastValue!==c&&(b.lastValue=c,b.onSearchChange(c),b.refreshOptions(),b.trigger("type",c))},onSearchChange:function(a){var
b=this,c=b.settings.load;c&&(b.loadedSearches.hasOwnProperty(a)||(b.loadedSearches[a]=!0,b.load(function(d){c.apply(b,[a,d])})))},onFocus:function(a){var b=this,c=b.isFocused;if(b.isDisabled)return b.blur(),a&&a.preventDefault(),!1;b.ignoreFocus||(b.isFocused=!0,"focus"===b.settings.preload&&b.onSearchChange(""),c||b.trigger("focus"),b.$activeItems.length||(b.showInput(),b.setActiveItem(null),b.refreshOptions(!!b.settings.openOnFocus)),b.refreshState())},onBlur:function(a,b){var c=this;if(c.isFocused&&(c.isFocused=!1,!c.ignoreFocus)){if(!c.ignoreBlur&&document.activeElement===c.$dropdown_content[0])return c.ignoreBlur=!0,void c.onFocus(a);var d=function(){c.close(),c.setTextboxValue(""),c.setActiveItem(null),c.setActiveOption(null),c.setCaret(c.items.length),c.refreshState(),b&&b.focus&&b.focus(),c.isBlurring=!1,c.ignoreFocus=!1,c.trigger("blur")};c.isBlurring=!0,c.ignoreFocus=!0,c.settings.create&&c.settings.createOnBlur?c.createItem(null,!1,d):d()}},onOptionHover:function(a){this.
ignoreHover||this.setActiveOption(a.currentTarget,!1)},onOptionSelect:function(b){var c,d,e=this;b.preventDefault&&(b.preventDefault(),b.stopPropagation()),d=a(b.currentTarget),d.hasClass("create")?e.createItem(null,function(){e.settings.closeAfterSelect&&e.close()}):void 0!==(c=d.attr("data-value"))&&(e.lastQuery=null,e.setTextboxValue(""),e.addItem(c),e.settings.closeAfterSelect?e.close():!e.settings.hideSelected&&b.type&&/mouse/.test(b.type)&&e.setActiveOption(e.getOption(c)))},onItemSelect:function(a){var b=this;b.isLocked||"multi"===b.settings.mode&&(a.preventDefault(),b.setActiveItem(a.currentTarget,a))},load:function(a){var b=this,c=b.$wrapper.addClass(b.settings.loadingClass);b.loading++,a.apply(b,[function(a){b.loading=Math.max(b.loading-1,0),a&&a.length&&(b.addOption(a),b.refreshOptions(b.isFocused&&!b.isInputHidden)),b.loading||c.removeClass(b.settings.loadingClass),b.trigger("load",a)}])},setTextboxValue:function(a){var b=this.$control_input;b.val()!==a&&(b.val(a).trigge
rHandler("update"),this.lastValue=a)},getValue:function(){return 1===this.tagType&&this.$input.attr("multiple")?this.items:this.items.join(this.settings.delimiter)},setValue:function(a,b){p(this,b?[]:["change"],function(){this.clear(b),this.addItems(a,b)})},setActiveItem:function(b,c){var d,e,f,g,h,i,j,k,l=this;if("single"!==l.settings.mode){if(b=a(b),!b.length)return a(l.$activeItems).removeClass("active"),l.$activeItems=[],void(l.isFocused&&l.showInput());if("mousedown"===(d=c&&c.type.toLowerCase())&&l.isShiftDown&&l.$activeItems.length){for(k=l.$control.children(".active:last"),g=Array.prototype.indexOf.apply(l.$control[0].childNodes,[k[0]]),h=Array.prototype.indexOf.apply(l.$control[0].childNodes,[b[0]]),g>h&&(j=g,g=h,h=j),e=g;e<=h;e++)i=l.$control[0].childNodes[e],-1===l.$activeItems.indexOf(i)&&(a(i).addClass("active"),l.$activeItems.push(i));c.preventDefault()}else"mousedown"===d&&l.isCtrlDown||"keydown"===d&&this.isShiftDown?b.hasClass("active")?(f=l.$activeItems.indexOf(b[0
]),l.$activeItems.splice(f,1),b.removeClass("active")):l.$activeItems.push(b.addClass("active")[0]):(a(l.$activeItems).removeClass("active"),l.$activeItems=[b.addClass("active")[0]]);l.hideInput(),this.isFocused||l.focus()}},setActiveOption:function(b,c,d){var e,f,g,h,i,k=this;k.$activeOption&&k.$activeOption.removeClass("active"),k.$activeOption=null,b=a(b),b.length&&(k.$activeOption=b.addClass("active"),!c&&j(c)||(e=k.$dropdown_content.height(),f=k.$activeOption.outerHeight(!0),c=k.$dropdown_content.scrollTop()||0,g=k.$activeOption.offset().top-k.$dropdown_content.offset().top+c,h=g,i=g-e+f,g+f>e+c?k.$dropdown_content.stop().animate({scrollTop:i},d?k.settings.scrollDuration:0):g<c&&k.$dropdown_content.stop().animate({scrollTop:h},d?k.settings.scrollDuration:0)))},selectAll:function(){var a=this;"single"!==a.settings.mode&&(a.$activeItems=Array.prototype.slice.apply(a.$control.children(":not(input)").addClass("active")),a.$activeItems.length&&(a.hideInput(),a.close()),a.focus())},h
ideInput:function(){var a=this;a.setTextboxValue(""),a.$control_input.css({opacity:0,position:"absolute",left:a.rtl?1e4:-1e4}),a.isInputHidden=!0},showInput:function(){this.$control_input.css({opacity:1,position:"relative",left:0}),this.isInputHidden=!1},focus:function(){var a=this;a.isDisabled||(a.ignoreFocus=!0,a.$control_input[0].focus(),window.setTimeout(function(){a.ignoreFocus=!1,a.onFocus()},0))},blur:function(a){this.$control_input[0].blur(),this.onBlur(null,a)},getScoreFunction:function(a){return this.sifter.getScoreFunction(a,this.getSearchOptions())},getSearchOptions:function(){var a=this.settings,b=a.sortField;return"string"==typeof b&&(b=[{field:b}]),{fields:a.searchField,conjunction:a.searchConjunction,sort:b,nesting:a.nesting}},search:function(b){var c,d,e,f=this,g=f.settings,h=this.getSearchOptions();if(g.score&&"function"!=typeof(e=f.settings.score.apply(this,[b])))throw new Error('Selectize "score" setting must be a function that returns a function');if(b!==f.lastQ
uery?(f.lastQuery=b,d=f.sifter.search(b,a.extend(h,{score:e})),f.currentResults=d):d=a.extend(!0,{},f.currentResults),g.hideSelected)for(c=d.items.length-1;c>=0;c--)-1!==f.items.indexOf(k(d.items[c].id))&&d.items.splice(c,1);return d},refreshOptions:function(b){var c,e,f,g,h,i,j,l,m,n,o,p,q,r,s,t;void 0===b&&(b=!0);var u=this,w=a.trim(u.$control_input.val()),x=u.search(w),y=u.$dropdown_content,z=u.$activeOption&&k(u.$activeOption.attr("data-value"));for(g=x.items.length,"number"==typeof u.settings.maxOptions&&(g=Math.min(g,u.settings.maxOptions)),h={},i=[],c=0;c<g;c++)for(j=u.options[x.items[c].id],l=u.render("option",j),m=j[u.settings.optgroupField]||"",n=a.isArray(m)?m:[m],e=0,f=n&&n.length;e<f;e++)m=n[e],u.optgroups.hasOwnProperty(m)||(m=""),h.hasOwnProperty(m)||(h[m]=document.createDocumentFragment(),i.push(m)),h[m].appendChild(l);for(this.settings.lockOptgroupOrder&&i.sort(function(a,b){return(u.optgroups[a].$order||0)-(u.optgroups[b].$order||0)}),o=document.createDocumentFragm
ent(),c=0,g=i.length;c<g;c++)m=i[c],u.optgroups.hasOwnProperty(m)&&h[m].childNodes.length?(p=document.createDocumentFragment(),p.appendChild(u.render("optgroup_header",u.optgroups[m])),p.appendChild(h[m]),o.appendChild(u.render("optgroup",a.extend({},u.optgroups[m],{html:v(p),dom:p})))):o.appendChild(h[m]);if(y.html(o),u.settings.highlight&&(y.removeHighlight(),x.query.length&&x.tokens.length))for(c=0,g=x.tokens.length;c<g;c++)d(y,x.tokens[c].regex);if(!u.settings.hideSelected)for(c=0,g=u.items.length;c<g;c++)u.getOption(u.items[c]).addClass("selected");q=u.canCreate(w),q&&(y.prepend(u.render("option_create",{input:w})),t=a(y[0].childNodes[0])),u.hasOptions=x.items.length>0||q,u.hasOptions?(x.items.length>0?(s=z&&u.getOption(z),s&&s.length?r=s:"single"===u.settings.mode&&u.items.length&&(r=u.getOption(u.items[0])),r&&r.length||(r=t&&!u.settings.addPrecedence?u.getAdjacentOption(t,1):y.find("[data-selectable]:first"))):r=t,u.setActiveOption(r),b&&!u.isOpen&&u.open()):(u.setActiveOpti
on(null),b&&u.isOpen&&u.close())},addOption:function(b){var c,d,e,f=this;if(a.isArray(b))for(c=0,d=b.length;c<d;c++)f.addOption(b[c]);else(e=f.registerOption(b))&&(f.userOptions[e]=!0,f.lastQuery=null,f.trigger("option_add",e,b))},registerOption:function(a){var b=k(a[this.settings.valueField]);return void 0!==b&&null!==b&&!this.options.hasOwnProperty(b)&&(a.$order=a.$order||++this.order,this.options[b]=a,b)},registerOptionGroup:function(a){var b=k(a[this.settings.optgroupValueField]);return!!b&&(a.$order=a.$order||++this.order,this.optgroups[b]=a,b)},addOptionGroup:function(a,b){b[this.settings.optgroupValueField]=a,(a=this.registerOptionGroup(b))&&this.trigger("optgroup_add",a,b)},removeOptionGroup:function(a){this.optgroups.hasOwnProperty(a)&&(delete this.optgroups[a],this.renderCache={},this.trigger("optgroup_remove",a))},clearOptionGroups:function(){this.optgroups={},this.renderCache={},this.trigger("optgroup_clear")},updateOption:function(b,c){var d,e,f,g,h,i,j,l=this;if(b=k(b)
,f=k(c[l.settings.valueField]),null!==b&&l.options.hasOwnProperty(b)){if("string"!=typeof f)throw new Error("Value must be set in option data");j=l.options[b].$order,f!==b&&(delete l.options[b],-1!==(g=l.items.indexOf(b))&&l.items.splice(g,1,f)),c.$order=c.$order||j,l.options[f]=c,h=l.renderCache.item,i=l.renderCache.option,h&&(delete h[b],delete h[f]),i&&(delete i[b],delete i[f]),-1!==l.items.indexOf(f)&&(d=l.getItem(b),e=a(l.render("item",c)),d.hasClass("active")&&e.addClass("active"),d.replaceWith(e)),l.lastQuery=null,l.isOpen&&l.refreshOptions(!1)}},removeOption:function(a,b){var c=this;a=k(a);var d=c.renderCache.item,e=c.renderCache.option;d&&delete d[a],e&&delete e[a],delete c.userOptions[a],delete c.options[a],c.lastQuery=null,c.trigger("option_remove",a),c.removeItem(a,b)},clearOptions:function(){var b=this;b.loadedSearches={},b.userOptions={},b.renderCache={};var c=b.options;a.each(b.options,function(a,d){-1==b.items.indexOf(a)&&delete c[a]}),b.options=b.sifter.items=c,b.la
stQuery=null,b.trigger("option_clear")},getOption:function(a){return this.getElementWithValue(a,this.$dropdown_content.find("[data-selectable]"))},getAdjacentOption:function(b,c){var d=this.$dropdown.find("[data-selectable]"),e=d.index(b)+c;return e>=0&&e<d.length?d.eq(e):a()},getElementWithValue:function(b,c){if(void 0!==(b=k(b))&&null!==b)for(var d=0,e=c.length;d<e;d++)if(c[d].getAttribute("data-value")===b)return a(c[d]);return a()},getItem:function(a){return this.getElementWithValue(a,this.$control.children())},addItems:function(b,c){this.buffer=document.createDocumentFragment();for(var d=this.$control[0].childNodes,e=0;e<d.length;e++)this.buffer.appendChild(d[e]);for(var f=a.isArray(b)?b:[b],e=0,g=f.length;e<g;e++)this.isPending=e<g-1,this.addItem(f[e],c);var h=this.$control[0];h.insertBefore(this.buffer,h.firstChild),this.buffer=null},addItem:function(b,c){p(this,c?[]:["change"],function(){var d,e,f,g,h,i=this,j=i.settings.mode;if(b=k(b),-1!==i.items.indexOf(b))return void("si
ngle"===j&&i.close());i.options.hasOwnProperty(b)&&("single"===j&&i.clear(c),"multi"===j&&i.isFull()||(d=a(i.render("item",i.options[b])),h=i.isFull(),i.items.splice(i.caretPos,0,b),i.insertAtCaret(d),(!i.isPending||!h&&i.isFull())&&i.refreshState(),i.isSetup&&(f=i.$dropdown_content.find("[data-selectable]"),i.isPending||(e=i.getOption(b),g=i.getAdjacentOption(e,1).attr("data-value"),i.refreshOptions(i.isFocused&&"single"!==j),g&&i.setActiveOption(i.getOption(g))),!f.length||i.isFull()?i.close():i.isPending||i.positionDropdown(),i.updatePlaceholder(),i.trigger("item_add",b,d),i.isPending||i.updateOriginalInput({silent:c}))))})},removeItem:function(b,c){var d,e,f,g=this;d=b instanceof a?b:g.getItem(b),b=k(d.attr("data-value")),-1!==(e=g.items.indexOf(b))&&(d.remove(),d.hasClass("active")&&(f=g.$activeItems.indexOf(d[0]),g.$activeItems.splice(f,1)),g.items.splice(e,1),g.lastQuery=null,!g.settings.persist&&g.userOptions.hasOwnProperty(b)&&g.removeOption(b,c),e<g.caretPos&&g.setCaret(g.
caretPos-1),g.refreshState(),g.updatePlaceholder(),g.updateOriginalInput({silent:c}),g.positionDropdown(),g.trigger("item_remove",b,d))},createItem:function(b,c){var d=this,e=d.caretPos;b=b||a.trim(d.$control_input.val()||"");var f=arguments[arguments.length-1];if("function"!=typeof f&&(f=function(){}),"boolean"!=typeof c&&(c=!0),!d.canCreate(b))return f(),!1;d.lock();var g="function"==typeof d.settings.create?this.settings.create:function(a){var b={};return b[d.settings.labelField]=a,b[d.settings.valueField]=a,b},h=n(function(a){if(d.unlock(),!a||"object"!=typeof a)return f();var b=k(a[d.settings.valueField]);if("string"!=typeof b)return f();d.setTextboxValue(""),d.addOption(a),d.setCaret(e),d.addItem(b),d.refreshOptions(c&&"single"!==d.settings.mode),f(a)}),i=g.apply(this,[b,h]);return void 0!==i&&h(i),!0},refreshItems:function(){this.lastQuery=null,this.isSetup&&this.addItem(this.items),this.refreshState(),this.updateOriginalInput()},refreshState:function(){this.refreshValiditySt
ate(),this.refreshClasses()},refreshValidityState:function(){if(!this.isRequired)return!1;var a=!this.items.length;this.isInvalid=a,this.$control_input.prop("required",a),this.$input.prop("required",!a)},refreshClasses:function(){var b=this,c=b.isFull(),d=b.isLocked;b.$wrapper.toggleClass("rtl",b.rtl),b.$control.toggleClass("focus",b.isFocused).toggleClass("disabled",b.isDisabled).toggleClass("required",b.isRequired).toggleClass("invalid",b.isInvalid).toggleClass("locked",d).toggleClass("full",c).toggleClass("not-full",!c).toggleClass("input-active",b.isFocused&&!b.isInputHidden).toggleClass("dropdown-active",b.isOpen).toggleClass("has-options",!a.isEmptyObject(b.options)).toggleClass("has-items",b.items.length>0),b.$control_input.data("grow",!c&&!d)},isFull:function(){
+return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems},updateOriginalInput:function(a){var b,c,d,e,f=this;if(a=a||{},1===f.tagType){for(d=[],b=0,c=f.items.length;b<c;b++)e=f.options[f.items[b]][f.settings.labelField]||"",d.push('<option value="'+l(f.items[b])+'" selected="selected">'+l(e)+"</option>");d.length||this.$input.attr("multiple")||d.push('<option value="" selected="selected"></option>'),f.$input.html(d.join(""))}else f.$input.val(f.getValue()),f.$input.attr("value",f.$input.val());f.isSetup&&(a.silent||f.trigger("change",f.$input.val()))},updatePlaceholder:function(){if(this.settings.placeholder){var a=this.$control_input;this.items.length?a.removeAttr("placeholder"):a.attr("placeholder",this.settings.placeholder),a.triggerHandler("update",{force:!0})}},open:function(){var a=this;a.isLocked||a.isOpen||"multi"===a.settings.mode&&a.isFull()||(a.focus(),a.isOpen=!0,a.refreshState(),a.$dropdown.css({visibility:"hidden",display:"block"}),a.positionDrop
down(),a.$dropdown.css({visibility:"visible"}),a.trigger("dropdown_open",a.$dropdown))},close:function(){var a=this,b=a.isOpen;"single"===a.settings.mode&&a.items.length&&(a.hideInput(),a.isBlurring||a.$control_input.blur()),a.isOpen=!1,a.$dropdown.hide(),a.setActiveOption(null),a.refreshState(),b&&a.trigger("dropdown_close",a.$dropdown)},positionDropdown:function(){var a=this.$control,b="body"===this.settings.dropdownParent?a.offset():a.position();b.top+=a.outerHeight(!0),this.$dropdown.css({width:a[0].getBoundingClientRect().width,top:b.top,left:b.left})},clear:function(a){var b=this;b.items.length&&(b.$control.children(":not(input)").remove(),b.items=[],b.lastQuery=null,b.setCaret(0),b.setActiveItem(null),b.updatePlaceholder(),b.updateOriginalInput({silent:a}),b.refreshState(),b.showInput(),b.trigger("clear"))},insertAtCaret:function(a){var b=Math.min(this.caretPos,this.items.length),c=a[0],d=this.buffer||this.$control[0];0===b?d.insertBefore(c,d.firstChild):d.insertBefore(c,d.ch
ildNodes[b]),this.setCaret(b+1)},deleteSelection:function(b){var c,d,e,f,g,h,i,j,k,l=this;if(e=b&&8===b.keyCode?-1:1,f=r(l.$control_input[0]),l.$activeOption&&!l.settings.hideSelected&&(i=l.getAdjacentOption(l.$activeOption,-1).attr("data-value")),g=[],l.$activeItems.length){for(k=l.$control.children(".active:"+(e>0?"last":"first")),h=l.$control.children(":not(input)").index(k),e>0&&h++,c=0,d=l.$activeItems.length;c<d;c++)g.push(a(l.$activeItems[c]).attr("data-value"));b&&(b.preventDefault(),b.stopPropagation())}else(l.isFocused||"single"===l.settings.mode)&&l.items.length&&(e<0&&0===f.start&&0===f.length?g.push(l.items[l.caretPos-1]):e>0&&f.start===l.$control_input.val().length&&g.push(l.items[l.caretPos]));if(!g.length||"function"==typeof l.settings.onDelete&&!1===l.settings.onDelete.apply(l,[g]))return!1;for(void 0!==h&&l.setCaret(h);g.length;)l.removeItem(g.pop());return l.showInput(),l.positionDropdown(),l.refreshOptions(!0),i&&(j=l.getOption(i),j.length&&l.setActiveOption(j)),
!0},advanceSelection:function(a,b){var c,d,e,f,g,h=this;0!==a&&(h.rtl&&(a*=-1),c=a>0?"last":"first",d=r(h.$control_input[0]),h.isFocused&&!h.isInputHidden?(f=h.$control_input.val().length,(a<0?0===d.start&&0===d.length:d.start===f)&&!f&&h.advanceCaret(a,b)):(g=h.$control.children(".active:"+c),g.length&&(e=h.$control.children(":not(input)").index(g),h.setActiveItem(null),h.setCaret(a>0?e+1:e))))},advanceCaret:function(a,b){var c,d,e=this;0!==a&&(c=a>0?"next":"prev",e.isShiftDown?(d=e.$control_input[c](),d.length&&(e.hideInput(),e.setActiveItem(d),b&&b.preventDefault())):e.setCaret(e.caretPos+a))},setCaret:function(b){var c=this;if(b="single"===c.settings.mode?c.items.length:Math.max(0,Math.min(c.items.length,b)),!c.isPending){var d,e,f,g;for(f=c.$control.children(":not(input)"),d=0,e=f.length;d<e;d++)g=a(f[d]).detach(),d<b?c.$control_input.before(g):c.$control.append(g)}c.caretPos=b},lock:function(){this.close(),this.isLocked=!0,this.refreshState()},unlock:function(){this.isLocked=!
1,this.refreshState()},disable:function(){var a=this;a.$input.prop("disabled",!0),a.$control_input.prop("disabled",!0).prop("tabindex",-1),a.isDisabled=!0,a.lock()},enable:function(){var a=this;a.$input.prop("disabled",!1),a.$control_input.prop("disabled",!1).prop("tabindex",a.tabIndex),a.isDisabled=!1,a.unlock()},destroy:function(){var b=this,c=b.eventNS,d=b.revertSettings;b.trigger("destroy"),b.off(),b.$wrapper.remove(),b.$dropdown.remove(),b.$input.html("").append(d.$children).removeAttr("tabindex").removeClass("selectized").attr({tabindex:d.tabindex}).show(),b.$control_input.removeData("grow"),b.$input.removeData("selectize"),0==--w.count&&w.$testInput&&(w.$testInput.remove(),w.$testInput=void 0),a(window).off(c),a(document).off(c),a(document.body).off(c),delete b.$input[0].selectize},render:function(b,c){var d,e,f="",g=!1,h=this;return"option"!==b&&"item"!==b||(d=k(c[h.settings.valueField]),g=!!d),g&&(j(h.renderCache[b])||(h.renderCache[b]={}),h.renderCache[b].hasOwnProperty(d)
)?h.renderCache[b][d]:(f=a(h.settings.render[b].apply(this,[c,l])),"option"===b||"option_create"===b?c[h.settings.disabledField]||f.attr("data-selectable",""):"optgroup"===b&&(e=c[h.settings.optgroupValueField]||"",f.attr("data-group",e),c[h.settings.disabledField]&&f.attr("data-disabled","")),"option"!==b&&"item"!==b||f.attr("data-value",d||""),g&&(h.renderCache[b][d]=f[0]),f[0])},clearCache:function(a){var b=this;void 0===a?b.renderCache={}:delete b.renderCache[a]},canCreate:function(a){var b=this;if(!b.settings.create)return!1;var c=b.settings.createFilter;return a.length&&("function"!=typeof c||c.apply(b,[a]))&&("string"!=typeof c||new RegExp(c).test(a))&&(!(c instanceof RegExp)||c.test(a))}}),w.count=0,w.defaults={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:!1,createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,maxOptions:1e3,maxItems:null,hideSelected:null,addPrecedence:!1,selectOnTab:!1,preload:!1,allowEmptyOption:!1
,closeAfterSelect:!1,scrollDuration:60,loadThrottle:300,loadingClass:"loading",dataAttr:"data-data",optgroupField:"optgroup",valueField:"value",labelField:"text",disabledField:"disabled",optgroupLabelField:"label",optgroupValueField:"value",lockOptgroupOrder:!1,sortField:"$order",searchField:["text"],searchConjunction:"and",mode:null,wrapperClass:"selectize-control",inputClass:"selectize-input",dropdownClass:"selectize-dropdown",dropdownContentClass:"selectize-dropdown-content",dropdownParent:null,copyClassesToDropdown:!0,render:{}},a.fn.selectize=function(b){var c=a.fn.selectize.defaults,d=a.extend({},c,b),e=d.dataAttr,f=d.labelField,g=d.valueField,h=d.disabledField,i=d.optgroupField,j=d.optgroupLabelField,l=d.optgroupValueField,m=function(b,c){var h,i,j,k,l=b.attr(e);if(l)for(c.options=JSON.parse(l),h=0,i=c.options.length;h<i;h++)c.items.push(c.options[h][g]);else{var m=a.trim(b.val()||"");if(!d.allowEmptyOption&&!m.length)return;for(j=m.split(d.delimiter),h=0,i=j.length;h<i;h++)k
={},k[f]=j[h],k[g]=j[h],c.options.push(k);c.items=j}},n=function(b,c){var m,n,o,p,q=c.options,r={},s=function(a){var b=e&&a.attr(e);return"string"==typeof b&&b.length?JSON.parse(b):null},t=function(b,e){b=a(b);var j=k(b.val());if(j||d.allowEmptyOption)if(r.hasOwnProperty(j)){if(e){var l=r[j][i];l?a.isArray(l)?l.push(e):r[j][i]=[l,e]:r[j][i]=e}}else{var m=s(b)||{};m[f]=m[f]||b.text(),m[g]=m[g]||j,m[h]=m[h]||b.prop("disabled"),m[i]=m[i]||e,r[j]=m,q.push(m),b.is(":selected")&&c.items.push(j)}};for(c.maxItems=b.attr("multiple")?null:1,p=b.children(),m=0,n=p.length;m<n;m++)o=p[m].tagName.toLowerCase(),"optgroup"===o?function(b){var d,e,f,g,i;for(b=a(b),f=b.attr("label"),f&&(g=s(b)||{},g[j]=f,g[l]=f,g[h]=b.prop("disabled"),c.optgroups.push(g)),i=a("option",b),d=0,e=i.length;d<e;d++)t(i[d],f)}(p[m]):"option"===o&&t(p[m])};return this.each(function(){if(!this.selectize){var e=a(this),f=this.tagName.toLowerCase(),g=e.attr("placeholder")||e.attr("data-placeholder");g||d.allowEmptyOption||(g=e
.children('option[value=""]').text());var h={placeholder:g,options:[],optgroups:[],items:[]};"select"===f?n(e,h):m(e,h),new w(e,a.extend(!0,{},c,h,b))}})},a.fn.selectize.defaults=w.defaults,a.fn.selectize.support={validity:i},w.define("drag_drop",function(b){if(!a.fn.sortable)throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".');if("multi"===this.settings.mode){var c=this;c.lock=function(){var a=c.lock;return function(){var b=c.$control.data("sortable");return b&&b.disable(),a.apply(c,arguments)}}(),c.unlock=function(){var a=c.unlock;return function(){var b=c.$control.data("sortable");return b&&b.enable(),a.apply(c,arguments)}}(),c.setup=function(){var b=c.setup;return function(){b.apply(this,arguments);var d=c.$control.sortable({items:"[data-value]",forcePlaceholderSize:!0,disabled:c.isLocked,start:function(a,b){b.placeholder.css("width",b.helper.css("width")),d.css({overflow:"visible"})},stop:function(){d.css({overflow:"hidden"});var b=c.$activeItems?c.$activeIt
ems.slice():null,e=[];d.children("[data-value]").each(function(){e.push(a(this).attr("data-value"))}),c.setValue(e),c.setActiveItem(b)}})}}()}}),w.define("dropdown_header",function(b){var c=this;b=a.extend({title:"Untitled",headerClass:"selectize-dropdown-header",titleRowClass:"selectize-dropdown-header-title",labelClass:"selectize-dropdown-header-label",closeClass:"selectize-dropdown-header-close",html:function(a){return'<div class="'+a.headerClass+'"><div class="'+a.titleRowClass+'"><span class="'+a.labelClass+'">'+a.title+'</span><a href="javascript:void(0)" class="'+a.closeClass+'">×</a></div></div>'}},b),c.setup=function(){var d=c.setup;return function(){d.apply(c,arguments),c.$dropdown_header=a(b.html(b)),c.$dropdown.prepend(c.$dropdown_header)}}()}),w.define("optgroup_columns",function(b){var c=this;b=a.extend({equalizeWidth:!0,equalizeHeight:!0},b),this.getAdjacentOption=function(b,c){var d=b.closest("[data-group]").find("[data-selectable]"),e=d.index(b)+c;return e>=0&
&e<d.length?d.eq(e):a()},this.onKeyDown=function(){var a=c.onKeyDown;return function(b){var d,e,f,g;return!this.isOpen||37!==b.keyCode&&39!==b.keyCode?a.apply(this,arguments):(c.ignoreHover=!0,g=this.$activeOption.closest("[data-group]"),d=g.find("[data-selectable]").index(this.$activeOption),g=37===b.keyCode?g.prev("[data-group]"):g.next("[data-group]"),f=g.find("[data-selectable]"),e=f.eq(Math.min(f.length-1,d)),void(e.length&&this.setActiveOption(e)))}}();var d=function(){var a,b=d.width,c=document;return void 0===b&&(a=c.createElement("div"),a.innerHTML='<div style="width:50px;height:50px;position:absolute;left:-50px;top:-50px;overflow:auto;"><div style="width:1px;height:100px;"></div></div>',a=a.firstChild,c.body.appendChild(a),b=d.width=a.offsetWidth-a.clientWidth,c.body.removeChild(a)),b},e=function(){var e,f,g,h,i,j,k;if(k=a("[data-group]",c.$dropdown_content),(f=k.length)&&c.$dropdown_content.width()){if(b.equalizeHeight){for(g=0,e=0;e<f;e++)g=Math.max(g,k.eq(e).height());k
.css({height:g})}b.equalizeWidth&&(j=c.$dropdown_content.innerWidth()-d(),h=Math.round(j/f),k.css({width:h}),f>1&&(i=j-h*(f-1),k.eq(f-1).css({width:i})))}};(b.equalizeHeight||b.equalizeWidth)&&(m.after(this,"positionDropdown",e),m.after(this,"refreshOptions",e))}),w.define("remove_button",function(b){b=a.extend({label:"×",title:"Remove",className:"remove",append:!0},b);if("single"===this.settings.mode)return void function(b,c){c.className="remove-single";var d=b,e='<a href="javascript:void(0)" class="'+c.className+'" tabindex="-1" title="'+l(c.title)+'">'+c.label+"</a>",f=function(b,c){return a("<span>").append(b).append(c)};b.setup=function(){var g=d.setup;return function(){if(c.append){var h=a(d.$input.context).attr("id"),i=(a("#"+h),d.settings.render.item);d.settings.render.item=function(a){return f(i.apply(b,arguments),e)}}g.apply(b,arguments),b.$control.on("click","."+c.className,function(a){a.preventDefault(),d.isLocked||d.clear()})}}()}(this,b);!function(b,c){var d=b,e=
'<a href="javascript:void(0)" class="'+c.className+'" tabindex="-1" title="'+l(c.title)+'">'+c.label+"</a>",f=function(a,b){var c=a.search(/(<\/[^>]+>\s*)$/);return a.substring(0,c)+b+a.substring(c)};b.setup=function(){var g=d.setup;return function(){if(c.append){var h=d.settings.render.item;d.settings.render.item=function(a){return f(h.apply(b,arguments),e)}}g.apply(b,arguments),b.$control.on("click","."+c.className,function(b){if(b.preventDefault(),!d.isLocked){var c=a(b.currentTarget).parent();d.setActiveItem(c),d.deleteSelection()&&d.setCaret(d.items.length)}})}}()}(this,b)}),w.define("restore_on_backspace",function(a){var b=this;a.text=a.text||function(a){return a[this.settings.labelField]},this.onKeyDown=function(){var c=b.onKeyDown;return function(b){var d,e;return 8===b.keyCode&&""===this.$control_input.val()&&!this.$activeItems.length&&(d=this.caretPos-1)>=0&&d<this.items.length?(e=this.options[this.items[d]],this.deleteSelection(b)&&(this.setTextboxValue(a.text.apply(this,
[e])),this.refreshOptions(!0)),void b.preventDefault()):c.apply(this,arguments)}}()}),w});
\ No newline at end of file
-----------------------------------------------------------------------
Summary of changes:
FS/FS/cust_pkg.pm | 21 +-
httemplate/edit/cust_pkg.cgi | 378 +++++++++++++--------
httemplate/edit/process/cust_pkg.cgi | 67 ++--
httemplate/elements/dropdown-menu.html | 6 +
httemplate/elements/header-cust_main.html | 12 +-
httemplate/elements/header-full.html | 7 +
.../selectize/select-multiple-pkg_class.html | 46 +++
.../elements/selectize/selectize-freeside.css | 37 ++
httemplate/elements/selectize/selectize.css | 333 ++++++++++++++++++
httemplate/elements/selectize/selectize.min.js | 4 +
10 files changed, 733 insertions(+), 178 deletions(-)
create mode 100644 httemplate/elements/selectize/select-multiple-pkg_class.html
create mode 100644 httemplate/elements/selectize/selectize-freeside.css
create mode 100644 httemplate/elements/selectize/selectize.css
create mode 100644 httemplate/elements/selectize/selectize.min.js
More information about the freeside-commits
mailing list