]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/jquery/suggest.min.js
WordPress 3.9-scripts
[autoinstalls/wordpress.git] / wp-includes / js / jquery / suggest.min.js
index 904936f3de5491ba8b484db8ea24adfb82257b30..b4fca2ba1f34a197a69cd91b5b6b3819250bf2da 100644 (file)
@@ -1 +1 @@
-(function(a){a.suggest=function(o,g){var c,f,n,d,q,p;c=a(o).attr("autocomplete","off");f=a(document.createElement("ul"));n=false;d=0;q=[];p=0;f.addClass(g.resultsClass).appendTo("body");j();a(window).load(j).resize(j);c.blur(function(){setTimeout(function(){f.hide()},200)});if(a.browser.msie){try{f.bgiframe()}catch(s){}}if(a.browser.mozilla){c.keypress(m)}else{c.keydown(m)}function j(){var e=c.offset();f.css({top:(e.top+o.offsetHeight)+"px",left:e.left+"px"})}function m(w){if((/27$|38$|40$/.test(w.keyCode)&&f.is(":visible"))||(/^13$|^9$/.test(w.keyCode)&&u())){if(w.preventDefault){w.preventDefault()}if(w.stopPropagation){w.stopPropagation()}w.cancelBubble=true;w.returnValue=false;switch(w.keyCode){case 38:k();break;case 40:t();break;case 9:case 13:r();break;case 27:f.hide();break}}else{if(c.val().length!=d){if(n){clearTimeout(n)}n=setTimeout(l,g.delay);d=c.val().length}}}function l(){var x=a.trim(c.val()),w,e;if(g.multiple){w=x.lastIndexOf(g.multipleSep);if(w!=-1){x=a.trim(x.substr(w+g.multipleSep.length))}}if(x.length>=g.minchars){cached=v(x);if(cached){i(cached.items)}else{a.get(g.source,{q:x},function(y){f.hide();e=b(y,x);i(e);h(x,e,y.length)})}}else{f.hide()}}function v(w){var e;for(e=0;e<q.length;e++){if(q[e]["q"]==w){q.unshift(q.splice(e,1)[0]);return q[0]}}return false}function h(y,e,w){var x;while(q.length&&(p+w>g.maxCacheSize)){x=q.pop();p-=x.size}q.push({q:y,size:w,items:e});p+=w}function i(e){var x="",w;if(!e){return}if(!e.length){f.hide();return}j();for(w=0;w<e.length;w++){x+="<li>"+e[w]+"</li>"}f.html(x).show();f.children("li").mouseover(function(){f.children("li").removeClass(g.selectClass);a(this).addClass(g.selectClass)}).click(function(y){y.preventDefault();y.stopPropagation();r()})}function b(e,z){var w=[],A=e.split(g.delimiter),y,x;for(y=0;y<A.length;y++){x=a.trim(A[y]);if(x){x=x.replace(new RegExp(z,"ig"),function(B){return'<span class="'+g.matchClass+'">'+B+"</span>"});w[w.length]=x}}return w}function u(){var e;if(!f.is(":visible")){return false}e=f.children("li."+g.selectClass);if(!e.length){e=false}return e}function r(){$currentResult=u();if($currentResult){if(g.multiple){if(c.val().indexOf(g.multipleSep)!=-1){$currentVal=c.val().substr(0,(c.val().lastIndexOf(g.multipleSep)+g.multipleSep.length))}else{$currentVal=""}c.val($currentVal+$currentResult.text()+g.multipleSep);c.focus()}else{c.val($currentResult.text())}f.hide();if(g.onSelect){g.onSelect.apply(c[0])}}}function t(){$currentResult=u();if($currentResult){$currentResult.removeClass(g.selectClass).next().addClass(g.selectClass)}else{f.children("li:first-child").addClass(g.selectClass)}}function k(){var e=u();if(e){e.removeClass(g.selectClass).prev().addClass(g.selectClass)}else{f.children("li:last-child").addClass(g.selectClass)}}};a.fn.suggest=function(c,b){if(!c){return}b=b||{};b.multiple=b.multiple||false;b.multipleSep=b.multipleSep||", ";b.source=c;b.delay=b.delay||100;b.resultsClass=b.resultsClass||"ac_results";b.selectClass=b.selectClass||"ac_over";b.matchClass=b.matchClass||"ac_match";b.minchars=b.minchars||2;b.delimiter=b.delimiter||"\n";b.onSelect=b.onSelect||false;b.maxCacheSize=b.maxCacheSize||65536;this.each(function(){new a.suggest(this,b)});return this}})(jQuery);
\ No newline at end of file
+!function(a){a.suggest=function(b,c){function d(){var a=o.offset();p.css({top:a.top+b.offsetHeight+"px",left:a.left+"px"})}function e(a){if(/27$|38$|40$/.test(a.keyCode)&&p.is(":visible")||/^13$|^9$/.test(a.keyCode)&&k())switch(a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0,a.returnValue=!1,a.keyCode){case 38:n();break;case 40:m();break;case 9:case 13:l();break;case 27:p.hide()}else o.val().length!=r&&(q&&clearTimeout(q),q=setTimeout(f,c.delay),r=o.val().length)}function f(){var b,d,e=a.trim(o.val());c.multiple&&(b=e.lastIndexOf(c.multipleSep),-1!=b&&(e=a.trim(e.substr(b+c.multipleSep.length)))),e.length>=c.minchars?(cached=g(e),cached?i(cached.items):a.get(c.source,{q:e},function(a){p.hide(),d=j(a,e),i(d),h(e,d,a.length)})):p.hide()}function g(a){var b;for(b=0;b<s.length;b++)if(s[b].q==a)return s.unshift(s.splice(b,1)[0]),s[0];return!1}function h(a,b,d){for(var e;s.length&&t+d>c.maxCacheSize;)e=s.pop(),t-=e.size;s.push({q:a,size:d,items:b}),t+=d}function i(b){var e,f="";if(b){if(!b.length)return void p.hide();for(d(),e=0;e<b.length;e++)f+="<li>"+b[e]+"</li>";p.html(f).show(),p.children("li").mouseover(function(){p.children("li").removeClass(c.selectClass),a(this).addClass(c.selectClass)}).click(function(a){a.preventDefault(),a.stopPropagation(),l()})}}function j(b,d){var e,f,g=[],h=b.split(c.delimiter);for(e=0;e<h.length;e++)f=a.trim(h[e]),f&&(f=f.replace(new RegExp(d,"ig"),function(a){return'<span class="'+c.matchClass+'">'+a+"</span>"}),g[g.length]=f);return g}function k(){var a;return p.is(":visible")?(a=p.children("li."+c.selectClass),a.length||(a=!1),a):!1}function l(){$currentResult=k(),$currentResult&&(c.multiple?($currentVal=-1!=o.val().indexOf(c.multipleSep)?o.val().substr(0,o.val().lastIndexOf(c.multipleSep)+c.multipleSep.length):"",o.val($currentVal+$currentResult.text()+c.multipleSep),o.focus()):o.val($currentResult.text()),p.hide(),o.trigger("change"),c.onSelect&&c.onSelect.apply(o[0]))}function m(){$currentResult=k(),$currentResult?$currentResult.removeClass(c.selectClass).next().addClass(c.selectClass):p.children("li:first-child").addClass(c.selectClass)}function n(){var a=k();a?a.removeClass(c.selectClass).prev().addClass(c.selectClass):p.children("li:last-child").addClass(c.selectClass)}var o,p,q,r,s,t;o=a(b).attr("autocomplete","off"),p=a("<ul/>"),q=!1,r=0,s=[],t=0,p.addClass(c.resultsClass).appendTo("body"),d(),a(window).load(d).resize(d),o.blur(function(){setTimeout(function(){p.hide()},200)}),o.keydown(e)},a.fn.suggest=function(b,c){return b?(c=c||{},c.multiple=c.multiple||!1,c.multipleSep=c.multipleSep||", ",c.source=b,c.delay=c.delay||100,c.resultsClass=c.resultsClass||"ac_results",c.selectClass=c.selectClass||"ac_over",c.matchClass=c.matchClass||"ac_match",c.minchars=c.minchars||2,c.delimiter=c.delimiter||"\n",c.onSelect=c.onSelect||!1,c.maxCacheSize=c.maxCacheSize||65536,this.each(function(){new a.suggest(this,c)}),this):void 0}}(jQuery);
\ No newline at end of file