You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
10 lines
70 KiB
Plaintext
10 lines
70 KiB
Plaintext
11 months ago
|
/*!
|
||
|
* Select2 4.0.3
|
||
|
* https://select2.github.io
|
||
|
*
|
||
|
* Released under the MIT license
|
||
|
* https://github.com/select2/select2/blob/master/LICENSE.md
|
||
|
*/
|
||
|
(function(a){if(typeof define==="function"&&define.amd){define(["jquery"],a)}else{if(typeof exports==="object"){a(require("jquery"))}else{a(jQuery)}}}(function(c){var b=(function(){if(c&&c.fn&&c.fn.select2&&c.fn.select2.amd){var d=c.fn.select2.amd}var d;(function(){if(!d||!d.requirejs){if(!d){d={}}else{e=d}var f,e,g;(function(l){var o,h,s,t,k={},j={},z={},w={},r=Object.prototype.hasOwnProperty,p=[].slice,q=/\.js$/;function A(B,C){return r.call(B,C)}function u(E,C){var M,I,G,J,N,F,P,Q,L,K,H,O=C&&C.split("/"),D=z.map,B=(D&&D["*"])||{};if(E&&E.charAt(0)==="."){if(C){E=E.split("/");N=E.length-1;if(z.nodeIdCompat&&q.test(E[N])){E[N]=E[N].replace(q,"")}E=O.slice(0,O.length-1).concat(E);for(L=0;L<E.length;L+=1){H=E[L];if(H==="."){E.splice(L,1);L-=1}else{if(H===".."){if(L===1&&(E[2]===".."||E[0]==="..")){break}else{if(L>0){E.splice(L-1,2);L-=2}}}}}E=E.join("/")}else{if(E.indexOf("./")===0){E=E.substring(2)}}}if((O||B)&&D){M=E.split("/");for(L=M.length;L>0;L-=1){I=M.slice(0,L).join("/");if(O){for(K=O.length;K>0;K-=1){G=D[O.slice(0,K).join("/")];if(G){G=G[I];if(G){J=G;F=L;break}}}}if(J){break}if(!P&&B&&B[I]){P=B[I];Q=L}}if(!J&&P){J=P;F=Q}if(J){M.splice(0,F,J);E=M.join("/")}}return E}function y(B,C){return function(){var D=p.call(arguments,0);if(typeof D[0]!=="string"&&D.length===1){D.push(null)}return h.apply(l,D.concat([B,C]))}}function v(B){return function(C){return u(C,B)}}function m(B){return function(C){k[B]=C}}function n(C){if(A(j,C)){var B=j[C];delete j[C];w[C]=true;o.apply(l,B)}if(!A(k,C)&&!A(w,C)){throw new Error("No "+C)}return k[C]}function x(C){var D,B=C?C.indexOf("!"):-1;if(B>-1){D=C.substring(0,B);C=C.substring(B+1,C.length)}return[D,C]}s=function(C,B){var D,F=x(C),E=F[0];C=F[1];if(E){E=u(E,B);D=n(E)}if(E){if(D&&D.normalize){C=D.normalize(C,v(B))}else{C=u(C,B)}}else{C=u(C,B);F=x(C);E=F[0];C=F[1];if(E){D=n(E)}}return{f:E?E+"!"+C:C,n:C,pr:E,p:D}};function i(B){return function(){return(z&&z.config&&z.config[B])||{}}}t={require:function(B){return y(B)},exports:function(B){var C=k[B];if(typeof C!=="undefined"){return C}else{return(k[B]={})}},module:function(B){return{id:B,uri:"",exports:k[B],config:i(B)}}};o=function(C,M,L,K){var F,J,G,B,E,H=[],D=typeof L,I;K=K||C;if(D==="undefined"||D==="function"){M=!M.length&&L.length?["require","exports","module"]:M;for(E=0;E<M.length;E+=1){B=s(M[E],K);J=B.f;if(J==="require"){H[E]=t.require(C)}else{if(J==="exports"){H[E]=t.exports(C);I=true}else{if(J==="module"){F=H[E]=t.module(C)}else{if(A(k,J)||A(j,J)||A(w,J)){H[E]=n(J)}else{if(B.p){B.p.load(B.n,y(K,true),m(J),{});H[E]=k[J]}else{throw new Error(C+" missing "+J)}}}}}}G=L?L.apply(k[C],H):undefined;if(C){if(F&&F.exports!==l&&F.exports!==k[C]){k[C]=F.exports}else{if(G!==l||!I){k[C]=G}}}}else{if(C){k[C]=L}}};f=e=h=function(E,F,B,C,D){if(typeof E==="string"){if(t[E]){return t[E](F)}return n(s(E,F).f)}else{if(!E.splice){z=E;if(z.deps){h(z.deps,z.callback)}if(!F){return}if(F.splice){E=F;F=B;B=null}else{E=l}}}F=F||function(){};if(typeof B==="function"){B=C;C=D}if(C){o(l,E,F,B)}else{setTimeout(function(){o(l,E,F,B)},4)}return h};h.config=function(B){return h(B)};f._defined=k;g=function(B,C,D){if(typeof B!=="string"){throw new Error("See almond README: incorrect module build, no module name")}if(!C.splice){D=C;C=[]}if(!A(k,B)&&!A(j,B)){j[B]=[B,C,D]}};g.amd={jQuery:true}}());d.requirejs=f;d.require=e;d.define=g}}());d.define("almond",function(){});d.define("jquery",[],function(){var e=c||$;if(e==null&&console&&console.error){console.error("Select2: An instance of jQuery or a jQuery-compatible library was not found. Make sure that you are including jQuery before Select2 on your web page.")}return e});d.define("select2/utils",["jquery"],function(h){var g={};g.Extend=function(m,j){var k={}.hasOwnProperty;function i(){this.constructor=m}for(var l in j){if(k.call(j,l)){m[l]=j[l]}}i.prototype=j.prototype;m.prototype=new i();m.__super__=j.prototype;return m};function f(n){var l=n.prototype;var k=[];for(var j in l){var i=l[j];if(typeof i!=="function"){continue}if(j==="constructor"){continue}k.push(j)}return k}g.Decorate=function(q,p){var o=f(p);var n=
|
||
|
return e});d.define("select2/data/base",["../utils"],function(f){function e(g,h){e.__super__.constructor.call(this)}f.Extend(e,f.Observable);e.prototype.current=function(g){throw new Error("The `current` method must be defined in child classes.")};e.prototype.query=function(g,h){throw new Error("The `query` method must be defined in child classes.")};e.prototype.bind=function(g,h){};e.prototype.destroy=function(){};e.prototype.generateResultId=function(g,h){var i=g.id+"-result-";i+=f.generateChars(4);if(h.id!=null){i+="-"+h.id.toString()}else{i+="-"+f.generateChars(4)}return i};return e});d.define("select2/data/select",["./base","../utils","jquery"],function(e,h,g){function f(i,j){this.$element=i;this.options=j;f.__super__.constructor.call(this)}h.Extend(f,e);f.prototype.current=function(k){var j=[];var i=this;this.$element.find(":selected").each(function(){var m=g(this);var l=i.item(m);j.push(l)});k(j)};f.prototype.select=function(j){var i=this;j.selected=true;if(g(j.element).is("option")){j.element.selected=true;this.$element.trigger("change");return}if(this.$element.prop("multiple")){this.current(function(l){var n=[];j=[j];j.push.apply(j,l);for(var m=0;m<j.length;m++){var o=j[m].id;if(g.inArray(o,n)===-1){n.push(o)}}i.$element.val(n);i.$element.trigger("change")})}else{var k=j.id;this.$element.val(k);this.$element.trigger("change")}};f.prototype.unselect=function(j){var i=this;if(!this.$element.prop("multiple")){return}j.selected=false;if(g(j.element).is("option")){j.element.selected=false;this.$element.trigger("change");return}this.current(function(k){var m=[];for(var l=0;l<k.length;l++){var n=k[l].id;if(n!==j.id&&g.inArray(n,m)===-1){m.push(n)}}i.$element.val(m);i.$element.trigger("change")})};f.prototype.bind=function(i,k){var j=this;this.container=i;i.on("select",function(l){j.select(l.data)});i.on("unselect",function(l){j.unselect(l.data)})};f.prototype.destroy=function(){this.$element.find("*").each(function(){g.removeData(this,"data")})};f.prototype.query=function(l,m){var k=[];var j=this;var i=this.$element.children();i.each(function(){var p=g(this);if(!p.is("option")&&!p.is("optgroup")){return}var n=j.item(p);var o=j.matches(l,n);if(o!==null){k.push(o)}});m({results:k})};f.prototype.addOptions=function(i){h.appendMany(this.$element,i)};f.prototype.option=function(j){var i;if(j.children){i=document.createElement("optgroup");i.label=j.text}else{i=document.createElement("option");if(i.textContent!==undefined){i.textContent=j.text}else{i.innerText=j.text}}if(j.id){i.value=j.id}if(j.disabled){i.disabled=true}if(j.selected){i.selected=true}if(j.title){i.title=j.title}var k=g(i);var l=this._normalizeItem(j);l.element=i;g.data(i,"data",l);return k};f.prototype.item=function(m){var l={};l=g.data(m[0],"data");if(l!=null){return l}if(m.is("option")){l={id:m.val(),text:m.text(),disabled:m.prop("disabled"),selected:m.prop("selected"),title:m.prop("title")}}else{if(m.is("optgroup")){l={text:m.prop("label"),children:[],title:m.prop("title")};var i=m.children("option");var j=[];for(var o=0;o<i.length;o++){var k=g(i[o]);var n=this.item(k);j.push(n)}l.children=j}}l=this._normalizeItem(l);l.element=m[0];g.data(m[0],"data",l);return l};f.prototype._normalizeItem=function(i){if(!g.isPlainObject(i)){i={id:i,text:i}}i=g.extend({},{text:""},i);var j={selected:false,disabled:false};if(i.id!=null){i.id=i.id.toString()}if(i.text!=null){i.text=i.text.toString()}if(i._resultId==null&&i.id&&this.container!=null){i._resultId=this.generateResultId(this.container,i)}return g.extend({},j,i)};f.prototype.matches=function(k,i){var j=this.options.get("matcher");return j(k,i)};return f});d.define("select2/data/array",["./select","../utils","jquery"],function(e,g,f){function h(i,j){var k=j.get("data")||[];h.__super__.constructor.call(this,i,j);this.addOptions(this.convertToOptions(k))}g.Extend(h,e);h.prototype.select=function(i){var j=this.$element.find("option").filter(function(k,l){return l.value==i.id.toString()});if(j.length===0){j=this.option(i);this.addOptions(j)}h.__super__.select.call(this,i)};h.prototype.convertToOptions=function(k){var
|
||
|
if(j.isOpen()){if(l===e.ESC||l===e.TAB||(l===e.UP&&k.altKey)){j.close();k.preventDefault()}else{if(l===e.ENTER){j.trigger("results:select",{});k.preventDefault()}else{if((l===e.SPACE&&k.ctrlKey)){j.trigger("results:toggle",{});k.preventDefault()}else{if(l===e.UP){j.trigger("results:previous",{});k.preventDefault()}else{if(l===e.DOWN){j.trigger("results:next",{});k.preventDefault()}}}}}}else{if(l===e.SPACE||(l===e.DOWN&&k.altKey)){j.open();k.preventDefault()}}})};f.prototype._syncAttributes=function(){this.options.set("disabled",this.$element.prop("disabled"));if(this.options.get("disabled")){if(this.isOpen()){this.close()}this.trigger("disable",{})}else{this.trigger("enable",{})}};f.prototype._syncSubtree=function(k,j){var o=false;var l=this;if(k&&k.target&&(k.target.nodeName!=="OPTION"&&k.target.nodeName!=="OPTGROUP")){return}if(!j){o=true}else{if(j.addedNodes&&j.addedNodes.length>0){for(var p=0;p<j.addedNodes.length;p++){var m=j.addedNodes[p];if(m.selected){o=true}}}else{if(j.removedNodes&&j.removedNodes.length>0){o=true}}}if(o){this.dataAdapter.current(function(n){l.trigger("selection:update",{data:n})})}};f.prototype.trigger=function(m,l){var n=f.__super__.trigger;var o={open:"opening",close:"closing",select:"selecting",unselect:"unselecting"};if(l===undefined){l={}}if(m in o){var k=o[m];var j={prevented:false,name:m,args:l};n.call(this,k,j);if(j.prevented){l.prevented=true;return}}n.call(this,m,l)};f.prototype.toggleDropdown=function(){if(this.options.get("disabled")){return}if(this.isOpen()){this.close()}else{this.open()}};f.prototype.open=function(){if(this.isOpen()){return}this.trigger("query",{})};f.prototype.close=function(){if(!this.isOpen()){return}this.trigger("close",{})};f.prototype.isOpen=function(){return this.$container.hasClass("select2-container--open")};f.prototype.hasFocus=function(){return this.$container.hasClass("select2-container--focus")};f.prototype.focus=function(j){if(this.hasFocus()){return}this.$container.addClass("select2-container--focus");this.trigger("focus",{})};f.prototype.enable=function(j){if(this.options.get("debug")&&window.console&&console.warn){console.warn('Select2: The `select2("enable")` method has been deprecated and will be removed in later Select2 versions. Use $element.prop("disabled") instead.')}if(j==null||j.length===0){j=[true]}var k=!j[0];this.$element.prop("disabled",k)};f.prototype.data=function(){if(this.options.get("debug")&&arguments.length>0&&window.console&&console.warn){console.warn('Select2: Data can no longer be set using `select2("data")`. You should consider setting the value instead using `$element.val()`.')}var j=[];this.dataAdapter.current(function(k){j=k});return j};f.prototype.val=function(k){if(this.options.get("debug")&&window.console&&console.warn){console.warn('Select2: The `select2("val")` method has been deprecated and will be removed in later Select2 versions. Use $element.val() instead.')}if(k==null||k.length===0){return this.$element.val()}var j=k[0];if(i.isArray(j)){j=i.map(j,function(l){return l.toString()})}this.$element.val(j).trigger("change")};f.prototype.destroy=function(){this.$container.remove();if(this.$element[0].detachEvent){this.$element[0].detachEvent("onpropertychange",this._syncA)}if(this._observer!=null){this._observer.disconnect();this._observer=null}else{if(this.$element[0].removeEventListener){this.$element[0].removeEventListener("DOMAttrModified",this._syncA,false);this.$element[0].removeEventListener("DOMNodeInserted",this._syncS,false);this.$element[0].removeEventListener("DOMNodeRemoved",this._syncS,false)}}this._syncA=null;this._syncS=null;this.$element.off(".select2");this.$element.attr("tabindex",this.$element.data("old-tabindex"));this.$element.removeClass("select2-hidden-accessible");this.$element.attr("aria-hidden","false");this.$element.removeData("select2");this.dataAdapter.destroy();this.selection.destroy();this.dropdown.destroy();this.results.destroy();this.dataAdapter=null;this.selection=null;this.dropdown=null;this.results=null};f.prototype.render=function(){var j=i('<span class="select2 select2-container
|