selectize-rails 0.6.1 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -4
- data/lib/selectize-rails/version.rb +1 -1
- data/update_from_vendor.sh +17 -0
- data/vendor/assets/javascripts/selectize.js +336 -325
- data/vendor/assets/stylesheets/selectize.css +1 -1
- metadata +4 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: a7ee6c515d9d21ce4a72744a617a0fb077d15760
         | 
| 4 | 
            +
              data.tar.gz: f08f8ad1647781d1e8707e8b50a35c625fd20df9
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 86d551993383a1972bbacf262a0e1aed6a188def90a584eb9b9f01ea57bdaaf8656c039d234e20da91eedc59545855e7b4405fc955801b3b4f7d8b20083c732f
         | 
| 7 | 
            +
              data.tar.gz: 4b864a531cb4e6ef11bfe59024abcbd824aa548071436aca58dfb3ecb8e277d9b972fa251baa4b1b8b666aa54c6ab881593851e4b2cb2f26ab377389742477d5
         | 
    
        data/README.md
    CHANGED
    
    | @@ -33,10 +33,11 @@ See the [demo page of Brian Reavis](http://brianreavis.github.io/selectize.js/) | |
| 33 33 |  | 
| 34 34 | 
             
            ## Changes
         | 
| 35 35 |  | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
| 39 | 
            -
             | 
| 36 | 
            +
            | Version | Notes                                                                               |
         | 
| 37 | 
            +
            | -------:| ----------------------------------------------------------------------------------- |
         | 
| 38 | 
            +
            |   0.6.4 | Update to latest version of selectize.js                                            |
         | 
| 39 | 
            +
            |   0.6.1 | Update and set gem version equal to selectize.js version                            |
         | 
| 40 | 
            +
            |   0.1.0 | Initial release                                                                     |
         | 
| 40 41 |  | 
| 41 42 | 
             
            ## License
         | 
| 42 43 |  | 
| @@ -0,0 +1,17 @@ | |
| 1 | 
            +
            #!/bin/bash
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            # Checkout vendor repo
         | 
| 4 | 
            +
            echo "Cloning brianreavis/selectize.js github repo into tmp_vendor"
         | 
| 5 | 
            +
            git clone https://github.com/brianreavis/selectize.js.git tmp_vendor
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            # Copy files
         | 
| 8 | 
            +
            echo "Copying selectize.js"
         | 
| 9 | 
            +
            cp tmp_vendor/selectize.js vendor/assets/javascripts/selectize.js
         | 
| 10 | 
            +
            echo "Copying selectize.css"
         | 
| 11 | 
            +
            cp tmp_vendor/selectize.css vendor/assets/stylesheets/selectize.css
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            # Delete vendor repo
         | 
| 14 | 
            +
            echo "Removing cloned vendor repo"
         | 
| 15 | 
            +
            rm -rf tmp_vendor
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            echo "Finished... You'll need to commit the changes. You should consider updating the changelog and gem version number"
         | 
| @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            /*! selectize.js - v0.6. | 
| 1 | 
            +
            /*! selectize.js - v0.6.4 | https://github.com/brianreavis/selectize.js | Apache License (v2) */
         | 
| 2 2 |  | 
| 3 3 | 
             
            (function(factory) {
         | 
| 4 4 | 
             
            	if (typeof exports === 'object') {
         | 
| @@ -9,10 +9,10 @@ | |
| 9 9 | 
             
            		factory(jQuery);
         | 
| 10 10 | 
             
            	}
         | 
| 11 11 | 
             
            }(function ($) {
         | 
| 12 | 
            -
            	"use strict";
         | 
| 13 | 
            -
             | 
| 12 | 
            +
            	"use strict";	
         | 
| 13 | 
            +
            	
         | 
| 14 14 | 
             
            	/* --- file: "src/contrib/highlight.js" --- */
         | 
| 15 | 
            -
             | 
| 15 | 
            +
            	
         | 
| 16 16 | 
             
            	/**
         | 
| 17 17 | 
             
            	* highlight v3 | MIT license | Johann Burkard <jb@eaio.com>
         | 
| 18 18 | 
             
            	* Highlights arbitrary terms in a node.
         | 
| @@ -20,11 +20,11 @@ | |
| 20 20 | 
             
            	* - Modified by Marshal <beatgates@gmail.com> 2011-6-24 (added regex)
         | 
| 21 21 | 
             
            	* - Modified by Brian Reavis <brian@thirdroute.com> 2012-8-27 (cleanup)
         | 
| 22 22 | 
             
            	*/
         | 
| 23 | 
            -
             | 
| 23 | 
            +
            	
         | 
| 24 24 | 
             
            	var highlight = function($element, pattern) {
         | 
| 25 25 | 
             
            		if (typeof pattern === 'string' && !pattern.length) return;
         | 
| 26 26 | 
             
            		var regex = (typeof pattern === 'string') ? new RegExp(pattern, 'i') : pattern;
         | 
| 27 | 
            -
             | 
| 27 | 
            +
            	
         | 
| 28 28 | 
             
            		var highlight = function(node) {
         | 
| 29 29 | 
             
            			var skip = 0;
         | 
| 30 30 | 
             
            			if (node.nodeType === 3) {
         | 
| @@ -47,12 +47,12 @@ | |
| 47 47 | 
             
            			}
         | 
| 48 48 | 
             
            			return skip;
         | 
| 49 49 | 
             
            		};
         | 
| 50 | 
            -
             | 
| 50 | 
            +
            	
         | 
| 51 51 | 
             
            		return $element.each(function() {
         | 
| 52 52 | 
             
            			highlight(this);
         | 
| 53 53 | 
             
            		});
         | 
| 54 54 | 
             
            	};
         | 
| 55 | 
            -
             | 
| 55 | 
            +
            	
         | 
| 56 56 | 
             
            	var unhighlight = function($element) {
         | 
| 57 57 | 
             
            		return $element.find('span.highlight').each(function() {
         | 
| 58 58 | 
             
            			var parent = this.parentNode;
         | 
| @@ -60,9 +60,9 @@ | |
| 60 60 | 
             
            			parent.normalize();
         | 
| 61 61 | 
             
            		}).end();
         | 
| 62 62 | 
             
            	};
         | 
| 63 | 
            -
             | 
| 63 | 
            +
            	
         | 
| 64 64 | 
             
            	/* --- file: "src/contrib/microevent.js" --- */
         | 
| 65 | 
            -
             | 
| 65 | 
            +
            	
         | 
| 66 66 | 
             
            	/**
         | 
| 67 67 | 
             
            	* MicroEvent - to make any js object an event emitter
         | 
| 68 68 | 
             
            	*
         | 
| @@ -72,7 +72,7 @@ | |
| 72 72 | 
             
            	*
         | 
| 73 73 | 
             
            	* @author Jerome Etienne (https://github.com/jeromeetienne)
         | 
| 74 74 | 
             
            	*/
         | 
| 75 | 
            -
             | 
| 75 | 
            +
            	
         | 
| 76 76 | 
             
            	var MicroEvent = function() {};
         | 
| 77 77 | 
             
            	MicroEvent.prototype = {
         | 
| 78 78 | 
             
            		on: function(event, fct){
         | 
| @@ -93,7 +93,7 @@ | |
| 93 93 | 
             
            			}
         | 
| 94 94 | 
             
            		}
         | 
| 95 95 | 
             
            	};
         | 
| 96 | 
            -
             | 
| 96 | 
            +
            	
         | 
| 97 97 | 
             
            	/**
         | 
| 98 98 | 
             
            	* Mixin will delegate all MicroEvent.js function in the destination object.
         | 
| 99 99 | 
             
            	*
         | 
| @@ -107,9 +107,9 @@ | |
| 107 107 | 
             
            			destObject.prototype[props[i]] = MicroEvent.prototype[props[i]];
         | 
| 108 108 | 
             
            		}
         | 
| 109 109 | 
             
            	};
         | 
| 110 | 
            -
             | 
| 110 | 
            +
            	
         | 
| 111 111 | 
             
            	/* --- file: "src/constants.js" --- */
         | 
| 112 | 
            -
             | 
| 112 | 
            +
            	
         | 
| 113 113 | 
             
            	/**
         | 
| 114 114 | 
             
            	* selectize - A highly customizable select control with autocomplete.
         | 
| 115 115 | 
             
            	* Copyright (c) 2013 Brian Reavis & contributors
         | 
| @@ -125,9 +125,9 @@ | |
| 125 125 | 
             
            	*
         | 
| 126 126 | 
             
            	* @author Brian Reavis <brian@thirdroute.com>
         | 
| 127 127 | 
             
            	*/
         | 
| 128 | 
            -
             | 
| 128 | 
            +
            	
         | 
| 129 129 | 
             
            	var IS_MAC        = /Mac/.test(navigator.userAgent);
         | 
| 130 | 
            -
             | 
| 130 | 
            +
            	
         | 
| 131 131 | 
             
            	var KEY_A         = 65;
         | 
| 132 132 | 
             
            	var KEY_COMMA     = 188;
         | 
| 133 133 | 
             
            	var KEY_RETURN    = 13;
         | 
| @@ -142,10 +142,10 @@ | |
| 142 142 | 
             
            	var KEY_CMD       = IS_MAC ? 91 : 17;
         | 
| 143 143 | 
             
            	var KEY_CTRL      = IS_MAC ? 18 : 17;
         | 
| 144 144 | 
             
            	var KEY_TAB       = 9;
         | 
| 145 | 
            -
             | 
| 145 | 
            +
            	
         | 
| 146 146 | 
             
            	var TAG_SELECT    = 1;
         | 
| 147 147 | 
             
            	var TAG_INPUT     = 2;
         | 
| 148 | 
            -
             | 
| 148 | 
            +
            	
         | 
| 149 149 | 
             
            	var DIACRITICS = {
         | 
| 150 150 | 
             
            		'a': '[aÀÁÂÃÄÅàáâãäå]',
         | 
| 151 151 | 
             
            		'c': '[cÇç]',
         | 
| @@ -158,14 +158,14 @@ | |
| 158 158 | 
             
            		'y': '[yŸÿý]',
         | 
| 159 159 | 
             
            		'z': '[zŽž]'
         | 
| 160 160 | 
             
            	};
         | 
| 161 | 
            -
             | 
| 161 | 
            +
            	
         | 
| 162 162 | 
             
            	/* --- file: "src/plugins.js" --- */
         | 
| 163 | 
            -
             | 
| 163 | 
            +
            	
         | 
| 164 164 | 
             
            	var Plugins = {};
         | 
| 165 | 
            -
             | 
| 165 | 
            +
            	
         | 
| 166 166 | 
             
            	Plugins.mixin = function(Interface, interfaceName) {
         | 
| 167 167 | 
             
            		Interface.plugins = {};
         | 
| 168 | 
            -
             | 
| 168 | 
            +
            	
         | 
| 169 169 | 
             
            		/**
         | 
| 170 170 | 
             
            		 * Initializes the provided functions.
         | 
| 171 171 | 
             
            		 * Acceptable formats:
         | 
| @@ -182,7 +182,7 @@ | |
| 182 182 | 
             
            			var i, n, key;
         | 
| 183 183 | 
             
            			this.plugins = [];
         | 
| 184 184 | 
             
            			this.pluginSettings = {};
         | 
| 185 | 
            -
             | 
| 185 | 
            +
            	
         | 
| 186 186 | 
             
            			if ($.isArray(plugins)) {
         | 
| 187 187 | 
             
            				for (i = 0, n = plugins.length; i < n; i++) {
         | 
| 188 188 | 
             
            					this.loadPlugin(plugins[i]);
         | 
| @@ -196,7 +196,7 @@ | |
| 196 196 | 
             
            				}
         | 
| 197 197 | 
             
            			}
         | 
| 198 198 | 
             
            		};
         | 
| 199 | 
            -
             | 
| 199 | 
            +
            	
         | 
| 200 200 | 
             
            		/**
         | 
| 201 201 | 
             
            		 * Initializes a plugin.
         | 
| 202 202 | 
             
            		 *
         | 
| @@ -204,14 +204,14 @@ | |
| 204 204 | 
             
            		 */
         | 
| 205 205 | 
             
            		Interface.prototype.loadPlugin = function(name) {
         | 
| 206 206 | 
             
            			var plugin, i, n;
         | 
| 207 | 
            -
             | 
| 207 | 
            +
            	
         | 
| 208 208 | 
             
            			if (this.plugins.indexOf(name) !== -1) return;
         | 
| 209 209 | 
             
            			if (!Interface.plugins.hasOwnProperty(name)) {
         | 
| 210 210 | 
             
            				throw new Error(interfaceName + ' unable to find "' +  name + '" plugin');
         | 
| 211 211 | 
             
            			}
         | 
| 212 | 
            -
             | 
| 212 | 
            +
            	
         | 
| 213 213 | 
             
            			plugin = Interface.plugins[name];
         | 
| 214 | 
            -
             | 
| 214 | 
            +
            	
         | 
| 215 215 | 
             
            			// initialize plugin and dependencies
         | 
| 216 216 | 
             
            			this.plugins.push(name);
         | 
| 217 217 | 
             
            			for (i = 0, n = plugin.dependencies.length; i < n; i++) {
         | 
| @@ -219,7 +219,7 @@ | |
| 219 219 | 
             
            			}
         | 
| 220 220 | 
             
            			plugin.fn.apply(this, [this.pluginSettings[name] || {}]);
         | 
| 221 221 | 
             
            		};
         | 
| 222 | 
            -
             | 
| 222 | 
            +
            	
         | 
| 223 223 | 
             
            		/**
         | 
| 224 224 | 
             
            		 * Registers a plugin.
         | 
| 225 225 | 
             
            		 *
         | 
| @@ -236,23 +236,23 @@ | |
| 236 236 | 
             
            			};
         | 
| 237 237 | 
             
            		};
         | 
| 238 238 | 
             
            	};
         | 
| 239 | 
            -
             | 
| 239 | 
            +
            	
         | 
| 240 240 | 
             
            	/* --- file: "src/utils.js" --- */
         | 
| 241 | 
            -
             | 
| 241 | 
            +
            	
         | 
| 242 242 | 
             
            	var isset = function(object) {
         | 
| 243 243 | 
             
            		return typeof object !== 'undefined';
         | 
| 244 244 | 
             
            	};
         | 
| 245 | 
            -
             | 
| 245 | 
            +
            	
         | 
| 246 246 | 
             
            	var htmlEntities = function(str) {
         | 
| 247 247 | 
             
            		return String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
         | 
| 248 248 | 
             
            	};
         | 
| 249 | 
            -
             | 
| 249 | 
            +
            	
         | 
| 250 250 | 
             
            	var quoteRegExp = function(str) {
         | 
| 251 251 | 
             
            		return (str + '').replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1');
         | 
| 252 252 | 
             
            	};
         | 
| 253 | 
            -
             | 
| 253 | 
            +
            	
         | 
| 254 254 | 
             
            	var hook = {};
         | 
| 255 | 
            -
             | 
| 255 | 
            +
            	
         | 
| 256 256 | 
             
            	/**
         | 
| 257 257 | 
             
            	* Wraps `method` on `self` so that `fn`
         | 
| 258 258 | 
             
            	* is invoked before the original method.
         | 
| @@ -268,7 +268,7 @@ | |
| 268 268 | 
             
            			return original.apply(self, arguments);
         | 
| 269 269 | 
             
            		};
         | 
| 270 270 | 
             
            	};
         | 
| 271 | 
            -
             | 
| 271 | 
            +
            	
         | 
| 272 272 | 
             
            	/**
         | 
| 273 273 | 
             
            	* Wraps `method` on `self` so that `fn`
         | 
| 274 274 | 
             
            	* is invoked after the original method.
         | 
| @@ -285,7 +285,7 @@ | |
| 285 285 | 
             
            			return result;
         | 
| 286 286 | 
             
            		};
         | 
| 287 287 | 
             
            	};
         | 
| 288 | 
            -
             | 
| 288 | 
            +
            	
         | 
| 289 289 | 
             
            	var once = function(fn) {
         | 
| 290 290 | 
             
            		var called = false;
         | 
| 291 291 | 
             
            		return function() {
         | 
| @@ -294,7 +294,7 @@ | |
| 294 294 | 
             
            			fn.apply(this, arguments);
         | 
| 295 295 | 
             
            		};
         | 
| 296 296 | 
             
            	};
         | 
| 297 | 
            -
             | 
| 297 | 
            +
            	
         | 
| 298 298 | 
             
            	var debounce = function(fn, delay) {
         | 
| 299 299 | 
             
            		var timeout;
         | 
| 300 300 | 
             
            		return function() {
         | 
| @@ -306,7 +306,7 @@ | |
| 306 306 | 
             
            			}, delay);
         | 
| 307 307 | 
             
            		};
         | 
| 308 308 | 
             
            	};
         | 
| 309 | 
            -
             | 
| 309 | 
            +
            	
         | 
| 310 310 | 
             
            	/**
         | 
| 311 311 | 
             
            	* Debounce all fired events types listed in `types`
         | 
| 312 312 | 
             
            	* while executing the provided `fn`.
         | 
| @@ -319,16 +319,16 @@ | |
| 319 319 | 
             
            		var type;
         | 
| 320 320 | 
             
            		var trigger = self.trigger;
         | 
| 321 321 | 
             
            		var event_args = {};
         | 
| 322 | 
            -
             | 
| 322 | 
            +
            	
         | 
| 323 323 | 
             
            		// override trigger method
         | 
| 324 324 | 
             
            		self.trigger = function() {
         | 
| 325 325 | 
             
            			event_args[arguments[0]] = arguments;
         | 
| 326 326 | 
             
            		};
         | 
| 327 | 
            -
             | 
| 327 | 
            +
            	
         | 
| 328 328 | 
             
            		// invoke provided function
         | 
| 329 329 | 
             
            		fn.apply(self, []);
         | 
| 330 330 | 
             
            		self.trigger = trigger;
         | 
| 331 | 
            -
             | 
| 331 | 
            +
            	
         | 
| 332 332 | 
             
            		// trigger queued events
         | 
| 333 333 | 
             
            		for (type in event_args) {
         | 
| 334 334 | 
             
            			if (event_args.hasOwnProperty(type)) {
         | 
| @@ -336,7 +336,7 @@ | |
| 336 336 | 
             
            			}
         | 
| 337 337 | 
             
            		}
         | 
| 338 338 | 
             
            	};
         | 
| 339 | 
            -
             | 
| 339 | 
            +
            	
         | 
| 340 340 | 
             
            	/**
         | 
| 341 341 | 
             
            	* A workaround for http://bugs.jquery.com/ticket/6696
         | 
| 342 342 | 
             
            	*
         | 
| @@ -355,7 +355,7 @@ | |
| 355 355 | 
             
            			return fn.apply(this, [e]);
         | 
| 356 356 | 
             
            		});
         | 
| 357 357 | 
             
            	};
         | 
| 358 | 
            -
             | 
| 358 | 
            +
            	
         | 
| 359 359 | 
             
            	var getSelection = function(input) {
         | 
| 360 360 | 
             
            		var result = {};
         | 
| 361 361 | 
             
            		if ('selectionStart' in input) {
         | 
| @@ -371,7 +371,7 @@ | |
| 371 371 | 
             
            		}
         | 
| 372 372 | 
             
            		return result;
         | 
| 373 373 | 
             
            	};
         | 
| 374 | 
            -
             | 
| 374 | 
            +
            	
         | 
| 375 375 | 
             
            	var transferStyles = function($from, $to, properties) {
         | 
| 376 376 | 
             
            		var styles = {};
         | 
| 377 377 | 
             
            		if (properties) {
         | 
| @@ -384,7 +384,7 @@ | |
| 384 384 | 
             
            		$to.css(styles);
         | 
| 385 385 | 
             
            		return $to;
         | 
| 386 386 | 
             
            	};
         | 
| 387 | 
            -
             | 
| 387 | 
            +
            	
         | 
| 388 388 | 
             
            	var measureString = function(str, $parent) {
         | 
| 389 389 | 
             
            		var $test = $('<test>').css({
         | 
| 390 390 | 
             
            			position: 'absolute',
         | 
| @@ -394,7 +394,7 @@ | |
| 394 394 | 
             
            			padding: 0,
         | 
| 395 395 | 
             
            			whiteSpace: 'nowrap'
         | 
| 396 396 | 
             
            		}).text(str).appendTo('body');
         | 
| 397 | 
            -
             | 
| 397 | 
            +
            	
         | 
| 398 398 | 
             
            		transferStyles($parent, $test, [
         | 
| 399 399 | 
             
            			'letterSpacing',
         | 
| 400 400 | 
             
            			'fontSize',
         | 
| @@ -402,22 +402,22 @@ | |
| 402 402 | 
             
            			'fontWeight',
         | 
| 403 403 | 
             
            			'textTransform'
         | 
| 404 404 | 
             
            		]);
         | 
| 405 | 
            -
             | 
| 405 | 
            +
            	
         | 
| 406 406 | 
             
            		var width = $test.width();
         | 
| 407 407 | 
             
            		$test.remove();
         | 
| 408 | 
            -
             | 
| 408 | 
            +
            	
         | 
| 409 409 | 
             
            		return width;
         | 
| 410 410 | 
             
            	};
         | 
| 411 | 
            -
             | 
| 411 | 
            +
            	
         | 
| 412 412 | 
             
            	var autoGrow = function($input) {
         | 
| 413 413 | 
             
            		var update = function(e) {
         | 
| 414 414 | 
             
            			var value, keyCode, printable, placeholder, width;
         | 
| 415 415 | 
             
            			var shift, character, selection;
         | 
| 416 416 | 
             
            			e = e || window.event || {};
         | 
| 417 | 
            -
             | 
| 417 | 
            +
            	
         | 
| 418 418 | 
             
            			if (e.metaKey || e.altKey) return;
         | 
| 419 419 | 
             
            			if ($input.data('grow') === false) return;
         | 
| 420 | 
            -
             | 
| 420 | 
            +
            	
         | 
| 421 421 | 
             
            			value = $input.val();
         | 
| 422 422 | 
             
            			if (e.type && e.type.toLowerCase() === 'keydown') {
         | 
| 423 423 | 
             
            				keyCode = e.keyCode;
         | 
| @@ -427,7 +427,7 @@ | |
| 427 427 | 
             
            					(keyCode >= 48 && keyCode <= 57)  || // 0-9
         | 
| 428 428 | 
             
            					keyCode == 32 // space
         | 
| 429 429 | 
             
            				);
         | 
| 430 | 
            -
             | 
| 430 | 
            +
            	
         | 
| 431 431 | 
             
            				if (keyCode === KEY_DELETE || keyCode === KEY_BACKSPACE) {
         | 
| 432 432 | 
             
            					selection = getSelection($input[0]);
         | 
| 433 433 | 
             
            					if (selection.length) {
         | 
| @@ -445,25 +445,25 @@ | |
| 445 445 | 
             
            					value += character;
         | 
| 446 446 | 
             
            				}
         | 
| 447 447 | 
             
            			}
         | 
| 448 | 
            -
             | 
| 448 | 
            +
            	
         | 
| 449 449 | 
             
            			placeholder = $input.attr('placeholder') || '';
         | 
| 450 450 | 
             
            			if (!value.length && placeholder.length) {
         | 
| 451 451 | 
             
            				value = placeholder;
         | 
| 452 452 | 
             
            			}
         | 
| 453 | 
            -
             | 
| 453 | 
            +
            	
         | 
| 454 454 | 
             
            			width = measureString(value, $input) + 4;
         | 
| 455 455 | 
             
            			if (width !== $input.width()) {
         | 
| 456 456 | 
             
            				$input.width(width);
         | 
| 457 457 | 
             
            				$input.triggerHandler('resize');
         | 
| 458 458 | 
             
            			}
         | 
| 459 459 | 
             
            		};
         | 
| 460 | 
            -
             | 
| 460 | 
            +
            	
         | 
| 461 461 | 
             
            		$input.on('keydown keyup update blur', update);
         | 
| 462 462 | 
             
            		update();
         | 
| 463 463 | 
             
            	};
         | 
| 464 | 
            -
             | 
| 464 | 
            +
            	
         | 
| 465 465 | 
             
            	/* --- file: "src/selectize.js" --- */
         | 
| 466 | 
            -
             | 
| 466 | 
            +
            	
         | 
| 467 467 | 
             
            	/**
         | 
| 468 468 | 
             
            	* selectize.js
         | 
| 469 469 | 
             
            	* Copyright (c) 2013 Brian Reavis & contributors
         | 
| @@ -479,15 +479,15 @@ | |
| 479 479 | 
             
            	*
         | 
| 480 480 | 
             
            	* @author Brian Reavis <brian@thirdroute.com>
         | 
| 481 481 | 
             
            	*/
         | 
| 482 | 
            -
             | 
| 482 | 
            +
            	
         | 
| 483 483 | 
             
            	var Selectize = function($input, settings) {
         | 
| 484 484 | 
             
            		var key, i, n;
         | 
| 485 485 | 
             
            		$input[0].selectize   = this;
         | 
| 486 | 
            -
             | 
| 486 | 
            +
            	
         | 
| 487 487 | 
             
            		this.$input           = $input;
         | 
| 488 488 | 
             
            		this.tagType          = $input[0].tagName.toLowerCase() === 'select' ? TAG_SELECT : TAG_INPUT;
         | 
| 489 489 | 
             
            		this.settings         = settings;
         | 
| 490 | 
            -
             | 
| 490 | 
            +
            	
         | 
| 491 491 | 
             
            		this.highlightedValue = null;
         | 
| 492 492 | 
             
            		this.isOpen           = false;
         | 
| 493 493 | 
             
            		this.isDisabled       = false;
         | 
| @@ -507,17 +507,17 @@ | |
| 507 507 | 
             
            		this.caretPos         = 0;
         | 
| 508 508 | 
             
            		this.loading          = 0;
         | 
| 509 509 | 
             
            		this.loadedSearches   = {};
         | 
| 510 | 
            -
             | 
| 510 | 
            +
            	
         | 
| 511 511 | 
             
            		this.$activeOption    = null;
         | 
| 512 512 | 
             
            		this.$activeItems     = [];
         | 
| 513 | 
            -
             | 
| 513 | 
            +
            	
         | 
| 514 514 | 
             
            		this.optgroups        = {};
         | 
| 515 515 | 
             
            		this.options          = {};
         | 
| 516 516 | 
             
            		this.userOptions      = {};
         | 
| 517 517 | 
             
            		this.items            = [];
         | 
| 518 518 | 
             
            		this.renderCache      = {};
         | 
| 519 519 | 
             
            		this.onSearchChange   = debounce(this.onSearchChange, this.settings.loadThrottle);
         | 
| 520 | 
            -
             | 
| 520 | 
            +
            	
         | 
| 521 521 | 
             
            		if ($.isArray(settings.options)) {
         | 
| 522 522 | 
             
            			key = settings.valueField;
         | 
| 523 523 | 
             
            			for (i = 0, n = settings.options.length; i < n; i++) {
         | 
| @@ -529,7 +529,7 @@ | |
| 529 529 | 
             
            			$.extend(this.options, settings.options);
         | 
| 530 530 | 
             
            			delete this.settings.options;
         | 
| 531 531 | 
             
            		}
         | 
| 532 | 
            -
             | 
| 532 | 
            +
            	
         | 
| 533 533 | 
             
            		if ($.isArray(settings.optgroups)) {
         | 
| 534 534 | 
             
            			key = settings.optgroupValueField;
         | 
| 535 535 | 
             
            			for (i = 0, n = settings.optgroups.length; i < n; i++) {
         | 
| @@ -541,27 +541,27 @@ | |
| 541 541 | 
             
            			$.extend(this.optgroups, settings.optgroups);
         | 
| 542 542 | 
             
            			delete this.settings.optgroups;
         | 
| 543 543 | 
             
            		}
         | 
| 544 | 
            -
             | 
| 544 | 
            +
            	
         | 
| 545 545 | 
             
            		// option-dependent defaults
         | 
| 546 546 | 
             
            		this.settings.mode = this.settings.mode || (this.settings.maxItems === 1 ? 'single' : 'multi');
         | 
| 547 547 | 
             
            		if (typeof this.settings.hideSelected !== 'boolean') {
         | 
| 548 548 | 
             
            			this.settings.hideSelected = this.settings.mode === 'multi';
         | 
| 549 549 | 
             
            		}
         | 
| 550 | 
            -
             | 
| 550 | 
            +
            	
         | 
| 551 551 | 
             
            		this.loadPlugins(this.settings.plugins);
         | 
| 552 552 | 
             
            		this.setupCallbacks();
         | 
| 553 553 | 
             
            		this.setup();
         | 
| 554 554 | 
             
            	};
         | 
| 555 | 
            -
             | 
| 555 | 
            +
            	
         | 
| 556 556 | 
             
            	// mixins
         | 
| 557 557 | 
             
            	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
         | 
| 558 | 
            -
             | 
| 558 | 
            +
            	
         | 
| 559 559 | 
             
            	MicroEvent.mixin(Selectize);
         | 
| 560 560 | 
             
            	Plugins.mixin(Selectize, 'Selectize');
         | 
| 561 | 
            -
             | 
| 561 | 
            +
            	
         | 
| 562 562 | 
             
            	// methods
         | 
| 563 563 | 
             
            	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
         | 
| 564 | 
            -
             | 
| 564 | 
            +
            	
         | 
| 565 565 | 
             
            	/**
         | 
| 566 566 | 
             
            	* Creates all elements and sets up event bindings.
         | 
| 567 567 | 
             
            	*/
         | 
| @@ -572,47 +572,49 @@ | |
| 572 572 | 
             
            		var $control_input;
         | 
| 573 573 | 
             
            		var $dropdown;
         | 
| 574 574 | 
             
            		var $dropdown_content;
         | 
| 575 | 
            +
            		var $dropdown_parent;
         | 
| 575 576 | 
             
            		var inputMode;
         | 
| 576 577 | 
             
            		var timeout_blur;
         | 
| 577 578 | 
             
            		var timeout_focus;
         | 
| 578 579 | 
             
            		var tab_index;
         | 
| 579 580 | 
             
            		var classes;
         | 
| 580 | 
            -
             | 
| 581 | 
            +
            	
         | 
| 581 582 | 
             
            		tab_index         = this.$input.attr('tabindex') || '';
         | 
| 582 583 | 
             
            		classes           = this.$input.attr('class') || '';
         | 
| 583 584 | 
             
            		$wrapper          = $('<div>').addClass(this.settings.theme).addClass(this.settings.wrapperClass).addClass(classes);
         | 
| 584 585 | 
             
            		$control          = $('<div>').addClass(this.settings.inputClass).addClass('items').toggleClass('has-options', !$.isEmptyObject(this.options)).appendTo($wrapper);
         | 
| 585 586 | 
             
            		$control_input    = $('<input type="text">').appendTo($control).attr('tabindex',tab_index);
         | 
| 586 | 
            -
            		$ | 
| 587 | 
            +
            		$dropdown_parent  = $(this.settings.dropdownParent || $wrapper);
         | 
| 588 | 
            +
            		$dropdown         = $('<div>').addClass(this.settings.dropdownClass).hide().appendTo($dropdown_parent);
         | 
| 587 589 | 
             
            		$dropdown_content = $('<div>').addClass(this.settings.dropdownContentClass).appendTo($dropdown);
         | 
| 588 | 
            -
             | 
| 590 | 
            +
            	
         | 
| 589 591 | 
             
            		$wrapper.css({
         | 
| 590 592 | 
             
            			width: this.$input[0].style.width,
         | 
| 591 593 | 
             
            			display: this.$input.css('display')
         | 
| 592 594 | 
             
            		});
         | 
| 593 | 
            -
             | 
| 595 | 
            +
            	
         | 
| 594 596 | 
             
            		if (this.plugins.length) {
         | 
| 595 597 | 
             
            			$wrapper.addClass('plugin-' + this.plugins.join(' plugin-'));
         | 
| 596 598 | 
             
            		}
         | 
| 597 | 
            -
             | 
| 599 | 
            +
            	
         | 
| 598 600 | 
             
            		inputMode = this.settings.mode;
         | 
| 599 601 | 
             
            		$wrapper.toggleClass('single', inputMode === 'single');
         | 
| 600 602 | 
             
            		$wrapper.toggleClass('multi', inputMode === 'multi');
         | 
| 601 | 
            -
             | 
| 603 | 
            +
            	
         | 
| 602 604 | 
             
            		if ((this.settings.maxItems === null || this.settings.maxItems > 1) && this.tagType === TAG_SELECT) {
         | 
| 603 605 | 
             
            			this.$input.attr('multiple', 'multiple');
         | 
| 604 606 | 
             
            		}
         | 
| 605 | 
            -
             | 
| 607 | 
            +
            	
         | 
| 606 608 | 
             
            		if (this.settings.placeholder) {
         | 
| 607 609 | 
             
            			$control_input.attr('placeholder', this.settings.placeholder);
         | 
| 608 610 | 
             
            		}
         | 
| 609 | 
            -
             | 
| 611 | 
            +
            	
         | 
| 610 612 | 
             
            		this.$wrapper          = $wrapper;
         | 
| 611 613 | 
             
            		this.$control          = $control;
         | 
| 612 614 | 
             
            		this.$control_input    = $control_input;
         | 
| 613 615 | 
             
            		this.$dropdown         = $dropdown;
         | 
| 614 616 | 
             
            		this.$dropdown_content = $dropdown_content;
         | 
| 615 | 
            -
             | 
| 617 | 
            +
            	
         | 
| 616 618 | 
             
            		$control.on('mousedown', function(e) {
         | 
| 617 619 | 
             
            			if (!e.isDefaultPrevented()) {
         | 
| 618 620 | 
             
            				window.setTimeout(function() {
         | 
| @@ -620,12 +622,20 @@ | |
| 620 622 | 
             
            				}, 0);
         | 
| 621 623 | 
             
            			}
         | 
| 622 624 | 
             
            		});
         | 
| 623 | 
            -
             | 
| 625 | 
            +
            	
         | 
| 626 | 
            +
            		// necessary for mobile webkit devices (manual focus triggering
         | 
| 627 | 
            +
            		// is ignored unless invoked within a click event)
         | 
| 628 | 
            +
            		$control.on('click', function(e) {
         | 
| 629 | 
            +
            			if (!self.isInputFocused) {
         | 
| 630 | 
            +
            				self.focus(true);
         | 
| 631 | 
            +
            			}
         | 
| 632 | 
            +
            		});
         | 
| 633 | 
            +
            	
         | 
| 624 634 | 
             
            		$dropdown.on('mouseenter', '[data-selectable]', function() { return self.onOptionHover.apply(self, arguments); });
         | 
| 625 635 | 
             
            		$dropdown.on('mousedown', '[data-selectable]', function() { return self.onOptionSelect.apply(self, arguments); });
         | 
| 626 636 | 
             
            		watchChildEvent($control, 'mousedown', '*:not(input)', function() { return self.onItemSelect.apply(self, arguments); });
         | 
| 627 637 | 
             
            		autoGrow($control_input);
         | 
| 628 | 
            -
             | 
| 638 | 
            +
            	
         | 
| 629 639 | 
             
            		$control_input.on({
         | 
| 630 640 | 
             
            			mousedown : function(e) { e.stopPropagation(); },
         | 
| 631 641 | 
             
            			keydown   : function() { return self.onKeyDown.apply(self, arguments); },
         | 
| @@ -635,7 +645,7 @@ | |
| 635 645 | 
             
            			blur      : function() { return self.onBlur.apply(self, arguments); },
         | 
| 636 646 | 
             
            			focus     : function() { return self.onFocus.apply(self, arguments); }
         | 
| 637 647 | 
             
            		});
         | 
| 638 | 
            -
             | 
| 648 | 
            +
            	
         | 
| 639 649 | 
             
            		$(document).on({
         | 
| 640 650 | 
             
            			keydown: function(e) {
         | 
| 641 651 | 
             
            				self.isCmdDown = e[IS_MAC ? 'metaKey' : 'ctrlKey'];
         | 
| @@ -666,7 +676,7 @@ | |
| 666 676 | 
             
            				}
         | 
| 667 677 | 
             
            			}
         | 
| 668 678 | 
             
            		});
         | 
| 669 | 
            -
             | 
| 679 | 
            +
            	
         | 
| 670 680 | 
             
            		$(window).on({
         | 
| 671 681 | 
             
            			resize: function() {
         | 
| 672 682 | 
             
            				if (self.isOpen) {
         | 
| @@ -677,29 +687,29 @@ | |
| 677 687 | 
             
            				self.ignoreHover = false;
         | 
| 678 688 | 
             
            			}
         | 
| 679 689 | 
             
            		});
         | 
| 680 | 
            -
             | 
| 690 | 
            +
            	
         | 
| 681 691 | 
             
            		this.$input.attr('tabindex',-1).hide().after(this.$wrapper);
         | 
| 682 | 
            -
             | 
| 692 | 
            +
            	
         | 
| 683 693 | 
             
            		if ($.isArray(this.settings.items)) {
         | 
| 684 694 | 
             
            			this.setValue(this.settings.items);
         | 
| 685 695 | 
             
            			delete this.settings.items;
         | 
| 686 696 | 
             
            		}
         | 
| 687 | 
            -
             | 
| 697 | 
            +
            	
         | 
| 688 698 | 
             
            		this.updateOriginalInput();
         | 
| 689 699 | 
             
            		this.refreshItems();
         | 
| 690 700 | 
             
            		this.updatePlaceholder();
         | 
| 691 701 | 
             
            		this.isSetup = true;
         | 
| 692 | 
            -
             | 
| 702 | 
            +
            	
         | 
| 693 703 | 
             
            		if (this.$input.is(':disabled')) {
         | 
| 694 704 | 
             
            			this.disable();
         | 
| 695 705 | 
             
            		}
         | 
| 696 | 
            -
             | 
| 706 | 
            +
            	
         | 
| 697 707 | 
             
            		// preload options
         | 
| 698 708 | 
             
            		if (this.settings.preload) {
         | 
| 699 709 | 
             
            			this.onSearchChange('');
         | 
| 700 710 | 
             
            		}
         | 
| 701 711 | 
             
            	};
         | 
| 702 | 
            -
             | 
| 712 | 
            +
            	
         | 
| 703 713 | 
             
            	/**
         | 
| 704 714 | 
             
            	* Maps fired events to callbacks provided
         | 
| 705 715 | 
             
            	* in the settings used when creating the control.
         | 
| @@ -717,7 +727,7 @@ | |
| 717 727 | 
             
            			'dropdown_close' : 'onDropdownClose',
         | 
| 718 728 | 
             
            			'type'           : 'onType'
         | 
| 719 729 | 
             
            		};
         | 
| 720 | 
            -
             | 
| 730 | 
            +
            	
         | 
| 721 731 | 
             
            		for (key in callbacks) {
         | 
| 722 732 | 
             
            			if (callbacks.hasOwnProperty(key)) {
         | 
| 723 733 | 
             
            				fn = this.settings[callbacks[key]];
         | 
| @@ -725,7 +735,7 @@ | |
| 725 735 | 
             
            			}
         | 
| 726 736 | 
             
            		}
         | 
| 727 737 | 
             
            	};
         | 
| 728 | 
            -
             | 
| 738 | 
            +
            	
         | 
| 729 739 | 
             
            	/**
         | 
| 730 740 | 
             
            	* Triggers a callback defined in the user-provided settings.
         | 
| 731 741 | 
             
            	* Events: onItemAdd, onOptionAdd, etc
         | 
| @@ -739,7 +749,7 @@ | |
| 739 749 | 
             
            			this.settings[event].apply(this, args);
         | 
| 740 750 | 
             
            		}
         | 
| 741 751 | 
             
            	};
         | 
| 742 | 
            -
             | 
| 752 | 
            +
            	
         | 
| 743 753 | 
             
            	/**
         | 
| 744 754 | 
             
            	* Triggered on <input> keypress.
         | 
| 745 755 | 
             
            	*
         | 
| @@ -755,7 +765,7 @@ | |
| 755 765 | 
             
            			return false;
         | 
| 756 766 | 
             
            		}
         | 
| 757 767 | 
             
            	};
         | 
| 758 | 
            -
             | 
| 768 | 
            +
            	
         | 
| 759 769 | 
             
            	/**
         | 
| 760 770 | 
             
            	* Triggered on <input> keydown.
         | 
| 761 771 | 
             
            	*
         | 
| @@ -764,14 +774,14 @@ | |
| 764 774 | 
             
            	*/
         | 
| 765 775 | 
             
            	Selectize.prototype.onKeyDown = function(e) {
         | 
| 766 776 | 
             
            		var isInput = e.target === this.$control_input[0];
         | 
| 767 | 
            -
             | 
| 777 | 
            +
            	
         | 
| 768 778 | 
             
            		if (this.isLocked) {
         | 
| 769 779 | 
             
            			if (e.keyCode !== KEY_TAB) {
         | 
| 770 780 | 
             
            				e.preventDefault();
         | 
| 771 781 | 
             
            			}
         | 
| 772 782 | 
             
            			return;
         | 
| 773 783 | 
             
            		}
         | 
| 774 | 
            -
             | 
| 784 | 
            +
            	
         | 
| 775 785 | 
             
            		switch (e.keyCode) {
         | 
| 776 786 | 
             
            			case KEY_A:
         | 
| 777 787 | 
             
            				if (this.isCmdDown) {
         | 
| @@ -829,7 +839,7 @@ | |
| 829 839 | 
             
            			return;
         | 
| 830 840 | 
             
            		}
         | 
| 831 841 | 
             
            	};
         | 
| 832 | 
            -
             | 
| 842 | 
            +
            	
         | 
| 833 843 | 
             
            	/**
         | 
| 834 844 | 
             
            	* Triggered on <input> keyup.
         | 
| 835 845 | 
             
            	*
         | 
| @@ -846,7 +856,7 @@ | |
| 846 856 | 
             
            			this.trigger('type', value);
         | 
| 847 857 | 
             
            		}
         | 
| 848 858 | 
             
            	};
         | 
| 849 | 
            -
             | 
| 859 | 
            +
            	
         | 
| 850 860 | 
             
            	/**
         | 
| 851 861 | 
             
            	* Invokes the user-provide option provider / loader.
         | 
| 852 862 | 
             
            	*
         | 
| @@ -865,7 +875,7 @@ | |
| 865 875 | 
             
            			fn.apply(self, [value, callback]);
         | 
| 866 876 | 
             
            		});
         | 
| 867 877 | 
             
            	};
         | 
| 868 | 
            -
             | 
| 878 | 
            +
            	
         | 
| 869 879 | 
             
            	/**
         | 
| 870 880 | 
             
            	* Triggered on <input> focus.
         | 
| 871 881 | 
             
            	*
         | 
| @@ -880,14 +890,16 @@ | |
| 880 890 | 
             
            			e.preventDefault();
         | 
| 881 891 | 
             
            			return false;
         | 
| 882 892 | 
             
            		}
         | 
| 893 | 
            +
            	
         | 
| 883 894 | 
             
            		if (this.ignoreFocus) return;
         | 
| 884 | 
            -
             | 
| 895 | 
            +
            		if (this.settings.preload === 'focus') this.onSearchChange('');
         | 
| 896 | 
            +
            	
         | 
| 885 897 | 
             
            		this.showInput();
         | 
| 886 898 | 
             
            		this.setActiveItem(null);
         | 
| 887 899 | 
             
            		this.refreshOptions(!!this.settings.openOnFocus);
         | 
| 888 900 | 
             
            		this.refreshClasses();
         | 
| 889 901 | 
             
            	};
         | 
| 890 | 
            -
             | 
| 902 | 
            +
            	
         | 
| 891 903 | 
             
            	/**
         | 
| 892 904 | 
             
            	* Triggered on <input> blur.
         | 
| 893 905 | 
             
            	*
         | 
| @@ -897,7 +909,7 @@ | |
| 897 909 | 
             
            	Selectize.prototype.onBlur = function(e) {
         | 
| 898 910 | 
             
            		this.isInputFocused = false;
         | 
| 899 911 | 
             
            		if (this.ignoreFocus) return;
         | 
| 900 | 
            -
             | 
| 912 | 
            +
            	
         | 
| 901 913 | 
             
            		this.close();
         | 
| 902 914 | 
             
            		this.setTextboxValue('');
         | 
| 903 915 | 
             
            		this.setActiveItem(null);
         | 
| @@ -906,7 +918,7 @@ | |
| 906 918 | 
             
            		this.isFocused = false;
         | 
| 907 919 | 
             
            		this.refreshClasses();
         | 
| 908 920 | 
             
            	};
         | 
| 909 | 
            -
             | 
| 921 | 
            +
            	
         | 
| 910 922 | 
             
            	/**
         | 
| 911 923 | 
             
            	* Triggered when the user rolls over
         | 
| 912 924 | 
             
            	* an option in the autocomplete dropdown menu.
         | 
| @@ -918,7 +930,7 @@ | |
| 918 930 | 
             
            		if (this.ignoreHover) return;
         | 
| 919 931 | 
             
            		this.setActiveOption(e.currentTarget, false);
         | 
| 920 932 | 
             
            	};
         | 
| 921 | 
            -
             | 
| 933 | 
            +
            	
         | 
| 922 934 | 
             
            	/**
         | 
| 923 935 | 
             
            	* Triggered when the user clicks on an option
         | 
| 924 936 | 
             
            	* in the autocomplete dropdown menu.
         | 
| @@ -930,7 +942,7 @@ | |
| 930 942 | 
             
            		e.preventDefault && e.preventDefault();
         | 
| 931 943 | 
             
            		e.stopPropagation && e.stopPropagation();
         | 
| 932 944 | 
             
            		this.focus(false);
         | 
| 933 | 
            -
             | 
| 945 | 
            +
            	
         | 
| 934 946 | 
             
            		var $target = $(e.currentTarget);
         | 
| 935 947 | 
             
            		if ($target.hasClass('create')) {
         | 
| 936 948 | 
             
            			this.createItem();
         | 
| @@ -942,7 +954,7 @@ | |
| 942 954 | 
             
            			}
         | 
| 943 955 | 
             
            		}
         | 
| 944 956 | 
             
            	};
         | 
| 945 | 
            -
             | 
| 957 | 
            +
            	
         | 
| 946 958 | 
             
            	/**
         | 
| 947 959 | 
             
            	* Triggered when the user clicks on an item
         | 
| 948 960 | 
             
            	* that has been selected.
         | 
| @@ -958,7 +970,7 @@ | |
| 958 970 | 
             
            			this.hideInput();
         | 
| 959 971 | 
             
            		}
         | 
| 960 972 | 
             
            	};
         | 
| 961 | 
            -
             | 
| 973 | 
            +
            	
         | 
| 962 974 | 
             
            	/**
         | 
| 963 975 | 
             
            	* Invokes the provided method that provides
         | 
| 964 976 | 
             
            	* results to a callback---which are then added
         | 
| @@ -969,7 +981,7 @@ | |
| 969 981 | 
             
            	Selectize.prototype.load = function(fn) {
         | 
| 970 982 | 
             
            		var self = this;
         | 
| 971 983 | 
             
            		var $wrapper = self.$wrapper.addClass('loading');
         | 
| 972 | 
            -
             | 
| 984 | 
            +
            	
         | 
| 973 985 | 
             
            		self.loading++;
         | 
| 974 986 | 
             
            		fn.apply(self, [function(results) {
         | 
| 975 987 | 
             
            			self.loading = Math.max(self.loading - 1, 0);
         | 
| @@ -984,7 +996,7 @@ | |
| 984 996 | 
             
            			self.trigger('load', results);
         | 
| 985 997 | 
             
            		}]);
         | 
| 986 998 | 
             
            	};
         | 
| 987 | 
            -
             | 
| 999 | 
            +
            	
         | 
| 988 1000 | 
             
            	/**
         | 
| 989 1001 | 
             
            	* Sets the input field of the control to the specified value.
         | 
| 990 1002 | 
             
            	*
         | 
| @@ -994,7 +1006,7 @@ | |
| 994 1006 | 
             
            		this.$control_input.val(value).triggerHandler('update');
         | 
| 995 1007 | 
             
            		this.lastValue = value;
         | 
| 996 1008 | 
             
            	};
         | 
| 997 | 
            -
             | 
| 1009 | 
            +
            	
         | 
| 998 1010 | 
             
            	/**
         | 
| 999 1011 | 
             
            	* Returns the value of the control. If multiple items
         | 
| 1000 1012 | 
             
            	* can be selected (e.g. <select multiple>), this returns
         | 
| @@ -1010,7 +1022,7 @@ | |
| 1010 1022 | 
             
            			return this.items.join(this.settings.delimiter);
         | 
| 1011 1023 | 
             
            		}
         | 
| 1012 1024 | 
             
            	};
         | 
| 1013 | 
            -
             | 
| 1025 | 
            +
            	
         | 
| 1014 1026 | 
             
            	/**
         | 
| 1015 1027 | 
             
            	* Resets the selected items to the given value.
         | 
| 1016 1028 | 
             
            	*
         | 
| @@ -1025,7 +1037,7 @@ | |
| 1025 1037 | 
             
            			}
         | 
| 1026 1038 | 
             
            		});
         | 
| 1027 1039 | 
             
            	};
         | 
| 1028 | 
            -
             | 
| 1040 | 
            +
            	
         | 
| 1029 1041 | 
             
            	/**
         | 
| 1030 1042 | 
             
            	* Sets the selected item.
         | 
| 1031 1043 | 
             
            	*
         | 
| @@ -1036,9 +1048,9 @@ | |
| 1036 1048 | 
             
            		var eventName;
         | 
| 1037 1049 | 
             
            		var i, idx, begin, end, item, swap;
         | 
| 1038 1050 | 
             
            		var $last;
         | 
| 1039 | 
            -
             | 
| 1051 | 
            +
            	
         | 
| 1040 1052 | 
             
            		$item = $($item);
         | 
| 1041 | 
            -
             | 
| 1053 | 
            +
            	
         | 
| 1042 1054 | 
             
            		// clear the active selection
         | 
| 1043 1055 | 
             
            		if (!$item.length) {
         | 
| 1044 1056 | 
             
            			$(this.$activeItems).removeClass('active');
         | 
| @@ -1046,10 +1058,10 @@ | |
| 1046 1058 | 
             
            			this.isFocused = this.isInputFocused;
         | 
| 1047 1059 | 
             
            			return;
         | 
| 1048 1060 | 
             
            		}
         | 
| 1049 | 
            -
             | 
| 1061 | 
            +
            	
         | 
| 1050 1062 | 
             
            		// modify selection
         | 
| 1051 1063 | 
             
            		eventName = e && e.type.toLowerCase();
         | 
| 1052 | 
            -
             | 
| 1064 | 
            +
            	
         | 
| 1053 1065 | 
             
            		if (eventName === 'mousedown' && this.isShiftDown && this.$activeItems.length) {
         | 
| 1054 1066 | 
             
            			$last = this.$control.children('.active:last');
         | 
| 1055 1067 | 
             
            			begin = Array.prototype.indexOf.apply(this.$control[0].childNodes, [$last[0]]);
         | 
| @@ -1079,10 +1091,10 @@ | |
| 1079 1091 | 
             
            			$(this.$activeItems).removeClass('active');
         | 
| 1080 1092 | 
             
            			this.$activeItems = [$item.addClass('active')[0]];
         | 
| 1081 1093 | 
             
            		}
         | 
| 1082 | 
            -
             | 
| 1094 | 
            +
            	
         | 
| 1083 1095 | 
             
            		this.isFocused = !!this.$activeItems.length || this.isInputFocused;
         | 
| 1084 1096 | 
             
            	};
         | 
| 1085 | 
            -
             | 
| 1097 | 
            +
            	
         | 
| 1086 1098 | 
             
            	/**
         | 
| 1087 1099 | 
             
            	* Sets the selected item in the dropdown menu
         | 
| 1088 1100 | 
             
            	* of available options.
         | 
| @@ -1094,33 +1106,33 @@ | |
| 1094 1106 | 
             
            	Selectize.prototype.setActiveOption = function($option, scroll, animate) {
         | 
| 1095 1107 | 
             
            		var height_menu, height_item, y;
         | 
| 1096 1108 | 
             
            		var scroll_top, scroll_bottom;
         | 
| 1097 | 
            -
             | 
| 1109 | 
            +
            	
         | 
| 1098 1110 | 
             
            		if (this.$activeOption) this.$activeOption.removeClass('active');
         | 
| 1099 1111 | 
             
            		this.$activeOption = null;
         | 
| 1100 | 
            -
             | 
| 1112 | 
            +
            	
         | 
| 1101 1113 | 
             
            		$option = $($option);
         | 
| 1102 1114 | 
             
            		if (!$option.length) return;
         | 
| 1103 | 
            -
             | 
| 1115 | 
            +
            	
         | 
| 1104 1116 | 
             
            		this.$activeOption = $option.addClass('active');
         | 
| 1105 | 
            -
             | 
| 1117 | 
            +
            	
         | 
| 1106 1118 | 
             
            		if (scroll || !isset(scroll)) {
         | 
| 1107 | 
            -
             | 
| 1119 | 
            +
            	
         | 
| 1108 1120 | 
             
            			height_menu   = this.$dropdown.height();
         | 
| 1109 1121 | 
             
            			height_item   = this.$activeOption.outerHeight(true);
         | 
| 1110 1122 | 
             
            			scroll        = this.$dropdown.scrollTop() || 0;
         | 
| 1111 1123 | 
             
            			y             = this.$activeOption.offset().top - this.$dropdown.offset().top + scroll;
         | 
| 1112 1124 | 
             
            			scroll_top    = y;
         | 
| 1113 1125 | 
             
            			scroll_bottom = y - height_menu + height_item;
         | 
| 1114 | 
            -
             | 
| 1126 | 
            +
            	
         | 
| 1115 1127 | 
             
            			if (y + height_item > height_menu - scroll) {
         | 
| 1116 1128 | 
             
            				this.$dropdown.stop().animate({scrollTop: scroll_bottom}, animate ? this.settings.scrollDuration : 0);
         | 
| 1117 1129 | 
             
            			} else if (y < scroll) {
         | 
| 1118 1130 | 
             
            				this.$dropdown.stop().animate({scrollTop: scroll_top}, animate ? this.settings.scrollDuration : 0);
         | 
| 1119 1131 | 
             
            			}
         | 
| 1120 | 
            -
             | 
| 1132 | 
            +
            	
         | 
| 1121 1133 | 
             
            		}
         | 
| 1122 1134 | 
             
            	};
         | 
| 1123 | 
            -
             | 
| 1135 | 
            +
            	
         | 
| 1124 1136 | 
             
            	/**
         | 
| 1125 1137 | 
             
            	* Selects all items (CTRL + A).
         | 
| 1126 1138 | 
             
            	*/
         | 
| @@ -1129,7 +1141,7 @@ | |
| 1129 1141 | 
             
            		this.isFocused = true;
         | 
| 1130 1142 | 
             
            		if (this.$activeItems.length) this.hideInput();
         | 
| 1131 1143 | 
             
            	};
         | 
| 1132 | 
            -
             | 
| 1144 | 
            +
            	
         | 
| 1133 1145 | 
             
            	/**
         | 
| 1134 1146 | 
             
            	* Hides the input element out of view, while
         | 
| 1135 1147 | 
             
            	* retaining its focus.
         | 
| @@ -1140,7 +1152,7 @@ | |
| 1140 1152 | 
             
            		this.$control_input.css({opacity: 0, position: 'absolute', left: -10000});
         | 
| 1141 1153 | 
             
            		this.isInputHidden = true;
         | 
| 1142 1154 | 
             
            	};
         | 
| 1143 | 
            -
             | 
| 1155 | 
            +
            	
         | 
| 1144 1156 | 
             
            	/**
         | 
| 1145 1157 | 
             
            	* Restores input visibility.
         | 
| 1146 1158 | 
             
            	*/
         | 
| @@ -1148,7 +1160,7 @@ | |
| 1148 1160 | 
             
            		this.$control_input.css({opacity: 1, position: 'relative', left: 0});
         | 
| 1149 1161 | 
             
            		this.isInputHidden = false;
         | 
| 1150 1162 | 
             
            	};
         | 
| 1151 | 
            -
             | 
| 1163 | 
            +
            	
         | 
| 1152 1164 | 
             
            	/**
         | 
| 1153 1165 | 
             
            	* Gives the control focus. If "trigger" is falsy,
         | 
| 1154 1166 | 
             
            	* focus handlers won't be fired--causing the focus
         | 
| @@ -1167,14 +1179,14 @@ | |
| 1167 1179 | 
             
            			if (trigger) self.onFocus();
         | 
| 1168 1180 | 
             
            		}, 0);
         | 
| 1169 1181 | 
             
            	};
         | 
| 1170 | 
            -
             | 
| 1182 | 
            +
            	
         | 
| 1171 1183 | 
             
            	/**
         | 
| 1172 1184 | 
             
            	* Forces the control out of focus.
         | 
| 1173 1185 | 
             
            	*/
         | 
| 1174 1186 | 
             
            	Selectize.prototype.blur = function() {
         | 
| 1175 1187 | 
             
            		this.$control_input.trigger('blur');
         | 
| 1176 1188 | 
             
            	};
         | 
| 1177 | 
            -
             | 
| 1189 | 
            +
            	
         | 
| 1178 1190 | 
             
            	/**
         | 
| 1179 1191 | 
             
            	* Splits a search string into an array of
         | 
| 1180 1192 | 
             
            	* individual regexps to be used to match results.
         | 
| @@ -1185,11 +1197,11 @@ | |
| 1185 1197 | 
             
            	Selectize.prototype.parseSearchTokens = function(query) {
         | 
| 1186 1198 | 
             
            		query = $.trim(String(query || '').toLowerCase());
         | 
| 1187 1199 | 
             
            		if (!query || !query.length) return [];
         | 
| 1188 | 
            -
             | 
| 1200 | 
            +
            	
         | 
| 1189 1201 | 
             
            		var i, n, regex, letter;
         | 
| 1190 1202 | 
             
            		var tokens = [];
         | 
| 1191 1203 | 
             
            		var words = query.split(/ +/);
         | 
| 1192 | 
            -
             | 
| 1204 | 
            +
            	
         | 
| 1193 1205 | 
             
            		for (i = 0, n = words.length; i < n; i++) {
         | 
| 1194 1206 | 
             
            			regex = quoteRegExp(words[i]);
         | 
| 1195 1207 | 
             
            			if (this.settings.diacritics) {
         | 
| @@ -1204,10 +1216,10 @@ | |
| 1204 1216 | 
             
            				regex  : new RegExp(regex, 'i')
         | 
| 1205 1217 | 
             
            			});
         | 
| 1206 1218 | 
             
            		}
         | 
| 1207 | 
            -
             | 
| 1219 | 
            +
            	
         | 
| 1208 1220 | 
             
            		return tokens;
         | 
| 1209 1221 | 
             
            	};
         | 
| 1210 | 
            -
             | 
| 1222 | 
            +
            	
         | 
| 1211 1223 | 
             
            	/**
         | 
| 1212 1224 | 
             
            	* Returns a function to be used to score individual results.
         | 
| 1213 1225 | 
             
            	* Results will be sorted by the score (descending). Scores less
         | 
| @@ -1220,14 +1232,14 @@ | |
| 1220 1232 | 
             
            	Selectize.prototype.getScoreFunction = function(search) {
         | 
| 1221 1233 | 
             
            		var self = this;
         | 
| 1222 1234 | 
             
            		var tokens = search.tokens;
         | 
| 1223 | 
            -
             | 
| 1235 | 
            +
            	
         | 
| 1224 1236 | 
             
            		var calculateFieldScore = (function() {
         | 
| 1225 1237 | 
             
            			if (!tokens.length) {
         | 
| 1226 1238 | 
             
            				return function() { return 0; };
         | 
| 1227 1239 | 
             
            			} else if (tokens.length === 1) {
         | 
| 1228 1240 | 
             
            				return function(value) {
         | 
| 1229 1241 | 
             
            					var score, pos;
         | 
| 1230 | 
            -
             | 
| 1242 | 
            +
            	
         | 
| 1231 1243 | 
             
            					value = String(value || '').toLowerCase();
         | 
| 1232 1244 | 
             
            					pos = value.search(tokens[0].regex);
         | 
| 1233 1245 | 
             
            					if (pos === -1) return 0;
         | 
| @@ -1238,7 +1250,7 @@ | |
| 1238 1250 | 
             
            			} else {
         | 
| 1239 1251 | 
             
            				return function(value) {
         | 
| 1240 1252 | 
             
            					var score, pos, i, j;
         | 
| 1241 | 
            -
             | 
| 1253 | 
            +
            	
         | 
| 1242 1254 | 
             
            					value = String(value || '').toLowerCase();
         | 
| 1243 1255 | 
             
            					score = 0;
         | 
| 1244 1256 | 
             
            					for (i = 0, j = tokens.length; i < j; i++) {
         | 
| @@ -1251,7 +1263,7 @@ | |
| 1251 1263 | 
             
            				};
         | 
| 1252 1264 | 
             
            			}
         | 
| 1253 1265 | 
             
            		})();
         | 
| 1254 | 
            -
             | 
| 1266 | 
            +
            	
         | 
| 1255 1267 | 
             
            		var calculateScore = (function() {
         | 
| 1256 1268 | 
             
            			var fields = self.settings.searchField;
         | 
| 1257 1269 | 
             
            			if (typeof fields === 'string') {
         | 
| @@ -1279,10 +1291,10 @@ | |
| 1279 1291 | 
             
            				};
         | 
| 1280 1292 | 
             
            			}
         | 
| 1281 1293 | 
             
            		})();
         | 
| 1282 | 
            -
             | 
| 1294 | 
            +
            	
         | 
| 1283 1295 | 
             
            		return calculateScore;
         | 
| 1284 1296 | 
             
            	};
         | 
| 1285 | 
            -
             | 
| 1297 | 
            +
            	
         | 
| 1286 1298 | 
             
            	/**
         | 
| 1287 1299 | 
             
            	* Searches through available options and returns
         | 
| 1288 1300 | 
             
            	* a sorted array of matches. Includes options that
         | 
| @@ -1308,20 +1320,20 @@ | |
| 1308 1320 | 
             
            	Selectize.prototype.search = function(query, settings) {
         | 
| 1309 1321 | 
             
            		var self = this;
         | 
| 1310 1322 | 
             
            		var value, score, search, calculateScore;
         | 
| 1311 | 
            -
             | 
| 1323 | 
            +
            	
         | 
| 1312 1324 | 
             
            		settings = settings || {};
         | 
| 1313 1325 | 
             
            		query = $.trim(String(query || '').toLowerCase());
         | 
| 1314 | 
            -
             | 
| 1326 | 
            +
            	
         | 
| 1315 1327 | 
             
            		if (query !== this.lastQuery) {
         | 
| 1316 1328 | 
             
            			this.lastQuery = query;
         | 
| 1317 | 
            -
             | 
| 1329 | 
            +
            	
         | 
| 1318 1330 | 
             
            			search = {
         | 
| 1319 1331 | 
             
            				query  : query,
         | 
| 1320 1332 | 
             
            				tokens : this.parseSearchTokens(query),
         | 
| 1321 1333 | 
             
            				total  : 0,
         | 
| 1322 1334 | 
             
            				items  : []
         | 
| 1323 1335 | 
             
            			};
         | 
| 1324 | 
            -
             | 
| 1336 | 
            +
            	
         | 
| 1325 1337 | 
             
            			// generate result scoring function
         | 
| 1326 1338 | 
             
            			if (this.settings.score) {
         | 
| 1327 1339 | 
             
            				calculateScore = this.settings.score.apply(this, [search]);
         | 
| @@ -1331,7 +1343,7 @@ | |
| 1331 1343 | 
             
            			} else {
         | 
| 1332 1344 | 
             
            				calculateScore = this.getScoreFunction(search);
         | 
| 1333 1345 | 
             
            			}
         | 
| 1334 | 
            -
             | 
| 1346 | 
            +
            	
         | 
| 1335 1347 | 
             
            			// perform search and sort
         | 
| 1336 1348 | 
             
            			if (query.length) {
         | 
| 1337 1349 | 
             
            				for (value in this.options) {
         | 
| @@ -1375,11 +1387,11 @@ | |
| 1375 1387 | 
             
            		} else {
         | 
| 1376 1388 | 
             
            			search = $.extend(true, {}, this.currentResults);
         | 
| 1377 1389 | 
             
            		}
         | 
| 1378 | 
            -
             | 
| 1390 | 
            +
            	
         | 
| 1379 1391 | 
             
            		// apply limits and return
         | 
| 1380 1392 | 
             
            		return this.prepareResults(search, settings);
         | 
| 1381 1393 | 
             
            	};
         | 
| 1382 | 
            -
             | 
| 1394 | 
            +
            	
         | 
| 1383 1395 | 
             
            	/**
         | 
| 1384 1396 | 
             
            	* Filters out any items that have already been selected
         | 
| 1385 1397 | 
             
            	* and applies search limits.
         | 
| @@ -1396,15 +1408,15 @@ | |
| 1396 1408 | 
             
            				}
         | 
| 1397 1409 | 
             
            			}
         | 
| 1398 1410 | 
             
            		}
         | 
| 1399 | 
            -
             | 
| 1411 | 
            +
            	
         | 
| 1400 1412 | 
             
            		search.total = search.items.length;
         | 
| 1401 1413 | 
             
            		if (typeof settings.limit === 'number') {
         | 
| 1402 1414 | 
             
            			search.items = search.items.slice(0, settings.limit);
         | 
| 1403 1415 | 
             
            		}
         | 
| 1404 | 
            -
             | 
| 1416 | 
            +
            	
         | 
| 1405 1417 | 
             
            		return search;
         | 
| 1406 1418 | 
             
            	};
         | 
| 1407 | 
            -
             | 
| 1419 | 
            +
            	
         | 
| 1408 1420 | 
             
            	/**
         | 
| 1409 1421 | 
             
            	* Refreshes the list of available options shown
         | 
| 1410 1422 | 
             
            	* in the autocomplete dropdown menu.
         | 
| @@ -1415,23 +1427,23 @@ | |
| 1415 1427 | 
             
            		if (typeof triggerDropdown === 'undefined') {
         | 
| 1416 1428 | 
             
            			triggerDropdown = true;
         | 
| 1417 1429 | 
             
            		}
         | 
| 1418 | 
            -
             | 
| 1430 | 
            +
            	
         | 
| 1419 1431 | 
             
            		var i, n, groups, groups_order, option, optgroup, html, html_children;
         | 
| 1420 1432 | 
             
            		var hasCreateOption;
         | 
| 1421 1433 | 
             
            		var query = this.$control_input.val();
         | 
| 1422 1434 | 
             
            		var results = this.search(query, {});
         | 
| 1423 1435 | 
             
            		var $active, $create;
         | 
| 1424 1436 | 
             
            		var $dropdown_content = this.$dropdown_content;
         | 
| 1425 | 
            -
             | 
| 1437 | 
            +
            	
         | 
| 1426 1438 | 
             
            		// build markup
         | 
| 1427 1439 | 
             
            		n = results.items.length;
         | 
| 1428 1440 | 
             
            		if (typeof this.settings.maxOptions === 'number') {
         | 
| 1429 1441 | 
             
            			n = Math.min(n, this.settings.maxOptions);
         | 
| 1430 1442 | 
             
            		}
         | 
| 1431 | 
            -
             | 
| 1443 | 
            +
            	
         | 
| 1432 1444 | 
             
            		// render and group available options individually
         | 
| 1433 1445 | 
             
            		groups = {};
         | 
| 1434 | 
            -
             | 
| 1446 | 
            +
            	
         | 
| 1435 1447 | 
             
            		if (this.settings.optgroupOrder) {
         | 
| 1436 1448 | 
             
            			groups_order = this.settings.optgroupOrder;
         | 
| 1437 1449 | 
             
            			for (i = 0; i < groups_order.length; i++) {
         | 
| @@ -1440,7 +1452,7 @@ | |
| 1440 1452 | 
             
            		} else {
         | 
| 1441 1453 | 
             
            			groups_order = [];
         | 
| 1442 1454 | 
             
            		}
         | 
| 1443 | 
            -
             | 
| 1455 | 
            +
            	
         | 
| 1444 1456 | 
             
            		for (i = 0; i < n; i++) {
         | 
| 1445 1457 | 
             
            			option = this.options[results.items[i].value];
         | 
| 1446 1458 | 
             
            			optgroup = option[this.settings.optgroupField] || '';
         | 
| @@ -1453,7 +1465,7 @@ | |
| 1453 1465 | 
             
            			}
         | 
| 1454 1466 | 
             
            			groups[optgroup].push(this.render('option', option));
         | 
| 1455 1467 | 
             
            		}
         | 
| 1456 | 
            -
             | 
| 1468 | 
            +
            	
         | 
| 1457 1469 | 
             
            		// render optgroup headers & join groups
         | 
| 1458 1470 | 
             
            		html = [];
         | 
| 1459 1471 | 
             
            		for (i = 0, n = groups_order.length; i < n; i++) {
         | 
| @@ -1470,30 +1482,30 @@ | |
| 1470 1482 | 
             
            				html.push(groups[optgroup].join(''));
         | 
| 1471 1483 | 
             
            			}
         | 
| 1472 1484 | 
             
            		}
         | 
| 1473 | 
            -
             | 
| 1485 | 
            +
            	
         | 
| 1474 1486 | 
             
            		$dropdown_content.html(html.join(''));
         | 
| 1475 | 
            -
             | 
| 1487 | 
            +
            	
         | 
| 1476 1488 | 
             
            		// highlight matching terms inline
         | 
| 1477 1489 | 
             
            		if (this.settings.highlight && results.query.length && results.tokens.length) {
         | 
| 1478 1490 | 
             
            			for (i = 0, n = results.tokens.length; i < n; i++) {
         | 
| 1479 1491 | 
             
            				highlight($dropdown_content, results.tokens[i].regex);
         | 
| 1480 1492 | 
             
            			}
         | 
| 1481 1493 | 
             
            		}
         | 
| 1482 | 
            -
             | 
| 1494 | 
            +
            	
         | 
| 1483 1495 | 
             
            		// add "selected" class to selected options
         | 
| 1484 1496 | 
             
            		if (!this.settings.hideSelected) {
         | 
| 1485 1497 | 
             
            			for (i = 0, n = this.items.length; i < n; i++) {
         | 
| 1486 1498 | 
             
            				this.getOption(this.items[i]).addClass('selected');
         | 
| 1487 1499 | 
             
            			}
         | 
| 1488 1500 | 
             
            		}
         | 
| 1489 | 
            -
             | 
| 1501 | 
            +
            	
         | 
| 1490 1502 | 
             
            		// add create option
         | 
| 1491 1503 | 
             
            		hasCreateOption = this.settings.create && results.query.length;
         | 
| 1492 1504 | 
             
            		if (hasCreateOption) {
         | 
| 1493 1505 | 
             
            			$dropdown_content.prepend(this.render('option_create', {input: query}));
         | 
| 1494 1506 | 
             
            			$create = $($dropdown_content[0].childNodes[0]);
         | 
| 1495 1507 | 
             
            		}
         | 
| 1496 | 
            -
             | 
| 1508 | 
            +
            	
         | 
| 1497 1509 | 
             
            		// activate
         | 
| 1498 1510 | 
             
            		this.hasOptions = results.items.length > 0 || hasCreateOption;
         | 
| 1499 1511 | 
             
            		if (this.hasOptions) {
         | 
| @@ -1513,7 +1525,7 @@ | |
| 1513 1525 | 
             
            			if (triggerDropdown && this.isOpen) { this.close(); }
         | 
| 1514 1526 | 
             
            		}
         | 
| 1515 1527 | 
             
            	};
         | 
| 1516 | 
            -
             | 
| 1528 | 
            +
            	
         | 
| 1517 1529 | 
             
            	/**
         | 
| 1518 1530 | 
             
            	* Adds an available option. If it already exists,
         | 
| 1519 1531 | 
             
            	* nothing will happen. Note: this does not refresh
         | 
| @@ -1530,23 +1542,23 @@ | |
| 1530 1542 | 
             
            	*/
         | 
| 1531 1543 | 
             
            	Selectize.prototype.addOption = function(value, data) {
         | 
| 1532 1544 | 
             
            		var i, n, optgroup;
         | 
| 1533 | 
            -
             | 
| 1545 | 
            +
            	
         | 
| 1534 1546 | 
             
            		if ($.isArray(value)) {
         | 
| 1535 1547 | 
             
            			for (i = 0, n = value.length; i < n; i++) {
         | 
| 1536 1548 | 
             
            				this.addOption(value[i][this.settings.valueField], value[i]);
         | 
| 1537 1549 | 
             
            			}
         | 
| 1538 1550 | 
             
            			return;
         | 
| 1539 1551 | 
             
            		}
         | 
| 1540 | 
            -
             | 
| 1552 | 
            +
            	
         | 
| 1541 1553 | 
             
            		value = value || '';
         | 
| 1542 1554 | 
             
            		if (this.options.hasOwnProperty(value)) return;
         | 
| 1543 | 
            -
             | 
| 1555 | 
            +
            	
         | 
| 1544 1556 | 
             
            		this.userOptions[value] = true;
         | 
| 1545 1557 | 
             
            		this.options[value] = data;
         | 
| 1546 1558 | 
             
            		this.lastQuery = null;
         | 
| 1547 1559 | 
             
            		this.trigger('option_add', value, data);
         | 
| 1548 1560 | 
             
            	};
         | 
| 1549 | 
            -
             | 
| 1561 | 
            +
            	
         | 
| 1550 1562 | 
             
            	/**
         | 
| 1551 1563 | 
             
            	* Registers a new optgroup for options
         | 
| 1552 1564 | 
             
            	* to be bucketed into.
         | 
| @@ -1558,7 +1570,7 @@ | |
| 1558 1570 | 
             
            		this.optgroups[id] = data;
         | 
| 1559 1571 | 
             
            		this.trigger('optgroup_add', value, data);
         | 
| 1560 1572 | 
             
            	};
         | 
| 1561 | 
            -
             | 
| 1573 | 
            +
            	
         | 
| 1562 1574 | 
             
            	/**
         | 
| 1563 1575 | 
             
            	* Updates an option available for selection. If
         | 
| 1564 1576 | 
             
            	* it is visible in the selected items or options
         | 
| @@ -1572,19 +1584,19 @@ | |
| 1572 1584 | 
             
            		this.options[value] = data;
         | 
| 1573 1585 | 
             
            		if (isset(this.renderCache['item'])) delete this.renderCache['item'][value];
         | 
| 1574 1586 | 
             
            		if (isset(this.renderCache['option'])) delete this.renderCache['option'][value];
         | 
| 1575 | 
            -
             | 
| 1587 | 
            +
            	
         | 
| 1576 1588 | 
             
            		if (this.items.indexOf(value) !== -1) {
         | 
| 1577 1589 | 
             
            			var $item = this.getItem(value);
         | 
| 1578 1590 | 
             
            			var $item_new = $(this.render('item', data));
         | 
| 1579 1591 | 
             
            			if ($item.hasClass('active')) $item_new.addClass('active');
         | 
| 1580 1592 | 
             
            			$item.replaceWith($item_new);
         | 
| 1581 1593 | 
             
            		}
         | 
| 1582 | 
            -
             | 
| 1594 | 
            +
            	
         | 
| 1583 1595 | 
             
            		if (this.isOpen) {
         | 
| 1584 1596 | 
             
            			this.refreshOptions(false);
         | 
| 1585 1597 | 
             
            		}
         | 
| 1586 1598 | 
             
            	};
         | 
| 1587 | 
            -
             | 
| 1599 | 
            +
            	
         | 
| 1588 1600 | 
             
            	/**
         | 
| 1589 1601 | 
             
            	* Removes a single option.
         | 
| 1590 1602 | 
             
            	*
         | 
| @@ -1598,7 +1610,7 @@ | |
| 1598 1610 | 
             
            		this.trigger('option_remove', value);
         | 
| 1599 1611 | 
             
            		this.removeItem(value);
         | 
| 1600 1612 | 
             
            	};
         | 
| 1601 | 
            -
             | 
| 1613 | 
            +
            	
         | 
| 1602 1614 | 
             
            	/**
         | 
| 1603 1615 | 
             
            	* Clears all options.
         | 
| 1604 1616 | 
             
            	*/
         | 
| @@ -1610,7 +1622,7 @@ | |
| 1610 1622 | 
             
            		this.trigger('option_clear');
         | 
| 1611 1623 | 
             
            		this.clear();
         | 
| 1612 1624 | 
             
            	};
         | 
| 1613 | 
            -
             | 
| 1625 | 
            +
            	
         | 
| 1614 1626 | 
             
            	/**
         | 
| 1615 1627 | 
             
            	* Returns the jQuery element of the option
         | 
| 1616 1628 | 
             
            	* matching the given value.
         | 
| @@ -1621,7 +1633,7 @@ | |
| 1621 1633 | 
             
            	Selectize.prototype.getOption = function(value) {
         | 
| 1622 1634 | 
             
            		return value ? this.$dropdown_content.find('[data-selectable]').filter('[data-value="' + value.replace(/(['"])/g, '\\$1') + '"]:first') : $();
         | 
| 1623 1635 | 
             
            	};
         | 
| 1624 | 
            -
             | 
| 1636 | 
            +
            	
         | 
| 1625 1637 | 
             
            	/**
         | 
| 1626 1638 | 
             
            	* Returns the jQuery element of the next or
         | 
| 1627 1639 | 
             
            	* previous selectable option.
         | 
| @@ -1633,10 +1645,10 @@ | |
| 1633 1645 | 
             
            	Selectize.prototype.getAdjacentOption = function($option, direction) {
         | 
| 1634 1646 | 
             
            		var $options = this.$dropdown.find('[data-selectable]');
         | 
| 1635 1647 | 
             
            		var index    = $options.index($option) + direction;
         | 
| 1636 | 
            -
             | 
| 1648 | 
            +
            	
         | 
| 1637 1649 | 
             
            		return index >= 0 && index < $options.length ? $options.eq(index) : $();
         | 
| 1638 1650 | 
             
            	};
         | 
| 1639 | 
            -
             | 
| 1651 | 
            +
            	
         | 
| 1640 1652 | 
             
            	/**
         | 
| 1641 1653 | 
             
            	* Returns the jQuery element of the item
         | 
| 1642 1654 | 
             
            	* matching the given value.
         | 
| @@ -1655,7 +1667,7 @@ | |
| 1655 1667 | 
             
            		}
         | 
| 1656 1668 | 
             
            		return $();
         | 
| 1657 1669 | 
             
            	};
         | 
| 1658 | 
            -
             | 
| 1670 | 
            +
            	
         | 
| 1659 1671 | 
             
            	/**
         | 
| 1660 1672 | 
             
            	* "Selects" an item. Adds it to the list
         | 
| 1661 1673 | 
             
            	* at the current caret position.
         | 
| @@ -1669,17 +1681,17 @@ | |
| 1669 1681 | 
             
            			var inputMode = this.settings.mode;
         | 
| 1670 1682 | 
             
            			var i, active, options, value_next;
         | 
| 1671 1683 | 
             
            			value = String(value);
         | 
| 1672 | 
            -
             | 
| 1684 | 
            +
            	
         | 
| 1673 1685 | 
             
            			if (inputMode === 'single') this.clear();
         | 
| 1674 1686 | 
             
            			if (inputMode === 'multi' && this.isFull()) return;
         | 
| 1675 1687 | 
             
            			if (this.items.indexOf(value) !== -1) return;
         | 
| 1676 1688 | 
             
            			if (!this.options.hasOwnProperty(value)) return;
         | 
| 1677 | 
            -
             | 
| 1689 | 
            +
            	
         | 
| 1678 1690 | 
             
            			$item = $(this.render('item', this.options[value]));
         | 
| 1679 1691 | 
             
            			this.items.splice(this.caretPos, 0, value);
         | 
| 1680 1692 | 
             
            			this.insertAtCaret($item);
         | 
| 1681 1693 | 
             
            			this.refreshClasses();
         | 
| 1682 | 
            -
             | 
| 1694 | 
            +
            	
         | 
| 1683 1695 | 
             
            			if (this.isSetup) {
         | 
| 1684 1696 | 
             
            				// remove the option from the menu
         | 
| 1685 1697 | 
             
            				options = this.$dropdown_content.find('[data-selectable]');
         | 
| @@ -1689,14 +1701,14 @@ | |
| 1689 1701 | 
             
            				if (value_next) {
         | 
| 1690 1702 | 
             
            					this.setActiveOption(this.getOption(value_next));
         | 
| 1691 1703 | 
             
            				}
         | 
| 1692 | 
            -
             | 
| 1704 | 
            +
            	
         | 
| 1693 1705 | 
             
            				// hide the menu if the maximum number of items have been selected or no options are left
         | 
| 1694 1706 | 
             
            				if (!options.length || (this.settings.maxItems !== null && this.items.length >= this.settings.maxItems)) {
         | 
| 1695 1707 | 
             
            					this.close();
         | 
| 1696 1708 | 
             
            				} else {
         | 
| 1697 1709 | 
             
            					this.positionDropdown();
         | 
| 1698 1710 | 
             
            				}
         | 
| 1699 | 
            -
             | 
| 1711 | 
            +
            	
         | 
| 1700 1712 | 
             
            				// restore focus to input
         | 
| 1701 1713 | 
             
            				if (this.isFocused) {
         | 
| 1702 1714 | 
             
            					window.setTimeout(function() {
         | 
| @@ -1709,14 +1721,14 @@ | |
| 1709 1721 | 
             
            						}
         | 
| 1710 1722 | 
             
            					}, 0);
         | 
| 1711 1723 | 
             
            				}
         | 
| 1712 | 
            -
             | 
| 1724 | 
            +
            	
         | 
| 1713 1725 | 
             
            				this.updatePlaceholder();
         | 
| 1714 1726 | 
             
            				this.trigger('item_add', value, $item);
         | 
| 1715 1727 | 
             
            				this.updateOriginalInput();
         | 
| 1716 1728 | 
             
            			}
         | 
| 1717 1729 | 
             
            		});
         | 
| 1718 1730 | 
             
            	};
         | 
| 1719 | 
            -
             | 
| 1731 | 
            +
            	
         | 
| 1720 1732 | 
             
            	/**
         | 
| 1721 1733 | 
             
            	* Removes the selected item matching
         | 
| 1722 1734 | 
             
            	* the provided value.
         | 
| @@ -1725,28 +1737,28 @@ | |
| 1725 1737 | 
             
            	*/
         | 
| 1726 1738 | 
             
            	Selectize.prototype.removeItem = function(value) {
         | 
| 1727 1739 | 
             
            		var $item, i, idx;
         | 
| 1728 | 
            -
             | 
| 1740 | 
            +
            	
         | 
| 1729 1741 | 
             
            		$item = (typeof value === 'object') ? value : this.getItem(value);
         | 
| 1730 1742 | 
             
            		value = String($item.attr('data-value'));
         | 
| 1731 1743 | 
             
            		i = this.items.indexOf(value);
         | 
| 1732 | 
            -
             | 
| 1744 | 
            +
            	
         | 
| 1733 1745 | 
             
            		if (i !== -1) {
         | 
| 1734 1746 | 
             
            			$item.remove();
         | 
| 1735 1747 | 
             
            			if ($item.hasClass('active')) {
         | 
| 1736 1748 | 
             
            				idx = this.$activeItems.indexOf($item[0]);
         | 
| 1737 1749 | 
             
            				this.$activeItems.splice(idx, 1);
         | 
| 1738 1750 | 
             
            			}
         | 
| 1739 | 
            -
             | 
| 1751 | 
            +
            	
         | 
| 1740 1752 | 
             
            			this.items.splice(i, 1);
         | 
| 1741 1753 | 
             
            			this.lastQuery = null;
         | 
| 1742 1754 | 
             
            			if (!this.settings.persist && this.userOptions.hasOwnProperty(value)) {
         | 
| 1743 1755 | 
             
            				this.removeOption(value);
         | 
| 1744 1756 | 
             
            			}
         | 
| 1745 | 
            -
             | 
| 1757 | 
            +
            	
         | 
| 1746 1758 | 
             
            			if (i < this.caretPos) {
         | 
| 1747 1759 | 
             
            				this.setCaret(this.caretPos - 1);
         | 
| 1748 1760 | 
             
            			}
         | 
| 1749 | 
            -
             | 
| 1761 | 
            +
            	
         | 
| 1750 1762 | 
             
            			this.refreshClasses();
         | 
| 1751 1763 | 
             
            			this.updatePlaceholder();
         | 
| 1752 1764 | 
             
            			this.updateOriginalInput();
         | 
| @@ -1754,7 +1766,7 @@ | |
| 1754 1766 | 
             
            			this.trigger('item_remove', value);
         | 
| 1755 1767 | 
             
            		}
         | 
| 1756 1768 | 
             
            	};
         | 
| 1757 | 
            -
             | 
| 1769 | 
            +
            	
         | 
| 1758 1770 | 
             
            	/**
         | 
| 1759 1771 | 
             
            	* Invokes the `create` method provided in the
         | 
| 1760 1772 | 
             
            	* selectize options that should provide the data
         | 
| @@ -1769,21 +1781,21 @@ | |
| 1769 1781 | 
             
            		var caret = this.caretPos;
         | 
| 1770 1782 | 
             
            		if (!input.length) return;
         | 
| 1771 1783 | 
             
            		this.lock();
         | 
| 1772 | 
            -
             | 
| 1784 | 
            +
            	
         | 
| 1773 1785 | 
             
            		var setup = (typeof this.settings.create === 'function') ? this.settings.create : function(input) {
         | 
| 1774 1786 | 
             
            			var data = {};
         | 
| 1775 1787 | 
             
            			data[self.settings.labelField] = input;
         | 
| 1776 1788 | 
             
            			data[self.settings.valueField] = input;
         | 
| 1777 1789 | 
             
            			return data;
         | 
| 1778 1790 | 
             
            		};
         | 
| 1779 | 
            -
             | 
| 1791 | 
            +
            	
         | 
| 1780 1792 | 
             
            		var create = once(function(data) {
         | 
| 1781 1793 | 
             
            			self.unlock();
         | 
| 1782 1794 | 
             
            			self.focus(false);
         | 
| 1783 | 
            -
             | 
| 1795 | 
            +
            	
         | 
| 1784 1796 | 
             
            			var value = data && data[self.settings.valueField];
         | 
| 1785 1797 | 
             
            			if (!value) return;
         | 
| 1786 | 
            -
             | 
| 1798 | 
            +
            	
         | 
| 1787 1799 | 
             
            			self.setTextboxValue('');
         | 
| 1788 1800 | 
             
            			self.addOption(value, data);
         | 
| 1789 1801 | 
             
            			self.setCaret(caret);
         | 
| @@ -1791,29 +1803,29 @@ | |
| 1791 1803 | 
             
            			self.refreshOptions(true);
         | 
| 1792 1804 | 
             
            			self.focus(false);
         | 
| 1793 1805 | 
             
            		});
         | 
| 1794 | 
            -
             | 
| 1806 | 
            +
            	
         | 
| 1795 1807 | 
             
            		var output = setup.apply(this, [input, create]);
         | 
| 1796 1808 | 
             
            		if (typeof output !== 'undefined') {
         | 
| 1797 1809 | 
             
            			create(output);
         | 
| 1798 1810 | 
             
            		}
         | 
| 1799 1811 | 
             
            	};
         | 
| 1800 | 
            -
             | 
| 1812 | 
            +
            	
         | 
| 1801 1813 | 
             
            	/**
         | 
| 1802 1814 | 
             
            	* Re-renders the selected item lists.
         | 
| 1803 1815 | 
             
            	*/
         | 
| 1804 1816 | 
             
            	Selectize.prototype.refreshItems = function() {
         | 
| 1805 1817 | 
             
            		this.lastQuery = null;
         | 
| 1806 | 
            -
             | 
| 1818 | 
            +
            	
         | 
| 1807 1819 | 
             
            		if (this.isSetup) {
         | 
| 1808 1820 | 
             
            			for (var i = 0; i < this.items.length; i++) {
         | 
| 1809 1821 | 
             
            				this.addItem(this.items);
         | 
| 1810 1822 | 
             
            			}
         | 
| 1811 1823 | 
             
            		}
         | 
| 1812 | 
            -
             | 
| 1824 | 
            +
            	
         | 
| 1813 1825 | 
             
            		this.refreshClasses();
         | 
| 1814 1826 | 
             
            		this.updateOriginalInput();
         | 
| 1815 1827 | 
             
            	};
         | 
| 1816 | 
            -
             | 
| 1828 | 
            +
            	
         | 
| 1817 1829 | 
             
            	/**
         | 
| 1818 1830 | 
             
            	* Updates all state-dependent CSS classes.
         | 
| 1819 1831 | 
             
            	*/
         | 
| @@ -1828,7 +1840,7 @@ | |
| 1828 1840 | 
             
            			.toggleClass('has-items', this.items.length > 0);
         | 
| 1829 1841 | 
             
            		this.$control_input.data('grow', !isFull && !isLocked);
         | 
| 1830 1842 | 
             
            	};
         | 
| 1831 | 
            -
             | 
| 1843 | 
            +
            	
         | 
| 1832 1844 | 
             
            	/**
         | 
| 1833 1845 | 
             
            	* Determines whether or not more items can be added
         | 
| 1834 1846 | 
             
            	* to the control without exceeding the user-defined maximum.
         | 
| @@ -1838,14 +1850,14 @@ | |
| 1838 1850 | 
             
            	Selectize.prototype.isFull = function() {
         | 
| 1839 1851 | 
             
            		return this.settings.maxItems !== null && this.items.length >= this.settings.maxItems;
         | 
| 1840 1852 | 
             
            	};
         | 
| 1841 | 
            -
             | 
| 1853 | 
            +
            	
         | 
| 1842 1854 | 
             
            	/**
         | 
| 1843 1855 | 
             
            	* Refreshes the original <select> or <input>
         | 
| 1844 1856 | 
             
            	* element to reflect the current state.
         | 
| 1845 1857 | 
             
            	*/
         | 
| 1846 1858 | 
             
            	Selectize.prototype.updateOriginalInput = function() {
         | 
| 1847 1859 | 
             
            		var i, n, options;
         | 
| 1848 | 
            -
             | 
| 1860 | 
            +
            	
         | 
| 1849 1861 | 
             
            		if (this.$input[0].tagName.toLowerCase() === 'select') {
         | 
| 1850 1862 | 
             
            			options = [];
         | 
| 1851 1863 | 
             
            			for (i = 0, n = this.items.length; i < n; i++) {
         | 
| @@ -1858,13 +1870,13 @@ | |
| 1858 1870 | 
             
            		} else {
         | 
| 1859 1871 | 
             
            			this.$input.val(this.getValue());
         | 
| 1860 1872 | 
             
            		}
         | 
| 1861 | 
            -
             | 
| 1873 | 
            +
            	
         | 
| 1862 1874 | 
             
            		this.$input.trigger('change');
         | 
| 1863 1875 | 
             
            		if (this.isSetup) {
         | 
| 1864 1876 | 
             
            			this.trigger('change', this.$input.val());
         | 
| 1865 1877 | 
             
            		}
         | 
| 1866 1878 | 
             
            	};
         | 
| 1867 | 
            -
             | 
| 1879 | 
            +
            	
         | 
| 1868 1880 | 
             
            	/**
         | 
| 1869 1881 | 
             
            	* Shows/hide the input placeholder depending
         | 
| 1870 1882 | 
             
            	* on if there items in the list already.
         | 
| @@ -1872,7 +1884,7 @@ | |
| 1872 1884 | 
             
            	Selectize.prototype.updatePlaceholder = function() {
         | 
| 1873 1885 | 
             
            		if (!this.settings.placeholder) return;
         | 
| 1874 1886 | 
             
            		var $input = this.$control_input;
         | 
| 1875 | 
            -
             | 
| 1887 | 
            +
            	
         | 
| 1876 1888 | 
             
            		if (this.items.length) {
         | 
| 1877 1889 | 
             
            			$input.removeAttr('placeholder');
         | 
| 1878 1890 | 
             
            		} else {
         | 
| @@ -1880,7 +1892,7 @@ | |
| 1880 1892 | 
             
            		}
         | 
| 1881 1893 | 
             
            		$input.triggerHandler('update');
         | 
| 1882 1894 | 
             
            	};
         | 
| 1883 | 
            -
             | 
| 1895 | 
            +
            	
         | 
| 1884 1896 | 
             
            	/**
         | 
| 1885 1897 | 
             
            	* Shows the autocomplete dropdown containing
         | 
| 1886 1898 | 
             
            	* the available options.
         | 
| @@ -1895,7 +1907,7 @@ | |
| 1895 1907 | 
             
            		this.$dropdown.css({visibility: 'visible'});
         | 
| 1896 1908 | 
             
            		this.trigger('dropdown_open', this.$dropdown);
         | 
| 1897 1909 | 
             
            	};
         | 
| 1898 | 
            -
             | 
| 1910 | 
            +
            	
         | 
| 1899 1911 | 
             
            	/**
         | 
| 1900 1912 | 
             
            	* Closes the autocomplete dropdown menu.
         | 
| 1901 1913 | 
             
            	*/
         | 
| @@ -1907,23 +1919,23 @@ | |
| 1907 1919 | 
             
            		this.isOpen = false;
         | 
| 1908 1920 | 
             
            		this.trigger('dropdown_close', this.$dropdown);
         | 
| 1909 1921 | 
             
            	};
         | 
| 1910 | 
            -
             | 
| 1922 | 
            +
            	
         | 
| 1911 1923 | 
             
            	/**
         | 
| 1912 1924 | 
             
            	* Calculates and applies the appropriate
         | 
| 1913 1925 | 
             
            	* position of the dropdown.
         | 
| 1914 1926 | 
             
            	*/
         | 
| 1915 1927 | 
             
            	Selectize.prototype.positionDropdown = function() {
         | 
| 1916 1928 | 
             
            		var $control = this.$control;
         | 
| 1917 | 
            -
            		var offset = $control.position();
         | 
| 1929 | 
            +
            		var offset = this.settings.dropdownParent === 'body' ? $control.offset() : $control.position();
         | 
| 1918 1930 | 
             
            		offset.top += $control.outerHeight(true);
         | 
| 1919 | 
            -
             | 
| 1931 | 
            +
            	
         | 
| 1920 1932 | 
             
            		this.$dropdown.css({
         | 
| 1921 1933 | 
             
            			width : $control.outerWidth(),
         | 
| 1922 1934 | 
             
            			top   : offset.top,
         | 
| 1923 1935 | 
             
            			left  : offset.left
         | 
| 1924 1936 | 
             
            		});
         | 
| 1925 1937 | 
             
            	};
         | 
| 1926 | 
            -
             | 
| 1938 | 
            +
            	
         | 
| 1927 1939 | 
             
            	/**
         | 
| 1928 1940 | 
             
            	* Resets / clears all selected items
         | 
| 1929 1941 | 
             
            	* from the control.
         | 
| @@ -1939,7 +1951,7 @@ | |
| 1939 1951 | 
             
            		this.showInput();
         | 
| 1940 1952 | 
             
            		this.trigger('clear');
         | 
| 1941 1953 | 
             
            	};
         | 
| 1942 | 
            -
             | 
| 1954 | 
            +
            	
         | 
| 1943 1955 | 
             
            	/**
         | 
| 1944 1956 | 
             
            	* A helper method for inserting an element
         | 
| 1945 1957 | 
             
            	* at the current caret position.
         | 
| @@ -1955,7 +1967,7 @@ | |
| 1955 1967 | 
             
            		}
         | 
| 1956 1968 | 
             
            		this.setCaret(caret + 1);
         | 
| 1957 1969 | 
             
            	};
         | 
| 1958 | 
            -
             | 
| 1970 | 
            +
            	
         | 
| 1959 1971 | 
             
            	/**
         | 
| 1960 1972 | 
             
            	* Removes the current selected item(s).
         | 
| 1961 1973 | 
             
            	*
         | 
| @@ -1964,18 +1976,18 @@ | |
| 1964 1976 | 
             
            	*/
         | 
| 1965 1977 | 
             
            	Selectize.prototype.deleteSelection = function(e) {
         | 
| 1966 1978 | 
             
            		var i, n, direction, selection, values, caret, $tail;
         | 
| 1967 | 
            -
             | 
| 1979 | 
            +
            	
         | 
| 1968 1980 | 
             
            		direction = (e && e.keyCode === KEY_BACKSPACE) ? -1 : 1;
         | 
| 1969 1981 | 
             
            		selection = getSelection(this.$control_input[0]);
         | 
| 1970 | 
            -
             | 
| 1982 | 
            +
            	
         | 
| 1971 1983 | 
             
            		// determine items that will be removed
         | 
| 1972 1984 | 
             
            		values = [];
         | 
| 1973 | 
            -
             | 
| 1985 | 
            +
            	
         | 
| 1974 1986 | 
             
            		if (this.$activeItems.length) {
         | 
| 1975 1987 | 
             
            			$tail = this.$control.children('.active:' + (direction > 0 ? 'last' : 'first'));
         | 
| 1976 1988 | 
             
            			caret = this.$control.children(':not(input)').index($tail);
         | 
| 1977 1989 | 
             
            			if (direction > 0) { caret++; }
         | 
| 1978 | 
            -
             | 
| 1990 | 
            +
            	
         | 
| 1979 1991 | 
             
            			for (i = 0, n = this.$activeItems.length; i < n; i++) {
         | 
| 1980 1992 | 
             
            				values.push($(this.$activeItems[i]).attr('data-value'));
         | 
| 1981 1993 | 
             
            			}
         | 
| @@ -1990,12 +2002,12 @@ | |
| 1990 2002 | 
             
            				values.push(this.items[this.caretPos]);
         | 
| 1991 2003 | 
             
            			}
         | 
| 1992 2004 | 
             
            		}
         | 
| 1993 | 
            -
             | 
| 2005 | 
            +
            	
         | 
| 1994 2006 | 
             
            		// allow the callback to abort
         | 
| 1995 2007 | 
             
            		if (!values.length || (typeof this.settings.onDelete === 'function' && this.settings.onDelete(values) === false)) {
         | 
| 1996 2008 | 
             
            			return false;
         | 
| 1997 2009 | 
             
            		}
         | 
| 1998 | 
            -
             | 
| 2010 | 
            +
            	
         | 
| 1999 2011 | 
             
            		// perform removal
         | 
| 2000 2012 | 
             
            		if (typeof caret !== 'undefined') {
         | 
| 2001 2013 | 
             
            			this.setCaret(caret);
         | 
| @@ -2003,12 +2015,12 @@ | |
| 2003 2015 | 
             
            		while (values.length) {
         | 
| 2004 2016 | 
             
            			this.removeItem(values.pop());
         | 
| 2005 2017 | 
             
            		}
         | 
| 2006 | 
            -
             | 
| 2018 | 
            +
            	
         | 
| 2007 2019 | 
             
            		this.showInput();
         | 
| 2008 2020 | 
             
            		this.refreshOptions(true);
         | 
| 2009 2021 | 
             
            		return true;
         | 
| 2010 2022 | 
             
            	};
         | 
| 2011 | 
            -
             | 
| 2023 | 
            +
            	
         | 
| 2012 2024 | 
             
            	/**
         | 
| 2013 2025 | 
             
            	* Selects the previous / next item (depending
         | 
| 2014 2026 | 
             
            	* on the `direction` argument).
         | 
| @@ -2021,18 +2033,18 @@ | |
| 2021 2033 | 
             
            	*/
         | 
| 2022 2034 | 
             
            	Selectize.prototype.advanceSelection = function(direction, e) {
         | 
| 2023 2035 | 
             
            		var tail, selection, idx, valueLength, cursorAtEdge, $tail;
         | 
| 2024 | 
            -
             | 
| 2036 | 
            +
            	
         | 
| 2025 2037 | 
             
            		if (direction === 0) return;
         | 
| 2026 | 
            -
             | 
| 2038 | 
            +
            	
         | 
| 2027 2039 | 
             
            		tail = direction > 0 ? 'last' : 'first';
         | 
| 2028 2040 | 
             
            		selection = getSelection(this.$control_input[0]);
         | 
| 2029 | 
            -
             | 
| 2041 | 
            +
            	
         | 
| 2030 2042 | 
             
            		if (this.isInputFocused && !this.isInputHidden) {
         | 
| 2031 2043 | 
             
            			valueLength = this.$control_input.val().length;
         | 
| 2032 2044 | 
             
            			cursorAtEdge = direction < 0
         | 
| 2033 2045 | 
             
            				? selection.start === 0 && selection.length === 0
         | 
| 2034 2046 | 
             
            				: selection.start === valueLength;
         | 
| 2035 | 
            -
             | 
| 2047 | 
            +
            	
         | 
| 2036 2048 | 
             
            			if (cursorAtEdge && !valueLength) {
         | 
| 2037 2049 | 
             
            				this.advanceCaret(direction, e);
         | 
| 2038 2050 | 
             
            			}
         | 
| @@ -2046,7 +2058,7 @@ | |
| 2046 2058 | 
             
            			}
         | 
| 2047 2059 | 
             
            		}
         | 
| 2048 2060 | 
             
            	};
         | 
| 2049 | 
            -
             | 
| 2061 | 
            +
            	
         | 
| 2050 2062 | 
             
            	/**
         | 
| 2051 2063 | 
             
            	* Moves the caret left / right.
         | 
| 2052 2064 | 
             
            	*
         | 
| @@ -2067,7 +2079,7 @@ | |
| 2067 2079 | 
             
            			this.setCaret(this.caretPos + direction);
         | 
| 2068 2080 | 
             
            		}
         | 
| 2069 2081 | 
             
            	};
         | 
| 2070 | 
            -
             | 
| 2082 | 
            +
            	
         | 
| 2071 2083 | 
             
            	/**
         | 
| 2072 2084 | 
             
            	* Moves the caret to the specified index.
         | 
| 2073 2085 | 
             
            	*
         | 
| @@ -2079,7 +2091,7 @@ | |
| 2079 2091 | 
             
            		} else {
         | 
| 2080 2092 | 
             
            			i = Math.max(0, Math.min(this.items.length, i));
         | 
| 2081 2093 | 
             
            		}
         | 
| 2082 | 
            -
             | 
| 2094 | 
            +
            	
         | 
| 2083 2095 | 
             
            		// the input must be moved by leaving it in place and moving the
         | 
| 2084 2096 | 
             
            		// siblings, due to the fact that focus cannot be restored once lost
         | 
| 2085 2097 | 
             
            		// on mobile webkit devices
         | 
| @@ -2093,10 +2105,10 @@ | |
| 2093 2105 | 
             
            				this.$control.append($child);
         | 
| 2094 2106 | 
             
            			}
         | 
| 2095 2107 | 
             
            		}
         | 
| 2096 | 
            -
             | 
| 2108 | 
            +
            	
         | 
| 2097 2109 | 
             
            		this.caretPos = i;
         | 
| 2098 2110 | 
             
            	};
         | 
| 2099 | 
            -
             | 
| 2111 | 
            +
            	
         | 
| 2100 2112 | 
             
            	/**
         | 
| 2101 2113 | 
             
            	* Disables user input on the control. Used while
         | 
| 2102 2114 | 
             
            	* items are being asynchronously created.
         | 
| @@ -2106,7 +2118,7 @@ | |
| 2106 2118 | 
             
            		this.isLocked = true;
         | 
| 2107 2119 | 
             
            		this.refreshClasses();
         | 
| 2108 2120 | 
             
            	};
         | 
| 2109 | 
            -
             | 
| 2121 | 
            +
            	
         | 
| 2110 2122 | 
             
            	/**
         | 
| 2111 2123 | 
             
            	* Re-enables user input on the control.
         | 
| 2112 2124 | 
             
            	*/
         | 
| @@ -2114,7 +2126,7 @@ | |
| 2114 2126 | 
             
            		this.isLocked = false;
         | 
| 2115 2127 | 
             
            		this.refreshClasses();
         | 
| 2116 2128 | 
             
            	};
         | 
