').addClass(settings.dropdownClass).addClass(inputMode).hide().appendTo($dropdown_parent);
+ $dropdown_content = $('
').addClass(settings.dropdownContentClass).appendTo($dropdown);
+
+ if(inputId = $input.attr('id')) {
+ $control_input.attr('id', inputId + '-selectized');
+ $("label[for='"+inputId+"']").attr('for', inputId + '-selectized');
+ }
+
+ if(self.settings.copyClassesToDropdown) {
+ $dropdown.addClass(classes);
+ }
+
+ $wrapper.css({
+ width: $input[0].style.width
+ });
+
+ if (self.plugins.names.length) {
+ classes_plugins = 'plugin-' + self.plugins.names.join(' plugin-');
+ $wrapper.addClass(classes_plugins);
+ $dropdown.addClass(classes_plugins);
+ }
+
+ if ((settings.maxItems === null || settings.maxItems > 1) && self.tagType === TAG_SELECT) {
+ $input.attr('multiple', 'multiple');
+ }
+
+ if (self.settings.placeholder) {
+ $control_input.attr('placeholder', settings.placeholder);
+ }
+
+ // if splitOn was not passed in, construct it from the delimiter to allow pasting universally
+ if (!self.settings.splitOn && self.settings.delimiter) {
+ var delimiterEscaped = self.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
+ self.settings.splitOn = new RegExp('\\s*' + delimiterEscaped + '+\\s*');
+ }
+
+ if ($input.attr('autocorrect')) {
+ $control_input.attr('autocorrect', $input.attr('autocorrect'));
+ }
+
+ if ($input.attr('autocapitalize')) {
+ $control_input.attr('autocapitalize', $input.attr('autocapitalize'));
+ }
+
+ self.$wrapper = $wrapper;
+ self.$control = $control;
+ self.$control_input = $control_input;
+ self.$dropdown = $dropdown;
+ self.$dropdown_content = $dropdown_content;
+
+ $dropdown.on('mouseenter', '[data-selectable]', function() { return self.onOptionHover.apply(self, arguments); });
+ $dropdown.on('mousedown click', '[data-selectable]', function() { return self.onOptionSelect.apply(self, arguments); });
+ watchChildEvent($control, 'mousedown', '*:not(input)', function() { return self.onItemSelect.apply(self, arguments); });
+ autoGrow($control_input);
+
+ $control.on({
+ mousedown : function() { return self.onMouseDown.apply(self, arguments); },
+ click : function() { return self.onClick.apply(self, arguments); }
+ });
+
+ $control_input.on({
+ mousedown : function(e) { e.stopPropagation(); },
+ keydown : function() { return self.onKeyDown.apply(self, arguments); },
+ keyup : function() { return self.onKeyUp.apply(self, arguments); },
+ keypress : function() { return self.onKeyPress.apply(self, arguments); },
+ resize : function() { self.positionDropdown.apply(self, []); },
+ blur : function() { return self.onBlur.apply(self, arguments); },
+ focus : function() { self.ignoreBlur = false; return self.onFocus.apply(self, arguments); },
+ paste : function() { return self.onPaste.apply(self, arguments); }
+ });
+
+ $document.on('keydown' + eventNS, function(e) {
+ self.isCmdDown = e[IS_MAC ? 'metaKey' : 'ctrlKey'];
+ self.isCtrlDown = e[IS_MAC ? 'altKey' : 'ctrlKey'];
+ self.isShiftDown = e.shiftKey;
+ });
+
+ $document.on('keyup' + eventNS, function(e) {
+ if (e.keyCode === KEY_CTRL) self.isCtrlDown = false;
+ if (e.keyCode === KEY_SHIFT) self.isShiftDown = false;
+ if (e.keyCode === KEY_CMD) self.isCmdDown = false;
+ });
+
+ $document.on('mousedown' + eventNS, function(e) {
+ if (self.isFocused) {
+ // prevent events on the dropdown scrollbar from causing the control to blur
+ if (e.target === self.$dropdown[0] || e.target.parentNode === self.$dropdown[0]) {
+ return false;
+ }
+ // blur on click outside
+ if (!self.$control.has(e.target).length && e.target !== self.$control[0]) {
+ self.blur(e.target);
+ }
+ }
+ });
+
+ $window.on(['scroll' + eventNS, 'resize' + eventNS].join(' '), function() {
+ if (self.isOpen) {
+ self.positionDropdown.apply(self, arguments);
+ }
+ });
+ $window.on('mousemove' + eventNS, function() {
+ self.ignoreHover = false;
+ });
+
+ // store original children and tab index so that they can be
+ // restored when the destroy() method is called.
+ this.revertSettings = {
+ $children : $input.children().detach(),
+ tabindex : $input.attr('tabindex')
+ };
+
+ $input.attr('tabindex', -1).hide().after(self.$wrapper);
+
+ if ($.isArray(settings.items)) {
+ self.setValue(settings.items);
+ delete settings.items;
+ }
+
+ // feature detect for the validation API
+ if (SUPPORTS_VALIDITY_API) {
+ $input.on('invalid' + eventNS, function(e) {
+ e.preventDefault();
+ self.isInvalid = true;
+ self.refreshState();
+ });
+ }
+
+ self.updateOriginalInput();
+ self.refreshItems();
+ self.refreshState();
+ self.updatePlaceholder();
+ self.isSetup = true;
+
+ if ($input.is(':disabled')) {
+ self.disable();
+ }
+
+ self.on('change', this.onChange);
+
+ $input.data('selectize', self);
+ $input.addClass('selectized');
+ self.trigger('initialize');
+
+ // preload options
+ if (settings.preload === true) {
+ self.onSearchChange('');
+ }
+
+ },
+
+ /**
+ * Sets up default rendering functions.
+ */
+ setupTemplates: function() {
+ var self = this;
+ var field_label = self.settings.labelField;
+ var field_optgroup = self.settings.optgroupLabelField;
+
+ var templates = {
+ 'optgroup': function(data) {
+ return '
' + data.html + '
';
+ },
+ 'optgroup_header': function(data, escape) {
+ return '';
+ },
+ 'option': function(data, escape) {
+ return '
' + escape(data[field_label]) + '
';
+ },
+ 'item': function(data, escape) {
+ return '
' + escape(data[field_label]) + '
';
+ },
+ 'option_create': function(data, escape) {
+ return '
Add ' + escape(data.input) + ' …
';
+ }
+ };
+
+ self.settings.render = $.extend({}, templates, self.settings.render);
+ },
+
+ /**
+ * Maps fired events to callbacks provided
+ * in the settings used when creating the control.
+ */
+ setupCallbacks: function() {
+ var key, fn, callbacks = {
+ '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 (key in callbacks) {
+ if (callbacks.hasOwnProperty(key)) {
+ fn = this.settings[callbacks[key]];
+ if (fn) this.on(key, fn);
+ }
+ }
+ },
+
+ /**
+ * Triggered when the main control element
+ * has a click event.
+ *
+ * @param {object} e
+ * @return {boolean}
+ */
+ onClick: function(e) {
+ var self = this;
+
+ // necessary for mobile webkit devices (manual focus triggering
+ // is ignored unless invoked within a click event)
+ if (!self.isFocused) {
+ self.focus();
+ e.preventDefault();
+ }
+ },
+
+ /**
+ * Triggered when the main control element
+ * has a mouse down event.
+ *
+ * @param {object} e
+ * @return {boolean}
+ */
+ onMouseDown: function(e) {
+ var self = this;
+ var defaultPrevented = e.isDefaultPrevented();
+ var $target = $(e.target);
+
+ if (self.isFocused) {
+ // retain focus by preventing native handling. if the
+ // event target is the input it should not be modified.
+ // otherwise, text selection within the input won't work.
+ if (e.target !== self.$control_input[0]) {
+ if (self.settings.mode === 'single') {
+ // toggle dropdown
+ self.isOpen ? self.close() : self.open();
+ } else if (!defaultPrevented) {
+ self.setActiveItem(null);
+ }
+ return false;
+ }
+ } else {
+ // give control focus
+ if (!defaultPrevented) {
+ window.setTimeout(function() {
+ self.focus();
+ }, 0);
+ }
+ }
+ },
+
+ /**
+ * Triggered when the value of the control has been changed.
+ * This should propagate the event to the original DOM
+ * input / select element.
+ */
+ onChange: function() {
+ this.$input.trigger('change');
+ },
+
+ /**
+ * Triggered on
paste.
+ *
+ * @param {object} e
+ * @returns {boolean}
+ */
+ onPaste: function(e) {
+ var self = this;
+
+ if (self.isFull() || self.isInputHidden || self.isLocked) {
+ e.preventDefault();
+ return;
+ }
+
+ // If a regex or string is included, this will split the pasted
+ // input and create Items for each separate value
+ if (self.settings.splitOn) {
+
+ // Wait for pasted text to be recognized in value
+ setTimeout(function() {
+ var pastedText = self.$control_input.val();
+ if(!pastedText.match(self.settings.splitOn)){ return }
+
+ var splitInput = $.trim(pastedText).split(self.settings.splitOn);
+ for (var i = 0, n = splitInput.length; i < n; i++) {
+ self.createItem(splitInput[i]);
+ }
+ }, 0);
+ }
+ },
+
+ /**
+ * Triggered on
keypress.
+ *
+ * @param {object} e
+ * @returns {boolean}
+ */
+ onKeyPress: function(e) {
+ if (this.isLocked) return e && e.preventDefault();
+ var character = String.fromCharCode(e.keyCode || e.which);
+ if (this.settings.create && this.settings.mode === 'multi' && character === this.settings.delimiter) {
+ this.createItem();
+ e.preventDefault();
+ return false;
+ }
+ },
+
+ lastKeyDown: null, // RJC
+
+ /**
+ * Triggered on
keydown.
+ *
+ * @param {object} e
+ * @returns {boolean}
+ */
+ onKeyDown: function(e) {
+ var isInput = e.target === this.$control_input[0];
+ var self = this;
+
+ if (self.isLocked) {
+ if (e.keyCode !== KEY_TAB) {
+ e.preventDefault();
+ }
+ return;
+ }
+
+ switch (e.keyCode) {
+ case KEY_A:
+ if (self.isCmdDown) {
+ self.selectAll();
+ return;
+ }
+ break;
+ case KEY_ESC:
+ if (self.isOpen) {
+ e.preventDefault();
+ e.stopPropagation();
+ self.close();
+ }
+ return;
+ case KEY_N:
+ if (!e.ctrlKey || e.altKey) break;
+ case KEY_DOWN:
+ if (!self.isOpen && self.hasOptions) {
+ self.open();
+ } else if (self.$activeOption) {
+ self.ignoreHover = true;
+ var $next = self.getAdjacentOption(self.$activeOption, 1);
+ if ($next.length) self.setActiveOption($next, true, true);
+ }
+ e.preventDefault();
+ return;
+ case KEY_P:
+ if (!e.ctrlKey || e.altKey) break;
+ case KEY_UP:
+ if (self.$activeOption) {
+ self.ignoreHover = true;
+ var $prev = self.getAdjacentOption(self.$activeOption, -1);
+ if ($prev.length) self.setActiveOption($prev, true, true);
+ }
+ e.preventDefault();
+ return;
+ case KEY_RETURN:
+ if (self.isOpen && self.$activeOption) {
+ self.onOptionSelect({currentTarget: self.$activeOption});
+ e.preventDefault();
+ }
+ if(!self.settings.submitOnReturn) return false; // RJC
+ return;
+ case KEY_LEFT:
+ self.advanceSelection(-1, e);
+ return;
+ case KEY_RIGHT:
+ self.advanceSelection(1, e);
+ return;
+ case KEY_TAB:
+ if (self.settings.selectOnTab && self.isOpen && self.$activeOption) {
+ self.onOptionSelect({currentTarget: self.$activeOption});
+
+ // Default behaviour is to jump to the next field, we only want this
+ // if the current field doesn't accept any more entries
+ if (!self.isFull()) {
+ e.preventDefault();
+ }
+ }
+ if (self.settings.create && self.createItem()) {
+ e.preventDefault();
+ }
+ return;
+ case KEY_BACKSPACE:
+ case KEY_DELETE:
+ self.deleteSelection(e);
+ return;
+ }
+
+ if ((self.isFull() || self.isInputHidden) && !(IS_MAC ? e.metaKey : e.ctrlKey)) {
+ e.preventDefault();
+ return;
+ }
+ },
+
+ /**
+ * Triggered on
keyup.
+ *
+ * @param {object} e
+ * @returns {boolean}
+ */
+ onKeyUp: function(e) {
+ var self = this;
+
+ if (self.isLocked) return e && e.preventDefault();
+ var value = self.$control_input.val() || '';
+ if (self.lastValue !== value) {
+ self.lastValue = value;
+ self.onSearchChange(value);
+ self.refreshOptions();
+ self.trigger('type', value);
+ }
+ },
+
+ /**
+ * Invokes the user-provide option provider / loader.
+ *
+ * Note: this function is debounced in the Selectize
+ * constructor (by `settings.loadThrottle` milliseconds)
+ *
+ * @param {string} value
+ */
+ onSearchChange: function(value) {
+ var self = this;
+ var fn = self.settings.load;
+ if (!fn) return;
+ if (self.loadedSearches.hasOwnProperty(value)) return;
+ self.loadedSearches[value] = true;
+ self.load(function(callback) {
+ fn.apply(self, [value, callback]);
+ });
+ },
+
+ /**
+ * Triggered on
focus.
+ *
+ * @param {object} e (optional)
+ * @returns {boolean}
+ */
+ onFocus: function(e) {
+ var self = this;
+ var wasFocused = self.isFocused;
+
+ if (self.isDisabled) {
+ self.blur();
+ e && e.preventDefault();
+ return false;
+ }
+
+ if (self.ignoreFocus) return;
+ self.isFocused = true;
+ if (self.settings.preload === 'focus') self.onSearchChange('');
+
+ if (!wasFocused) self.trigger('focus');
+
+ if (!self.$activeItems.length) {
+ self.showInput();
+ self.setActiveItem(null);
+ self.refreshOptions(!!self.settings.openOnFocus);
+ }
+
+ self.refreshState();
+ },
+
+ /**
+ * Triggered on
blur.
+ *
+ * @param {object} e
+ * @param {Element} dest
+ */
+ onBlur: function(e, dest) {
+ var self = this;
+ if (!self.isFocused) return;
+ self.isFocused = false;
+
+ if (self.ignoreFocus) {
+ return;
+ } else if (!self.ignoreBlur && document.activeElement === self.$dropdown_content[0]) {
+ // necessary to prevent IE closing the dropdown when the scrollbar is clicked
+ self.ignoreBlur = true;
+ self.onFocus(e);
+ return;
+ }
+
+ var deactivate = function() {
+ self.close();
+ self.setTextboxValue('');
+ self.setActiveItem(null);
+ self.setActiveOption(null);
+ self.setCaret(self.items.length);
+ self.refreshState();
+
+ // IE11 bug: element still marked as active
+ dest && dest.focus && dest.focus();
+
+ self.ignoreFocus = false;
+ self.trigger('blur');
+ };
+
+ self.ignoreFocus = true;
+ if (self.settings.create && self.settings.createOnBlur) {
+ self.createItem(null, false, deactivate);
+ } else {
+ deactivate();
+ }
+ },
+
+ /**
+ * Triggered when the user rolls over
+ * an option in the autocomplete dropdown menu.
+ *
+ * @param {object} e
+ * @returns {boolean}
+ */
+ onOptionHover: function(e) {
+ if (this.ignoreHover) return;
+ this.setActiveOption(e.currentTarget, false);
+ },
+
+ /**
+ * Triggered when the user clicks on an option
+ * in the autocomplete dropdown menu.
+ *
+ * @param {object} e
+ * @returns {boolean}
+ */
+ onOptionSelect: function(e) {
+ var value, $target, $option, self = this;
+
+ if (e.preventDefault) {
+ e.preventDefault();
+ e.stopPropagation();
+ }
+
+ $target = $(e.currentTarget);
+ if ($target.hasClass('create')) {
+ self.createItem(null, function() {
+ if (self.settings.closeAfterSelect) {
+ self.close();
+ console.log('1');
+ }
+ });
+ } else {
+ value = $target.attr('data-value');
+ if (typeof value !== 'undefined') {
+ self.lastQuery = null;
+ self.setTextboxValue('');
+ self.addItem(value);
+ if (self.settings.closeAfterSelect) {
+ self.close();
+ self.blur(); // RJC otherwise you have to manually blur and re-focus to see dropdown
+ } else if (!self.settings.hideSelected && e.type && /mouse/.test(e.type)) {
+ self.setActiveOption(self.getOption(value));
+ }
+ }
+ }
+ },
+
+ /**
+ * Triggered when the user clicks on an item
+ * that has been selected.
+ *
+ * @param {object} e
+ * @returns {boolean}
+ */
+ onItemSelect: function(e) {
+ var self = this;
+
+ if (self.isLocked) return;
+ if (self.settings.mode === 'multi') {
+ e.preventDefault();
+ self.setActiveItem(e.currentTarget, e);
+ }
+ },
+
+ /**
+ * Invokes the provided method that provides
+ * results to a callback---which are then added
+ * as options to the control.
+ *
+ * @param {function} fn
+ */
+ load: function(fn) {
+ var self = this;
+ var $wrapper = self.$wrapper.addClass(self.settings.loadingClass);
+
+ self.loading++;
+ fn.apply(self, [function(results) {
+ self.loading = Math.max(self.loading - 1, 0);
+ if (results && results.length) {
+ self.addOption(results);
+ self.refreshOptions(self.isFocused && !self.isInputHidden);
+ }
+ if (!self.loading) {
+ $wrapper.removeClass(self.settings.loadingClass);
+ }
+ self.trigger('load', results);
+ }]);
+ },
+
+ /**
+ * Sets the input field of the control to the specified value.
+ *
+ * @param {string} value
+ */
+ setTextboxValue: function(value) {
+ var $input = this.$control_input;
+ var changed = $input.val() !== value;
+ if (changed) {
+ $input.val(value).triggerHandler('update');
+ this.lastValue = value;
+ }
+ },
+
+ /**
+ * Returns the value of the control. If multiple items
+ * can be selected (e.g.
), this returns
+ * an array. If only one item can be selected, this
+ * returns a string.
+ *
+ * @returns {mixed}
+ */
+ getValue: function() {
+ if (this.tagType === TAG_SELECT && this.$input.attr('multiple')) {
+ return this.items;
+ } else {
+ return this.items.join(this.settings.delimiter);
+ }
+ },
+
+ /**
+ * Resets the selected items to the given value.
+ *
+ * @param {mixed} value
+ */
+ setValue: function(value, silent) {
+ var events = silent ? [] : ['change'];
+
+ debounce_events(this, events, function() {
+ this.clear(silent);
+ this.addItems(value, silent);
+ });
+ },
+
+ /**
+ * Sets the selected item.
+ *
+ * @param {object} $item
+ * @param {object} e (optional)
+ */
+ setActiveItem: function($item, e) {
+ var self = this;
+ var eventName;
+ var i, idx, begin, end, item, swap;
+ var $last;
+
+ if (self.settings.mode === 'single') return;
+ $item = $($item);
+
+ // clear the active selection
+ if (!$item.length) {
+ $(self.$activeItems).removeClass('active');
+ self.$activeItems = [];
+ if (self.isFocused) {
+ self.showInput();
+ }
+ return;
+ }
+
+ // modify selection
+ eventName = e && e.type.toLowerCase();
+
+ if (eventName === 'mousedown' && self.isShiftDown && self.$activeItems.length) {
+ $last = self.$control.children('.active:last');
+ begin = Array.prototype.indexOf.apply(self.$control[0].childNodes, [$last[0]]);
+ end = Array.prototype.indexOf.apply(self.$control[0].childNodes, [$item[0]]);
+ if (begin > end) {
+ swap = begin;
+ begin = end;
+ end = swap;
+ }
+ for (i = begin; i <= end; i++) {
+ item = self.$control[0].childNodes[i];
+ if (self.$activeItems.indexOf(item) === -1) {
+ $(item).addClass('active');
+ self.$activeItems.push(item);
+ }
+ }
+ e.preventDefault();
+ } else if ((eventName === 'mousedown' && self.isCtrlDown) || (eventName === 'keydown' && this.isShiftDown)) {
+ if ($item.hasClass('active')) {
+ idx = self.$activeItems.indexOf($item[0]);
+ self.$activeItems.splice(idx, 1);
+ $item.removeClass('active');
+ } else {
+ self.$activeItems.push($item.addClass('active')[0]);
+ }
+ } else {
+ $(self.$activeItems).removeClass('active');
+ self.$activeItems = [$item.addClass('active')[0]];
+ }
+
+ // ensure control has focus
+ self.hideInput();
+ if (!this.isFocused) {
+ self.focus();
+ }
+ },
+
+ /**
+ * Sets the selected item in the dropdown menu
+ * of available options.
+ *
+ * @param {object} $object
+ * @param {boolean} scroll
+ * @param {boolean} animate
+ */
+ setActiveOption: function($option, scroll, animate) {
+ var height_menu, height_item, y;
+ var scroll_top, scroll_bottom;
+ var self = this;
+
+ if (self.$activeOption) self.$activeOption.removeClass('active');
+ self.$activeOption = null;
+
+ $option = $($option);
+ if (!$option.length) return;
+
+ self.$activeOption = $option.addClass('active');
+
+ if (scroll || !isset(scroll)) {
+
+ height_menu = self.$dropdown_content.height();
+ height_item = self.$activeOption.outerHeight(true);
+ scroll = self.$dropdown_content.scrollTop() || 0;
+ y = self.$activeOption.offset().top - self.$dropdown_content.offset().top + scroll;
+ scroll_top = y;
+ scroll_bottom = y - height_menu + height_item;
+
+ if (y + height_item > height_menu + scroll) {
+ self.$dropdown_content.stop().animate({scrollTop: scroll_bottom}, animate ? self.settings.scrollDuration : 0);
+ } else if (y < scroll) {
+ self.$dropdown_content.stop().animate({scrollTop: scroll_top}, animate ? self.settings.scrollDuration : 0);
+ }
+
+ }
+ },
+
+ /**
+ * Selects all items (CTRL + A).
+ */
+ selectAll: function() {
+ var self = this;
+ if (self.settings.mode === 'single') return;
+
+ self.$activeItems = Array.prototype.slice.apply(self.$control.children(':not(input)').addClass('active'));
+ if (self.$activeItems.length) {
+ self.hideInput();
+ self.close();
+ }
+ self.focus();
+ },
+
+ /**
+ * Hides the input element out of view, while
+ * retaining its focus.
+ */
+ hideInput: function() {
+ var self = this;
+
+ self.setTextboxValue('');
+ self.$control_input.css({opacity: 0, position: 'absolute', left: self.rtl ? 10000 : -10000});
+ self.isInputHidden = true;
+ },
+
+ /**
+ * Restores input visibility.
+ */
+ showInput: function() {
+ this.$control_input.css({opacity: 1, position: 'relative', left: 0});
+ this.isInputHidden = false;
+ },
+
+ /**
+ * Gives the control focus.
+ */
+ focus: function() {
+ var self = this;
+ if (self.isDisabled) return;
+
+ self.ignoreFocus = true;
+ self.$control_input[0].focus();
+ window.setTimeout(function() {
+ self.ignoreFocus = false;
+ self.onFocus();
+ }, 0);
+ },
+
+ /**
+ * Forces the control out of focus.
+ *
+ * @param {Element} dest
+ */
+ blur: function(dest) {
+ this.$control_input[0].blur();
+ this.onBlur(null, dest);
+ },
+
+ /**
+ * Returns a function that scores an object
+ * to show how good of a match it is to the
+ * provided query.
+ *
+ * @param {string} query
+ * @param {object} options
+ * @return {function}
+ */
+ getScoreFunction: function(query) {
+ return this.sifter.getScoreFunction(query, this.getSearchOptions());
+ },
+
+ /**
+ * Returns search options for sifter (the system
+ * for scoring and sorting results).
+ *
+ * @see https://github.com/brianreavis/sifter.js
+ * @return {object}
+ */
+ getSearchOptions: function() {
+ var settings = this.settings;
+ var sort = settings.sortField;
+ if (typeof sort === 'string') {
+ sort = [{field: sort}];
+ }
+
+ return {
+ fields : settings.searchField,
+ conjunction : settings.searchConjunction,
+ sort : sort
+ };
+ },
+
+ /**
+ * Searches through available options and returns
+ * a sorted array of matches.
+ *
+ * Returns an object containing:
+ *
+ * - query {string}
+ * - tokens {array}
+ * - total {int}
+ * - items {array}
+ *
+ * @param {string} query
+ * @returns {object}
+ */
+ search: function(query) {
+ var i, value, score, result, calculateScore;
+ var self = this;
+ var settings = self.settings;
+ var options = this.getSearchOptions();
+
+ // validate user-provided result scoring function
+ if (settings.score) {
+ calculateScore = self.settings.score.apply(this, [query]);
+ if (typeof calculateScore !== 'function') {
+ throw new Error('Selectize "score" setting must be a function that returns a function');
+ }
+ }
+
+ // perform search
+ if (query !== self.lastQuery) {
+ self.lastQuery = query;
+ result = self.sifter.search(query, $.extend(options, {score: calculateScore}));
+ self.currentResults = result;
+ } else {
+ result = $.extend(true, {}, self.currentResults);
+ }
+
+ // filter out selected items
+ if (settings.hideSelected) {
+ for (i = result.items.length - 1; i >= 0; i--) {
+ if (self.items.indexOf(hash_key(result.items[i].id)) !== -1) {
+ result.items.splice(i, 1);
+ }
+ }
+ }
+
+ return result;
+ },
+
+ /**
+ * Refreshes the list of available options shown
+ * in the autocomplete dropdown menu.
+ *
+ * @param {boolean} triggerDropdown
+ */
+ refreshOptions: function(triggerDropdown) {
+ var i, j, k, n, groups, groups_order, option, option_html, optgroup, optgroups, html, html_children, has_create_option;
+ var $active, $active_before, $create;
+
+ if (typeof triggerDropdown === 'undefined') {
+ triggerDropdown = true;
+ }
+
+ var self = this;
+ var query = $.trim(self.$control_input.val());
+ var results = self.search(query);
+ var $dropdown_content = self.$dropdown_content;
+ var active_before = self.$activeOption && hash_key(self.$activeOption.attr('data-value'));
+
+ // build markup
+ n = results.items.length;
+ if (typeof self.settings.maxOptions === 'number') {
+ n = Math.min(n, self.settings.maxOptions);
+ }
+
+ // render and group available options individually
+ groups = {};
+ groups_order = [];
+
+ for (i = 0; i < n; i++) {
+ option = self.options[results.items[i].id];
+ option_html = self.render('option', option);
+ optgroup = option[self.settings.optgroupField] || '';
+ optgroups = $.isArray(optgroup) ? optgroup : [optgroup];
+
+ for (j = 0, k = optgroups && optgroups.length; j < k; j++) {
+ optgroup = optgroups[j];
+ if (!self.optgroups.hasOwnProperty(optgroup)) {
+ optgroup = '';
+ }
+ if (!groups.hasOwnProperty(optgroup)) {
+ groups[optgroup] = document.createDocumentFragment();
+ groups_order.push(optgroup);
+ }
+ groups[optgroup].appendChild(option_html);
+ }
+ }
+
+ // sort optgroups
+ if (this.settings.lockOptgroupOrder) {
+ groups_order.sort(function(a, b) {
+ var a_order = self.optgroups[a].$order || 0;
+ var b_order = self.optgroups[b].$order || 0;
+ return a_order - b_order;
+ });
+ }
+
+ // render optgroup headers & join groups
+ html = document.createDocumentFragment();
+ for (i = 0, n = groups_order.length; i < n; i++) {
+ optgroup = groups_order[i];
+ if (self.optgroups.hasOwnProperty(optgroup) && groups[optgroup].childNodes.length) {
+ // render the optgroup header and options within it,
+ // then pass it to the wrapper template
+ html_children = document.createDocumentFragment();
+ html_children.appendChild(self.render('optgroup_header', self.optgroups[optgroup]));
+ html_children.appendChild(groups[optgroup]);
+
+ html.appendChild(self.render('optgroup', $.extend({}, self.optgroups[optgroup], {
+ html: domToString(html_children),
+ dom: html_children
+ })));
+ } else {
+ html.appendChild(groups[optgroup]);
+ }
+ }
+
+ $dropdown_content.html(html);
+
+ // highlight matching terms inline
+ if (self.settings.highlight && results.query.length && results.tokens.length) {
+ $dropdown_content.removeHighlight();
+ for (i = 0, n = results.tokens.length; i < n; i++) {
+ highlight($dropdown_content, results.tokens[i].regex);
+ }
+ }
+
+ // add "selected" class to selected options
+ if (!self.settings.hideSelected) {
+ for (i = 0, n = self.items.length; i < n; i++) {
+ self.getOption(self.items[i]).addClass('selected');
+ }
+ }
+
+ // add create option
+ has_create_option = self.canCreate(query);
+ if (has_create_option) {
+ $dropdown_content.prepend(self.render('option_create', {input: query}));
+ $create = $($dropdown_content[0].childNodes[0]);
+ }
+
+ // activate
+ self.hasOptions = results.items.length > 0 || has_create_option;
+ if (self.hasOptions) {
+ if (results.items.length > 0) {
+ $active_before = active_before && self.getOption(active_before);
+ if ($active_before && $active_before.length) {
+ $active = $active_before;
+ } else if (self.settings.mode === 'single' && self.items.length) {
+ $active = self.getOption(self.items[0]);
+ }
+ if (!$active || !$active.length) {
+ if ($create && !self.settings.addPrecedence) {
+ $active = self.getAdjacentOption($create, 1);
+ } else {
+ $active = $dropdown_content.find('[data-selectable]:first');
+ }
+ }
+ } else {
+ $active = $create;
+ }
+ self.setActiveOption($active);
+ if (triggerDropdown && !self.isOpen) { self.open(); }
+ } else {
+ self.setActiveOption(null);
+ if (triggerDropdown && self.isOpen) { self.close(); }
+ }
+ },
+
+ /**
+ * Adds an available option. If it already exists,
+ * nothing will happen. Note: this does not refresh
+ * the options list dropdown (use `refreshOptions`
+ * for that).
+ *
+ * Usage:
+ *
+ * this.addOption(data)
+ *
+ * @param {object|array} data
+ */
+ addOption: function(data) {
+ var i, n, value, self = this;
+
+ if ($.isArray(data)) {
+ for (i = 0, n = data.length; i < n; i++) {
+ self.addOption(data[i]);
+ }
+ return;
+ }
+
+ if (value = self.registerOption(data)) {
+ self.userOptions[value] = true;
+ self.lastQuery = null;
+ self.trigger('option_add', value, data);
+ }
+ },
+
+ /**
+ * Registers an option to the pool of options.
+ *
+ * @param {object} data
+ * @return {boolean|string}
+ */
+ registerOption: function(data) {
+ var key = hash_key(data[this.settings.valueField]);
+ if (typeof key === 'undefined' || key === null || this.options.hasOwnProperty(key)) return false;
+ data.$order = data.$order || ++this.order;
+ this.options[key] = data;
+ return key;
+ },
+
+ /**
+ * Registers an option group to the pool of option groups.
+ *
+ * @param {object} data
+ * @return {boolean|string}
+ */
+ registerOptionGroup: function(data) {
+ var key = hash_key(data[this.settings.optgroupValueField]);
+ if (!key) return false;
+
+ data.$order = data.$order || ++this.order;
+ this.optgroups[key] = data;
+ return key;
+ },
+
+ /**
+ * Registers a new optgroup for options
+ * to be bucketed into.
+ *
+ * @param {string} id
+ * @param {object} data
+ */
+ addOptionGroup: function(id, data) {
+ data[this.settings.optgroupValueField] = id;
+ if (id = this.registerOptionGroup(data)) {
+ this.trigger('optgroup_add', id, data);
+ }
+ },
+
+ /**
+ * Removes an existing option group.
+ *
+ * @param {string} id
+ */
+ removeOptionGroup: function(id) {
+ if (this.optgroups.hasOwnProperty(id)) {
+ delete this.optgroups[id];
+ this.renderCache = {};
+ this.trigger('optgroup_remove', id);
+ }
+ },
+
+ /**
+ * Clears all existing option groups.
+ */
+ clearOptionGroups: function() {
+ this.optgroups = {};
+ this.renderCache = {};
+ this.trigger('optgroup_clear');
+ },
+
+ /**
+ * Updates an option available for selection. If
+ * it is visible in the selected items or options
+ * dropdown, it will be re-rendered automatically.
+ *
+ * @param {string} value
+ * @param {object} data
+ */
+ updateOption: function(value, data) {
+ var self = this;
+ var $item, $item_new;
+ var value_new, index_item, cache_items, cache_options, order_old;
+
+ value = hash_key(value);
+ value_new = hash_key(data[self.settings.valueField]);
+
+ // sanity checks
+ if (value === null) return;
+ if (!self.options.hasOwnProperty(value)) return;
+ if (typeof value_new !== 'string') throw new Error('Value must be set in option data');
+
+ order_old = self.options[value].$order;
+
+ // update references
+ if (value_new !== value) {
+ delete self.options[value];
+ index_item = self.items.indexOf(value);
+ if (index_item !== -1) {
+ self.items.splice(index_item, 1, value_new);
+ }
+ }
+ data.$order = data.$order || order_old;
+ self.options[value_new] = data;
+
+ // invalidate render cache
+ cache_items = self.renderCache['item'];
+ cache_options = self.renderCache['option'];
+
+ if (cache_items) {
+ delete cache_items[value];
+ delete cache_items[value_new];
+ }
+ if (cache_options) {
+ delete cache_options[value];
+ delete cache_options[value_new];
+ }
+
+ // update the item if it's selected
+ if (self.items.indexOf(value_new) !== -1) {
+ $item = self.getItem(value);
+ $item_new = $(self.render('item', data));
+ if ($item.hasClass('active')) $item_new.addClass('active');
+ $item.replaceWith($item_new);
+ }
+
+ // invalidate last query because we might have updated the sortField
+ self.lastQuery = null;
+
+ // update dropdown contents
+ if (self.isOpen) {
+ self.refreshOptions(false);
+ }
+ },
+
+ /**
+ * Removes a single option.
+ *
+ * @param {string} value
+ * @param {boolean} silent
+ */
+ removeOption: function(value, silent) {
+ var self = this;
+ value = hash_key(value);
+
+ var cache_items = self.renderCache['item'];
+ var cache_options = self.renderCache['option'];
+ if (cache_items) delete cache_items[value];
+ if (cache_options) delete cache_options[value];
+
+ delete self.userOptions[value];
+ delete self.options[value];
+ self.lastQuery = null;
+ self.trigger('option_remove', value);
+ self.removeItem(value, silent);
+ },
+
+ /**
+ * Clears all options.
+ */
+ clearOptions: function() {
+ var self = this;
+
+ self.loadedSearches = {};
+ self.userOptions = {};
+ self.renderCache = {};
+ self.options = self.sifter.items = {};
+ self.lastQuery = null;
+ self.trigger('option_clear');
+ self.clear();
+ },
+
+ /**
+ * Returns the jQuery element of the option
+ * matching the given value.
+ *
+ * @param {string} value
+ * @returns {object}
+ */
+ getOption: function(value) {
+ return this.getElementWithValue(value, this.$dropdown_content.find('[data-selectable]'));
+ },
+
+ /**
+ * Returns the jQuery element of the next or
+ * previous selectable option.
+ *
+ * @param {object} $option
+ * @param {int} direction can be 1 for next or -1 for previous
+ * @return {object}
+ */
+ getAdjacentOption: function($option, direction) {
+ var $options = this.$dropdown.find('[data-selectable]');
+ var index = $options.index($option) + direction;
+
+ return index >= 0 && index < $options.length ? $options.eq(index) : $();
+ },
+
+ /**
+ * Finds the first element with a "data-value" attribute
+ * that matches the given value.
+ *
+ * @param {mixed} value
+ * @param {object} $els
+ * @return {object}
+ */
+ getElementWithValue: function(value, $els) {
+ value = hash_key(value);
+
+ if (typeof value !== 'undefined' && value !== null) {
+ for (var i = 0, n = $els.length; i < n; i++) {
+ if ($els[i].getAttribute('data-value') === value) {
+ return $($els[i]);
+ }
+ }
+ }
+
+ return $();
+ },
+
+ /**
+ * Returns the jQuery element of the item
+ * matching the given value.
+ *
+ * @param {string} value
+ * @returns {object}
+ */
+ getItem: function(value) {
+ return this.getElementWithValue(value, this.$control.children());
+ },
+
+ /**
+ * "Selects" multiple items at once. Adds them to the list
+ * at the current caret position.
+ *
+ * @param {string} value
+ * @param {boolean} silent
+ */
+ addItems: function(values, silent) {
+ var items = $.isArray(values) ? values : [values];
+ for (var i = 0, n = items.length; i < n; i++) {
+ this.isPending = (i < n - 1);
+ this.addItem(items[i], silent);
+ }
+ },
+
+ /**
+ * "Selects" an item. Adds it to the list
+ * at the current caret position.
+ *
+ * @param {string} value
+ * @param {boolean} silent
+ */
+ addItem: function(value, silent) {
+ var events = silent ? [] : ['change'];
+
+ debounce_events(this, events, function() {
+ var $item, $option, $options;
+ var self = this;
+ var inputMode = self.settings.mode;
+ var i, active, value_next, wasFull;
+ value = hash_key(value);
+
+ if (self.items.indexOf(value) !== -1) {
+ if (inputMode === 'single') self.close();
+ return;
+ }
+
+ if (!self.options.hasOwnProperty(value)) return;
+ if (inputMode === 'single') self.clear(silent);
+ if (inputMode === 'multi' && self.isFull()) return;
+
+ $item = $(self.render('item', self.options[value]));
+ wasFull = self.isFull();
+ self.items.splice(self.caretPos, 0, value);
+ self.insertAtCaret($item);
+ if (!self.isPending || (!wasFull && self.isFull())) {
+ self.refreshState();
+ }
+
+ if (self.isSetup) {
+ $options = self.$dropdown_content.find('[data-selectable]');
+
+ // update menu / remove the option (if this is not one item being added as part of series)
+ if (!self.isPending) {
+ $option = self.getOption(value);
+ value_next = self.getAdjacentOption($option, 1).attr('data-value');
+ self.refreshOptions(self.isFocused && inputMode !== 'single');
+ if (value_next) {
+ self.setActiveOption(self.getOption(value_next));
+ }
+ }
+
+ // hide the menu if the maximum number of items have been selected or no options are left
+ if (!$options.length || self.isFull()) {
+ self.close();
+ } else {
+ self.positionDropdown();
+ }
+
+ self.updatePlaceholder();
+ self.trigger('item_add', value, $item);
+ self.updateOriginalInput({silent: silent});
+ }
+ });
+ },
+
+ /**
+ * Removes the selected item matching
+ * the provided value.
+ *
+ * @param {string} value
+ */
+ removeItem: function(value, silent) {
+ var self = this;
+ var $item, i, idx;
+
+ $item = (value instanceof $) ? value : self.getItem(value);
+ value = hash_key($item.attr('data-value'));
+ i = self.items.indexOf(value);
+
+ if (i !== -1) {
+ $item.remove();
+ if ($item.hasClass('active')) {
+ idx = self.$activeItems.indexOf($item[0]);
+ self.$activeItems.splice(idx, 1);
+ }
+
+ self.items.splice(i, 1);
+ self.lastQuery = null;
+ if (!self.settings.persist && self.userOptions.hasOwnProperty(value)) {
+ self.removeOption(value, silent);
+ }
+
+ if (i < self.caretPos) {
+ self.setCaret(self.caretPos - 1);
+ }
+
+ self.refreshState();
+ self.updatePlaceholder();
+ self.updateOriginalInput({silent: silent});
+ self.positionDropdown();
+ self.trigger('item_remove', value, $item);
+ }
+ },
+
+ /**
+ * Invokes the `create` method provided in the
+ * selectize options that should provide the data
+ * for the new item, given the user input.
+ *
+ * Once this completes, it will be added
+ * to the item list.
+ *
+ * @param {string} value
+ * @param {boolean} [triggerDropdown]
+ * @param {function} [callback]
+ * @return {boolean}
+ */
+ createItem: function(input, triggerDropdown) {
+ var self = this;
+ var caret = self.caretPos;
+ input = input || $.trim(self.$control_input.val() || '');
+
+ var callback = arguments[arguments.length - 1];
+ if (typeof callback !== 'function') callback = function() {};
+
+ if (typeof triggerDropdown !== 'boolean') {
+ triggerDropdown = true;
+ }
+
+ if (!self.canCreate(input)) {
+ callback();
+ return false;
+ }
+
+ self.lock();
+
+ var setup = (typeof self.settings.create === 'function') ? this.settings.create : function(input) {
+ var data = {};
+ data[self.settings.labelField] = input;
+ data[self.settings.valueField] = input;
+ return data;
+ };
+
+ var create = once(function(data) {
+ self.unlock();
+
+ if (!data || typeof data !== 'object') return callback();
+ var value = hash_key(data[self.settings.valueField]);
+ if (typeof value !== 'string') return callback();
+
+ self.setTextboxValue('');
+ self.addOption(data);
+ self.setCaret(caret);
+ self.addItem(value);
+ self.refreshOptions(triggerDropdown && self.settings.mode !== 'single');
+ callback(data);
+ });
+
+ var output = setup.apply(this, [input, create]);
+ if (typeof output !== 'undefined') {
+ create(output);
+ }
+
+ return true;
+ },
+
+ /**
+ * Re-renders the selected item lists.
+ */
+ refreshItems: function() {
+ this.lastQuery = null;
+
+ if (this.isSetup) {
+ this.addItem(this.items);
+ }
+
+ this.refreshState();
+ this.updateOriginalInput();
+ },
+
+ /**
+ * Updates all state-dependent attributes
+ * and CSS classes.
+ */
+ refreshState: function() {
+ this.refreshValidityState();
+ this.refreshClasses();
+ },
+
+ /**
+ * Update the `required` attribute of both input and control input.
+ *
+ * The `required` property needs to be activated on the control input
+ * for the error to be displayed at the right place. `required` also
+ * needs to be temporarily deactivated on the input since the input is
+ * hidden and can't show errors.
+ */
+ refreshValidityState: function() {
+ if (!this.isRequired) return false;
+
+ var invalid = !this.items.length;
+
+ this.isInvalid = invalid;
+ this.$control_input.prop('required', invalid);
+ this.$input.prop('required', !invalid);
+ },
+
+ /**
+ * Updates all state-dependent CSS classes.
+ */
+ refreshClasses: function() {
+ var self = this;
+ var isFull = self.isFull();
+ var isLocked = self.isLocked;
+
+ self.$wrapper
+ .toggleClass('rtl', self.rtl);
+
+ self.$control
+ .toggleClass('focus', self.isFocused)
+ .toggleClass('disabled', self.isDisabled)
+ .toggleClass('required', self.isRequired)
+ .toggleClass('invalid', self.isInvalid)
+ .toggleClass('locked', isLocked)
+ .toggleClass('full', isFull).toggleClass('not-full', !isFull)
+ .toggleClass('input-active', self.isFocused && !self.isInputHidden)
+ .toggleClass('dropdown-active', self.isOpen)
+ .toggleClass('has-options', !$.isEmptyObject(self.options))
+ .toggleClass('has-items', self.items.length > 0);
+
+ self.$control_input.data('grow', !isFull && !isLocked);
+ },
+
+ /**
+ * Determines whether or not more items can be added
+ * to the control without exceeding the user-defined maximum.
+ *
+ * @returns {boolean}
+ */
+ isFull: function() {
+ return this.settings.maxItems !== null && this.items.length >= this.settings.maxItems;
+ },
+
+ /**
+ * Refreshes the original or
+ * element to reflect the current state.
+ */
+ updateOriginalInput: function(opts) {
+ var i, n, options, label, self = this;
+ opts = opts || {};
+
+ if (self.tagType === TAG_SELECT) {
+ options = [];
+ for (i = 0, n = self.items.length; i < n; i++) {
+ label = self.options[self.items[i]][self.settings.labelField] || '';
+ options.push('' + escape_html(label) + ' ');
+ }
+ if (!options.length && !this.$input.attr('multiple')) {
+ options.push(' ');
+ }
+ self.$input.html(options.join(''));
+ } else {
+ self.$input.val(self.getValue());
+ self.$input.attr('value',self.$input.val());
+ }
+
+ if (self.isSetup) {
+ if (!opts.silent) {
+ self.trigger('change', self.$input.val());
+ }
+ }
+ },
+
+ /**
+ * Shows/hide the input placeholder depending
+ * on if there items in the list already.
+ */
+ updatePlaceholder: function() {
+ if (!this.settings.placeholder) return;
+ var $input = this.$control_input;
+
+ if (this.items.length) {
+ $input.removeAttr('placeholder');
+ } else {
+ $input.attr('placeholder', this.settings.placeholder);
+ }
+ $input.triggerHandler('update', {force: true});
+ },
+
+ /**
+ * Shows the autocomplete dropdown containing
+ * the available options.
+ */
+ open: function() {
+ var self = this;
+
+ if (self.isLocked || self.isOpen || (self.settings.mode === 'multi' && self.isFull())) return;
+ self.focus();
+ self.isOpen = true;
+ self.refreshState();
+ self.$dropdown.css({visibility: 'hidden', display: 'block'});
+ self.positionDropdown();
+ self.$dropdown.css({visibility: 'visible'});
+ self.trigger('dropdown_open', self.$dropdown);
+ },
+
+ /**
+ * Closes the autocomplete dropdown menu.
+ */
+ close: function() {
+ var self = this;
+ var trigger = self.isOpen;
+
+ if (self.settings.mode === 'single' && self.items.length) {
+ self.hideInput();
+ self.$control_input.blur(); // close keyboard on iOS
+ }
+
+ self.isOpen = false;
+ self.$dropdown.hide();
+ self.setActiveOption(null);
+ self.refreshState();
+
+ if (trigger) self.trigger('dropdown_close', self.$dropdown);
+ },
+
+ /**
+ * Calculates and applies the appropriate
+ * position of the dropdown.
+ */
+ positionDropdown: function() {
+ var $control = this.$control;
+ var offset = this.settings.dropdownParent === 'body' ? $control.offset() : $control.position();
+ offset.top += $control.outerHeight(true);
+
+ this.$dropdown.css({
+ width : $control.outerWidth(),
+ top : offset.top,
+ left : offset.left
+ });
+ },
+
+ /**
+ * Resets / clears all selected items
+ * from the control.
+ *
+ * @param {boolean} silent
+ */
+ clear: function(silent) {
+ var self = this;
+
+ if (!self.items.length) return;
+ self.$control.children(':not(input)').remove();
+ self.items = [];
+ self.lastQuery = null;
+ self.setCaret(0);
+ self.setActiveItem(null);
+ self.updatePlaceholder();
+ self.updateOriginalInput({silent: silent});
+ self.refreshState();
+ self.showInput();
+ self.trigger('clear');
+ },
+
+ /**
+ * A helper method for inserting an element
+ * at the current caret position.
+ *
+ * @param {object} $el
+ */
+ insertAtCaret: function($el) {
+ var caret = Math.min(this.caretPos, this.items.length);
+ if (caret === 0) {
+ this.$control.prepend($el);
+ } else {
+ $(this.$control[0].childNodes[caret]).before($el);
+ }
+ this.setCaret(caret + 1);
+ },
+
+ /**
+ * Removes the current selected item(s).
+ *
+ * @param {object} e (optional)
+ * @returns {boolean}
+ */
+ deleteSelection: function(e) {
+ var i, n, direction, selection, values, caret, option_select, $option_select, $tail;
+ var self = this;
+
+ direction = (e && e.keyCode === KEY_BACKSPACE) ? -1 : 1;
+ selection = getSelection(self.$control_input[0]);
+
+ if (self.$activeOption && !self.settings.hideSelected) {
+ option_select = self.getAdjacentOption(self.$activeOption, -1).attr('data-value');
+ }
+
+ // determine items that will be removed
+ values = [];
+
+ if (self.$activeItems.length) {
+ $tail = self.$control.children('.active:' + (direction > 0 ? 'last' : 'first'));
+ caret = self.$control.children(':not(input)').index($tail);
+ if (direction > 0) { caret++; }
+
+ for (i = 0, n = self.$activeItems.length; i < n; i++) {
+ values.push($(self.$activeItems[i]).attr('data-value'));
+ }
+ if (e) {
+ e.preventDefault();
+ e.stopPropagation();
+ }
+ } else if ((self.isFocused || self.settings.mode === 'single') && self.items.length) {
+ if (direction < 0 && selection.start === 0 && selection.length === 0) {
+ values.push(self.items[self.caretPos - 1]);
+ } else if (direction > 0 && selection.start === self.$control_input.val().length) {
+ values.push(self.items[self.caretPos]);
+ }
+ }
+
+ // allow the callback to abort
+ if (!values.length || (typeof self.settings.onDelete === 'function' && self.settings.onDelete.apply(self, [values]) === false)) {
+ return false;
+ }
+
+ // perform removal
+ if (typeof caret !== 'undefined') {
+ self.setCaret(caret);
+ }
+ while (values.length) {
+ self.removeItem(values.pop());
+ }
+
+ self.showInput();
+ self.positionDropdown();
+ self.refreshOptions(true);
+
+ // select previous option
+ if (option_select) {
+ $option_select = self.getOption(option_select);
+ if ($option_select.length) {
+ self.setActiveOption($option_select);
+ }
+ }
+
+ return true;
+ },
+
+ /**
+ * Selects the previous / next item (depending
+ * on the `direction` argument).
+ *
+ * > 0 - right
+ * < 0 - left
+ *
+ * @param {int} direction
+ * @param {object} e (optional)
+ */
+ advanceSelection: function(direction, e) {
+ var tail, selection, idx, valueLength, cursorAtEdge, $tail;
+ var self = this;
+
+ if (direction === 0) return;
+ if (self.rtl) direction *= -1;
+
+ tail = direction > 0 ? 'last' : 'first';
+ selection = getSelection(self.$control_input[0]);
+
+ if (self.isFocused && !self.isInputHidden) {
+ valueLength = self.$control_input.val().length;
+ cursorAtEdge = direction < 0
+ ? selection.start === 0 && selection.length === 0
+ : selection.start === valueLength;
+
+ if (cursorAtEdge && !valueLength) {
+ self.advanceCaret(direction, e);
+ }
+ } else {
+ $tail = self.$control.children('.active:' + tail);
+ if ($tail.length) {
+ idx = self.$control.children(':not(input)').index($tail);
+ self.setActiveItem(null);
+ self.setCaret(direction > 0 ? idx + 1 : idx);
+ }
+ }
+ },
+
+ /**
+ * Moves the caret left / right.
+ *
+ * @param {int} direction
+ * @param {object} e (optional)
+ */
+ advanceCaret: function(direction, e) {
+ var self = this, fn, $adj;
+
+ if (direction === 0) return;
+
+ fn = direction > 0 ? 'next' : 'prev';
+ if (self.isShiftDown) {
+ $adj = self.$control_input[fn]();
+ if ($adj.length) {
+ self.hideInput();
+ self.setActiveItem($adj);
+ e && e.preventDefault();
+ }
+ } else {
+ self.setCaret(self.caretPos + direction);
+ }
+ },
+
+ /**
+ * Moves the caret to the specified index.
+ *
+ * @param {int} i
+ */
+ setCaret: function(i) {
+ var self = this;
+
+ if (self.settings.mode === 'single') {
+ i = self.items.length;
+ } else {
+ i = Math.max(0, Math.min(self.items.length, i));
+ }
+
+ if(!self.isPending) {
+ // the input must be moved by leaving it in place and moving the
+ // siblings, due to the fact that focus cannot be restored once lost
+ // on mobile webkit devices
+ var j, n, fn, $children, $child;
+ $children = self.$control.children(':not(input)');
+ for (j = 0, n = $children.length; j < n; j++) {
+ $child = $($children[j]).detach();
+ if (j < i) {
+ self.$control_input.before($child);
+ } else {
+ self.$control.append($child);
+ }
+ }
+ }
+
+ self.caretPos = i;
+ },
+
+ /**
+ * Disables user input on the control. Used while
+ * items are being asynchronously created.
+ */
+ lock: function() {
+ this.close();
+ this.isLocked = true;
+ this.refreshState();
+ },
+
+ /**
+ * Re-enables user input on the control.
+ */
+ unlock: function() {
+ this.isLocked = false;
+ this.refreshState();
+ },
+
+ /**
+ * Disables user input on the control completely.
+ * While disabled, it cannot receive focus.
+ */
+ disable: function() {
+ var self = this;
+ self.$input.prop('disabled', true);
+ self.$control_input.prop('disabled', true).prop('tabindex', -1);
+ self.isDisabled = true;
+ self.lock();
+ },
+
+ /**
+ * Enables the control so that it can respond
+ * to focus and user input.
+ */
+ enable: function() {
+ var self = this;
+ self.$input.prop('disabled', false);
+ self.$control_input.prop('disabled', false).prop('tabindex', self.tabIndex);
+ self.isDisabled = false;
+ self.unlock();
+ },
+
+ /**
+ * Completely destroys the control and
+ * unbinds all event listeners so that it can
+ * be garbage collected.
+ */
+ destroy: function() {
+ var self = this;
+ var eventNS = self.eventNS;
+ var revertSettings = self.revertSettings;
+
+ self.trigger('destroy');
+ self.off();
+ self.$wrapper.remove();
+ self.$dropdown.remove();
+
+ self.$input
+ .html('')
+ .append(revertSettings.$children)
+ .removeAttr('tabindex')
+ .removeClass('selectized')
+ .attr({tabindex: revertSettings.tabindex})
+ .show();
+
+ self.$control_input.removeData('grow');
+ self.$input.removeData('selectize');
+
+ $(window).off(eventNS);
+ $(document).off(eventNS);
+ $(document.body).off(eventNS);
+
+ delete self.$input[0].selectize;
+ },
+
+ /**
+ * A helper method for rendering "item" and
+ * "option" templates, given the data.
+ *
+ * @param {string} templateName
+ * @param {object} data
+ * @returns {string}
+ */
+ render: function(templateName, data) {
+ var value, id, label;
+ var html = '';
+ var cache = false;
+ var self = this;
+ var regex_tag = /^[\t \r\n]*<([a-z][a-z0-9\-_]*(?:\:[a-z][a-z0-9\-_]*)?)/i;
+
+ if (templateName === 'option' || templateName === 'item') {
+ value = hash_key(data[self.settings.valueField]);
+ cache = !!value;
+ }
+
+ // pull markup from cache if it exists
+ if (cache) {
+ if (!isset(self.renderCache[templateName])) {
+ self.renderCache[templateName] = {};
+ }
+ if (self.renderCache[templateName].hasOwnProperty(value)) {
+ return self.renderCache[templateName][value];
+ }
+ }
+
+ // render markup
+ html = $(self.settings.render[templateName].apply(this, [data, escape_html]));
+
+ // add mandatory attributes
+ if (templateName === 'option' || templateName === 'option_create') {
+ html.attr('data-selectable', '');
+ }
+ else if (templateName === 'optgroup') {
+ id = data[self.settings.optgroupValueField] || '';
+ html.attr('data-group', id);
+ }
+ if (templateName === 'option' || templateName === 'item') {
+ html.attr('data-value', value || '');
+ }
+
+ // update cache
+ if (cache) {
+ self.renderCache[templateName][value] = html[0];
+ }
+
+ return html[0];
+ },
+
+ /**
+ * Clears the render cache for a template. If
+ * no template is given, clears all render
+ * caches.
+ *
+ * @param {string} templateName
+ */
+ clearCache: function(templateName) {
+ var self = this;
+ if (typeof templateName === 'undefined') {
+ self.renderCache = {};
+ } else {
+ delete self.renderCache[templateName];
+ }
+ },
+
+ /**
+ * Determines whether or not to display the
+ * create item prompt, given a user input.
+ *
+ * @param {string} input
+ * @return {boolean}
+ */
+ canCreate: function(input) {
+ var self = this;
+ if (!self.settings.create) return false;
+ var filter = self.settings.createFilter;
+ return input.length
+ && (typeof filter !== 'function' || filter.apply(self, [input]))
+ && (typeof filter !== 'string' || new RegExp(filter).test(input))
+ && (!(filter instanceof RegExp) || filter.test(input));
+ }
+
+ });
+
+
+ Selectize.count = 0;
+ Selectize.defaults = {
+ options: [],
+ optgroups: [],
+
+ plugins: [],
+ delimiter: ',',
+ splitOn: null, // regexp or string for splitting up values from a paste command
+ persist: true,
+ diacritics: true,
+ create: false,
+ createOnBlur: false,
+ createFilter: null,
+ highlight: true,
+ openOnFocus: true,
+ maxOptions: 1000,
+ maxItems: null,
+ hideSelected: null,
+ addPrecedence: false,
+ selectOnTab: false,
+ preload: false,
+ allowEmptyOption: false,
+ closeAfterSelect: false,
+ submitOnReturn: true, // RJC
+
+ scrollDuration: 60,
+ loadThrottle: 300,
+ loadingClass: 'loading',
+
+ dataAttr: 'data-data',
+ optgroupField: 'optgroup',
+ valueField: 'value',
+ labelField: 'text',
+ optgroupLabelField: 'label',
+ optgroupValueField: 'value',
+ lockOptgroupOrder: false,
+
+ sortField: '$order',
+ searchField: ['text'],
+ searchConjunction: 'and',
+
+ mode: null,
+ wrapperClass: 'selectize-control',
+ inputClass: 'selectize-input',
+ dropdownClass: 'selectize-dropdown',
+ dropdownContentClass: 'selectize-dropdown-content',
+
+ dropdownParent: null,
+
+ copyClassesToDropdown: true,
+
+ /*
+ load : null, // function(query, callback) { ... }
+ score : null, // function(search) { ... }
+ onInitialize : null, // function() { ... }
+ onChange : null, // function(value) { ... }
+ onItemAdd : null, // function(value, $item) { ... }
+ onItemRemove : null, // function(value) { ... }
+ onClear : null, // function() { ... }
+ onOptionAdd : null, // function(value, data) { ... }
+ onOptionRemove : null, // function(value) { ... }
+ onOptionClear : null, // function() { ... }
+ onOptionGroupAdd : null, // function(id, data) { ... }
+ onOptionGroupRemove : null, // function(id) { ... }
+ onOptionGroupClear : null, // function() { ... }
+ onDropdownOpen : null, // function($dropdown) { ... }
+ onDropdownClose : null, // function($dropdown) { ... }
+ onType : null, // function(str) { ... }
+ onDelete : null, // function(values) { ... }
+ */
+
+ render: {
+ /*
+ item: null,
+ optgroup: null,
+ optgroup_header: null,
+ option: null,
+ option_create: null
+ */
+ }
+ };
+
+
+ $.fn.selectize = function(settings_user) {
+ var defaults = $.fn.selectize.defaults;
+ var settings = $.extend({}, defaults, settings_user);
+ var attr_data = settings.dataAttr;
+ var field_label = settings.labelField;
+ var field_value = settings.valueField;
+ var field_optgroup = settings.optgroupField;
+ var field_optgroup_label = settings.optgroupLabelField;
+ var field_optgroup_value = settings.optgroupValueField;
+
+ /**
+ * Initializes selectize from a element.
+ *
+ * @param {object} $input
+ * @param {object} settings_element
+ */
+ var init_textbox = function($input, settings_element) {
+ var i, n, values, option;
+
+ var data_raw = $input.attr(attr_data);
+
+ if (!data_raw) {
+ var value = $.trim($input.val() || '');
+ if (!settings.allowEmptyOption && !value.length) return;
+ values = value.split(settings.delimiter);
+ for (i = 0, n = values.length; i < n; i++) {
+ option = {};
+ option[field_label] = values[i];
+ option[field_value] = values[i];
+ settings_element.options.push(option);
+ }
+ settings_element.items = values;
+ } else {
+ settings_element.options = JSON.parse(data_raw);
+ for (i = 0, n = settings_element.options.length; i < n; i++) {
+ settings_element.items.push(settings_element.options[i][field_value]);
+ }
+ }
+ };
+
+ /**
+ * Initializes selectize from a element.
+ *
+ * @param {object} $input
+ * @param {object} settings_element
+ */
+ var init_select = function($input, settings_element) {
+ var i, n, tagName, $children, order = 0;
+ var options = settings_element.options;
+ var optionsMap = {};
+
+ var readData = function($el) {
+ var data = attr_data && $el.attr(attr_data);
+ if (typeof data === 'string' && data.length) {
+ return JSON.parse(data);
+ }
+ return null;
+ };
+
+ var addOption = function($option, group) {
+ $option = $($option);
+
+ var value = hash_key($option.val());
+ if (!value && !settings.allowEmptyOption) return;
+
+ // if the option already exists, it's probably been
+ // duplicated in another optgroup. in this case, push
+ // the current group to the "optgroup" property on the
+ // existing option so that it's rendered in both places.
+ if (optionsMap.hasOwnProperty(value)) {
+ if (group) {
+ var arr = optionsMap[value][field_optgroup];
+ if (!arr) {
+ optionsMap[value][field_optgroup] = group;
+ } else if (!$.isArray(arr)) {
+ optionsMap[value][field_optgroup] = [arr, group];
+ } else {
+ arr.push(group);
+ }
+ }
+ return;
+ }
+
+ var option = readData($option) || {};
+ option[field_label] = option[field_label] || $option.text();
+ option[field_value] = option[field_value] || value;
+ option[field_optgroup] = option[field_optgroup] || group;
+
+ optionsMap[value] = option;
+ options.push(option);
+
+ if ($option.is(':selected')) {
+ settings_element.items.push(value);
+ }
+ };
+
+ var addGroup = function($optgroup) {
+ var i, n, id, optgroup, $options;
+
+ $optgroup = $($optgroup);
+ id = $optgroup.attr('label');
+
+ if (id) {
+ optgroup = readData($optgroup) || {};
+ optgroup[field_optgroup_label] = id;
+ optgroup[field_optgroup_value] = id;
+ settings_element.optgroups.push(optgroup);
+ }
+
+ $options = $('option', $optgroup);
+ for (i = 0, n = $options.length; i < n; i++) {
+ addOption($options[i], id);
+ }
+ };
+
+ settings_element.maxItems = $input.attr('multiple') ? null : 1;
+
+ $children = $input.children();
+ for (i = 0, n = $children.length; i < n; i++) {
+ tagName = $children[i].tagName.toLowerCase();
+ if (tagName === 'optgroup') {
+ addGroup($children[i]);
+ } else if (tagName === 'option') {
+ addOption($children[i]);
+ }
+ }
+ };
+
+ return this.each(function() {
+ if (this.selectize) return;
+
+ var instance;
+ var $input = $(this);
+ var tag_name = this.tagName.toLowerCase();
+ var placeholder = $input.attr('placeholder') || $input.attr('data-placeholder');
+ if (!placeholder && !settings.allowEmptyOption) {
+ placeholder = $input.children('option[value=""]').text();
+ }
+
+ var settings_element = {
+ 'placeholder' : placeholder,
+ 'options' : [],
+ 'optgroups' : [],
+ 'items' : []
+ };
+
+ if (tag_name === 'select') {
+ init_select($input, settings_element);
+ } else {
+ init_textbox($input, settings_element);
+ }
+
+ instance = new Selectize($input, $.extend(true, {}, defaults, settings_element, settings_user));
+ });
+ };
+
+ $.fn.selectize.defaults = Selectize.defaults;
+ $.fn.selectize.support = {
+ validity: SUPPORTS_VALIDITY_API
+ };
+
+
+ Selectize.define('drag_drop', function(options) {
+ if (!$.fn.sortable) throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".');
+ if (this.settings.mode !== 'multi') return;
+ var self = this;
+
+ self.lock = (function() {
+ var original = self.lock;
+ return function() {
+ var sortable = self.$control.data('sortable');
+ if (sortable) sortable.disable();
+ return original.apply(self, arguments);
+ };
+ })();
+
+ self.unlock = (function() {
+ var original = self.unlock;
+ return function() {
+ var sortable = self.$control.data('sortable');
+ if (sortable) sortable.enable();
+ return original.apply(self, arguments);
+ };
+ })();
+
+ self.setup = (function() {
+ var original = self.setup;
+ return function() {
+ original.apply(this, arguments);
+
+ var $control = self.$control.sortable({
+ items: '[data-value]',
+ forcePlaceholderSize: true,
+ disabled: self.isLocked,
+ start: function(e, ui) {
+ ui.placeholder.css('width', ui.helper.css('width'));
+ $control.css({overflow: 'visible'});
+ },
+ stop: function() {
+ $control.css({overflow: 'hidden'});
+ var active = self.$activeItems ? self.$activeItems.slice() : null;
+ var values = [];
+ $control.children('[data-value]').each(function() {
+ values.push($(this).attr('data-value'));
+ });
+ self.setValue(values);
+ self.setActiveItem(active);
+ }
+ });
+ };
+ })();
+
+ });
+
+ Selectize.define('dropdown_header', function(options) {
+ var self = this;
+
+ options = $.extend({
+ title : 'Untitled',
+ headerClass : 'selectize-dropdown-header',
+ titleRowClass : 'selectize-dropdown-header-title',
+ labelClass : 'selectize-dropdown-header-label',
+ closeClass : 'selectize-dropdown-header-close',
+
+ html: function(data) {
+ return (
+ ''
+ );
+ }
+ }, options);
+
+ self.setup = (function() {
+ var original = self.setup;
+ return function() {
+ original.apply(self, arguments);
+ self.$dropdown_header = $(options.html(options));
+ self.$dropdown.prepend(self.$dropdown_header);
+ };
+ })();
+
+ });
+
+ Selectize.define('optgroup_columns', function(options) {
+ var self = this;
+
+ options = $.extend({
+ equalizeWidth : true,
+ equalizeHeight : true
+ }, options);
+
+ this.getAdjacentOption = function($option, direction) {
+ var $options = $option.closest('[data-group]').find('[data-selectable]');
+ var index = $options.index($option) + direction;
+
+ return index >= 0 && index < $options.length ? $options.eq(index) : $();
+ };
+
+ this.onKeyDown = (function() {
+ var original = self.onKeyDown;
+ return function(e) {
+ var index, $option, $options, $optgroup;
+
+ if (this.isOpen && (e.keyCode === KEY_LEFT || e.keyCode === KEY_RIGHT)) {
+ self.ignoreHover = true;
+ $optgroup = this.$activeOption.closest('[data-group]');
+ index = $optgroup.find('[data-selectable]').index(this.$activeOption);
+
+ if(e.keyCode === KEY_LEFT) {
+ $optgroup = $optgroup.prev('[data-group]');
+ } else {
+ $optgroup = $optgroup.next('[data-group]');
+ }
+
+ $options = $optgroup.find('[data-selectable]');
+ $option = $options.eq(Math.min($options.length - 1, index));
+ if ($option.length) {
+ this.setActiveOption($option);
+ }
+ return;
+ }
+
+ return original.apply(this, arguments);
+ };
+ })();
+
+ var getScrollbarWidth = function() {
+ var div;
+ var width = getScrollbarWidth.width;
+ var doc = document;
+
+ if (typeof width === 'undefined') {
+ div = doc.createElement('div');
+ div.innerHTML = '';
+ div = div.firstChild;
+ doc.body.appendChild(div);
+ width = getScrollbarWidth.width = div.offsetWidth - div.clientWidth;
+ doc.body.removeChild(div);
+ }
+ return width;
+ };
+
+ var equalizeSizes = function() {
+ var i, n, height_max, width, width_last, width_parent, $optgroups;
+
+ $optgroups = $('[data-group]', self.$dropdown_content);
+ n = $optgroups.length;
+ if (!n || !self.$dropdown_content.width()) return;
+
+ if (options.equalizeHeight) {
+ height_max = 0;
+ for (i = 0; i < n; i++) {
+ height_max = Math.max(height_max, $optgroups.eq(i).height());
+ }
+ $optgroups.css({height: height_max});
+ }
+
+ if (options.equalizeWidth) {
+ width_parent = self.$dropdown_content.innerWidth() - getScrollbarWidth();
+ width = Math.round(width_parent / n);
+ $optgroups.css({width: width});
+ if (n > 1) {
+ width_last = width_parent - width * (n - 1);
+ $optgroups.eq(n - 1).css({width: width_last});
+ }
+ }
+ };
+
+ if (options.equalizeHeight || options.equalizeWidth) {
+ hook.after(this, 'positionDropdown', equalizeSizes);
+ hook.after(this, 'refreshOptions', equalizeSizes);
+ }
+
+
+ });
+
+ Selectize.define('remove_button', function(options) {
+ options = $.extend({
+ label : '×',
+ title : 'Remove',
+ className : 'remove',
+ append : true
+ }, options);
+
+ var singleClose = function(thisRef, options) {
+
+ options.className = 'remove-single';
+
+ var self = thisRef;
+ var html = '' + options.label + ' ';
+
+ /**
+ * Appends an element as a child (with raw HTML).
+ *
+ * @param {string} html_container
+ * @param {string} html_element
+ * @return {string}
+ */
+ var append = function(html_container, html_element) {
+ return html_container + html_element;
+ };
+
+ thisRef.setup = (function() {
+ var original = self.setup;
+ return function() {
+ // override the item rendering method to add the button to each
+ if (options.append) {
+ var id = $(self.$input.context).attr('id');
+ var selectizer = $('#'+id);
+
+ var render_item = self.settings.render.item;
+ self.settings.render.item = function(data) {
+ return append(render_item.apply(thisRef, arguments), html);
+ };
+ }
+
+ original.apply(thisRef, arguments);
+
+ // add event listener
+ thisRef.$control.on('click', '.' + options.className, function(e) {
+ e.preventDefault();
+ if (self.isLocked) return;
+
+ self.clear();
+ });
+
+ };
+ })();
+ };
+
+ var multiClose = function(thisRef, options) {
+
+ var self = thisRef;
+ var html = '' + options.label + ' ';
+
+ /**
+ * Appends an element as a child (with raw HTML).
+ *
+ * @param {string} html_container
+ * @param {string} html_element
+ * @return {string}
+ */
+ var append = function(html_container, html_element) {
+ var pos = html_container.search(/(<\/[^>]+>\s*)$/);
+ return html_container.substring(0, pos) + html_element + html_container.substring(pos);
+ };
+
+ thisRef.setup = (function() {
+ var original = self.setup;
+ return function() {
+ // override the item rendering method to add the button to each
+ if (options.append) {
+ var render_item = self.settings.render.item;
+ self.settings.render.item = function(data) {
+ return append(render_item.apply(thisRef, arguments), html);
+ };
+ }
+
+ original.apply(thisRef, arguments);
+
+ // add event listener
+ thisRef.$control.on('click', '.' + options.className, function(e) {
+ e.preventDefault();
+ if (self.isLocked) return;
+
+ var $item = $(e.currentTarget).parent();
+ self.setActiveItem($item);
+ if (self.deleteSelection()) {
+ self.setCaret(self.items.length);
+ }
+ });
+
+ };
+ })();
+ };
+
+ if (this.settings.mode === 'single') {
+ singleClose(this, options);
+ return;
+ } else {
+ multiClose(this, options);
+ }
+ });
+
+
+ Selectize.define('restore_on_backspace', function(options) {
+ var self = this;
+
+ options.text = options.text || function(option) {
+ return option[this.settings.labelField];
+ };
+
+ this.onKeyDown = (function() {
+ var original = self.onKeyDown;
+ return function(e) {
+ var index, option;
+ if (e.keyCode === KEY_BACKSPACE && this.$control_input.val() === '' && !this.$activeItems.length) {
+ index = this.caretPos - 1;
+ if (index >= 0 && index < this.items.length) {
+ option = this.options[this.items[index]];
+ if (this.deleteSelection(e)) {
+ this.setTextboxValue(options.text.apply(this, [option]));
+ this.refreshOptions(true);
+ }
+ e.preventDefault();
+ return;
+ }
+ }
+ return original.apply(this, arguments);
+ };
+ })();
+ });
+
+
+ return Selectize;
+}));
\ No newline at end of file
diff --git a/wire/modules/Jquery/JqueryUI/selectize/js/standalone/selectize.min.js b/wire/modules/Jquery/JqueryUI/selectize/js/standalone/selectize.min.js
new file mode 100644
index 00000000..f511c9c2
--- /dev/null
+++ b/wire/modules/Jquery/JqueryUI/selectize/js/standalone/selectize.min.js
@@ -0,0 +1 @@
+(function(a,b){if(typeof define==="function"&&define.amd){define("sifter",b)}else{if(typeof exports==="object"){module.exports=b()}else{a.Sifter=b()}}}(this,function(){var h=function(j,k){this.items=j;this.settings=k||{diacritics:true}};h.prototype.tokenize=function(m){m=b(String(m||"").toLowerCase());if(!m||!m.length){return[]}var j,q,l,k;var o=[];var p=m.split(/ +/);for(j=0,q=p.length;j0){q.items.push({score:k,id:t})}})}else{p.iterator(p.items,function(s,t){q.items.push({score:1,id:t})})}j=p.getSortFunction(q,r);if(j){q.items.sort(j)}q.total=q.items.length;if(typeof r.limit==="number"){q.items=q.items.slice(0,r.limit)}return q};var f=function(k,j){if(typeof k==="number"&&typeof j==="number"){return k>j?1:(kj){return 1}if(j>k){return -1}return 0};var d=function(l,j){var p,q,m,o;for(p=1,q=arguments.length;p=0&&V.data.length>0){var Z=V.data.match(R);var Y=document.createElement("span");Y.className="highlight";var W=V.splitText(aa);var T=W.splitText(Z[0].length);var U=W.cloneNode(true);Y.appendChild(U);W.parentNode.replaceChild(Y,W);ab=1}}else{if(V.nodeType===1&&V.childNodes&&!/(script|style)/i.test(V.tagName)){for(var X=0;X/g,">").replace(/"/g,""")};var f=function(P){return(P+"").replace(/\$/g,"$$$$")};var s={};s.before=function(P,S,R){var Q=P[S];P[S]=function(){R.apply(P,arguments);return Q.apply(P,arguments)}};s.after=function(P,S,R){var Q=P[S];P[S]=function(){var T=Q.apply(P,arguments);R.apply(P,arguments);return T}};var r=function(P){var Q=false;return function(){if(Q){return}Q=true;P.apply(this,arguments)}};var g=function(Q,P){var R;return function(){var S=this;var T=arguments;window.clearTimeout(R);R=window.setTimeout(function(){Q.apply(S,T)},P)}};var a=function(P,R,T){var S;var Q=P.trigger;var U={};P.trigger=function(){var V=arguments[0];if(R.indexOf(V)!==-1){U[V]=arguments}else{return Q.apply(P,arguments)}};T.apply(P,[]);P.trigger=Q;for(S in U){if(U.hasOwnProperty(S)){Q.apply(P,U[S])}}};var A=function(S,R,P,Q){S.on(R,P,function(T){var U=T.target;while(U&&U.parentNode!==S[0]){U=U.parentNode}T.currentTarget=U;return Q.apply(this,[T])})};var l=function(R){var Q={};if("selectionStart" in R){Q.start=R.selectionStart;Q.length=R.selectionEnd-Q.start}else{if(document.selection){R.focus();var S=document.selection.createRange();var P=document.selection.createRange().text.length;S.moveStart("character",-R.value.length);Q.start=S.text.length-P;Q.length=P}}return Q};var n=function(S,T,Q){var P,U,R={};if(Q){for(P=0,U=Q.length;P").css({position:"absolute",top:-99999,left:-99999,width:"auto",padding:0,whiteSpace:"pre"}).text(S).appendTo("body");n(R,Q,["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"]);var P=Q.width();Q.remove();return P};var L=function(R){var P=null;var Q=function(V,ab){var Z,aa,W,Y,S;var T,U,X;V=V||window.event||{};ab=ab||{};if(V.metaKey||V.altKey){return}if(!ab.force&&R.data("grow")===false){return}Z=R.val();if(V.type&&V.type.toLowerCase()==="keydown"){aa=V.keyCode;W=((aa>=97&&aa<=122)||(aa>=65&&aa<=90)||(aa>=48&&aa<=57)||aa===32);if(aa===q||aa===o){X=l(R[0]);if(X.length){Z=Z.substring(0,X.start)+Z.substring(X.start+X.length)}else{if(aa===o&&X.start){Z=Z.substring(0,X.start-1)+Z.substring(X.start+1)}else{if(aa===q&&typeof X.start!=="undefined"){Z=Z.substring(0,X.start)+Z.substring(X.start+1)}}}}else{if(W){T=V.shiftKey;U=String.fromCharCode(V.keyCode);if(T){U=U.toUpperCase()}else{U=U.toLowerCase()}Z+=U}}}Y=R.attr("placeholder");if(!Z&&Y){Z=Y}S=K(Z,R)+4;if(S!==P){P=S;R.width(S);R.triggerHandler("resize")}};R.on("keydown keyup update blur",Q);Q()};var E=function(Q){var P=document.createElement("div");P.appendChild(Q.cloneNode(true));return P.innerHTML};var d=function(R,Q){if(!Q){Q={}}var P="Selectize";console.error(P+": "+R);if(Q.explanation){if(console.group){console.group()}console.error(Q.explanation);if(console.group){console.groupEnd()}}};var c=function(U,R){var W,S,P,Q,V,X=this;V=U[0];V.selectize=X;var T=window.getComputedStyle&&window.getComputedStyle(V,null);Q=T?T.getPropertyValue("direction"):V.currentStyle&&V.currentStyle.direction;Q=Q||U.parents("[dir]:first").attr("dir")||"";v.extend(X,{order:0,settings:R,$input:U,tabIndex:U.attr("tabindex")||"",tagType:V.tagName.toLowerCase()==="select"?k:h,rtl:/rtl/i.test(Q),eventNS:".selectize"+(++c.count),highlightedValue:null,isOpen:false,isDisabled:false,isRequired:U.is("[required]"),isInvalid:false,isLocked:false,isFocused:false,isInputHidden:false,isSetup:false,isShiftDown:false,isCmdDown:false,isCtrlDown:false,ignoreFocus:false,ignoreBlur:false,ignoreHover:false,hasOptions:false,currentResults:null,lastValue:"",caretPos:0,loading:0,loadedSearches:{},$activeOption:null,$activeItems:[],optgroups:{},options:{},userOptions:{},items:[],renderCache:{},onSearchChange:R.loadThrottle===null?X.onSearchChange:g(X.onSearchChange,R.loadThrottle)});X.sifter=new m(this.options,{diacritics:R.diacritics});if(X.settings.options){for(S=0,P=X.settings.options.length;S ").addClass(ac.wrapperClass).addClass(ad).addClass(ah);ae=v("
").addClass(ac.inputClass).addClass("items").appendTo(aa);Q=v('
').appendTo(ae).attr("tabindex",R.is(":disabled")?"-1":V.tabIndex);ab=v(ac.dropdownParent||aa);S=v("
").addClass(ac.dropdownClass).addClass(ah).hide().appendTo(ab);W=v("
").addClass(ac.dropdownContentClass).appendTo(S);if(Z=R.attr("id")){Q.attr("id",Z+"-selectized");v("label[for='"+Z+"']").attr("for",Z+"-selectized")}if(V.settings.copyClassesToDropdown){S.addClass(ad)}aa.css({width:R[0].style.width});if(V.plugins.names.length){X="plugin-"+V.plugins.names.join(" plugin-");aa.addClass(X);S.addClass(X)}if((ac.maxItems===null||ac.maxItems>1)&&V.tagType===k){R.attr("multiple","multiple")}if(V.settings.placeholder){Q.attr("placeholder",ac.placeholder)}if(!V.settings.splitOn&&V.settings.delimiter){var P=V.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&");V.settings.splitOn=new RegExp("\\s*"+P+"+\\s*")}if(R.attr("autocorrect")){Q.attr("autocorrect",R.attr("autocorrect"))}if(R.attr("autocapitalize")){Q.attr("autocapitalize",R.attr("autocapitalize"))}V.$wrapper=aa;V.$control=ae;V.$control_input=Q;V.$dropdown=S;V.$dropdown_content=W;S.on("mouseenter","[data-selectable]",function(){return V.onOptionHover.apply(V,arguments)});S.on("mousedown click","[data-selectable]",function(){return V.onOptionSelect.apply(V,arguments)});A(ae,"mousedown","*:not(input)",function(){return V.onItemSelect.apply(V,arguments)});L(Q);ae.on({mousedown:function(){return V.onMouseDown.apply(V,arguments)},click:function(){return V.onClick.apply(V,arguments)}});Q.on({mousedown:function(ai){ai.stopPropagation()},keydown:function(){return V.onKeyDown.apply(V,arguments)},keyup:function(){return V.onKeyUp.apply(V,arguments)},keypress:function(){return V.onKeyPress.apply(V,arguments)},resize:function(){V.positionDropdown.apply(V,[])},blur:function(){return V.onBlur.apply(V,arguments)},focus:function(){V.ignoreBlur=false;return V.onFocus.apply(V,arguments)},paste:function(){return V.onPaste.apply(V,arguments)}});ag.on("keydown"+Y,function(ai){V.isCmdDown=ai[b?"metaKey":"ctrlKey"];V.isCtrlDown=ai[b?"altKey":"ctrlKey"];V.isShiftDown=ai.shiftKey});ag.on("keyup"+Y,function(ai){if(ai.keyCode===e){V.isCtrlDown=false}if(ai.keyCode===j){V.isShiftDown=false}if(ai.keyCode===J){V.isCmdDown=false}});ag.on("mousedown"+Y,function(ai){if(V.isFocused){if(ai.target===V.$dropdown[0]||ai.target.parentNode===V.$dropdown[0]){return false}if(!V.$control.has(ai.target).length&&ai.target!==V.$control[0]){V.blur(ai.target)}}});U.on(["scroll"+Y,"resize"+Y].join(" "),function(){if(V.isOpen){V.positionDropdown.apply(V,arguments)}});U.on("mousemove"+Y,function(){V.ignoreHover=false});this.revertSettings={$children:R.children().detach(),tabindex:R.attr("tabindex")};R.attr("tabindex",-1).hide().after(V.$wrapper);if(v.isArray(ac.items)){V.setValue(ac.items);delete ac.items}if(C){R.on("invalid"+Y,function(ai){ai.preventDefault();V.isInvalid=true;V.refreshState()})}V.updateOriginalInput();V.refreshItems();V.refreshState();V.updatePlaceholder();V.isSetup=true;if(R.is(":disabled")){V.disable()}V.on("change",this.onChange);R.data("selectize",V);R.addClass("selectized");V.trigger("initialize");if(ac.preload===true){V.onSearchChange("")}},setupTemplates:function(){var Q=this;var P=Q.settings.labelField;var R=Q.settings.optgroupLabelField;var S={optgroup:function(T){return'
'+T.html+"
"},optgroup_header:function(U,T){return'"},option:function(U,T){return'
'+T(U[P])+"
"},item:function(U,T){return'
'+T(U[P])+"
"},option_create:function(U,T){return'
Add '+T(U.input)+" …
"}};Q.settings.render=v.extend({},S,Q.settings.render)},setupCallbacks:function(){var P,Q,R={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(P in R){if(R.hasOwnProperty(P)){Q=this.settings[R[P]];if(Q){this.on(P,Q)}}}},onClick:function(Q){var P=this;if(!P.isFocused){P.focus();Q.preventDefault()}},onMouseDown:function(S){var Q=this;var R=S.isDefaultPrevented();var P=v(S.target);if(Q.isFocused){if(S.target!==Q.$control_input[0]){if(Q.settings.mode==="single"){Q.isOpen?Q.close():Q.open()}else{if(!R){Q.setActiveItem(null)}}return false}}else{if(!R){window.setTimeout(function(){Q.focus()},0)}}},onChange:function(){this.$input.trigger("change")},onPaste:function(Q){var P=this;if(P.isFull()||P.isInputHidden||P.isLocked){Q.preventDefault();return}if(P.settings.splitOn){setTimeout(function(){var S=P.$control_input.val();if(!S.match(P.settings.splitOn)){return}var R=v.trim(S).split(P.settings.splitOn);for(var T=0,U=R.length;T
R){Q=P;P=R;R=Q}for(S=P;S<=R;S++){Y=Z.$control[0].childNodes[S];if(Z.$activeItems.indexOf(Y)===-1){v(Y).addClass("active");Z.$activeItems.push(Y)}}U.preventDefault()}else{if((T==="mousedown"&&Z.isCtrlDown)||(T==="keydown"&&this.isShiftDown)){if(W.hasClass("active")){X=Z.$activeItems.indexOf(W[0]);Z.$activeItems.splice(X,1);W.removeClass("active")}else{Z.$activeItems.push(W.addClass("active")[0])}}else{v(Z.$activeItems).removeClass("active");Z.$activeItems=[W.addClass("active")[0]]}}Z.hideInput();if(!this.isFocused){Z.focus()}},setActiveOption:function(P,V,R){var Q,W,U;var T,S;var X=this;if(X.$activeOption){X.$activeOption.removeClass("active")}X.$activeOption=null;P=v(P);if(!P.length){return}X.$activeOption=P.addClass("active");if(V||!O(V)){Q=X.$dropdown_content.height();W=X.$activeOption.outerHeight(true);V=X.$dropdown_content.scrollTop()||0;U=X.$activeOption.offset().top-X.$dropdown_content.offset().top+V;T=U;S=U-Q+W;if(U+W>Q+V){X.$dropdown_content.stop().animate({scrollTop:S},R?X.settings.scrollDuration:0)}else{if(U=0;S--){if(V.items.indexOf(y(X.items[S].id))!==-1){X.items.splice(S,1)}}}return X},refreshOptions:function(Z){var ag,af,ae,ac,aj,P,V,ah,R,ad,T,ai,U;var S,Y,aa;if(typeof Z==="undefined"){Z=true}var X=this;var Q=v.trim(X.$control_input.val());var ab=X.search(Q);var W=X.$dropdown_content;var ak=X.$activeOption&&y(X.$activeOption.attr("data-value"));ac=ab.items.length;if(typeof X.settings.maxOptions==="number"){ac=Math.min(ac,X.settings.maxOptions)}aj={};P=[];for(ag=0;ag0||U;if(X.hasOptions){if(ab.items.length>0){Y=ak&&X.getOption(ak);if(Y&&Y.length){S=Y}else{if(X.settings.mode==="single"&&X.items.length){S=X.getOption(X.items[0])}}if(!S||!S.length){if(aa&&!X.settings.addPrecedence){S=X.getAdjacentOption(aa,1)}else{S=W.find("[data-selectable]:first")}}}else{S=aa}X.setActiveOption(S);if(Z&&!X.isOpen){X.open()}}else{X.setActiveOption(null);if(Z&&X.isOpen){X.close()}}},addOption:function(S){var Q,T,R,P=this;if(v.isArray(S)){for(Q=0,T=S.length;Q=0&&Q0);P.$control_input.data("grow",!Q&&!R)},isFull:function(){return this.settings.maxItems!==null&&this.items.length>=this.settings.maxItems},updateOriginalInput:function(T){var S,U,R,Q,P=this;T=T||{};if(P.tagType===k){R=[];for(S=0,U=P.items.length;S'+D(Q)+"")}if(!R.length&&!this.$input.attr("multiple")){R.push(' ')}P.$input.html(R.join(""))}else{P.$input.val(P.getValue());P.$input.attr("value",P.$input.val())}if(P.isSetup){if(!T.silent){P.trigger("change",P.$input.val())}}},updatePlaceholder:function(){if(!this.settings.placeholder){return}var P=this.$control_input;if(this.items.length){P.removeAttr("placeholder")}else{P.attr("placeholder",this.settings.placeholder)}P.triggerHandler("update",{force:true})},open:function(){var P=this;if(P.isLocked||P.isOpen||(P.settings.mode==="multi"&&P.isFull())){return}P.focus();P.isOpen=true;P.refreshState();P.$dropdown.css({visibility:"hidden",display:"block"});P.positionDropdown();P.$dropdown.css({visibility:"visible"});P.trigger("dropdown_open",P.$dropdown)},close:function(){var P=this;var Q=P.isOpen;if(P.settings.mode==="single"&&P.items.length){P.hideInput();P.$control_input.blur()}P.isOpen=false;P.$dropdown.hide();P.setActiveOption(null);P.refreshState();if(Q){P.trigger("dropdown_close",P.$dropdown)}},positionDropdown:function(){var P=this.$control;var Q=this.settings.dropdownParent==="body"?P.offset():P.position();Q.top+=P.outerHeight(true);this.$dropdown.css({width:P.outerWidth(),top:Q.top,left:Q.left})},clear:function(Q){var P=this;if(!P.items.length){return}P.$control.children(":not(input)").remove();P.items=[];P.lastQuery=null;P.setCaret(0);P.setActiveItem(null);P.updatePlaceholder();P.updateOriginalInput({silent:Q});P.refreshState();P.showInput();P.trigger("clear")},insertAtCaret:function(P){var Q=Math.min(this.caretPos,this.items.length);if(Q===0){this.$control.prepend(P)}else{v(this.$control[0].childNodes[Q]).before(P)}this.setCaret(Q+1)},deleteSelection:function(S){var Q,P,W,X,Y,U,T,V,R;var Z=this;W=(S&&S.keyCode===o)?-1:1;X=l(Z.$control_input[0]);if(Z.$activeOption&&!Z.settings.hideSelected){T=Z.getAdjacentOption(Z.$activeOption,-1).attr("data-value")}Y=[];if(Z.$activeItems.length){R=Z.$control.children(".active:"+(W>0?"last":"first"));U=Z.$control.children(":not(input)").index(R);if(W>0){U++}for(Q=0,P=Z.$activeItems.length;Q 0&&X.start===Z.$control_input.val().length){Y.push(Z.items[Z.caretPos])}}}}if(!Y.length||(typeof Z.settings.onDelete==="function"&&Z.settings.onDelete.apply(Z,[Y])===false)){return false}if(typeof U!=="undefined"){Z.setCaret(U)}while(Y.length){Z.removeItem(Y.pop())}Z.showInput();Z.positionDropdown();Z.refreshOptions(true);if(T){V=Z.getOption(T);if(V.length){Z.setActiveOption(V)}}return true},advanceSelection:function(T,Q){var R,U,V,W,S,P;var X=this;if(T===0){return}if(X.rtl){T*=-1}R=T>0?"last":"first";U=l(X.$control_input[0]);if(X.isFocused&&!X.isInputHidden){W=X.$control_input.val().length;S=T<0?U.start===0&&U.length===0:U.start===W;if(S&&!W){X.advanceCaret(T,Q)}}else{P=X.$control.children(".active:"+R);if(P.length){V=X.$control.children(":not(input)").index(P);X.setActiveItem(null);X.setCaret(T>0?V+1:V)}}},advanceCaret:function(T,S){var P=this,R,Q;if(T===0){return}R=T>0?"next":"prev";if(P.isShiftDown){Q=P.$control_input[R]();if(Q.length){P.hideInput();P.setActiveItem(Q);S&&S.preventDefault()}}else{P.setCaret(P.caretPos+T)}},setCaret:function(S){var Q=this;if(Q.settings.mode==="single"){S=Q.items.length}else{S=Math.max(0,Math.min(Q.items.length,S))}if(!Q.isPending){var R,V,T,P,U;P=Q.$control.children(":not(input)");for(R=0,V=P.length;R
')}},Q);P.setup=(function(){var R=P.setup;return function(){R.apply(P,arguments);P.$dropdown_header=v(Q.html(Q));P.$dropdown.prepend(P.$dropdown_header)}})()});c.define("optgroup_columns",function(R){var Q=this;R=v.extend({equalizeWidth:true,equalizeHeight:true},R);this.getAdjacentOption=function(W,V){var T=W.closest("[data-group]").find("[data-selectable]");var U=T.index(W)+V;return U>=0&&U
';V=V.firstChild;U.body.appendChild(V);T=P.width=V.offsetWidth-V.clientWidth;U.body.removeChild(V)}return T};var S=function(){var U,Z,T,V,Y,X,W;W=v("[data-group]",Q.$dropdown_content);Z=W.length;if(!Z||!Q.$dropdown_content.width()){return}if(R.equalizeHeight){T=0;for(U=0;U
1){Y=X-V*(Z-1);W.eq(Z-1).css({width:Y})}}};if(R.equalizeHeight||R.equalizeWidth){s.after(this,"positionDropdown",S);s.after(this,"refreshOptions",S)}});c.define("remove_button",function(P){P=v.extend({label:"×",title:"Remove",className:"remove",append:true},P);var Q=function(W,U){U.className="remove-single";var T=W;var V=''+U.label+" ";var S=function(X,Y){return X+Y};W.setup=(function(){var X=T.setup;return function(){if(U.append){var aa=v(T.$input.context).attr("id");var Z=v("#"+aa);var Y=T.settings.render.item;T.settings.render.item=function(ab){return S(Y.apply(W,arguments),V)}}X.apply(W,arguments);W.$control.on("click","."+U.className,function(ab){ab.preventDefault();if(T.isLocked){return}T.clear()})}})()};var R=function(W,U){var T=W;var V=''+U.label+" ";var S=function(X,Y){var Z=X.search(/(<\/[^>]+>\s*)$/);return X.substring(0,Z)+Y+X.substring(Z)};W.setup=(function(){var X=T.setup;return function(){if(U.append){var Y=T.settings.render.item;T.settings.render.item=function(Z){return S(Y.apply(W,arguments),V)}}X.apply(W,arguments);W.$control.on("click","."+U.className,function(aa){aa.preventDefault();if(T.isLocked){return}var Z=v(aa.currentTarget).parent();T.setActiveItem(Z);if(T.deleteSelection()){T.setCaret(T.items.length)}})}})()};if(this.settings.mode==="single"){Q(this,P);return}else{R(this,P)}});c.define("restore_on_backspace",function(Q){var P=this;Q.text=Q.text||function(R){return R[this.settings.labelField]};this.onKeyDown=(function(){var R=P.onKeyDown;return function(U){var S,T;if(U.keyCode===o&&this.$control_input.val()===""&&!this.$activeItems.length){S=this.caretPos-1;if(S>=0&&S .selectize-input > div.ui-sortable-placeholder {
+ visibility: visible !important;
+ background: #f2f2f2 !important;
+ background: rgba(0,0,0,0.06) !important;
+ border: 0 none !important;
+ .selectize-box-shadow(inset 0 0 12px 4px #fff);
+ }
+ .ui-sortable-placeholder::after {
+ content: '!';
+ visibility: hidden;
+ }
+ .ui-sortable-helper {
+ .selectize-box-shadow(0 2px 5px rgba(0,0,0,0.2));
+ }
+}
\ No newline at end of file
diff --git a/wire/modules/Jquery/JqueryUI/selectize/less/plugins/dropdown_header.less b/wire/modules/Jquery/JqueryUI/selectize/less/plugins/dropdown_header.less
new file mode 100755
index 00000000..c3e777e1
--- /dev/null
+++ b/wire/modules/Jquery/JqueryUI/selectize/less/plugins/dropdown_header.less
@@ -0,0 +1,20 @@
+.selectize-dropdown-header {
+ position: relative;
+ padding: @selectize-padding-dropdown-item-y @selectize-padding-dropdown-item-x;
+ border-bottom: 1px solid @selectize-color-border;
+ background: mix(@selectize-color-dropdown, @selectize-color-border, 85%);
+ .selectize-border-radius(@selectize-border-radius @selectize-border-radius 0 0);
+}
+.selectize-dropdown-header-close {
+ position: absolute;
+ right: @selectize-padding-dropdown-item-x;
+ top: 50%;
+ color: @selectize-color-text;
+ opacity: 0.4;
+ margin-top: -12px;
+ line-height: 20px;
+ font-size: 20px !important;
+}
+.selectize-dropdown-header-close:hover {
+ color: darken(@selectize-color-text, 25%);
+}
\ No newline at end of file
diff --git a/wire/modules/Jquery/JqueryUI/selectize/less/plugins/optgroup_columns.less b/wire/modules/Jquery/JqueryUI/selectize/less/plugins/optgroup_columns.less
new file mode 100755
index 00000000..5c72d7a0
--- /dev/null
+++ b/wire/modules/Jquery/JqueryUI/selectize/less/plugins/optgroup_columns.less
@@ -0,0 +1,17 @@
+.selectize-dropdown.plugin-optgroup_columns {
+ .optgroup {
+ border-right: 1px solid #f2f2f2;
+ border-top: 0 none;
+ float: left;
+ .selectize-box-sizing(border-box);
+ }
+ .optgroup:last-child {
+ border-right: 0 none;
+ }
+ .optgroup:before {
+ display: none;
+ }
+ .optgroup-header {
+ border-top: 0 none;
+ }
+}
\ No newline at end of file
diff --git a/wire/modules/Jquery/JqueryUI/selectize/less/plugins/remove_button.less b/wire/modules/Jquery/JqueryUI/selectize/less/plugins/remove_button.less
new file mode 100755
index 00000000..b5303c55
--- /dev/null
+++ b/wire/modules/Jquery/JqueryUI/selectize/less/plugins/remove_button.less
@@ -0,0 +1,43 @@
+.selectize-control.plugin-remove_button {
+ [data-value] {
+ position: relative;
+ padding-right: 24px !important;
+ }
+ [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: @selectize-padding-item-y 0 0 0;
+ border-left: 1px solid @selectize-color-item-border;
+ .selectize-border-radius(0 2px 2px 0);
+ .selectize-box-sizing(border-box);
+ }
+ [data-value] .remove:hover {
+ background: rgba(0,0,0,0.05);
+ }
+ [data-value].active .remove {
+ border-left-color: @selectize-color-item-active-border;
+ }
+ .disabled [data-value] .remove:hover {
+ background: none;
+ }
+ .disabled [data-value] .remove {
+ border-left-color: lighten(desaturate(@selectize-color-item-border, 100%), @selectize-lighten-disabled-item-border);
+ }
+ .remove-single {
+ position: absolute;
+ right: 28px;
+ top: 6px;
+ font-size: 23px;
+ }
+}
diff --git a/wire/modules/Jquery/JqueryUI/selectize/less/selectize.bootstrap2.less b/wire/modules/Jquery/JqueryUI/selectize/less/selectize.bootstrap2.less
new file mode 100755
index 00000000..d4dce713
--- /dev/null
+++ b/wire/modules/Jquery/JqueryUI/selectize/less/selectize.bootstrap2.less
@@ -0,0 +1,161 @@
+/**
+ * selectize.bootstrap2.css (v0.12.4) - Bootstrap 2 Theme
+ * 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
+ */
+
+@import "selectize";
+
+@selectize-font-family: @baseFontFamily;
+@selectize-font-size: @baseFontSize;
+@selectize-line-height: @baseLineHeight;
+
+@selectize-color-text: @textColor;
+@selectize-color-highlight: rgba(255,237,40,0.4);
+@selectize-color-input: @inputBackground;
+@selectize-color-input-full: @inputBackground;
+@selectize-color-disabled: @inputBackground;
+@selectize-color-item: @btnBackgroundHighlight;
+@selectize-color-item-border: @btnBorder;
+@selectize-color-item-active: @dropdownLinkBackgroundHover;
+@selectize-color-item-active-text: @dropdownLinkColorHover;
+@selectize-color-item-active-border: darken(@selectize-color-item-active, 5%);
+@selectize-color-optgroup: @dropdownBackground;
+@selectize-color-optgroup-text: @grayLight;
+@selectize-color-optgroup-border: @dropdownDividerTop;
+@selectize-color-dropdown: @dropdownBackground;
+@selectize-color-dropdown-border: @inputBorder;
+@selectize-color-dropdown-border-top: @dropdownDividerTop;
+@selectize-color-dropdown-item-active: @dropdownLinkBackgroundHover;
+@selectize-color-dropdown-item-active-text: @dropdownLinkColorHover;
+@selectize-color-dropdown-item-create-active-text: @dropdownLinkColorHover;
+@selectize-lighten-disabled-item: 8%;
+@selectize-lighten-disabled-item-text: 8%;
+@selectize-lighten-disabled-item-border: 8%;
+@selectize-opacity-disabled: 0.5;
+@selectize-shadow-input: none;
+@selectize-shadow-input-focus: inset 0 1px 2px rgba(0,0,0,0.15);
+@selectize-border-radius: @inputBorderRadius;
+
+@selectize-padding-x: 10px;
+@selectize-padding-y: 7px;
+@selectize-padding-dropdown-item-x: @selectize-padding-x;
+@selectize-padding-dropdown-item-y: 3px;
+@selectize-padding-item-x: 3px;
+@selectize-padding-item-y: 1px;
+@selectize-margin-item-x: 3px;
+@selectize-margin-item-y: 3px;
+@selectize-caret-margin: 0;
+
+@selectize-arrow-size: 5px;
+@selectize-arrow-color: @black;
+@selectize-arrow-offset: @selectize-padding-x + 5px;
+
+@selectize-width-item-border: 1px;
+
+.selectize-dropdown {
+ margin: 2px 0 0 0;
+ z-index: @zindexDropdown;
+ border: 1px solid @dropdownBorder;
+ border-radius: @baseBorderRadius;
+ .box-shadow(0 5px 10px rgba(0,0,0,.2));
+
+ .optgroup-header {
+ font-size: 11px;
+ font-weight: bold;
+ text-shadow: 0 1px 0 rgba(255,255,255,.5);
+ text-transform: uppercase;
+ }
+ .optgroup:first-child:before {
+ display: none;
+ }
+ .optgroup:before {
+ content: ' ';
+ display: block;
+ .nav-divider();
+ margin-left: @selectize-padding-dropdown-item-x * -1;
+ margin-right: @selectize-padding-dropdown-item-x * -1;
+ }
+
+ [data-selectable].active {
+ #gradient > .vertical(@dropdownLinkBackgroundHover, darken(@dropdownLinkBackgroundHover, 5%));
+ }
+}
+
+.selectize-dropdown-content {
+ padding: 5px 0;
+}
+
+.selectize-dropdown-header {
+ padding: @selectize-padding-dropdown-item-y * 2 @selectize-padding-dropdown-item-x;
+}
+
+.selectize-input {
+ .transition(~"border linear .2s, box-shadow linear .2s");
+
+ &.dropdown-active {
+ .selectize-border-radius(@selectize-border-radius);
+ }
+ &.dropdown-active::before {
+ display: none;
+ }
+ &.input-active, &.input-active:hover, .selectize-control.multi &.focus {
+ background: @selectize-color-input !important;
+ border-color: rgba(82,168,236,.8) !important;
+ outline: 0 !important;
+ outline: thin dotted \9 !important;
+ .box-shadow(~"inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(82,168,236,.6)") !important;
+ }
+}
+
+.selectize-control {
+ &.single {
+ .selectize-input {
+ .buttonBackground(@btnBackground, @btnBackgroundHighlight, @grayDark, 0 1px 1px rgba(255,255,255,.75));
+ .box-shadow(~"inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05)");
+ &:hover {
+ color: @grayDark;
+ text-decoration: none;
+ background-position: 0 -15px;
+ .transition(background-position .1s linear);
+ }
+ &.disabled {
+ background: @btnBackgroundHighlight !important;
+ .box-shadow(none);
+ }
+ }
+ }
+ &.multi {
+ .selectize-input {
+ .box-shadow(inset 0 1px 1px rgba(0,0,0,.075));
+ &.has-items {
+ @padding-x: @selectize-padding-x - @selectize-padding-item-x;
+ padding-left: @padding-x;
+ padding-right: @padding-x;
+ }
+ }
+ .selectize-input > div {
+ .gradientBar(@btnBackground, @btnBackgroundHighlight, @selectize-color-item-text, none);
+ *background-color: @selectize-color-item;
+ border: @selectize-width-item-border solid @selectize-color-item-border;
+ .border-radius(@baseBorderRadius);
+ .box-shadow(~"inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05)");
+ &.active {
+ .box-shadow(~"0 1px 2px rgba(0,0,0,.05)");
+ .gradientBar(@selectize-color-item-active, @selectize-color-item-active-border, @selectize-color-item-active-text, none);
+ *background-color: @selectize-color-item-active;
+ border: @selectize-width-item-border solid @dropdownLinkBackgroundHover;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/wire/modules/Jquery/JqueryUI/selectize/less/selectize.bootstrap3.less b/wire/modules/Jquery/JqueryUI/selectize/less/selectize.bootstrap3.less
new file mode 100755
index 00000000..19b3ccd1
--- /dev/null
+++ b/wire/modules/Jquery/JqueryUI/selectize/less/selectize.bootstrap3.less
@@ -0,0 +1,150 @@
+/**
+ * selectize.bootstrap3.css (v0.12.4) - Bootstrap 3 Theme
+ * 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
+ */
+
+@import "selectize";
+
+@selectize-font-family: inherit;
+@selectize-font-size: inherit;
+@selectize-line-height: @line-height-computed;
+
+@selectize-color-text: @text-color;
+@selectize-color-highlight: rgba(255,237,40,0.4);
+@selectize-color-input: @input-bg;
+@selectize-color-input-full: @input-bg;
+@selectize-color-input-error: @state-danger-text;
+@selectize-color-input-error-focus: darken(@selectize-color-input-error, 10%);
+@selectize-color-disabled: @input-bg;
+@selectize-color-item: #efefef;
+@selectize-color-item-border: rgba(0,0,0,0);
+@selectize-color-item-active: @component-active-bg;
+@selectize-color-item-active-text: #fff;
+@selectize-color-item-active-border: rgba(0,0,0,0);
+@selectize-color-optgroup: @dropdown-bg;
+@selectize-color-optgroup-text: @dropdown-header-color;
+@selectize-color-optgroup-border: @dropdown-divider-bg;
+@selectize-color-dropdown: @dropdown-bg;
+@selectize-color-dropdown-border-top: mix(@input-border, @input-bg, 0.8);
+@selectize-color-dropdown-item-active: @dropdown-link-hover-bg;
+@selectize-color-dropdown-item-active-text: @dropdown-link-hover-color;
+@selectize-color-dropdown-item-create-active-text: @dropdown-link-hover-color;
+@selectize-opacity-disabled: 0.5;
+@selectize-shadow-input: none;
+@selectize-shadow-input-focus: inset 0 1px 2px rgba(0,0,0,0.15);
+@selectize-shadow-input-error: inset 0 1px 1px rgba(0, 0, 0, .075);
+@selectize-shadow-input-error-focus: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px lighten(@selectize-color-input-error, 20%);
+@selectize-border: 1px solid @input-border;
+@selectize-border-radius: @input-border-radius;
+
+@selectize-width-item-border: 0;
+@selectize-padding-x: @padding-base-horizontal;
+@selectize-padding-y: @padding-base-vertical;
+@selectize-padding-dropdown-item-x: @padding-base-horizontal;
+@selectize-padding-dropdown-item-y: 3px;
+@selectize-padding-item-x: 3px;
+@selectize-padding-item-y: 1px;
+@selectize-margin-item-x: 3px;
+@selectize-margin-item-y: 3px;
+@selectize-caret-margin: 0;
+
+@selectize-arrow-size: 5px;
+@selectize-arrow-color: @selectize-color-text;
+@selectize-arrow-offset: @selectize-padding-x + 5px;
+
+.selectize-dropdown, .selectize-dropdown.form-control {
+ height: auto;
+ padding: 0;
+ margin: 2px 0 0 0;
+ z-index: @zindex-dropdown;
+ background: @selectize-color-dropdown;
+ border: 1px solid @dropdown-fallback-border;
+ border: 1px solid @dropdown-border;
+ .selectize-border-radius(@border-radius-base);
+ .selectize-box-shadow(0 6px 12px rgba(0,0,0,.175));
+}
+
+.selectize-dropdown {
+ .optgroup-header {
+ font-size: @font-size-small;
+ line-height: @line-height-base;
+ }
+ .optgroup:first-child:before {
+ display: none;
+ }
+ .optgroup:before {
+ content: ' ';
+ display: block;
+ .nav-divider();
+ margin-left: @selectize-padding-dropdown-item-x * -1;
+ margin-right: @selectize-padding-dropdown-item-x * -1;
+ }
+}
+
+.selectize-dropdown-content {
+ padding: 5px 0;
+}
+
+.selectize-dropdown-header {
+ padding: @selectize-padding-dropdown-item-y * 2 @selectize-padding-dropdown-item-x;
+}
+
+.selectize-input {
+ min-height: @input-height-base;
+
+ &.dropdown-active {
+ .selectize-border-radius(@selectize-border-radius);
+ }
+ &.dropdown-active::before {
+ display: none;
+ }
+ &.focus {
+ @color: @input-border-focus;
+ @color-rgba: rgba(red(@color), green(@color), blue(@color), .6);
+ border-color: @color;
+ outline: 0;
+ .selectize-box-shadow(~"inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px @{color-rgba}");
+ }
+}
+
+.has-error .selectize-input {
+ border-color: @selectize-color-input-error;
+ .selectize-box-shadow(@selectize-shadow-input-error);
+
+ &:focus {
+ border-color: @selectize-color-input-error-focus;
+ .selectize-box-shadow(@selectize-shadow-input-error-focus);
+ }
+}
+
+.selectize-control {
+ &.multi {
+ .selectize-input.has-items {
+ padding-left: @selectize-padding-x - @selectize-padding-item-x;
+ padding-right: @selectize-padding-x - @selectize-padding-item-x;
+ }
+ .selectize-input > div {
+ .selectize-border-radius(@selectize-border-radius - 1px);
+ }
+ }
+}
+
+.form-control.selectize-control {
+ padding: 0;
+ height: auto;
+ border: none;
+ background: none;
+ .selectize-box-shadow(none);
+ .selectize-border-radius(0);
+}
diff --git a/wire/modules/Jquery/JqueryUI/selectize/less/selectize.default.less b/wire/modules/Jquery/JqueryUI/selectize/less/selectize.default.less
new file mode 100755
index 00000000..812c4eba
--- /dev/null
+++ b/wire/modules/Jquery/JqueryUI/selectize/less/selectize.default.less
@@ -0,0 +1,84 @@
+/**
+ * selectize.default.css (v0.12.4) - Default Theme
+ * 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
+ */
+
+@import "selectize";
+
+@selectize-color-item: #1da7ee;
+@selectize-color-item-text: #fff;
+@selectize-color-item-active-text: #fff;
+@selectize-color-item-border: #0073bb;
+@selectize-color-item-active: #92c836;
+@selectize-color-item-active-border: #00578d;
+@selectize-width-item-border: 1px;
+@selectize-caret-margin: 0 1px;
+
+.selectize-control {
+ &.multi {
+ .selectize-input {
+ &.has-items {
+ @padding-x: @selectize-padding-x - 3px;
+ padding-left: @padding-x;
+ padding-right: @padding-x;
+ }
+ &.disabled [data-value] {
+ color: #999;
+ text-shadow: none;
+ background: none;
+ .selectize-box-shadow(none);
+
+ &, .remove {
+ border-color: #e6e6e6;
+ }
+ .remove {
+ background: none;
+ }
+ }
+ [data-value] {
+ text-shadow: 0 1px 0 rgba(0,51,83,0.3);
+ .selectize-border-radius(3px);
+ .selectize-vertical-gradient(#1da7ee, #178ee9);
+ .selectize-box-shadow(~"0 1px 0 rgba(0,0,0,0.2),inset 0 1px rgba(255,255,255,0.03)");
+ &.active {
+ .selectize-vertical-gradient(#008fd8, #0075cf);
+ }
+ }
+ }
+ }
+ &.single {
+ .selectize-input {
+ .selectize-box-shadow(~"0 1px 0 rgba(0,0,0,0.05), inset 0 1px 0 rgba(255,255,255,0.8)");
+ .selectize-vertical-gradient(#fefefe, #f2f2f2);
+ }
+ }
+}
+
+.selectize-control.single .selectize-input, .selectize-dropdown.single {
+ border-color: #b8b8b8;
+}
+
+.selectize-dropdown {
+ .optgroup-header {
+ padding-top: @selectize-padding-dropdown-item-y + 2px;
+ font-weight: bold;
+ font-size: 0.85em;
+ }
+ .optgroup {
+ border-top: 1px solid @selectize-color-dropdown-border-top;
+ &:first-child {
+ border-top: 0 none;
+ }
+ }
+}
\ No newline at end of file
diff --git a/wire/modules/Jquery/JqueryUI/selectize/less/selectize.legacy.less b/wire/modules/Jquery/JqueryUI/selectize/less/selectize.legacy.less
new file mode 100755
index 00000000..2b7c7cbb
--- /dev/null
+++ b/wire/modules/Jquery/JqueryUI/selectize/less/selectize.legacy.less
@@ -0,0 +1,75 @@
+/**
+ * selectize.legacy.css (v0.12.4) - Default Theme
+ * 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
+ */
+
+@import "selectize";
+
+@selectize-font-size: 13px;
+@selectize-line-height: 20px;
+
+@selectize-color-input-full: #f2f2f2;
+@selectize-color-item: #b8e76f;
+@selectize-color-item-text: #3d5d18;
+@selectize-color-item-border: #74b21e;
+@selectize-color-item-active: #92c836;
+@selectize-color-item-active-border: #6f9839;
+@selectize-color-highlight: rgba(255,237,40,0.4);
+@selectize-color-dropdown-item-active: #fffceb;
+@selectize-color-dropdown-item-active-text: @selectize-color-text;
+@selectize-color-optgroup: #f8f8f8;
+@selectize-color-optgroup-text: @selectize-color-text;
+@selectize-width-item-border: 1px;
+
+@selectize-padding-x: 10px;
+@selectize-padding-y: 10px;
+@selectize-padding-item-x: 5px;
+@selectize-padding-item-y: 1px;
+@selectize-padding-dropdown-item-x: 10px;
+@selectize-padding-dropdown-item-y: 7px;
+@selectize-margin-item-x: 4px;
+@selectize-margin-item-y: 4px;
+
+.selectize-control {
+ &.multi {
+ .selectize-input [data-value] {
+ text-shadow: 0 1px 0 rgba(255,255,255,0.1);
+ .selectize-border-radius(3px);
+ .selectize-vertical-gradient(#b8e76f, #a9e25c);
+ .selectize-box-shadow(0 1px 1px rgba(0,0,0,0.1));
+ &.active {
+ .selectize-vertical-gradient(#92c836, #7abc2c);
+ }
+ }
+ }
+ &.single {
+ .selectize-input {
+ .selectize-box-shadow(~"inset 0 1px 0 rgba(255,255,255,0.8), 0 2px 0 #e0e0e0, 0 3px 0 #c8c8c8, 0 4px 1px rgba(0,0,0,0.1)");
+ .selectize-vertical-gradient(#f5f5f5, #efefef);
+ }
+ }
+}
+
+.selectize-control.single .selectize-input, .selectize-dropdown.single {
+ border-color: #b8b8b8;
+}
+
+.selectize-dropdown {
+ .optgroup-header {
+ font-weight: bold;
+ font-size: 0.8em;
+ border-bottom: 1px solid @selectize-color-dropdown-border-top;
+ border-top: 1px solid @selectize-color-dropdown-border-top;
+ }
+}
\ No newline at end of file
diff --git a/wire/modules/Jquery/JqueryUI/selectize/less/selectize.less b/wire/modules/Jquery/JqueryUI/selectize/less/selectize.less
new file mode 100755
index 00000000..df1c41bc
--- /dev/null
+++ b/wire/modules/Jquery/JqueryUI/selectize/less/selectize.less
@@ -0,0 +1,296 @@
+@import "plugins/drag_drop";
+@import "plugins/dropdown_header";
+@import "plugins/optgroup_columns";
+@import "plugins/remove_button";
+
+// base styles
+
+@selectize-font-family: inherit;
+@selectize-font-smoothing: inherit;
+@selectize-font-size: 13px;
+@selectize-line-height: 18px;
+
+@selectize-color-text: #303030;
+@selectize-color-border: #d0d0d0;
+@selectize-color-highlight: rgba(125,168,208,0.2);
+@selectize-color-input: #fff;
+@selectize-color-input-full: @selectize-color-input;
+@selectize-color-disabled: #fafafa;
+@selectize-color-item: #f2f2f2;
+@selectize-color-item-text: @selectize-color-text;
+@selectize-color-item-border: #d0d0d0;
+@selectize-color-item-active: #e8e8e8;
+@selectize-color-item-active-text: @selectize-color-text;
+@selectize-color-item-active-border: #cacaca;
+@selectize-color-dropdown: #fff;
+@selectize-color-dropdown-border: @selectize-color-border;
+@selectize-color-dropdown-border-top: #f0f0f0;
+@selectize-color-dropdown-item-active: #f5fafd;
+@selectize-color-dropdown-item-active-text: #495c68;
+@selectize-color-dropdown-item-create-text: rgba(red(@selectize-color-text), green(@selectize-color-text), blue(@selectize-color-text), 0.5);
+@selectize-color-dropdown-item-create-active-text: @selectize-color-dropdown-item-active-text;
+@selectize-color-optgroup: @selectize-color-dropdown;
+@selectize-color-optgroup-text: @selectize-color-text;
+@selectize-lighten-disabled-item: 30%;
+@selectize-lighten-disabled-item-text: 30%;
+@selectize-lighten-disabled-item-border: 30%;
+@selectize-opacity-disabled: 0.5;
+
+@selectize-shadow-input: inset 0 1px 1px rgba(0,0,0,0.1);
+@selectize-shadow-input-focus: inset 0 1px 2px rgba(0,0,0,0.15);
+@selectize-border: 1px solid @selectize-color-border;
+@selectize-dropdown-border: 1px solid @selectize-color-dropdown-border;
+@selectize-border-radius: 3px;
+
+@selectize-width-item-border: 0;
+@selectize-max-height-dropdown: 200px;
+
+@selectize-padding-x: 8px;
+@selectize-padding-y: 8px;
+@selectize-padding-item-x: 6px;
+@selectize-padding-item-y: 2px;
+@selectize-padding-dropdown-item-x: @selectize-padding-x;
+@selectize-padding-dropdown-item-y: 5px;
+@selectize-margin-item-x: 3px;
+@selectize-margin-item-y: 3px;
+
+@selectize-arrow-size: 5px;
+@selectize-arrow-color: #808080;
+@selectize-arrow-offset: 15px;
+
+@selectize-caret-margin: 0 2px 0 0;
+@selectize-caret-margin-rtl: 0 4px 0 -2px;
+
+.selectize-border-radius (@radii) {
+ -webkit-border-radius: @radii;
+ -moz-border-radius: @radii;
+ border-radius: @radii;
+}
+.selectize-unselectable () {
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+}
+.selectize-box-shadow (@shadow) {
+ -webkit-box-shadow: @shadow;
+ box-shadow: @shadow;
+}
+.selectize-box-sizing (@type: border-box) {
+ -webkit-box-sizing: @type;
+ -moz-box-sizing: @type;
+ box-sizing: @type;
+}
+.selectize-vertical-gradient (@color-top, @color-bottom) {
+ background-color: mix(@color-top, @color-bottom, 60%);
+ background-image: -moz-linear-gradient(top, @color-top, @color-bottom); // FF 3.6+
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(@color-top), to(@color-bottom)); // Safari 4+, Chrome 2+
+ background-image: -webkit-linear-gradient(top, @color-top, @color-bottom); // Safari 5.1+, Chrome 10+
+ background-image: -o-linear-gradient(top, @color-top, @color-bottom); // Opera 11.10
+ background-image: linear-gradient(to bottom, @color-top, @color-bottom); // Standard, IE10
+ background-repeat: repeat-x;
+ filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",argb(@color-top),argb(@color-bottom))); // IE9 and down
+}
+
+.selectize-control {
+ position: relative;
+}
+
+.selectize-dropdown, .selectize-input, .selectize-input input {
+ color: @selectize-color-text;
+ font-family: @selectize-font-family;
+ font-size: @selectize-font-size;
+ line-height: @selectize-line-height;
+ -webkit-font-smoothing: @selectize-font-smoothing;
+}
+
+.selectize-input, .selectize-control.single .selectize-input.input-active {
+ background: @selectize-color-input;
+ cursor: text;
+ display: inline-block;
+}
+
+.selectize-input {
+ border: @selectize-border;
+ padding: @selectize-padding-y @selectize-padding-x;
+ display: inline-block;
+ width: 100%;
+ overflow: hidden;
+ position: relative;
+ z-index: 1;
+ .selectize-box-sizing(border-box);
+ .selectize-box-shadow(@selectize-shadow-input);
+ .selectize-border-radius(@selectize-border-radius);
+
+ .selectize-control.multi &.has-items {
+ @padding-x: @selectize-padding-x;
+ @padding-top: @selectize-padding-y - @selectize-padding-item-y - @selectize-width-item-border;
+ @padding-bottom: @selectize-padding-y - @selectize-padding-item-y - @selectize-margin-item-y - @selectize-width-item-border;
+ padding: @padding-top @padding-x @padding-bottom;
+ }
+
+ &.full {
+ background-color: @selectize-color-input-full;
+ }
+ &.disabled, &.disabled * {
+ cursor: default !important;
+ }
+ &.focus {
+ .selectize-box-shadow(@selectize-shadow-input-focus);
+ }
+ &.dropdown-active {
+ .selectize-border-radius(@selectize-border-radius @selectize-border-radius 0 0);
+ }
+
+ > * {
+ vertical-align: baseline;
+ display: -moz-inline-stack;
+ display: inline-block;
+ zoom: 1;
+ *display: inline;
+ }
+ .selectize-control.multi & > div {
+ cursor: pointer;
+ margin: 0 @selectize-margin-item-x @selectize-margin-item-y 0;
+ padding: @selectize-padding-item-y @selectize-padding-item-x;
+ background: @selectize-color-item;
+ color: @selectize-color-item-text;
+ border: @selectize-width-item-border solid @selectize-color-item-border;
+
+ &.active {
+ background: @selectize-color-item-active;
+ color: @selectize-color-item-active-text;
+ border: @selectize-width-item-border solid @selectize-color-item-active-border;
+ }
+ }
+ .selectize-control.multi &.disabled > div {
+ &, &.active {
+ color: lighten(desaturate(@selectize-color-item-text, 100%), @selectize-lighten-disabled-item-text);
+ background: lighten(desaturate(@selectize-color-item, 100%), @selectize-lighten-disabled-item);
+ border: @selectize-width-item-border solid lighten(desaturate(@selectize-color-item-border, 100%), @selectize-lighten-disabled-item-border);
+ }
+ }
+ > input {
+ &::-ms-clear {
+ display: none;
+ }
+ display: inline-block !important;
+ padding: 0 !important;
+ min-height: 0 !important;
+ max-height: none !important;
+ max-width: 100% !important;
+ margin: @selectize-caret-margin !important;
+ text-indent: 0 !important;
+ border: 0 none !important;
+ background: none !important;
+ line-height: inherit !important;
+ -webkit-user-select: auto !important;
+ .selectize-box-shadow(none) !important;
+ &:focus { outline: none !important; }
+ }
+}
+
+.selectize-input::after {
+ content: ' ';
+ display: block;
+ clear: left;
+}
+
+.selectize-input.dropdown-active::before {
+ content: ' ';
+ display: block;
+ position: absolute;
+ background: @selectize-color-dropdown-border-top;
+ height: 1px;
+ bottom: 0;
+ left: 0;
+ right: 0;
+}
+
+.selectize-dropdown {
+ position: absolute;
+ z-index: 10;
+ border: @selectize-dropdown-border;
+ background: @selectize-color-dropdown;
+ margin: -1px 0 0 0;
+ border-top: 0 none;
+ .selectize-box-sizing(border-box);
+ .selectize-box-shadow(0 1px 3px rgba(0,0,0,0.1));
+ .selectize-border-radius(0 0 @selectize-border-radius @selectize-border-radius);
+
+ [data-selectable] {
+ cursor: pointer;
+ overflow: hidden;
+ .highlight {
+ background: @selectize-color-highlight;
+ .selectize-border-radius(1px);
+ }
+ }
+ [data-selectable], .optgroup-header {
+ padding: @selectize-padding-dropdown-item-y @selectize-padding-dropdown-item-x;
+ }
+ .optgroup:first-child .optgroup-header {
+ border-top: 0 none;
+ }
+ .optgroup-header {
+ color: @selectize-color-optgroup-text;
+ background: @selectize-color-optgroup;
+ cursor: default;
+ }
+ .active {
+ background-color: @selectize-color-dropdown-item-active;
+ color: @selectize-color-dropdown-item-active-text;
+ &.create {
+ color: @selectize-color-dropdown-item-create-active-text;
+ }
+ }
+ .create {
+ color: @selectize-color-dropdown-item-create-text;
+ }
+}
+
+.selectize-dropdown-content {
+ overflow-y: auto;
+ overflow-x: hidden;
+ max-height: @selectize-max-height-dropdown;
+ -webkit-overflow-scrolling: touch;
+}
+
+.selectize-control.single .selectize-input {
+ &, input { cursor: pointer; }
+ &.input-active, &.input-active input { cursor: text; }
+
+ &:after {
+ content: ' ';
+ display: block;
+ position: absolute;
+ top: 50%;
+ right: @selectize-arrow-offset;
+ margin-top: round((-1 * @selectize-arrow-size / 2));
+ width: 0;
+ height: 0;
+ border-style: solid;
+ border-width: @selectize-arrow-size @selectize-arrow-size 0 @selectize-arrow-size;
+ border-color: @selectize-arrow-color transparent transparent transparent;
+ }
+ &.dropdown-active:after {
+ margin-top: @selectize-arrow-size * -0.8;
+ border-width: 0 @selectize-arrow-size @selectize-arrow-size @selectize-arrow-size;
+ border-color: transparent transparent @selectize-arrow-color transparent;
+ }
+}
+
+.selectize-control.rtl {
+ &.single .selectize-input:after {
+ left: @selectize-arrow-offset;
+ right: auto;
+ }
+ .selectize-input > input {
+ margin: @selectize-caret-margin-rtl !important;
+ }
+}
+
+.selectize-control .selectize-input.disabled {
+ opacity: @selectize-opacity-disabled;
+ background-color: @selectize-color-disabled;
+}