1 line
40 KiB
JavaScript
1 line
40 KiB
JavaScript
|
(function(a,b){if(typeof define==="function"&&define.amd){define(["jquery","sifter","microplugin"],b)}else{if(typeof exports==="object"){module.exports=b(require("jquery"),require("sifter"),require("microplugin"))}else{a.Selectize=b(a.jQuery,a.Sifter,a.MicroPlugin)}}}(this,function(v,m,i){var M=function(P,S){if(typeof S==="string"&&!S.length){return}var R=(typeof S==="string")?new RegExp(S,"i"):S;var Q=function(V){var ab=0;if(V.nodeType===3){var aa=V.data.search(R);if(aa>=0&&V.data.length>0){var Z=V.data.match(R);var Y=document.createElement("span");Y.className="highlight";var W=V.splitText(aa);var T=W.splitText(Z[0].length);var U=W.cloneNode(true);Y.appendChild(U);W.parentNode.replaceChild(Y,W);ab=1}}else{if(V.nodeType===1&&V.childNodes&&!/(script|style)/i.test(V.tagName)){for(var X=0;X<V.childNodes.length;++X){X+=Q(V.childNodes[X])}}}return ab};return P.each(function(){Q(this)})};v.fn.removeHighlight=function(){return this.find("span.highlight").each(function(){this.parentNode.firstChild.nodeName;var P=this.parentNode;P.replaceChild(this.firstChild,this);P.normalize()}).end()};var G=function(){};G.prototype={on:function(Q,P){this._events=this._events||{};this._events[Q]=this._events[Q]||[];this._events[Q].push(P)},off:function(Q,P){var R=arguments.length;if(R===0){return delete this._events}if(R===1){return delete this._events[Q]}this._events=this._events||{};if(Q in this._events===false){return}this._events[Q].splice(this._events[Q].indexOf(P),1)},trigger:function(Q){this._events=this._events||{};if(Q in this._events===false){return}for(var P=0;P<this._events[Q].length;P++){this._events[Q][P].apply(this,Array.prototype.slice.call(arguments,1))}}};G.mixin=function(P){var R=["on","off","trigger"];for(var Q=0;Q<R.length;Q++){P.prototype[R[Q]]=G.prototype[R[Q]]}};var b=/Mac/.test(navigator.userAgent);var I=65;var N=188;var z=13;var w=27;var p=37;var H=38;var x=80;var t=39;var u=40;var B=78;var o=8;var q=46;var j=16;var J=b?91:17;var e=b?18:17;var F=9;var k=1;var h=2;var C=!/android/i.test(window.navigator.userAgent)&&!!document.createElement("input").validity;var O=function(P){return typeof P!=="undefined"};var y=function(P){if(typeof P==="undefined"||P===null){return null}if(typeof P==="boolean"){return P?"1":"0"}return P+""};var D=function(P){return(P+"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")};var f=function(P){return(P+"").replace(/\$/g,"$$$$")};var s={};s.before=function(P,S,R){var Q=P[S];P[S]=function(){R.apply(P,arguments);return Q.apply(P,arguments)}};s.after=function(P,S,R){var Q=P[S];P[S]=function(){var T=Q.apply(P,arguments);R.apply(P,arguments);return T}};var r=function(P){var Q=false;return function(){if(Q){return}Q=true;P.apply(this,arguments)}};var g=function(Q,P){var R;return function(){var S=this;var T=arguments;window.clearTimeout(R);R=window.setTimeout(function(){Q.apply(S,T)},P)}};var a=function(P,R,T){var S;var Q=P.trigger;var U={};P.trigger=function(){var V=arguments[0];if(R.indexOf(V)!==-1){U[V]=arguments}else{return Q.apply(P,arguments)}};T.apply(P,[]);P.trigger=Q;for(S in U){if(U.hasOwnProperty(S)){Q.apply(P,U[S])}}};var A=function(S,R,P,Q){S.on(R,P,function(T){var U=T.target;while(U&&U.parentNode!==S[0]){U=U.parentNode}T.currentTarget=U;return Q.apply(this,[T])})};var l=function(R){var Q={};if("selectionStart" in R){Q.start=R.selectionStart;Q.length=R.selectionEnd-Q.start}else{if(document.selection){R.focus();var S=document.selection.createRange();var P=document.selection.createRange().text.length;S.moveStart("character",-R.value.length);Q.start=S.text.length-P;Q.length=P}}return Q};var n=function(S,T,Q){var P,U,R={};if(Q){for(P=0,U=Q.length;P<U;P++){R[Q[P]]=S.css(Q[P])}}else{R=S.css()}T.css(R)};var K=function(S,R){if(!S){return 0}var Q=v("<test>").css({position:"absolute",top:-99999,left:-99999,width:"auto",padding:0,whiteSpace:"pre"}).text(S).appendTo("body");n(R,Q,["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"]);var P=Q.width();Q.remove();return P};var L=function(R){var P=null;var Q=function(V,ab){var Z,aa,W,Y,S;var T,U,X;
|