judy.min.js 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877
  1. (function($){var Judy=function($){var self=this,_name="Judy",_nonObj=["window","document","document.documentElement","element","image","textNode","attributeNode","otherNode","event","date","regexp","jquery"],_uaIe=0,_dateFrmt,_dateTz,_nonInputFlds=["textarea","select"],_dataName,_dialEvts=["beforeClose","create","open","focus","dragStart","drag","dragStop","resizeStart","resize","resizeStop","close"],_dialOpts=["appendTo","autoOpen","buttons","closeOnEscape","closeText","dialogClass","draggable","height","hide","maxHeight","maxWidth","minHeight","minWidth","modal","position","resizable","show","title","width"],_dialMthds=["close","destroy","isOpen","moveToTop","open","option","widget"],_dialogs=[],_acInit,_acLstnrs={},_acFltrs=[{"!url":/\/inspect\/ajax/},{"!url":/\/log_filter\/ajax/}],_checklist="checkboxes",_radio="radios",_jqOvrly,_ovrlyRsz,_errorHandler=function(error,variable,options){var u=options,o={},t;
  2. if(typeof window.inspect==="function"&&inspect.tcepsnI){if(typeof inspect.errorHandler==="function"){if(u){if((t=typeof u)==="string"){o.message=u;
  3. o.wrappers=1;
  4. }else{if(t==="object"){o=u;
  5. o.wrappers=!u.wrappers?1:(u.wrappers+1);
  6. }}}o.category="Judy";
  7. inspect.errorHandler(error,variable,o);
  8. }else{inspect.console("Please update Inspect.");
  9. }}},_elm=function(list,u,cntxt,mthd,noError){var li=!list?0:undefined,t,s=u,jq,le,i,f;
  10. if(u){if((t=typeof u)==="object"){if(u===window||u===document||u.getAttributeNode){return !list?u:[u];
  11. }if(typeof u.jquery==="string"){if(u.length){if(!cntxt){return u.get(li);
  12. }if((jq=$(u,cntxt)).length){return jq.get(li);
  13. }}s=u.selector;
  14. }else{if(self.isArray(u)&&(le=u.length)){for(i=0;
  15. i<le;
  16. i++){if(!(u[i]===window||u[i]===document||u[i].getAttributeNode)){f=true;
  17. break;
  18. }else{if(!i&&!list){return u[0];
  19. }}}if(!f){return u;
  20. }}}}else{if(t==="string"&&(jq=$(u)).length){return jq.get(li);
  21. }}}if(!noError){try{throw new Error("selector["+s+"], type["+self.typeOf(u)+"], doesnt resolve to element");
  22. }catch(er){_errorHandler(er,null,_name+"."+mthd+"()");
  23. }}return undefined;
  24. },_fieldType=function(r,b){var t=r.tagName.toLowerCase();
  25. if(t==="input"){if((t=r.getAttribute("type"))){switch(t){case"button":case"submit":case"reset":return !b?"":t;
  26. case"radio":return _radio;
  27. case"checkbox":return self.ancestor(r,"div.form-checkboxes",3)?_checklist:"checkbox";
  28. default:return t;
  29. }}return"";
  30. }return self.arrayIndexOf(_nonInputFlds,t)>-1?t:"";
  31. },_disable=function(nbl,slctr,cntxt,ttl){var a=_elm(true,slctr,cntxt,!nbl?"disable":"enable"),le,i,r;
  32. if(a){le=a.length;
  33. for(i=0;
  34. i<le;
  35. i++){(r=a[i]).disabled=!nbl?"disabled":false;
  36. if(typeof ttl==="string"){r.setAttribute("title",ttl);
  37. }switch(_fieldType(r,true)){case"checkbox":$(r).unbind("click."+_name+".disabled");
  38. if(!nbl){$(r).bind("click."+_name+".disabled",function(){return false;
  39. });
  40. }break;
  41. case _checklist:$("input[type='checkbox']",r).each(function(){$(r).unbind("click."+_name+".disabled");
  42. if(!nbl){$(this).bind("click."+_name+".disabled",function(){return false;
  43. });
  44. }});
  45. break;
  46. case _radio:$("input[name='"+r.getAttribute("name")+"']",cntxt).each(function(){this.disabled=!nbl?"disabled":false;
  47. });
  48. break;
  49. case"button":case"submit":case"reset":$(r)[!nbl?"addClass":"removeClass"]("form-button-disabled");
  50. break;
  51. }}}},_valCheckbox=function(r,val){if(val===undefined){return r.checked?r.value:"";
  52. }r.checked=(val?"checked":false);
  53. return true;
  54. },_valRadio=function(r,context,val){var nm=r.getAttribute("name"),a,le,i,v;
  55. if(!nm){return _valCheckbox(r,val);
  56. }if(val===undefined){return(v=$("input[name='"+nm+"']:checked",context).val())!==undefined?v:"";
  57. }if((le=(a=$().get("input[name='"+nm+"']",context)).length)){if((v=""+val)===""){for(i=0;
  58. i<le;
  59. i++){a[i].checked=false;
  60. }return true;
  61. }for(i=0;
  62. i<le;
  63. i++){if(a[i].value===v){a[i].checked="checked";
  64. return true;
  65. }}return false;
  66. }return undefined;
  67. },_valSelect=function(r,val){var multi,ndx=-1,rOpts,nOpts,rOpt,nVals,i,vals=[],v,set=0;
  68. if(val===undefined&&((ndx=r.selectedIndex)===undefined||ndx<0)){return"";
  69. }multi=r.multiple;
  70. nOpts=(rOpts=$("option",r).get()).length;
  71. if(val===undefined){if(!multi){return(v=rOpts[ndx].value)!=="_none"?v:"";
  72. }for(i=0;
  73. i<nOpts;
  74. i++){if((rOpt=rOpts[i]).selected&&(v=rOpt.value)!==""&&v!=="_none"){vals.push(v);
  75. }}return vals.length?vals:"";
  76. }for(i=0;
  77. i<nOpts;
  78. i++){rOpts[i].selected=false;
  79. }if(val===""||val==="_none"){return true;
  80. }if(!self.isArray(val)){v=[""+val];
  81. }else{if(!(nVals=val.length)||(nVals===1&&(val[0]===""||val[0]==="_none"))){return true;
  82. }v=val.concat();
  83. for(i=0;
  84. i<nVals;
  85. i++){v[i]=""+v[i];
  86. }}for(i=0;
  87. i<nOpts;
  88. i++){if(((rOpt=rOpts[i]).selected=self.arrayIndexOf(v,rOpt.value)>-1?"selected":false)){++set;
  89. if(!multi){return 1;
  90. }}}return set;
  91. },_valChecklist=function(r,val){var par,rOpts,nOpts,rOpt,nVals,i,v=[],set=0;
  92. if((par=self.ancestor(r,"div.form-checkboxes",3))){nOpts=(rOpts=$("input[type='checkbox']",par).get()).length;
  93. if(val===undefined){for(i=0;
  94. i<nOpts;
  95. i++){if((rOpt=rOpts[i]).checked){v.push(rOpt.value);
  96. }}return v.length?v:"";
  97. }v=!self.isArray(val)?(val===""?undefined:[val]):(!(nVals=val.length)||(nVals===1&&val[0]==="")?undefined:val.concat());
  98. if(v===undefined){for(i=0;
  99. i<nOpts;
  100. i++){rOpts[i].checked=false;
  101. }return true;
  102. }for(i=0;
  103. i<nVals;
  104. i++){v[i]=""+v[i];
  105. }for(i=0;
  106. i<nOpts;
  107. i++){if(((rOpt=rOpts[i]).checked=self.arrayIndexOf(v,rOpt.value)>-1?"checked":false)){++set;
  108. }}return set;
  109. }return undefined;
  110. },_filter=function(o,fltr){var le=fltr.length,i,k,x,not,v;
  111. for(i=0;
  112. i<le;
  113. i++){for(k in fltr[i]){v=null;
  114. if(fltr[i].hasOwnProperty(k)){x=k;
  115. if((not=x.charAt(0)==="!")){x=x.substr(1);
  116. }if(o.hasOwnProperty(x)){if((v=fltr[i][k])&&v instanceof RegExp){if(typeof o[x]==="string"){if(v.test(o[x])){if(not){return false;
  117. }}else{if(!not){return false;
  118. }}}}else{if(o[x]===v){if(not){return false;
  119. }}else{if(!not){return false;
  120. }}}}}}}return true;
  121. },_acOff=function(u,s,nm,h){var le,i,rm=[],n,sbtrt;
  122. if(_acLstnrs[u]&&_acLstnrs.hasOwnProperty(u)){le=_acLstnrs[u].length;
  123. for(i=0;
  124. i<le;
  125. i++){if((_acLstnrs[u][i][0]===s||(nm&&_acLstnrs[u][i][1]===nm))&&(!h||_acLstnrs[u][i][2]===h)){rm.push(i);
  126. }}if((n=rm.length)){if(n===le){delete _acLstnrs[u];
  127. }else{sbtrt=0;
  128. for(i=0;
  129. i<n;
  130. i++){_acLstnrs[u].splice(rm[i]-sbtrt,1);
  131. ++sbtrt;
  132. }}}}},_keyMask=function(keystrokes){var aK=keystrokes.toUpperCase().split(/_/),nK=aK.length,k=0,ky,cK,i;
  133. for(i=0;
  134. i<nK;
  135. i++){switch((ky=aK[i])){case"CTR":case"CTRL":case"CMD":case"META":k+=100000;
  136. break;
  137. case"ALT":k+=10000;
  138. break;
  139. case"SHIFT":k+=1000;
  140. break;
  141. case"ENTER":case"RETURN":k+=13;
  142. break;
  143. case"ESC":case"ESCAPE":k+=27;
  144. break;
  145. case"TAB":k+=9;
  146. break;
  147. case"SPACE":k+=32;
  148. break;
  149. case"BACKSPACE":k+=8;
  150. break;
  151. case"INS":case"INSERT":k+=45;
  152. break;
  153. case"DEL":case"DELETE":k+=46;
  154. break;
  155. case"HOME":k+=36;
  156. break;
  157. case"END":k+=35;
  158. break;
  159. case"PGUP":case"PAGEUP":k+=33;
  160. break;
  161. case"PGDN":case"PAGEDOWN":k+=34;
  162. break;
  163. case"PAUSE":case"BREAK":k+=19;
  164. break;
  165. case"STAR":k+=106;
  166. break;
  167. case"-":case"MINUS":case"HYPHEN":k+=109;
  168. break;
  169. case"+":case"PLUS":k+=107;
  170. break;
  171. case"LEFT":k+=37;
  172. break;
  173. case"UP":k+=38;
  174. break;
  175. case"RIGHT":k+=39;
  176. break;
  177. case"DOWN":k+=40;
  178. break;
  179. case"F1":k+=112;
  180. break;
  181. case"F2":k+=113;
  182. break;
  183. case"F3":k+=114;
  184. break;
  185. case"F4":k+=115;
  186. break;
  187. case"F5":k+=116;
  188. break;
  189. case"F6":k+=117;
  190. break;
  191. case"F7":k+=118;
  192. break;
  193. case"F8":k+=119;
  194. break;
  195. case"F9":k+=120;
  196. break;
  197. case"F10":k+=121;
  198. break;
  199. case"F11":k+=122;
  200. break;
  201. case"F12":k+=123;
  202. break;
  203. default:cK=ky.charCodeAt(0);
  204. if(cK>=96&&cK<=105){k+=(cK-48);
  205. }else{if((cK>=65&&cK<=90)||(cK>=48&&cK<=57)){k+=cK;
  206. }else{throw new Error("unsupported char["+ky+"] in keystrokes["+keystrokes+"]");
  207. }}}}if(k&&k%1000>0){return"_"+k;
  208. }throw new Error("keystrokes["+keystrokes+"] "+(!k?"evaluates to nothing":"all modifiers, no plain keys"));
  209. },_keystrokes=function(e){var k=0,kC;
  210. if(e.ctrlKey||e.metaKey){k+=100000;
  211. }if(e.altKey){k+=10000;
  212. }if(e.shiftKey){k+=1000;
  213. }if((kC=e.keyCode)){switch(kC){case 61:k+=107;
  214. break;
  215. case 189:k+=109;
  216. break;
  217. default:if(kC>=96&&kC<=105){k+=(kC-48);
  218. }else{k+=kC;
  219. }}}return k;
  220. },_bindKeys=function(et,as){var jq=$(as[0]),jqMthd=typeof jq.on==="function"?"on":"bind",nAs=as.length,qualifiers="",nQs,iQ,q,nm,kms={},km,rs=jq.get(),nRs=jq.length,r,hndlr,dat,pdef=false,i,jq1,d,e,j,le,kyHndlrs,f;
  221. if(nAs<3){throw new Error("requires at least 3 args");
  222. }if(!nRs){throw new Error("No element like selector["+as[0]+"], type["+self.typeOf(as[0])+"]");
  223. }for(i=1;
  224. i<5;
  225. i++){switch(typeof as[i]){case"string":qualifiers=as[1];
  226. break;
  227. case"function":hndlr=as[i];
  228. break;
  229. case"object":dat=as[i];
  230. break;
  231. case"boolean":pdef=as[i];
  232. break;
  233. }}if(!hndlr){throw new Error("No handler function arg found");
  234. }nQs=(qualifiers=qualifiers.split(" ")).length;
  235. for(iQ=0;
  236. iQ<nQs;
  237. iQ++){if((q=qualifiers[iQ]).indexOf("key")===0){q=q.replace(/^key[^_]+_(.+)$/,"$1");
  238. }if(!q||q==="*"){jq[jqMthd].apply(jq,!dat?[et,hndlr]:[et,dat,hndlr]);
  239. return true;
  240. }nm="";
  241. if(q.indexOf(".")>-1){nm=q.replace(/^[^\.]+\.(.+)$/,"$1");
  242. q=q.replace(/^([^\.]+)\..+$/,"$1");
  243. }km=_keyMask(q.replace(/[_\+]\+/,"_plus").replace(/\+/g,"_"));
  244. if(iQ&&kms[km]&&kms.hasOwnProperty(km)){continue;
  245. }kms[km]={handler:hndlr,data:dat,namespace:nm,type:q,preventDefault:pdef};
  246. }for(i=0;
  247. i<nRs;
  248. i++){if((r=rs[i])!==document.documentElement){if(r===window){if(_uaIe){throw new Error("IE key event on window illegal, do set it on document.documentElement");
  249. }}else{if(!_uaIe){switch(r.tagName.toLowerCase()){case"textarea":case"input":break;
  250. default:if(!r.hasAttribute("tabindex")){throw new Error("non-IE key event on tag-type["+r.tagName+"] without tabindex not possible");
  251. }}}}}kyHndlrs=null;
  252. if((d=(jq1=$(r)).data("events"))&&(e=d[et])&&d.hasOwnProperty(et)){le=e.length;
  253. for(j=0;
  254. j<le;
  255. j++){if(e[j].namespace===_dataName){kyHndlrs=e[j].handler.judy_keyMask_handlers;
  256. break;
  257. }}}if(!kyHndlrs){f=function(evt){var o,k,a,pd,le,i,lstnr,e;
  258. if((a=(o=f.judy_keyMask_handlers)[k="_"+_keystrokes(evt)])&&o.hasOwnProperty(k)&&(le=a.length)){for(i=0;
  259. i<le;
  260. i++){lstnr=a[i];
  261. if(!pd&&lstnr.preventDefault){pd=true;
  262. evt.preventDefault();
  263. }evt.data=lstnr.data;
  264. evt.keystrokes=lstnr.type;
  265. lstnr.handler.apply(this,[evt]);
  266. }}};
  267. kyHndlrs=f.judy_keyMask_handlers={};
  268. jq1[jqMthd](et+"."+_dataName,f);
  269. }for(km in kms){if(kms.hasOwnProperty(km)){if(kyHndlrs[km]&&kyHndlrs.hasOwnProperty(km)){kyHndlrs[km].push(kms[km]);
  270. }else{kyHndlrs[km]=[kms[km]];
  271. }}}}return undefined;
  272. },_dateTz=function(dt,asHourStr){var z=dt.getTimezoneOffset(),zu;
  273. return !asHourStr?(-(z*60*1000)):(z?(((zu=z>0)?"-":"+")+((zu=((zu?z:z*-1)/60))<10?"0":"")+Math.floor(zu)):"+00");
  274. },_dateFrmt=function(dt,d,t,m,UTC,iso){var u,f=UTC?"getUTC":"get";
  275. return(d?(dt[f+"FullYear"]()+"-"+((u=dt[f+"Month"]()+1)<10?("0"+u):u)+"-"+((u=dt[f+"Date"]())<10?("0"+u):u)):"")+(d&&t?(iso?"T":" "):"")+(t?((((u=dt[f+"Hours"]())<10?("0"+u):u)+":"+((u=dt[f+"Minutes"]())<10?("0"+u):u)+":"+((u=dt[f+"Seconds"]())<10?("0"+u):u))+(m?((iso?".":" ")+((u=dt[f+"Milliseconds"]())<10?("00"+u):(u<100?("0"+u):u))):"")):"")+(!iso?"":(UTC?"Z":(_dateTz(dt,1)+":00")));
  276. },_dimInner=function(d,slctr,ignorePadding){var u=slctr,r,dE=document.documentElement,jq,v,p;
  277. if(u===window){return dE["client"+d];
  278. }if(u===dE||u===document.body){return dE["scroll"+d];
  279. }if((r=_elm(0,u,0,"inner"+d))){v=r["client"+d];
  280. if(!ignorePadding){if((p=(jq=$(r)).css("padding-"+(d==="Width"?"left":"top"))).indexOf("px")>-1){v-=parseFloat(p);
  281. }if((p=jq.css("padding-"+(d==="Width"?"right":"bottom"))).indexOf("px")>-1){v-=parseFloat(p);
  282. }v=Math.round(v);
  283. }return v;
  284. }return undefined;
  285. },_dimOuter=function(d,slctr,includeMargin,set,max){var u=slctr,r,dE=document.documentElement,jq,v;
  286. if(u===window){return dE["inner"+d]||dE["client"+d];
  287. }if(u===dE||u===document.body){return dE["scroll"+d];
  288. }if((r=_elm(0,u,0,"outer"+d))){v=(jq=$(r))["outer"+d](includeMargin);
  289. if(!set||set===v){return v;
  290. }v=_dimInner(d,u)+(set-v);
  291. if(!max||max===2){jq.css(d.toLowerCase(),v+"px");
  292. }if(max){jq.css("max-"+d.toLowerCase(),v+"px");
  293. }return set;
  294. }return undefined;
  295. },_ovrlyRsz=function(){var w=window,d=document.documentElement,dW,dD;
  296. _jqOvrly.css({width:((dD=self.innerWidth(d))>(dW=self.innerWidth(w))?dD:dW)+"px",height:((dD=self.innerHeight(d))>(dW=self.innerHeight(w))?dD:dW)+"px"});
  297. };
  298. this.yduj=true;
  299. this.yduJ=true;
  300. this.version=2.1;
  301. this.browserIE=_uaIe=(function(){var u;
  302. if((u=window.navigator)&&(u=u.userAgent)){if(/; MSIE \d{1,2}\.\d/.test(u)){return(u=parseFloat(u.replace(/^.+; MSIE (\d{1,2}\.\d).+/,"$1")))?u:0;
  303. }if(/; Trident\/\d+\.\d+;/.test(u)&&/; rv:\d+\.\d+[;\)]/.test(u)){return(u=parseFloat(u.replace(/^.+; rv:(\d+\.\d+)[;\)].+$/,"$1")))?u:0;
  304. }}return 0;
  305. }());
  306. this.setup=function(){self.setup=function(){};
  307. _dataName="judy_"+self.randName();
  308. };
  309. this.typeOf=function(u){var t=typeof u;
  310. if(!arguments.length){return"Judy";
  311. }switch(t){case"boolean":case"string":return t;
  312. case"number":return isFinite(u)?t:(isNaN(u)?"NaN":"infinite");
  313. case"object":if(u===null){return"null";
  314. }try{if(u.typeOf&&typeof u.typeOf==="function"){return u.typeOf();
  315. }else{if(typeof u.length==="number"&&!(u.propertyIsEnumerable("length"))&&typeof u.splice==="function"){return"array";
  316. }else{if(u===window){return"window";
  317. }else{if(u===document){return"document";
  318. }else{if(u===document.documentElement){return"document.documentElement";
  319. }else{if(u.getAttributeNode){return u.tagName.toLowerCase==="img"?"image":"element";
  320. }else{if(u.nodeType){switch(u.nodeType){case 3:return"textNode";
  321. case 2:return"attributeNode";
  322. }return"otherNode";
  323. }else{if(typeof u.stopPropagation==="function"||(u.cancelBubble!==undefined&&typeof u.cancelBubble!=="function"&&typeof u.boundElements==="object")){return"event";
  324. }else{if(typeof u.getUTCMilliseconds==="function"){return"date";
  325. }else{if(typeof u.exec==="function"&&typeof u.test==="function"){return"regexp";
  326. }else{if(u.hspace&&typeof u.hspace!=="function"){return"image";
  327. }else{if(u.jquery&&typeof u.jquery==="string"&&!u.hasOwnProperty("jquery")){return"jquery";
  328. }}}}}}}}}}}}}catch(er){}return t;
  329. case"function":return(u.constructor===RegExp||(typeof u.exec==="function"&&typeof u.test==="function"))?"regexp":t;
  330. }return t;
  331. };
  332. this.isContainer=function(u,orArray){var t;
  333. return u&&typeof u==="object"&&((t=self.typeOf(u))==="object"||(orArray&&t==="array")||(t!=="array"&&self.arrayIndexOf(_nonObj,t)===-1))?(!orArray||t!=="array"?"object":t):false;
  334. };
  335. this.isArray=function(u){return(u&&typeof u==="object"&&typeof u.length==="number"&&!(u.propertyIsEnumerable("length"))&&typeof u.splice==="function");
  336. };
  337. this.isNumber=function(u){return typeof u==="number"&&isFinite(u);
  338. };
  339. this.isInt=function(u,nonNegative){return typeof u==="number"&&isFinite(u)&&(u%1===0)&&(!nonNegative||u>-1);
  340. };
  341. this.containerCopy=function(oa,shallow){var t,c={},p,v;
  342. if(!oa||!(t=self.isContainer(oa,true))){return oa;
  343. }if(t==="array"){if(shallow){return oa.concat();
  344. }c=[];
  345. }for(p in oa){if(oa.hasOwnProperty(p)){c[p]=((v=oa[p])&&typeof v==="object")?(v===oa?c:(!shallow?self.containerCopy(v,false):v)):v;
  346. }}return c;
  347. };
  348. this.objectGet=function(o,anyNumberOfKeys){var a=arguments,le=a.length,u=o,p,i;
  349. try{if(!u||typeof u!=="object"){throw new Error("arg o isnt object");
  350. }if(le<2){throw new Error("no key arg");
  351. }for(i=1;
  352. i<le;
  353. i++){if(i>1&&(!u||typeof u!=="object")){return undefined;
  354. }if((!(p=a[i])&&p!==0)||!(p=""+p)){throw new Error("arg #"+i+"["+p+"] type["+self.typeOf(p)+"] isnt integer or non-empty string");
  355. }if(u.hasOwnProperty(p)){u=u[p];
  356. }else{return undefined;
  357. }}return u;
  358. }catch(er){_errorHandler(er,null,_name+".objectGet()");
  359. }return undefined;
  360. };
  361. this.objectKeys=function(o){var a,k;
  362. if(!o||typeof o!=="object"){return null;
  363. }if(typeof Object.keys==="function"){return Object.keys(o);
  364. }a=[];
  365. for(k in o){if(o.hasOwnProperty(k)){a.push(k);
  366. }}return a;
  367. };
  368. this.objectKeyOf=function(o,v){var k;
  369. if(v!==undefined&&o||typeof o==="object"){for(k in o){if(o.hasOwnProperty(k)&&o[k]===v){return k;
  370. }}}return undefined;
  371. };
  372. this.objectSort=function(o){var a=[],oByVal={},os={},k,v,cNum=String.fromCharCode(127),le,i=0;
  373. if(!o||typeof o!=="object"){return o;
  374. }for(k in o){if(o.hasOwnProperty(k)){++i;
  375. oByVal[(typeof(v=o[k])!=="number"?"":cNum)+v]=k;
  376. a.push(v);
  377. }}if(!i){return o;
  378. }le=i;
  379. a.sort();
  380. for(i=0;
  381. i<le;
  382. i++){os[oByVal[(typeof(v=a[i])!=="number"?"":cNum)+v]]=v;
  383. }return os;
  384. };
  385. this.objectKeySort=function(o){var a,os={},le,i;
  386. if(!(a=self.objectKeys(o))||(le=a.length)<2){return a?o:null;
  387. }a.sort();
  388. for(i=0;
  389. i<le;
  390. i++){os[a[i]]=o[a[i]];
  391. }return os;
  392. };
  393. this.toArray=function(o){var a,le,i;
  394. if(o&&typeof o==="object"){if(typeof o.hasOwnProperty==="function"){return Array.prototype.slice.call(o);
  395. }a=[];
  396. le=o.length;
  397. for(i=0;
  398. i<le;
  399. i++){a.push(o[i]);
  400. }return a;
  401. }return null;
  402. };
  403. this.arrayIndexOf=function(a,v){var le=a.length,i;
  404. for(i=0;
  405. i<le;
  406. i++){if(a[i]===v){return i;
  407. }}return -1;
  408. };
  409. this.merge=function(oa,oa1,isContainer,_depth){var tBoth=isContainer!==true?isContainer:0,t=tBoth||self.isContainer(oa,true),t1=tBoth||self.isContainer(oa1,true),d=_depth||0,p,le,le1,v,v1;
  410. try{if(d<10){if(t&&t1){if(t==="object"){if(t1==="object"){for(p in oa1){if(oa1.hasOwnProperty(p)&&(v1=oa1[p])!==undefined){if((v=oa[p])===undefined||!oa.hasOwnProperty(p)){oa[p]=v1;
  411. }else{if(v1!==null){if(!(t=self.isContainer(v,true))||self.isContainer(v1,true)!==t){oa[p]=v1;
  412. }else{self.merge(v,v1,t,d+1);
  413. }}}}}return true;
  414. }throw new TypeError("Type mismatch, first is object type["+self.typeOf(oa)+"], second is array");
  415. }else{if(t1==="array"){if((le1=oa1.length)){if(!(le=oa.length)){oa=oa1.concat();
  416. }else{for(p=0;
  417. p<le1;
  418. p++){if((v1=oa1[p])!==undefined){if(p>=le){oa.push(v1);
  419. }else{if((v=oa[p])===undefined){oa[p]=v1;
  420. }else{if(v1!==null){if(!(t=self.isContainer(v,true))||self.isContainer(v1,true)!==t){oa[p]=v1;
  421. }else{self.merge(v,v1,t,d+1);
  422. }}}}}}}}return true;
  423. }}throw new TypeError("Type mismatch, first is array, second is type["+self.typeOf(oa1)+"]");
  424. }throw new TypeError("First arg is type["+self.typeOf(oa)+"], second is type["+self.typeOf(oa1)+"]");
  425. }throw new Error("Cant recurse > 10, circular ref?");
  426. }catch(er){_errorHandler(er,null,_name+".merge()");
  427. }return false;
  428. };
  429. this.ancestor=function(selector,parentSelector,max){var u,r=_elm(0,selector,null,"ancestor"),tt=parentSelector,lim=max&&max>0?(max+1):101,id,aCls,tn,cls,le,i;
  430. if(!r||r===window||r===document.documentElement){return undefined;
  431. }if(!tt||!(tt=$.trim(""+tt))){return r.parentNode;
  432. }if(tt.indexOf("#")>-1){u=tt.replace(/^([^\#]+)?\#([^\.]+)(\..+)?$/,"$2,$1$3").split(",");
  433. id=u[0];
  434. tt=u[1]||"";
  435. }if(tt.indexOf(".")>-1){aCls=tt.split(".");
  436. tt=aCls[0];
  437. aCls.splice(0,1);
  438. le=aCls.length;
  439. }tt=tt.toLowerCase();
  440. while((--lim)&&(r=r.parentNode)){if(r.nodeType!==1||tn==="body"){return undefined;
  441. }tn=r.tagName.toLowerCase();
  442. if((tt&&tn!==tt)||(id&&r.id!==id)){continue;
  443. }if(le){if(!(cls=r.className).length){continue;
  444. }cls=" "+cls+" ";
  445. u=0;
  446. for(i=0;
  447. i<le;
  448. i++){if(cls.indexOf(aCls[i])===-1){continue;
  449. }++u;
  450. }if(u<le){continue;
  451. }}return r;
  452. }return undefined;
  453. };
  454. this.selector=function(selector,findName){var s=selector,f=findName,t=typeof s,x,v,tg;
  455. try{if(!s){throw new Error("Falsy selector, type["+t+"]");
  456. }if(t==="string"){return !f?s:(s.indexOf("[name=")===-1?[s]:[s,s.replace(/^.*\[name=['\"]([^'\"]+)['\"]\].*$/,"$1")]);
  457. }else{if(t==="object"){if($.isWindow(s)){x="_win_";
  458. }else{if(s===document){x="_doc_";
  459. }else{if(s===document.documentElement){x="_docElm_";
  460. }}}if(x){return !f?x:[x];
  461. }if(typeof s.getAttributeNode!=="function"||typeof s.getAttribute!=="function"){throw new Error("Selector, type["+t+"], isnt non-empty string|element");
  462. }tg=s.tagName.toLowerCase();
  463. if((v=s.getAttribute("name"))){x=tg+'[name="'+v+'"]';
  464. return !f?x:[x,v];
  465. }if((v=s.id)){x="#"+v;
  466. }else{if((v=s.className)){x=tg+"."+v.replace(/ +/g,".");
  467. }else{if((v=s.getAttribute("type"))){x=tg+'[type="'+v+'"]';
  468. }else{x=tg;
  469. }}}return !f?x:[x];
  470. }else{throw new Error("Selector, type["+t+"], isnt non-empty string|element");
  471. }}}catch(er){_errorHandler(er,null,_name+".selector()");
  472. }return null;
  473. };
  474. this.ajaxcomplete=function(selector,url,data,handler,filter){var s=selector,t=typeof s,nm,u=url,d=data,h=handler,f=filter,a,le,i,v;
  475. try{if(!s){throw new Error("Falsy selector, type["+t+"]");
  476. }if(t==="object"){if(s instanceof $){s=s.selector||s.get();
  477. }if($.isArray(s)){if(!(le=s.length)){throw new Error("Empty selector, type array or jquery");
  478. }for(i=0;
  479. i<le;
  480. i++){self.ajaxcomplete(s[i],u,d,h,f);
  481. return;
  482. }}}if(!(a=self.selector(s,true))){throw new Error("Bad selector, see previous error");
  483. }nm=a[1];
  484. s=a[0];
  485. if(!u||typeof u!=="string"){throw new Error("Url type["+self.typeOf(v)+"] isnt non-empty string");
  486. }if(u!=="*"){if(u.indexOf("http")===0){u=u.replace(/^https?:\/\/[^\/]+(\/.+)$/,"$1");
  487. }else{if(u.charAt(0)!=="/"){u="/"+u;
  488. }}}if(h){if(typeof h==="object"){f=h;
  489. h=null;
  490. }}if(d&&typeof d==="function"){h=d;
  491. d=null;
  492. }if(!h){throw new Error("Cant resolve a handler");
  493. }if(!_acInit){$(document).ajaxComplete(function(event,xhr,settings){var url=self.objectGet(settings,"url"),all=[],nm,val,le,i,n,j,k,$jq,nElms,fElms,elms,elm,lstnr,h,d,evt;
  494. if(url){if(url.indexOf("http")===0){url=url.replace(/^https?:\/\/[^\/]+(\/.+)$/,"$1");
  495. }for(k in _acLstnrs){if(_acLstnrs.hasOwnProperty(k)&&url.indexOf(k)===0){all.push(_acLstnrs[k]);
  496. }}if(_acLstnrs["*"]&&_acLstnrs.hasOwnProperty("*")){all.push(_acLstnrs["*"]);
  497. }if((le=all.length)){if((nm=self.objectGet(settings,"extraData","_triggering_element_name"))){if(!($jq=$('[name="'+nm+'"]')).length){return;
  498. }if((val=self.objectGet(settings,"extraData","_triggering_element_value"))!==undefined){if(!($jq=$jq.filter('[value="'+val+'"]')).length){return;
  499. }}nElms=(fElms=$jq.get()).length;
  500. }for(i=0;
  501. i<le;
  502. i++){n=all[i].length;
  503. for(j=0;
  504. j<n;
  505. j++){lstnr=$jq=elms=h=d=evt=null;
  506. lstnr=all[i][j];
  507. if(nm){if(lstnr[1]!==nm||(lstnr[4]&&!_filter(settings,lstnr[4]))){continue;
  508. }elms=fElms;
  509. }else{nElms=1;
  510. switch(lstnr[0]){case"_win_":elms=[window];
  511. break;
  512. case"_doc_":elms=[document];
  513. break;
  514. case"_docElm_":elms=[document.documentElement];
  515. break;
  516. default:nElms=(elms=$(lstnr[0]).get()).length;
  517. }if(!nElms||(lstnr[4]&&!_filter(settings,lstnr[4]))){continue;
  518. }}h=lstnr[2];
  519. d=lstnr[3];
  520. evt=!d?{type:"ajaxcomplete"}:{type:"ajaxcomplete",data:d};
  521. evt.ajax=settings;
  522. for(k=0;
  523. k<nElms;
  524. k++){elm=null;
  525. elm=elms[k];
  526. h.apply(elm,[evt]);
  527. }}}}}});
  528. _acInit=true;
  529. }if(f){if(!$.isArray(f)){f=[f];
  530. }if(u==="*"){f=f.concat(_acFltrs);
  531. }}else{if(u==="*"){f=_acFltrs;
  532. }}if(!_acLstnrs[u]){_acLstnrs[u]=[[s,nm,h,d,f]];
  533. }else{_acLstnrs[u].push([s,nm,h,d,f]);
  534. }}catch(er){_errorHandler(er,null,_name+".ajaxcomplete()");
  535. }};
  536. this.ajaxcomplete.off=function(selector,url,handler){var s=selector,t=typeof s,u=url,h=handler,nm,lstnrs,a,le,i,rm=[],sbtrt;
  537. try{if(!_acInit){return;
  538. }if(!s){throw new Error("Falsy selector, type["+t+"]");
  539. }if(t==="object"){if(s instanceof $){s=s.selector||s.get();
  540. }if($.isArray(s)){if(!(le=s.length)){throw new Error("Empty selector, type array or jquery");
  541. }for(i=0;
  542. i<le;
  543. i++){self.ajaxcomplete.off(s[i],u,h);
  544. return;
  545. }}}if(!(a=self.selector(s,true))){throw new Error("Bad selector, see previous error");
  546. }nm=a[1];
  547. s=a[0];
  548. if(u){if((t=typeof u)==="function"){h=u;
  549. u=null;
  550. }else{if(t!=="string"){throw new Error("Url type["+self.typeOf(v)+"] isnt non-empty string");
  551. }if(u.indexOf("http")===0){u=u.replace(/^https?:\/\/[^\/]+(\/.+)$/,"$1");
  552. }else{if(u.charAt(0)!=="/"){u="/"+u;
  553. }}}}if(u){_acOff(u,s,nm,h);
  554. }else{for(u in _acLstnrs){_acOff(u,s,nm,h);
  555. }}}catch(er){_errorHandler(er,null,_name+".ajaxcomplete.off()");
  556. }};
  557. this.keydown=function(){try{_bindKeys("keydown",arguments);
  558. return true;
  559. }catch(er){_errorHandler(er,null,_name+".keydown()");
  560. }return false;
  561. };
  562. this.keyup=function(){try{_bindKeys("keyup",arguments);
  563. return true;
  564. }catch(er){_errorHandler(er,null,_name+".keyup()");
  565. }return false;
  566. };
  567. this.eventList=function(selector,type){var r=_elm(0,selector,null,"eventList"),jq,o,k;
  568. if(!r){return undefined;
  569. }jq=$(r);
  570. if((o=jq.data())){if(!o.hasOwnProperty("events")){for(k in o){if(k.length>7&&o.hasOwnProperty(k)&&k.indexOf("jQuery")===0){if(!(o=o[k])||!o.events||!o.hasOwnProperty("events")){return null;
  571. }}}}}if(!o){return null;
  572. }if(!type){return o.events;
  573. }o=o.events;
  574. for(k in o){if(k===type&&o.hasOwnProperty(k)){return o[k];
  575. }}return null;
  576. };
  577. this.isField=function(elm,button){return typeof elm==="object"&&elm.tagName?(_fieldType(elm,button)?true:false):undefined;
  578. };
  579. this.fieldType=function(selector,context,button){var r=_elm(0,selector,context,"fieldType");
  580. return r?_fieldType(r,button):undefined;
  581. };
  582. this.fieldValue=function(selector,context,val,type){var r=_elm(0,selector,context,"fieldValue"),t;
  583. if(r&&(t=type||_fieldType(r,true))){switch(t){case"select":return _valSelect(r,val);
  584. case"checkbox":return _valCheckbox(r,val);
  585. case"checkboxes":case"checklist":return _valChecklist(r,val);
  586. case"radio":case"radios":return _valRadio(r,context,val);
  587. case"image":t="src";
  588. default:t="";
  589. }if(val===undefined){return !t?r.value:r.getAttribute(t);
  590. }if(!t){r.value=""+val;
  591. }else{r.setAttribute(t,""+val);
  592. }return true;
  593. }return undefined;
  594. };
  595. this.disable=function(selector,context,hoverTitle){_disable(0,selector,context,hoverTitle);
  596. };
  597. this.enable=function(selector,context,hoverTitle){_disable(1,selector,context,hoverTitle);
  598. };
  599. this.scrollTrap=function(selector,context,eventName){var a=_elm(true,selector,context,"scrollTrap"),nm=eventName||(_name+".scrollTrap");
  600. if(a){$(a).each(function(){var preventZone=100,halfZone,s=this.scrollTop,$self=$(this),$chlds,le,$chld,h;
  601. if(!$self.hasClass("scroll-trapped")){if((le=($chlds=$self.children()).get().length)===1){$chld=$($chlds.get(0));
  602. }else{if(le){$chld=$chlds.wrapAll("<div />").parent();
  603. }else{return;
  604. }}$self.addClass("scroll-trapped");
  605. if((h=this.clientHeight)<1.5*preventZone){preventZone=Math.floor(h/1.5);
  606. }halfZone=Math.floor(preventZone/2);
  607. $chld.css({"margin-top":preventZone+"px","margin-bottom":preventZone+"px"});
  608. this.scrollTop=s+preventZone;
  609. $self.bind("scroll."+nm,function(){var that=this,s=that.scrollTop,h;
  610. if(s<halfZone){that.scrollTop=halfZone;
  611. setTimeout(function(){that.scrollTop=preventZone;
  612. },100);
  613. }else{if(s>(h=that.scrollHeight-that.clientHeight)-halfZone){that.scrollTop=h-halfZone;
  614. setTimeout(function(){that.scrollTop=h-preventZone;
  615. },100);
  616. }}});
  617. }});
  618. }};
  619. this.scrollTo=function(selector,context,offset,pad){var u,par,r,to=offset,p=pad||0,num,$par,chld,prvntZn=0,max=-1;
  620. if((par=_elm(0,selector,context,"scrollTo"))){if(!to||typeof to==="number"||!(r=_elm(0,to,par,"",true))){num=true;
  621. to=!to||!isFinite(to)||to<0?0:to;
  622. }if(($par=$(par)).hasClass("scroll-trapped")&&(chld=$par.children().get(0))){prvntZn=parseInt($(chld).css("margin-top").replace(/px/,""),10);
  623. max=par.scrollHeight-par.clientHeight-Math.floor(prvntZn*0.75);
  624. }if(num){to+=prvntZn;
  625. }else{par.scrollTop=prvntZn;
  626. to=(r.offsetTop-par.offsetTop);
  627. }if(p&&prvntZn&&p<0&&(p*-1)>(u=Math.floor(prvntZn/4))){p=-u;
  628. }to+=p;
  629. if(max>0&&to>max){to=max;
  630. }par.scrollTop=to;
  631. }};
  632. this.focus=function(selector,context,delay){var d=delay||0,to;
  633. if(selector){to=setTimeout(function(){var r;
  634. if((r=_elm(0,selector,context,"",true))){try{r.focus();
  635. }catch(er){}}},d>=0?d:20);
  636. }};
  637. this.innerWidth=function(selector,ignorePadding){return _dimInner("Width",selector,ignorePadding);
  638. };
  639. this.innerHeight=function(selector,ignorePadding){return _dimInner("Height",selector,ignorePadding);
  640. };
  641. this.outerWidth=function(selector,includeMargin,set,max){return _dimOuter("Width",selector,includeMargin,set,max);
  642. };
  643. this.outerHeight=function(selector,includeMargin,set,max){return _dimOuter("Height",selector,includeMargin,set,max);
  644. };
  645. this.stripTags=function(u){return $.trim((""+u).replace(/<[^<>]+>/g," ").replace(/[ ]+/g," "));
  646. };
  647. this.toLeading=function(u,length){var le=length||1;
  648. return(new Array(le).join("0")+u).substr(-le,le);
  649. };
  650. this.toUpperCaseFirst=function(u){var s=""+u,le=s.length;
  651. return !le?"":(s.charAt(0).toUpperCase()+(le<2?"":s.substr(1)));
  652. };
  653. this.isLeapYear=function(u){var y;
  654. switch(self.typeOf(u)){case"date":y=u.getFullYear();
  655. break;
  656. case"number":y=u;
  657. break;
  658. case"string":y=parseInt(u,10);
  659. break;
  660. default:return null;
  661. }if(isFinite(y)&&u>-1&&u%1===0){return(!(y%4)&&(y%100))||!(y%400);
  662. }return null;
  663. };
  664. this.dateISO=function(date,UTC){var d=date||new Date();
  665. return UTC&&Date.prototype.toISOString?d.toISOString():_dateFrmt(d,1,1,1,UTC,1);
  666. };
  667. this.dateTime=function(date,UTC){var d=date||new Date();
  668. return UTC&&Date.prototype.toISOString?d.toISOString().replace(/T/," ").replace(/\.\d{3}Z$/,""):_dateFrmt(d,1,1,0,UTC);
  669. };
  670. this.dateToFormat=function(date,sFormat){var u=date,fmt=sFormat||"YYYY-MM-DD",le,y,m,d,s,a,b;
  671. if(u&&typeof u==="object"&&u.getFullYear){y=u.getFullYear();
  672. m=self.toLeading(u.getMonth()+1,2);
  673. d=self.toLeading(u.getDate(),2);
  674. if((a=(s=fmt.substr(0,10)).replace(/[MDY]/g,"")).length<2){return"";
  675. }b=a.charAt(1);
  676. a=a.charAt(0);
  677. switch(s.replace(/[^MDY]/g,"")){case"YYYYMMDD":s=y+a+m+b+d;
  678. break;
  679. case"MMDDYYYY":s=m+a+d+b+y;
  680. break;
  681. case"DDMMYYYY":s=d+a+m+b+y;
  682. break;
  683. default:return"";
  684. }if((le=fmt.length)>11){s+=" "+self.toLeading(u.getHours(),2);
  685. if(le>14){s+=":"+self.toLeading(u.getMinutes(),2);
  686. if(le>17){s+=":"+self.toLeading(u.getSeconds(),2);
  687. if(le>20){s+=" "+self.toLeading(u.getMilliseconds(),3);
  688. }}}}return s;
  689. }else{try{throw new Error("date["+u+"] type["+self.typeOf(u)+"] is not a non-empty Date");
  690. }catch(er){_errorHandler(er,null,_name+".dateToFormat()");
  691. }return"";
  692. }};
  693. this.dateFromFormat=function(sDate,sFormat){var s=sDate,dt=new Date(),fmt=sFormat||"YYYY-MM-DD",y,m,d;
  694. if(s&&typeof s==="string"){if(/^YYYY.MM.DD$/.test(fmt)){y=s.substr(0,4);
  695. m=s.substr(5,2);
  696. d=s.substr(8,2);
  697. }else{if(/^MM.DD.YYYY$/.test(fmt)){y=s.substr(6,4);
  698. m=s.substr(0,2);
  699. d=s.substr(3,2);
  700. }else{if(/^DD.MM.YYYY$/.test(fmt)){y=s.substr(6,4);
  701. m=s.substr(3,2);
  702. d=s.substr(0,2);
  703. }else{return null;
  704. }}}y=parseInt(y,10);
  705. d=parseInt(d,10);
  706. switch((m=parseInt(m,10))){case 1:case 3:case 5:case 7:case 8:case 10:case 12:if(d>31){return null;
  707. }break;
  708. case 4:case 6:case 9:case 11:if(d>30){return null;
  709. }break;
  710. case 2:if(d>29||(d===29&&!self.isLeapYear(y))){return null;
  711. }break;
  712. default:return null;
  713. }dt.setFullYear(y,m-1,d);
  714. dt.setHours(0,0,0);
  715. dt.setMilliseconds(0);
  716. return dt;
  717. }else{try{throw new Error("date["+s+"] type["+self.typeOf(s)+"] is not non-empty string");
  718. }catch(er){_errorHandler(er,null,_name+".dateFromFormat()");
  719. }return null;
  720. }};
  721. this.timeFormat=function(date,sTime){var d=date,t=sTime?$.trim(sTime):0,h=0,i=0,s=0,le,v;
  722. if(d&&typeof d==="object"&&d.getFullYear){if(t){if(/^\d+$/.test(t)){h=t.substr(0,2);
  723. if((le=t.length)>3){i=t.substr(2,2);
  724. if(le>5){s=t.substr(4,2);
  725. }}}else{if((le=(t=t.split(/[^\d]/)).length)){h=t[0];
  726. if(le>1){i=t[1];
  727. if(le>2){s=t[2];
  728. }}}}if(h){h=isFinite(v=parseInt(h,10))&&v<25?v:0;
  729. if(i){i=isFinite(v=parseInt(i,10))&&v<60?v:0;
  730. }if(s){s=isFinite(v=parseInt(s,10))&&v<60?v:0;
  731. }if(h===24){if(!i&&!s){h=23;
  732. i=s=59;
  733. }else{h=0;
  734. }}}d.setHours(h,i,s);
  735. }else{h=d.getHours();
  736. i=d.getMinutes();
  737. s=d.getSeconds();
  738. }return""+(h<10?"0":"")+h+":"+(i<10?"0":"")+i+":"+(s<10?"0":"")+s;
  739. }else{try{throw new Error("date["+d+"] type["+self.typeOf(d)+"] is not a non-empty Date");
  740. }catch(er){_errorHandler(er,null,_name+".timeFormat()");
  741. }return"00:00:00";
  742. }};
  743. this.numberToFormat=function(num,oFormat){var n=num||0,s,sgn="",o,isInt,kSep,scale,u,le,d,i;
  744. if(!n){return"0";
  745. }if(n<0){n*=-1;
  746. sgn="-";
  747. }isInt=!(u=(o=oFormat||{}).type)||u==="integer";
  748. kSep=(u=o.thousand_separator)||u===""?u:" ";
  749. if((d=n%1)){n=Math.round(n);
  750. }s=""+n;
  751. if(kSep&&(le=s.length)>3){n=s;
  752. s=n.substr(0,i=le%3);
  753. while(i<le){s+=(i?kSep:"")+n.substr(i,3);
  754. i+=3;
  755. }}scale=o.scale||2;
  756. return sgn+s+(isInt?"":(((u=o.decimal_separator)||u===""?u:".")+((d?(""+Math.round(d*Math.pow(10,scale))):"")+new Array(scale+1).join("0")).substr(0,scale)));
  757. };
  758. this.numberFromFormat=function(str,oFormat){var s=$.trim(str),sgn=1,o,isInt,dSep,u,p,d,n;
  759. if(!s||s==="0"||s==="-0"){return 0;
  760. }if(s.charAt(0)==="-"){sgn=-1;
  761. s=s.substr(1);
  762. }if((s=s.replace(/^(.*\d)\D+$/,"$1").replace(/^[^1-9]+([1-9].*)$/,"$1"))){isInt=!(u=(o=oFormat||{}).type)||u==="integer";
  763. dSep=o.decimal_separator||".";
  764. if(new RegExp("\\"+dSep+"\\d*\\D").test(s)){return false;
  765. }if((p=s.indexOf(dSep))>-1){d=s.substr(p).replace(/\D/g,"");
  766. s=s.substr(0,p);
  767. }n=parseInt(s.replace(/\D/g,""),10);
  768. if(d){n+=parseInt(d,10)/Math.pow(10,d.length);
  769. }return sgn*(!isInt?n:Math.round(n));
  770. }return 0;
  771. };
  772. this.rand=function(min,max){var m=min||0;
  773. return m+Math.floor((Math.random()*(((max||9000000000000000)-m)+1))+1)-1;
  774. };
  775. this.randName=function(length){var al=length||20,l,s=String.fromCharCode(Math.floor(Math.random()*26)+97);
  776. while((l=s.length)<al){s+=Math.floor(Math.random()*9000000000000000).toString(36);
  777. }return l>al?s.substr(0,al):s;
  778. };
  779. this.overlay=function(show,opaque,hoverTitle){var hide=!show||typeof show==="object",ttl=hoverTitle||"",clsO="module-judy-overlay-opaque",clsT="module-judy-overlay-hovertitled";
  780. if(!_jqOvrly){if(hide){return;
  781. }$(document.body).append('<div id="module_judy_overlay" class="'+(opaque?clsO:"")+(opaque&&ttl?" ":"")+(ttl?clsT:"")+'"></div>');
  782. _jqOvrly=$("div#module_judy_overlay");
  783. _ovrlyRsz();
  784. $(window).resize(function(){_ovrlyRsz();
  785. });
  786. }else{if(hide){_jqOvrly.hide();
  787. return;
  788. }else{_jqOvrly[opaque?"addClass":"removeClass"](clsO)[ttl?"addClass":"removeClass"](clsT).get(0).setAttribute("title",ttl);
  789. }}_jqOvrly.show();
  790. };
  791. this.dialog=function(selector,option,value){var sl=selector,u=option,t,s,o,v=value,keys,a,tg="",id="",cls="module-judy-dialog",cls1="",elm,jq,dialExists,fxd,title,doOpen,autoOpenLater,to;
  792. if($.ui&&typeof $.ui.dialog==="function"){if(u){if((t=typeof u)==="string"){if(u!=="option"){s=u;
  793. }else{if(v&&typeof v==="object"){o=self.containerCopy(v);
  794. }}}else{if(t==="object"){o=self.containerCopy(u);
  795. }}}if(sl){if(typeof sl==="string"){if(sl.indexOf("#")===-1&&sl.indexOf(".")===-1){if((elm=document.getElementById(id=sl))&&self.arrayIndexOf(_dialogs,id)>-1){dialExists=true;
  796. }}else{if((elm=$(sl).get(0))){if((id=elm.id)){if(self.arrayIndexOf(_dialogs,id)>-1){dialExists=true;
  797. }}else{id=elm.id=self.randName();
  798. }}else{a=sl.replace(/^([a-z\d_\-]+)?(\#[a-z\d_\-]+)?(\.[a-z\d_\-]+)?$/,"$1,$2,$3").split(",");
  799. tg=a[0];
  800. id=a[1]?a[1].substr(1):self.randName();
  801. if(a[2]){cls1=" "+a[2].split(/\./).join(" ");
  802. }}}}else{if(typeof sl==="object"&&sl.getAttributeNode){if((id=elm.id)){if(self.arrayIndexOf(_dialogs,id)>-1){dialExists=true;
  803. }}else{id=elm.id=self.randName();
  804. }}}}else{id=self.randName();
  805. }if(dialExists){doOpen=false;
  806. jq=$(elm);
  807. if(o){delete o.fixed;
  808. if((keys=self.objectKeys(o)).length===1){v=o[s=keys[0]];
  809. }}if(s){if(s==="content"){if(jq.dialog("isOpen")){doOpen=true;
  810. }jq.html(v);
  811. if(doOpen){if(doOpen){to=setTimeout(function(){jq.dialog("open");
  812. },100);
  813. }}return id;
  814. }if(s==="getContent"){return jq.html();
  815. }if(s==="title"){$(".ui-dialog-title",$(elm.parentNode)).html(v);
  816. return id;
  817. }else{if(self.arrayIndexOf(_dialOpts,s)>-1||self.arrayIndexOf(_dialEvts,s)>-1){jq.dialog("option",s,v);
  818. }}if(self.arrayIndexOf(_dialMthds,s)>-1){return jq.dialog(s);
  819. }jq.dialog(s,v);
  820. return id;
  821. }else{if(o){if(jq.dialog("isOpen")){doOpen=true;
  822. jq.dialog("close");
  823. }if(o.close&&o.hasOwnProperty("close")&&typeof o.close!=="function"){doOpen=false;
  824. delete o.close;
  825. }if(o.content!==undefined&&o.hasOwnProperty("content")){jq.html(v);
  826. delete o.content;
  827. }if(o.open&&o.hasOwnProperty("open")){doOpen=true;
  828. delete o.open;
  829. }jq.dialog(o);
  830. if(doOpen){to=setTimeout(function(){jq.dialog("open");
  831. },100);
  832. }}}return id;
  833. }doOpen=true;
  834. if(!o){o={};
  835. if(s){o[s]=v;
  836. }}if(!elm){$(document.body).append("<"+(tg||"div")+' id="'+id+'" class="'+cls+cls1+(!o.contentClass?"":(" "+o.contentClass))+'"></'+(tg||"div")+">");
  837. elm=document.getElementById(id);
  838. }jq=$(elm);
  839. if(o.open&&o.hasOwnProperty("open")){delete o.open;
  840. }if(!o.autoOpen&&o.hasOwnProperty("autoOpen")){doOpen=false;
  841. }else{autoOpenLater=true;
  842. o.autoOpen=false;
  843. }if((u=self.objectGet(o,"content"))){jq.html(u);
  844. delete o.content;
  845. }if(o.fixed&&o.hasOwnProperty("fixed")){fxd=true;
  846. delete o.fixed;
  847. }if(o.title&&o.hasOwnProperty("title")){title=o.title;
  848. delete o.title;
  849. }jq.dialog(o);
  850. u=$(elm.parentNode);
  851. if(fxd){u.css("position","fixed");
  852. }if(title!==undefined){$(".ui-dialog-title",u).html(title);
  853. }u.addClass(cls+"-container");
  854. _dialogs.push(id);
  855. if(doOpen){to=setTimeout(function(){jq.dialog("open");
  856. if(autoOpenLater){jq.dialog("autoOpen",true);
  857. }},100);
  858. }return id;
  859. }try{throw new Error("jQuery UI Dialog not included");
  860. }catch(er){_errorHandler(er,null,_name+".dialog()");
  861. }return false;
  862. };
  863. this.timer=function(o,func,args,delay){return new self.Timer(o,func,args,delay);
  864. };
  865. this.Timer=function(o,func,args,delay){var a=args||[],fired=false,f=o?function(){fired=true;
  866. try{func.apply(o,a);
  867. }catch(er){}}:function(){fired=true;
  868. try{func();
  869. }catch(er){}},t=window.setTimeout(f,delay||0);
  870. this.fired=function(){return fired;
  871. };
  872. this.cancel=function(){window.clearTimeout(t);
  873. };
  874. };
  875. };
  876. (Drupal.Judy=window.Judy=window.judy=new Judy($)).setup();
  877. })(jQuery);