web/assets/libs/jquery-plugin/select2/3.4.1/select2.js
(开头部分) 48KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
define("jquery-plugin/select2/3.4.1/select2",["$","./i18n/{locale}"],function(e){var t=e("$");!function(e){"undefined"==typeof e.fn.each2&&e.fn.extend({each2:function(t){for(var s=e([0]),i=-1,n=this.length;++i<n&&(s.context=s[0]=this[i])&&t.call(s[0],i,s)!==!1;);return this}})}(t),function(e,t){"use strict";function s(e,t){for(var s=0,i=t.length;i>s;s+=1)if(n(e,t[s]))return s;return-1}function i(){var t=e(L);t.appendTo("body");var s={width:t.width()-t[0].clientWidth,height:t.height()-t[0].clientHeight};return t.remove(),s}function n(e,s){return e===s?!0:e===t||s===t?!1:null===e||null===s?!1:e.constructor===String?e+""==s+"":s.constructor===String?s+""==e+"":!1}function o(t,s){var i,n,o;if(null===t||t.length<1)return[];for(i=t.split(s),n=0,o=i.length;o>n;n+=1)i[n]=e.trim(i[n]);return i}function a(e){return e.outerWidth(!1)-e.width()}function l(s){var i="keyup-change-value";s.on("keydown",function(){e.data(s,i)===t&&e.data(s,i,s.val())}),s.on("keyup",function(){var n=e.data(s,i);n!==t&&s.val()!==n&&(e.removeData(s,i),s.trigger("keyup-change"))})}function c(s){s.on("mousemove",function(s){var i=N;(i===t||i.x!==s.pageX||i.y!==s.pageY)&&e(s.target).trigger("mousemove-filtered",s)})}function r(e,s,i){i=i||t;var n;return function(){var t=arguments;window.clearTimeout(n),n=window.setTimeout(function(){s.apply(i,t)},e)}}function h(e){var t,s=!1;return function(){return s===!1&&(t=e(),s=!0),t}}function d(e,t){var i=r(e,function(e){t.trigger("scroll-debounced",e)});t.on("scroll",function(e){s(e.target,t.get())>=0&&i(e)})}function u(e){e[0]!==document.activeElement&&window.setTimeout(function(){var t,s=e[0],i=e.val().length;e.focus(),e.is(":visible")&&s===document.activeElement&&(s.setSelectionRange?s.setSelectionRange(i,i):s.createTextRange&&(t=s.createTextRange(),t.collapse(!1),t.select()))},0)}function p(t){t=e(t)[0];var s=0,i=0;if("selectionStart"in t)s=t.selectionStart,i=t.selectionEnd-s;else if("selection"in document){t.focus();var n=document.selection.createRange();i=document.selection.createRange().text.length,n.moveStart("character",-t.value.length),s=n.text.length-i}return{offset:s,length:i}}function f(e){e.preventDefault(),e.stopPropagation()}function g(e){e.preventDefault(),e.stopImmediatePropagation()}function m(t){if(!M){var s=t[0].currentStyle||window.getComputedStyle(t[0],null);M=e(document.createElement("div")).css({position:"absolute",left:"-10000px",top:"-10000px",display:"none",fontSize:s.fontSize,fontFamily:s.fontFamily,fontStyle:s.fontStyle,fontWeight:s.fontWeight,letterSpacing:s.letterSpacing,textTransform:s.textTransform,whiteSpace:"nowrap"}),M.attr("class","select2-sizer"),e("body").append(M)}return M.text(t.val()),M.width()}function v(t,s,i){var n,o,a=[];n=t.attr("class"),n&&(n=""+n,e(n.split(" ")).each2(function(){0===this.indexOf("select2-")&&a.push(this)})),n=s.attr("class"),n&&(n=""+n,e(n.split(" ")).each2(function(){0!==this.indexOf("select2-")&&(o=i(this),o&&a.push(this))})),t.attr("class",a.join(" "))}function C(e,t,s,i){s.push("<div class='select2-result-text'>");var n=e.toUpperCase().indexOf(t.toUpperCase()),o=t.length;return 0>n?void s.push(i(e)):(s.push(i(e.substring(0,n))),s.push("<span class='select2-match'>"),s.push(i(e.substring(n,n+o))),s.push("</span>"),s.push(i(e.substring(n+o,e.length))),void s.push("</div>"))}function w(e){var t={"\\":"\","&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};return String(e).replace(/[&<>"'\/\\]/g,function(e){return t[e]})}function b(s){var i,n=0,o=null,a=s.quietMillis||100,l=s.url,c=this;return function(r){window.clearTimeout(i),i=window.setTimeout(function(){n+=1;var i=n,a=s.data,h=l,d=s.transport||e.fn.select2.ajaxDefaults.transport,u={type:s.type||"GET",cache:s.cache||!1,jsonpCallback:s.jsonpCallback||t,dataType:s.dataType||"json"},p=e.extend({},e.fn.select2.ajaxDefaults.params,u);a=a?a.call(c,r.term,r.page,r.context):null,h="function"==typeof h?h.call(c,r.term,r.page,r.context):h,o&&o.abort(),s.params&&(e.isFunction(s.params)?e.extend(p,s.params.call(c)):e.extend(p,s.params)),e.extend(p,{url:h,dataType:s.dataType,data:a,success:function(e){if(!(n>i)){var t=s.results(e,r.page);r.callback(t)}}}),o=d.call(c,p)},a)}}function S(t){var s,i,n=t,o=function(e){return""+e.text};e.isArray(n)&&(i=n,n={results:i}),e.isFunction(n)===!1&&(i=n,n=function(){return i});var a=n();return a.text&&(o=a.text,e.isFunction(o)||(s=a.text,o=function(e){return e[s]})),function(t){var s,i=t.term,a={results:[]};return""===i?void t.callback(n()):(s=function(n,a){var l,c;if(n=n[0],n.children){l={};for(c in n)n.hasOwnProperty(c)&&(l[c]=n[c]);l.children=[],e(n.children).each2(function(e,t){s(t,l.children)}),(l.children.length||t.matcher(i,o(l),n))&&a.push(l)}else t.matcher(i,o(n),n)&&a.push(n)},e(n().results).each2(function(e,t){s(t,a.results)}),void t.callback(a))}}function y(s){var i=e.isFunction(s);return function(n){var o=n.term,a={results:[]};e(i?s():s).each(function(){var e=this.text!==t,s=e?this.text:this;(""===o||n.matcher(o,s))&&a.results.push(e?this:{id:this,text:this})}),n.callback(a)}}function x(t,s){if(e.isFunction(t))return!0;if(!t)return!1;throw new Error(s+" must be a function or a falsy value")}function E(t){return e.isFunction(t)?t():t}function T(t){var s=0;return e.each(t,function(e,t){t.children?s+=T(t.children):s++}),s}function k(e,s,i,o){var a,l,c,r,h,d=e,u=!1;if(!o.createSearchChoice||!o.tokenSeparators||o.tokenSeparators.length<1)return t;for(;;){for(l=-1,c=0,r=o.tokenSeparators.length;r>c&&(h=o.tokenSeparators[c],l=e.indexOf(h),!(l>=0));c++);if(0>l)break;if(a=e.substring(0,l),e=e.substring(l+h.length),a.length>0&&(a=o.createSearchChoice.call(this,a,s),a!==t&&null!==a&&o.id(a)!==t&&null!==o.id(a))){for(u=!1,c=0,r=s.length;r>c;c++)if(n(o.id(a),o.id(s[c]))){u=!0;break}u||i(a)}}return d!==e?e:void 0}function P(t,s){var i=function(){};return i.prototype=new t,i.prototype.constructor=i,i.prototype.parent=t.prototype,i.prototype=e.extend(i.prototype,s),i}if(window.Select2===t){var I,O,R,D,A,M,F,H,N={x:0,y:0},I={TAB:9,ENTER:13,ESC:27,SPACE:32,LEFT:37,UP:38,RIGHT:39,DOWN:40,SHIFT:16,CTRL:17,ALT:18,PAGE_UP:33,PAGE_DOWN:34,HOME:36,END:35,BACKSPACE:8,DELETE:46,isArrow:function(e){switch(e=e.which?e.which:e){case I.LEFT:case I.RIGHT:case I.UP:case I.DOWN:return!0}return!1},isControl:function(e){var t=e.which;switch(t){case I.SHIFT:case I.CTRL:case I.ALT:return!0}return e.metaKey?!0:!1},isFunctionKey:function(e){return e=e.which?e.which:e,e>=112&&123>=e}},L="<div class='select2-measure-scrollbar'></div>";F=e(document),A=function(){var e=1;return function(){return e++}}(),F.on("mousemove",function(e){N.x=e.pageX,N.y=e.pageY}),O=P(Object,{bind:function(e){var t=this;return function(){e.apply(t,arguments)}},init:function(s){var n,o,a,r,u=".select2-results",p=".select2-result";this.opts=s=this.prepareOpts(s),this.id=s.id,s.element.data("select2")!==t&&null!==s.element.data("select2")&&s.element.data("select2").destroy(),this.container=this.createContainer(),this.containerId="s2id_"+(s.element.attr("id")||"autogen"+A()),this.containerSelector="#"+this.containerId.replace(/([;&,\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g,"\\$1"),this.container.attr("id",this.containerId),this.body=h(function(){return s.element.closest("body")}),v(this.container,this.opts.element,this.opts.adaptContainerCssClass),this.container.css(E(s.containerCss)),this.container.addClass(E(s.containerCssClass)),this.elementTabIndex=this.opts.element.attr("tabindex"),this.opts.element.data("select2",this).attr("tabindex","-1").before(this.container),this.container.data("select2",this),this.dropdown=this.container.find(".select2-drop"),this.dropdown.addClass(E(s.dropdownCssClass)),this.dropdown.data("select2",this),this.results=n=this.container.find(u),this.search=o=this.container.find("input.select2-input"),this.resultsPage=0,this.context=null,this.initContainer(),c(this.results),this.dropdown.on("mousemove-filtered touchstart touchmove touchend",u,this.bind(this.highlightUnderEvent)),d(80,this.results),this.dropdown.on("scroll-debounced",u,this.bind(this.loadMoreIfNeeded)),e(this.container).on("change",".select2-input",function(e){e.stopPropagation()}),e(this.dropdown).on("change",".select2-input",function(e){e.stopPropagation()}),e.fn.mousewheel&&n.mousewheel(function(e,t,s,i){var o=n.scrollTop();i>0&&0>=o-i?(n.scrollTop(0),f(e)):0>i&&n.get(0).scrollHeight-n.scrollTop()+i<=n.height()&&(n.scrollTop(n.get(0).scrollHeight-n.height()),f(e))}),l(o),o.on("keyup-change input paste",this.bind(this.updateResults)),o.on("focus",function(){o.addClass("select2-focused")}),o.on("blur",function(){o.removeClass("select2-focused")}),this.opts.treeview&&(p=".select2-result-text"),this.dropdown.on("mouseup",p,this.bind(function(t){e(t.target).closest(".select2-result-selectable").length>0&&(this.highlightUnderEvent(t),this.selectHighlighted(t))})),this.dropdown.on("click mouseup mousedown",function(e){e.stopPropagation()}),e.isFunction(this.opts.initSelection)&&(this.initSelection(),this.monitorSource()),null!==s.maximumInputLength&&this.search.attr("maxlength",s.maximumInputLength);var a=s.element.prop("disabled");a===t&&(a=!1),this.enable(!a);var r=s.element.prop("readonly");r===t&&(r=!1),this.readonly(r),H=H||i(),this.autofocus=s.element.prop("autofocus"),s.element.prop("autofocus",!1),this.autofocus&&this.focus()},destroy:function(){var e=this.opts.element,s=e.data("select2");this.propertyObserver&&(delete this.propertyObserver,this.propertyObserver=null),s!==t&&(s.container.remove(),s.dropdown.remove(),e.removeClass("select2-offscreen").removeData("select2").off(".select2").prop("autofocus",this.autofocus||!1),this.elementTabIndex?e.attr({tabindex:this.elementTabIndex}):e.removeAttr("tabindex"),e.show())},optionToData:function(e){return e.is("option")?{id:e.prop("value"),text:e.text(),element:e.get(),css:e.attr("class"),disabled:e.prop("disabled"),locked:n(e.attr("locked"),"locked")||n(e.data("locked"),!0)}:e.is("optgroup")?{text:e.attr("label"),children:[],element:e.get(),css:e.attr("class")}:void 0},getChildrenByIndent:function(e){var t=e.nextUntil('[data-indent-count="'+e.data("indent-count")+'"]'),s=e.nextUntil('[data-indent-count="0"]');return t.length>s.length?s:t},filterVal:function(e){return e.replace(/[\.]/g,"-").replace(/-$/g,"")},expandNode:function(t,s){var i=this,n=i.getChildrenByIndent(t);n.slideDown(),n.each2(function(){var t=e(this).prevAll('[data-indent-count="'+(e(this).data("indent-count")-1)+'"]').first();t.hasClass("collapsed")&&(s?(t.removeClass("collapsed").addClass("expanded"),t.find(".select2-tree-icon").addClass(i.opts.treeviewExpandedClass)):e(this).hide())})},collapseNode:function(e){var t=this.getChildrenByIndent(e);t.slideUp()},prepareOpts:function(s){var i,a,l,c,r=this;if(i=s.element,"select"===i.get(0).tagName.toLowerCase()&&(this.select=a=s.element),a&&e.each(["id","multiple","ajax","query","createSearchChoice","initSelection","data","tags"],function(){if(this in s)throw new Error("Option '"+this+"' is not allowed for Select2 when attached to a <select> element.")}),s=e.extend({},{populateResults:function(i,n,o){var a,l=this.opts.id;if(a=function(i,n,c){var h,d,u,p,f,g,m,v,C,w,b=0;for(i=s.sortResults(i,n,o),h=0,d=i.length;d>h;h+=1)u=i[h],f=u.disabled===!0,p=!f&&l(u)!==t,g=u.children&&u.children.length>0,s.treeview&&(b=u.text.lastIndexOf(s.indentChar)+1,u.text=u.text.replace(new RegExp("^"+s.indentChar+"*"),"")),m=e("<li></li>"),m.attr("id","select2-result-"+r.filterVal(u.id)),m.attr("data-indent-count",b),m.addClass("select2-results-dept-"+c),m.addClass("select2-result"),m.addClass(p?"select2-result-selectable":"select2-result-unselectable"),f&&m.addClass("select2-disabled"),g&&m.addClass("select2-result-with-children"),m.addClass(r.opts.formatResultCssClass(u)),v=e(document.createElement("div")),v.addClass("select2-result-label"),v.css({"padding-left":5+15*b}),w=s.formatResult(u,v,o,r.opts.escapeMarkup),w!==t&&v.html(w),m.append(v),g&&(C=e("<ul></ul>"),C.addClass("select2-result-sub"),a(u.children,C,c+1),m.append(C)),m.data("select2-data",u),n.append(m)},a(n,i,0),s.treeview&&(e(".select2-result").each2(function(){var t=e(this).data("indent-count"),i=e('<i class="select2-tree-icon"></i>');if(e(this).next().length>0&&e(this).next().data("indentCount")>t){var n=r.getChildrenByIndent(e(this));n.length>0&&(e(this).addClass("select2-result-parent"),"expanded"==s.treeviewInitState||o.term?(e(this).addClass("expanded"),i.addClass(s.treeviewExpandedClass)):(e(this).addClass("collapsed"),n.hide(),i.addClass(s.treeviewCollapsedClass)))}e(this).find(".select2-result-label").prepend(i)}),e(".select2-tree-icon").click(function(){var t=e(this),i=t.closest("li.select2-result");i.hasClass("expanded")?(i.removeClass("expanded").addClass("collapsed"),t.removeClass(s.treeviewExpandedClass).addClass(s.treeviewCollapsedClass),r.collapseNode(i)):(i.removeClass("collapsed").addClass("expanded"),t.removeClass(s.treeviewCollapsedClass).addClass(s.treeviewExpandedClass),r.expandNode(i,!1))}),r.opts.element.val())){var c=e("#select2-result-"+r.filterVal(r.opts.element.val())),h=c.data("indentCount");if(h>0){var d=c.prevAll('[data-indent-count="0"]').filter(".select2-result-parent").first();r.expandNode(d,!0)}}}},e.fn.select2.defaults,s),"function"!=typeof s.id&&(l=s.id,s.id=function(e){return e[l]}),e.isArray(s.element.data("select2Tags"))){if("tags"in s)throw"tags specified as both an attribute 'data-select2-tags' and in options of Select2 "+s.element.attr("id");s.tags=s.element.data("select2Tags")}if(a?(s.query=this.bind(function(e){var s,n,o,a={results:[],more:!1},l=e.term;o=function(t,s){var i;t.is("option")?e.matcher(l,t.text(),t)&&s.push(r.optionToData(t)):t.is("optgroup")&&(i=r.optionToData(t),t.children().each2(function(e,t){o(t,i.children)}),i.children.length>0&&s.push(i))},s=i.children(),this.getPlaceholder()!==t&&s.length>0&&(n=this.getPlaceholderOption(),n&&(s=s.not(n))),s.each2(function(e,t){o(t,a.results)}),e.callback(a)}),s.id=function(e){return e.id},s.formatResultCssClass=function(e){return e.css}):"query"in s||("ajax"in s?(c=s.element.data("ajax-url"),c&&c.length>0&&(s.ajax.url=c),s.query=b.call(s.element,s.ajax)):"data"in s?s.query=S(s.data):"tags"in s&&(s.query=y(s.tags),s.createSearchChoice===t&&(s.createSearchChoice=function(e){return{id:e,text:e}}),s.initSelection===t&&(s.initSelection=function(t,i){var a=[];e(o(t.val(),s.separator)).each(function(){var t=this,i=this,o=s.tags;e.isFunction(o)&&(o=o()),e(o).each(function(){return n(this.id,t)?(i=this.text,!1):void 0}),a.push({id:t,text:i})}),i(a)}))),"function"!=typeof s.query)throw"query function not defined for Select2 "+s.element.attr("id");return s},monitorSource:function(){var e,s=this.opts.element;s.on("change.select2",this.bind(function(){this.opts.element.data("select2-change-triggered")!==!0&&this.initSelection()})),e=this.bind(function(){var e,i=s.prop("disabled");i===t&&(i=!1),this.enable(!i);var e=s.prop("readonly");e===t&&(e=!1),this.readonly(e),v(this.container,this.opts.element,this.opts.adaptContainerCssClass),this.container.addClass(E(this.opts.containerCssClass)),v(this.dropdown,this.opts.element,this.opts.adaptDropdownCssClass),this.dropdown.addClass(E(this.opts.dropdownCssClass))}),s.on("propertychange.select2 DOMAttrModified.select2",e),this.mutationCallback===t&&(this.mutationCallback=function(t){t.forEach(e)}),"undefined"!=typeof WebKitMutationObserver&&(this.propertyObserver&&(delete this.propertyObserver,this.propertyObserver=null),this.propertyObserver=new WebKitMutationObserver(this.mutationCallback),this.propertyObserver.observe(s.get(0),{attributes:!0,subtree:!1}))},triggerSelect:function(t){var s=e.Event("select2-selecting",{val:this.id(t),object:t});return this.opts.element.trigger(s),!s.isDefaultPrevented()},triggerChange:function(t){t=t||{},t=e.extend({},t,{type:"change",val:this.val()}),this.opts.element.data("select2-change-triggered",!0),this.opts.element.trigger(t),this.opts.element.data("select2-change-triggered",!1),this.opts.element.click(),this.opts.blurOnChange&&this.opts.element.blur()},isInterfaceEnabled:function(){return this.enabledInterface===!0},enableInterface:function(){var e=this._enabled&&!this._readonly,t=!e;return e===this.enabledInterface?!1:(this.container.toggleClass("select2-container-disabled",t),this.close(),this.enabledInterface=e,!0)},enable:function(e){return e===t&&(e=!0),this._enabled===e?!1:(this._enabled=e,this.opts.element.prop("disabled",!e),this.enableInterface(),!0)},readonly:function(e){return e===t&&(e=!1),this._readonly===e?!1:(this._readonly=e,this.opts.element.prop("readonly",e),this.enableInterface(),!0)},opened:function(){return this.container.hasClass("select2-dropdown-open")},positionDropdown:function(){var t,s,i,n,o,a=this.dropdown,l=this.container.offset(),c=this.container.outerHeight(!1),r=this.container.outerWidth(!1),h=a.outerHeight(!1),d=e(window).scrollLeft()+e(window).width(),u=e(window).scrollTop()+e(window).height(),p=l.top+c,f=l.left,g=u>=p+h,m=l.top-h>=this.body().scrollTop(),v=0,C=d>=f+v,w=a.hasClass("select2-drop-above");this.opts.dropdownAutoWidth?(n=e(".select2-result",a),a.addClass("select2-drop-auto-width"),a.css("width",""),n.each2(function(){var t=25*e(this).data("indentCount")+14*e(this).find(".select2-result-text").text().length;v=v>t?v:t}),o=e(".select2-results",a)[0],v+=o.scrollHeight===o.clientHeight?0:H.width,v>r?r=v:v=r,C=d>=f+v):this.container.removeClass("select2-drop-auto-width"),"static"!==this.body().css("position")&&(t=this.body().offset(),p-=t.top,f-=t.left),w?(s=!0,!m&&g&&(s=!1)):(s=!1,!g&&m&&(s=!0)),C||(f=l.left+r-v),s?(p=l.top-h,this.container.addClass("select2-drop-above"),a.addClass("select2-drop-above")):(this.container.removeClass("select2-drop-above"),a.removeClass("select2-drop-above")),i=e.extend({top:p,left:f,width:r},E(this.opts.dropdownCss)),a.css(i)},shouldOpen:function(){var t;return this.opened()?!1:this._enabled===!1||this._readonly===!0?!1:(t=e.Event("select2-opening"),this.opts.element.trigger(t),!t.isDefaultPrevented())},clearDropdownAlignmentPreference:function(){this.container.removeClass("select2-drop-above"),this.dropdown.removeClass("select2-drop-above")},open:function(){return this.shouldOpen()?(this.opening(),!0):!1},opening:function(){function t(){return{width:Math.max(document.documentElement.scrollWidth,e(window).width()),height:Math.max(document.documentElement.scrollHeight,e(window).height())}}var s,i,n=this.containerId,o="scroll."+n,a="resize."+n,l="orientationchange."+n;this.container.addClass("select2-dropdown-open").addClass("select2-container-active"),this.clearDropdownAlignmentPreference(),this.dropdown[0]!==this.body().children().last()[0]&&this.dropdown.detach().appendTo(this.body()),s=e("#select2-drop-mask"),0==s.length&&(s=e(document.createElement("div")),s.attr("id","select2-drop-mask").attr("class","select2-drop-mask"),s.hide(),s.appendTo(this.body()),s.on("mousedown touchstart click",function(t){var s,i=e("#select2-drop");i.length>0&&(s=i.data("select2"),s.opts.selectOnBlur&&s.selectHighlighted({noFocus:!0}),s.close(),t.preventDefault(),t.stopPropagation())})),this.dropdown.prev()[0]!==s[0]&&this.dropdown.before(s),e("#select2-drop").removeAttr("id"),this.dropdown.attr("id","select2-drop"),i=t(),s.css(i).show(),this.dropdown.show(),this.positionDropdown(),this.dropdown.addClass("select2-drop-active");var c=this;this.container.parents().add(window).each(function(){e(this).on(a+" "+o+" "+l,function(){var s=t();e("#select2-drop-mask").css(s),c.positionDropdown()})})},close:function(){if(this.opened()){var t=this.containerId,s="scroll."+t,i="resize."+t,n="orientationchange."+t;this.container.parents().add(window).each(function(){e(this).off(s).off(i).off(n)}),this.clearDropdownAlignmentPreference(),e("#select2-drop-mask").hide(),this.dropdown.removeAttr("id"),this.dropdown.hide(),this.container.removeClass("select2-dropdown-open"),this.results.empty(),this.clearSearch(),this.search.removeClass("select2-active"),this.opts.element.trigger(e.Event("select2-close"))}},externalSearch:function(e){this.open(),this.search.val(e),this.updateResults(!1)},clearSearch:function(){},getMaximumSelectionSize:function(){return E(this.opts.maximumSelectionSize)},ensureHighlightVisible:function(){var t,s,i,n,o,a,l,c=this.results;if(s=this.highlight(),!(0>s)){if(0==s)return void c.scrollTop(0);t=this.findHighlightableChoices().find(".select2-result-label"),i=e(t[s]),n=i.offset().top+i.outerHeight(!0),s===t.length-1&&(l=c.find("li.select2-more-results"),l.length>0&&(n=l.offset().top+l.outerHeight(!0))),o=c.offset().top+c.outerHeight(!0),n>o&&c.scrollTop(c.scrollTop()+(n-o)),a=i.offset().top-c.offset().top,0>a&&"none"!=i.css("display")&&c.scrollTop(c.scrollTop()+a)}},findHighlightableChoices:function(){return this.results.find(".select2-result-selectable:not(.select2-selected):not(.select2-disabled)")},moveHighlight:function(t){for(var s=this.findHighlightableChoices(),i=this.highlight();i>-1&&i<s.length;){i+=t;var n=e(s[i]);if(n.hasClass("select2-result-selectable")&&!n.hasClass("select2-disabled")&&!n.hasClass("select2-selected")){this.highlight(i);break}}},highlight:function(t){var i,n,o=this.findHighlightableChoices();return 0===arguments.length?s(o.filter(".select2-highlighted")[0],o.get()):(t>=o.length&&(t=o.length-1),0>t&&(t=0),this.results.find(".select2-highlighted").removeClass("select2-highlighted"),i=e(o[t]),i.addClass("select2-highlighted"),this.ensureHighlightVisible(),n=i.data("select2-data"),void(n&&this.opts.element.trigger({type:"select2-highlight",val:this.id(n),choice:n})))},countSelectableResults:function(){return this.findHighlightableChoices().length},highlightUnderEvent:function(t){var s=e(t.target).closest(".select2-result-selectable");if(s.length>0&&!s.is(".select2-highlighted")){var i=this.findHighlightableChoices();this.highlight(i.index(s))}else 0==s.length&&this.results.find(".select2-highlighted").removeClass("select2-highlighted")},loadMoreIfNeeded:function(){var e,t=this.results,s=t.find("li.select2-more-results"),i=this.resultsPage+1,n=this,o=this.search.val(),a=this.context;0!==s.length&&(e=s.offset().top-t.offset().top-t.height(),e<=this.opts.loadMorePadding&&(s.addClass("select2-active"),this.opts.query({element:this.opts.element,term:o,page:i,context:a,matcher:this.opts.matcher,callback:this.bind(function(e){n.opened()&&(n.opts.populateResults.call(this,t,e.results,{term:o,page:i,context:a}),n.postprocessResults(e,!1,!1),e.more===!0?(s.detach().appendTo(t).text(n.opts.formatLoadMore(i+1)),window.setTimeout(function(){n.loadMoreIfNeeded()},10)):s.remove(),n.positionDropdown(),n.resultsPage=i,n.context=e.context)})})))},tokenize:function(){},updateResults:function(s){function i(){c.removeClass("select2-active"),d.positionDropdown()}function o(e){r.html(e),i()}var a,l,c=this.search,r=this.results,h=this.opts,d=this,u=c.val(),p=e.data(this.container,"select2-last-term");if((s===!0||!p||!n(u,p))&&(e.data(this.container,"select2-last-term",u),s===!0||this.showSearchInput!==!1&&this.opened())){var f=this.getMaximumSelectionSize();if(f>=1&&(a=this.data(),e.isArray(a)&&a.length>=f&&x(h.formatSelectionTooBig,"formatSelectionTooBig")))return void o("<li class='select2-selection-limit'>"+h.formatSelectionTooBig(f)+"</li>");if(c.val().length<h.minimumInputLength)return o(x(h.formatInputTooShort,"formatInputTooShort")?"<li class='select2-no-results'>"+h.formatInputTooShort(c.val(),h.minimumInputLength)+"</li>":""),void(s&&this.showSearch&&this.showSearch(!0));if(h.maximumInputLength&&c.val().length>h.maximumInputLength)return void o(x(h.formatInputTooLong,"formatInputTooLong")?"<li class='select2-no-results'>"+h.formatInputTooLong(c.val(),h.maximumInputLength)+"</li>":"");h.formatSearching&&0===this.findHighlightableChoices().length&&o("<li class='select2-searching'>"+h.formatSearching()+"</li>"),c.addClass("select2-active"),l=this.tokenize(),l!=t&&null!=l&&c.val(l),this.resultsPage=1,h.query({element:h.element,term:c.val(),page:this.resultsPage,context:null,matcher:h.matcher,callback:this.bind(function(a){var l;return this.opened()?(this.context=a.context===t?null:a.context,this.opts.createSearchChoice&&""!==c.val()&&(l=this.opts.createSearchChoice.call(d,c.val(),a.results),l!==t&&null!==l&&d.id(l)!==t&&null!==d.id(l)&&0===e(a.results).filter(function(){return n(d.id(this),d.id(l))}).length&&a.results.unshift(l)),0===a.results.length&&x(h.formatNoMatches,"formatNoMatches")?void o("<li class='select2-no-results'>"+h.formatNoMatches(c.val())+"</li>"):(r.empty(),d.opts.populateResults.call(this,r,a.results,{term:c.val(),page:this.resultsPage,context:null}),a.more===!0&&x(h.formatLoadMore,"formatLoadMore")&&(r.append("<li class='select2-more-results'>"+d.opts.escapeMarkup(h.formatLoadMore(this.resultsPage))+"</li>"),window.setTimeout(function(){d.loadMoreIfNeeded()},10)),this.postprocessResults(a,s),i(),void this.opts.element.trigger({type:"select2-loaded",items:a}))):void this.search.removeClass("select2-active")})})}},cancel:function(){this.close()},blur:function(){this.opts.selectOnBlur&&this.selectHighlighted({noFocus:!0}),this.close(),this.container.removeClass("select2-container-active"),this.search[0]===document.activeElement&&this.search.blur(),this.clearSearch(),this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus")},focusSearch:function(){u(this.search)},selectHighlighted:function(e){var t=this.highlight(),s=this.results.find(".select2-highlighted"),i=s.closest(".select2-result").data("select2-data");i?(this.highlight(t),this.onSelect(i,e)):e&&e.noFocus&&this.close()},getPlaceholder:function(){var e;return this.opts.element.attr("placeholder")||this.opts.element.attr("data-placeholder")||this.opts.element.data("placeholder")||this.opts.placeholder||((e=this.getPlaceholderOption())!==t?e.text():t)},getPlaceholderOption:function(){if(this.select){var e=this.select.children().first();if(this.opts.placeholderOption!==t)return"first"===this.opts.placeholderOption&&e||"function"==typeof this.opts.placeholderOption&&this.opts.placeholderOption(this.select);if(""===e.text()&&""===e.val())return e}},initContainerWidth:function(){function s(){var s,i,n,o,a;if("off"===this.opts.width)return null;if("element"===this.opts.width)return 0===this.opts.element.outerWidth(!1)?"auto":this.opts.element.outerWidth(!1)+"px";if("copy"===this.opts.width||"resolve"===this.opts.width){if(s=this.opts.element.attr("style"),s!==t)for(i=s.split(";"),o=0,a=i.length;a>o;o+=1)if(n=i[o].replace(/\s/g,"").match(/width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i),null!==n&&n.length>=1)return n[1];return"resolve"===this.opts.width?(s=this.opts.element.css("width"),s.indexOf("%")>0?s:0===this.opts.element.outerWidth(!1)?"auto":this.opts.element.outerWidth(!1)+"px"):null}return e.isFunction(this.opts.width)?this.opts.width():this.opts.width}var i=s.call(this);null!==i&&this.container.css("width",i)}}),R=P(O,{createContainer:function(){var t=e(document.createElement("div")).attr({"class":"select2-container"}).html(["<a href='javascript:void(0)' onclick='return false;' class='select2-choice' tabindex='-1'>"," <span class='select2-chosen'> </span><abbr class='select2-search-choice-close'></abbr>"," <span class='select2-arrow'><b></b></span>","</a>","<input class='select2-focusser select2-offscreen' type='text'/>","<div class='select2-drop select2-display-none'>"," <div class='select2-search'>"," <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input'/>"," </div>"," <ul class='select2-results'>"," </ul>","</div>"].join(""));return t},enableInterface:function(){this.parent.enableInterface.apply(this,arguments)&&this.focusser.prop("disabled",!this.isInterfaceEnabled())},opening:function(){var t,s,i;this.opts.minimumResultsForSearch>=0&&this.showSearch(!0),this.parent.opening.apply(this,arguments),this.showSearchInput!==!1&&this.search.val(this.focusser.val()),this.search.focus(),t=this.search.get(0),t.createTextRange?(s=t.createTextRange(),s.collapse(!1),s.select()):t.setSelectionRange&&(i=this.search.val().length,t.setSelectionRange(i,i)),this.focusser.prop("disabled",!0).val(""),this.updateResults(!0),this.opts.element.trigger(e.Event("select2-open"))},close:function(){this.opened()&&(this.parent.close.apply(this,arguments),this.focusser.removeAttr("disabled"),this.focusser.focus())},focus:function(){this.opened()?this.close():(this.focusser.removeAttr("disabled"),this.focusser.focus())},isFocused:function(){return this.container.hasClass("select2-container-active")},cancel:function(){this.parent.cancel.apply(this,arguments),this.focusser.removeAttr("disabled"),this.focusser.focus()},initContainer:function(){var t,s=this.container,i=this.dropdown;this.showSearch(this.opts.minimumResultsForSearch<0?!1:!0),this.selection=t=s.find(".select2-choice"),this.focusser=s.find(".select2-focusser"),this.focusser.attr("id","s2id_autogen"+A()),e("label[for='"+this.opts.element.attr("id")+"']").attr("for",this.focusser.attr("id")),this.focusser.attr("tabindex",this.elementTabIndex),this.search.on("keydown",this.bind(function(e){if(this.isInterfaceEnabled()){if(e.which===I.PAGE_UP||e.which===I.PAGE_DOWN)return void f(e);switch(e.which){case I.UP:case I.DOWN:return this.moveHighlight(e.which===I.UP?-1:1),void f(e);case I.ENTER:return this.selectHighlighted(),void f(e);case I.TAB:return void this.selectHighlighted({noFocus:!0});case I.ESC:return this.cancel(e),void f(e)}}})),this.search.on("blur",this.bind(function(){document.activeElement===this.body().get(0)&&window.setTimeout(this.bind(function(){this.search.focus()}),0)})),this.focusser.on("keydown",this.bind(function(e){if(this.isInterfaceEnabled()&&e.which!==I.TAB&&!I.isControl(e)&&!I.isFunctionKey(e)&&e.which!==I.ESC){if(this.opts.openOnEnter===!1&&e.which===I.ENTER)return void f(e);if(e.which==I.DOWN||e.which==I.UP||e.which==I.ENTER&&this.opts.openOnEnter){if(e.altKey||e.ctrlKey||e.shiftKey||e.metaKey)return;return this.open(),void f(e)}return e.which==I.DELETE||e.which==I.BACKSPACE?(this.opts.allowClear&&this.clear(),void f(e)):void 0}})),l(this.focusser),this.focusser.on("keyup-change input",this.bind(function(e){if(this.opts.minimumResultsForSearch>=0){if(e.stopPropagation(),this.opened())return;this.open()}})),t.on("mousedown","abbr",this.bind(function(e){this.isInterfaceEnabled()&&(this.clear(),g(e),this.close(),this.selection.focus())})),t.on("mousedown",this.bind(function(t){this.container.hasClass("select2-container-active")||this.opts.element.trigger(e.Event("select2-focus")),this.opened()?this.close():this.isInterfaceEnabled()&&this.open(),f(t)})),i.on("mousedown",this.bind(function(){this.search.focus()})),t.on("focus",this.bind(function(e){f(e)})),this.focusser.on("focus",this.bind(function(){this.container.hasClass("select2-container-active")||this.opts.element.trigger(e.Event("select2-focus")),this.container.addClass("select2-container-active")})).on("blur",this.bind(function(){this.opened()||(this.container.removeClass("select2-container-active"),this.opts.element.trigger(e.Event("select2-blur")))})),this.search.on("focus",this.bind(function(){this.container.hasClass("select2-container-active")||this.opts.element.trigger(e.Event("select2-focus")),this.container.addClass("select2-container-active")})),this.initContainerWidth(),this.opts.element.addClass("select2-offscreen"),this.setPlaceholder()},clear:function(e){var t=this.selection.data("select2-data");if(t){var s=this.getPlaceholderOption();this.opts.element.val(s?s.val():""),this.selection.find(".select2-chosen").empty(),this.selection.removeData("select2-data"),this.setPlaceholder(),e!==!1&&(this.opts.element.trigger({type:"select2-removed",val:this.id(t),choice:t}),this.triggerChange({removed:t}))}},initSelection:function(){if(this.isPlaceholderOptionSelected())this.updateSelection([]),this.close(),this.setPlaceholder();else{var e=this;this.opts.initSelection.call(null,this.opts.element,function(s){s!==t&&null!==s&&(e.updateSelection(s),e.close(),e.setPlaceholder())
})}},isPlaceholderOptionSelected:function(){var e;return(e=this.getPlaceholderOption())!==t&&e.is(":selected")||""===this.opts.element.val()||this.opts.element.val()===t||null===this.opts.element.val()},prepareOpts:function(){var t=this.parent.prepareOpts.apply(this,arguments),s=this;return"select"===t.element.get(0).tagName.toLowerCase()?t.initSelection=function(e,t){var i=e.find(":selected");t(s.optionToData(i))}:"data"in t&&(t.initSelection=t.initSelection||function(s,i){var o=s.val(),a=null;t.query({matcher:function(e,s,i){var l=n(o,t.id(i));return l&&(a=i),l},callback:e.isFunction(i)?function(){i(a)}:e.noop})}),t},getPlaceholder:function(){return this.select&&this.getPlaceholderOption()===t?t:this.parent.getPlaceholder.apply(this,arguments)},setPlaceholder:function(){var e=this.getPlaceholder();if(this.isPlaceholderOptionSelected()&&e!==t){if(this.select&&this.getPlaceholderOption()===t)return;this.selection.find(".select2-chosen").html(this.opts.escapeMarkup(e)),this.selection.addClass("select2-default"),this.container.removeClass("select2-allowclear")}},postprocessResults:function(e,t,s){var i=0,o=this;if(this.findHighlightableChoices().each2(function(e,t){return n(o.id(t.data("select2-data")),o.opts.element.val())?(i=e,!1):void 0}),s!==!1&&this.highlight(t===!0&&i>=0?i:0),t===!0){var a=this.opts.minimumResultsForSearch;a>=0&&this.showSearch(T(e.results)>=a)}},showSearch:function(t){this.showSearchInput!==t&&(this.showSearchInput=t,this.dropdown.find(".select2-search").toggleClass("select2-search-hidden",!t),this.dropdown.find(".select2-search").toggleClass("select2-offscreen",!t),e(this.dropdown,this.container).toggleClass("select2-with-searchbox",t))},onSelect:function(e,t){if(this.triggerSelect(e)){var s=this.opts.element.val(),i=this.data();this.opts.element.val(this.id(e)),this.updateSelection(e),this.opts.element.trigger({type:"select2-selected",val:this.id(e),choice:e}),this.close(),t&&t.noFocus||this.selection.focus(),n(s,this.id(e))||this.triggerChange({added:e,removed:i})}},updateSelection:function(e){var s,i,n=this.selection.find(".select2-chosen");this.selection.data("select2-data",e),n.empty(),s=this.opts.formatSelection(e,n,this.opts.escapeMarkup),this.opts.treeview&&(s=s.replace(new RegExp("^"+this.opts.indentChar+"*"),"")),s!==t&&n.append(s),i=this.opts.formatSelectionCssClass(e,n),i!==t&&n.addClass(i),this.selection.removeClass("select2-default"),this.opts.allowClear&&this.getPlaceholder()!==t&&this.container.addClass("select2-allowclear")},val:function(){var e,s=!1,i=null,n=this,o=this.data();if(0===arguments.length)return this.opts.element.val();if(e=arguments[0],arguments.length>1&&(s=arguments[1]),this.select)this.select.val(e).find(":selected").each2(function(e,t){return i=n.optionToData(t),!1}),this.updateSelection(i),this.setPlaceholder(),s&&this.triggerChange({added:i,removed:o});else{if(!e&&0!==e)return void this.clear(s);if(this.opts.initSelection===t)throw new Error("cannot call val() if initSelection() is not defined");this.opts.element.val(e),this.opts.initSelection(this.opts.element,function(e){n.opts.element.val(e?n.id(e):""),n.updateSelection(e),n.setPlaceholder(),s&&n.triggerChange({added:e,removed:o})})}},clearSearch:function(){this.search.val(""),this.focusser.val("")},data:function(e,s){var i;return 0===arguments.length?(i=this.selection.data("select2-data"),i==t&&(i=null),i):void(e&&""!==e?(i=this.data(),this.opts.element.val(e?this.id(e):""),this.updateSelection(e),s&&this.triggerChange({added:e,removed:i})):this.clear(s))}}),D=P(O,{createContainer:function(){var t=e(document.createElement("div")).attr({"class":"select2-container select2-container-multi"}).html(["<ul class='select2-choices'>"," <li class='select2-search-field'>"," <input type='text' autocomplete='off' autocorrect='off' autocapitilize='off' spellcheck='false' class='select2-input'>"," </li>","</ul>","<div class='select2-drop select2-drop-multi select2-display-none'>"," <ul class='select2-results'>"," </ul>","</div>"].join(""));return t},prepareOpts:function(){var t=this.parent.prepareOpts.apply(this,arguments),s=this;return"select"===t.element.get(0).tagName.toLowerCase()?t.initSelection=function(e,t){var i=[];e.find(":selected").each2(function(e,t){i.push(s.optionToData(t))}),t(i)}:"data"in t&&(t.initSelection=t.initSelection||function(s,i){var a=o(s.val(),t.separator),l=[];t.query({matcher:function(s,i,o){var c=e.grep(a,function(e){return n(e,t.id(o))}).length;return c&&l.push(o),c},callback:e.isFunction(i)?function(){for(var e=[],s=0;s<a.length;s++)for(var o=a[s],c=0;c<l.length;c++){var r=l[c];if(n(o,t.id(r))){e.push(r),l.splice(c,1);break}}i(e)}:e.noop})}),t},selectChoice:function(e){var t=this.container.find(".select2-search-choice-focus");t.length&&e&&e[0]==t[0]||(t.length&&this.opts.element.trigger("choice-deselected",t),t.removeClass("select2-search-choice-focus"),e&&e.length&&(this.close(),e.addClass("select2-search-choice-focus"),this.opts.element.trigger("choice-selected",e)))},initContainer:function(){var t,s=".select2-choices";this.searchContainer=this.container.find(".select2-search-field"),this.selection=t=this.container.find(s);var i=this;this.selection.on("mousedown",".select2-search-choice",function(){i.search[0].focus(),i.selectChoice(e(this))}),this.search.attr("id","s2id_autogen"+A()),e("label[for='"+this.opts.element.attr("id")+"']").attr("for",this.search.attr("id")),this.search.on("input paste",this.bind(function(){this.isInterfaceEnabled()&&(this.opened()||this.open())})),this.search.attr("tabindex",this.elementTabIndex),this.keydowns=0,this.search.on("keydown",this.bind(function(e){if(this.isInterfaceEnabled()){++this.keydowns;var s=t.find(".select2-search-choice-focus"),i=s.prev(".select2-search-choice:not(.select2-locked)"),n=s.next(".select2-search-choice:not(.select2-locked)"),o=p(this.search);if(s.length&&(e.which==I.LEFT||e.which==I.RIGHT||e.which==I.BACKSPACE||e.which==I.DELETE||e.which==I.ENTER)){var a=s;return e.which==I.LEFT&&i.length?a=i:e.which==I.RIGHT?a=n.length?n:null:e.which===I.BACKSPACE?(this.unselect(s.first()),this.search.width(10),a=i.length?i:n):e.which==I.DELETE?(this.unselect(s.first()),this.search.width(10),a=n.length?n:null):e.which==I.ENTER&&(a=null),this.selectChoice(a),f(e),void(a&&a.length||this.open())}if((e.which===I.BACKSPACE&&1==this.keydowns||e.which==I.LEFT)&&0==o.offset&&!o.length)return this.selectChoice(t.find(".select2-search-choice:not(.select2-locked)").last()),void f(e);if(this.selectChoice(null),this.opened())switch(e.which){case I.UP:case I.DOWN:return this.moveHighlight(e.which===I.UP?-1:1),void f(e);case I.ENTER:return this.selectHighlighted(),void f(e);case I.TAB:return this.selectHighlighted({noFocus:!0}),void this.close();case I.ESC:return this.cancel(e),void f(e)}if(e.which!==I.TAB&&!I.isControl(e)&&!I.isFunctionKey(e)&&e.which!==I.BACKSPACE&&e.which!==I.ESC){if(e.which===I.ENTER){if(this.opts.openOnEnter===!1)return;if(e.altKey||e.ctrlKey||e.shiftKey||e.metaKey)return}this.open(),(e.which===I.PAGE_UP||e.which===I.PAGE_DOWN)&&f(e),e.which===I.ENTER&&f(e)}}})),this.search.on("keyup",this.bind(function(){this.keydowns=0,this.resizeSearch()})),this.search.on("blur",this.bind(function(t){this.container.removeClass("select2-container-active"),this.search.removeClass("select2-focused"),this.selectChoice(null),this.opened()||this.clearSearch(),t.stopImmediatePropagation(),this.opts.element.trigger(e.Event("select2-blur"))})),this.container.on("click",s,this.bind(function(t){this.isInterfaceEnabled()&&(e(t.target).closest(".select2-search-choice").length>0||(this.selectChoice(null),this.clearPlaceholder(),this.container.hasClass("select2-container-active")||this.opts.element.trigger(e.Event("select2-focus")),this.open(),this.focusSearch(),t.preventDefault()))})),this.container.on("focus",s,this.bind(function(){this.isInterfaceEnabled()&&(this.container.hasClass("select2-container-active")||this.opts.element.trigger(e.Event("select2-focus")),this.container.addClass("select2-container-active"),this.dropdown.addClass("select2-drop-active"),this.clearPlaceholder())})),this.initContainerWidth(),this.opts.element.addClass("select2-offscreen"),this.clearSearch()},enableInterface:function(){this.parent.enableInterface.apply(this,arguments)&&this.search.prop("disabled",!this.isInterfaceEnabled())},initSelection:function(){if(""===this.opts.element.val()&&""===this.opts.element.text()&&(this.updateSelection([]),this.close(),this.clearSearch()),this.select||""!==this.opts.element.val()){var e=this;this.opts.initSelection.call(null,this.opts.element,function(s){s!==t&&null!==s&&(e.updateSelection(s),e.close(),e.clearSearch())})}},clearSearch:function(){var e=this.getPlaceholder(),s=this.getMaxSearchWidth();e!==t&&0===this.getVal().length&&this.search.hasClass("select2-focused")===!1?(this.search.val(e).addClass("select2-default"),this.search.width(s>0?s:this.container.css("width"))):this.search.val("").width(10)},clearPlaceholder:function(){this.search.hasClass("select2-default")&&this.search.val("").removeClass("select2-default")},opening:function(){this.clearPlaceholder(),this.resizeSearch(),this.parent.opening.apply(this,arguments),this.focusSearch(),this.updateResults(!0),this.search.focus(),this.opts.element.trigger(e.Event("select2-open"))},close:function(){this.opened()&&this.parent.close.apply(this,arguments)},focus:function(){this.close(),this.search.focus()},isFocused:function(){return this.search.hasClass("select2-focused")},updateSelection:function(t){var i=[],n=[],o=this;e(t).each(function(){s(o.id(this),i)<0&&(i.push(o.id(this)),n.push(this))}),t=n,this.selection.find(".select2-search-choice").remove(),e(t).each(function(){o.addSelectedChoice(this)}),o.postprocessResults()},tokenize:function(){var e=this.search.val();e=this.opts.tokenizer.call(this,e,this.data(),this.bind(this.onSelect),this.opts),null!=e&&e!=t&&(this.search.val(e),e.length>0&&this.open())},onSelect:function(e,t){this.triggerSelect(e)&&(this.addSelectedChoice(e),this.opts.element.trigger({type:"selected",val:this.id(e),choice:e}),(this.select||!this.opts.closeOnSelect)&&this.postprocessResults(),this.opts.closeOnSelect?(this.close(),this.search.width(10)):this.countSelectableResults()>0?(this.search.width(10),this.resizeSearch(),this.getMaximumSelectionSize()>0&&this.val().length>=this.getMaximumSelectionSize()&&this.updateResults(!0),this.positionDropdown()):(this.close(),this.search.width(10)),this.triggerChange({added:e}),t&&t.noFocus||this.focusSearch())},cancel:function(){this.close(),this.focusSearch()},addSelectedChoice:function(s){var i,n,o=!s.locked,a=e("<li class='select2-search-choice'> <div></div> <a href='#' onclick='return false;' class='select2-search-choice-close' tabindex='-1'></a></li>"),l=e("<li class='select2-search-choice select2-locked'><div></div></li>"),c=o?a:l,r=this.id(s),h=this.getVal();i=this.opts.formatSelection(s,c.find("div"),this.opts.escapeMarkup),i!=t&&c.find("div").replaceWith("<div>"+i+"</div>"),n=this.opts.formatSelectionCssClass(s,c.find("div")),n!=t&&c.addClass(n),o&&c.find(".select2-search-choice-close").on("mousedown",f).on("click dblclick",this.bind(function(t){this.isInterfaceEnabled()&&(e(t.target).closest(".select2-search-choice").fadeOut("fast",this.bind(function(){this.unselect(e(t.target)),this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus"),this.close(),this.focusSearch()})).dequeue(),f(t))})).on("focus",this.bind(function(){this.isInterfaceEnabled()&&(this.container.addClass("select2-container-active"),this.dropdown.addClass("select2-drop-active"))})),c.data("select2-data",s),c.insertBefore(this.searchContainer),h.push(r),this.setVal(h)},unselect:function(e){var t,i,n=this.getVal();if(e=e.closest(".select2-search-choice"),0===e.length)throw"Invalid argument: "+e+". Must be .select2-search-choice";t=e.data("select2-data"),t&&(i=s(this.id(t),n),i>=0&&(n.splice(i,1),this.setVal(n),this.select&&this.postprocessResults()),e.remove(),this.opts.element.trigger({type:"removed",val:this.id(t),choice:t}),this.triggerChange({removed:t}))},postprocessResults:function(e,t,i){var n=this.getVal(),o=this.results.find(".select2-result"),a=this.results.find(".select2-result-with-children"),l=this;o.each2(function(e,t){var i=l.id(t.data("select2-data"));s(i,n)>=0&&(t.addClass("select2-selected"),t.find(".select2-result-selectable").addClass("select2-selected"))}),a.each2(function(e,t){t.is(".select2-result-selectable")||0!==t.find(".select2-result-selectable:not(.select2-selected)").length||t.addClass("select2-selected")}),-1==this.highlight()&&i!==!1&&l.highlight(0),!this.opts.createSearchChoice&&!o.filter(".select2-result:not(.select2-selected)").length>0&&(!e||e&&!e.more&&0===this.results.find(".select2-no-results").length)&&x(l.opts.formatNoMatches,"formatNoMatches")&&this.results.append("<li class='select2-no-results'>"+l.opts.formatNoMatches(l.search.val())+"</li>")},getMaxSearchWidth:function(){return this.selection.width()-a(this.search)},resizeSearch:function(){var e,t,s,i,n,o=a(this.search);e=m(this.search)+10,t=this.search.offset().left,s=this.selection.width(),i=this.selection.offset().left,n=s-(t-i)-o,e>n&&(n=s-o),40>n&&(n=s-o),0>=n&&(n=e),this.search.width(n)},getVal:function(){var e;return this.select?(e=this.select.val(),null===e?[]:e):(e=this.opts.element.val(),o(e,this.opts.separator))},setVal:function(t){var i;this.select?this.select.val(t):(i=[],e(t).each(function(){s(this,i)<0&&i.push(this)}),this.opts.element.val(0===i.length?"":i.join(this.opts.separator)))},buildChangeDetails:function(e,t){for(var t=t.slice(0),e=e.slice(0),s=0;s<t.length;s++)for(var i=0;i<e.length;i++)n(this.opts.id(t[s]),this.opts.id(e[i]))&&(t.splice(s,1),s--,e.splice(i,1),i--);return{added:t,removed:e}},val:function(s,i){var n,o=this;if(0===arguments.length)return this.getVal();if(n=this.data(),n.length||(n=[]),!s&&0!==s)return this.opts.element.val(""),this.updateSelection([]),this.clearSearch(),void(i&&this.triggerChange({added:this.data(),removed:n}));if(this.setVal(s),this.select)this.opts.initSelection(this.select,this.bind(this.updateSelection)),i&&this.triggerChange(this.buildChangeDetails(n,this.data()));else{if(this.opts.initSelection===t)throw new Error("val() cannot be called if initSelection() is not defined");this.opts.initSelection(this.opts.element,function(t){var s=e.map(t,o.id);o.setVal(s),o.updateSelection(t),o.clearSearch(),i&&o.triggerChange(this.buildChangeDetails(n,this.data()))})}this.clearSearch()},onSortStart:function(){if(this.select)throw new Error("Sorting of elements is not supported when attached to <select>. Attach to <input type='hidden'/> instead.");this.search.width(0),this.searchContainer.hide()},onSortEnd:function(){var t=[],s=this;this.searchContainer.show(),this.searchContainer.appendTo(this.searchContainer.parent()),this.resizeSearch(),this.selection.find(".select2-search-choice").each(function(){t.push(s.opts.id(e(this).data("select2-data")))}),this.setVal(t),this.triggerChange()},data:function(t,s){var i,n,o=this;return 0===arguments.length?this.selection.find(".select2-search-choice").map(function(){return e(this).data("select2-data")}).get():(n=this.data(),t||(t=[]),i=e.map(t,function(e){return o.opts.id(e)}),this.setVal(i),this.updateSelection(t),this.clearSearch(),s&&this.triggerChange(this.buildChangeDetails(n,this.data())),void 0)}}),e.fn.select2=function(){var i,n,o,a,l,c=Array.prototype.slice.call(arguments,0),r=["val","destroy","opened","open","close","focus","isFocused","container","dropdown","onSortStart","onSortEnd","enable","readonly","positionDropdown","data","search"],h=["val","opened","isFocused","container","data"],d={search:"externalSearch"};return this.each(function(){if(0===c.length||"object"==typeof c[0])i=0===c.length?{}:e.extend({},c[0]),i.element=e(this),"select"===i.element.get(0).tagName.toLowerCase()?l=i.element.prop("multiple"):(l=i.multiple||!1,"tags"in i&&(i.multiple=l=!0)),n=l?new D:new R,n.init(i);else{if("string"!=typeof c[0])throw"Invalid arguments to select2 plugin: "+c;if(s(c[0],r)<0)throw"Unknown method: "+c[0];if(a=t,n=e(this).data("select2"),n===t)return;if(o=c[0],"container"===o?a=n.container:"dropdown"===o?a=n.dropdown:(d[o]&&(o=d[o]),a=n[o].apply(n,c.slice(1))),s(c[0],h)>=0)return!1}}),a===t?this:a},e.fn.select2.defaults={width:"copy",indentChar:" ",treeview:!1,treeviewInitState:"expanded",treeviewExpandedClass:"glyphicon glyphicon-chevron-down",treeviewCollapsedClass:"glyphicon glyphicon-chevron-right",loadMorePadding:0,closeOnSelect:!0,openOnEnter:!0,containerCss:{},dropdownCss:{},containerCssClass:"",dropdownCssClass:"",formatResult:function(e,t,s,i){var n=[];return C(e.text,s.term,n,i),n.join("")},formatSelection:function(e,s,i){return e?i(e.text):t},sortResults:function(e){return e},formatResultCssClass:function(){return t},formatSelectionCssClass:function(){return t},formatNoMatches:function(){return"No matches found"},formatInputTooShort:function(e,t){var s=t-e.length;return"Please enter "+s+" more character"+(1==s?"":"s")},formatInputTooLong:function(e,t){var s=e.length-t;return"Please delete "+s+" character"+(1==s?"":"s")},formatSelectionTooBig:function(e){return"You can only select "+e+" item"+(1==e?"":"s")},formatLoadMore:function(){return"Loading more results..."},formatSearching:function(){return"Searching..."},minimumResultsForSearch:0,minimumInputLength:0,maximumInputLength:null,maximumSelectionSize:0,id:function(e){return e.id},matcher:function(e,t){return(""+t).toUpperCase().indexOf((""+e).toUpperCase())>=0},separator:",",tokenSeparators:[],tokenizer:k,escapeMarkup:w,blurOnChange:!1,selectOnBlur:!1,adaptContainerCssClass:function(e){return e},adaptDropdownCssClass:function(){return null}},e.fn.select2.ajaxDefaults={transport:e.ajax,params:{type:"GET",cache:!1,dataType:"json"}},window.Select2={query:{ajax:b,local:S,tags:y},util:{debounce:r,markMatch:C,escapeMarkup:w},"class":{"abstract":O,single:R,multi:D}}}}(t),e("./i18n/{locale}")});
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。