1
0
mirror of synced 2024-11-24 05:46:09 +03:00
select2/dist/js/select2.min.js
Kevin Brown 559a93bcb6 Added basic implementation of tags
Tags no longer takes an array, as pre-existing tags should already
exist as options in the data adapter.  A compatibility module will
later be added to convert tag data that is passed in to array data.

Tags allow for users to enter their own options, which will be
added to the beginning of the results list.
2014-10-21 21:44:01 -04:00

1 line
22 KiB
JavaScript

var requirejs,require,define;!function(a){function b(a,b){return r.call(a,b)}function c(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=b&&b.split("/"),o=p.map,q=o&&o["*"]||{};if(a&&"."===a.charAt(0))if(b){for(n=n.slice(0,n.length-1),a=a.split("/"),g=a.length-1,p.nodeIdCompat&&t.test(a[g])&&(a[g]=a[g].replace(t,"")),a=n.concat(a),k=0;k<a.length;k+=1)if(m=a[k],"."===m)a.splice(k,1),k-=1;else if(".."===m){if(1===k&&(".."===a[2]||".."===a[0]))break;k>0&&(a.splice(k-1,2),k-=2)}a=a.join("/")}else 0===a.indexOf("./")&&(a=a.substring(2));if((n||q)&&o){for(c=a.split("/"),k=c.length;k>0;k-=1){if(d=c.slice(0,k).join("/"),n)for(l=n.length;l>0;l-=1)if(e=o[n.slice(0,l).join("/")],e&&(e=e[d])){f=e,h=k;break}if(f)break;!i&&q&&q[d]&&(i=q[d],j=k)}!f&&i&&(f=i,h=j),f&&(c.splice(0,h,f),a=c.join("/"))}return a}function d(b,c){return function(){return k.apply(a,s.call(arguments,0).concat([b,c]))}}function e(a){return function(b){return c(b,a)}}function f(a){return function(b){n[a]=b}}function g(c){if(b(o,c)){var d=o[c];delete o[c],q[c]=!0,j.apply(a,d)}if(!b(n,c)&&!b(q,c))throw new Error("No "+c);return n[c]}function h(a){var b,c=a?a.indexOf("!"):-1;return c>-1&&(b=a.substring(0,c),a=a.substring(c+1,a.length)),[b,a]}function i(a){return function(){return p&&p.config&&p.config[a]||{}}}var j,k,l,m,n={},o={},p={},q={},r=Object.prototype.hasOwnProperty,s=[].slice,t=/\.js$/;l=function(a,b){var d,f=h(a),i=f[0];return a=f[1],i&&(i=c(i,b),d=g(i)),i?a=d&&d.normalize?d.normalize(a,e(b)):c(a,b):(a=c(a,b),f=h(a),i=f[0],a=f[1],i&&(d=g(i))),{f:i?i+"!"+a:a,n:a,pr:i,p:d}},m={require:function(a){return d(a)},exports:function(a){var b=n[a];return"undefined"!=typeof b?b:n[a]={}},module:function(a){return{id:a,uri:"",exports:n[a],config:i(a)}}},j=function(c,e,h,i){var j,k,p,r,s,t,u=[],v=typeof h;if(i=i||c,"undefined"===v||"function"===v){for(e=!e.length&&h.length?["require","exports","module"]:e,s=0;s<e.length;s+=1)if(r=l(e[s],i),k=r.f,"require"===k)u[s]=m.require(c);else if("exports"===k)u[s]=m.exports(c),t=!0;else if("module"===k)j=u[s]=m.module(c);else if(b(n,k)||b(o,k)||b(q,k))u[s]=g(k);else{if(!r.p)throw new Error(c+" missing "+k);r.p.load(r.n,d(i,!0),f(k),{}),u[s]=n[k]}p=h?h.apply(n[c],u):void 0,c&&(j&&j.exports!==a&&j.exports!==n[c]?n[c]=j.exports:p===a&&t||(n[c]=p))}else c&&(n[c]=h)},requirejs=require=k=function(b,c,d,e,f){if("string"==typeof b)return m[b]?m[b](c):g(l(b,c).f);if(!b.splice){if(p=b,p.deps&&k(p.deps,p.callback),!c)return;c.splice?(b=c,c=d,d=null):b=a}return c=c||function(){},"function"==typeof d&&(d=e,e=f),e?j(a,b,c,d):setTimeout(function(){j(a,b,c,d)},4),k},k.config=function(a){return k(a)},requirejs._defined=n,define=function(a,c,d){c.splice||(d=c,c=[]),b(n,a)||b(o,a)||(o[a]=[a,c,d])},define.amd={jQuery:!0}}(),define("almond",function(){}),define("jquery",[],function(){return jQuery}),define("select2/utils",[],function(){function a(a){var b=a.prototype,c=[];for(var d in b){var e=b[d];"function"==typeof e&&c.push(d)}return c}var b={};b.Extend=function(a,b){function c(){this.constructor=a}var d={}.hasOwnProperty;for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},b.Decorate=function(b,c){function d(){var a=Array.prototype.unshift,d=c.prototype.constructor.length,e=b.prototype.constructor;d>0&&(a.call(arguments,b.prototype.constructor),e=c.prototype.constructor),e.apply(this,arguments)}function e(){this.constructor=d}var f=a(c),g=a(b);c.displayName=b.displayName,d.prototype=new e;for(var h=0;h<g.length;h++){var i=g[h];d.prototype[i]=b.prototype[i]}for(var j=(function(a){var b=function(){};a in d.prototype&&(b=d.prototype[a]);var e=c.prototype[a];return function(){var a=Array.prototype.unshift;return a.call(arguments,b),e.apply(this,arguments)}}),k=0;k<f.length;k++){var l=f[k];d.prototype[l]=j(l)}return d};var c=function(){this.listeners={}};return c.prototype.on=function(a,b){a in this.listeners?this.listeners[a].push(b):this.listeners[a]=[b]},c.prototype.trigger=function(a){var b=Array.prototype.slice;a in this.listeners&&this.invoke(this.listeners[a],b.call(arguments,1)),"*"in this.listeners&&this.invoke(this.listeners["*"],arguments)},c.prototype.invoke=function(a,b){for(var c=0,d=a.length;d>c;c++)a[c].apply(this,b)},b.Observable=c,b.generateChars=function(a){for(var b="",c=0;a>c;c++){var d=Math.floor(36*Math.random());b+=d.toString(36)}return b},b}),define("select2/results",["./utils"],function(a){function b(a,c,d){this.$element=a,this.data=d,this.options=c,b.__super__.constructor.call(this)}return a.Extend(b,a.Observable),b.prototype.render=function(){var a=$('<ul class="options" role="tree"></ul>');return this.options.get("multiple")&&a.attr("aria-multiselectable","true"),this.$results=a,a},b.prototype.clear=function(){this.$results.empty()},b.prototype.append=function(a){var b=[];a=this.sort(a);for(var c=0;c<a.length;c++){var d=a[c],e=this.option(d);b.push(e)}this.$results.append(b)},b.prototype.sort=function(a){return a},b.prototype.setClasses=function(){var a=this;this.data.current(function(b){var c=$.map(b,function(a){return a.id.toString()}),d=a.$results.find(".option[aria-selected]");d.each(function(){var a=$(this),b=a.data("data");null!=b.id&&c.indexOf(b.id.toString())>-1?a.attr("aria-selected","true"):a.attr("aria-selected","false")});var e=d.filter("[aria-selected=true]");e.length>0?e.first().trigger("mouseenter"):d.first().trigger("mouseenter")})},b.prototype.option=function(a){var b=$('<li class="option" role="treeitem" aria-selected="false"></li>');if(a.children){b.attr("role","group").attr("aria-label",a.text).removeAttr("aria-selected");var c=$('<strong class="group-label"></strong>');c.html(a.text);for(var d=[],e=0;e<a.children.length;e++){var f=a.children[e],g=this.option(f);d.push(g)}var h=$('<ul class="options nested-options"></ul>');h.append(d),b.append(c),b.append(h)}else b.html(a.text);return a.disabled&&b.removeAttr("aria-selected").attr("aria-disabled","true"),null==a.id&&b.removeAttr("aria-selected"),null!=a._resultId&&b.attr("id",a._resultId),b.data("data",a),b},b.prototype.bind=function(a){var b=this,c=a.id+"-results";this.$results.attr("id",c),a.on("results:all",function(c){b.clear(),b.append(c.data),a.isOpen()&&b.setClasses()}),a.on("results:append",function(c){b.append(c.data),a.isOpen()&&b.setClasses()}),a.on("select",function(){a.isOpen()&&b.setClasses()}),a.on("unselect",function(){a.isOpen()&&b.setClasses()}),a.on("open",function(){b.$results.attr("aria-expanded","true"),b.$results.attr("aria-hidden","false"),b.setClasses()}),a.on("close",function(){b.$results.attr("aria-expanded","false"),b.$results.attr("aria-hidden","true"),b.$results.removeAttr("aria-activedescendant")}),a.on("results:select",function(){var a=b.$results.find(".highlighted");if(0!==a.length){var c=a.data("data");"true"==a.attr("aria-selected")?b.trigger("unselected",{data:c}):b.trigger("selected",{data:c})}}),a.on("results:previous",function(){var a=b.$results.find(".highlighted"),c=b.$results.find("[aria-selected]"),d=c.index(a);if(0!==d){var e=d-1;0===a.length&&(e=0);var f=c.eq(e);f.trigger("mouseenter");var g=b.$results.offset().top,h=f.offset().top,i=b.$results.scrollTop()+(h-g);0===e?b.$results.scrollTop(0):0>h-g&&b.$results.scrollTop(i)}}),a.on("results:next",function(){var a=b.$results.find(".highlighted"),c=b.$results.find("[aria-selected]"),d=c.index(a),e=d+1;if(!(e>=c.length)){var f=c.eq(e);f.trigger("mouseenter");var g=b.$results.offset().top+b.$results.outerHeight(!1),h=f.offset().top+f.outerHeight(!1),i=b.$results.scrollTop()+h-g;0===e?b.$results.scrollTop(0):h>g&&b.$results.scrollTop(i)}}),a.on("results:focus",function(a){a.element.addClass("highlighted")}),this.$results.on("mouseup",".option[aria-selected]",function(a){var c=$(this),d=c.data("data");return"true"===c.attr("aria-selected")?void b.trigger("unselected",{originalEvent:a,data:d}):void b.trigger("selected",{originalEvent:a,data:d})}),this.$results.on("mouseenter",".option[aria-selected]",function(){var a=$(this).data("data");b.$results.find(".option.highlighted").removeClass("highlighted"),b.trigger("results:focus",{data:a,element:$(this)})}),this.$results.on("mouseleave",".option",function(){$(this).hasClass("highlighted")&&($(this).removeClass("highlighted"),b.$results.removeAttr("aria-activedescendant"))})},b}),define("select2/selection/base",["../utils"],function(a){function b(a,c){this.$element=a,this.options=c,b.__super__.constructor.call(this)}return a.Extend(b,a.Observable),b.prototype.render=function(){throw new Error("The `render` method must be defined in child classes.")},b.prototype.bind=function(a){var b=this;a.on("selection:update",function(a){b.update(a.data)})},b.prototype.update=function(){throw new Error("The `update` method must be defined in child classes.")},b}),define("select2/keys",[],function(){var a={BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46,isArrow:function(a){switch(a=a.which?a.which:a){case KEY.LEFT:case KEY.RIGHT:case KEY.UP:case KEY.DOWN:return!0}return!1}};return a}),define("select2/selection/single",["./base","../utils","../keys"],function(a,b,c){function d(){d.__super__.constructor.apply(this,arguments)}return b.Extend(d,a),d.prototype.render=function(){var a=$('<span class="single-select" tabindex="0" role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-expanded="false"><span class="rendered-selection"></span></span>');return a.attr("title",this.$element.attr("title")),this.$selection=a,a},d.prototype.bind=function(a){var b=this;d.__super__.bind.apply(this,arguments);var e=a.id+"-container",f=a.id+"-results";this.$selection.find(".rendered-selection").attr("id",e),this.$selection.attr("aria-labelledby",e),this.$selection.attr("aria-owns",f),this.$selection.on("mousedown",function(a){1===a.which&&b.trigger("toggle",{originalEvent:a})}),a.on("open",function(){b.$selection.attr("aria-expanded","true")}),a.on("close",function(){b.$selection.attr("aria-expanded","false"),b.$selection.removeAttr("aria-activedescendant")}),this.$selection.on("focus",function(){}),this.$selection.on("blur",function(){}),this.$selection.on("keydown",function(d){var e=d.which;a.isOpen()?e==c.ENTER?(b.trigger("results:select"),d.preventDefault()):e==c.UP?(b.trigger("results:previous"),d.preventDefault()):e==c.DOWN&&(b.trigger("results:next"),d.preventDefault()):(e==c.ENTER||e==c.SPACE)&&(b.trigger("open"),d.preventDefault())}),a.on("results:focus",function(a){b.$selection.attr("aria-activedescendant",a.data._resultId)}),a.on("selection:update",function(a){b.update(a.data)})},d.prototype.clear=function(){this.$selection.find(".rendered-selection").empty()},d.prototype.display=function(a){return a.text},d.prototype.selectionContainer=function(){return $("<span></span>")},d.prototype.update=function(a){if(0===a.length)return void this.clear();var b=a[0],c=this.display(b);this.$selection.find(".rendered-selection").html(c)},d}),define("select2/selection/multiple",["./base","../utils"],function(a,b){function c(a,b){this.$element=a,this.options=b,c.__super__.constructor.call(this)}return b.Extend(c,a),c.prototype.render=function(){var a=$('<span class="multiple-select"><ul class="rendered-selection"></ul></span>');return this.$selection=a,a},c.prototype.bind=function(){var a=this;c.__super__.bind.apply(this,arguments),this.$selection.on("click",function(b){a.trigger("toggle",{originalEvent:b})}),this.$selection.on("click",".remove",function(b){var c=$(this),d=c.parent(),e=d.data("data");a.trigger("unselected",{originalEvent:b,data:e})})},c.prototype.clear=function(){this.$selection.find(".rendered-selection").empty()},c.prototype.display=function(a){return a.text},c.prototype.selectionContainer=function(){var a=$('<li class="choice"><span class="remove" role="presentation">&times;</span></li>');return a},c.prototype.update=function(a){if(this.clear(),0!==a.length){for(var b=[],c=0;c<a.length;c++){var d=a[c],e=this.display(d),f=this.selectionContainer();f.append(e),f.data("data",d),b.push(f)}this.$selection.find(".rendered-selection").append(b)}},c}),define("select2/selection/placeholder",["../utils"],function(){function a(a,b,c){this.placeholder=this.normalizePlaceholder(c.get("placeholder")),a.call(this,b,c)}return a.prototype.normalizePlaceholder=function(a,b){return"string"==typeof b&&(b={id:"",text:b}),b},a.prototype.update=function(a,b){var c=1==b.length&&b[0].id!=this.placeholder.id,d=b.length>1;if(d||c)return a.call(this,b);this.clear();var e=this.selectionContainer();e.html(this.display(this.placeholder)),e.addClass("placeholder").removeClass("choice"),this.$selection.find(".rendered-selection").append(e)},a}),define("select2/data/base",["../utils"],function(a){function b(){b.__super__.constructor.call(this)}return a.Extend(b,a.Observable),b.prototype.current=function(){throw new Error("The `current` method must be defined in child classes.")},b.prototype.query=function(){throw new Error("The `query` method must be defined in child classes.")},b.prototype.bind=function(){},b.prototype.generateResultId=function(b,c){var d=b.id+"-result-";return d+=a.generateChars(4),d+=null!=c.id?"-"+c.id.toString():"-"+a.generateChars(4)},b}),define("select2/data/select",["./base","../utils","jquery"],function(a,b,c){function d(a){this.$element=a,d.__super__.constructor.call(this)}return b.Extend(d,a),d.prototype.current=function(a){var b=[],d=this;this.$element.find(":selected").each(function(){var a=c(this),e=d.item(a);b.push(e)}),a(b)},d.prototype.select=function(a){var b=this;if(a._tag===!0){delete a._tag;var c=this.option(a);this.$element.append(c)}if(this.$element.prop("multiple"))this.current(function(c){var d=[];a=[a],a.push.apply(a,c);for(var e=0;e<a.length;e++)id=a[e].id,-1===d.indexOf(id)&&d.push(id);b.$element.val(d),b.$element.trigger("change")});else{var d=a.id;this.$element.val(d),this.$element.trigger("change")}},d.prototype.unselect=function(a){var b=this;this.$element.prop("multiple")&&this.current(function(c){for(var d=[],e=0;e<c.length;e++)id=c[e].id,id!==a.id&&-1===d.indexOf(id)&&d.push(id);b.$element.val(d),b.$element.trigger("change")})},d.prototype.bind=function(a){var b=this;this.container=a,a.on("select",function(a){b.select(a.data)}),a.on("unselect",function(a){b.unselect(a.data)})},d.prototype.query=function(a,b){var d=[],e=this,f=this.$element.children();f.each(function(){var b=c(this);if(b.is("option")||b.is("optgroup")){var f=e.item(b),g=e.matches(a,f);null!==g&&d.push(g)}}),b(d)},d.prototype.option=function(a){var b=c("<option></option>");b.text(a.text),b.val(a.id),b.prop("disabled",a.disabled||!1);var d=this.item(b),e=c.extend({},a,d);return b.data("data",e),b},d.prototype.item=function(a){var b=a.data("data");if(null==b){if(a.is("option"))b={id:a.val(),text:a.html(),disabled:a.prop("disabled")};else if(a.is("optgroup")){b={text:a.attr("label"),children:[]};for(var d=a.children("option"),e=[],f=0;f<d.length;f++){var g=c(d[f]),h=this.item(g);e.push(h)}b.children=e}b.id&&null!=this.container&&(b._resultId=this.generateResultId(this.container,b)),a.data("data",b)}return b},d.prototype.matches=function(a,b){var d=c.extend(!0,{},b);if(b.children){for(var e=b.children.length-1;e>=0;e--){var f=b.children[e],g=this.matches(a,f);null===g&&d.children.splice(e,1)}if(d.children.length>0)return d}return""===c.trim(a.term)?d:b.text.toUpperCase().indexOf(a.term.toUpperCase())>-1?d:null},d}),define("select2/data/array",["./select","../utils","jquery"],function(a,b,c){function d(a,b){this.data=b.get("data"),d.__super__.constructor.call(this,a,b)}return b.Extend(d,a),d.prototype.select=function(a){var b=this;this.$element.find("option").each(function(){var d=c(this),e=b.item(d);e.id==a.id.toString()&&d.remove()});var e=this.option(a);this.$element.append(e),d.__super__.select.call(this,a)},d.prototype.query=function(a,b){var d=[],e=this;c.each(this.data,function(){var b=this;e.matches(a,b)&&d.push(b)}),b(d)},d}),define("select2/data/ajax",["./array","../utils","jquery"],function(a,b,c){function d(b,c){this.ajaxOptions=c.get("ajax"),this.processResults=this.ajaxOptions.processResults||function(a){return a},a.__super__.constructor.call(this,b,c)}return b.Extend(d,a),d.prototype.query=function(a,b){var d=this,e=c.extend({type:"GET"},this.ajaxOptions);"function"==typeof e.url&&(e.url=e.url(a)),"function"==typeof e.data&&(e.data=e.data(a));var f=c.ajax(e);f.success(function(a){var c=d.processResults(a);b(c)})},d}),define("select2/data/tags",[],function(){function a(a,b,c){c.get("tags");a.call(this,b,c)}return a.prototype.query=function(a,b,c){function d(a,f){for(var g=0;g<a.length;g++){var h=a[g],i=null!=h.children&&!d(h.children,!0),j=h.text===b.term;if(j||i)return f?!1:void c(a)}if(f)return!0;var k=e.createTag(b);k._tag=!0,a.unshift(k),c(a)}var e=this;return null==b.term||""===b.term||null!=b.page?void a.call(this,b,c):void a.call(this,b,d)},a.prototype.createTag=function(a,b){return{id:b.term,text:b.term}},a}),define("select2/dropdown",["./utils"],function(a){function b(a){this.$element=a}return a.Extend(b,a.Observable),b.prototype.render=function(){var a=$('<span class="dropdown"><span class="results"></span></span>');return a},b.prototype.bind=function(){},b}),define("select2/dropdown/search",[],function(){function a(){}return a.prototype.render=function(a){var b=a.call(this),c=$('<span class="search"><input type="search" name="search" tabindex="-1" role="textbox" /></span>');return this.$searchContainer=c,this.$search=c.find("input"),b.prepend(c),b},a.prototype.bind=function(a,b,c){var d=this;a.call(this,b,c),this.$search.on("keyup",function(){b.trigger("query",{term:$(this).val()})}),b.on("open",function(){d.$search.attr("tabindex",0)}),b.on("close",function(){d.$search.attr("tabindex",-1)}),b.on("results:all",function(a){if(null==a.query.term||""===a.query.term){var b=d.showSearch(a);b?d.$searchContainer.show():d.$searchContainer.hide()}})},a.prototype.showSearch=function(){return!0},a}),define("select2/defaults",["./results","./selection/single","./selection/multiple","./selection/placeholder","./utils","./data/select","./data/array","./data/ajax","./data/tags","./dropdown","./dropdown/search"],function(a,b,c,d,e,f,g,h,i,j,k){function l(){this.reset()}l.prototype.apply=function(l){if(l=$.extend({},l,this.defaults),null==l.dataAdapter&&(l.dataAdapter=l.ajax?h:l.data?g:f),null!=l.tags&&(l.dataAdapter=e.Decorate(l.dataAdapter,i)),null==l.resultsAdapter&&(l.resultsAdapter=a),null==l.dropdownAdapter){var m=e.Decorate(j,k);l.dropdownAdapter=m}return null==l.selectionAdapter&&(l.selectionAdapter=l.multiple?c:b,null!=l.placeholder&&(l.selectionAdapter=e.Decorate(l.selectionAdapter,d))),l},l.prototype.reset=function(){this.defaults={}};var m=new l;return m}),define("select2/options",["./defaults"],function(a){function b(b){this.options=a.apply(b)}return b.prototype.fromElement=function(){return this},b.prototype.get=function(a){return this.options[a]},b.prototype.set=function(a,b){this.options[a]=b},b}),define("select2/core",["jquery","./options","./utils"],function(a,b,c){var d=function(a,e){this.$element=a,this.id=null!=a.attr("id")?a.attr("id"):null!=a.attr("name")?a.attr("name")+"-"+c.generateChars(2):c.generateChars(4),this.id="select2-"+this.id,e=e||{},e.multiple=e.multiple||a.prop("multiple"),this.options=new b(e),d.__super__.constructor.call(this);var f=this.options.get("dataAdapter");this.data=new f(a,this.options);var g=this.render();this.$container=g,g.insertAfter(this.$element),g.width(a.outerWidth(!1));var h=this.options.get("selectionAdapter");this.selection=new h(a,this.options);var i=g.find(".selection"),j=this.selection.render();i.append(j);var k=this.options.get("dropdownAdapter");this.dropdown=new k(a,this.options);var l=g.find(".dropdown-wrapper"),m=this.dropdown.render();l.append(m);var n=this.options.get("resultsAdapter");this.results=new n(a,this.options,this.data);var o=m.find(".results"),p=this.results.render();o.append(p);var q=this;this.data.bind(this,g),this.selection.bind(this,g),this.dropdown.bind(this,g),this.results.bind(this,g),this.$element.on("change",function(){q.data.current(function(a){q.trigger("selection:update",{data:a})})}),this.selection.on("open",function(){q.trigger("open")}),this.selection.on("close",function(){q.trigger("close")}),this.selection.on("toggle",function(){q.toggleDropdown()}),this.selection.on("results:select",function(){q.trigger("results:select")}),this.selection.on("results:previous",function(){q.trigger("results:previous")}),this.selection.on("results:next",function(){q.trigger("results:next")}),this.selection.on("unselected",function(a){q.trigger("unselect",a),q.trigger("close")}),this.results.on("selected",function(a){q.trigger("select",a),q.trigger("close")}),this.results.on("unselected",function(a){q.trigger("unselect",a),q.trigger("close")}),this.results.on("results:focus",function(a){q.trigger("results:focus",a)}),this.on("open",function(){g.addClass("open")}),this.on("close",function(){g.removeClass("open")}),this.data.current(function(a){q.trigger("selection:update",{data:a})}),this.on("query",function(a){this.data.query(a,function(b){q.trigger("results:all",{data:b,query:a})})}),this.trigger("query",{}),a.hide(),a.attr("tabindex","-1")};return c.Extend(d,c.Observable),d.prototype.toggleDropdown=function(){this.trigger(this.isOpen()?"close":"open")},d.prototype.isOpen=function(){return this.$container.hasClass("open")},d.prototype.render=function(){var b=a('<span class="select2 select2-container select2-theme-default"><span class="selection"></span><span class="dropdown-wrapper" aria-hidden="true"></span></span>');return b},d}),define("jquery.select2",["jquery","select2/core"],function(a,b){return null==a.fn.select2&&(a.fn.select2=function(c){if(c=c||{},"object"==typeof c)this.each(function(){new b(a(this),c)});else{if("string"!=typeof c)throw new Error("Invalid arguments for Select2: "+c);var d=this.data("select2");d[c](arguments.slice(1))}}),b}),require("jquery.select2");