media/js/vendor/selectize/selectize.js
function($item, e) {
			var self = this;
			var eventName;
			var i, idx, begin, end, item, swap;
			var $last;
	
			if (self.settings.mode === 'single') return;
			$item = $($item);
	
			// clear the active selection
			if (!$item.length) {
				$(self.$activeItems).removeClass('active');
				self.$activeItems = [];
				if (self.isFocused) {
					self.showInput();
				}
				return;
			}
	
			// modify selection
			eventName = e && e.type.toLowerCase();
	
			if (eventName === 'mousedown' && self.isShiftDown && self.$activeItems.length) {
				$last = self.$control.children('.active:last');
				begin = Array.prototype.indexOf.apply(self.$control[0].childNodes, [$last[0]]);
				end   = Array.prototype.indexOf.apply(self.$control[0].childNodes, [$item[0]]);
				if (begin > end) {
					swap  = begin;
					begin = end;
					end   = swap;
				}
				for (i = begin; i <= end; i++) {
					item = self.$control[0].childNodes[i];
					if (self.$activeItems.indexOf(item) === -1) {
						$(item).addClass('active');
						self.$activeItems.push(item);
					}
				}
				e.preventDefault();
			} else if ((eventName === 'mousedown' && self.isCtrlDown) || (eventName === 'keydown' && this.isShiftDown)) {
				if ($item.hasClass('active')) {
					idx = self.$activeItems.indexOf($item[0]);
					self.$activeItems.splice(idx, 1);
					$item.removeClass('active');
				} else {
					self.$activeItems.push($item.addClass('active')[0]);
				}
			} else {
				$(self.$activeItems).removeClass('active');
				self.$activeItems = [$item.addClass('active')[0]];
			}
	
			// ensure control has focus
			self.hideInput();
			if (!this.isFocused) {
				self.focus();
			}
		}
function($item, e) {
			var self = this;
			var eventName;
			var i, idx, begin, end, item, swap;
			var $last;
	
			if (self.settings.mode === 'single') return;
			$item = $($item);
	
			// clear the active selection
			if (!$item.length) {
				$(self.$activeItems).removeClass('active');
				self.$activeItems = [];
				if (self.isFocused) {
					self.showInput();
				}
				return;
			}
	
			// modify selection
			eventName = e && e.type.toLowerCase();
	
			if (eventName === 'mousedown' && self.isShiftDown && self.$activeItems.length) {
				$last = self.$control.children('.active:last');
				begin = Array.prototype.indexOf.apply(self.$control[0].childNodes, [$last[0]]);
				end   = Array.prototype.indexOf.apply(self.$control[0].childNodes, [$item[0]]);
				if (begin > end) {
					swap  = begin;
					begin = end;
					end   = swap;
				}
				for (i = begin; i <= end; i++) {
					item = self.$control[0].childNodes[i];
					if (self.$activeItems.indexOf(item) === -1) {
						$(item).addClass('active');
						self.$activeItems.push(item);
					}
				}
				e.preventDefault();
			} else if ((eventName === 'mousedown' && self.isCtrlDown) || (eventName === 'keydown' && this.isShiftDown)) {
				if ($item.hasClass('active')) {
					idx = self.$activeItems.indexOf($item[0]);
					self.$activeItems.splice(idx, 1);
					$item.removeClass('active');
				} else {
					self.$activeItems.push($item.addClass('active')[0]);
				}
			} else {
				$(self.$activeItems).removeClass('active');
				self.$activeItems = [$item.addClass('active')[0]];
			}
	
			// ensure control has focus
			self.hideInput();
			if (!this.isFocused) {
				self.focus();
			}
		}
function ( $item , e ) { var self = this ; var eventName ; var i , idx , begin , end , item , swap ; var $last ; if ( self . settings . mode === 'single' ) return ; $item = $ ( $item ) ; // clear the active selection if ( ! $item . length ) { $ ( self . $activeItems ) . removeClass ( 'active' ) ; self . $activeItems = [ ] ; if ( self . isFocused ) { self . showInput ( ) ; } return ; } // modify selection eventName = e && e . type . toLowerCase ( ) ; if ( eventName === 'mousedown' && self . isShiftDown && self . $activeItems . length ) { $last = self . $control . children ( '.active:last' ) ; begin = Array . prototype . indexOf . apply ( self . $control [ 0 ] . childNodes , [ $last [ 0 ] ] ) ; end = Array . prototype . indexOf . apply ( self . $control [ 0 ] . childNodes , [ $item [ 0 ] ] ) ; if ( begin > end ) { swap = begin ; begin = end ; end = swap ; } for ( i = begin ; i <= end ; i ++ ) { item = self . $control [ 0 ] . childNodes [ i ] ; if ( self . $activeItems . indexOf ( item ) === - 1 ) { $ ( item ) . addClass ( 'active' ) ; self . $activeItems . push ( item ) ; } } e . preventDefault ( ) ; } else if ( ( eventName === 'mousedown' && self . isCtrlDown ) || ( eventName === 'keydown' && this . isShiftDown ) ) { if ( $item . hasClass ( 'active' ) ) { idx = self . $activeItems . indexOf ( $item [ 0 ] ) ; self . $activeItems . splice ( idx , 1 ) ; $item . removeClass ( 'active' ) ; } else { self . $activeItems . push ( $item . addClass ( 'active' ) [ 0 ] ) ; } } else { $ ( self . $activeItems ) . removeClass ( 'active' ) ; self . $activeItems = [ $item . addClass ( 'active' ) [ 0 ] ] ; } // ensure control has focus self . hideInput ( ) ; if ( ! this . isFocused ) { self . focus ( ) ; } }
Sets the selected item.

@param {object} $item
@param {object} e (optional)
Sets the selected item .