| 2117 | 
            -
             | 
| 2129 | 
            +
            	
         | 
| 2118 2130 | 
             
            	/**
         | 
| 2119 2131 | 
             
            	* Disables user input on the control completely.
         | 
| 2120 2132 | 
             
            	* While disabled, it cannot receive focus.
         | 
| @@ -2123,7 +2135,7 @@ | |
| 2123 2135 | 
             
            		this.isDisabled = true;
         | 
| 2124 2136 | 
             
            		this.lock();
         | 
| 2125 2137 | 
             
            	};
         | 
| 2126 | 
            -
             | 
| 2138 | 
            +
            	
         | 
| 2127 2139 | 
             
            	/**
         | 
| 2128 2140 | 
             
            	* Enables the control so that it can respond
         | 
| 2129 2141 | 
             
            	* to focus and user input.
         | 
| @@ -2132,7 +2144,7 @@ | |
| 2132 2144 | 
             
            		this.isDisabled = false;
         | 
| 2133 2145 | 
             
            		this.unlock();
         | 
| 2134 2146 | 
             
            	};
         | 
| 2135 | 
            -
             | 
| 2147 | 
            +
            	
         | 
| 2136 2148 | 
             
            	/**
         | 
| 2137 2149 | 
             
            	* A helper method for rendering "item" and
         | 
| 2138 2150 | 
             
            	* "option" templates, given the data.
         | 
| @@ -2146,12 +2158,12 @@ | |
| 2146 2158 | 
             
            		var html = '';
         | 
| 2147 2159 | 
             
            		var cache = false;
         | 
| 2148 2160 | 
             
            		var regex_tag = /^[\	 ]*<([a-z][a-z0-9\-_]*(?:\:[a-z][a-z0-9\-_]*)?)/i;
         | 
| 2149 | 
            -
             | 
| 2161 | 
            +
            	
         | 
| 2150 2162 | 
             
            		if (templateName === 'option' || templateName === 'item') {
         | 
| 2151 2163 | 
             
            			value = data[this.settings.valueField];
         | 
| 2152 2164 | 
             
            			cache = isset(value);
         | 
| 2153 2165 | 
             
            		}
         | 
| 2154 | 
            -
             | 
| 2166 | 
            +
            	
         | 
| 2155 2167 | 
             
            		// pull markup from cache if it exists
         | 
| 2156 2168 | 
             
            		if (cache) {
         | 
| 2157 2169 | 
             
            			if (!isset(this.renderCache[templateName])) {
         | 
| @@ -2161,7 +2173,7 @@ | |
| 2161 2173 | 
             
            				return this.renderCache[templateName][value];
         | 
| 2162 2174 | 
             
            			}
         | 
| 2163 2175 | 
             
            		}
         | 
| 2164 | 
            -
             | 
| 2176 | 
            +
            	
         | 
| 2165 2177 | 
             
            		// render markup
         | 
| 2166 2178 | 
             
            		if (this.settings.render && typeof this.settings.render[templateName] === 'function') {
         | 
| 2167 2179 | 
             
            			html = this.settings.render[templateName].apply(this, [data, htmlEntities]);
         | 
| @@ -2186,7 +2198,7 @@ | |
| 2186 2198 | 
             
            					break;
         | 
| 2187 2199 | 
             
            			}
         | 
| 2188 2200 | 
             
            		}
         | 
| 2189 | 
            -
             | 
| 2201 | 
            +
            	
         | 
| 2190 2202 | 
             
            		// add mandatory attributes
         | 
| 2191 2203 | 
             
            		if (templateName === 'option' || templateName === 'option_create') {
         | 
| 2192 2204 | 
             
            			html = html.replace(regex_tag, '<$1 data-selectable');
         | 
| @@ -2198,15 +2210,15 @@ | |
| 2198 2210 | 
             
            		if (templateName === 'option' || templateName === 'item') {
         | 
| 2199 2211 | 
             
            			html = html.replace(regex_tag, '<$1 data-value="' + htmlEntities(value || '') + '"');
         | 
| 2200 2212 | 
             
            		}
         | 
| 2201 | 
            -
             | 
| 2213 | 
            +
            	
         | 
| 2202 2214 | 
             
            		// update cache
         | 
| 2203 2215 | 
             
            		if (cache) {
         | 
| 2204 2216 | 
             
            			this.renderCache[templateName][value] = html;
         | 
| 2205 2217 | 
             
            		}
         | 
| 2206 | 
            -
             | 
| 2218 | 
            +
            	
         | 
| 2207 2219 | 
             
            		return html;
         | 
| 2208 2220 | 
             
            	};
         | 
| 2209 | 
            -
             | 
| 2221 | 
            +
            	
         | 
| 2210 2222 | 
             
            	Selectize.defaults = {
         | 
| 2211 2223 | 
             
            		plugins: [],
         | 
| 2212 2224 | 
             
            		delimiter: ',',
         | 
| @@ -2219,10 +2231,10 @@ | |
| 2219 2231 | 
             
            		maxItems: null,
         | 
| 2220 2232 | 
             
            		hideSelected: null,
         | 
| 2221 2233 | 
             
            		preload: false,
         | 
| 2222 | 
            -
             | 
| 2234 | 
            +
            	
         | 
| 2223 2235 | 
             
            		scrollDuration: 60,
         | 
| 2224 2236 | 
             
            		loadThrottle: 300,
         | 
| 2225 | 
            -
             | 
| 2237 | 
            +
            	
         | 
| 2226 2238 | 
             
            		dataAttr: 'data-data',
         | 
| 2227 2239 | 
             
            		optgroupField: 'optgroup',
         | 
| 2228 2240 | 
             
            		sortField: null,
         | 
| @@ -2233,14 +2245,16 @@ | |
| 2233 2245 | 
             
            		optgroupValueField: 'value',
         | 
| 2234 2246 | 
             
            		optgroupOrder: null,
         | 
| 2235 2247 | 
             
            		searchField: ['text'],
         | 
| 2236 | 
            -
             | 
| 2248 | 
            +
            	
         | 
| 2237 2249 | 
             
            		mode: null,
         | 
| 2238 2250 | 
             
            		theme: 'default',
         | 
| 2239 2251 | 
             
            		wrapperClass: 'selectize-control',
         | 
| 2240 2252 | 
             
            		inputClass: 'selectize-input',
         | 
| 2241 2253 | 
             
            		dropdownClass: 'selectize-dropdown',
         | 
| 2242 2254 | 
             
            		dropdownContentClass: 'selectize-dropdown-content',
         | 
| 2243 | 
            -
             | 
| 2255 | 
            +
            	
         | 
| 2256 | 
            +
            		dropdownParent: null,
         | 
| 2257 | 
            +
            	
         | 
| 2244 2258 | 
             
            		load            : null, // function(query, callback)
         | 
| 2245 2259 | 
             
            		score           : null, // function(search)
         | 
| 2246 2260 | 
             
            		onChange        : null, // function(value)
         | 
| @@ -2254,7 +2268,7 @@ | |
| 2254 2268 | 
             
            		onDropdownClose : null, // function($dropdown) { ... }
         | 
| 2255 2269 | 
             
            		onType          : null, // function(str) { ... }
         | 
| 2256 2270 | 
             
            		onDelete        : null, // function(values) { ... }
         | 
| 2257 | 
            -
             | 
| 2271 | 
            +
            	
         | 
| 2258 2272 | 
             
            		render: {
         | 
| 2259 2273 | 
             
            			item: null,
         | 
| 2260 2274 | 
             
            			optgroup: null,
         | 
| @@ -2263,15 +2277,15 @@ | |
| 2263 2277 | 
             
            			option_create: null
         | 
| 2264 2278 | 
             
            		}
         | 
| 2265 2279 | 
             
            	};
         | 
| 2266 | 
            -
             | 
| 2280 | 
            +
            	
         | 
| 2267 2281 | 
             
            	/* --- file: "src/selectize.jquery.js" --- */
         | 
