10 lines
13 KiB
JavaScript
10 lines
13 KiB
JavaScript
|
/*
|
||
|
* jQuery FlexBox $Version: 0.9.6 $
|
||
|
*
|
||
|
* Copyright (c) 2008-2010 Noah Heldman and Fairway Technologies (http://www.fairwaytech.com/flexbox)
|
||
|
* Licensed under Ms-PL (http://www.codeplex.com/flexbox/license)
|
||
|
*
|
||
|
* $Date: 2010-11-24 01:02:00 PM $
|
||
|
* $Rev: 0.9.6.1 $
|
||
|
*/
|
||
|
(function(a){a.flexbox=function(N,I){var K=false,p=[],J=[],f=0,l="\u25CA",Q=false,x=I.paging&&I.paging.pageSize?I.paging.pageSize:0,F=false,D=a(N).css("position","relative").css("z-index",0);var P=a('<input type="hidden"/>').attr("id",D.attr("id")+"_hidden").attr("name",D.attr("id")).val(I.initialId).appendTo(D);var z=a("<input/>").attr("id",D.attr("id")+"_input").attr("autocomplete","off").addClass(I.inputClass).css("width",I.width+"px").appendTo(D).click(function(o){if(I.watermark!==""&&this.value===I.watermark){this.value=""}else{this.select()}}).focus(function(o){a(this).removeClass("watermark")}).blur(function(o){if(this.value===""){P.val("")}setTimeout(function(){if(!z.data("active")){b()}},200)}).keydown(L);if(I.initialValue!==""){z.val(I.initialValue).removeClass("watermark")}else{z.val(I.watermark).addClass("watermark")}var g=0;if(I.showArrow&&I.showResults){var E=function(){if(q.is(":visible")){b()}else{z.focus();if(I.watermark!==""&&z.val()===I.watermark){z.val("")}else{z.select()}if(K){clearTimeout(K)}K=setTimeout(function(){G(1,true,I.arrowQuery)},I.queryDelay)}};var i=a("<span></span>").attr("id",D.attr("id")+"_arrow").addClass(I.arrowClass).addClass("out").hover(function(){a(this).removeClass("out").addClass("over")},function(){a(this).removeClass("over").addClass("out")}).mousedown(function(){a(this).removeClass("over").addClass("active")}).mouseup(function(){a(this).removeClass("active").addClass("over")}).click(E).appendTo(D);g=i.width();z.css("width",(I.width-g)+"px")}if(!I.allowInput){I.selectFirstMatch=false;z.click(E)}var O=z.outerHeight()-z.height()-2;var s=z.outerWidth()-2;var j=z.outerHeight();if(O===0){s+=4;j+=4}else{if(O!==4){s+=O;j+=O}}var q=a("<div></div>").attr("id",D.attr("id")+"_ctr").css("width",s+g).css("top",j).css("left",0).addClass(I.containerClass).appendTo(D).mousedown(function(o){z.data("active",true)}).hide();var c=a("<div></div>").addClass(I.contentClass).appendTo(q).scroll(function(){Q=true});var u=a("<div></div>").appendTo(q);D.css("height",z.outerHeight());function L(X){var V=0;if(typeof(X.ctrlKey)!=="undefined"){if(X.ctrlKey){V|=1}if(X.shiftKey){V|=2}}else{if(X.modifiers&Event.CONTROL_MASK){V|=1}if(X.modifiers&Event.SHIFT_MASK){V|=2}}if(/16$|17$/.test(X.keyCode)){return}var W=X.keyCode===9,U=X.keyCode===27;var T=X.keyCode===9&&V>0;var o=X.keyCode===8;if(W){if(k()){w()}}if((/27$|38$|33$|34$/.test(X.keyCode)&&q.is(":visible"))||(/13$|40$/.test(X.keyCode))||!I.allowInput){if(X.preventDefault){X.preventDefault()}if(X.stopPropagation){X.stopPropagation()}X.cancelBubble=true;X.returnValue=false;switch(X.keyCode){case 38:M();break;case 40:if(q.is(":visible")){t()}else{v(true)}break;case 13:if(k()){w()}else{v(true)}break;case 27:b();break;case 34:if(!F){if(I.paging){a("#"+D.attr("id")+"n").click()}else{R()}}break;case 33:if(!F){if(I.paging){a("#"+D.attr("id")+"p").click()}else{H()}}break;default:if(!I.allowInput){return}}}else{if(!U&&!W&&!T){v(false,o)}}}function v(o,U){if(K){clearTimeout(K)}var T=U?I.queryDelay*5:I.queryDelay;K=setTimeout(function(){G(1,o,"")},T)}function G(W,T,V){if(T){V=""}var U=V&&V.length>0?V:a.trim(z.val());if(U.length>=I.minChars||T){if(c.outerHeight()>0){c.css("height",c.outerHeight())}c.html("").attr("scrollTop",0);var o=n(U,W);if(o){c.css("height","auto");A(o.data,U);e(W,o.t)}else{var X={q:U,p:W,s:x,contentType:"application/json; charset=utf-8"};var Y=function(af,ac){if(ac===true){U=ac}var aa=parseInt(af[I.totalProperty]);if(isNaN(aa)&&I.paging){if(I.maxCacheBytes<=0){alert('The "maxCacheBytes" configuration option must be greater\nthan zero when implementing client-side paging.')}aa=af[I.resultsProperty].length;var Z=aa/x;if(aa%x>0){Z=parseInt(++Z)}for(var ae=1;ae<=Z;ae++){var ad={};ad[I.totalProperty]=aa;ad[I.resultsProperty]=af[I.resultsProperty].splice(0,x);if(ae===1){ab=A(ad,U)}S(U,ae,x,aa,ad,ab)}}else{var ab=A(af,U);S(U,W,x,aa,af,ab)}e(W,aa);c.css("height","auto");F=false};if(typeof(I.source)==="object"){if(I.allowInput){Y(B(I.source,X))}else{Y(I.source)}}else{F=true;if(I.method.toUpperCase()=="POST"){a.post(I.source,X,Y,"json")}else{a.getJSON(I.sour
|