849a9c7a32
Some people like the old theme, so we're going to also include that one as well as the easier-to-extend flat theme.
1 line
30 KiB
JavaScript
1 line
30 KiB
JavaScript
window.$=window.$||{},function(){$&&$.fn&&$.fn.select2&&$.fn.select2.amd&&(c=$.fn.select2.amd.define,b=$.fn.select2.amd.require);var a,b,c;!function(d){function e(a,b){return u.call(a,b)}function f(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=b&&b.split("/"),o=s.map,p=o&&o["*"]||{};if(a&&"."===a.charAt(0))if(b){for(n=n.slice(0,n.length-1),a=a.split("/"),g=a.length-1,s.nodeIdCompat&&w.test(a[g])&&(a[g]=a[g].replace(w,"")),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||p)&&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&&p&&p[d]&&(i=p[d],j=k)}!f&&i&&(f=i,h=j),f&&(c.splice(0,h,f),a=c.join("/"))}return a}function g(a,b){return function(){return n.apply(d,v.call(arguments,0).concat([a,b]))}}function h(a){return function(b){return f(b,a)}}function i(a){return function(b){q[a]=b}}function j(a){if(e(r,a)){var b=r[a];delete r[a],t[a]=!0,m.apply(d,b)}if(!e(q,a)&&!e(t,a))throw new Error("No "+a);return q[a]}function k(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 l(a){return function(){return s&&s.config&&s.config[a]||{}}}var m,n,o,p,q={},r={},s={},t={},u=Object.prototype.hasOwnProperty,v=[].slice,w=/\.js$/;o=function(a,b){var c,d=k(a),e=d[0];return a=d[1],e&&(e=f(e,b),c=j(e)),e?a=c&&c.normalize?c.normalize(a,h(b)):f(a,b):(a=f(a,b),d=k(a),e=d[0],a=d[1],e&&(c=j(e))),{f:e?e+"!"+a:a,n:a,pr:e,p:c}},p={require:function(a){return g(a)},exports:function(a){var b=q[a];return"undefined"!=typeof b?b:q[a]={}},module:function(a){return{id:a,uri:"",exports:q[a],config:l(a)}}},m=function(a,b,c,f){var h,k,l,m,n,s,u=[],v=typeof c;if(f=f||a,"undefined"===v||"function"===v){for(b=!b.length&&c.length?["require","exports","module"]:b,n=0;n<b.length;n+=1)if(m=o(b[n],f),k=m.f,"require"===k)u[n]=p.require(a);else if("exports"===k)u[n]=p.exports(a),s=!0;else if("module"===k)h=u[n]=p.module(a);else if(e(q,k)||e(r,k)||e(t,k))u[n]=j(k);else{if(!m.p)throw new Error(a+" missing "+k);m.p.load(m.n,g(f,!0),i(k),{}),u[n]=q[k]}l=c?c.apply(q[a],u):void 0,a&&(h&&h.exports!==d&&h.exports!==q[a]?q[a]=h.exports:l===d&&s||(q[a]=l))}else a&&(q[a]=c)},a=b=n=function(a,b,c,e,f){if("string"==typeof a)return p[a]?p[a](b):j(o(a,b).f);if(!a.splice){if(s=a,s.deps&&n(s.deps,s.callback),!b)return;b.splice?(a=b,b=c,c=null):a=d}return b=b||function(){},"function"==typeof c&&(c=e,e=f),e?m(d,a,b,c):setTimeout(function(){m(d,a,b,c)},4),n},n.config=function(a){return n(a)},a._defined=q,c=function(a,b,c){b.splice||(c=b,b=[]),e(q,a)||e(r,a)||(r[a]=[a,b,c])},c.amd={jQuery:!0}}(),c("almond",function(){}),c("jquery",[],function(){return jQuery}),c("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){this.listeners=this.listeners||{},a in this.listeners?this.listeners[a].push(b):this.listeners[a]=[b]},c.prototype.trigger=function(a){var b=Array.prototype.slice;this.listeners=this.listeners||{},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}),c("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.displayMessage=function(a){this.clear();var b=$('<li role="treeitem" class="option"></li>'),c=this.options.get("translations").get(a.message);b.text(c(a.args)),this.$results.append(b)},b.prototype.append=function(a){var b=[];if(0===a.length)return void(0===this.$results.children().length&&this.trigger("results:message",{message:"noResults"}));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=$.data(this,"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=document.createElement("li");b.className="option";var c={role:"treeitem","aria-selected":"false"};a.disabled&&(delete c["aria-selected"],c["aria-disabled"]="true"),null==a.id&&delete c["aria-selected"],null!=a._resultId&&(b.id=a._resultId),a.children&&(c.role="group",c["aria-label"]=a.text,delete c["aria-selected"]);for(var d in c){var e=c[d];b.setAttribute(d,e)}if(a.children){var f=$(b),g=document.createElement("strong");g.className="group-label";{$(g)}this.template(a,g);for(var h=[],i=0;i<a.children.length;i++){var j=a.children[i],k=this.option(j);h.push(k)}var l=$('<ul class="options nested-options"></ul>');l.append(h),f.append(g),f.append(l)}else this.template(a,b);return $.data(b,"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(),b.ensureHighlightVisible()}),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")}),a.on("results:message",function(a){b.trigger("results:message",a)}),this.on("results:message",function(a){b.displayMessage(a)}),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.prototype.destroy=function(){this.$results.remove()},b.prototype.ensureHighlightVisible=function(){var a=this.$results.find(".highlighted");if(0!==a.length){var b=this.$results.find("[aria-selected]"),c=b.index(a),d=this.$results.offset().top,e=a.offset().top,f=this.$results.scrollTop()+(e-d),g=e-d;f-=2*a.outerHeight(!1),2>=c?this.$results.scrollTop(0):(g>this.$results.outerHeight()||0>g)&&this.$results.scrollTop(f)}},b.prototype.template=function(a,b){var c=this.options.get("templateResult");b.innerHTML=c(a)},b}),c("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)}),a.on("open",function(){$(document.body).on("mousedown.select2."+a.id,function(a){var b=$(a.target),c=b.closest(".select2"),d=$(".select2.open");d.each(function(){var a=$(this);if(this!=c[0]){var b=a.data("element");b.select2("close")}})}),a.on("close",function(){$(document.body).off("mousedown.select2."+a.id)})})},b.prototype.destroy=function(){$(document.body).off(".select2."+container.id)},b.prototype.update=function(){throw new Error("The `update` method must be defined in child classes.")},b}),c("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}),c("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"),b.$selection.focus()}),this.$selection.on("focus",function(){}),this.$selection.on("blur",function(){}),this.$selection.on("keydown",function(a){b.trigger("keypress",a),a.which===c.SPACE&&a.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){var b=this.options.get("templateSelection");return b(a)},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}),c("select2/selection/multiple",["./base","../utils"],function(a,b){function c(){c.__super__.constructor.apply(this,arguments)}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){var b=this.options.get("templateSelection");return b(a)},c.prototype.selectionContainer=function(){var a=$('<li class="choice"><span class="remove" role="presentation">×</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}),c("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}),c("select2/translation",[],function(){function a(a){this.dict=a||{}}return a.prototype.all=function(){return this.dict},a.prototype.get=function(a){return this.dict[a]},a.prototype.extend=function(a){this.dict=$.extend({},a.all(),this.dict)},a._cache={},a.loadPath=function(c){if(!(c in a._cache)){var d=b(c);a._cache[c]=d}return new a(a._cache[c])},a}),c("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.destroy=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}),c("select2/data/select",["./base","../utils","jquery"],function(a,b,c){function d(a,b){this.$element=a,this.options=b,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(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 c=a.id;this.$element.val(c),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.destroy=function(){this.$element.find("*").each(function(){c.removeData(this,"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=document.createElement("option");b.value=a.id,a.disabled&&(b.disabled=!0),a.selected&&(b.selected=!0),b.innerText=a.text;var d=c(b),e=this._normalizeItem(a);return c.data(b,"data",e),d},d.prototype.item=function(a){var b={};if(b=c.data(a[0],"data"),null!=b)return b;if(a.is("option"))b={id:a.val(),text:a.html(),disabled:a.prop("disabled"),selected:a.prop("selected")};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}return b=this._normalizeItem(b),c.data(a[0],"data",b),b},d.prototype._normalizeItem=function(a){null==a.text&&(a={id:a,text:a});var b={selected:!1,disabled:!1};return null!=a.id&&(a.id=a.id.toString()),null!=a.text&&(a.text=a.text.toString()),null==a._resultId&&a.id&&null!=this.container&&(a._resultId=this.generateResultId(this.container,a)),c.extend({},b,a)},d.prototype.matches=function(a,b){var c=this.options.get("matcher");return c(a,b)},d}),c("select2/data/array",["./select","../utils","jquery"],function(a,b,c){function d(a,b){var c=b.get("data");d.__super__.constructor.call(this,a,b),this.convertToOptions(c)}return b.Extend(d,a),d.prototype.select=function(a){var b=this.$element.find('option[value="'+a.id+'"]');0===b.length&&(b=this.option(a),this.$element.append(b)),d.__super__.select.call(this,a)},d.prototype.convertToOptions=function(a){function b(a){return function(){return c(this).val()==a.id}}for(var d=this,e=this.$element.find("option"),f=e.map(function(){return d.item(c(this)).id}).get(),g=0;g<a.length;g++){var h=a[g];if(h.id=h.id.toString(),f.indexOf(h.id)>=0){var i=e.filter(b(h)),j=this.item(i),k=(c.extend(!0,{},j,h),this.option(j));i.replaceWith(k)}else{var l=this.option(h);this.$element.append(l)}}},d}),c("select2/data/ajax",["./array","../utils","jquery"],function(a,b,c){function d(b,c){this.ajaxOptions=c.get("ajax"),null!=this.ajaxOptions.processResults&&(this.processResults=this.ajaxOptions.processResults),a.__super__.constructor.call(this,b,c)}return b.Extend(d,a),d.prototype.processResults=function(a){return a},d.prototype.query=function(a,b){function d(){var a=c.ajax(f);a.success(function(a){var c=e.processResults(a);b(c)})}var e=this,f=c.extend({type:"GET"},this.ajaxOptions);"function"==typeof f.url&&(f.url=f.url(a)),"function"==typeof f.data&&(f.data=f.data(a)),this.ajaxOptions.delay&&""!==a.term?(this._queryTimeout&&window.clearTimeout(this._queryTimeout),this._queryTimeout=window.setTimeout(d,this.ajaxOptions.delay)):d()},d}),c("select2/data/tags",[],function(){function a(a,b,c){var d=c.get("tags");if(a.call(this,b,c),$.isArray(d))for(var e=0;e<d.length;e++){var f=d[e],g=this._normalizeItem(f),h=this.option(g);this.$element.append(h)}}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),l=e.option(k);l.attr("data-select2-tag",!0),e.$element.append(l),e.insertTag(a,k),c(a)}var e=this;return this._removeOldTags(),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.prototype.insertTag=function(a,b,c){b.unshift(c)},a.prototype._removeOldTags=function(){var a=(this._lastTag,this.$element.find("option[data-select2-tag]"));a.each(function(){this.selected||$(this).remove()})},a}),c("select2/data/minimumInputLength",[],function(){function a(a,b,c){this.minimumInputLength=c.get("minimumInputLength"),a.call(this,b,c)}return a.prototype.query=function(a,b,c){return b.term=b.term||"",b.term.length<this.minimumInputLength?void this.trigger("results:message",{message:"inputTooShort",args:{minimum:this.minimumInputLength,input:b.term,params:b}}):void a.call(this,b,c)},a}),c("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 this.$dropdown=a,a},b.prototype.destroy=function(){this.$dropdown.remove()},b.prototype.bind=function(){},b}),c("select2/dropdown/search",["../utils"],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("keydown",function(a){d.trigger("keypress",a),d._keyUpPrevented=a.isDefaultPrevented()}),this.$search.on("keyup",function(a){d.handleSearch(a)}),b.on("open",function(){d.$search.attr("tabindex",0),d.$search.focus()}),b.on("close",function(){d.$search.attr("tabindex",-1),d.$search.val("")}),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.handleSearch=function(){if(!this._keyUpPrevented){var a=this.$search.val();this.trigger("query",{term:a})}this._keyUpPrevented=!1},a.prototype.showSearch=function(){return!0},a}),c("select2/dropdown/hidePlaceholder",[],function(){function a(a,b,c,d){this.placeholder=this.normalizePlaceholder(c.get("placeholder")),a.call(this,b,c,d)}return a.prototype.append=function(a,b){b=this.removePlaceholder(b),a.call(this,b)},a.prototype.normalizePlaceholder=function(a,b){return"string"==typeof b&&(b={id:"",text:b}),b},a.prototype.removePlaceholder=function(a,b){for(var c=b.slice(0),d=b.length-1;d>=0;d--){var e=b[d];this.placeholder.id===e.id&&c.splice(d,1)}return c},a}),c("select2/dropdown/infiniteScroll",["jquery"],function(a){function b(a,b,c,d){this.lastParams={},a.call(this,b,c,d),this.$loadingMore=this.createLoadingMore(),this.loading=!1}return b.prototype.append=function(a,b){this.$loadingMore.remove(),a.call(this,b),b.length>0&&this.$results.append(this.$loadingMore),this.loading=!1},b.prototype.bind=function(b,c,d){var e=this;b.call(this,c,d),c.on("query",function(a){e.lastParams=a,e.loading=!0}),c.on("query:append",function(a){e.lastParams=a,e.loading=!0}),this.$results.on("scroll",function(){var b=a.contains(document.documentElement,e.$loadingMore[0]);if(!e.loading&&b){var c=e.$results.offset().top+e.$results.outerHeight(!1),d=e.$loadingMore.offset().top+e.$loadingMore.outerHeight(!1);c+50>=d&&e.loadMore()}})},b.prototype.loadMore=function(){this.loading=!0;var b=a.extend({},{page:1},this.lastParams);b.page++,this.trigger("query:append",b)},b.prototype.createLoadingMore=function(){var b=a('<li class="option load-more" role="treeitem"></li>'),c=this.options.get("translations").get("loadingMore");return b.html(c(this.lastParams)),b},b}),c("select2/i18n/en",[],function(){return{inputTooShort:function(a){var b=a.minimum-a.input.length,c="Please enter "+b+" or more character";return 1!=b&&(c+="s"),c},loadingMore:function(){return"Loading more results…"},noResults:function(){return"No results found"}}}),c("select2/defaults",["jquery","./results","./selection/single","./selection/multiple","./selection/placeholder","./utils","./translation","./data/select","./data/array","./data/ajax","./data/tags","./data/minimumInputLength","./dropdown","./dropdown/search","./dropdown/hidePlaceholder","./dropdown/infiniteScroll","./i18n/en"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p){function q(){this.reset()}q.prototype.apply=function(q){if(q=a.extend({},this.defaults,q),null==q.dataAdapter&&(q.dataAdapter=null!=q.ajax?j:null!=q.data?i:h),q.minimumInputLength>0&&(q.dataAdapter=f.Decorate(q.dataAdapter,l)),null!=q.tags&&(q.dataAdapter=f.Decorate(q.dataAdapter,k)),null==q.resultsAdapter&&(q.resultsAdapter=b,null!=q.ajax&&(q.resultsAdapter=f.Decorate(q.resultsAdapter,p)),null!=q.placeholder&&(q.resultsAdapter=f.Decorate(q.resultsAdapter,o))),null==q.dropdownAdapter){var r=f.Decorate(m,n);q.dropdownAdapter=r}if(null==q.selectionAdapter&&(q.selectionAdapter=q.multiple?d:c,null!=q.placeholder&&(q.selectionAdapter=f.Decorate(q.selectionAdapter,e))),"string"==typeof q.language&&(q.language=[q.language]),a.isArray(q.language)){for(var s=new g,t=q.language.concat(this.defaults.language),u=0;u<t.length;u++){var v=t[u],w={};try{w=g.loadPath(v)}catch(x){v="select2/i18n/"+v,w=g.loadPath(v)}s.extend(w)}q.translations=s}else q.translations=new Translations(q.language);return q},q.prototype.reset=function(){function b(c,d){if(""===a.trim(c.term))return d;if(d.children&&d.children.length>0){for(var e=a.extend(!0,{},d),f=d.children.length-1;f>=0;f--){var g=d.children[f],h=b(c,g);null==h&&e.children.splice(f,1)}return e.children.length>0?e:b(c,e)}return d.text.toUpperCase().indexOf(c.term.toUpperCase())>-1?d:null}this.defaults={language:["select2/i18n/en"],matcher:b,minimumInputLength:0,theme:"default",templateResult:function(a){return a.text},templateSelection:function(a){return a.text}}};var r=new q;return r}),c("select2/options",["./defaults"],function(a){function b(b,c){this.options=b,null!=c&&this.fromElement(c),this.options=a.apply(this.options)}return b.prototype.fromElement=function(a){return null==this.options.multiple&&(this.options.multiple=a.prop("multiple")),this},b.prototype.get=function(a){return this.options[a]},b.prototype.set=function(a,b){this.options[a]=b},b}),c("select2/core",["jquery","./options","./utils","./keys"],function(a,b,c,d){var e=function(a,c){if(null==a.data("select2")){this.$element=a,this.id=this._generateId(a),c=c||{},this.options=new b(c,a),e.__super__.constructor.call(this);var d=this.options.get("dataAdapter");this.data=new d(a,this.options);var f=this.render();this._placeContainer(f);var g=this.options.get("selectionAdapter");this.selection=new g(a,this.options);var h=this.selection.render();this._placeSelection(h);var i=this.options.get("dropdownAdapter");this.dropdown=new i(a,this.options);var j=this.dropdown.render();this._placeDropdown(j);var k=this.options.get("resultsAdapter");this.results=new k(a,this.options,this.data);var l=this.results.render();this._placeResults(l);var m=this;this._bindAdapters(),this._registerDomEvents(),this._registerDataEvents(),this._registerSelectionEvents(),this._registerDropdownEvents(),this._registerResultsEvents(),this._registerEvents(),this.data.current(function(a){m.trigger("selection:update",{data:a})}),a.hide(),this._tabindex=a.attr("tabindex")||0,a.attr("tabindex","-1"),a.data("select2",this)}};return c.Extend(e,c.Observable),e.prototype._generateId=function(a){var b="";return b=null!=a.attr("id")?a.attr("id"):null!=a.attr("name")?a.attr("name")+"-"+c.generateChars(2):c.generateChars(4),b="select2-"+b},e.prototype._placeContainer=function(a){a.insertAfter(this.$element),a.width(this.$element.outerWidth(!1))},e.prototype._placeSelection=function(a){var b=this.$container.find(".selection");b.append(a)},e.prototype._placeDropdown=function(a){this.$dropdown=a;var b=this.$container.find(".dropdown-wrapper");b.append(a)},e.prototype._placeResults=function(a){var b=this.$dropdown.find(".results");b.append(a)},e.prototype._bindAdapters=function(){this.data.bind(this,this.$container),this.selection.bind(this,this.$container),this.dropdown.bind(this,this.$container),this.results.bind(this,this.$container)},e.prototype._registerDomEvents=function(){var a=this;this.$element.on("change.select2",function(){a.data.current(function(b){a.trigger("selection:update",{data:b})})})},e.prototype._registerDataEvents=function(){var a=this;this.data.on("results:message",function(b){a.trigger("results:message",b)})},e.prototype._registerSelectionEvents=function(){var a=this;this.selection.on("open",function(){a.open()}),this.selection.on("close",function(){a.close()}),this.selection.on("toggle",function(){a.toggleDropdown()}),this.selection.on("results:select",function(){a.trigger("results:select")}),this.selection.on("results:previous",function(){a.trigger("results:previous")}),this.selection.on("results:next",function(){a.trigger("results:next")}),this.selection.on("unselected",function(b){a.trigger("unselect",b),a.close()}),this.selection.on("keypress",function(b){a.trigger("keypress",b)})},e.prototype._registerDropdownEvents=function(){var a=this;this.dropdown.on("query",function(b){a.trigger("query",b)}),this.dropdown.on("keypress",function(b){a.trigger("keypress",b)})},e.prototype._registerResultsEvents=function(){var a=this;this.results.on("query:append",function(b){a.trigger("query:append",b)}),this.results.on("selected",function(b){a.trigger("select",b),a.close()}),this.results.on("unselected",function(b){a.trigger("unselect",b),a.close()}),this.results.on("results:focus",function(b){a.trigger("results:focus",b)})},e.prototype._registerEvents=function(){var a=this;this.on("open",function(){a.$container.addClass("open")}),this.on("close",function(){a.$container.removeClass("open")}),this.on("query",function(b){this.data.query(b,function(c){a.trigger("results:all",{data:c,query:b})})}),this.on("query:append",function(b){this.data.query(b,function(c){a.trigger("results:append",{data:c,query:b})})}),this.on("keypress",function(b){var c=b.which;a.isOpen()?c===d.ENTER?(a.trigger("results:select"),b.preventDefault()):c===d.UP?(a.trigger("results:previous"),b.preventDefault()):c===d.DOWN?(a.trigger("results:next"),b.preventDefault()):(c===d.ESC||c===d.TAB)&&(a.close(),b.preventDefault()):(c===d.ENTER||c===d.SPACE)&&(a.open(),b.preventDefault())})},e.prototype.toggleDropdown=function(){this.isOpen()?this.close():this.open()},e.prototype.open=function(){this.isOpen()||(this.trigger("query",{}),this.trigger("open"))},e.prototype.close=function(){this.isOpen()&&this.trigger("close")},e.prototype.isOpen=function(){return this.$container.hasClass("open")},e.prototype.destroy=function(){this.$container.remove(),this.$element.off(".select2"),this.$element.attr("tabindex",this._tabindex),this.$element.show(),this.$element.removeData("select2"),this.data.destroy(),this.selection.destroy(),this.dropdown.destroy(),this.results.destroy(),this.data=null,this.selection=null,this.dropdown=null,this.results=null},e.prototype.render=function(){var b=a('<span class="select2 select2-container"><span class="selection"></span><span class="dropdown-wrapper" aria-hidden="true"></span></span>');return this.$container=b,this.$container.addClass("select2-theme-"+this.options.get("theme")),b.data("element",this.$element),b},e}),c("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"),e=Array.prototype.slice.call(arguments,1);d[c](e)}}),b}),b("jquery.select2"),$.fn.select2.amd={define:c,require:b}}(); |