| 2268 | 
            -
             | 
| 2282 | 
            +
            	
         | 
| 2269 2283 | 
             
            	$.fn.selectize = function(settings) {
         | 
| 2270 2284 | 
             
            		settings = settings || {};
         | 
| 2271 | 
            -
             | 
| 2285 | 
            +
            	
         | 
| 2272 2286 | 
             
            		var defaults = $.fn.selectize.defaults;
         | 
| 2273 2287 | 
             
            		var dataAttr = settings.dataAttr || defaults.dataAttr;
         | 
| 2274 | 
            -
             | 
| 2288 | 
            +
            	
         | 
| 2275 2289 | 
             
            		/**
         | 
| 2276 2290 | 
             
            		 * Initializes selectize from a <input type="text"> element.
         | 
| 2277 2291 | 
             
            		 *
         | 
| @@ -2281,7 +2295,7 @@ | |
| 2281 2295 | 
             
            		var init_textbox = function($input, settings_element) {
         | 
| 2282 2296 | 
             
            			var i, n, values, value = $.trim($input.val() || '');
         | 
| 2283 2297 | 
             
            			if (!value.length) return;
         | 
| 2284 | 
            -
             | 
| 2298 | 
            +
            	
         | 
| 2285 2299 | 
             
            			values = value.split(settings.delimiter || defaults.delimiter);
         | 
| 2286 2300 | 
             
            			for (i = 0, n = values.length; i < n; i++) {
         | 
| 2287 2301 | 
             
            				settings_element.options[values[i]] = {
         | 
| @@ -2289,10 +2303,10 @@ | |
| 2289 2303 | 
             
            					'value' : values[i]
         | 
| 2290 2304 | 
             
            				};
         | 
| 2291 2305 | 
             
            			}
         | 
| 2292 | 
            -
             | 
| 2306 | 
            +
            	
         | 
| 2293 2307 | 
             
            			settings_element.items = values;
         | 
| 2294 2308 | 
             
            		};
         | 
| 2295 | 
            -
             | 
| 2309 | 
            +
            	
         | 
| 2296 2310 | 
             
            		/**
         | 
| 2297 2311 | 
             
            		 * Initializes selectize from a <select> element.
         | 
| 2298 2312 | 
             
            		 *
         | 
| @@ -2303,7 +2317,7 @@ | |
| 2303 2317 | 
             
            			var i, n, tagName;
         | 
| 2304 2318 | 
             
            			var $children;
         | 
| 2305 2319 | 
             
            			settings_element.maxItems = !!$input.attr('multiple') ? null : 1;
         | 
| 2306 | 
            -
             | 
| 2320 | 
            +
            	
         | 
| 2307 2321 | 
             
            			var readData = function($el) {
         | 
| 2308 2322 | 
             
            				var data = dataAttr && $el.attr(dataAttr);
         | 
| 2309 2323 | 
             
            				if (typeof data === 'string' && data.length) {
         | 
| @@ -2311,13 +2325,13 @@ | |
| 2311 2325 | 
             
            				}
         | 
| 2312 2326 | 
             
            				return null;
         | 
| 2313 2327 | 
             
            			};
         | 
| 2314 | 
            -
             | 
| 2328 | 
            +
            	
         | 
| 2315 2329 | 
             
            			var addOption = function($option, group) {
         | 
| 2316 2330 | 
             
            				$option = $($option);
         | 
| 2317 | 
            -
             | 
| 2331 | 
            +
            	
         | 
| 2318 2332 | 
             
            				var value = $option.attr('value') || '';
         | 
| 2319 2333 | 
             
            				if (!value.length) return;
         | 
| 2320 | 
            -
             | 
| 2334 | 
            +
            	
         | 
| 2321 2335 | 
             
            				settings_element.options[value] = readData($option) || {
         | 
| 2322 2336 | 
             
            					'text'     : $option.html(),
         | 
| 2323 2337 | 
             
            					'value'    : value,
         | 
| @@ -2327,23 +2341,23 @@ | |
| 2327 2341 | 
             
            					settings_element.items.push(value);
         | 
| 2328 2342 | 
             
            				}
         | 
| 2329 2343 | 
             
            			};
         | 
| 2330 | 
            -
             | 
| 2344 | 
            +
            	
         | 
| 2331 2345 | 
             
            			var addGroup = function($optgroup) {
         | 
| 2332 2346 | 
             
            				var i, n, $options = $('option', $optgroup);
         | 
| 2333 2347 | 
             
            				$optgroup = $($optgroup);
         | 
| 2334 | 
            -
             | 
| 2348 | 
            +
            	
         | 
| 2335 2349 | 
             
            				var id = $optgroup.attr('label');
         | 
| 2336 2350 | 
             
            				if (id && id.length) {
         | 
| 2337 2351 | 
             
            					settings_element.optgroups[id] = readData($optgroup) || {
         | 
| 2338 2352 | 
             
            						'label': id
         | 
| 2339 2353 | 
             
            					};
         | 
| 2340 2354 | 
             
            				}
         | 
| 2341 | 
            -
             | 
| 2355 | 
            +
            	
         | 
| 2342 2356 | 
             
            				for (i = 0, n = $options.length; i < n; i++) {
         | 
| 2343 2357 | 
             
            					addOption($options[i], id);
         | 
| 2344 2358 | 
             
            				}
         | 
| 2345 2359 | 
             
            			};
         | 
| 2346 | 
            -
             | 
| 2360 | 
            +
            	
         | 
| 2347 2361 | 
             
            			$children = $input.children();
         | 
| 2348 2362 | 
             
            			for (i = 0, n = $children.length; i < n; i++) {
         | 
| 2349 2363 | 
             
            				tagName = $children[i].tagName.toLowerCase();
         | 
| @@ -2354,7 +2368,7 @@ | |
| 2354 2368 | 
             
            				}
         | 
| 2355 2369 | 
             
            			}
         | 
| 2356 2370 | 
             
            		};
         | 
| 2357 | 
            -
             | 
| 2371 | 
            +
            	
         | 
| 2358 2372 | 
             
            		return this.each(function() {
         | 
| 2359 2373 | 
             
            			var instance;
         | 
| 2360 2374 | 
             
            			var $input = $(this);
         | 
| @@ -2365,23 +2379,23 @@ | |
| 2365 2379 | 
             
            				'optgroups'   : {},
         | 
| 2366 2380 | 
             
            				'items'       : []
         | 
| 2367 2381 | 
             
            			};
         | 
| 2368 | 
            -
             | 
| 2382 | 
            +
            	
         | 
| 2369 2383 | 
             
            			if (tag_name === 'select') {
         | 
| 2370 2384 | 
             
            				init_select($input, settings_element);
         | 
| 2371 2385 | 
             
            			} else {
         | 
| 2372 2386 | 
             
            				init_textbox($input, settings_element);
         | 
| 2373 2387 | 
             
            			}
         | 
| 2374 | 
            -
             | 
| 2388 | 
            +
            	
         | 
| 2375 2389 | 
             
            			instance = new Selectize($input, $.extend(true, {}, defaults, settings_element, settings));
         | 
| 2376 2390 | 
             
            			$input.data('selectize', instance);
         | 
| 2377 2391 | 
             
            			$input.addClass('selectized');
         | 
| 2378 2392 | 
             
            		});
         | 
| 2379 2393 | 
             
            	};
         | 
| 2380 | 
            -
             | 
| 2394 | 
            +
            	
         | 
| 2381 2395 | 
             
            	$.fn.selectize.defaults = Selectize.defaults;
         | 
| 2382 | 
            -
             | 
| 2396 | 
            +
            	
         | 
| 2383 2397 | 
             
            	/* --- file: "src/plugins/drag_drop/plugin.js" --- */
         | 
| 2384 | 
            -
             | 
| 2398 | 
            +
            	
         | 
| 2385 2399 | 
             
            	/**
         | 
| 2386 2400 | 
             
            	* Plugin: "drag_drop" (selectize.js)
         | 
| 2387 2401 | 
             
            	* Copyright (c) 2013 Brian Reavis & contributors
         | 
| @@ -2397,17 +2411,17 @@ | |
| 2397 2411 | 
             
            	*
         | 
| 2398 2412 | 
             
            	* @author Brian Reavis <brian@thirdroute.com>
         | 
| 2399 2413 | 
             
            	*/
         | 
| 2400 | 
            -
             | 
| 2414 | 
            +
            	
         | 
| 2401 2415 | 
             
            	Selectize.registerPlugin('drag_drop', function(options) {
         | 
| 2402 2416 | 
             
            		if (!$.fn.sortable) throw new Error('The "drag_drop" Selectize plugin requires jQuery UI "sortable".');
         | 
| 2403 2417 | 
             
            		if (this.settings.mode !== 'multi') return;
         | 
| 2404 2418 | 
             
            		var self = this;
         | 
| 2405 | 
            -
             | 
| 2419 | 
            +
            	
         | 
| 2406 2420 | 
             
            		this.setup = (function() {
         | 
| 2407 2421 | 
             
            			var original = self.setup;
         | 
| 2408 2422 | 
             
            			return function() {
         | 
| 2409 2423 | 
             
            				original.apply(this, arguments);
         | 
| 2410 | 
            -
             | 
| 2424 | 
            +
            	
         | 
| 2411 2425 | 
             
            				var $control = this.$control.sortable({
         | 
| 2412 2426 | 
             
            					items: '[data-value]',
         | 
| 2413 2427 | 
             
            					forcePlaceholderSize: true,
         | 
| @@ -2428,11 +2442,11 @@ | |
| 2428 2442 | 
             
            				});
         | 
| 2429 2443 | 
             
            			};
         | 
| 2430 2444 | 
             
            		})();
         | 
| 2431 | 
            -
             | 
| 2445 | 
            +
            	
         | 
| 2432 2446 | 
             
            	});
         | 
| 2433 | 
            -
             | 
| 2447 | 
            +
            	
         | 
| 2434 2448 | 
             
            	/* --- file: "src/plugins/optgroup_columns/plugin.js" --- */
         | 
| 2435 | 
            -
             | 
| 2449 | 
            +
            	
         | 
| 2436 2450 | 
             
            	/**
         | 
| 2437 2451 | 
             
            	* Plugin: "optgroup_columns" (selectize.js)
         | 
| 2438 2452 | 
             
            	* Copyright (c) 2013 Simon Hewitt & contributors
         | 
| @@ -2448,38 +2462,38 @@ | |
| 2448 2462 | 
             
            	*
         | 
| 2449 2463 | 
             
            	* @author Simon Hewitt <si@sjhewitt.co.uk>
         | 
| 2450 2464 | 
             
            	*/
         | 
| 2451 | 
            -
             | 
| 2465 | 
            +
            	
         | 
| 2452 2466 | 
             
            	Selectize.registerPlugin('optgroup_columns', function(options) {
         | 
| 2453 2467 | 
             
            		var self = this;
         | 
| 2454 | 
            -
             | 
| 2468 | 
            +
            	
         | 
| 2455 2469 | 
             
            		options = $.extend({
         | 
| 2456 2470 | 
             
            			equalizeWidth  : true,
         | 
| 2457 2471 | 
             
            			equalizeHeight : true
         | 
| 2458 2472 | 
             
            		}, options);
         | 
| 2459 | 
            -
             | 
| 2473 | 
            +
            	
         | 
| 2460 2474 | 
             
            		this.getAdjacentOption = function($option, direction) {
         | 
| 2461 2475 | 
             
            			var $options = $option.closest('[data-group]').find('[data-selectable]');
         | 
| 2462 2476 | 
             
            			var index    = $options.index($option) + direction;
         | 
| 2463 | 
            -
             | 
| 2477 | 
            +
            	
         | 
| 2464 2478 | 
             
            			return index >= 0 && index < $options.length ? $options.eq(index) : $();
         | 
| 2465 2479 | 
             
            		};
         | 
| 2466 | 
            -
             | 
| 2480 | 
            +
            	
         | 
| 2467 2481 | 
             
            		this.onKeyDown = (function() {
         | 
| 2468 2482 | 
             
            			var original = self.onKeyDown;
         | 
| 2469 2483 | 
             
            			return function(e) {
         | 
| 2470 2484 | 
             
            				var index, $option, $options, $optgroup;
         | 
| 2471 | 
            -
             | 
| 2485 | 
            +
            	
         | 
| 2472 2486 | 
             
            				if (this.isOpen && (e.keyCode === KEY_LEFT || e.keyCode === KEY_RIGHT)) {
         | 
| 2473 2487 | 
             
            					self.ignoreHover = true;
         | 
| 2474 2488 | 
             
            					$optgroup = this.$activeOption.closest('[data-group]');
         | 
| 2475 2489 | 
             
            					index = $optgroup.find('[data-selectable]').index(this.$activeOption);
         | 
| 2476 | 
            -
             | 
| 2490 | 
            +
            	
         | 
| 2477 2491 | 
             
            					if(e.keyCode === KEY_LEFT) {
         | 
| 2478 2492 | 
             
            						$optgroup = $optgroup.prev('[data-group]');
         | 
| 2479 2493 | 
             
            					} else {
         | 
| 2480 2494 | 
             
            						$optgroup = $optgroup.next('[data-group]');
         | 
| 2481 2495 | 
             
            					}
         | 
| 2482 | 
            -
             | 
| 2496 | 
            +
            	
         | 
| 2483 2497 | 
             
            					$options = $optgroup.find('[data-selectable]');
         | 
| 2484 2498 | 
             
            					$option  = $options.eq(Math.min($options.length - 1, index));
         | 
| 2485 2499 | 
             
            					if ($option.length) {
         | 
| @@ -2487,18 +2501,18 @@ | |
| 2487 2501 | 
             
            					}
         | 
| 2488 2502 | 
             
            					return;
         | 
| 2489 2503 | 
             
            				}
         | 
| 2490 | 
            -
             | 
| 2504 | 
            +
            	
         | 
| 2491 2505 | 
             
            				return original.apply(this, arguments);
         | 
| 2492 2506 | 
             
            			};
         | 
| 2493 2507 | 
             
            		})();
         | 
| 2494 | 
            -
             | 
| 2508 | 
            +
            	
         | 
| 2495 2509 | 
             
            		var equalizeSizes = function() {
         | 
| 2496 2510 | 
             
            			var i, n, height_max, width, width_last, width_parent, $optgroups;
         | 
| 2497 | 
            -
             | 
| 2511 | 
            +
            	
         | 
| 2498 2512 | 
             
            			$optgroups = $('[data-group]', self.$dropdown_content);
         | 
| 2499 2513 | 
             
            			n = $optgroups.length;
         | 
| 2500 2514 | 
             
            			if (!n || !self.$dropdown_content.width()) return;
         | 
| 2501 | 
            -
             | 
| 2515 | 
            +
            	
         | 
| 2502 2516 | 
             
            			if (options.equalizeHeight) {
         | 
| 2503 2517 | 
             
            				height_max = 0;
         | 
| 2504 2518 | 
             
            				for (i = 0; i < n; i++) {
         | 
| @@ -2506,7 +2520,7 @@ | |
| 2506 2520 | 
             
            				}
         | 
| 2507 2521 | 
             
            				$optgroups.css({height: height_max});
         | 
| 2508 2522 | 
             
            			}
         | 
| 2509 | 
            -
             | 
| 2523 | 
            +
            	
         | 
| 2510 2524 | 
             
            			if (options.equalizeWidth) {
         | 
| 2511 2525 | 
             
            				width_parent = self.$dropdown_content.innerWidth();
         | 
| 2512 2526 | 
             
            				width = Math.round(width_parent / n);
         | 
| @@ -2517,17 +2531,17 @@ | |
| 2517 2531 | 
             
            				}
         | 
| 2518 2532 | 
             
            			}
         | 
| 2519 2533 | 
             
            		};
         | 
| 2520 | 
            -
             | 
| 2534 | 
            +
            	
         | 
| 2521 2535 | 
             
            		if (options.equalizeHeight || options.equalizeWidth) {
         | 
| 2522 2536 | 
             
            			hook.after(this, 'positionDropdown', equalizeSizes);
         | 
| 2523 2537 | 
             
            			hook.after(this, 'refreshOptions', equalizeSizes);
         | 
| 2524 2538 | 
             
            		}
         | 
| 2525 | 
            -
             | 
| 2526 | 
            -
             | 
| 2539 | 
            +
            	
         | 
| 2540 | 
            +
            	
         | 
| 2527 2541 | 
             
            	});
         | 
| 2528 | 
            -
             | 
| 2542 | 
            +
            	
         | 
| 2529 2543 | 
             
            	/* --- file: "src/plugins/remove_button/plugin.js" --- */
         | 
| 2530 | 
            -
             | 
| 2544 | 
            +
            	
         | 
| 2531 2545 | 
             
            	/**
         | 
| 2532 2546 | 
             
            	* Plugin: "remove_button" (selectize.js)
         | 
| 2533 2547 | 
             
            	* Copyright (c) 2013 Brian Reavis & contributors
         | 
| @@ -2543,16 +2557,16 @@ | |
| 2543 2557 | 
             
            	*
         | 
| 2544 2558 | 
             
            	* @author Brian Reavis <brian@thirdroute.com>
         | 
| 2545 2559 | 
             
            	*/
         | 
| 2546 | 
            -
             | 
| 2560 | 
            +
            	
         | 
| 2547 2561 | 
             
            	Selectize.registerPlugin('remove_button', function(options) {
         | 
| 2548 2562 | 
             
            		var self = this;
         | 
| 2549 | 
            -
             | 
| 2563 | 
            +
            	
         | 
| 2550 2564 | 
             
            		// override the item rendering method to add a "x" to each
         | 
| 2551 2565 | 
             
            		this.settings.render.item = function(data) {
         | 
| 2552 2566 | 
             
            			var label = data[self.settings.labelField];
         | 
| 2553 2567 | 
             
            			return '<div class="item">' + label + ' <a href="javascript:void(0)" class="remove" tabindex="-1" title="Remove">×</a></div>';
         | 
| 2554 2568 | 
             
            		};
         | 
| 2555 | 
            -
             | 
| 2569 | 
            +
            	
         | 
| 2556 2570 | 
             
            		// override the setup method to add an extra "click" handler
         | 
| 2557 2571 | 
             
            		// that listens for mousedown events on the "x"
         | 
| 2558 2572 | 
             
            		this.setup = (function() {
         | 
| @@ -2569,11 +2583,11 @@ | |
| 2569 2583 | 
             
            				});
         | 
| 2570 2584 | 
             
            			};
         | 
| 2571 2585 | 
             
            		})();
         | 
| 2572 | 
            -
             | 
| 2586 | 
            +
            	
         | 
| 2573 2587 | 
             
            	});
         | 
| 2574 | 
            -
             | 
| 2588 | 
            +
            	
         | 
| 2575 2589 | 
             
            	/* --- file: "src/plugins/restore_on_backspace/plugin.js" --- */
         | 
| 2576 | 
            -
             | 
| 2590 | 
            +
            	
         | 
| 2577 2591 | 
             
            	/**
         | 
| 2578 2592 | 
             
            	* Plugin: "restore_on_backspace" (selectize.js)
         | 
| 2579 2593 | 
             
            	* Copyright (c) 2013 Brian Reavis & contributors
         | 
| @@ -2589,37 +2603,34 @@ | |
| 2589 2603 | 
             
            	*
         | 
| 2590 2604 | 
             
            	* @author Brian Reavis <brian@thirdroute.com>
         | 
| 2591 2605 | 
             
            	*/
         | 
| 2592 | 
            -
             | 
| 2593 | 
            -
            	(function() {
         | 
| 2594 | 
            -
            		 | 
| 2595 | 
            -
             | 
| 2596 | 
            -
             | 
| 2597 | 
            -
            			 | 
| 2598 | 
            -
             | 
| 2599 | 
            -
             | 
| 2600 | 
            -
             | 
| 2601 | 
            -
            			 | 
| 2602 | 
            -
             | 
| 2603 | 
            -
            				 | 
| 2604 | 
            -
             | 
| 2605 | 
            -
            					 | 
| 2606 | 
            -
             | 
| 2607 | 
            -
            						 | 
| 2608 | 
            -
             | 
| 2609 | 
            -
            							 | 
| 2610 | 
            -
             | 
| 2611 | 
            -
            								this.refreshOptions(true);
         | 
| 2612 | 
            -
            							}
         | 
| 2613 | 
            -
            							e.preventDefault();
         | 
| 2614 | 
            -
            							return;
         | 
| 2606 | 
            +
            	
         | 
| 2607 | 
            +
            	Selectize.registerPlugin('restore_on_backspace', function(options) {
         | 
| 2608 | 
            +
            		var self = this;
         | 
| 2609 | 
            +
            	
         | 
| 2610 | 
            +
            		options.text = options.text || function(option) {
         | 
| 2611 | 
            +
            			return option[this.settings.labelField];
         | 
| 2612 | 
            +
            		};
         | 
| 2613 | 
            +
            	
         | 
| 2614 | 
            +
            		this.onKeyDown = (function(e) {
         | 
| 2615 | 
            +
            			var original = self.onKeyDown;
         | 
| 2616 | 
            +
            			return function(e) {
         | 
| 2617 | 
            +
            				var index, option;
         | 
| 2618 | 
            +
            				if (e.keyCode === KEY_BACKSPACE && this.$control_input.val() === '' && !this.$activeItems.length) {
         | 
| 2619 | 
            +
            					index = this.caretPos - 1;
         | 
| 2620 | 
            +
            					if (index >= 0 && index < this.items.length) {
         | 
| 2621 | 
            +
            						option = this.options[this.items[index]];
         | 
| 2622 | 
            +
            						if (this.deleteSelection(e)) {
         | 
| 2623 | 
            +
            							this.setTextboxValue(options.text.apply(this, [option]));
         | 
| 2624 | 
            +
            							this.refreshOptions(true);
         | 
| 2615 2625 | 
             
            						}
         | 
| 2626 | 
            +
            						e.preventDefault();
         | 
| 2627 | 
            +
            						return;
         | 
| 2616 2628 | 
             
            					}
         | 
| 2617 | 
            -
             | 
| 2618 | 
            -
            				 | 
| 2619 | 
            -
            			} | 
| 2620 | 
            -
             | 
| 2621 | 
            -
             | 
| 2622 | 
            -
            	})();
         | 
| 2629 | 
            +
            				}
         | 
| 2630 | 
            +
            				return original.apply(this, arguments);
         | 
| 2631 | 
            +
            			};
         | 
| 2632 | 
            +
            		})();
         | 
| 2633 | 
            +
            	});
         | 
| 2623 2634 |  | 
| 2624 2635 | 
             
            	return Selectize;
         | 
| 2625 2636 |  |