diff --git a/apps/showcase/src/main/webapp/tags/ui/datepicker/index.jsp b/apps/showcase/src/main/webapp/tags/ui/datepicker/index.jsp index cba4f72b3..5fbd01935 100644 --- a/apps/showcase/src/main/webapp/tags/ui/datepicker/index.jsp +++ b/apps/showcase/src/main/webapp/tags/ui/datepicker/index.jsp @@ -5,7 +5,7 @@ UI Tags Example - + @@ -16,8 +16,8 @@ - - + +
diff --git a/apps/showcase/src/main/webapp/tags/ui/timepicker/index.jsp b/apps/showcase/src/main/webapp/tags/ui/timepicker/index.jsp index 5a9b892ca..dc31c88db 100644 --- a/apps/showcase/src/main/webapp/tags/ui/timepicker/index.jsp +++ b/apps/showcase/src/main/webapp/tags/ui/timepicker/index.jsp @@ -5,7 +5,7 @@ UI Tags Example - + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/LICENSE b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/LICENSE index f18ac7059..225d20c79 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/LICENSE +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/LICENSE @@ -13,20 +13,20 @@ The text of the AFL and BSD licenses is reproduced below. The "New" BSD License: ********************** -Copyright (c) 2005, The Dojo Foundation +Copyright (c) 2005-2006, The Dojo Foundation All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. + list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. * Neither the name of the Dojo Foundation nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. + may be used to endorse or promote products derived from this software + without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/README b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/README index 198c01157..2bb84eaf2 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/README +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/README @@ -100,7 +100,7 @@ problems. You're most likely to find them at: irc.freenode.net #dojo -Note that 2PM Wed PST in this channel is reserved for a weekly meeting between +Note that 3PM Wed PST in #dojo-meeting is reserved for a weekly meeting between project developers, although anyone is welcome to participate. diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/build.txt b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/build.txt index f2f83a836..8bb8093ff 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/build.txt +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/build.txt @@ -1,86 +1,35 @@ - -Files baked into this package: - -dojoGuardStart.js, -../src/bootstrap1.js, -../src/loader.js, -dojoGuardEnd.js, -../src/hostenv_browser.js, -../src/bootstrap2.js, -../src/lang/common.js, -../src/lang.js, -../src/dom.js, -../src/html/common.js, -../src/uri/Uri.js, -../src/html/style.js, -../src/html/__package__.js, -../src/html/display.js, -../src/html/layout.js, -../src/html/util.js, -../src/lang/array.js, -../src/gfx/color.js, -../src/lang/func.js, -../src/lfx/Animation.js, -../src/html/color.js, -../src/lfx/html.js, -../src/lfx/__package__.js, -../src/lang/extras.js, -../src/event/common.js, -../src/event/topic.js, -../src/event/browser.js, -../src/event/__package__.js, -../src/logging/Logger.js, -../src/logging/__package__.js, -../src/string/common.js, -../src/string.js, -../src/io/common.js, -../src/string/extras.js, -../src/undo/browser.js, -../src/io/BrowserIO.js, -../src/io/cookie.js, -../src/io/__package__.js, -../src/uri/__package__.js, -../src/io/IframeIO.js, -../src/date.js, -../src/string/Builder.js, -../src/string/__package__.js, -../__package__.js, -../src/AdapterRegistry.js, -../src/json.js, -../src/Deferred.js, -../src/rpc/RpcService.js, -../src/rpc/JsonService.js, -../src/rpc/__package__.js, -../src/xml/Parse.js, -../src/xml/__package__.js, -../src/undo/Manager.js, -../src/undo/__package__.js, -../src/crypto.js, -../src/crypto/MD5.js, -../src/crypto/__package__.js, -../src/collections/Collections.js, -../src/collections/ArrayList.js, -../src/collections/Queue.js, -../src/collections/Stack.js, -../src/lang/declare.js, -../src/dnd/DragAndDrop.js, -../src/dnd/HtmlDragManager.js, -../src/html/selection.js, -../src/html/iframe.js, -../src/dnd/HtmlDragAndDrop.js, -../src/dnd/__package__.js, -../src/ns.js, -../src/widget/Manager.js, -../src/a11y.js, -../src/widget/Widget.js, -../src/widget/Parse.js, -../src/widget/DomWidget.js, -../src/lfx/toggle.js, -../src/widget/HtmlWidget.js, -../src/widget/__package__.js, -../src/math.js, -../src/math/curves.js, -../src/math/points.js, -../src/math/__package__.js - - \ No newline at end of file +Files baked into this build: +dojoGuardStart.js +../src/bootstrap1.js +../src/loader.js +dojoGuardEnd.js +../src/hostenv_browser.js +../src/lang/common.js +../src/lang/array.js +../src/lang/extras.js +../src/lang/declare.js +../src/lang/func.js +../src/event/common.js +../src/event/topic.js +../src/event/browser.js +../src/event/__package__.js +../src/event.js +../src/string/common.js +../src/string/extras.js +../src/string.js +../src/io/common.js +../src/dom.js +../src/undo/browser.js +../src/io/BrowserIO.js +../src/io/cookie.js +../src/io/__package__.js +../src/io.js +../src/AdapterRegistry.js +../src/json.js +../src/html/common.js +../src/uri/Uri.js +../src/html/style.js +../src/html/__package__.js +../src/html/display.js +../src/html/layout.js +../src/html/util.js \ No newline at end of file diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/dojo.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/dojo.js index fa573795e..880b39430 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/dojo.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/dojo.js @@ -33,7 +33,7 @@ dojo.global=function(){ return dj_currentContext; }; dojo.locale=djConfig.locale; -dojo.version={major:0,minor:4,patch:0,flag:"",revision:Number("$Rev: 6258 $".match(/[0-9]+/)[0]),toString:function(){ +dojo.version={major:0,minor:4,patch:2,flag:"",revision:Number("$Rev: 7616 $".match(/[0-9]+/)[0]),toString:function(){ with(dojo.version){ return major+"."+minor+"."+patch+flag+" ("+revision+")"; } @@ -83,6 +83,8 @@ return _11; dojo.raise=function(_12,_13){ if(_13){ _12=_12+": "+dojo.errorToString(_13); +}else{ +_12=dojo.errorToString(_12); } try{ if(djConfig.isDebug){ @@ -287,7 +289,7 @@ dojo.hostenv.callLoaded(); } }; dojo.hostenv.callLoaded=function(){ -if(typeof setTimeout=="object"){ +if(typeof setTimeout=="object"||(djConfig["useXDomain"]&&dojo.render.html.opera)){ setTimeout("dojo.hostenv.loaded();",0); }else{ dojo.hostenv.loaded(); @@ -435,6 +437,11 @@ return dojo.hostenv.startPackage.apply(dojo.hostenv,arguments); dojo.registerModulePath=function(_66,_67){ return dojo.hostenv.setModulePrefix(_66,_67); }; +if(djConfig["modulePaths"]){ +for(var param in djConfig["modulePaths"]){ +dojo.registerModulePath(param,djConfig["modulePaths"][param]); +} +} dojo.setModulePrefix=function(_68,_69){ dojo.deprecated("dojo.setModulePrefix(\""+_68+"\", \""+_69+"\")","replaced by dojo.registerModulePath","0.5"); return dojo.registerModulePath(_68,_69); @@ -450,23 +457,27 @@ obj=obj[p[i]]; return true; }; dojo.hostenv.normalizeLocale=function(_6e){ -return _6e?_6e.toLowerCase():dojo.locale; +var _6f=_6e?_6e.toLowerCase():dojo.locale; +if(_6f=="root"){ +_6f="ROOT"; +} +return _6f; }; -dojo.hostenv.searchLocalePath=function(_6f,_70,_71){ -_6f=dojo.hostenv.normalizeLocale(_6f); -var _72=_6f.split("-"); -var _73=[]; -for(var i=_72.length;i>0;i--){ -_73.push(_72.slice(0,i).join("-")); +dojo.hostenv.searchLocalePath=function(_70,_71,_72){ +_70=dojo.hostenv.normalizeLocale(_70); +var _73=_70.split("-"); +var _74=[]; +for(var i=_73.length;i>0;i--){ +_74.push(_73.slice(0,i).join("-")); } -_73.push(false); -if(_70){ -_73.reverse(); +_74.push(false); +if(_71){ +_74.reverse(); } -for(var j=_73.length-1;j>=0;j--){ -var loc=_73[j]||"ROOT"; -var _77=_71(loc); -if(_77){ +for(var j=_74.length-1;j>=0;j--){ +var loc=_74[j]||"ROOT"; +var _78=_72(loc); +if(_78){ break; } } @@ -478,9 +489,9 @@ dojo.registerModulePath("nls","nls"); dojo.hostenv.preloadLocalizations=function(){ if(dojo.hostenv.localesGenerated){ dojo.hostenv.registerNlsPrefix(); -function preload(_78){ -_78=dojo.hostenv.normalizeLocale(_78); -dojo.hostenv.searchLocalePath(_78,true,function(loc){ +function preload(_79){ +_79=dojo.hostenv.normalizeLocale(_79); +dojo.hostenv.searchLocalePath(_79,true,function(loc){ for(var i=0;i_84.length){ +_84=_85[i]; +} +} +} +if(!_84){ +_84="ROOT"; +} +} +var _87=_81?_84:_82; +var _88=dojo.hostenv.findModule(_83); +var _89=null; +if(_88){ +if(djConfig.localizationComplete&&_88._built){ return; } -var _82=dojo.hostenv.normalizeLocale(_7f).replace("-","_"); -var _83=_80+"."+_82; -if(dojo.hostenv.findModule(_83)){ -return; +var _8a=_87.replace("-","_"); +var _8b=_83+"."+_8a; +_89=dojo.hostenv.findModule(_8b); } -} -_81=dojo.hostenv.startPackage(_80); -var _84=dojo.hostenv.getModuleSymbols(_7d); -var _85=_84.concat("nls").join("/"); -var _86; -dojo.hostenv.searchLocalePath(_7f,false,function(loc){ -var _88=loc.replace("-","_"); -var _89=_80+"."+_88; -var _8a=false; -if(!dojo.hostenv.findModule(_89)){ -dojo.hostenv.startPackage(_89); -var _8b=[_85]; +if(!_89){ +_88=dojo.hostenv.startPackage(_83); +var _8c=dojo.hostenv.getModuleSymbols(_7e); +var _8d=_8c.concat("nls").join("/"); +var _8e; +dojo.hostenv.searchLocalePath(_87,_81,function(loc){ +var _90=loc.replace("-","_"); +var _91=_83+"."+_90; +var _92=false; +if(!dojo.hostenv.findModule(_91)){ +dojo.hostenv.startPackage(_91); +var _93=[_8d]; if(loc!="ROOT"){ -_8b.push(loc); +_93.push(loc); } -_8b.push(_7e); -var _8c=_8b.join("/")+".js"; -_8a=dojo.hostenv.loadPath(_8c,null,function(_8d){ -var _8e=function(){ +_93.push(_7f); +var _94=_93.join("/")+".js"; +_92=dojo.hostenv.loadPath(_94,null,function(_95){ +var _96=function(){ }; -_8e.prototype=_86; -_81[_88]=new _8e(); -for(var j in _8d){ -_81[_88][j]=_8d[j]; +_96.prototype=_8e; +_88[_90]=new _96(); +for(var j in _95){ +_88[_90][j]=_95[j]; } }); }else{ -_8a=true; +_92=true; } -if(_8a&&_81[_88]){ -_86=_81[_88]; +if(_92&&_88[_90]){ +_8e=_88[_90]; }else{ -_81[_88]=_86; +_88[_90]=_8e; +} +if(_81){ +return true; } }); +} +if(_81&&_82!=_84){ +_88[_82.replace("-","_")]=_88[_84.replace("-","_")]; +} }; (function(){ -var _90=djConfig.extraLocale; -if(_90){ -if(!_90 instanceof Array){ -_90=[_90]; +var _98=djConfig.extraLocale; +if(_98){ +if(!_98 instanceof Array){ +_98=[_98]; } var req=dojo.requireLocalization; -dojo.requireLocalization=function(m,b,_94){ -req(m,b,_94); -if(_94){ +dojo.requireLocalization=function(m,b,_9c,_9d){ +req(m,b,_9c,_9d); +if(_9c){ return; } -for(var i=0;i<_90.length;i++){ -req(m,b,_90[i]); +for(var i=0;i<_98.length;i++){ +req(m,b,_98[i],_9d); } }; } @@ -570,13 +604,13 @@ req(m,b,_90[i]); if(typeof window!="undefined"){ (function(){ if(djConfig.allowQueryConfig){ -var _96=document.location.toString(); -var _97=_96.split("?",2); -if(_97.length>1){ -var _98=_97[1]; -var _99=_98.split("&"); -for(var x in _99){ -var sp=_99[x].split("="); +var _9f=document.location.toString(); +var _a0=_9f.split("?",2); +if(_a0.length>1){ +var _a1=_a0[1]; +var _a2=_a1.split("&"); +for(var x in _a2){ +var sp=_a2[x].split("="); if((sp[0].length>9)&&(sp[0].substr(0,9)=="djConfig.")){ var opt=sp[0].substr(9); try{ @@ -590,27 +624,27 @@ djConfig[opt]=sp[1]; } } if(((djConfig["baseScriptUri"]=="")||(djConfig["baseRelativePath"]==""))&&(document&&document.getElementsByTagName)){ -var _9d=document.getElementsByTagName("script"); -var _9e=/(__package__|dojo|bootstrap1)\.js([\?\.]|$)/i; -for(var i=0;i<_9d.length;i++){ -var src=_9d[i].getAttribute("src"); +var _a6=document.getElementsByTagName("script"); +var _a7=/(__package__|dojo|bootstrap1)\.js([\?\.]|$)/i; +for(var i=0;i<_a6.length;i++){ +var src=_a6[i].getAttribute("src"); if(!src){ continue; } -var m=src.match(_9e); +var m=src.match(_a7); if(m){ -var _a2=src.substring(0,m.index); +var _ab=src.substring(0,m.index); if(src.indexOf("bootstrap1")>-1){ -_a2+="../"; +_ab+="../"; } if(!this["djConfig"]){ djConfig={}; } if(djConfig["baseScriptUri"]==""){ -djConfig["baseScriptUri"]=_a2; +djConfig["baseScriptUri"]=_ab; } if(djConfig["baseRelativePath"]==""){ -djConfig["baseRelativePath"]=_a2; +djConfig["baseRelativePath"]=_ab; } break; } @@ -632,10 +666,10 @@ dr.os.linux=dav.indexOf("X11")>=0; drh.opera=dua.indexOf("Opera")>=0; drh.khtml=(dav.indexOf("Konqueror")>=0)||(dav.indexOf("Safari")>=0); drh.safari=dav.indexOf("Safari")>=0; -var _aa=dua.indexOf("Gecko"); -drh.mozilla=drh.moz=(_aa>=0)&&(!drh.khtml); +var _b3=dua.indexOf("Gecko"); +drh.mozilla=drh.moz=(_b3>=0)&&(!drh.khtml); if(drh.mozilla){ -drh.geckoVersion=dua.substring(_aa+6,_aa+14); +drh.geckoVersion=dua.substring(_b3+6,_b3+14); } drh.ie=(document.all)&&(!drh.opera); drh.ie50=drh.ie&&dav.indexOf("MSIE 5.0")>=0; @@ -649,8 +683,8 @@ dr.vml.capable=drh.ie; drs.capable=f; drs.support.plugin=f; drs.support.builtin=f; -var _ac=window["document"]; -var tdi=_ac["implementation"]; +var _b5=window["document"]; +var tdi=_b5["implementation"]; if((tdi)&&(tdi["hasFeature"])&&(tdi.hasFeature("org.w3c.dom.svg","1.0"))){ drs.capable=t; drs.support.builtin=t; @@ -664,6 +698,7 @@ drs.capable=t; drs.support.builtin=t; drs.support.plugin=f; } +}else{ } })(); dojo.hostenv.startPackage("dojo.hostenv"); @@ -671,110 +706,110 @@ dojo.render.name=dojo.hostenv.name_="browser"; dojo.hostenv.searchIds=[]; dojo.hostenv._XMLHTTP_PROGIDS=["Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0"]; dojo.hostenv.getXmlhttpObject=function(){ -var _b0=null; -var _b1=null; +var _b9=null; +var _ba=null; try{ -_b0=new XMLHttpRequest(); +_b9=new XMLHttpRequest(); } catch(e){ } -if(!_b0){ +if(!_b9){ for(var i=0;i<3;++i){ -var _b3=dojo.hostenv._XMLHTTP_PROGIDS[i]; +var _bc=dojo.hostenv._XMLHTTP_PROGIDS[i]; try{ -_b0=new ActiveXObject(_b3); +_b9=new ActiveXObject(_bc); } catch(e){ -_b1=e; +_ba=e; } -if(_b0){ -dojo.hostenv._XMLHTTP_PROGIDS=[_b3]; +if(_b9){ +dojo.hostenv._XMLHTTP_PROGIDS=[_bc]; break; } } } -if(!_b0){ -return dojo.raise("XMLHTTP not available",_b1); +if(!_b9){ +return dojo.raise("XMLHTTP not available",_ba); } -return _b0; +return _b9; }; dojo.hostenv._blockAsync=false; -dojo.hostenv.getText=function(uri,_b5,_b6){ -if(!_b5){ +dojo.hostenv.getText=function(uri,_be,_bf){ +if(!_be){ this._blockAsync=true; } -var _b7=this.getXmlhttpObject(); -function isDocumentOk(_b8){ -var _b9=_b8["status"]; -return Boolean((!_b9)||((200<=_b9)&&(300>_b9))||(_b9==304)); +var _c0=this.getXmlhttpObject(); +function isDocumentOk(_c1){ +var _c2=_c1["status"]; +return Boolean((!_c2)||((200<=_c2)&&(300>_c2))||(_c2==304)); } -if(_b5){ -var _ba=this,_bb=null,gbl=dojo.global(); +if(_be){ +var _c3=this,_c4=null,gbl=dojo.global(); var xhr=dojo.evalObjPath("dojo.io.XMLHTTPTransport"); -_b7.onreadystatechange=function(){ -if(_bb){ -gbl.clearTimeout(_bb); -_bb=null; +_c0.onreadystatechange=function(){ +if(_c4){ +gbl.clearTimeout(_c4); +_c4=null; } -if(_ba._blockAsync||(xhr&&xhr._blockAsync)){ -_bb=gbl.setTimeout(function(){ -_b7.onreadystatechange.apply(this); +if(_c3._blockAsync||(xhr&&xhr._blockAsync)){ +_c4=gbl.setTimeout(function(){ +_c0.onreadystatechange.apply(this); },10); }else{ -if(4==_b7.readyState){ -if(isDocumentOk(_b7)){ -_b5(_b7.responseText); +if(4==_c0.readyState){ +if(isDocumentOk(_c0)){ +_be(_c0.responseText); } } } }; } -_b7.open("GET",uri,_b5?true:false); +_c0.open("GET",uri,_be?true:false); try{ -_b7.send(null); -if(_b5){ +_c0.send(null); +if(_be){ return null; } -if(!isDocumentOk(_b7)){ -var err=Error("Unable to load "+uri+" status:"+_b7.status); -err.status=_b7.status; -err.responseText=_b7.responseText; +if(!isDocumentOk(_c0)){ +var err=Error("Unable to load "+uri+" status:"+_c0.status); +err.status=_c0.status; +err.responseText=_c0.responseText; throw err; } } catch(e){ this._blockAsync=false; -if((_b6)&&(!_b5)){ +if((_bf)&&(!_be)){ return null; }else{ throw e; } } this._blockAsync=false; -return _b7.responseText; +return _c0.responseText; }; dojo.hostenv.defaultDebugContainerId="dojoDebug"; dojo.hostenv._println_buffer=[]; dojo.hostenv._println_safe=false; -dojo.hostenv.println=function(_bf){ +dojo.hostenv.println=function(_c8){ if(!dojo.hostenv._println_safe){ -dojo.hostenv._println_buffer.push(_bf); +dojo.hostenv._println_buffer.push(_c8); }else{ try{ -var _c0=document.getElementById(djConfig.debugContainerId?djConfig.debugContainerId:dojo.hostenv.defaultDebugContainerId); -if(!_c0){ -_c0=dojo.body(); +var _c9=document.getElementById(djConfig.debugContainerId?djConfig.debugContainerId:dojo.hostenv.defaultDebugContainerId); +if(!_c9){ +_c9=dojo.body(); } var div=document.createElement("div"); -div.appendChild(document.createTextNode(_bf)); -_c0.appendChild(div); +div.appendChild(document.createTextNode(_c8)); +_c9.appendChild(div); } catch(e){ try{ -document.write("
"+_bf+"
"); +document.write("
"+_c8+"
"); } catch(e2){ -window.status=_bf; +window.status=_c8; } } } @@ -785,18 +820,18 @@ while(dojo.hostenv._println_buffer.length>0){ dojo.hostenv.println(dojo.hostenv._println_buffer.shift()); } }); -function dj_addNodeEvtHdlr(_c2,_c3,fp,_c5){ -var _c6=_c2["on"+_c3]||function(){ +function dj_addNodeEvtHdlr(_cb,_cc,fp){ +var _ce=_cb["on"+_cc]||function(){ }; -_c2["on"+_c3]=function(){ -fp.apply(_c2,arguments); -_c6.apply(_c2,arguments); +_cb["on"+_cc]=function(){ +fp.apply(_cb,arguments); +_ce.apply(_cb,arguments); }; return true; } function dj_load_init(e){ -var _c8=(e&&e.type)?e.type.toLowerCase():"load"; -if(arguments.callee.initialized||(_c8!="domcontentloaded"&&_c8!="load")){ +var _d0=(e&&e.type)?e.type.toLowerCase():"load"; +if(arguments.callee.initialized||(_d0!="domcontentloaded"&&_d0!="load")){ return; } arguments.callee.initialized=true; @@ -804,20 +839,20 @@ if(typeof (_timer)!="undefined"){ clearInterval(_timer); delete _timer; } -var _c9=function(){ +var _d1=function(){ if(dojo.render.html.ie){ dojo.hostenv.makeWidgets(); } }; if(dojo.hostenv.inFlightCount==0){ -_c9(); +_d1(); dojo.hostenv.modulesLoaded(); }else{ -dojo.addOnLoad(_c9); +dojo.hostenv.modulesLoadedListeners.unshift(_d1); } } if(document.addEventListener){ -if(dojo.render.html.opera||(dojo.render.html.moz&&!djConfig.delayMozLoadingFix)){ +if(dojo.render.html.opera||(dojo.render.html.moz&&(djConfig["enableMozDomContentLoaded"]===true))){ document.addEventListener("DOMContentLoaded",dj_load_init,null); } window.addEventListener("load",dj_load_init,null); @@ -851,29 +886,29 @@ dojo.hostenv.unloaded(); } }); dojo.hostenv.makeWidgets=function(){ -var _cb=[]; +var _d3=[]; if(djConfig.searchIds&&djConfig.searchIds.length>0){ -_cb=_cb.concat(djConfig.searchIds); +_d3=_d3.concat(djConfig.searchIds); } if(dojo.hostenv.searchIds&&dojo.hostenv.searchIds.length>0){ -_cb=_cb.concat(dojo.hostenv.searchIds); +_d3=_d3.concat(dojo.hostenv.searchIds); } -if((djConfig.parseWidgets)||(_cb.length>0)){ +if((djConfig.parseWidgets)||(_d3.length>0)){ if(dojo.evalObjPath("dojo.widget.Parse")){ -var _cc=new dojo.xml.Parse(); -if(_cb.length>0){ -for(var x=0;x<_cb.length;x++){ -var _ce=document.getElementById(_cb[x]); -if(!_ce){ +var _d4=new dojo.xml.Parse(); +if(_d3.length>0){ +for(var x=0;x<_d3.length;x++){ +var _d6=document.getElementById(_d3[x]); +if(!_d6){ continue; } -var _cf=_cc.parseElement(_ce,null,true); -dojo.widget.getParser().createComponents(_cf); +var _d7=_d4.parseElement(_d6,null,true); +dojo.widget.getParser().createComponents(_d7); } }else{ if(djConfig.parseWidgets){ -var _cf=_cc.parseElement(dojo.body(),null,true); -dojo.widget.getParser().createComponents(_cf); +var _d7=_d4.parseElement(dojo.body(),null,true); +dojo.widget.getParser().createComponents(_d7); } } } @@ -929,90 +964,48 @@ return ele; } return id; }; -dojo.setContext=function(_d4,_d5){ -dj_currentContext=_d4; -dj_currentDocument=_d5; +dojo.setContext=function(_dc,_dd){ +dj_currentContext=_dc; +dj_currentDocument=_dd; }; -dojo._fireCallback=function(_d6,_d7,_d8){ -if((_d7)&&((typeof _d6=="string")||(_d6 instanceof String))){ -_d6=_d7[_d6]; +dojo._fireCallback=function(_de,_df,_e0){ +if((_df)&&((typeof _de=="string")||(_de instanceof String))){ +_de=_df[_de]; } -return (_d7?_d6.apply(_d7,_d8||[]):_d6()); +return (_df?_de.apply(_df,_e0||[]):_de()); }; -dojo.withGlobal=function(_d9,_da,_db,_dc){ -var _dd; -var _de=dj_currentContext; -var _df=dj_currentDocument; +dojo.withGlobal=function(_e1,_e2,_e3,_e4){ +var _e5; +var _e6=dj_currentContext; +var _e7=dj_currentDocument; try{ -dojo.setContext(_d9,_d9.document); -_dd=dojo._fireCallback(_da,_db,_dc); +dojo.setContext(_e1,_e1.document); +_e5=dojo._fireCallback(_e2,_e3,_e4); } finally{ -dojo.setContext(_de,_df); +dojo.setContext(_e6,_e7); } -return _dd; +return _e5; }; -dojo.withDoc=function(_e0,_e1,_e2,_e3){ -var _e4; -var _e5=dj_currentDocument; +dojo.withDoc=function(_e8,_e9,_ea,_eb){ +var _ec; +var _ed=dj_currentDocument; try{ -dj_currentDocument=_e0; -_e4=dojo._fireCallback(_e1,_e2,_e3); +dj_currentDocument=_e8; +_ec=dojo._fireCallback(_e9,_ea,_eb); } finally{ -dj_currentDocument=_e5; +dj_currentDocument=_ed; } -return _e4; +return _ec; }; } -(function(){ -if(typeof dj_usingBootstrap!="undefined"){ -return; -} -var _e6=false; -var _e7=false; -var _e8=false; -if((typeof this["load"]=="function")&&((typeof this["Packages"]=="function")||(typeof this["Packages"]=="object"))){ -_e6=true; -}else{ -if(typeof this["load"]=="function"){ -_e7=true; -}else{ -if(window.widget){ -_e8=true; -} -} -} -var _e9=[]; -if((this["djConfig"])&&((djConfig["isDebug"])||(djConfig["debugAtAllCosts"]))){ -_e9.push("debug.js"); -} -if((this["djConfig"])&&(djConfig["debugAtAllCosts"])&&(!_e6)&&(!_e8)){ -_e9.push("browser_debug.js"); -} -var _ea=djConfig["baseScriptUri"]; -if((this["djConfig"])&&(djConfig["baseLoaderUri"])){ -_ea=djConfig["baseLoaderUri"]; -} -for(var x=0;x<_e9.length;x++){ -var _ec=_ea+"src/"+_e9[x]; -if(_e6||_e7){ -load(_ec); -}else{ -try{ -document.write(""); -} -catch(e){ -var _ed=document.createElement("script"); -_ed.src=_ec; -document.getElementsByTagName("head")[0].appendChild(_ed); -} -} -} -})(); +dojo.requireIf((djConfig["isDebug"]||djConfig["debugAtAllCosts"]),"dojo.debug"); +dojo.requireIf(djConfig["debugAtAllCosts"]&&!window.widget&&!djConfig["useXDomain"],"dojo.browser_debug"); +dojo.requireIf(djConfig["debugAtAllCosts"]&&!window.widget&&djConfig["useXDomain"],"dojo.browser_debug_xd"); dojo.provide("dojo.lang.common"); dojo.lang.inherits=function(_ee,_ef){ -if(typeof _ef!="function"){ +if(!dojo.lang.isFunction(_ef)){ dojo.raise("dojo.inherits: superclass argument ["+_ef+"] must be a function (subclass: ["+_ee+"']"); } _ee.prototype=new _ef(); @@ -1123,14 +1116,18 @@ return true; return false; }; dojo.lang.isFunction=function(it){ -if(!it){ -return false; -} +return (it instanceof Function||typeof it=="function"); +}; +(function(){ +if((dojo.render.html.capable)&&(dojo.render.html["safari"])){ +dojo.lang.isFunction=function(it){ if((typeof (it)=="function")&&(it=="[object NodeList]")){ return false; } return (it instanceof Function||typeof it=="function"); }; +} +})(); dojo.lang.isString=function(it){ return (typeof it=="string"||it instanceof String); }; @@ -1138,7 +1135,7 @@ dojo.lang.isAlien=function(it){ if(!it){ return false; } -return !dojo.lang.isFunction()&&/\{\s*\[native code\]\s*\}/.test(String(it)); +return !dojo.lang.isFunction(it)&&/\{\s*\[native code\]\s*\}/.test(String(it)); }; dojo.lang.isBoolean=function(it){ return (it instanceof Boolean||typeof it=="boolean"); @@ -1149,2049 +1146,151 @@ return (it instanceof Number||typeof it=="number"); dojo.lang.isUndefined=function(it){ return ((typeof (it)=="undefined")&&(it==undefined)); }; -dojo.provide("dojo.lang"); -dojo.deprecated("dojo.lang","replaced by dojo.lang.common","0.5"); -dojo.provide("dojo.dom"); -dojo.dom.ELEMENT_NODE=1; -dojo.dom.ATTRIBUTE_NODE=2; -dojo.dom.TEXT_NODE=3; -dojo.dom.CDATA_SECTION_NODE=4; -dojo.dom.ENTITY_REFERENCE_NODE=5; -dojo.dom.ENTITY_NODE=6; -dojo.dom.PROCESSING_INSTRUCTION_NODE=7; -dojo.dom.COMMENT_NODE=8; -dojo.dom.DOCUMENT_NODE=9; -dojo.dom.DOCUMENT_TYPE_NODE=10; -dojo.dom.DOCUMENT_FRAGMENT_NODE=11; -dojo.dom.NOTATION_NODE=12; -dojo.dom.dojoml="http://www.dojotoolkit.org/2004/dojoml"; -dojo.dom.xmlns={svg:"http://www.w3.org/2000/svg",smil:"http://www.w3.org/2001/SMIL20/",mml:"http://www.w3.org/1998/Math/MathML",cml:"http://www.xml-cml.org",xlink:"http://www.w3.org/1999/xlink",xhtml:"http://www.w3.org/1999/xhtml",xul:"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",xbl:"http://www.mozilla.org/xbl",fo:"http://www.w3.org/1999/XSL/Format",xsl:"http://www.w3.org/1999/XSL/Transform",xslt:"http://www.w3.org/1999/XSL/Transform",xi:"http://www.w3.org/2001/XInclude",xforms:"http://www.w3.org/2002/01/xforms",saxon:"http://icl.com/saxon",xalan:"http://xml.apache.org/xslt",xsd:"http://www.w3.org/2001/XMLSchema",dt:"http://www.w3.org/2001/XMLSchema-datatypes",xsi:"http://www.w3.org/2001/XMLSchema-instance",rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",rdfs:"http://www.w3.org/2000/01/rdf-schema#",dc:"http://purl.org/dc/elements/1.1/",dcq:"http://purl.org/dc/qualifiers/1.0","soap-env":"http://schemas.xmlsoap.org/soap/envelope/",wsdl:"http://schemas.xmlsoap.org/wsdl/",AdobeExtensions:"http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"}; -dojo.dom.isNode=function(wh){ -if(typeof Element=="function"){ -try{ -return wh instanceof Element; -} -catch(E){ -} -}else{ -return wh&&!isNaN(wh.nodeType); -} -}; -dojo.dom.getUniqueId=function(){ -var _114=dojo.doc(); -do{ -var id="dj_unique_"+(++arguments.callee._idIncrement); -}while(_114.getElementById(id)); -return id; -}; -dojo.dom.getUniqueId._idIncrement=0; -dojo.dom.firstElement=dojo.dom.getFirstChildElement=function(_116,_117){ -var node=_116.firstChild; -while(node&&node.nodeType!=dojo.dom.ELEMENT_NODE){ -node=node.nextSibling; -} -if(_117&&node&&node.tagName&&node.tagName.toLowerCase()!=_117.toLowerCase()){ -node=dojo.dom.nextElement(node,_117); -} -return node; -}; -dojo.dom.lastElement=dojo.dom.getLastChildElement=function(_119,_11a){ -var node=_119.lastChild; -while(node&&node.nodeType!=dojo.dom.ELEMENT_NODE){ -node=node.previousSibling; -} -if(_11a&&node&&node.tagName&&node.tagName.toLowerCase()!=_11a.toLowerCase()){ -node=dojo.dom.prevElement(node,_11a); -} -return node; -}; -dojo.dom.nextElement=dojo.dom.getNextSiblingElement=function(node,_11d){ -if(!node){ -return null; -} -do{ -node=node.nextSibling; -}while(node&&node.nodeType!=dojo.dom.ELEMENT_NODE); -if(node&&_11d&&_11d.toLowerCase()!=node.tagName.toLowerCase()){ -return dojo.dom.nextElement(node,_11d); -} -return node; -}; -dojo.dom.prevElement=dojo.dom.getPreviousSiblingElement=function(node,_11f){ -if(!node){ -return null; -} -if(_11f){ -_11f=_11f.toLowerCase(); -} -do{ -node=node.previousSibling; -}while(node&&node.nodeType!=dojo.dom.ELEMENT_NODE); -if(node&&_11f&&_11f.toLowerCase()!=node.tagName.toLowerCase()){ -return dojo.dom.prevElement(node,_11f); -} -return node; -}; -dojo.dom.moveChildren=function(_120,_121,trim){ -var _123=0; -if(trim){ -while(_120.hasChildNodes()&&_120.firstChild.nodeType==dojo.dom.TEXT_NODE){ -_120.removeChild(_120.firstChild); -} -while(_120.hasChildNodes()&&_120.lastChild.nodeType==dojo.dom.TEXT_NODE){ -_120.removeChild(_120.lastChild); -} -} -while(_120.hasChildNodes()){ -_121.appendChild(_120.firstChild); -_123++; -} -return _123; -}; -dojo.dom.copyChildren=function(_124,_125,trim){ -var _127=_124.cloneNode(true); -return this.moveChildren(_127,_125,trim); -}; -dojo.dom.removeChildren=function(node){ -var _129=node.childNodes.length; -while(node.hasChildNodes()){ -node.removeChild(node.firstChild); -} -return _129; -}; -dojo.dom.replaceChildren=function(node,_12b){ -dojo.dom.removeChildren(node); -node.appendChild(_12b); -}; -dojo.dom.removeNode=function(node){ -if(node&&node.parentNode){ -return node.parentNode.removeChild(node); -} -}; -dojo.dom.getAncestors=function(node,_12e,_12f){ -var _130=[]; -var _131=(_12e&&(_12e instanceof Function||typeof _12e=="function")); -while(node){ -if(!_131||_12e(node)){ -_130.push(node); -} -if(_12f&&_130.length>0){ -return _130[0]; -} -node=node.parentNode; -} -if(_12f){ -return null; -} -return _130; -}; -dojo.dom.getAncestorsByTag=function(node,tag,_134){ -tag=tag.toLowerCase(); -return dojo.dom.getAncestors(node,function(el){ -return ((el.tagName)&&(el.tagName.toLowerCase()==tag)); -},_134); -}; -dojo.dom.getFirstAncestorByTag=function(node,tag){ -return dojo.dom.getAncestorsByTag(node,tag,true); -}; -dojo.dom.isDescendantOf=function(node,_139,_13a){ -if(_13a&&node){ -node=node.parentNode; -} -while(node){ -if(node==_139){ -return true; -} -node=node.parentNode; -} -return false; -}; -dojo.dom.innerXML=function(node){ -if(node.innerXML){ -return node.innerXML; -}else{ -if(node.xml){ -return node.xml; -}else{ -if(typeof XMLSerializer!="undefined"){ -return (new XMLSerializer()).serializeToString(node); -} -} -} -}; -dojo.dom.createDocument=function(){ -var doc=null; -var _13d=dojo.doc(); -if(!dj_undef("ActiveXObject")){ -var _13e=["MSXML2","Microsoft","MSXML","MSXML3"]; -for(var i=0;i<_13e.length;i++){ -try{ -doc=new ActiveXObject(_13e[i]+".XMLDOM"); -} -catch(e){ -} -if(doc){ -break; -} -} -}else{ -if((_13d.implementation)&&(_13d.implementation.createDocument)){ -doc=_13d.implementation.createDocument("","",null); -} -} -return doc; -}; -dojo.dom.createDocumentFromText=function(str,_141){ -if(!_141){ -_141="text/xml"; -} -if(!dj_undef("DOMParser")){ -var _142=new DOMParser(); -return _142.parseFromString(str,_141); -}else{ -if(!dj_undef("ActiveXObject")){ -var _143=dojo.dom.createDocument(); -if(_143){ -_143.async=false; -_143.loadXML(str); -return _143; -}else{ -dojo.debug("toXml didn't work?"); -} -}else{ -var _144=dojo.doc(); -if(_144.createElement){ -var tmp=_144.createElement("xml"); -tmp.innerHTML=str; -if(_144.implementation&&_144.implementation.createDocument){ -var _146=_144.implementation.createDocument("foo","",null); -for(var i=0;i1){ -var _15e=dojo.doc(); -dojo.dom.replaceChildren(node,_15e.createTextNode(text)); -return text; -}else{ -if(node.textContent!=undefined){ -return node.textContent; -} -var _15f=""; -if(node==null){ -return _15f; -} -for(var i=0;i0&&!(j==1&&segs[0]=="")&&segs[j]==".."&&segs[j-1]!=".."){ -if(j==segs.length-1){ -segs.splice(j,1); -segs[j-1]=""; -}else{ -segs.splice(j-1,2); -j-=2; -} -} -} -} -_196.path=segs.join("/"); -} -} -} -} -uri=""; -if(_196.scheme!=null){ -uri+=_196.scheme+":"; -} -if(_196.authority!=null){ -uri+="//"+_196.authority; -} -uri+=_196.path; -if(_196.query!=null){ -uri+="?"+_196.query; -} -if(_196.fragment!=null){ -uri+="#"+_196.fragment; -} -} -this.uri=uri.toString(); -var _19b="^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$"; -var r=this.uri.match(new RegExp(_19b)); -this.scheme=r[2]||(r[1]?"":null); -this.authority=r[4]||(r[3]?"":null); -this.path=r[5]; -this.query=r[7]||(r[6]?"":null); -this.fragment=r[9]||(r[8]?"":null); -if(this.authority!=null){ -_19b="^((([^:]+:)?([^@]+))@)?([^:]*)(:([0-9]+))?$"; -r=this.authority.match(new RegExp(_19b)); -this.user=r[3]||null; -this.password=r[4]||null; -this.host=r[5]; -this.port=r[7]||null; -} -this.toString=function(){ -return this.uri; -}; -}; -}; -dojo.provide("dojo.html.style"); -dojo.html.getClass=function(node){ -node=dojo.byId(node); -if(!node){ -return ""; -} -var cs=""; -if(node.className){ -cs=node.className; -}else{ -if(dojo.html.hasAttribute(node,"class")){ -cs=dojo.html.getAttribute(node,"class"); -} -} -return cs.replace(/^\s+|\s+$/g,""); -}; -dojo.html.getClasses=function(node){ -var c=dojo.html.getClass(node); -return (c=="")?[]:c.split(/\s+/g); -}; -dojo.html.hasClass=function(node,_1a2){ -return (new RegExp("(^|\\s+)"+_1a2+"(\\s+|$)")).test(dojo.html.getClass(node)); -}; -dojo.html.prependClass=function(node,_1a4){ -_1a4+=" "+dojo.html.getClass(node); -return dojo.html.setClass(node,_1a4); -}; -dojo.html.addClass=function(node,_1a6){ -if(dojo.html.hasClass(node,_1a6)){ -return false; -} -_1a6=(dojo.html.getClass(node)+" "+_1a6).replace(/^\s+|\s+$/g,""); -return dojo.html.setClass(node,_1a6); -}; -dojo.html.setClass=function(node,_1a8){ -node=dojo.byId(node); -var cs=new String(_1a8); -try{ -if(typeof node.className=="string"){ -node.className=cs; -}else{ -if(node.setAttribute){ -node.setAttribute("class",_1a8); -node.className=cs; -}else{ -return false; -} -} -} -catch(e){ -dojo.debug("dojo.html.setClass() failed",e); -} -return true; -}; -dojo.html.removeClass=function(node,_1ab,_1ac){ -try{ -if(!_1ac){ -var _1ad=dojo.html.getClass(node).replace(new RegExp("(^|\\s+)"+_1ab+"(\\s+|$)"),"$1$2"); -}else{ -var _1ad=dojo.html.getClass(node).replace(_1ab,""); -} -dojo.html.setClass(node,_1ad); -} -catch(e){ -dojo.debug("dojo.html.removeClass() failed",e); -} -return true; -}; -dojo.html.replaceClass=function(node,_1af,_1b0){ -dojo.html.removeClass(node,_1b0); -dojo.html.addClass(node,_1af); -}; -dojo.html.classMatchType={ContainsAll:0,ContainsAny:1,IsOnly:2}; -dojo.html.getElementsByClass=function(_1b1,_1b2,_1b3,_1b4,_1b5){ -_1b5=false; -var _1b6=dojo.doc(); -_1b2=dojo.byId(_1b2)||_1b6; -var _1b7=_1b1.split(/\s+/g); -var _1b8=[]; -if(_1b4!=1&&_1b4!=2){ -_1b4=0; -} -var _1b9=new RegExp("(\\s|^)(("+_1b7.join(")|(")+"))(\\s|$)"); -var _1ba=_1b7.join(" ").length; -var _1bb=[]; -if(!_1b5&&_1b6.evaluate){ -var _1bc=".//"+(_1b3||"*")+"[contains("; -if(_1b4!=dojo.html.classMatchType.ContainsAny){ -_1bc+="concat(' ',@class,' '), ' "+_1b7.join(" ') and contains(concat(' ',@class,' '), ' ")+" ')"; -if(_1b4==2){ -_1bc+=" and string-length(@class)="+_1ba+"]"; -}else{ -_1bc+="]"; -} -}else{ -_1bc+="concat(' ',@class,' '), ' "+_1b7.join(" ') or contains(concat(' ',@class,' '), ' ")+" ')]"; -} -var _1bd=_1b6.evaluate(_1bc,_1b2,null,XPathResult.ANY_TYPE,null); -var _1be=_1bd.iterateNext(); -while(_1be){ -try{ -_1bb.push(_1be); -_1be=_1bd.iterateNext(); -} -catch(e){ -break; -} -} -return _1bb; -}else{ -if(!_1b3){ -_1b3="*"; -} -_1bb=_1b2.getElementsByTagName(_1b3); -var node,i=0; -outer: -while(node=_1bb[i++]){ -var _1c1=dojo.html.getClasses(node); -if(_1c1.length==0){ -continue outer; -} -var _1c2=0; -for(var j=0;j<_1c1.length;j++){ -if(_1b9.test(_1c1[j])){ -if(_1b4==dojo.html.classMatchType.ContainsAny){ -_1b8.push(node); -continue outer; -}else{ -_1c2++; -} -}else{ -if(_1b4==dojo.html.classMatchType.IsOnly){ -continue outer; -} -} -} -if(_1c2==_1b7.length){ -if((_1b4==dojo.html.classMatchType.IsOnly)&&(_1c2==_1c1.length)){ -_1b8.push(node); -}else{ -if(_1b4==dojo.html.classMatchType.ContainsAll){ -_1b8.push(node); -} -} -} -} -return _1b8; -} -}; -dojo.html.getElementsByClassName=dojo.html.getElementsByClass; -dojo.html.toCamelCase=function(_1c4){ -var arr=_1c4.split("-"),cc=arr[0]; -for(var i=1;i=1){ -if(h.ie){ -dojo.html.clearOpacity(node); -return; -}else{ -_229=0.999999; -} -}else{ -if(_229<0){ -_229=0; -} -} -} -if(h.ie){ -if(node.nodeName.toLowerCase()=="tr"){ -var tds=node.getElementsByTagName("td"); -for(var x=0;x=0.999999?1:Number(opac); -}; -dojo.provide("dojo.html.layout"); -dojo.html.sumAncestorProperties=function(node,prop){ -node=dojo.byId(node); -if(!node){ -return 0; -} -var _236=0; -while(node){ -if(dojo.html.getComputedStyle(node,"position")=="fixed"){ -return 0; -} -var val=node[prop]; -if(val){ -_236+=val-0; -if(node==dojo.body()){ -break; -} -} -node=node.parentNode; -} -return _236; -}; -dojo.html.setStyleAttributes=function(node,_239){ -node=dojo.byId(node); -var _23a=_239.replace(/(;)?\s*$/,"").split(";"); -for(var i=0;i<_23a.length;i++){ -var _23c=_23a[i].split(":"); -var name=_23c[0].replace(/\s*$/,"").replace(/^\s*/,"").toLowerCase(); -var _23e=_23c[1].replace(/\s*$/,"").replace(/^\s*/,""); -switch(name){ -case "opacity": -dojo.html.setOpacity(node,_23e); -break; -case "content-height": -dojo.html.setContentBox(node,{height:_23e}); -break; -case "content-width": -dojo.html.setContentBox(node,{width:_23e}); -break; -case "outer-height": -dojo.html.setMarginBox(node,{height:_23e}); -break; -case "outer-width": -dojo.html.setMarginBox(node,{width:_23e}); -break; -default: -node.style[dojo.html.toCamelCase(name)]=_23e; -} -} -}; -dojo.html.boxSizing={MARGIN_BOX:"margin-box",BORDER_BOX:"border-box",PADDING_BOX:"padding-box",CONTENT_BOX:"content-box"}; -dojo.html.getAbsolutePosition=dojo.html.abs=function(node,_240,_241){ -node=dojo.byId(node,node.ownerDocument); -var ret={x:0,y:0}; -var bs=dojo.html.boxSizing; -if(!_241){ -_241=bs.CONTENT_BOX; -} -var _244=2; -var _245; -switch(_241){ -case bs.MARGIN_BOX: -_245=3; -break; -case bs.BORDER_BOX: -_245=2; -break; -case bs.PADDING_BOX: -default: -_245=1; -break; -case bs.CONTENT_BOX: -_245=0; -break; -} -var h=dojo.render.html; -var db=document["body"]||document["documentElement"]; -if(h.ie){ -with(node.getBoundingClientRect()){ -ret.x=left-2; -ret.y=top-2; -} -}else{ -if(document.getBoxObjectFor){ -_244=1; -try{ -var bo=document.getBoxObjectFor(node); -ret.x=bo.x-dojo.html.sumAncestorProperties(node,"scrollLeft"); -ret.y=bo.y-dojo.html.sumAncestorProperties(node,"scrollTop"); -} -catch(e){ -} -}else{ -if(node["offsetParent"]){ -var _249; -if((h.safari)&&(node.style.getPropertyValue("position")=="absolute")&&(node.parentNode==db)){ -_249=db; -}else{ -_249=db.parentNode; -} -if(node.parentNode!=db){ -var nd=node; -if(dojo.render.html.opera){ -nd=db; -} -ret.x-=dojo.html.sumAncestorProperties(nd,"scrollLeft"); -ret.y-=dojo.html.sumAncestorProperties(nd,"scrollTop"); -} -var _24b=node; -do{ -var n=_24b["offsetLeft"]; -if(!h.opera||n>0){ -ret.x+=isNaN(n)?0:n; -} -var m=_24b["offsetTop"]; -ret.y+=isNaN(m)?0:m; -_24b=_24b.offsetParent; -}while((_24b!=_249)&&(_24b!=null)); -}else{ -if(node["x"]&&node["y"]){ -ret.x+=isNaN(node.x)?0:node.x; -ret.y+=isNaN(node.y)?0:node.y; -} -} -} -} -if(_240){ -var _24e=dojo.html.getScroll(); -ret.y+=_24e.top; -ret.x+=_24e.left; -} -var _24f=[dojo.html.getPaddingExtent,dojo.html.getBorderExtent,dojo.html.getMarginExtent]; -if(_244>_245){ -for(var i=_245;i<_244;++i){ -ret.y+=_24f[i](node,"top"); -ret.x+=_24f[i](node,"left"); -} -}else{ -if(_244<_245){ -for(var i=_245;i>_244;--i){ -ret.y-=_24f[i-1](node,"top"); -ret.x-=_24f[i-1](node,"left"); -} -} -} -ret.top=ret.y; -ret.left=ret.x; -return ret; -}; -dojo.html.isPositionAbsolute=function(node){ -return (dojo.html.getComputedStyle(node,"position")=="absolute"); -}; -dojo.html._sumPixelValues=function(node,_253,_254){ -var _255=0; -for(var x=0;x<_253.length;x++){ -_255+=dojo.html.getPixelValue(node,_253[x],_254); -} -return _255; -}; -dojo.html.getMargin=function(node){ -return {width:dojo.html._sumPixelValues(node,["margin-left","margin-right"],(dojo.html.getComputedStyle(node,"position")=="absolute")),height:dojo.html._sumPixelValues(node,["margin-top","margin-bottom"],(dojo.html.getComputedStyle(node,"position")=="absolute"))}; -}; -dojo.html.getBorder=function(node){ -return {width:dojo.html.getBorderExtent(node,"left")+dojo.html.getBorderExtent(node,"right"),height:dojo.html.getBorderExtent(node,"top")+dojo.html.getBorderExtent(node,"bottom")}; -}; -dojo.html.getBorderExtent=function(node,side){ -return (dojo.html.getStyle(node,"border-"+side+"-style")=="none"?0:dojo.html.getPixelValue(node,"border-"+side+"-width")); -}; -dojo.html.getMarginExtent=function(node,side){ -return dojo.html._sumPixelValues(node,["margin-"+side],dojo.html.isPositionAbsolute(node)); -}; -dojo.html.getPaddingExtent=function(node,side){ -return dojo.html._sumPixelValues(node,["padding-"+side],true); -}; -dojo.html.getPadding=function(node){ -return {width:dojo.html._sumPixelValues(node,["padding-left","padding-right"],true),height:dojo.html._sumPixelValues(node,["padding-top","padding-bottom"],true)}; -}; -dojo.html.getPadBorder=function(node){ -var pad=dojo.html.getPadding(node); -var _262=dojo.html.getBorder(node); -return {width:pad.width+_262.width,height:pad.height+_262.height}; -}; -dojo.html.getBoxSizing=function(node){ -var h=dojo.render.html; -var bs=dojo.html.boxSizing; -if((h.ie)||(h.opera)){ -var cm=document["compatMode"]; -if((cm=="BackCompat")||(cm=="QuirksMode")){ -return bs.BORDER_BOX; -}else{ -return bs.CONTENT_BOX; -} -}else{ -if(arguments.length==0){ -node=document.documentElement; -} -var _267=dojo.html.getStyle(node,"-moz-box-sizing"); -if(!_267){ -_267=dojo.html.getStyle(node,"box-sizing"); -} -return (_267?_267:bs.CONTENT_BOX); -} -}; -dojo.html.isBorderBox=function(node){ -return (dojo.html.getBoxSizing(node)==dojo.html.boxSizing.BORDER_BOX); -}; -dojo.html.getBorderBox=function(node){ -node=dojo.byId(node); -return {width:node.offsetWidth,height:node.offsetHeight}; -}; -dojo.html.getPaddingBox=function(node){ -var box=dojo.html.getBorderBox(node); -var _26c=dojo.html.getBorder(node); -return {width:box.width-_26c.width,height:box.height-_26c.height}; -}; -dojo.html.getContentBox=function(node){ -node=dojo.byId(node); -var _26e=dojo.html.getPadBorder(node); -return {width:node.offsetWidth-_26e.width,height:node.offsetHeight-_26e.height}; -}; -dojo.html.setContentBox=function(node,args){ -node=dojo.byId(node); -var _271=0; -var _272=0; -var isbb=dojo.html.isBorderBox(node); -var _274=(isbb?dojo.html.getPadBorder(node):{width:0,height:0}); -var ret={}; -if(typeof args.width!="undefined"){ -_271=args.width+_274.width; -ret.width=dojo.html.setPositivePixelValue(node,"width",_271); -} -if(typeof args.height!="undefined"){ -_272=args.height+_274.height; -ret.height=dojo.html.setPositivePixelValue(node,"height",_272); -} -return ret; -}; -dojo.html.getMarginBox=function(node){ -var _277=dojo.html.getBorderBox(node); -var _278=dojo.html.getMargin(node); -return {width:_277.width+_278.width,height:_277.height+_278.height}; -}; -dojo.html.setMarginBox=function(node,args){ -node=dojo.byId(node); -var _27b=0; -var _27c=0; -var isbb=dojo.html.isBorderBox(node); -var _27e=(!isbb?dojo.html.getPadBorder(node):{width:0,height:0}); -var _27f=dojo.html.getMargin(node); -var ret={}; -if(typeof args.width!="undefined"){ -_27b=args.width-_27e.width; -_27b-=_27f.width; -ret.width=dojo.html.setPositivePixelValue(node,"width",_27b); -} -if(typeof args.height!="undefined"){ -_27c=args.height-_27e.height; -_27c-=_27f.height; -ret.height=dojo.html.setPositivePixelValue(node,"height",_27c); -} -return ret; -}; -dojo.html.getElementBox=function(node,type){ -var bs=dojo.html.boxSizing; -switch(type){ -case bs.MARGIN_BOX: -return dojo.html.getMarginBox(node); -case bs.BORDER_BOX: -return dojo.html.getBorderBox(node); -case bs.PADDING_BOX: -return dojo.html.getPaddingBox(node); -case bs.CONTENT_BOX: -default: -return dojo.html.getContentBox(node); -} -}; -dojo.html.toCoordinateObject=dojo.html.toCoordinateArray=function(_284,_285,_286){ -if(_284 instanceof Array||typeof _284=="array"){ -dojo.deprecated("dojo.html.toCoordinateArray","use dojo.html.toCoordinateObject({left: , top: , width: , height: }) instead","0.5"); -while(_284.length<4){ -_284.push(0); -} -while(_284.length>4){ -_284.pop(); -} -var ret={left:_284[0],top:_284[1],width:_284[2],height:_284[3]}; -}else{ -if(!_284.nodeType&&!(_284 instanceof String||typeof _284=="string")&&("width" in _284||"height" in _284||"left" in _284||"x" in _284||"top" in _284||"y" in _284)){ -var ret={left:_284.left||_284.x||0,top:_284.top||_284.y||0,width:_284.width||0,height:_284.height||0}; -}else{ -var node=dojo.byId(_284); -var pos=dojo.html.abs(node,_285,_286); -var _28a=dojo.html.getMarginBox(node); -var ret={left:pos.left,top:pos.top,width:_28a.width,height:_28a.height}; -} -} -ret.x=ret.left; -ret.y=ret.top; -return ret; -}; -dojo.html.setMarginBoxWidth=dojo.html.setOuterWidth=function(node,_28c){ -return dojo.html._callDeprecated("setMarginBoxWidth","setMarginBox",arguments,"width"); -}; -dojo.html.setMarginBoxHeight=dojo.html.setOuterHeight=function(){ -return dojo.html._callDeprecated("setMarginBoxHeight","setMarginBox",arguments,"height"); -}; -dojo.html.getMarginBoxWidth=dojo.html.getOuterWidth=function(){ -return dojo.html._callDeprecated("getMarginBoxWidth","getMarginBox",arguments,null,"width"); -}; -dojo.html.getMarginBoxHeight=dojo.html.getOuterHeight=function(){ -return dojo.html._callDeprecated("getMarginBoxHeight","getMarginBox",arguments,null,"height"); -}; -dojo.html.getTotalOffset=function(node,type,_28f){ -return dojo.html._callDeprecated("getTotalOffset","getAbsolutePosition",arguments,null,type); -}; -dojo.html.getAbsoluteX=function(node,_291){ -return dojo.html._callDeprecated("getAbsoluteX","getAbsolutePosition",arguments,null,"x"); -}; -dojo.html.getAbsoluteY=function(node,_293){ -return dojo.html._callDeprecated("getAbsoluteY","getAbsolutePosition",arguments,null,"y"); -}; -dojo.html.totalOffsetLeft=function(node,_295){ -return dojo.html._callDeprecated("totalOffsetLeft","getAbsolutePosition",arguments,null,"left"); -}; -dojo.html.totalOffsetTop=function(node,_297){ -return dojo.html._callDeprecated("totalOffsetTop","getAbsolutePosition",arguments,null,"top"); -}; -dojo.html.getMarginWidth=function(node){ -return dojo.html._callDeprecated("getMarginWidth","getMargin",arguments,null,"width"); -}; -dojo.html.getMarginHeight=function(node){ -return dojo.html._callDeprecated("getMarginHeight","getMargin",arguments,null,"height"); -}; -dojo.html.getBorderWidth=function(node){ -return dojo.html._callDeprecated("getBorderWidth","getBorder",arguments,null,"width"); -}; -dojo.html.getBorderHeight=function(node){ -return dojo.html._callDeprecated("getBorderHeight","getBorder",arguments,null,"height"); -}; -dojo.html.getPaddingWidth=function(node){ -return dojo.html._callDeprecated("getPaddingWidth","getPadding",arguments,null,"width"); -}; -dojo.html.getPaddingHeight=function(node){ -return dojo.html._callDeprecated("getPaddingHeight","getPadding",arguments,null,"height"); -}; -dojo.html.getPadBorderWidth=function(node){ -return dojo.html._callDeprecated("getPadBorderWidth","getPadBorder",arguments,null,"width"); -}; -dojo.html.getPadBorderHeight=function(node){ -return dojo.html._callDeprecated("getPadBorderHeight","getPadBorder",arguments,null,"height"); -}; -dojo.html.getBorderBoxWidth=dojo.html.getInnerWidth=function(){ -return dojo.html._callDeprecated("getBorderBoxWidth","getBorderBox",arguments,null,"width"); -}; -dojo.html.getBorderBoxHeight=dojo.html.getInnerHeight=function(){ -return dojo.html._callDeprecated("getBorderBoxHeight","getBorderBox",arguments,null,"height"); -}; -dojo.html.getContentBoxWidth=dojo.html.getContentWidth=function(){ -return dojo.html._callDeprecated("getContentBoxWidth","getContentBox",arguments,null,"width"); -}; -dojo.html.getContentBoxHeight=dojo.html.getContentHeight=function(){ -return dojo.html._callDeprecated("getContentBoxHeight","getContentBox",arguments,null,"height"); -}; -dojo.html.setContentBoxWidth=dojo.html.setContentWidth=function(node,_2a1){ -return dojo.html._callDeprecated("setContentBoxWidth","setContentBox",arguments,"width"); -}; -dojo.html.setContentBoxHeight=dojo.html.setContentHeight=function(node,_2a3){ -return dojo.html._callDeprecated("setContentBoxHeight","setContentBox",arguments,"height"); -}; -dojo.provide("dojo.html.util"); -dojo.html.getElementWindow=function(_2a4){ -return dojo.html.getDocumentWindow(_2a4.ownerDocument); -}; -dojo.html.getDocumentWindow=function(doc){ -if(dojo.render.html.safari&&!doc._parentWindow){ -var fix=function(win){ -win.document._parentWindow=win; -for(var i=0;i=left&&_2b3.x<=_2b9&&_2b3.y>=top&&_2b3.y<=_2b7); -}; -dojo.html.renderedTextContent=function(node){ -node=dojo.byId(node); -var _2bb=""; -if(node==null){ -return _2bb; -} -for(var i=0;i]/i).test(txt.replace(/^\s+/))){ -txt="
"+txt+"
"; -_2c4="cell"; -}else{ -if((/^]/i).test(txt.replace(/^\s+/))){ -txt=""+txt+"
"; -_2c4="row"; -}else{ -if((/^<(thead|tbody|tfoot)[\s\r\n>]/i).test(txt.replace(/^\s+/))){ -txt=""+txt+"
"; -_2c4="section"; -} -} -} -tn.innerHTML=txt; -if(tn["normalize"]){ -tn.normalize(); -} -var _2c5=null; -switch(_2c4){ -case "cell": -_2c5=tn.getElementsByTagName("tr")[0]; -break; -case "row": -_2c5=tn.getElementsByTagName("tbody")[0]; -break; -case "section": -_2c5=tn.getElementsByTagName("table")[0]; -break; -default: -_2c5=tn; -break; -} -var _2c6=[]; -for(var x=0;x<_2c5.childNodes.length;x++){ -_2c6.push(_2c5.childNodes[x].cloneNode(true)); -} -tn.style.display="none"; -dojo.body().removeChild(tn); -return _2c6; -}; -dojo.html.placeOnScreen=function(node,_2c9,_2ca,_2cb,_2cc,_2cd,_2ce){ -if(_2c9 instanceof Array||typeof _2c9=="array"){ -_2ce=_2cd; -_2cd=_2cc; -_2cc=_2cb; -_2cb=_2ca; -_2ca=_2c9[1]; -_2c9=_2c9[0]; -} -if(_2cd instanceof String||typeof _2cd=="string"){ -_2cd=_2cd.split(","); -} -if(!isNaN(_2cb)){ -_2cb=[Number(_2cb),Number(_2cb)]; -}else{ -if(!(_2cb instanceof Array||typeof _2cb=="array")){ -_2cb=[0,0]; -} -} -var _2cf=dojo.html.getScroll().offset; -var view=dojo.html.getViewport(); -node=dojo.byId(node); -var _2d1=node.style.display; -node.style.display=""; -var bb=dojo.html.getBorderBox(node); -var w=bb.width; -var h=bb.height; -node.style.display=_2d1; -if(!(_2cd instanceof Array||typeof _2cd=="array")){ -_2cd=["TL"]; -} -var _2d5,_2d6,_2d7=Infinity,_2d8; -for(var _2d9=0;_2d9<_2cd.length;++_2d9){ -var _2da=_2cd[_2d9]; -var _2db=true; -var tryX=_2c9-(_2da.charAt(1)=="L"?0:w)+_2cb[0]*(_2da.charAt(1)=="L"?1:-1); -var tryY=_2ca-(_2da.charAt(0)=="T"?0:h)+_2cb[1]*(_2da.charAt(0)=="T"?1:-1); -if(_2cc){ -tryX-=_2cf.x; -tryY-=_2cf.y; -} -if(tryX<0){ -tryX=0; -_2db=false; -} -if(tryY<0){ -tryY=0; -_2db=false; -} -var x=tryX+w; -if(x>view.width){ -x=view.width-w; -_2db=false; -}else{ -x=tryX; -} -x=Math.max(_2cb[0],x)+_2cf.x; -var y=tryY+h; -if(y>view.height){ -y=view.height-h; -_2db=false; -}else{ -y=tryY; -} -y=Math.max(_2cb[1],y)+_2cf.y; -if(_2db){ -_2d5=x; -_2d6=y; -_2d7=0; -_2d8=_2da; -break; -}else{ -var dist=Math.pow(x-tryX-_2cf.x,2)+Math.pow(y-tryY-_2cf.y,2); -if(_2d7>dist){ -_2d7=dist; -_2d5=x; -_2d6=y; -_2d8=_2da; -} -} -} -if(!_2ce){ -node.style.left=_2d5+"px"; -node.style.top=_2d6+"px"; -} -return {left:_2d5,top:_2d6,x:_2d5,y:_2d6,dist:_2d7,corner:_2d8}; -}; -dojo.html.placeOnScreenPoint=function(node,_2e2,_2e3,_2e4,_2e5){ -dojo.deprecated("dojo.html.placeOnScreenPoint","use dojo.html.placeOnScreen() instead","0.5"); -return dojo.html.placeOnScreen(node,_2e2,_2e3,_2e4,_2e5,["TL","TR","BL","BR"]); -}; -dojo.html.placeOnScreenAroundElement=function(node,_2e7,_2e8,_2e9,_2ea,_2eb){ -var best,_2ed=Infinity; -_2e7=dojo.byId(_2e7); -var _2ee=_2e7.style.display; -_2e7.style.display=""; -var mb=dojo.html.getElementBox(_2e7,_2e9); -var _2f0=mb.width; -var _2f1=mb.height; -var _2f2=dojo.html.getAbsolutePosition(_2e7,true,_2e9); -_2e7.style.display=_2ee; -for(var _2f3 in _2ea){ -var pos,_2f5,_2f6; -var _2f7=_2ea[_2f3]; -_2f5=_2f2.x+(_2f3.charAt(1)=="L"?0:_2f0); -_2f6=_2f2.y+(_2f3.charAt(0)=="T"?0:_2f1); -pos=dojo.html.placeOnScreen(node,_2f5,_2f6,_2e8,true,_2f7,true); -if(pos.dist==0){ -best=pos; -break; -}else{ -if(_2ed>pos.dist){ -_2ed=pos.dist; -best=pos; -} -} -} -if(!_2eb){ -node.style.left=best.left+"px"; -node.style.top=best.top+"px"; -} -return best; -}; -dojo.html.scrollIntoView=function(node){ -if(!node){ -return; -} -if(dojo.render.html.ie){ -if(dojo.html.getBorderBox(node.parentNode).heightnode.offsetTop){ -_2f9.scrollTop-=(_2f9.scrollTop-node.offsetTop); -} -} -} -} -}; dojo.provide("dojo.lang.array"); -dojo.lang.has=function(obj,name){ +dojo.lang.mixin(dojo.lang,{has:function(obj,name){ try{ return typeof obj[name]!="undefined"; } catch(e){ return false; } -}; -dojo.lang.isEmpty=function(obj){ +},isEmpty:function(obj){ if(dojo.lang.isObject(obj)){ var tmp={}; -var _300=0; +var _118=0; for(var x in obj){ if(obj[x]&&(!tmp[x])){ -_300++; +_118++; break; } } -return _300==0; +return _118==0; }else{ if(dojo.lang.isArrayLike(obj)||dojo.lang.isString(obj)){ return obj.length==0; } } -}; -dojo.lang.map=function(arr,obj,_304){ -var _305=dojo.lang.isString(arr); -if(_305){ +},map:function(arr,obj,_11c){ +var _11d=dojo.lang.isString(arr); +if(_11d){ arr=arr.split(""); } -if(dojo.lang.isFunction(obj)&&(!_304)){ -_304=obj; +if(dojo.lang.isFunction(obj)&&(!_11c)){ +_11c=obj; obj=dj_global; }else{ -if(dojo.lang.isFunction(obj)&&_304){ -var _306=obj; -obj=_304; -_304=_306; +if(dojo.lang.isFunction(obj)&&_11c){ +var _11e=obj; +obj=_11c; +_11c=_11e; } } if(Array.map){ -var _307=Array.map(arr,_304,obj); +var _11f=Array.map(arr,_11c,obj); }else{ -var _307=[]; +var _11f=[]; for(var i=0;i=3){ dojo.raise("thisObject doesn't exist!"); } -_324=dj_global; +_13d=dj_global; } -_326=[]; +_13f=[]; for(var i=0;i0){ -this.duration=_389; -} -if(_38c){ -this.repeatCount=_38c; -} -if(rate){ -this.rate=rate; -} -if(_388){ -dojo.lang.forEach(["handler","beforeBegin","onBegin","onEnd","onPlay","onStop","onAnimate"],function(item){ -if(_388[item]){ -this.connect(item,_388[item]); -} -},this); -} -if(_38b&&dojo.lang.isFunction(_38b)){ -this.easing=_38b; -} -}; -dojo.inherits(dojo.lfx.Animation,dojo.lfx.IAnimation); -dojo.lang.extend(dojo.lfx.Animation,{_startTime:null,_endTime:null,_timer:null,_percent:0,_startRepeatCount:0,play:function(_38f,_390){ -if(_390){ -clearTimeout(this._timer); -this._active=false; -this._paused=false; -this._percent=0; -}else{ -if(this._active&&!this._paused){ -return this; -} -} -this.fire("handler",["beforeBegin"]); -this.fire("beforeBegin"); -if(_38f>0){ -setTimeout(dojo.lang.hitch(this,function(){ -this.play(null,_390); -}),_38f); -return this; -} -this._startTime=new Date().valueOf(); -if(this._paused){ -this._startTime-=(this.duration*this._percent/100); -} -this._endTime=this._startTime+this.duration; -this._active=true; -this._paused=false; -var step=this._percent/100; -var _392=this.curve.getValue(step); -if(this._percent==0){ -if(!this._startRepeatCount){ -this._startRepeatCount=this.repeatCount; -} -this.fire("handler",["begin",_392]); -this.fire("onBegin",[_392]); -} -this.fire("handler",["play",_392]); -this.fire("onPlay",[_392]); -this._cycle(); -return this; -},pause:function(){ -clearTimeout(this._timer); -if(!this._active){ -return this; -} -this._paused=true; -var _393=this.curve.getValue(this._percent/100); -this.fire("handler",["pause",_393]); -this.fire("onPause",[_393]); -return this; -},gotoPercent:function(pct,_395){ -clearTimeout(this._timer); -this._active=true; -this._paused=true; -this._percent=pct; -if(_395){ -this.play(); -} -return this; -},stop:function(_396){ -clearTimeout(this._timer); -var step=this._percent/100; -if(_396){ -step=1; -} -var _398=this.curve.getValue(step); -this.fire("handler",["stop",_398]); -this.fire("onStop",[_398]); -this._active=false; -this._paused=false; -return this; -},status:function(){ -if(this._active){ -return this._paused?"paused":"playing"; -}else{ -return "stopped"; -} -return this; -},_cycle:function(){ -clearTimeout(this._timer); -if(this._active){ -var curr=new Date().valueOf(); -var step=(curr-this._startTime)/(this._endTime-this._startTime); -if(step>=1){ -step=1; -this._percent=100; -}else{ -this._percent=step*100; -} -if((this.easing)&&(dojo.lang.isFunction(this.easing))){ -step=this.easing(step); -} -var _39b=this.curve.getValue(step); -this.fire("handler",["animate",_39b]); -this.fire("onAnimate",[_39b]); -if(step<1){ -this._timer=setTimeout(dojo.lang.hitch(this,"_cycle"),this.rate); -}else{ -this._active=false; -this.fire("handler",["end"]); -this.fire("onEnd"); -if(this.repeatCount>0){ -this.repeatCount--; -this.play(null,true); -}else{ -if(this.repeatCount==-1){ -this.play(null,true); -}else{ -if(this._startRepeatCount){ -this.repeatCount=this._startRepeatCount; -this._startRepeatCount=0; -} -} -} -} -} -return this; -}}); -dojo.lfx.Combine=function(_39c){ -dojo.lfx.IAnimation.call(this); -this._anims=[]; -this._animsEnded=0; -var _39d=arguments; -if(_39d.length==1&&(dojo.lang.isArray(_39d[0])||dojo.lang.isArrayLike(_39d[0]))){ -_39d=_39d[0]; -} -dojo.lang.forEach(_39d,function(anim){ -this._anims.push(anim); -anim.connect("onEnd",dojo.lang.hitch(this,"_onAnimsEnded")); -},this); -}; -dojo.inherits(dojo.lfx.Combine,dojo.lfx.IAnimation); -dojo.lang.extend(dojo.lfx.Combine,{_animsEnded:0,play:function(_39f,_3a0){ -if(!this._anims.length){ -return this; -} -this.fire("beforeBegin"); -if(_39f>0){ -setTimeout(dojo.lang.hitch(this,function(){ -this.play(null,_3a0); -}),_39f); -return this; -} -if(_3a0||this._anims[0].percent==0){ -this.fire("onBegin"); -} -this.fire("onPlay"); -this._animsCall("play",null,_3a0); -return this; -},pause:function(){ -this.fire("onPause"); -this._animsCall("pause"); -return this; -},stop:function(_3a1){ -this.fire("onStop"); -this._animsCall("stop",_3a1); -return this; -},_onAnimsEnded:function(){ -this._animsEnded++; -if(this._animsEnded>=this._anims.length){ -this.fire("onEnd"); -} -return this; -},_animsCall:function(_3a2){ -var args=[]; -if(arguments.length>1){ -for(var i=1;i0){ -setTimeout(dojo.lang.hitch(this,function(){ -this.play(null,_3ae); -}),_3ad); -return this; -} -if(_3af){ -if(this._currAnim==0){ -this.fire("handler",["begin",this._currAnim]); -this.fire("onBegin",[this._currAnim]); -} -this.fire("onPlay",[this._currAnim]); -_3af.play(null,_3ae); -} -return this; -},pause:function(){ -if(this._anims[this._currAnim]){ -this._anims[this._currAnim].pause(); -this.fire("onPause",[this._currAnim]); -} -return this; -},playPause:function(){ -if(this._anims.length==0){ -return this; -} -if(this._currAnim==-1){ -this._currAnim=0; -} -var _3b0=this._anims[this._currAnim]; -if(_3b0){ -if(!_3b0._active||_3b0._paused){ -this.play(); -}else{ -this.pause(); -} -} -return this; -},stop:function(){ -var _3b1=this._anims[this._currAnim]; -if(_3b1){ -_3b1.stop(); -this.fire("onStop",[this._currAnim]); -} -return _3b1; -},_playNext:function(){ -if(this._currAnim==-1||this._anims.length==0){ -return this; -} -this._currAnim++; -if(this._anims[this._currAnim]){ -this._anims[this._currAnim].play(null,true); -} -return this; -}}); -dojo.lfx.combine=function(_3b2){ -var _3b3=arguments; -if(dojo.lang.isArray(arguments[0])){ -_3b3=arguments[0]; -} -if(_3b3.length==1){ -return _3b3[0]; -} -return new dojo.lfx.Combine(_3b3); -}; -dojo.lfx.chain=function(_3b4){ -var _3b5=arguments; -if(dojo.lang.isArray(arguments[0])){ -_3b5=arguments[0]; -} -if(_3b5.length==1){ -return _3b5[0]; -} -return new dojo.lfx.Chain(_3b5); -}; -dojo.provide("dojo.html.color"); -dojo.html.getBackgroundColor=function(node){ -node=dojo.byId(node); -var _3b7; -do{ -_3b7=dojo.html.getStyle(node,"background-color"); -if(_3b7.toLowerCase()=="rgba(0, 0, 0, 0)"){ -_3b7="transparent"; -} -if(node==document.getElementsByTagName("body")[0]){ -node=null; -break; -} -node=node.parentNode; -}while(node&&dojo.lang.inArray(["transparent",""],_3b7)); -if(_3b7=="transparent"){ -_3b7=[255,255,255,0]; -}else{ -_3b7=dojo.gfx.color.extractRGB(_3b7); -} -return _3b7; -}; -dojo.provide("dojo.lfx.html"); -dojo.lfx.html._byId=function(_3b8){ -if(!_3b8){ -return []; -} -if(dojo.lang.isArrayLike(_3b8)){ -if(!_3b8.alreadyChecked){ -var n=[]; -dojo.lang.forEach(_3b8,function(node){ -n.push(dojo.byId(node)); -}); -n.alreadyChecked=true; -return n; -}else{ -return _3b8; -} -}else{ -var n=[]; -n.push(dojo.byId(_3b8)); -n.alreadyChecked=true; -return n; -} -}; -dojo.lfx.html.propertyAnimation=function(_3bb,_3bc,_3bd,_3be,_3bf){ -_3bb=dojo.lfx.html._byId(_3bb); -var _3c0={"propertyMap":_3bc,"nodes":_3bb,"duration":_3bd,"easing":_3be||dojo.lfx.easeDefault}; -var _3c1=function(args){ -if(args.nodes.length==1){ -var pm=args.propertyMap; -if(!dojo.lang.isArray(args.propertyMap)){ -var parr=[]; -for(var _3c5 in pm){ -pm[_3c5].property=_3c5; -parr.push(pm[_3c5]); -} -pm=args.propertyMap=parr; -} -dojo.lang.forEach(pm,function(prop){ -if(dj_undef("start",prop)){ -if(prop.property!="opacity"){ -prop.start=parseInt(dojo.html.getComputedStyle(args.nodes[0],prop.property)); -}else{ -prop.start=dojo.html.getOpacity(args.nodes[0]); -} -} -}); -} -}; -var _3c7=function(_3c8){ -var _3c9=[]; -dojo.lang.forEach(_3c8,function(c){ -_3c9.push(Math.round(c)); -}); -return _3c9; -}; -var _3cb=function(n,_3cd){ -n=dojo.byId(n); -if(!n||!n.style){ -return; -} -for(var s in _3cd){ -if(s=="opacity"){ -dojo.html.setOpacity(n,_3cd[s]); -}else{ -n.style[s]=_3cd[s]; -} -} -}; -var _3cf=function(_3d0){ -this._properties=_3d0; -this.diffs=new Array(_3d0.length); -dojo.lang.forEach(_3d0,function(prop,i){ -if(dojo.lang.isFunction(prop.start)){ -prop.start=prop.start(prop,i); -} -if(dojo.lang.isFunction(prop.end)){ -prop.end=prop.end(prop,i); -} -if(dojo.lang.isArray(prop.start)){ -this.diffs[i]=null; -}else{ -if(prop.start instanceof dojo.gfx.color.Color){ -prop.startRgb=prop.start.toRgb(); -prop.endRgb=prop.end.toRgb(); -}else{ -this.diffs[i]=prop.end-prop.start; -} -} -},this); -this.getValue=function(n){ -var ret={}; -dojo.lang.forEach(this._properties,function(prop,i){ -var _3d7=null; -if(dojo.lang.isArray(prop.start)){ -}else{ -if(prop.start instanceof dojo.gfx.color.Color){ -_3d7=(prop.units||"rgb")+"("; -for(var j=0;j3){ -_448.pop(); -} -var rgb=new dojo.gfx.color.Color(_442); -var _44d=new dojo.gfx.color.Color(_448); -var anim=dojo.lfx.propertyAnimation(node,{"background-color":{start:rgb,end:_44d}},_443,_444,{"beforeBegin":function(){ -if(_44a){ -node.style.backgroundImage="none"; -} -node.style.backgroundColor="rgb("+rgb.toRgb().join(",")+")"; -},"onEnd":function(){ -if(_44a){ -node.style.backgroundImage=_44a; -} -if(_44b){ -node.style.backgroundColor="transparent"; -} -if(_445){ -_445(node,anim); -} -}}); -_446.push(anim); -}); -return dojo.lfx.combine(_446); -}; -dojo.lfx.html.unhighlight=function(_44f,_450,_451,_452,_453){ -_44f=dojo.lfx.html._byId(_44f); -var _454=[]; -dojo.lang.forEach(_44f,function(node){ -var _456=new dojo.gfx.color.Color(dojo.html.getBackgroundColor(node)); -var rgb=new dojo.gfx.color.Color(_450); -var _458=dojo.html.getStyle(node,"background-image"); -var anim=dojo.lfx.propertyAnimation(node,{"background-color":{start:_456,end:rgb}},_451,_452,{"beforeBegin":function(){ -if(_458){ -node.style.backgroundImage="none"; -} -node.style.backgroundColor="rgb("+_456.toRgb().join(",")+")"; -},"onEnd":function(){ -if(_453){ -_453(node,anim); -} -}}); -_454.push(anim); -}); -return dojo.lfx.combine(_454); -}; -dojo.lang.mixin(dojo.lfx,dojo.lfx.html); -dojo.provide("dojo.lfx.*"); dojo.provide("dojo.lang.extras"); -dojo.lang.setTimeout=function(func,_45b){ -var _45c=window,_45d=2; +dojo.lang.setTimeout=function(func,_149){ +var _14a=window,_14b=2; if(!dojo.lang.isFunction(func)){ -_45c=func; -func=_45b; -_45b=arguments[2]; -_45d++; +_14a=func; +func=_149; +_149=arguments[2]; +_14b++; } if(dojo.lang.isString(func)){ -func=_45c[func]; +func=_14a[func]; } var args=[]; -for(var i=_45d;i2)?args[0]:"after",precedence:"last",once:false,delay:null,rate:0,adviceMsg:false}; +var ao={srcObj:dj_global,srcFunc:null,adviceObj:dj_global,adviceFunc:null,aroundObj:null,aroundFunc:null,adviceType:(args.length>2)?args[0]:"after",precedence:"last",once:false,delay:null,rate:0,adviceMsg:false,maxCalls:-1}; switch(args.length){ case 0: return; @@ -4448,14 +1627,14 @@ if((dl.isObject(args[0]))&&(dl.isString(args[1]))&&(dl.isFunction(args[2]))){ ao.adviceType="after"; ao.srcObj=args[0]; ao.srcFunc=args[1]; -var _474=dl.nameAnonFunc(args[2],ao.adviceObj,_471); -ao.adviceFunc=_474; +var _19e=dl.nameAnonFunc(args[2],ao.adviceObj,_19b); +ao.adviceFunc=_19e; }else{ if((dl.isFunction(args[0]))&&(dl.isObject(args[1]))&&(dl.isString(args[2]))){ ao.adviceType="after"; ao.srcObj=dj_global; -var _474=dl.nameAnonFunc(args[0],ao.srcObj,_471); -ao.srcFunc=_474; +var _19e=dl.nameAnonFunc(args[0],ao.srcObj,_19b); +ao.srcFunc=_19e; ao.adviceObj=args[1]; ao.adviceFunc=args[2]; } @@ -4481,17 +1660,17 @@ ao.adviceFunc=args[3]; if((dl.isString(args[0]))&&(dl.isFunction(args[1]))&&(dl.isObject(args[2]))){ ao.adviceType=args[0]; ao.srcObj=dj_global; -var _474=dl.nameAnonFunc(args[1],dj_global,_471); -ao.srcFunc=_474; +var _19e=dl.nameAnonFunc(args[1],dj_global,_19b); +ao.srcFunc=_19e; ao.adviceObj=args[2]; ao.adviceFunc=args[3]; }else{ if((dl.isString(args[0]))&&(dl.isObject(args[1]))&&(dl.isString(args[2]))&&(dl.isFunction(args[3]))){ ao.srcObj=args[1]; ao.srcFunc=args[2]; -var _474=dl.nameAnonFunc(args[3],dj_global,_471); +var _19e=dl.nameAnonFunc(args[3],dj_global,_19b); ao.adviceObj=dj_global; -ao.adviceFunc=_474; +ao.adviceFunc=_19e; }else{ if(dl.isObject(args[1])){ ao.srcObj=args[1]; @@ -4535,11 +1714,12 @@ ao.once=args[7]; ao.delay=args[8]; ao.rate=args[9]; ao.adviceMsg=args[10]; +ao.maxCalls=(!isNaN(parseInt(args[11])))?args[11]:-1; break; } if(dl.isFunction(ao.aroundFunc)){ -var _474=dl.nameAnonFunc(ao.aroundFunc,ao.aroundObj,_471); -ao.aroundFunc=_474; +var _19e=dl.nameAnonFunc(ao.aroundFunc,ao.aroundObj,_19b); +ao.aroundFunc=_19e; } if(dl.isFunction(ao.srcFunc)){ ao.srcFunc=dl.getNameInObj(ao.srcObj,ao.srcFunc); @@ -4568,25 +1748,18 @@ var ao=arguments[0]; }else{ var ao=interpolateArgs(arguments,true); } -if(dojo.lang.isString(ao.srcFunc)&&(ao.srcFunc.toLowerCase()=="onkey")){ -if(dojo.render.html.ie){ -ao.srcFunc="onkeydown"; -this.connect(ao); -} -ao.srcFunc="onkeypress"; -} if(dojo.lang.isArray(ao.srcObj)&&ao.srcObj!=""){ -var _476={}; +var _1a0={}; for(var x in ao){ -_476[x]=ao[x]; +_1a0[x]=ao[x]; } var mjps=[]; dojo.lang.forEach(ao.srcObj,function(src){ if((dojo.render.html.capable)&&(dojo.lang.isString(src))){ src=dojo.byId(src); } -_476.srcObj=src; -mjps.push(dojo.event.connect.call(dojo.event,_476)); +_1a0.srcObj=src; +mjps.push(dojo.event.connect.call(dojo.event,_1a0)); }); return mjps; } @@ -4598,20 +1771,20 @@ mjp.kwAddAdvice(ao); return mjp; }; this.log=function(a1,a2){ -var _47e; +var _1a8; if((arguments.length==1)&&(typeof a1=="object")){ -_47e=a1; +_1a8=a1; }else{ -_47e={srcObj:a1,srcFunc:a2}; +_1a8={srcObj:a1,srcFunc:a2}; } -_47e.adviceFunc=function(){ -var _47f=[]; +_1a8.adviceFunc=function(){ +var _1a9=[]; for(var x=0;x-1){ +if(_1d8==0){ +return; +} +marr[7]--; +} +var _1d9; var to={args:[],jp_:this,object:obj,proceed:function(){ -return _4a7[_4a8].apply(_4a7,to.args); +return _1d3[_1d4].apply(_1d3,to.args); }}; -to.args=_4a3; -var _4ae=parseInt(marr[4]); -var _4af=((!isNaN(_4ae))&&(marr[4]!==null)&&(typeof marr[4]!="undefined")); +to.args=_1cf; +var _1db=parseInt(marr[4]); +var _1dc=((!isNaN(_1db))&&(marr[4]!==null)&&(typeof marr[4]!="undefined")); if(marr[5]){ var rate=parseInt(marr[5]); var cur=new Date(); -var _4b2=false; +var _1df=false; if((marr["last"])&&((cur-marr.last)<=rate)){ if(dojo.event._canTimeout){ if(marr["delayTimer"]){ @@ -4815,7 +2011,7 @@ var tod=parseInt(rate*2); var mcpy=dojo.lang.shallowCopy(marr); marr.delayTimer=setTimeout(function(){ mcpy[5]=0; -_4a5(mcpy); +_1d1(mcpy); },tod); } return; @@ -4823,61 +2019,62 @@ return; marr.last=cur; } } -if(_4aa){ -_4a9[_4aa].call(_4a9,to); +if(_1d6){ +_1d5[_1d6].call(_1d5,to); }else{ -if((_4af)&&((dojo.render.html)||(dojo.render.svg))){ +if((_1dc)&&((dojo.render.html)||(dojo.render.svg))){ dj_global["setTimeout"](function(){ if(msg){ -_4a7[_4a8].call(_4a7,to); +_1d3[_1d4].call(_1d3,to); }else{ -_4a7[_4a8].apply(_4a7,args); +_1d3[_1d4].apply(_1d3,args); } -},_4ae); +},_1db); }else{ if(msg){ -_4a7[_4a8].call(_4a7,to); +_1d3[_1d4].call(_1d3,to); }else{ -_4a7[_4a8].apply(_4a7,args); +_1d3[_1d4].apply(_1d3,args); } } } }; -var _4b5=function(){ +var _1e2=function(){ if(this.squelch){ try{ -return _4a5.apply(this,arguments); +return _1d1.apply(this,arguments); } catch(e){ dojo.debug(e); } }else{ -return _4a5.apply(this,arguments); +return _1d1.apply(this,arguments); } }; if((this["before"])&&(this.before.length>0)){ -dojo.lang.forEach(this.before.concat(new Array()),_4b5); +dojo.lang.forEach(this.before.concat(new Array()),_1e2); } -var _4b6; +var _1e3; try{ if((this["around"])&&(this.around.length>0)){ var mi=new dojo.event.MethodInvocation(this,obj,args); -_4b6=mi.proceed(); +_1e3=mi.proceed(); }else{ if(this.methodfunc){ -_4b6=this.object[this.methodname].apply(this.object,args); +_1e3=this.object[this.methodname].apply(this.object,args); } } } catch(e){ if(!this.squelch){ +dojo.debug(e,"when calling",this.methodname,"on",this.object,"with arguments",args); dojo.raise(e); } } if((this["after"])&&(this.after.length>0)){ -dojo.lang.forEach(this.after.concat(new Array()),_4b5); +dojo.lang.forEach(this.after.concat(new Array()),_1e2); } -return (this.methodfunc)?_4b6:null; +return (this.methodfunc)?_1e3:null; },getArr:function(kind){ var type="after"; if((typeof kind=="string")&&(kind.indexOf("before")!=-1)){ @@ -4892,39 +2089,39 @@ this[type]=[]; } return this[type]; },kwAddAdvice:function(args){ -this.addAdvice(args["adviceObj"],args["adviceFunc"],args["aroundObj"],args["aroundFunc"],args["adviceType"],args["precedence"],args["once"],args["delay"],args["rate"],args["adviceMsg"]); -},addAdvice:function(_4bb,_4bc,_4bd,_4be,_4bf,_4c0,once,_4c2,rate,_4c4){ -var arr=this.getArr(_4bf); +this.addAdvice(args["adviceObj"],args["adviceFunc"],args["aroundObj"],args["aroundFunc"],args["adviceType"],args["precedence"],args["once"],args["delay"],args["rate"],args["adviceMsg"],args["maxCalls"]); +},addAdvice:function(_1e8,_1e9,_1ea,_1eb,_1ec,_1ed,once,_1ef,rate,_1f1,_1f2){ +var arr=this.getArr(_1ec); if(!arr){ dojo.raise("bad this: "+this); } -var ao=[_4bb,_4bc,_4bd,_4be,_4c2,rate,_4c4]; +var ao=[_1e8,_1e9,_1ea,_1eb,_1ef,rate,_1f1,_1f2]; if(once){ -if(this.hasAdvice(_4bb,_4bc,_4bf,arr)>=0){ +if(this.hasAdvice(_1e8,_1e9,_1ec,arr)>=0){ return; } } -if(_4c0=="first"){ +if(_1ed=="first"){ arr.unshift(ao); }else{ arr.push(ao); } -},hasAdvice:function(_4c7,_4c8,_4c9,arr){ +},hasAdvice:function(_1f5,_1f6,_1f7,arr){ if(!arr){ -arr=this.getArr(_4c9); +arr=this.getArr(_1f7); } var ind=-1; for(var x=0;x=0;i=i-1){ var el=na[i]; try{ @@ -5070,6 +2267,15 @@ dojo.widget.manager.destroyAll(); } catch(e){ } +if(dojo.widget){ +for(var name in dojo.widget._templateCache){ +if(dojo.widget._templateCache[name].node){ +dojo.dom.destroyNode(dojo.widget._templateCache[name].node); +dojo.widget._templateCache[name].node=null; +delete dojo.widget._templateCache[name].node; +} +} +} try{ window.onload=null; } @@ -5084,9 +2290,9 @@ dojo._ie_clobber.clobberNodes=[]; }); } dojo.event.browser=new function(){ -var _4fd=0; -this.normalizedEventName=function(_4fe){ -switch(_4fe){ +var _22c=0; +this.normalizedEventName=function(_22d){ +switch(_22d){ case "CheckboxStateChange": case "DOMAttrModified": case "DOMMenuItemActive": @@ -5095,10 +2301,11 @@ case "DOMMouseScroll": case "DOMNodeInserted": case "DOMNodeRemoved": case "RadioStateChange": -return _4fe; +return _22d; break; default: -return _4fe.toLowerCase(); +var lcn=_22d.toLowerCase(); +return (lcn.indexOf("on")==0)?lcn.substr(2):lcn; break; } }; @@ -5117,93 +2324,88 @@ dojo._ie_clobber.clobberNodes.push(node); node.__clobberAttrs__=[]; } }; -this.addClobberNodeAttrs=function(node,_502){ +this.addClobberNodeAttrs=function(node,_232){ if(!dojo.render.html.ie){ return; } this.addClobberNode(node); -for(var x=0;x<_502.length;x++){ -node.__clobberAttrs__.push(_502[x]); +for(var x=0;x<_232.length;x++){ +node.__clobberAttrs__.push(_232[x]); } }; -this.removeListener=function(node,_505,fp,_507){ -if(!_507){ -var _507=false; +this.removeListener=function(node,_235,fp,_237){ +if(!_237){ +var _237=false; } -_505=dojo.event.browser.normalizedEventName(_505); -if((_505=="onkey")||(_505=="key")){ +_235=dojo.event.browser.normalizedEventName(_235); +if(_235=="key"){ if(dojo.render.html.ie){ -this.removeListener(node,"onkeydown",fp,_507); +this.removeListener(node,"onkeydown",fp,_237); } -_505="onkeypress"; -} -if(_505.substr(0,2)=="on"){ -_505=_505.substr(2); +_235="keypress"; } if(node.removeEventListener){ -node.removeEventListener(_505,fp,_507); +node.removeEventListener(_235,fp,_237); } }; -this.addListener=function(node,_509,fp,_50b,_50c){ +this.addListener=function(node,_239,fp,_23b,_23c){ if(!node){ return; } -if(!_50b){ -var _50b=false; +if(!_23b){ +var _23b=false; } -_509=dojo.event.browser.normalizedEventName(_509); -if((_509=="onkey")||(_509=="key")){ +_239=dojo.event.browser.normalizedEventName(_239); +if(_239=="key"){ if(dojo.render.html.ie){ -this.addListener(node,"onkeydown",fp,_50b,_50c); +this.addListener(node,"onkeydown",fp,_23b,_23c); } -_509="onkeypress"; +_239="keypress"; } -if(_509.substr(0,2)!="on"){ -_509="on"+_509; -} -if(!_50c){ -var _50d=function(evt){ +if(!_23c){ +var _23d=function(evt){ if(!evt){ evt=window.event; } var ret=fp(dojo.event.browser.fixEvent(evt,this)); -if(_50b){ +if(_23b){ dojo.event.browser.stopEvent(evt); } return ret; }; }else{ -_50d=fp; +_23d=fp; } if(node.addEventListener){ -node.addEventListener(_509.substr(2),_50d,_50b); -return _50d; +node.addEventListener(_239,_23d,_23b); +return _23d; }else{ -if(typeof node[_509]=="function"){ -var _510=node[_509]; -node[_509]=function(e){ -_510(e); -return _50d(e); +_239="on"+_239; +if(typeof node[_239]=="function"){ +var _240=node[_239]; +node[_239]=function(e){ +_240(e); +return _23d(e); }; }else{ -node[_509]=_50d; +node[_239]=_23d; } if(dojo.render.html.ie){ -this.addClobberNodeAttrs(node,[_509]); +this.addClobberNodeAttrs(node,[_239]); } -return _50d; +return _23d; } }; this.isEvent=function(obj){ -return (typeof obj!="undefined")&&(typeof Event!="undefined")&&(obj.eventPhase); +return (typeof obj!="undefined")&&(obj)&&(typeof Event!="undefined")&&(obj.eventPhase); }; this.currentEvent=null; -this.callListener=function(_513,_514){ -if(typeof _513!="function"){ -dojo.raise("listener not a function: "+_513); +this.callListener=function(_243,_244){ +if(typeof _243!="function"){ +dojo.raise("listener not a function: "+_243); } -dojo.event.browser.currentEvent.currentTarget=_514; -return _513.call(_514,dojo.event.browser.currentEvent); +dojo.event.browser.currentEvent.currentTarget=_244; +return _243.call(_244,dojo.event.browser.currentEvent); }; this._stopPropagation=function(){ dojo.event.browser.currentEvent.cancelBubble=true; @@ -5216,7 +2418,7 @@ this.revKeys=[]; for(var key in this.keys){ this.revKeys[this.keys[key]]=key; } -this.fixEvent=function(evt,_517){ +this.fixEvent=function(evt,_247){ if(!evt){ if(window["event"]){ evt=window.event; @@ -5293,14 +2495,14 @@ evt.key=evt.keyCode; break; default: if(evt.ctrlKey||evt.altKey){ -var _519=evt.keyCode; -if(_519>=65&&_519<=90&&evt.shiftKey==false){ -_519+=32; +var _249=evt.keyCode; +if(_249>=65&&_249<=90&&evt.shiftKey==false){ +_249+=32; } -if(_519>=1&&_519<=26&&evt.ctrlKey){ -_519+=96; +if(_249>=1&&_249<=26&&evt.ctrlKey){ +_249+=96; } -evt.key=String.fromCharCode(_519); +evt.key=String.fromCharCode(_249); } } }else{ @@ -5326,11 +2528,11 @@ case evt.KEY_ESCAPE: evt.key=evt.which; break; default: -var _519=evt.which; +var _249=evt.which; if((evt.ctrlKey||evt.altKey||evt.metaKey)&&(evt.which>=65&&evt.which<=90&&evt.shiftKey==false)){ -_519+=32; +_249+=32; } -evt.key=String.fromCharCode(_519); +evt.key=String.fromCharCode(_249); } } } @@ -5342,6 +2544,10 @@ evt.key=String.fromCharCode(evt.keyCode); }else{ if(dojo.render.html.safari){ switch(evt.keyCode){ +case 25: +evt.key=evt.KEY_TAB; +evt.shift=true; +break; case 63232: evt.key=evt.KEY_UP_ARROW; break; @@ -5354,8 +2560,69 @@ break; case 63235: evt.key=evt.KEY_RIGHT_ARROW; break; +case 63236: +evt.key=evt.KEY_F1; +break; +case 63237: +evt.key=evt.KEY_F2; +break; +case 63238: +evt.key=evt.KEY_F3; +break; +case 63239: +evt.key=evt.KEY_F4; +break; +case 63240: +evt.key=evt.KEY_F5; +break; +case 63241: +evt.key=evt.KEY_F6; +break; +case 63242: +evt.key=evt.KEY_F7; +break; +case 63243: +evt.key=evt.KEY_F8; +break; +case 63244: +evt.key=evt.KEY_F9; +break; +case 63245: +evt.key=evt.KEY_F10; +break; +case 63246: +evt.key=evt.KEY_F11; +break; +case 63247: +evt.key=evt.KEY_F12; +break; +case 63250: +evt.key=evt.KEY_PAUSE; +break; +case 63272: +evt.key=evt.KEY_DELETE; +break; +case 63273: +evt.key=evt.KEY_HOME; +break; +case 63275: +evt.key=evt.KEY_END; +break; +case 63276: +evt.key=evt.KEY_PAGE_UP; +break; +case 63277: +evt.key=evt.KEY_PAGE_DOWN; +break; +case 63302: +evt.key=evt.KEY_INSERT; +break; +case 63248: +case 63249: +case 63289: +break; default: -evt.key=evt.charCode>0?String.fromCharCode(evt.charCode):evt.keyCode; +evt.key=evt.charCode>=evt.KEY_SPACE?String.fromCharCode(evt.charCode):evt.keyCode; } }else{ evt.key=evt.charCode>0?String.fromCharCode(evt.charCode):evt.keyCode; @@ -5370,7 +2637,7 @@ if(!evt.target){ evt.target=evt.srcElement; } if(!evt.currentTarget){ -evt.currentTarget=(_517?_517:evt.srcElement); +evt.currentTarget=(_247?_247:evt.srcElement); } if(!evt.layerX){ evt.layerX=evt.offsetX; @@ -5379,12 +2646,12 @@ if(!evt.layerY){ evt.layerY=evt.offsetY; } var doc=(evt.srcElement&&evt.srcElement.ownerDocument)?evt.srcElement.ownerDocument:document; -var _51b=((dojo.render.html.ie55)||(doc["compatMode"]=="BackCompat"))?doc.body:doc.documentElement; +var _24b=((dojo.render.html.ie55)||(doc["compatMode"]=="BackCompat"))?doc.body:doc.documentElement; if(!evt.pageX){ -evt.pageX=evt.clientX+(_51b.scrollLeft||0); +evt.pageX=evt.clientX+(_24b.scrollLeft||0); } if(!evt.pageY){ -evt.pageY=evt.clientY+(_51b.scrollTop||0); +evt.pageY=evt.clientY+(_24b.scrollTop||0); } if(evt.type=="mouseover"){ evt.relatedTarget=evt.fromElement; @@ -5401,223 +2668,18 @@ return evt; }; this.stopEvent=function(evt){ if(window.event){ -evt.returnValue=false; evt.cancelBubble=true; +evt.returnValue=false; }else{ evt.preventDefault(); evt.stopPropagation(); } }; }; +dojo.kwCompoundRequire({common:["dojo.event.common","dojo.event.topic"],browser:["dojo.event.browser"],dashboard:["dojo.event.browser"]}); dojo.provide("dojo.event.*"); -dojo.provide("dojo.logging.Logger"); -dojo.logging.Record=function(lvl,msg){ -this.level=lvl; -this.message=""; -this.msgArgs=[]; -this.time=new Date(); -if(dojo.lang.isArray(msg)){ -if(msg.length>0&&dojo.lang.isString(msg[0])){ -this.message=msg.shift(); -} -this.msgArgs=msg; -}else{ -this.message=msg; -} -}; -dojo.logging.LogFilter=function(_51f){ -this.passChain=_51f||""; -this.filter=function(_520){ -return true; -}; -}; -dojo.logging.Logger=function(){ -this.cutOffLevel=0; -this.propagate=true; -this.parent=null; -this.data=[]; -this.filters=[]; -this.handlers=[]; -}; -dojo.extend(dojo.logging.Logger,{argsToArr:function(args){ -var ret=[]; -for(var x=0;x=this.cutOffLevel; -},getEffectiveLevel:function(){ -if((this.cutOffLevel==0)&&(this.parent)){ -return this.parent.getEffectiveLevel(); -} -return this.cutOffLevel; -},addFilter:function(flt){ -this.filters.push(flt); -return this.filters.length-1; -},removeFilterByIndex:function(_527){ -if(this.filters[_527]){ -delete this.filters[_527]; -return true; -} -return false; -},removeFilter:function(_528){ -for(var x=0;x=this.cutOffLevel)){ -this.parent.log(lvl,msg); -return false; -} -this.handle(new dojo.logging.Record(lvl,msg)); -return true; -},debug:function(msg){ -return this.logType("DEBUG",this.argsToArr(arguments)); -},info:function(msg){ -return this.logType("INFO",this.argsToArr(arguments)); -},warning:function(msg){ -return this.logType("WARNING",this.argsToArr(arguments)); -},error:function(msg){ -return this.logType("ERROR",this.argsToArr(arguments)); -},critical:function(msg){ -return this.logType("CRITICAL",this.argsToArr(arguments)); -},exception:function(msg,e,_538){ -if(e){ -var _539=[e.name,(e.description||e.message)]; -if(e.fileName){ -_539.push(e.fileName); -_539.push("line "+e.lineNumber); -} -msg+=" "+_539.join(" : "); -} -this.logType("ERROR",msg); -if(!_538){ -throw e; -} -},logType:function(type,args){ -return this.log.apply(this,[dojo.logging.log.getLevel(type),args]); -},warn:function(){ -this.warning.apply(this,arguments); -},err:function(){ -this.error.apply(this,arguments); -},crit:function(){ -this.critical.apply(this,arguments); -}}); -dojo.logging.LogHandler=function(_53c){ -this.cutOffLevel=(_53c)?_53c:0; -this.formatter=null; -this.data=[]; -this.filters=[]; -}; -dojo.lang.extend(dojo.logging.LogHandler,{setFormatter:function(_53d){ -dojo.unimplemented("setFormatter"); -},flush:function(){ -},close:function(){ -},handleError:function(){ -},handle:function(_53e){ -if((this.filter(_53e))&&(_53e.level>=this.cutOffLevel)){ -this.emit(_53e); -} -},emit:function(_53f){ -dojo.unimplemented("emit"); -}}); -void (function(){ -var _540=["setLevel","addFilter","removeFilterByIndex","removeFilter","removeAllFilters","filter"]; -var tgt=dojo.logging.LogHandler.prototype; -var src=dojo.logging.Logger.prototype; -for(var x=0;x<_540.length;x++){ -tgt[_540[x]]=src[_540[x]]; -} -})(); -dojo.logging.log=new dojo.logging.Logger(); -dojo.logging.log.levels=[{"name":"DEBUG","level":1},{"name":"INFO","level":2},{"name":"WARNING","level":3},{"name":"ERROR","level":4},{"name":"CRITICAL","level":5}]; -dojo.logging.log.loggers={}; -dojo.logging.log.getLogger=function(name){ -if(!this.loggers[name]){ -this.loggers[name]=new dojo.logging.Logger(); -this.loggers[name].parent=this; -} -return this.loggers[name]; -}; -dojo.logging.log.getLevelName=function(lvl){ -for(var x=0;xthis.numRecords){ -this.data.shift(); -} -} -}}); -dojo.logging.logQueueHandler=new dojo.logging.MemoryLogHandler(0,50,0,10000); -dojo.logging.log.addHandler(dojo.logging.logQueueHandler); -dojo.log=dojo.logging.log; -dojo.provide("dojo.logging.*"); +dojo.provide("dojo.event"); +dojo.deprecated("dojo.event","replaced by dojo.event.*","0.5"); dojo.provide("dojo.string.common"); dojo.string.trim=function(str,wh){ if(!str.replace){ @@ -5635,12 +2697,12 @@ return dojo.string.trim(str,1); dojo.string.trimEnd=function(str){ return dojo.string.trim(str,-1); }; -dojo.string.repeat=function(str,_557,_558){ +dojo.string.repeat=function(str,_253,_254){ var out=""; -for(var i=0;i<_557;i++){ +for(var i=0;i<_253;i++){ out+=str; -if(_558&&i<_557-1){ -out+=_558; +if(_254&&i<_253-1){ +out+=_254; } } return out; @@ -5668,216 +2730,10 @@ return dojo.string.pad(str,len,c,1); dojo.string.padRight=function(str,len,c){ return dojo.string.pad(str,len,c,-1); }; -dojo.provide("dojo.string"); -dojo.provide("dojo.io.common"); -dojo.io.transports=[]; -dojo.io.hdlrFuncNames=["load","error","timeout"]; -dojo.io.Request=function(url,_567,_568,_569){ -if((arguments.length==1)&&(arguments[0].constructor==Object)){ -this.fromKwArgs(arguments[0]); -}else{ -this.url=url; -if(_567){ -this.mimetype=_567; -} -if(_568){ -this.transport=_568; -} -if(arguments.length>=4){ -this.changeUrl=_569; -} -} -}; -dojo.lang.extend(dojo.io.Request,{url:"",mimetype:"text/plain",method:"GET",content:undefined,transport:undefined,changeUrl:undefined,formNode:undefined,sync:false,bindSuccess:false,useCache:false,preventCache:false,load:function(type,data,_56c,_56d){ -},error:function(type,_56f,_570,_571){ -},timeout:function(type,_573,_574,_575){ -},handle:function(type,data,_578,_579){ -},timeoutSeconds:0,abort:function(){ -},fromKwArgs:function(_57a){ -if(_57a["url"]){ -_57a.url=_57a.url.toString(); -} -if(_57a["formNode"]){ -_57a.formNode=dojo.byId(_57a.formNode); -} -if(!_57a["method"]&&_57a["formNode"]&&_57a["formNode"].method){ -_57a.method=_57a["formNode"].method; -} -if(!_57a["handle"]&&_57a["handler"]){ -_57a.handle=_57a.handler; -} -if(!_57a["load"]&&_57a["loaded"]){ -_57a.load=_57a.loaded; -} -if(!_57a["changeUrl"]&&_57a["changeURL"]){ -_57a.changeUrl=_57a.changeURL; -} -_57a.encoding=dojo.lang.firstValued(_57a["encoding"],djConfig["bindEncoding"],""); -_57a.sendTransport=dojo.lang.firstValued(_57a["sendTransport"],djConfig["ioSendTransport"],false); -var _57b=dojo.lang.isFunction; -for(var x=0;x0){ -dojo.io.bind(dojo.io._bindQueue.shift()); -}else{ -dojo.io._queueBindInFlight=false; -} -} -}; -dojo.io._bindQueue=[]; -dojo.io._queueBindInFlight=false; -dojo.io.argsFromMap=function(map,_58f,last){ -var enc=/utf/i.test(_58f||"")?encodeURIComponent:dojo.string.encodeAscii; -var _592=[]; -var _593=new Object(); -for(var name in map){ -var _595=function(elt){ -var val=enc(name)+"="+enc(elt); -_592[(last==name)?"push":"unshift"](val); -}; -if(!_593[name]){ -var _598=map[name]; -if(dojo.lang.isArray(_598)){ -dojo.lang.forEach(_598,_595); -}else{ -_595(_598); -} -} -} -return _592.join("&"); -}; -dojo.io.setIFrameSrc=function(_599,src,_59b){ -try{ -var r=dojo.render.html; -if(!_59b){ -if(r.safari){ -_599.location=src; -}else{ -frames[_599.name].location=src; -} -}else{ -var idoc; -if(r.ie){ -idoc=_599.contentWindow.document; -}else{ -if(r.safari){ -idoc=_599.document; -}else{ -idoc=_599.contentWindow; -} -} -if(!idoc){ -_599.location=src; -return; -}else{ -idoc.location.replace(src); -} -} -} -catch(e){ -dojo.debug(e); -dojo.debug("setIFrameSrc: "+e); -} -}; dojo.provide("dojo.string.extras"); -dojo.string.substituteParams=function(_59e,hash){ +dojo.string.substituteParams=function(_262,hash){ var map=(typeof hash=="object")?hash:dojo.lang.toArray(arguments,1); -return _59e.replace(/\%\{(\w+)\}/g,function(_5a1,key){ +return _262.replace(/\%\{(\w+)\}/g,function(_265,key){ if(typeof (map[key])!="undefined"&&map[key]!=null){ return map[key]; } @@ -5891,11 +2747,11 @@ return ""; if(arguments.length==0){ str=this; } -var _5a4=str.split(" "); -for(var i=0;i<_5a4.length;i++){ -_5a4[i]=_5a4[i].charAt(0).toUpperCase()+_5a4[i].substring(1); +var _268=str.split(" "); +for(var i=0;i<_268.length;i++){ +_268[i]=_268[i].charAt(0).toUpperCase()+_268[i].substring(1); } -return _5a4.join(" "); +return _268.join(" "); }; dojo.string.isBlank=function(str){ if(!dojo.lang.isString(str)){ @@ -5908,15 +2764,15 @@ if(!dojo.lang.isString(str)){ return str; } var ret=""; -var _5a9=escape(str); -var _5aa,re=/%u([0-9A-F]{4})/i; -while((_5aa=_5a9.match(re))){ -var num=Number("0x"+_5aa[1]); -var _5ad=escape("&#"+num+";"); -ret+=_5a9.substring(0,_5aa.index)+_5ad; -_5a9=_5a9.substring(_5aa.index+_5aa[0].length); +var _26d=escape(str); +var _26e,re=/%u([0-9A-F]{4})/i; +while((_26e=_26d.match(re))){ +var num=Number("0x"+_26e[1]); +var _271=escape("&#"+num+";"); +ret+=_26d.substring(0,_26e.index)+_271; +_26d=_26d.substring(_26e.index+_26e[0].length); } -ret+=_5a9.replace(/\+/g,"%2B"); +ret+=_26d.replace(/\+/g,"%2B"); return ret; }; dojo.string.escape=function(type,str){ @@ -5941,9 +2797,9 @@ default: return str; } }; -dojo.string.escapeXml=function(str,_5b2){ +dojo.string.escapeXml=function(str,_276){ str=str.replace(/&/gm,"&").replace(//gm,">").replace(/"/gm,"""); -if(!_5b2){ +if(!_276){ str=str.replace(/'/gm,"'"); } return str; @@ -5966,8 +2822,8 @@ return str; } return str.substring(0,len).replace(/\.+$/,"")+"..."; }; -dojo.string.endsWith=function(str,end,_5bb){ -if(_5bb){ +dojo.string.endsWith=function(str,end,_27f){ +if(_27f){ str=str.toLowerCase(); end=end.toLowerCase(); } @@ -5984,12 +2840,12 @@ return true; } return false; }; -dojo.string.startsWith=function(str,_5bf,_5c0){ -if(_5c0){ +dojo.string.startsWith=function(str,_283,_284){ +if(_284){ str=str.toLowerCase(); -_5bf=_5bf.toLowerCase(); +_283=_283.toLowerCase(); } -return str.indexOf(_5bf)==0; +return str.indexOf(_283)==0; }; dojo.string.startsWithAny=function(str){ for(var i=1;i=4){ +this.changeUrl=_293; +} +} +}; +dojo.lang.extend(dojo.io.Request,{url:"",mimetype:"text/plain",method:"GET",content:undefined,transport:undefined,changeUrl:undefined,formNode:undefined,sync:false,bindSuccess:false,useCache:false,preventCache:false,load:function(type,data,_296,_297){ +},error:function(type,_299,_29a,_29b){ +},timeout:function(type,_29d,_29e,_29f){ +},handle:function(type,data,_2a2,_2a3){ +},timeoutSeconds:0,abort:function(){ +},fromKwArgs:function(_2a4){ +if(_2a4["url"]){ +_2a4.url=_2a4.url.toString(); +} +if(_2a4["formNode"]){ +_2a4.formNode=dojo.byId(_2a4.formNode); +} +if(!_2a4["method"]&&_2a4["formNode"]&&_2a4["formNode"].method){ +_2a4.method=_2a4["formNode"].method; +} +if(!_2a4["handle"]&&_2a4["handler"]){ +_2a4.handle=_2a4.handler; +} +if(!_2a4["load"]&&_2a4["loaded"]){ +_2a4.load=_2a4.loaded; +} +if(!_2a4["changeUrl"]&&_2a4["changeURL"]){ +_2a4.changeUrl=_2a4.changeURL; +} +_2a4.encoding=dojo.lang.firstValued(_2a4["encoding"],djConfig["bindEncoding"],""); +_2a4.sendTransport=dojo.lang.firstValued(_2a4["sendTransport"],djConfig["ioSendTransport"],false); +var _2a5=dojo.lang.isFunction; +for(var x=0;x0){ +dojo.io.bind(dojo.io._bindQueue.shift()); +}else{ +dojo.io._queueBindInFlight=false; +} +} +}; +dojo.io._bindQueue=[]; +dojo.io._queueBindInFlight=false; +dojo.io.argsFromMap=function(map,_2b9,last){ +var enc=/utf/i.test(_2b9||"")?encodeURIComponent:dojo.string.encodeAscii; +var _2bc=[]; +var _2bd=new Object(); +for(var name in map){ +var _2bf=function(elt){ +var val=enc(name)+"="+enc(elt); +_2bc[(last==name)?"push":"unshift"](val); +}; +if(!_2bd[name]){ +var _2c2=map[name]; +if(dojo.lang.isArray(_2c2)){ +dojo.lang.forEach(_2c2,_2bf); +}else{ +_2bf(_2c2); +} +} +} +return _2bc.join("&"); +}; +dojo.io.setIFrameSrc=function(_2c3,src,_2c5){ +try{ +var r=dojo.render.html; +if(!_2c5){ +if(r.safari){ +_2c3.location=src; +}else{ +frames[_2c3.name].location=src; +} +}else{ +var idoc; +if(r.ie){ +idoc=_2c3.contentWindow.document; +}else{ +if(r.safari){ +idoc=_2c3.document; +}else{ +idoc=_2c3.contentWindow; +} +} +if(!idoc){ +_2c3.location=src; +return; +}else{ +idoc.location.replace(src); +} +} +} +catch(e){ +dojo.debug(e); +dojo.debug("setIFrameSrc: "+e); +} +}; +dojo.provide("dojo.dom"); +dojo.dom.ELEMENT_NODE=1; +dojo.dom.ATTRIBUTE_NODE=2; +dojo.dom.TEXT_NODE=3; +dojo.dom.CDATA_SECTION_NODE=4; +dojo.dom.ENTITY_REFERENCE_NODE=5; +dojo.dom.ENTITY_NODE=6; +dojo.dom.PROCESSING_INSTRUCTION_NODE=7; +dojo.dom.COMMENT_NODE=8; +dojo.dom.DOCUMENT_NODE=9; +dojo.dom.DOCUMENT_TYPE_NODE=10; +dojo.dom.DOCUMENT_FRAGMENT_NODE=11; +dojo.dom.NOTATION_NODE=12; +dojo.dom.dojoml="http://www.dojotoolkit.org/2004/dojoml"; +dojo.dom.xmlns={svg:"http://www.w3.org/2000/svg",smil:"http://www.w3.org/2001/SMIL20/",mml:"http://www.w3.org/1998/Math/MathML",cml:"http://www.xml-cml.org",xlink:"http://www.w3.org/1999/xlink",xhtml:"http://www.w3.org/1999/xhtml",xul:"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",xbl:"http://www.mozilla.org/xbl",fo:"http://www.w3.org/1999/XSL/Format",xsl:"http://www.w3.org/1999/XSL/Transform",xslt:"http://www.w3.org/1999/XSL/Transform",xi:"http://www.w3.org/2001/XInclude",xforms:"http://www.w3.org/2002/01/xforms",saxon:"http://icl.com/saxon",xalan:"http://xml.apache.org/xslt",xsd:"http://www.w3.org/2001/XMLSchema",dt:"http://www.w3.org/2001/XMLSchema-datatypes",xsi:"http://www.w3.org/2001/XMLSchema-instance",rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",rdfs:"http://www.w3.org/2000/01/rdf-schema#",dc:"http://purl.org/dc/elements/1.1/",dcq:"http://purl.org/dc/qualifiers/1.0","soap-env":"http://schemas.xmlsoap.org/soap/envelope/",wsdl:"http://schemas.xmlsoap.org/wsdl/",AdobeExtensions:"http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"}; +dojo.dom.isNode=function(wh){ +if(typeof Element=="function"){ +try{ +return wh instanceof Element; +} +catch(e){ +} +}else{ +return wh&&!isNaN(wh.nodeType); +} +}; +dojo.dom.getUniqueId=function(){ +var _2c9=dojo.doc(); +do{ +var id="dj_unique_"+(++arguments.callee._idIncrement); +}while(_2c9.getElementById(id)); +return id; +}; +dojo.dom.getUniqueId._idIncrement=0; +dojo.dom.firstElement=dojo.dom.getFirstChildElement=function(_2cb,_2cc){ +var node=_2cb.firstChild; +while(node&&node.nodeType!=dojo.dom.ELEMENT_NODE){ +node=node.nextSibling; +} +if(_2cc&&node&&node.tagName&&node.tagName.toLowerCase()!=_2cc.toLowerCase()){ +node=dojo.dom.nextElement(node,_2cc); +} +return node; +}; +dojo.dom.lastElement=dojo.dom.getLastChildElement=function(_2ce,_2cf){ +var node=_2ce.lastChild; +while(node&&node.nodeType!=dojo.dom.ELEMENT_NODE){ +node=node.previousSibling; +} +if(_2cf&&node&&node.tagName&&node.tagName.toLowerCase()!=_2cf.toLowerCase()){ +node=dojo.dom.prevElement(node,_2cf); +} +return node; +}; +dojo.dom.nextElement=dojo.dom.getNextSiblingElement=function(node,_2d2){ +if(!node){ +return null; +} +do{ +node=node.nextSibling; +}while(node&&node.nodeType!=dojo.dom.ELEMENT_NODE); +if(node&&_2d2&&_2d2.toLowerCase()!=node.tagName.toLowerCase()){ +return dojo.dom.nextElement(node,_2d2); +} +return node; +}; +dojo.dom.prevElement=dojo.dom.getPreviousSiblingElement=function(node,_2d4){ +if(!node){ +return null; +} +if(_2d4){ +_2d4=_2d4.toLowerCase(); +} +do{ +node=node.previousSibling; +}while(node&&node.nodeType!=dojo.dom.ELEMENT_NODE); +if(node&&_2d4&&_2d4.toLowerCase()!=node.tagName.toLowerCase()){ +return dojo.dom.prevElement(node,_2d4); +} +return node; +}; +dojo.dom.moveChildren=function(_2d5,_2d6,trim){ +var _2d8=0; +if(trim){ +while(_2d5.hasChildNodes()&&_2d5.firstChild.nodeType==dojo.dom.TEXT_NODE){ +_2d5.removeChild(_2d5.firstChild); +} +while(_2d5.hasChildNodes()&&_2d5.lastChild.nodeType==dojo.dom.TEXT_NODE){ +_2d5.removeChild(_2d5.lastChild); +} +} +while(_2d5.hasChildNodes()){ +_2d6.appendChild(_2d5.firstChild); +_2d8++; +} +return _2d8; +}; +dojo.dom.copyChildren=function(_2d9,_2da,trim){ +var _2dc=_2d9.cloneNode(true); +return this.moveChildren(_2dc,_2da,trim); +}; +dojo.dom.replaceChildren=function(node,_2de){ +var _2df=[]; +if(dojo.render.html.ie){ +for(var i=0;i0){ +return _2ea[0]; +} +node=node.parentNode; +} +if(_2e9){ +return null; +} +return _2ea; +}; +dojo.dom.getAncestorsByTag=function(node,tag,_2ee){ +tag=tag.toLowerCase(); +return dojo.dom.getAncestors(node,function(el){ +return ((el.tagName)&&(el.tagName.toLowerCase()==tag)); +},_2ee); +}; +dojo.dom.getFirstAncestorByTag=function(node,tag){ +return dojo.dom.getAncestorsByTag(node,tag,true); +}; +dojo.dom.isDescendantOf=function(node,_2f3,_2f4){ +if(_2f4&&node){ +node=node.parentNode; +} +while(node){ +if(node==_2f3){ +return true; +} +node=node.parentNode; +} +return false; +}; +dojo.dom.innerXML=function(node){ +if(node.innerXML){ +return node.innerXML; +}else{ +if(node.xml){ +return node.xml; +}else{ +if(typeof XMLSerializer!="undefined"){ +return (new XMLSerializer()).serializeToString(node); +} +} +} +}; +dojo.dom.createDocument=function(){ +var doc=null; +var _2f7=dojo.doc(); +if(!dj_undef("ActiveXObject")){ +var _2f8=["MSXML2","Microsoft","MSXML","MSXML3"]; +for(var i=0;i<_2f8.length;i++){ +try{ +doc=new ActiveXObject(_2f8[i]+".XMLDOM"); +} +catch(e){ +} +if(doc){ +break; +} +} +}else{ +if((_2f7.implementation)&&(_2f7.implementation.createDocument)){ +doc=_2f7.implementation.createDocument("","",null); +} +} +return doc; +}; +dojo.dom.createDocumentFromText=function(str,_2fb){ +if(!_2fb){ +_2fb="text/xml"; +} +if(!dj_undef("DOMParser")){ +var _2fc=new DOMParser(); +return _2fc.parseFromString(str,_2fb); +}else{ +if(!dj_undef("ActiveXObject")){ +var _2fd=dojo.dom.createDocument(); +if(_2fd){ +_2fd.async=false; +_2fd.loadXML(str); +return _2fd; +}else{ +dojo.debug("toXml didn't work?"); +} +}else{ +var _2fe=dojo.doc(); +if(_2fe.createElement){ +var tmp=_2fe.createElement("xml"); +tmp.innerHTML=str; +if(_2fe.implementation&&_2fe.implementation.createDocument){ +var _300=_2fe.implementation.createDocument("foo","",null); +for(var i=0;i1){ +var _315=dojo.doc(); +dojo.dom.replaceChildren(node,_315.createTextNode(text)); +return text; +}else{ +if(node.textContent!=undefined){ +return node.textContent; +} +var _316=""; +if(node==null){ +return _316; +} +for(var i=0;i"); +document.write(""); } } catch(e){ @@ -6047,13 +3477,16 @@ catch(e){ if(dojo.render.html.opera){ dojo.debug("Opera is not supported with dojo.undo.browser, so back/forward detection will not work."); } -dojo.undo.browser={initialHref:window.location.href,initialHash:window.location.hash,moveForward:false,historyStack:[],forwardStack:[],historyIframe:null,bookmarkAnchor:null,locationTimer:null,setInitialState:function(args){ +dojo.undo.browser={initialHref:(!dj_undef("window"))?window.location.href:"",initialHash:(!dj_undef("window"))?window.location.hash:"",moveForward:false,historyStack:[],forwardStack:[],historyIframe:null,bookmarkAnchor:null,locationTimer:null,setInitialState:function(args){ this.initialState=this._createState(this.initialHref,args,this.initialHash); },addToHistory:function(args){ this.forwardStack=[]; var hash=null; var url=null; if(!this.historyIframe){ +if(djConfig["useXDomain"]&&!djConfig["dojoIframeHistoryUrl"]){ +dojo.debug("dojo.undo.browser: When using cross-domain Dojo builds,"+" please save iframe_history.html to your domain and set djConfig.dojoIframeHistoryUrl"+" to the path on your domain to iframe_history.html"); +} this.historyIframe=window.frames["djhistory"]; } if(!this.bookmarkAnchor){ @@ -6077,12 +3510,12 @@ setTimeout("window.location.href = '"+hash+"'; dojo.undo.browser.changingUrl = f this.bookmarkAnchor.href=hash; if(dojo.render.html.ie){ url=this._loadIframeHistory(); -var _5d0=args["back"]||args["backButton"]||args["handle"]; -var tcb=function(_5d2){ +var _325=args["back"]||args["backButton"]||args["handle"]; +var tcb=function(_327){ if(window.location.hash!=""){ setTimeout("window.location.href = '"+hash+"';",1); } -_5d0.apply(this,[_5d2]); +_325.apply(this,[_327]); }; if(args["back"]){ args.back=tcb; @@ -6095,13 +3528,13 @@ args.handle=tcb; } } } -var _5d3=args["forward"]||args["forwardButton"]||args["handle"]; -var tfw=function(_5d5){ +var _328=args["forward"]||args["forwardButton"]||args["handle"]; +var tfw=function(_32a){ if(window.location.hash!=""){ window.location.href=hash; } -if(_5d3){ -_5d3.apply(this,[_5d5]); +if(_328){ +_328.apply(this,[_32a]); } }; if(args["forward"]){ @@ -6146,10 +3579,10 @@ return; } } } -},iframeLoaded:function(evt,_5d8){ +},iframeLoaded:function(evt,_32d){ if(!dojo.render.html.opera){ -var _5d9=this._getUrlQuery(_5d8.href); -if(_5d9==null){ +var _32e=this._getUrlQuery(_32d.href); +if(_32e==null){ if(this.historyStack.length==1){ this.handleBackButton(); } @@ -6159,17 +3592,17 @@ if(this.moveForward){ this.moveForward=false; return; } -if(this.historyStack.length>=2&&_5d9==this._getUrlQuery(this.historyStack[this.historyStack.length-2].url)){ +if(this.historyStack.length>=2&&_32e==this._getUrlQuery(this.historyStack[this.historyStack.length-2].url)){ this.handleBackButton(); }else{ -if(this.forwardStack.length>0&&_5d9==this._getUrlQuery(this.forwardStack[this.forwardStack.length-1].url)){ +if(this.forwardStack.length>0&&_32e==this._getUrlQuery(this.forwardStack[this.forwardStack.length-1].url)){ this.handleForwardButton(); } } } },handleBackButton:function(){ -var _5da=this.historyStack.pop(); -if(!_5da){ +var _32f=this.historyStack.pop(); +if(!_32f){ return; } var last=this.historyStack[this.historyStack.length-1]; @@ -6189,7 +3622,7 @@ last.kwArgs.handle("back"); } } } -this.forwardStack.push(_5da); +this.forwardStack.push(_32f); },handleForwardButton:function(){ var last=this.forwardStack.pop(); if(!last){ @@ -6210,52 +3643,46 @@ this.historyStack.push(last); },_createState:function(url,args,hash){ return {"url":url,"kwArgs":args,"urlHash":hash}; },_getUrlQuery:function(url){ -var _5e1=url.split("?"); -if(_5e1.length<2){ +var _336=url.split("?"); +if(_336.length<2){ return null; }else{ -return _5e1[1]; +return _336[1]; } },_loadIframeHistory:function(){ -var url=dojo.hostenv.getBaseScriptUri()+"iframe_history.html?"+(new Date()).getTime(); +var url=(djConfig["dojoIframeHistoryUrl"]||dojo.hostenv.getBaseScriptUri()+"iframe_history.html")+"?"+(new Date()).getTime(); this.moveForward=true; dojo.io.setIFrameSrc(this.historyIframe,url,false); return url; }}; dojo.provide("dojo.io.BrowserIO"); +if(!dj_undef("window")){ dojo.io.checkChildrenForFile=function(node){ -var _5e4=false; -var _5e5=node.getElementsByTagName("input"); -dojo.lang.forEach(_5e5,function(_5e6){ -if(_5e4){ +var _339=false; +var _33a=node.getElementsByTagName("input"); +dojo.lang.forEach(_33a,function(_33b){ +if(_339){ return; } -if(_5e6.getAttribute("type")=="file"){ -_5e4=true; +if(_33b.getAttribute("type")=="file"){ +_339=true; } }); -return _5e4; +return _339; }; -dojo.io.formHasFile=function(_5e7){ -return dojo.io.checkChildrenForFile(_5e7); +dojo.io.formHasFile=function(_33c){ +return dojo.io.checkChildrenForFile(_33c); }; -dojo.io.updateNode=function(node,_5e9){ +dojo.io.updateNode=function(node,_33e){ node=dojo.byId(node); -var args=_5e9; -if(dojo.lang.isString(_5e9)){ -args={url:_5e9}; +var args=_33e; +if(dojo.lang.isString(_33e)){ +args={url:_33e}; } args.mimetype="text/html"; args.load=function(t,d,e){ while(node.firstChild){ -if(dojo["event"]){ -try{ -dojo.event.browser.clean(node.firstChild); -} -catch(e){ -} -} -node.removeChild(node.firstChild); +dojo.dom.destroyNode(node.firstChild); } node.innerHTML=d; }; @@ -6265,18 +3692,18 @@ dojo.io.formFilter=function(node){ var type=(node.type||"").toLowerCase(); return !node.disabled&&node.name&&!dojo.lang.inArray(["file","submit","image","reset","button"],type); }; -dojo.io.encodeForm=function(_5f0,_5f1,_5f2){ -if((!_5f0)||(!_5f0.tagName)||(!_5f0.tagName.toLowerCase()=="form")){ +dojo.io.encodeForm=function(_345,_346,_347){ +if((!_345)||(!_345.tagName)||(!_345.tagName.toLowerCase()=="form")){ dojo.raise("Attempted to encode a non-form element."); } -if(!_5f2){ -_5f2=dojo.io.formFilter; +if(!_347){ +_347=dojo.io.formFilter; } -var enc=/utf/i.test(_5f1||"")?encodeURIComponent:dojo.string.encodeAscii; -var _5f4=[]; -for(var i=0;i<_5f0.elements.length;i++){ -var elm=_5f0.elements[i]; -if(!elm||elm.tagName.toLowerCase()=="fieldset"||!_5f2(elm)){ +var enc=/utf/i.test(_346||"")?encodeURIComponent:dojo.string.encodeAscii; +var _349=[]; +for(var i=0;i<_345.elements.length;i++){ +var elm=_345.elements[i]; +if(!elm||elm.tagName.toLowerCase()=="fieldset"||!_347(elm)){ continue; } var name=enc(elm.name); @@ -6284,30 +3711,30 @@ var type=elm.type.toLowerCase(); if(type=="select-multiple"){ for(var j=0;j=200)&&(http.status<300))||(http.status==304)||(location.protocol=="file:"&&(http.status==0||http.status==undefined))||(location.protocol=="chrome:"&&(http.status==0||http.status==undefined))){ var ret; -if(_61b.method.toLowerCase()=="head"){ -var _621=http.getAllResponseHeaders(); +if(_370.method.toLowerCase()=="head"){ +var _376=http.getAllResponseHeaders(); ret={}; ret.toString=function(){ -return _621; +return _376; }; -var _622=_621.split(/[\r\n]+/g); -for(var i=0;i<_622.length;i++){ -var pair=_622[i].match(/^([^:]+)\s*:\s*(.+)$/i); +var _377=_376.split(/[\r\n]+/g); +for(var i=0;i<_377.length;i++){ +var pair=_377[i].match(/^([^:]+)\s*:\s*(.+)$/i); if(pair){ ret[pair[1]]=pair[2]; } } }else{ -if(_61b.mimetype=="text/javascript"){ +if(_370.mimetype=="text/javascript"){ try{ ret=dj_eval(http.responseText); } @@ -6442,7 +3869,7 @@ dojo.debug(http.responseText); ret=null; } }else{ -if(_61b.mimetype=="text/json"||_61b.mimetype=="application/json"){ +if(_370.mimetype=="text/json"||_370.mimetype=="application/json"){ try{ ret=dj_eval("("+http.responseText+")"); } @@ -6452,7 +3879,7 @@ dojo.debug(http.responseText); ret=false; } }else{ -if((_61b.mimetype=="application/xml")||(_61b.mimetype=="text/xml")){ +if((_370.mimetype=="application/xml")||(_370.mimetype=="text/xml")){ ret=http.responseXML; if(!ret||typeof ret=="string"||!http.getResponseHeader("Content-Type")){ ret=dojo.dom.createDocumentFromText(http.responseText); @@ -6463,22 +3890,22 @@ ret=http.responseText; } } } -if(_61f){ -addToCache(url,_61e,_61b.method,http); +if(_374){ +addToCache(url,_373,_370.method,http); } -_61b[(typeof _61b.load=="function")?"load":"handle"]("load",ret,http,_61b); +_370[(typeof _370.load=="function")?"load":"handle"]("load",ret,http,_370); }else{ -var _625=new dojo.io.Error("XMLHttpTransport Error: "+http.status+" "+http.statusText); -_61b[(typeof _61b.error=="function")?"error":"handle"]("error",_625,http,_61b); +var _37a=new dojo.io.Error("XMLHttpTransport Error: "+http.status+" "+http.statusText); +_370[(typeof _370.error=="function")?"error":"handle"]("error",_37a,http,_370); } } -function setHeaders(http,_627){ -if(_627["headers"]){ -for(var _628 in _627["headers"]){ -if(_628.toLowerCase()=="content-type"&&!_627["contentType"]){ -_627["contentType"]=_627["headers"][_628]; +function setHeaders(http,_37c){ +if(_37c["headers"]){ +for(var _37d in _37c["headers"]){ +if(_37d.toLowerCase()=="content-type"&&!_37c["contentType"]){ +_37c["contentType"]=_37c["headers"][_37d]; }else{ -http.setRequestHeader(_628,_627["headers"][_628]); +http.setRequestHeader(_37d,_37c["headers"][_37d]); } } } @@ -6492,7 +3919,7 @@ this.inFlightTimer=setTimeout("dojo.io.XMLHTTPTransport.watchInFlight();",10); }; this.watchInFlight=function(){ var now=null; -if(!dojo.hostenv._blockAsync&&!_60f._blockAsync){ +if(!dojo.hostenv._blockAsync&&!_364._blockAsync){ for(var x=this.inFlight.length-1;x>=0;x--){ try{ var tif=this.inFlight[x]; @@ -6520,8 +3947,8 @@ tif.req[(typeof tif.req.timeout=="function")?"timeout":"handle"]("timeout",null, } catch(e){ try{ -var _62c=new dojo.io.Error("XMLHttpTransport.watchInFlight Error: "+e); -tif.req[(typeof tif.req.error=="function")?"error":"handle"]("error",_62c,tif.http,tif.req); +var _381=new dojo.io.Error("XMLHttpTransport.watchInFlight Error: "+e); +tif.req[(typeof tif.req.error=="function")?"error":"handle"]("error",_381,tif.http,tif.req); } catch(e2){ dojo.debug("XMLHttpTransport error callback failed: "+e2); @@ -6536,74 +3963,74 @@ return; } this.inFlightTimer=setTimeout("dojo.io.XMLHTTPTransport.watchInFlight();",10); }; -var _62d=dojo.hostenv.getXmlhttpObject()?true:false; -this.canHandle=function(_62e){ -return _62d&&dojo.lang.inArray(["text/plain","text/html","application/xml","text/xml","text/javascript","text/json","application/json"],(_62e["mimetype"].toLowerCase()||""))&&!(_62e["formNode"]&&dojo.io.formHasFile(_62e["formNode"])); +var _382=dojo.hostenv.getXmlhttpObject()?true:false; +this.canHandle=function(_383){ +return _382&&dojo.lang.inArray(["text/plain","text/html","application/xml","text/xml","text/javascript","text/json","application/json"],(_383["mimetype"].toLowerCase()||""))&&!(_383["formNode"]&&dojo.io.formHasFile(_383["formNode"])); }; this.multipartBoundary="45309FFF-BD65-4d50-99C9-36986896A96F"; -this.bind=function(_62f){ -if(!_62f["url"]){ -if(!_62f["formNode"]&&(_62f["backButton"]||_62f["back"]||_62f["changeUrl"]||_62f["watchForURL"])&&(!djConfig.preventBackButtonFix)){ +this.bind=function(_384){ +if(!_384["url"]){ +if(!_384["formNode"]&&(_384["backButton"]||_384["back"]||_384["changeUrl"]||_384["watchForURL"])&&(!djConfig.preventBackButtonFix)){ dojo.deprecated("Using dojo.io.XMLHTTPTransport.bind() to add to browser history without doing an IO request","Use dojo.undo.browser.addToHistory() instead.","0.4"); -dojo.undo.browser.addToHistory(_62f); +dojo.undo.browser.addToHistory(_384); return true; } } -var url=_62f.url; -var _631=""; -if(_62f["formNode"]){ -var ta=_62f.formNode.getAttribute("action"); -if((ta)&&(!_62f["url"])){ +var url=_384.url; +var _386=""; +if(_384["formNode"]){ +var ta=_384.formNode.getAttribute("action"); +if((ta)&&(!_384["url"])){ url=ta; } -var tp=_62f.formNode.getAttribute("method"); -if((tp)&&(!_62f["method"])){ -_62f.method=tp; +var tp=_384.formNode.getAttribute("method"); +if((tp)&&(!_384["method"])){ +_384.method=tp; } -_631+=dojo.io.encodeForm(_62f.formNode,_62f.encoding,_62f["formFilter"]); +_386+=dojo.io.encodeForm(_384.formNode,_384.encoding,_384["formFilter"]); } if(url.indexOf("#")>-1){ dojo.debug("Warning: dojo.io.bind: stripping hash values from url:",url); url=url.split("#")[0]; } -if(_62f["file"]){ -_62f.method="post"; +if(_384["file"]){ +_384.method="post"; } -if(!_62f["method"]){ -_62f.method="get"; +if(!_384["method"]){ +_384.method="get"; } -if(_62f.method.toLowerCase()=="get"){ -_62f.multipart=false; +if(_384.method.toLowerCase()=="get"){ +_384.multipart=false; }else{ -if(_62f["file"]){ -_62f.multipart=true; +if(_384["file"]){ +_384.multipart=true; }else{ -if(!_62f["multipart"]){ -_62f.multipart=false; +if(!_384["multipart"]){ +_384.multipart=false; } } } -if(_62f["backButton"]||_62f["back"]||_62f["changeUrl"]){ -dojo.undo.browser.addToHistory(_62f); +if(_384["backButton"]||_384["back"]||_384["changeUrl"]){ +dojo.undo.browser.addToHistory(_384); } -var _634=_62f["content"]||{}; -if(_62f.sendTransport){ -_634["dojo.transport"]="xmlhttp"; +var _389=_384["content"]||{}; +if(_384.sendTransport){ +_389["dojo.transport"]="xmlhttp"; } do{ -if(_62f.postContent){ -_631=_62f.postContent; +if(_384.postContent){ +_386=_384.postContent; break; } -if(_634){ -_631+=dojo.io.argsFromMap(_634,_62f.encoding); +if(_389){ +_386+=dojo.io.argsFromMap(_389,_384.encoding); } -if(_62f.method.toLowerCase()=="get"||!_62f.multipart){ +if(_384.method.toLowerCase()=="get"||!_384.multipart){ break; } var t=[]; -if(_631.length){ -var q=_631.split("&"); +if(_386.length){ +var q=_386.split("&"); for(var i=0;i-1?"&":"?")+_631; +var _396=url; +if(_386!=""){ +_396+=(_396.indexOf("?")>-1?"&":"?")+_386; } -if(_63b){ -_641+=(dojo.string.endsWithAny(_641,"?","&")?"":(_641.indexOf("?")>-1?"&":"?"))+"dojo.preventCache="+new Date().valueOf(); +if(_390){ +_396+=(dojo.string.endsWithAny(_396,"?","&")?"":(_396.indexOf("?")>-1?"&":"?"))+"dojo.preventCache="+new Date().valueOf(); } -if(!_62f.user){ -http.open(_62f.method.toUpperCase(),_641,_63a); +if(!_384.user){ +http.open(_384.method.toUpperCase(),_396,_38f); }else{ -http.open(_62f.method.toUpperCase(),_641,_63a,_62f.user,_62f.password); +http.open(_384.method.toUpperCase(),_396,_38f,_384.user,_384.password); } -setHeaders(http,_62f); +setHeaders(http,_384); try{ http.send(null); } @@ -6683,14 +4110,14 @@ catch(e){ if(typeof http.abort=="function"){ http.abort(); } -doLoad(_62f,{status:404},url,_631,_63c); +doLoad(_384,{status:404},url,_386,_391); } } -if(!_63a){ -doLoad(_62f,http,url,_631,_63c); -_60f._blockAsync=false; +if(!_38f){ +doLoad(_384,http,url,_386,_391); +_364._blockAsync=false; } -_62f.abort=function(){ +_384.abort=function(){ try{ http._aborted=true; } @@ -6702,16 +4129,17 @@ return; }; dojo.io.transports.addTransport("XMLHTTPTransport"); }; +} dojo.provide("dojo.io.cookie"); -dojo.io.cookie.setCookie=function(name,_643,days,path,_646,_647){ -var _648=-1; -if(typeof days=="number"&&days>=0){ +dojo.io.cookie.setCookie=function(name,_398,days,path,_39b,_39c){ +var _39d=-1; +if((typeof days=="number")&&(days>=0)){ var d=new Date(); d.setTime(d.getTime()+(days*24*60*60*1000)); -_648=d.toGMTString(); +_39d=d.toGMTString(); } -_643=escape(_643); -document.cookie=name+"="+_643+";"+(_648!=-1?" expires="+_648+";":"")+(path?"path="+path:"")+(_646?"; domain="+_646:"")+(_647?"; secure":""); +_398=escape(_398); +document.cookie=name+"="+_398+";"+(_39d!=-1?" expires="+_39d+";":"")+(path?"path="+path:"")+(_39b?"; domain="+_39b:"")+(_39c?"; secure":""); }; dojo.io.cookie.set=dojo.io.cookie.setCookie; dojo.io.cookie.getCookie=function(name){ @@ -6719,71 +4147,71 @@ var idx=document.cookie.lastIndexOf(name+"="); if(idx==-1){ return null; } -var _64c=document.cookie.substring(idx+name.length+1); -var end=_64c.indexOf(";"); +var _3a1=document.cookie.substring(idx+name.length+1); +var end=_3a1.indexOf(";"); if(end==-1){ -end=_64c.length; +end=_3a1.length; } -_64c=_64c.substring(0,end); -_64c=unescape(_64c); -return _64c; +_3a1=_3a1.substring(0,end); +_3a1=unescape(_3a1); +return _3a1; }; dojo.io.cookie.get=dojo.io.cookie.getCookie; dojo.io.cookie.deleteCookie=function(name){ dojo.io.cookie.setCookie(name,"-",0); }; -dojo.io.cookie.setObjectCookie=function(name,obj,days,path,_653,_654,_655){ +dojo.io.cookie.setObjectCookie=function(name,obj,days,path,_3a8,_3a9,_3aa){ if(arguments.length==5){ -_655=_653; -_653=null; -_654=null; +_3aa=_3a8; +_3a8=null; +_3a9=null; } -var _656=[],_657,_658=""; -if(!_655){ -_657=dojo.io.cookie.getObjectCookie(name); +var _3ab=[],_3ac,_3ad=""; +if(!_3aa){ +_3ac=dojo.io.cookie.getObjectCookie(name); } if(days>=0){ -if(!_657){ -_657={}; +if(!_3ac){ +_3ac={}; } for(var prop in obj){ -if(prop==null){ -delete _657[prop]; +if(obj[prop]==null){ +delete _3ac[prop]; }else{ -if(typeof obj[prop]=="string"||typeof obj[prop]=="number"){ -_657[prop]=obj[prop]; +if((typeof obj[prop]=="string")||(typeof obj[prop]=="number")){ +_3ac[prop]=obj[prop]; } } } prop=null; -for(var prop in _657){ -_656.push(escape(prop)+"="+escape(_657[prop])); +for(var prop in _3ac){ +_3ab.push(escape(prop)+"="+escape(_3ac[prop])); } -_658=_656.join("&"); +_3ad=_3ab.join("&"); } -dojo.io.cookie.setCookie(name,_658,days,path,_653,_654); +dojo.io.cookie.setCookie(name,_3ad,days,path,_3a8,_3a9); }; dojo.io.cookie.getObjectCookie=function(name){ -var _65b=null,_65c=dojo.io.cookie.getCookie(name); -if(_65c){ -_65b={}; -var _65d=_65c.split("&"); -for(var i=0;i<_65d.length;i++){ -var pair=_65d[i].split("="); -var _660=pair[1]; -if(isNaN(_660)){ -_660=unescape(pair[1]); +var _3b0=null,_3b1=dojo.io.cookie.getCookie(name); +if(_3b1){ +_3b0={}; +var _3b2=_3b1.split("&"); +for(var i=0;i<_3b2.length;i++){ +var pair=_3b2[i].split("="); +var _3b5=pair[1]; +if(isNaN(_3b5)){ +_3b5=unescape(pair[1]); } -_65b[unescape(pair[0])]=_660; +_3b0[unescape(pair[0])]=_3b5; } } -return _65b; +return _3b0; }; dojo.io.cookie.isSupported=function(){ if(typeof navigator.cookieEnabled!="boolean"){ dojo.io.cookie.setCookie("__TestingYourBrowserForCookieSupport__","CookiesAllowed",90,null); -var _661=dojo.io.cookie.getCookie("__TestingYourBrowserForCookieSupport__"); -navigator.cookieEnabled=(_661=="CookiesAllowed"); +var _3b6=dojo.io.cookie.getCookie("__TestingYourBrowserForCookieSupport__"); +navigator.cookieEnabled=(_3b6=="CookiesAllowed"); if(navigator.cookieEnabled){ this.deleteCookie("__TestingYourBrowserForCookieSupport__"); } @@ -6793,304 +4221,18 @@ return navigator.cookieEnabled; if(!dojo.io.cookies){ dojo.io.cookies=dojo.io.cookie; } +dojo.kwCompoundRequire({common:["dojo.io.common"],rhino:["dojo.io.RhinoIO"],browser:["dojo.io.BrowserIO","dojo.io.cookie"],dashboard:["dojo.io.BrowserIO","dojo.io.cookie"]}); dojo.provide("dojo.io.*"); -dojo.provide("dojo.uri.*"); -dojo.provide("dojo.io.IframeIO"); -dojo.io.createIFrame=function(_662,_663,uri){ -if(window[_662]){ -return window[_662]; -} -if(window.frames[_662]){ -return window.frames[_662]; -} -var r=dojo.render.html; -var _666=null; -var turi=uri||dojo.uri.dojoUri("iframe_history.html?noInit=true"); -var _668=((r.ie)&&(dojo.render.os.win))?""); + document.write(""); } }catch(e){/* squelch */} @@ -9085,37 +5748,9 @@ if(dojo.render.html.opera){ dojo.debug("Opera is not supported with dojo.undo.browser, so back/forward detection will not work."); } -/* NOTES: - * Safari 1.2: - * back button "works" fine, however it's not possible to actually - * DETECT that you've moved backwards by inspecting window.location. - * Unless there is some other means of locating. - * FIXME: perhaps we can poll on history.length? - * Safari 2.0.3+ (and probably 1.3.2+): - * works fine, except when changeUrl is used. When changeUrl is used, - * Safari jumps all the way back to whatever page was shown before - * the page that uses dojo.undo.browser support. - * IE 5.5 SP2: - * back button behavior is macro. It does not move back to the - * previous hash value, but to the last full page load. This suggests - * that the iframe is the correct way to capture the back button in - * these cases. - * Don't test this page using local disk for MSIE. MSIE will not create - * a history list for iframe_history.html if served from a file: URL. - * The XML served back from the XHR tests will also not be properly - * created if served from local disk. Serve the test pages from a web - * server to test in that browser. - * IE 6.0: - * same behavior as IE 5.5 SP2 - * Firefox 1.0+: - * the back button will return us to the previous hash on the same - * page, thereby not requiring an iframe hack, although we do then - * need to run a timer to detect inter-page movement. - */ - dojo.undo.browser = { - initialHref: window.location.href, - initialHash: window.location.hash, + initialHref: (!dj_undef("window")) ? window.location.href : "", + initialHash: (!dj_undef("window")) ? window.location.hash : "", moveForward: false, historyStack: [], @@ -9125,40 +5760,71 @@ dojo.undo.browser = { locationTimer: null, /** - * setInitialState sets the state object and back callback for the very first page that is loaded. - * It is recommended that you call this method as part of an event listener that is registered via - * dojo.addOnLoad(). + * */ - setInitialState: function(args){ + setInitialState: function(/*Object*/args){ + //summary: Sets the state object and back callback for the very first page that is loaded. + //description: It is recommended that you call this method as part of an event listener that is registered via + //dojo.addOnLoad(). + //args: Object + // See the addToHistory() function for the list of valid args properties. this.initialState = this._createState(this.initialHref, args, this.initialHash); }, //FIXME: Would like to support arbitrary back/forward jumps. Have to rework iframeLoaded among other things. //FIXME: is there a slight race condition in moz using change URL with the timer check and when // the hash gets set? I think I have seen a back/forward call in quick succession, but not consistent. - /** - * addToHistory takes one argument, and it is an object that defines the following functions: - * - To support getting back button notifications, the object argument should implement a - * function called either "back", "backButton", or "handle". The string "back" will be - * passed as the first and only argument to this callback. - * - To support getting forward button notifications, the object argument should implement a - * function called either "forward", "forwardButton", or "handle". The string "forward" will be - * passed as the first and only argument to this callback. - * - If you want the browser location string to change, define "changeUrl" on the object. If the - * value of "changeUrl" is true, then a unique number will be appended to the URL as a fragment - * identifier (http://some.domain.com/path#uniquenumber). If it is any other value that does - * not evaluate to false, that value will be used as the fragment identifier. For example, - * if changeUrl: 'page1', then the URL will look like: http://some.domain.com/path#page1 - * - * Full example: - * - * dojo.undo.browser.addToHistory({ - * back: function() { alert('back pressed'); }, - * forward: function() { alert('forward pressed'); }, - * changeUrl: true - * }); - */ addToHistory: function(args){ + //summary: adds a state object (args) to the history list. You must set + //djConfig.preventBackButtonFix = false to use dojo.undo.browser. + + //args: Object + // args can have the following properties: + // To support getting back button notifications, the object argument should implement a + // function called either "back", "backButton", or "handle". The string "back" will be + // passed as the first and only argument to this callback. + // - To support getting forward button notifications, the object argument should implement a + // function called either "forward", "forwardButton", or "handle". The string "forward" will be + // passed as the first and only argument to this callback. + // - If you want the browser location string to change, define "changeUrl" on the object. If the + // value of "changeUrl" is true, then a unique number will be appended to the URL as a fragment + // identifier (http://some.domain.com/path#uniquenumber). If it is any other value that does + // not evaluate to false, that value will be used as the fragment identifier. For example, + // if changeUrl: 'page1', then the URL will look like: http://some.domain.com/path#page1 + // Full example: + // dojo.undo.browser.addToHistory({ + // back: function() { alert('back pressed'); }, + // forward: function() { alert('forward pressed'); }, + // changeUrl: true + // }); + // + // BROWSER NOTES: + // Safari 1.2: + // back button "works" fine, however it's not possible to actually + // DETECT that you've moved backwards by inspecting window.location. + // Unless there is some other means of locating. + // FIXME: perhaps we can poll on history.length? + // Safari 2.0.3+ (and probably 1.3.2+): + // works fine, except when changeUrl is used. When changeUrl is used, + // Safari jumps all the way back to whatever page was shown before + // the page that uses dojo.undo.browser support. + // IE 5.5 SP2: + // back button behavior is macro. It does not move back to the + // previous hash value, but to the last full page load. This suggests + // that the iframe is the correct way to capture the back button in + // these cases. + // Don't test this page using local disk for MSIE. MSIE will not create + // a history list for iframe_history.html if served from a file: URL. + // The XML served back from the XHR tests will also not be properly + // created if served from local disk. Serve the test pages from a web + // server to test in that browser. + // IE 6.0: + // same behavior as IE 5.5 SP2 + // Firefox 1.0+: + // the back button will return us to the previous hash on the same + // page, thereby not requiring an iframe hack, although we do then + // need to run a timer to detect inter-page movement. + //If addToHistory is called, then that means we prune the //forward stack -- the user went back, then wanted to //start a new forward path. @@ -9167,6 +5833,11 @@ dojo.undo.browser = { var hash = null; var url = null; if(!this.historyIframe){ + if(djConfig["useXDomain"] && !djConfig["dojoIframeHistoryUrl"]){ + dojo.debug("dojo.undo.browser: When using cross-domain Dojo builds," + + " please save iframe_history.html to your domain and set djConfig.dojoIframeHistoryUrl" + + " to the path on your domain to iframe_history.html"); + } this.historyIframe = window.frames["djhistory"]; } if(!this.bookmarkAnchor){ @@ -9259,6 +5930,7 @@ dojo.undo.browser = { }, checkLocation: function(){ + //summary: private method. Do not call this directly. if (!this.changingUrl){ var hsl = this.historyStack.length; @@ -9290,6 +5962,7 @@ dojo.undo.browser = { }, iframeLoaded: function(evt, ifrLoc){ + //summary: private method. Do not call this directly. if(!dojo.render.html.opera){ var query = this._getUrlQuery(ifrLoc.href); if(query == null){ @@ -9318,6 +5991,8 @@ dojo.undo.browser = { }, handleBackButton: function(){ + //summary: private method. Do not call this directly. + //The "current" page is always at the top of the history stack. var current = this.historyStack.pop(); if(!current){ return; } @@ -9338,6 +6013,8 @@ dojo.undo.browser = { }, handleForwardButton: function(){ + //summary: private method. Do not call this directly. + var last = this.forwardStack.pop(); if(!last){ return; } if(last.kwArgs["forward"]){ @@ -9351,31 +6028,45 @@ dojo.undo.browser = { }, _createState: function(url, args, hash){ - return {"url": url, "kwArgs": args, "urlHash": hash}; + //summary: private method. Do not call this directly. + + return {"url": url, "kwArgs": args, "urlHash": hash}; //Object }, _getUrlQuery: function(url){ + //summary: private method. Do not call this directly. var segments = url.split("?"); if (segments.length < 2){ - return null; + return null; //null } else{ - return segments[1]; + return segments[1]; //String } }, _loadIframeHistory: function(){ - var url = dojo.hostenv.getBaseScriptUri()+"iframe_history.html?"+(new Date()).getTime(); + //summary: private method. Do not call this directly. + var url = (djConfig["dojoIframeHistoryUrl"] || dojo.hostenv.getBaseScriptUri()+'iframe_history.html') + + "?" + (new Date()).getTime(); this.moveForward = true; dojo.io.setIFrameSrc(this.historyIframe, url, false); - return url; + return url; //String } } dojo.provide("dojo.io.BrowserIO"); -dojo.io.checkChildrenForFile = function(node){ + + + + + + +if(!dj_undef("window")) { + +dojo.io.checkChildrenForFile = function(/*DOMNode*/node){ + //summary: Checks any child nodes of node for an input type="file" element. var hasFile = false; var inputs = node.getElementsByTagName("input"); dojo.lang.forEach(inputs, function(input){ @@ -9384,14 +6075,20 @@ dojo.io.checkChildrenForFile = function(node){ hasFile = true; } }); - return hasFile; + return hasFile; //boolean } -dojo.io.formHasFile = function(formNode){ - return dojo.io.checkChildrenForFile(formNode); +dojo.io.formHasFile = function(/*DOMNode*/formNode){ + //summary: Just calls dojo.io.checkChildrenForFile(). + return dojo.io.checkChildrenForFile(formNode); //boolean } -dojo.io.updateNode = function(node, urlOrArgs){ +dojo.io.updateNode = function(/*DOMNode*/node, /*String or Object*/urlOrArgs){ + //summary: Updates a DOMnode with the result of a dojo.io.bind() call. + //node: DOMNode + //urlOrArgs: String or Object + // Either a String that has an URL, or an object containing dojo.io.bind() + // arguments. node = dojo.byId(node); var args = urlOrArgs; if(dojo.lang.isString(urlOrArgs)){ @@ -9400,26 +6097,35 @@ dojo.io.updateNode = function(node, urlOrArgs){ args.mimetype = "text/html"; args.load = function(t, d, e){ while(node.firstChild){ - if(dojo["event"]){ - try{ - dojo.event.browser.clean(node.firstChild); - }catch(e){} - } - node.removeChild(node.firstChild); + dojo.dom.destroyNode(node.firstChild); } node.innerHTML = d; }; dojo.io.bind(args); } -dojo.io.formFilter = function(node) { +dojo.io.formFilter = function(/*DOMNode*/node) { + //summary: Returns true if the node is an input element that is enabled, has + //a name, and whose type is one of the following values: ["file", "submit", "image", "reset", "button"] var type = (node.type||"").toLowerCase(); return !node.disabled && node.name - && !dojo.lang.inArray(["file", "submit", "image", "reset", "button"], type); + && !dojo.lang.inArray(["file", "submit", "image", "reset", "button"], type); //boolean } // TODO: Move to htmlUtils -dojo.io.encodeForm = function(formNode, encoding, formFilter){ +dojo.io.encodeForm = function(/*DOMNode*/formNode, /*String?*/encoding, /*Function?*/formFilter){ + //summary: Converts the names and values of form elements into an URL-encoded + //string (name=value&name=value...). + //formNode: DOMNode + //encoding: String? + // The encoding to use for the values. Specify a string that starts with + // "utf" (for instance, "utf8"), to use encodeURIComponent() as the encoding + // function. Otherwise, dojo.string.encodeAscii will be used. + //formFilter: Function? + // A function used to filter out form elements. The element node will be passed + // to the formFilter function, and a boolean result is expected (true indicating + // indicating that the element should have its name/value included in the output). + // If no formFilter is specified, then dojo.io.formFilter() will be used. if((!formNode)||(!formNode.tagName)||(!formNode.tagName.toLowerCase() == "form")){ dojo.raise("Attempted to encode a non-form element."); } @@ -9460,10 +6166,16 @@ dojo.io.encodeForm = function(formNode, encoding, formFilter){ values.push(name + ".y=0"); } } - return values.join("&") + "&"; + return values.join("&") + "&"; //String } -dojo.io.FormBind = function(args) { +dojo.io.FormBind = function(/*DOMNode or Object*/args) { + //summary: constructor for a dojo.io.FormBind object. See the Dojo Book for + //some information on usage: http://manual.dojotoolkit.org/WikiHome/DojoDotBook/Book23 + //args: DOMNode or Object + // args can either be the DOMNode for a form element, or an object containing + // dojo.io.bind() arguments, one of which should be formNode with the value of + // a form element DOMNode. this.bindArgs = {}; if(args && args.formNode) { @@ -9479,7 +6191,9 @@ dojo.lang.extend(dojo.io.FormBind, { clickedButton: null, - init: function(args) { + init: function(/*DOMNode or Object*/args) { + //summary: Internal function called by the dojo.io.FormBind() constructor + //do not call this method directly. var form = dojo.byId(args.formNode); if(!form || !form.tagName || form.tagName.toLowerCase() != "form") { @@ -9511,11 +6225,15 @@ dojo.lang.extend(dojo.io.FormBind, { } }, - onSubmit: function(form) { - return true; + onSubmit: function(/*DOMNode*/form) { + //summary: Function used to verify that the form is OK to submit. + //Override this function if you want specific form validation done. + return true; //boolean }, - submit: function(e) { + submit: function(/*Event*/e) { + //summary: internal function that is connected as a listener to the + //form's onsubmit event. e.preventDefault(); if(this.onSubmit(this.form)) { dojo.io.bind(dojo.lang.mixin(this.bindArgs, { @@ -9524,13 +6242,17 @@ dojo.lang.extend(dojo.io.FormBind, { } }, - click: function(e) { + click: function(/*Event*/e) { + //summary: internal method that is connected as a listener to the + //form's elements whose click event can submit a form. var node = e.currentTarget; if(node.disabled) { return; } this.clickedButton = node; }, - formFilter: function(node) { + formFilter: function(/*DOMNode*/node) { + //summary: internal function used to know which form element values to include + // in the dojo.io.bind() request. var type = (node.type||"").toLowerCase(); var accept = false; if(node.disabled || !node.name) { @@ -9541,11 +6263,13 @@ dojo.lang.extend(dojo.io.FormBind, { } else { accept = !dojo.lang.inArray(["file", "submit", "reset", "button"], type); } - return accept; + return accept; //boolean }, // in case you don't have dojo.event.* pulled in - connect: function(srcObj, srcFcn, targetFcn) { + connect: function(/*Object*/srcObj, /*Function*/srcFcn, /*Function*/targetFcn) { + //summary: internal function used to connect event listeners to form elements + //that trigger events. Used in case dojo.event is not loaded. if(dojo.evalObjPath("dojo.event.connect")) { dojo.event.connect(srcObj, srcFcn, this, targetFcn); } else { @@ -9561,6 +6285,7 @@ dojo.lang.extend(dojo.io.FormBind, { }); dojo.io.XMLHTTPTransport = new function(){ + //summary: The object that implements the dojo.io.bind transport for XMLHttpRequest. var _this = this; var _cache = {}; // FIXME: make this public? do we even need to? @@ -9656,6 +6381,8 @@ dojo.io.XMLHTTPTransport = new function(){ this.inFlightTimer = null; this.startWatchingInFlight = function(){ + //summary: internal method used to trigger a timer to watch all inflight + //XMLHttpRequests. if(!this.inFlightTimer){ // setInterval broken in mozilla x86_64 in some circumstances, see // https://bugzilla.mozilla.org/show_bug.cgi?id=344439 @@ -9665,6 +6392,8 @@ dojo.io.XMLHTTPTransport = new function(){ } this.watchInFlight = function(){ + //summary: internal method that checks each inflight XMLHttpRequest to see + //if it has completed or if the timeout situation applies. var now = null; // make sure sync calls stay thread safe, if this callback is called during a sync call // and this results in another sync call before the first sync call ends the browser hangs @@ -9715,21 +6444,66 @@ dojo.io.XMLHTTPTransport = new function(){ } var hasXmlHttp = dojo.hostenv.getXmlhttpObject() ? true : false; - this.canHandle = function(kwArgs){ - // canHandle just tells dojo.io.bind() if this is a good transport to - // use for the particular type of request. + this.canHandle = function(/*dojo.io.Request*/kwArgs){ + //summary: Tells dojo.io.bind() if this is a good transport to + //use for the particular type of request. This type of transport cannot + //handle forms that have an input type="file" element. // FIXME: we need to determine when form values need to be // multi-part mime encoded and avoid using this transport for those // requests. return hasXmlHttp && dojo.lang.inArray(["text/plain", "text/html", "application/xml", "text/xml", "text/javascript", "text/json", "application/json"], (kwArgs["mimetype"].toLowerCase()||"")) - && !( kwArgs["formNode"] && dojo.io.formHasFile(kwArgs["formNode"]) ); + && !( kwArgs["formNode"] && dojo.io.formHasFile(kwArgs["formNode"]) ); //boolean } this.multipartBoundary = "45309FFF-BD65-4d50-99C9-36986896A96F"; // unique guid as a boundary value for multipart posts - this.bind = function(kwArgs){ + this.bind = function(/*dojo.io.Request*/kwArgs){ + //summary: function that sends the request to the server. + + //This function will attach an abort() function to the kwArgs dojo.io.Request object, + //so if you need to abort the request, you can call that method on the request object. + //The following are acceptable properties in kwArgs (in addition to the + //normal dojo.io.Request object properties). + //url: String: URL the server URL to use for the request. + //method: String: the HTTP method to use (GET, POST, etc...). + //mimetype: Specifies what format the result data should be given to the load/handle callback. Valid values are: + // text/javascript, text/json, application/json, application/xml, text/xml. Any other mimetype will give back a text + // string. + //transport: String: specify "XMLHTTPTransport" to force the use of this XMLHttpRequest transport. + //headers: Object: The object property names and values will be sent as HTTP request header + // names and values. + //sendTransport: boolean: If true, then dojo.transport=xmlhttp will be added to the request. + //encoding: String: The type of encoding to use when dealing with the content kwArgs property. + //content: Object: The content object is converted into a name=value&name=value string, by + // using dojo.io.argsFromMap(). The encoding kwArgs property is passed to dojo.io.argsFromMap() + // for use in encoding the names and values. The resulting string is added to the request. + //formNode: DOMNode: a form element node. This should not normally be used. Use new dojo.io.FormBind() instead. + // If formNode is used, then the names and values of the form elements will be converted + // to a name=value&name=value string and added to the request. The encoding kwArgs property is used + // to encode the names and values. + //postContent: String: Raw name=value&name=value string to be included as part of the request. + //back or backButton: Function: A function to be called if the back button is pressed. If this kwArgs property + // is used, then back button support via dojo.undo.browser will be used. See notes for dojo.undo.browser on usage. + // You need to set djConfig.preventBackButtonFix = false to enable back button support. + //changeUrl: boolean or String: Used as part of back button support. See notes for dojo.undo.browser on usage. + //user: String: The user name. Used in conjuction with password. Passed to XMLHttpRequest.open(). + //password: String: The user's password. Used in conjuction with user. Passed to XMLHttpRequest.open(). + //file: Object or Array of Objects: an object simulating a file to be uploaded. file objects should have the following properties: + // name or fileName: the name of the file + // contentType: the MIME content type for the file. + // content: the actual content of the file. + //multipart: boolean: indicates whether this should be a multipart mime request. If kwArgs.file exists, then this + // property is set to true automatically. + //sync: boolean: if true, then a synchronous XMLHttpRequest call is done, + // if false (the default), then an asynchronous call is used. + //preventCache: boolean: If true, then a cache busting parameter is added to the request URL. + // default value is false. + //useCache: boolean: If true, then XMLHttpTransport will keep an internal cache of the server + // response and use that response if a similar request is done again. + // A similar request is one that has the same URL, query string and HTTP method value. + // default is false. if(!kwArgs["url"]){ // are we performing a history action? if( !kwArgs["formNode"] @@ -9949,11 +6723,16 @@ dojo.io.XMLHTTPTransport = new function(){ dojo.io.transports.addTransport("XMLHTTPTransport"); } +} + dojo.provide("dojo.io.cookie"); -dojo.io.cookie.setCookie = function(name, value, days, path, domain, secure) { +dojo.io.cookie.setCookie = function(/*String*/name, /*String*/value, + /*Number?*/days, /*String?*/path, + /*String?*/domain, /*boolean?*/secure){ + //summary: sets a cookie. var expires = -1; - if(typeof days == "number" && days >= 0) { + if((typeof days == "number")&&(days >= 0)){ var d = new Date(); d.setTime(d.getTime()+(days*24*60*60*1000)); expires = d.toGMTString(); @@ -9968,7 +6747,9 @@ dojo.io.cookie.setCookie = function(name, value, days, path, domain, secure) { dojo.io.cookie.set = dojo.io.cookie.setCookie; -dojo.io.cookie.getCookie = function(name) { +dojo.io.cookie.getCookie = function(/*String*/name){ + //summary: Gets a cookie with the given name. + // FIXME: Which cookie should we return? // If there are cookies set for different sub domains in the current // scope there could be more than one cookie with the same name. @@ -9981,34 +6762,48 @@ dojo.io.cookie.getCookie = function(name) { if(end == -1) { end = value.length; } value = value.substring(0, end); value = unescape(value); - return value; + return value; //String } dojo.io.cookie.get = dojo.io.cookie.getCookie; -dojo.io.cookie.deleteCookie = function(name) { +dojo.io.cookie.deleteCookie = function(/*String*/name){ + //summary: Deletes a cookie with the given name. dojo.io.cookie.setCookie(name, "-", 0); } -dojo.io.cookie.setObjectCookie = function(name, obj, days, path, domain, secure, clearCurrent) { - if(arguments.length == 5) { // for backwards compat +dojo.io.cookie.setObjectCookie = function( /*String*/name, /*Object*/obj, + /*Number?*/days, /*String?*/path, + /*String?*/domain, /*boolean?*/secure, + /*boolean?*/clearCurrent){ + //summary: Takes an object, serializes it to a cookie value, and either + //sets a cookie with the serialized value. + //description: If clearCurrent is true, then any current cookie value + //for this object will be replaced with the the new serialized object value. + //If clearCurrent is false, then the existing cookie value will be modified + //with any changes from the new object value. + //Objects must be simple name/value pairs where the value is either a string + //or a number. Any other value will be ignored. + if(arguments.length == 5){ // for backwards compat clearCurrent = domain; domain = null; secure = null; } var pairs = [], cookie, value = ""; - if(!clearCurrent) { cookie = dojo.io.cookie.getObjectCookie(name); } - if(days >= 0) { - if(!cookie) { cookie = {}; } - for(var prop in obj) { - if(prop == null) { + if(!clearCurrent){ + cookie = dojo.io.cookie.getObjectCookie(name); + } + if(days >= 0){ + if(!cookie){ cookie = {}; } + for(var prop in obj){ + if(obj[prop] == null){ delete cookie[prop]; - } else if(typeof obj[prop] == "string" || typeof obj[prop] == "number") { + }else if((typeof obj[prop] == "string")||(typeof obj[prop] == "number")){ cookie[prop] = obj[prop]; } } prop = null; - for(var prop in cookie) { + for(var prop in cookie){ pairs.push(escape(prop) + "=" + escape(cookie[prop])); } value = pairs.join("&"); @@ -10016,419 +6811,58 @@ dojo.io.cookie.setObjectCookie = function(name, obj, days, path, domain, secure, dojo.io.cookie.setCookie(name, value, days, path, domain, secure); } -dojo.io.cookie.getObjectCookie = function(name) { +dojo.io.cookie.getObjectCookie = function(/*String*/name){ + //summary: Gets an object value for the given cookie name. The complement of + //dojo.io.cookie.setObjectCookie(). var values = null, cookie = dojo.io.cookie.getCookie(name); - if(cookie) { + if(cookie){ values = {}; var pairs = cookie.split("&"); - for(var i = 0; i < pairs.length; i++) { + for(var i = 0; i < pairs.length; i++){ var pair = pairs[i].split("="); var value = pair[1]; - if( isNaN(value) ) { value = unescape(pair[1]); } + if( isNaN(value) ){ value = unescape(pair[1]); } values[ unescape(pair[0]) ] = value; } } return values; } -dojo.io.cookie.isSupported = function() { - if(typeof navigator.cookieEnabled != "boolean") { +dojo.io.cookie.isSupported = function(){ + //summary: Tests the browser to see if cookies are enabled. + if(typeof navigator.cookieEnabled != "boolean"){ dojo.io.cookie.setCookie("__TestingYourBrowserForCookieSupport__", "CookiesAllowed", 90, null); var cookieVal = dojo.io.cookie.getCookie("__TestingYourBrowserForCookieSupport__"); navigator.cookieEnabled = (cookieVal == "CookiesAllowed"); - if(navigator.cookieEnabled) { + if(navigator.cookieEnabled){ // FIXME: should we leave this around? this.deleteCookie("__TestingYourBrowserForCookieSupport__"); } } - return navigator.cookieEnabled; + return navigator.cookieEnabled; //boolean } // need to leave this in for backwards-compat from 0.1 for when it gets pulled in by dojo.io.* -if(!dojo.io.cookies) { dojo.io.cookies = dojo.io.cookie; } +if(!dojo.io.cookies){ dojo.io.cookies = dojo.io.cookie; } +dojo.kwCompoundRequire({ + common: ["dojo.io.common"], + rhino: ["dojo.io.RhinoIO"], + browser: ["dojo.io.BrowserIO", "dojo.io.cookie"], + dashboard: ["dojo.io.BrowserIO", "dojo.io.cookie"] +}); dojo.provide("dojo.io.*"); -dojo.provide("dojo.uri.*"); +dojo.provide("dojo.io"); -dojo.provide("dojo.io.IframeIO"); -// FIXME: is it possible to use the Google htmlfile hack to prevent the -// background click with this transport? - -dojo.io.createIFrame = function(fname, onloadstr, uri){ - if(window[fname]){ return window[fname]; } - if(window.frames[fname]){ return window.frames[fname]; } - var r = dojo.render.html; - var cframe = null; - var turi = uri||dojo.uri.dojoUri("iframe_history.html?noInit=true"); - var ifrstr = ((r.ie)&&(dojo.render.os.win)) ? '" - }else{ + ifrDiv.innerHTML = ""; + } else { this.rcvNode = dojo.io.createIFrame(this.rcvNodeName, "", initUrl); - // dojo.io.setIFrameSrc(this.rcvNode, initUrl); - // we're still waiting on the iframe to call back up to use and - // advertise that it's been initialized via tunnelInit } - } -} - -cometd.mimeReplaceTransport = new function(){ + }; +}; +cometd.mimeReplaceTransport = new function () { this.connected = false; this.connectionId = null; this.xhr = null; - this.authToken = null; this.lastTimestamp = null; this.lastId = null; this.backlog = []; - - this.check = function(types, version, xdomain){ - return ((!xdomain)&& - (dojo.render.html.mozilla)&& // seems only Moz really supports this right now = ( - (dojo.lang.inArray(types, "mime-message-block"))); - } - - this.tunnelInit = function(){ - if(this.connected){ return; } - // FIXME: open up the connection here - this.openTunnelWith({ - message: dojo.json.serialize([ - { - channel: "/meta/connect", - clientId: cometd.clientId, - connectionType: "mime-message-block" - // FIXME: auth not passed here! - // "authToken": this.authToken - } - ]) - }); + this.check = function (types, version, xdomain) { + return ((!xdomain) && (dojo.render.html.mozilla) && (dojo.lang.inArray(types, "mime-message-block"))); + }; + this.tunnelInit = function () { + if (this.connected) { + return; + } + this.openTunnelWith({message:dojo.json.serialize([{channel:"/meta/connect", clientId:cometd.clientId, connectionType:"mime-message-block"}])}); this.connected = true; - } - - this.tunnelCollapse = function(){ - if(this.connected){ - // try to restart the tunnel + }; + this.tunnelCollapse = function () { + if (this.connected) { this.connected = false; - this.openTunnelWith({ - message: dojo.json.serialize([ - { - channel: "/meta/reconnect", - clientId: cometd.clientId, - connectionId: this.connectionId, - timestamp: this.lastTimestamp, - id: this.lastId - // FIXME: no authToken provision! - } - ]) - }); + this.openTunnelWith({message:dojo.json.serialize([{channel:"/meta/reconnect", clientId:cometd.clientId, connectionId:this.connectionId, timestamp:this.lastTimestamp, id:this.lastId}])}); } - } - + }; this.deliver = cometd.iframeTransport.deliver; - // the logic appears to be the same - - this.handleOnLoad = function(resp){ + this.handleOnLoad = function (resp) { cometd.deliver(dojo.json.evalJson(this.xhr.responseText)); - } - - this.openTunnelWith = function(content, url){ - // set up the XHR object and register the multipart callbacks + }; + this.openTunnelWith = function (content, url) { this.xhr = dojo.hostenv.getXmlhttpObject(); - this.xhr.multipart = true; // FIXME: do Opera and Safari support this flag? - if(dojo.render.html.mozilla){ + this.xhr.multipart = true; + if (dojo.render.html.mozilla) { this.xhr.addEventListener("load", dojo.lang.hitch(this, "handleOnLoad"), false); - }else if(dojo.render.html.safari){ - // Blah. WebKit doesn't actually populate responseText and/or responseXML. Useless. - dojo.debug("Webkit is broken with multipart responses over XHR = ("); - this.xhr.onreadystatechange = dojo.lang.hitch(this, "handleOnLoad"); - }else{ - this.xhr.onload = dojo.lang.hitch(this, "handleOnLoad"); + } else { + if (dojo.render.html.safari) { + dojo.debug("Webkit is broken with multipart responses over XHR = ("); + this.xhr.onreadystatechange = dojo.lang.hitch(this, "handleOnLoad"); + } else { + this.xhr.onload = dojo.lang.hitch(this, "handleOnLoad"); + } } - this.xhr.open("POST", (url||cometd.url), true); // async post + this.xhr.open("POST", (url || cometd.url), true); this.xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); dojo.debug(dojo.json.serialize(content)); this.xhr.send(dojo.io.argsFromMap(content, "utf8")); - } - - this.processBacklog = function(){ - while(this.backlog.length > 0){ + }; + this.processBacklog = function () { + while (this.backlog.length > 0) { this.sendMessage(this.backlog.shift(), true); } - } - - this.sendMessage = function(message, bypassBacklog){ - // FIXME: what about auth fields? - if((bypassBacklog)||(this.connected)){ + }; + this.sendMessage = function (message, bypassBacklog) { + if ((bypassBacklog) || (this.connected)) { message.connectionId = this.connectionId; message.clientId = cometd.clientId; - var bindArgs = { - url: cometd.url||djConfig["cometdRoot"], - method: "POST", - mimetype: "text/json", - content: { message: dojo.json.serialize([ message ]) } - }; + var bindArgs = {url:cometd.url || djConfig["cometdRoot"], method:"POST", mimetype:"text/json", content:{message:dojo.json.serialize([message])}}; return dojo.io.bind(bindArgs); - }else{ + } else { this.backlog.push(message); } - } - - this.startup = function(handshakeData){ + }; + this.startup = function (handshakeData) { dojo.debugShallow(handshakeData); - if(this.connected){ return; } + if (this.connected) { + return; + } this.tunnelInit(); - } -} - -cometd.longPollTransport = new function(){ + }; +}; +cometd.longPollTransport = new function () { this.connected = false; this.connectionId = null; - this.authToken = null; this.lastTimestamp = null; this.lastId = null; this.backlog = []; - - this.check = function(types, version, xdomain){ - return ((!xdomain)&&(dojo.lang.inArray(types, "long-polling"))); - } - - this.tunnelInit = function(){ - if(this.connected){ return; } - // FIXME: open up the connection here - this.openTunnelWith({ - message: dojo.json.serialize([ - { - channel: "/meta/connect", - clientId: cometd.clientId, - connectionType: "long-polling" - // FIXME: auth not passed here! - // "authToken": this.authToken - } - ]) - }); + this.check = function (types, version, xdomain) { + return ((!xdomain) && (dojo.lang.inArray(types, "long-polling"))); + }; + this.tunnelInit = function () { + if (this.connected) { + return; + } + this.openTunnelWith({message:dojo.json.serialize([{channel:"/meta/connect", clientId:cometd.clientId, connectionType:"long-polling"}])}); this.connected = true; - } - - this.tunnelCollapse = function(){ - if(!this.connected){ - // try to restart the tunnel + }; + this.tunnelCollapse = function () { + if (!this.connected) { this.connected = false; dojo.debug("clientId:", cometd.clientId); - this.openTunnelWith({ - message: dojo.json.serialize([ - { - channel: "/meta/reconnect", - connectionType: "long-polling", - clientId: cometd.clientId, - connectionId: this.connectionId, - timestamp: this.lastTimestamp, - id: this.lastId - // FIXME: no authToken provision! - } - ]) - }); + this.openTunnelWith({message:dojo.json.serialize([{channel:"/meta/reconnect", connectionType:"long-polling", clientId:cometd.clientId, connectionId:this.connectionId, timestamp:this.lastTimestamp, id:this.lastId}])}); } - } - + }; this.deliver = cometd.iframeTransport.deliver; - // the logic appears to be the same - - this.openTunnelWith = function(content, url){ - dojo.io.bind({ - url: (url||cometd.url), - method: "post", - content: content, - mimetype: "text/json", - load: dojo.lang.hitch(this, function(type, data, evt, args){ - // dojo.debug(evt.responseText); - cometd.deliver(data); - this.connected = false; - this.tunnelCollapse(); - }), - error: function(){ dojo.debug("tunnel opening failed"); } - }); + this.openTunnelWith = function (content, url) { + dojo.io.bind({url:(url || cometd.url), method:"post", content:content, mimetype:"text/json", load:dojo.lang.hitch(this, function (type, data, evt, args) { + cometd.deliver(data); + this.connected = false; + this.tunnelCollapse(); + }), error:function () { + dojo.debug("tunnel opening failed"); + }}); this.connected = true; - } - - this.processBacklog = function(){ - while(this.backlog.length > 0){ + }; + this.processBacklog = function () { + while (this.backlog.length > 0) { this.sendMessage(this.backlog.shift(), true); } - } - - this.sendMessage = function(message, bypassBacklog){ - // FIXME: what about auth fields? - if((bypassBacklog)||(this.connected)){ + }; + this.sendMessage = function (message, bypassBacklog) { + if ((bypassBacklog) || (this.connected)) { message.connectionId = this.connectionId; message.clientId = cometd.clientId; - var bindArgs = { - url: cometd.url||djConfig["cometdRoot"], - method: "post", - mimetype: "text/json", - content: { message: dojo.json.serialize([ message ]) } - }; + var bindArgs = {url:cometd.url || djConfig["cometdRoot"], method:"post", mimetype:"text/json", content:{message:dojo.json.serialize([message])}, load:dojo.lang.hitch(this, function (type, data, evt, args) { + cometd.deliver(data); + })}; return dojo.io.bind(bindArgs); - }else{ + } else { this.backlog.push(message); } - } - - this.startup = function(handshakeData){ - if(this.connected){ return; } + }; + this.startup = function (handshakeData) { + if (this.connected) { + return; + } this.tunnelInit(); - } -} - -cometd.callbackPollTransport = new function(){ + }; +}; +cometd.callbackPollTransport = new function () { this.connected = false; this.connectionId = null; - this.authToken = null; this.lastTimestamp = null; this.lastId = null; this.backlog = []; - - this.check = function(types, version, xdomain){ - // we handle x-domain! + this.check = function (types, version, xdomain) { return dojo.lang.inArray(types, "callback-polling"); - } - - this.tunnelInit = function(){ - if(this.connected){ return; } - // FIXME: open up the connection here - this.openTunnelWith({ - message: dojo.json.serialize([ - { - channel: "/meta/connect", - clientId: cometd.clientId, - connectionType: "callback-polling" - // FIXME: auth not passed here! - // "authToken": this.authToken - } - ]) - }); - this.connected = true; - } - - this.tunnelCollapse = function(){ - if(!this.connected){ - // try to restart the tunnel - this.connected = false; - this.openTunnelWith({ - message: dojo.json.serialize([ - { - channel: "/meta/reconnect", - connectionType: "long-polling", - clientId: cometd.clientId, - connectionId: this.connectionId, - timestamp: this.lastTimestamp, - id: this.lastId - // FIXME: no authToken provision! - } - ]) - }); + }; + this.tunnelInit = function () { + if (this.connected) { + return; } - } - - this.deliver = cometd.iframeTransport.deliver; - // the logic appears to be the same - - this.openTunnelWith = function(content, url){ - // create a @@ -195,6 +256,6 @@

This file is used for Dojo's XMLHttpRequest Iframe Proxy. This is the "client" file used internally by dojo.io.XhrIframeProxy.

- + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/io/xip_server.html b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/io/xip_server.html index 565c7cc2c..b69fb8e7d 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/io/xip_server.html +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/io/xip_server.html @@ -42,16 +42,11 @@ - data: The URL-encoded data for the request. For a GET request, this would be the querystring parameters. For a POST request, it wll be the body data. + + See xip_client.html for more info on the xip fragment identifier protocol. --> @@ -333,5 +373,6 @@

This file is used for Dojo's XMLHttpRequest Iframe Proxy. This is the the file that should go on the server that will actually be doing the XHR request.

+
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/json.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/json.js index caa1474ae..52971fced 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/json.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/json.js @@ -12,145 +12,85 @@ dojo.provide("dojo.json"); dojo.require("dojo.lang.func"); dojo.require("dojo.string.extras"); dojo.require("dojo.AdapterRegistry"); - -dojo.json = { - // jsonRegistry: AdapterRegistry a registry of type-based serializers - jsonRegistry: new dojo.AdapterRegistry(), - - register: function( /*String*/ name, - /*function*/ check, - /*function*/ wrap, - /*optional, boolean*/ override){ - // summary: - // Register a JSON serialization function. JSON serialization - // functions should take one argument and return an object - // suitable for JSON serialization: - // - string - // - number - // - boolean - // - undefined - // - object - // - null - // - Array-like (length property that is a number) - // - Objects with a "json" method will have this method called - // - Any other object will be used as {key:value, ...} pairs - // - // If override is given, it is used as the highest priority JSON - // serialization, otherwise it will be used as the lowest. - // name: - // a descriptive type for this serializer - // check: - // a unary function that will be passed an object to determine - // whether or not wrap will be used to serialize the object - // wrap: - // the serialization function - // override: - // optional, determines if the this serialization function will be - // given priority in the test order - - dojo.json.jsonRegistry.register(name, check, wrap, override); - }, - - evalJson: function(/*String*/ json){ - // summary: - // evaluates the passed string-form of a JSON object - // json: - // a string literal of a JSON item, for instance: - // '{ "foo": [ "bar", 1, { "baz": "thud" } ] }' - // return: - // the result of the evaluation - - // FIXME: should this accept mozilla's optional second arg? - try { - return eval("(" + json + ")"); - }catch(e){ - dojo.debug(e); - return json; - } - }, - - serialize: function(/*Object*/ o){ - // summary: - // Create a JSON serialization of an object, note that this - // doesn't check for infinite recursion, so don't do that! - // o: - // an object to be serialized. Objects may define their own - // serialization via a special "__json__" or "json" function - // property. If a specialized serializer has been defined, it will - // be used as a fallback. - // return: - // a String representing the serialized version of the passed - // object - - var objtype = typeof(o); - if(objtype == "undefined"){ - return "undefined"; - }else if((objtype == "number")||(objtype == "boolean")){ - return o + ""; - }else if(o === null){ - return "null"; - } - if (objtype == "string") { return dojo.string.escapeString(o); } - // recurse - var me = arguments.callee; - // short-circuit for objects that support "json" serialization - // if they return "self" then just pass-through... - var newObj; - if(typeof(o.__json__) == "function"){ - newObj = o.__json__(); - if(o !== newObj){ - return me(newObj); - } - } - if(typeof(o.json) == "function"){ - newObj = o.json(); - if (o !== newObj) { - return me(newObj); - } - } - // array - if(objtype != "function" && typeof(o.length) == "number"){ - var res = []; - for(var i = 0; i < o.length; i++){ - var val = me(o[i]); - if(typeof(val) != "string"){ - val = "undefined"; - } - res.push(val); - } - return "[" + res.join(",") + "]"; - } - // look in the registry - try { - window.o = o; - newObj = dojo.json.jsonRegistry.match(o); - return me(newObj); - }catch(e){ - // dojo.debug(e); - } - // it's a function with no adapter, bad - if(objtype == "function"){ - return null; - } - // generic object code path - res = []; - for (var k in o){ - var useKey; - if (typeof(k) == "number"){ - useKey = '"' + k + '"'; - }else if (typeof(k) == "string"){ - useKey = dojo.string.escapeString(k); - }else{ - // skip non-string or number keys - continue; - } - val = me(o[k]); - if(typeof(val) != "string"){ - // skip non-serializable values - continue; - } - res.push(useKey + ":" + val); - } - return "{" + res.join(",") + "}"; +dojo.json = {jsonRegistry:new dojo.AdapterRegistry(), register:function (name, check, wrap, override) { + dojo.json.jsonRegistry.register(name, check, wrap, override); +}, evalJson:function (json) { + try { + return eval("(" + json + ")"); } -}; + catch (e) { + dojo.debug(e); + return json; + } +}, serialize:function (o) { + var objtype = typeof (o); + if (objtype == "undefined") { + return "undefined"; + } else { + if ((objtype == "number") || (objtype == "boolean")) { + return o + ""; + } else { + if (o === null) { + return "null"; + } + } + } + if (objtype == "string") { + return dojo.string.escapeString(o); + } + var me = arguments.callee; + var newObj; + if (typeof (o.__json__) == "function") { + newObj = o.__json__(); + if (o !== newObj) { + return me(newObj); + } + } + if (typeof (o.json) == "function") { + newObj = o.json(); + if (o !== newObj) { + return me(newObj); + } + } + if (objtype != "function" && typeof (o.length) == "number") { + var res = []; + for (var i = 0; i < o.length; i++) { + var val = me(o[i]); + if (typeof (val) != "string") { + val = "undefined"; + } + res.push(val); + } + return "[" + res.join(",") + "]"; + } + try { + window.o = o; + newObj = dojo.json.jsonRegistry.match(o); + return me(newObj); + } + catch (e) { + } + if (objtype == "function") { + return null; + } + res = []; + for (var k in o) { + var useKey; + if (typeof (k) == "number") { + useKey = "\"" + k + "\""; + } else { + if (typeof (k) == "string") { + useKey = dojo.string.escapeString(k); + } else { + continue; + } + } + val = me(o[k]); + if (typeof (val) != "string") { + continue; + } + res.push(useKey + ":" + val); + } + return "{" + res.join(",") + "}"; +}}; + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang.js index 7f8cfad60..094210d89 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang.js @@ -10,5 +10,5 @@ dojo.provide("dojo.lang"); dojo.require("dojo.lang.common"); - dojo.deprecated("dojo.lang", "replaced by dojo.lang.common", "0.5"); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang/__package__.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang/__package__.js index 7f51006e7..b2ab79ab6 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang/__package__.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang/__package__.js @@ -8,16 +8,6 @@ http://dojotoolkit.org/community/licensing.shtml */ -dojo.kwCompoundRequire({ - common: [ - "dojo.lang.common", - "dojo.lang.assert", - "dojo.lang.array", - "dojo.lang.type", - "dojo.lang.func", - "dojo.lang.extras", - "dojo.lang.repr", - "dojo.lang.declare" - ] -}); +dojo.kwCompoundRequire({common:["dojo.lang.common", "dojo.lang.assert", "dojo.lang.array", "dojo.lang.type", "dojo.lang.func", "dojo.lang.extras", "dojo.lang.repr", "dojo.lang.declare"]}); dojo.provide("dojo.lang.*"); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang/array.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang/array.js index f48b09423..bbe9cc6eb 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang/array.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang/array.js @@ -9,178 +9,166 @@ */ dojo.provide("dojo.lang.array"); - dojo.require("dojo.lang.common"); - -// FIXME: Is this worthless since you can do: if(name in obj) -// is this the right place for this? -dojo.lang.has = function(/*Object*/obj, /*String*/name){ - try{ +dojo.lang.mixin(dojo.lang, {has:function (obj, name) { + try { return typeof obj[name] != "undefined"; - }catch(e){ return false; } -} - -dojo.lang.isEmpty = function(/*Object*/obj){ - if(dojo.lang.isObject(obj)){ + } + catch (e) { + return false; + } +}, isEmpty:function (obj) { + if (dojo.lang.isObject(obj)) { var tmp = {}; var count = 0; - for(var x in obj){ - if(obj[x] && (!tmp[x])){ + for (var x in obj) { + if (obj[x] && (!tmp[x])) { count++; break; - } + } } return count == 0; - }else if(dojo.lang.isArrayLike(obj) || dojo.lang.isString(obj)){ - return obj.length == 0; + } else { + if (dojo.lang.isArrayLike(obj) || dojo.lang.isString(obj)) { + return obj.length == 0; + } } -} - -dojo.lang.map = function(/*Array*/arr, /*Object|Function*/obj, /*Function?*/unary_func){ +}, map:function (arr, obj, unary_func) { var isString = dojo.lang.isString(arr); - if(isString){ - // arr: String + if (isString) { arr = arr.split(""); } - if(dojo.lang.isFunction(obj)&&(!unary_func)){ + if (dojo.lang.isFunction(obj) && (!unary_func)) { unary_func = obj; obj = dj_global; - }else if(dojo.lang.isFunction(obj) && unary_func){ - // ff 1.5 compat - var tmpObj = obj; - obj = unary_func; - unary_func = tmpObj; + } else { + if (dojo.lang.isFunction(obj) && unary_func) { + var tmpObj = obj; + obj = unary_func; + unary_func = tmpObj; + } } - if(Array.map){ - var outArr = Array.map(arr, unary_func, obj); - }else{ + if (Array.map) { + var outArr = Array.map(arr, unary_func, obj); + } else { var outArr = []; - for(var i=0;i= 3){ dojo.raise("thisObject doesn't exist!"); } + if (!thisObject) { + if (arguments.length >= 3) { + dojo.raise("thisObject doesn't exist!"); + } thisObject = dj_global; } - outArr = []; - for(var i = 0; i < arr.length; i++){ - if(callback.call(thisObject, arr[i], i, arr)){ + for (var i = 0; i < arr.length; i++) { + if (callback.call(thisObject, arr[i], i, arr)) { outArr.push(arr[i]); } } } - if(isString){ - return outArr.join(""); // String + if (isString) { + return outArr.join(""); } else { - return outArr; // Array + return outArr; } -} - -dojo.lang.unnest = function(/* ... */){ - // summary: - // Creates a 1-D array out of all the arguments passed, - // unravelling any array-like objects in the process - // - // usage: - // unnest(1, 2, 3) ==> [1, 2, 3] - // unnest(1, [2, [3], [[[4]]]]) ==> [1, 2, 3, 4] - +}, unnest:function () { var out = []; - for(var i = 0; i < arguments.length; i++){ - if(dojo.lang.isArrayLike(arguments[i])){ + for (var i = 0; i < arguments.length; i++) { + if (dojo.lang.isArrayLike(arguments[i])) { var add = dojo.lang.unnest.apply(this, arguments[i]); out = out.concat(add); - }else{ + } else { out.push(arguments[i]); } } - return out; // Array -} - -dojo.lang.toArray = function(/*Object*/arrayLike, /*Number*/startOffset){ - // summary: - // Converts an array-like object (i.e. arguments, DOMCollection) - // to an array + return out; +}, toArray:function (arrayLike, startOffset) { var array = []; - for(var i = startOffset||0; i < arrayLike.length; i++){ + for (var i = startOffset || 0; i < arrayLike.length; i++) { array.push(arrayLike[i]); } - return array; // Array -} + return array; +}}); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang/assert.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang/assert.js index 78311dc0c..8a32646d3 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang/assert.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang/assert.js @@ -9,108 +9,49 @@ */ dojo.provide("dojo.lang.assert"); - dojo.require("dojo.lang.common"); dojo.require("dojo.lang.array"); dojo.require("dojo.lang.type"); - -dojo.lang.assert = function(/* boolean */ booleanValue, /* string? */ message){ - /* summary: - * Throws an exception if the assertion fails. - * description: - * If the asserted condition is true, this method does nothing. If the - * condition is false, we throw an error with a error message. - * booleanValue: Must be true for the assertion to succeed. - * message: A string describing the assertion. - */ - - // throws: Throws an Error if 'booleanValue' is false. - if(!booleanValue){ - var errorMessage = "An assert statement failed.\n" + - "The method dojo.lang.assert() was called with a 'false' value.\n"; - if(message){ +dojo.lang.assert = function (booleanValue, message) { + if (!booleanValue) { + var errorMessage = "An assert statement failed.\n" + "The method dojo.lang.assert() was called with a 'false' value.\n"; + if (message) { errorMessage += "Here's the assert message:\n" + message + "\n"; } - // Use throw instead of dojo.raise, until bug #264 is fixed: - // dojo.raise(errorMessage); throw new Error(errorMessage); } -} - -dojo.lang.assertType = function(/* anything */ value, /* misc. */ type, /* object? */ keywordParameters){ - /* summary: - * Throws an exception if 'value' is not of type 'type' - * description: - * Given a value and a data type, this method checks the type of the value - * to make sure it matches the data type, and throws an exception if there - * is a mismatch. - * value: Any literal value or object instance. - * type: A class of object, or a literal type, or the string name of a type, or an array with a list of types. - * keywordParameters: {optional: boolean} - */ - - /* examples: - * dojo.lang.assertType("foo", String); - * dojo.lang.assertType(12345, Number); - * dojo.lang.assertType(false, Boolean); - * dojo.lang.assertType([6, 8], Array); - * dojo.lang.assertType(dojo.lang.assertType, Function); - * dojo.lang.assertType({foo: "bar"}, Object); - * dojo.lang.assertType(new Date(), Date); - * dojo.lang.assertType(null, Array, {optional: true}); - * throws: Throws an Error if 'value' is not of type 'type'. - */ +}; +dojo.lang.assertType = function (value, type, keywordParameters) { if (dojo.lang.isString(keywordParameters)) { - dojo.deprecated('dojo.lang.assertType(value, type, "message")', 'use dojo.lang.assertType(value, type) instead', "0.5"); + dojo.deprecated("dojo.lang.assertType(value, type, \"message\")", "use dojo.lang.assertType(value, type) instead", "0.5"); } - if(!dojo.lang.isOfType(value, type, keywordParameters)){ - if(!dojo.lang.assertType._errorMessage){ + if (!dojo.lang.isOfType(value, type, keywordParameters)) { + if (!dojo.lang.assertType._errorMessage) { dojo.lang.assertType._errorMessage = "Type mismatch: dojo.lang.assertType() failed."; } dojo.lang.assert(false, dojo.lang.assertType._errorMessage); } -} - -dojo.lang.assertValidKeywords = function(/* object */ object, /* array */ expectedProperties, /* string? */ message){ - /* summary: - * Throws an exception 'object' has any properties other than the 'expectedProperties'. - * description: - * Given an anonymous object and a list of expected property names, this - * method check to make sure the object does not have any properties - * that aren't on the list of expected properties, and throws an Error - * if there are unexpected properties. This is useful for doing error - * checking on keyword arguments, to make sure there aren't typos. - * object: An anonymous object. - * expectedProperties: An array of strings (or an object with all the expected properties). - * message: A message describing the assertion. - */ - - /* examples: - * dojo.lang.assertValidKeywords({a: 1, b: 2}, ["a", "b"]); - * dojo.lang.assertValidKeywords({a: 1, b: 2}, ["a", "b", "c"]); - * dojo.lang.assertValidKeywords({foo: "iggy"}, ["foo"]); - * dojo.lang.assertValidKeywords({foo: "iggy"}, ["foo", "bar"]); - * dojo.lang.assertValidKeywords({foo: "iggy"}, {foo: null, bar: null}); - * throws: Throws an Error if 'object' has unexpected properties. - */ +}; +dojo.lang.assertValidKeywords = function (object, expectedProperties, message) { var key; - if(!message){ - if(!dojo.lang.assertValidKeywords._errorMessage){ + if (!message) { + if (!dojo.lang.assertValidKeywords._errorMessage) { dojo.lang.assertValidKeywords._errorMessage = "In dojo.lang.assertValidKeywords(), found invalid keyword:"; } message = dojo.lang.assertValidKeywords._errorMessage; } - if(dojo.lang.isArray(expectedProperties)){ - for(key in object){ - if(!dojo.lang.inArray(expectedProperties, key)){ + if (dojo.lang.isArray(expectedProperties)) { + for (key in object) { + if (!dojo.lang.inArray(expectedProperties, key)) { dojo.lang.assert(false, message + " " + key); } } - }else{ - for(key in object){ - if(!(key in expectedProperties)){ + } else { + for (key in object) { + if (!(key in expectedProperties)) { dojo.lang.assert(false, message + " " + key); } } } -} +}; + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang/common.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang/common.js index a1114751f..d99bd61f2 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang/common.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang/common.js @@ -9,89 +9,54 @@ */ dojo.provide("dojo.lang.common"); - -dojo.lang.inherits = function(/*Function*/ subclass, /*Function*/ superclass){ - // summary: Set up inheritance between two classes. - if(typeof superclass != 'function'){ - dojo.raise("dojo.inherits: superclass argument ["+superclass+"] must be a function (subclass: ["+subclass+"']"); +dojo.lang.inherits = function (subclass, superclass) { + if (!dojo.lang.isFunction(superclass)) { + dojo.raise("dojo.inherits: superclass argument [" + superclass + "] must be a function (subclass: [" + subclass + "']"); } subclass.prototype = new superclass(); subclass.prototype.constructor = subclass; subclass.superclass = superclass.prototype; - // DEPRECATED: super is a reserved word, use 'superclass' - subclass['super'] = superclass.prototype; -} - -dojo.lang._mixin = function(/*Object*/ obj, /*Object*/ props){ - // summary: Adds all properties and methods of props to obj. + subclass["super"] = superclass.prototype; +}; +dojo.lang._mixin = function (obj, props) { var tobj = {}; - for(var x in props){ - // the "tobj" condition avoid copying properties in "props" - // inherited from Object.prototype. For example, if obj has a custom - // toString() method, don't overwrite it with the toString() method - // that props inherited from Object.protoype - if((typeof tobj[x] == "undefined") || (tobj[x] != props[x])){ + for (var x in props) { + if ((typeof tobj[x] == "undefined") || (tobj[x] != props[x])) { obj[x] = props[x]; } } - // IE doesn't recognize custom toStrings in for..in - if(dojo.render.html.ie - && (typeof(props["toString"]) == "function") - && (props["toString"] != obj["toString"]) - && (props["toString"] != tobj["toString"])) - { + if (dojo.render.html.ie && (typeof (props["toString"]) == "function") && (props["toString"] != obj["toString"]) && (props["toString"] != tobj["toString"])) { obj.toString = props.toString; } - return obj; // Object -} - -dojo.lang.mixin = function(/*Object*/ obj, /*Object...*/props){ - // summary: Adds all properties and methods of props to obj. - for(var i=1, l=arguments.length; i -1; // boolean -} - -/** - * Partial implmentation of is* functions from - * http://www.crockford.com/javascript/recommend.html - * NOTE: some of these may not be the best thing to use in all situations - * as they aren't part of core JS and therefore can't work in every case. - * See WARNING messages inline for tips. - * - * The following is* functions are fairly "safe" - */ - -dojo.lang.isObject = function(/*anything*/ it){ - // summary: Return true if it is an Object, Array or Function. - if(typeof it == "undefined"){ return false; } - return (typeof it == "object" || it === null || dojo.lang.isArray(it) || dojo.lang.isFunction(it)); // Boolean -} - -dojo.lang.isArray = function(/*anything*/ it){ - // summary: Return true if it is an Array. - return (it && it instanceof Array || typeof it == "array"); // Boolean -} - -dojo.lang.isArrayLike = function(/*anything*/ it){ - // summary: Return true if it can be used as an array (i.e. is an object with an integer length property). - if((!it)||(dojo.lang.isUndefined(it))){ return false; } - if(dojo.lang.isString(it)){ return false; } - if(dojo.lang.isFunction(it)){ return false; } // keeps out built-in constructors (Number, String, ...) which have length properties - if(dojo.lang.isArray(it)){ return true; } - // form node itself is ArrayLike, but not always iterable. Use form.elements instead. - if((it.tagName)&&(it.tagName.toLowerCase()=='form')){ return false; } - if(dojo.lang.isNumber(it.length) && isFinite(it.length)){ return true; } - return false; // Boolean -} - -dojo.lang.isFunction = function(/*anything*/ it){ - // summary: Return true if it is a Function. - if(!it){ return false; } - // webkit treats NodeList as a function, which is bad - if((typeof(it) == "function") && (it == "[object NodeList]")) { return false; } - return (it instanceof Function || typeof it == "function"); // Boolean -} - -dojo.lang.isString = function(/*anything*/ it){ - // summary: Return true if it is a String. +dojo.lang.inArray = function (array, value) { + return dojo.lang.find(array, value) > -1; +}; +dojo.lang.isObject = function (it) { + if (typeof it == "undefined") { + return false; + } + return (typeof it == "object" || it === null || dojo.lang.isArray(it) || dojo.lang.isFunction(it)); +}; +dojo.lang.isArray = function (it) { + return (it && it instanceof Array || typeof it == "array"); +}; +dojo.lang.isArrayLike = function (it) { + if ((!it) || (dojo.lang.isUndefined(it))) { + return false; + } + if (dojo.lang.isString(it)) { + return false; + } + if (dojo.lang.isFunction(it)) { + return false; + } + if (dojo.lang.isArray(it)) { + return true; + } + if ((it.tagName) && (it.tagName.toLowerCase() == "form")) { + return false; + } + if (dojo.lang.isNumber(it.length) && isFinite(it.length)) { + return true; + } + return false; +}; +dojo.lang.isFunction = function (it) { + return (it instanceof Function || typeof it == "function"); +}; +(function () { + if ((dojo.render.html.capable) && (dojo.render.html["safari"])) { + dojo.lang.isFunction = function (it) { + if ((typeof (it) == "function") && (it == "[object NodeList]")) { + return false; + } + return (it instanceof Function || typeof it == "function"); + }; + } +})(); +dojo.lang.isString = function (it) { return (typeof it == "string" || it instanceof String); -} +}; +dojo.lang.isAlien = function (it) { + if (!it) { + return false; + } + return !dojo.lang.isFunction(it) && /\{\s*\[native code\]\s*\}/.test(String(it)); +}; +dojo.lang.isBoolean = function (it) { + return (it instanceof Boolean || typeof it == "boolean"); +}; +dojo.lang.isNumber = function (it) { + return (it instanceof Number || typeof it == "number"); +}; +dojo.lang.isUndefined = function (it) { + return ((typeof (it) == "undefined") && (it == undefined)); +}; -dojo.lang.isAlien = function(/*anything*/ it){ - // summary: Return true if it is not a built-in function. - if(!it){ return false; } - return !dojo.lang.isFunction() && /\{\s*\[native code\]\s*\}/.test(String(it)); // Boolean -} - -dojo.lang.isBoolean = function(/*anything*/ it){ - // summary: Return true if it is a Boolean. - return (it instanceof Boolean || typeof it == "boolean"); // Boolean -} - -/** - * The following is***() functions are somewhat "unsafe". Fortunately, - * there are workarounds the the language provides and are mentioned - * in the WARNING messages. - * - */ -dojo.lang.isNumber = function(/*anything*/ it){ - // summary: Return true if it is a number. - // description: - // WARNING - In most cases, isNaN(it) is sufficient to determine whether or not - // something is a number or can be used as such. For example, a number or string - // can be used interchangably when accessing array items (array["1"] is the same as - // array[1]) and isNaN will return false for both values ("1" and 1). However, - // isNumber("1") will return false, which is generally not too useful. - // Also, isNumber(NaN) returns true, again, this isn't generally useful, but there - // are corner cases (like when you want to make sure that two things are really - // the same type of thing). That is really where isNumber "shines". - // - // Recommendation - Use isNaN(it) when possible - - return (it instanceof Number || typeof it == "number"); // Boolean -} - -/* - * FIXME: Should isUndefined go away since it is error prone? - */ -dojo.lang.isUndefined = function(/*anything*/ it){ - // summary: Return true if it is not defined. - // description: - // WARNING - In some cases, isUndefined will not behave as you - // might expect. If you do isUndefined(foo) and there is no earlier - // reference to foo, an error will be thrown before isUndefined is - // called. It behaves correctly if you scope yor object first, i.e. - // isUndefined(foo.bar) where foo is an object and bar isn't a - // property of the object. - // - // Recommendation - Use typeof foo == "undefined" when possible - - return ((typeof(it) == "undefined")&&(it == undefined)); // Boolean -} - -// end Crockford functions diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang/declare.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang/declare.js index 3f5eade9e..7b3af5294 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang/declare.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang/declare.js @@ -9,153 +9,99 @@ */ dojo.provide("dojo.lang.declare"); - dojo.require("dojo.lang.common"); dojo.require("dojo.lang.extras"); - -dojo.lang.declare = function(/*String*/ className, /*Function|Array*/ superclass, /*Function?*/ init, /*Object|Array*/ props){ -/* - * summary: Create a feature-rich constructor with a compact notation - * - * className: the name of the constructor (loosely, a "class") - * - * superclass: may be a Function, or an Array of Functions. - * If "superclass" is an array, the first element is used - * as the prototypical ancestor and any following Functions - * become mixin ancestors. - * - * init: an initializer function - * - * props: an object (or array of objects) whose properties are copied to the created prototype - * - * description: Create a constructor using a compact notation for inheritance and prototype extension. - * - * "superclass" argument may be a Function, or an array of - * Functions. - * - * If "superclass" is an array, the first element is used - * as the prototypical ancestor and any following Functions - * become mixin ancestors. - * - * All "superclass(es)" must be Functions (not mere Objects). - * - * Using mixin ancestors provides a type of multiple - * inheritance. Mixin ancestors prototypical - * properties are copied to the subclass, and any - * inializater/constructor is invoked. - * - * Properties of object "props" are copied to the constructor - * prototype. If "props" is an array, properties of each - * object in the array are copied to the constructor prototype. - * - * name of the class ("className" argument) is stored in - * "declaredClass" property - * - * Initializer functions are called when an object - * is instantiated from this constructor. - * - * Aliased as "dojo.declare" - * - * Usage: - * - * dojo.declare("my.classes.bar", my.classes.foo, - * function() { - * // initialization function - * this.myComplicatedObject = new ReallyComplicatedObject(); - * },{ - * someValue: 2, - * someMethod: function() { - * doStuff(); - * } - * }); - * - */ - if((dojo.lang.isFunction(props))||((!props)&&(!dojo.lang.isFunction(init)))){ - // parameter juggling to support omitting init param (also allows reordering init and props arguments) +dojo.lang.declare = function (className, superclass, init, props) { + if ((dojo.lang.isFunction(props)) || ((!props) && (!dojo.lang.isFunction(init)))) { var temp = props; props = init; init = temp; - } - var mixins = [ ]; - if(dojo.lang.isArray(superclass)){ + } + var mixins = []; + if (dojo.lang.isArray(superclass)) { mixins = superclass; superclass = mixins.shift(); } - if(!init){ + if (!init) { init = dojo.evalObjPath(className, false); - if((init)&&(!dojo.lang.isFunction(init))){ init = null }; + if ((init) && (!dojo.lang.isFunction(init))) { + init = null; + } } var ctor = dojo.lang.declare._makeConstructor(); var scp = (superclass ? superclass.prototype : null); - if(scp){ + if (scp) { scp.prototyping = true; ctor.prototype = new superclass(); - scp.prototyping = false; + scp.prototyping = false; } ctor.superclass = scp; ctor.mixins = mixins; - for(var i=0,l=mixins.length; i 0){ + while (typeof (obj) == "undefined" && queue.length > 0) { obj = queue.shift(); } - - // check to see if the input function needs to be fired - // stop before firing the output function - // TODO: relegate this to the output function? - if(typeof(obj) == "undefined"){ + if (typeof (obj) == "undefined") { self.stop(); return; } - - // call the output function. self.outputFunction(obj); }; - - this.setInterval = function(/* int */ms){ - // summary - // sets the interval in milliseconds of the internal timer + this.setInterval = function (ms) { this.interval = ms; timer.setInterval(ms); }; - - this.onTick = function(/* dojo.lang.timing.Streamer */obj){ }; - // wrap the timer functions so that we can connect to them if needed. - this.start = function(){ - // summary - // starts the Streamer - if(typeof(this.inputFunction) == "function" && typeof(this.outputFunction) == "function"){ + this.onTick = function (obj) { + }; + this.start = function () { + if (typeof (this.inputFunction) == "function" && typeof (this.outputFunction) == "function") { timer.start(); return; } dojo.raise("You cannot start a Streamer without an input and an output function."); }; - this.onStart = function(){ }; - this.stop = function(){ - // summary - // stops the Streamer + this.onStart = function () { + }; + this.stop = function () { timer.stop(); }; - this.onStop = function(){ }; - - // finish initialization + this.onStop = function () { + }; timer.onTick = this.tick; timer.onStart = this.onStart; timer.onStop = this.onStop; - if(initialData){ + if (initialData) { queue.concat(initialData); } }; + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang/timing/Timer.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang/timing/Timer.js index 888e40381..084a8bd12 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang/timing/Timer.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang/timing/Timer.js @@ -10,55 +10,33 @@ dojo.provide("dojo.lang.timing.Timer"); dojo.require("dojo.lang.func"); - -dojo.lang.timing.Timer = function(/*int*/ interval){ - // summary: Timer object executes an "onTick()" method repeatedly at a specified interval. - // repeatedly at a given interval. - // interval: Interval between function calls, in milliseconds. +dojo.lang.timing.Timer = function (interval) { this.timer = null; this.isRunning = false; this.interval = interval; - this.onStart = null; this.onStop = null; }; - -dojo.extend(dojo.lang.timing.Timer, { - onTick : function(){ - // summary: Method called every time the interval passes. Override to do something useful. - }, - - setInterval : function(interval){ - // summary: Reset the interval of a timer, whether running or not. - // interval: New interval, in milliseconds. - if (this.isRunning){ - dj_global.clearInterval(this.timer); - } - this.interval = interval; - if (this.isRunning){ - this.timer = dj_global.setInterval(dojo.lang.hitch(this, "onTick"), this.interval); - } - }, - - start : function(){ - // summary: Start the timer ticking. - // description: Calls the "onStart()" handler, if defined. - // Note that the onTick() function is not called right away, - // only after first interval passes. - if (typeof this.onStart == "function"){ - this.onStart(); - } - this.isRunning = true; - this.timer = dj_global.setInterval(dojo.lang.hitch(this, "onTick"), this.interval); - }, - - stop : function(){ - // summary: Stop the timer. - // description: Calls the "onStop()" handler, if defined. - if (typeof this.onStop == "function"){ - this.onStop(); - } - this.isRunning = false; +dojo.extend(dojo.lang.timing.Timer, {onTick:function () { +}, setInterval:function (interval) { + if (this.isRunning) { dj_global.clearInterval(this.timer); } -}); + this.interval = interval; + if (this.isRunning) { + this.timer = dj_global.setInterval(dojo.lang.hitch(this, "onTick"), this.interval); + } +}, start:function () { + if (typeof this.onStart == "function") { + this.onStart(); + } + this.isRunning = true; + this.timer = dj_global.setInterval(dojo.lang.hitch(this, "onTick"), this.interval); +}, stop:function () { + if (typeof this.onStop == "function") { + this.onStop(); + } + this.isRunning = false; + dj_global.clearInterval(this.timer); +}}); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang/timing/__package__.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang/timing/__package__.js index cbfeb7e4e..314ee7c72 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang/timing/__package__.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang/timing/__package__.js @@ -9,3 +9,4 @@ */ dojo.provide("dojo.lang.timing.*"); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang/type.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang/type.js index bd3110d0f..b7d91a780 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang/type.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lang/type.js @@ -10,242 +10,134 @@ dojo.provide("dojo.lang.type"); dojo.require("dojo.lang.common"); - -dojo.lang.whatAmI = function(value) { +dojo.lang.whatAmI = function (value) { dojo.deprecated("dojo.lang.whatAmI", "use dojo.lang.getType instead", "0.5"); return dojo.lang.getType(value); -} +}; dojo.lang.whatAmI.custom = {}; - -dojo.lang.getType = function(/* anything */ value){ - /* summary: - * Attempts to determine what type value is. - * value: Any literal value or object instance. - */ +dojo.lang.getType = function (value) { try { - if(dojo.lang.isArray(value)) { - return "array"; // string + if (dojo.lang.isArray(value)) { + return "array"; } - if(dojo.lang.isFunction(value)) { - return "function"; // string + if (dojo.lang.isFunction(value)) { + return "function"; } - if(dojo.lang.isString(value)) { - return "string"; // string + if (dojo.lang.isString(value)) { + return "string"; } - if(dojo.lang.isNumber(value)) { - return "number"; // string + if (dojo.lang.isNumber(value)) { + return "number"; } - if(dojo.lang.isBoolean(value)) { - return "boolean"; // string + if (dojo.lang.isBoolean(value)) { + return "boolean"; } - if(dojo.lang.isAlien(value)) { - return "alien"; // string + if (dojo.lang.isAlien(value)) { + return "alien"; } - if(dojo.lang.isUndefined(value)) { - return "undefined"; // string + if (dojo.lang.isUndefined(value)) { + return "undefined"; } - // FIXME: should this go first? - for(var name in dojo.lang.whatAmI.custom) { - if(dojo.lang.whatAmI.custom[name](value)) { - return name; // string + for (var name in dojo.lang.whatAmI.custom) { + if (dojo.lang.whatAmI.custom[name](value)) { + return name; } } - if(dojo.lang.isObject(value)) { - return "object"; // string + if (dojo.lang.isObject(value)) { + return "object"; } - } catch(e) {} - return "unknown"; // string -} - -dojo.lang.isNumeric = function(/* anything */ value){ - /* summary: - * Returns true if value can be interpreted as a number - * value: Any literal value or object instance. - */ - - /* examples: - * dojo.lang.isNumeric(3); // returns true - * dojo.lang.isNumeric("3"); // returns true - * dojo.lang.isNumeric(new Number(3)); // returns true - * dojo.lang.isNumeric(new String("3")); // returns true - * - * dojo.lang.isNumeric(3/0); // returns false - * dojo.lang.isNumeric("foo"); // returns false - * dojo.lang.isNumeric(new Number("foo")); // returns false - * dojo.lang.isNumeric(false); // returns false - * dojo.lang.isNumeric(true); // returns false - */ - return (!isNaN(value) - && isFinite(value) - && (value != null) - && !dojo.lang.isBoolean(value) - && !dojo.lang.isArray(value) - && !/^\s*$/.test(value) - ); // boolean -} - -dojo.lang.isBuiltIn = function(/* anything */ value){ - /* summary: - * Returns true if value is of a type provided by core JavaScript - * description: - * Returns true for any literal, and for any object that is an - * instance of a built-in type like String, Number, Boolean, - * Array, Function, or Error. - * value: Any literal value or object instance. - */ - return (dojo.lang.isArray(value) - || dojo.lang.isFunction(value) - || dojo.lang.isString(value) - || dojo.lang.isNumber(value) - || dojo.lang.isBoolean(value) - || (value == null) - || (value instanceof Error) - || (typeof value == "error") - ); // boolean -} - -dojo.lang.isPureObject = function(/* anything */ value){ - /* summary: - * Returns true for any value where the value of value.constructor == Object - * description: - * Returns true for any literal, and for any object that is an - * instance of a built-in type like String, Number, Boolean, - * Array, Function, or Error. - * value: Any literal value or object instance. - */ - - /* examples: - * dojo.lang.isPureObject(new Object()); // returns true - * dojo.lang.isPureObject({a: 1, b: 2}); // returns true - * - * dojo.lang.isPureObject(new Date()); // returns false - * dojo.lang.isPureObject([11, 2, 3]); // returns false - */ - return ((value != null) - && dojo.lang.isObject(value) - && value.constructor == Object - ); // boolean -} - -dojo.lang.isOfType = function(/* anything */ value, /* function */ type, /* object? */ keywordParameters) { - /* summary: - * Returns true if 'value' is of type 'type' - * description: - * Given a value and a datatype, this method returns true if the - * type of the value matches the datatype. The datatype parameter - * can be an array of datatypes, in which case the method returns - * true if the type of the value matches any of the datatypes. - * value: Any literal value or object instance. - * type: A class of object, or a literal type, or the string name of a type, or an array with a list of types. - * keywordParameters: {optional: boolean} - */ - - /* examples: - * dojo.lang.isOfType("foo", String); // returns true - * dojo.lang.isOfType(12345, Number); // returns true - * dojo.lang.isOfType(false, Boolean); // returns true - * dojo.lang.isOfType([6, 8], Array); // returns true - * dojo.lang.isOfType(dojo.lang.isOfType, Function); // returns true - * dojo.lang.isOfType({foo: "bar"}, Object); // returns true - * dojo.lang.isOfType(new Date(), Date); // returns true - * - * dojo.lang.isOfType("foo", "string"); // returns true - * dojo.lang.isOfType(12345, "number"); // returns true - * dojo.lang.isOfType(false, "boolean"); // returns true - * dojo.lang.isOfType([6, 8], "array"); // returns true - * dojo.lang.isOfType(dojo.lang.isOfType, "function"); // returns true - * dojo.lang.isOfType({foo: "bar"}, "object"); // returns true - * dojo.lang.isOfType(xxxxx, "undefined"); // returns true - * dojo.lang.isOfType(null, "null"); // returns true - * - * dojo.lang.isOfType("foo", [Number, String, Boolean]); // returns true - * dojo.lang.isOfType(12345, [Number, String, Boolean]); // returns true - * dojo.lang.isOfType(false, [Number, String, Boolean]); // returns true - * - * dojo.lang.isOfType(null, Date, {optional: true} ); // returns true // description: - */ + } + catch (e) { + } + return "unknown"; +}; +dojo.lang.isNumeric = function (value) { + return (!isNaN(value) && isFinite(value) && (value != null) && !dojo.lang.isBoolean(value) && !dojo.lang.isArray(value) && !/^\s*$/.test(value)); +}; +dojo.lang.isBuiltIn = function (value) { + return (dojo.lang.isArray(value) || dojo.lang.isFunction(value) || dojo.lang.isString(value) || dojo.lang.isNumber(value) || dojo.lang.isBoolean(value) || (value == null) || (value instanceof Error) || (typeof value == "error")); +}; +dojo.lang.isPureObject = function (value) { + return ((value != null) && dojo.lang.isObject(value) && value.constructor == Object); +}; +dojo.lang.isOfType = function (value, type, keywordParameters) { var optional = false; if (keywordParameters) { optional = keywordParameters["optional"]; } if (optional && ((value === null) || dojo.lang.isUndefined(value))) { - return true; // boolean + return true; } - if(dojo.lang.isArray(type)){ + if (dojo.lang.isArray(type)) { var arrayOfTypes = type; - for(var i in arrayOfTypes){ + for (var i in arrayOfTypes) { var aType = arrayOfTypes[i]; - if(dojo.lang.isOfType(value, aType)) { - return true; // boolean + if (dojo.lang.isOfType(value, aType)) { + return true; } } - return false; // boolean - }else{ - if(dojo.lang.isString(type)){ + return false; + } else { + if (dojo.lang.isString(type)) { type = type.toLowerCase(); } switch (type) { - case Array: - case "array": - return dojo.lang.isArray(value); // boolean - case Function: - case "function": - return dojo.lang.isFunction(value); // boolean - case String: - case "string": - return dojo.lang.isString(value); // boolean - case Number: - case "number": - return dojo.lang.isNumber(value); // boolean - case "numeric": - return dojo.lang.isNumeric(value); // boolean - case Boolean: - case "boolean": - return dojo.lang.isBoolean(value); // boolean - case Object: - case "object": - return dojo.lang.isObject(value); // boolean - case "pureobject": - return dojo.lang.isPureObject(value); // boolean - case "builtin": - return dojo.lang.isBuiltIn(value); // boolean - case "alien": - return dojo.lang.isAlien(value); // boolean - case "undefined": - return dojo.lang.isUndefined(value); // boolean - case null: - case "null": - return (value === null); // boolean - case "optional": - dojo.deprecated('dojo.lang.isOfType(value, [type, "optional"])', 'use dojo.lang.isOfType(value, type, {optional: true} ) instead', "0.5"); - return ((value === null) || dojo.lang.isUndefined(value)); // boolean - default: - if (dojo.lang.isFunction(type)) { - return (value instanceof type); // boolean - } else { - dojo.raise("dojo.lang.isOfType() was passed an invalid type"); - } + case Array: + case "array": + return dojo.lang.isArray(value); + case Function: + case "function": + return dojo.lang.isFunction(value); + case String: + case "string": + return dojo.lang.isString(value); + case Number: + case "number": + return dojo.lang.isNumber(value); + case "numeric": + return dojo.lang.isNumeric(value); + case Boolean: + case "boolean": + return dojo.lang.isBoolean(value); + case Object: + case "object": + return dojo.lang.isObject(value); + case "pureobject": + return dojo.lang.isPureObject(value); + case "builtin": + return dojo.lang.isBuiltIn(value); + case "alien": + return dojo.lang.isAlien(value); + case "undefined": + return dojo.lang.isUndefined(value); + case null: + case "null": + return (value === null); + case "optional": + dojo.deprecated("dojo.lang.isOfType(value, [type, \"optional\"])", "use dojo.lang.isOfType(value, type, {optional: true} ) instead", "0.5"); + return ((value === null) || dojo.lang.isUndefined(value)); + default: + if (dojo.lang.isFunction(type)) { + return (value instanceof type); + } else { + dojo.raise("dojo.lang.isOfType() was passed an invalid type"); + } } } dojo.raise("If we get here, it means a bug was introduced above."); -} +}; +dojo.lang.getObject = function (str) { + var parts = str.split("."), i = 0, obj = dj_global; + do { + obj = obj[parts[i++]]; + } while (i < parts.length && obj); + return (obj != dj_global) ? obj : null; +}; +dojo.lang.doesObjectExist = function (str) { + var parts = str.split("."), i = 0, obj = dj_global; + do { + obj = obj[parts[i++]]; + } while (i < parts.length && obj); + return (obj && obj != dj_global); +}; -dojo.lang.getObject=function(/* String */ str){ - // summary: - // Will return an object, if it exists, based on the name in the passed string. - var parts=str.split("."), i=0, obj=dj_global; - do{ - obj=obj[parts[i++]]; - }while(i 0){ this.duration = duration; } - if(repeatCount){ this.repeatCount = repeatCount; } - if(rate){ this.rate = rate; } - if(handlers){ - dojo.lang.forEach([ - "handler", "beforeBegin", "onBegin", - "onEnd", "onPlay", "onStop", "onAnimate" - ], function(item){ - if(handlers[item]){ - this.connect(item, handlers[item]); - } - }, this); + if (duration != null && duration > 0) { + this.duration = duration; } - if(easing && dojo.lang.isFunction(easing)){ - this.easing=easing; + if (repeatCount) { + this.repeatCount = repeatCount; } -} -dojo.inherits(dojo.lfx.Animation, dojo.lfx.IAnimation); -dojo.lang.extend(dojo.lfx.Animation, { - // "private" properties - _startTime: null, - _endTime: null, - _timer: null, - _percent: 0, - _startRepeatCount: 0, - - // public methods - play: function(/*int?*/ delay, /*bool?*/ gotoStart){ - // summary: Start the animation. - // delay: How many milliseconds to delay before starting. - // gotoStart: If true, starts the animation from the beginning; otherwise, - // starts it from its current position. - if(gotoStart){ - clearTimeout(this._timer); - this._active = false; - this._paused = false; - this._percent = 0; - }else if(this._active && !this._paused){ - return this; // dojo.lfx.Animation - } - - this.fire("handler", ["beforeBegin"]); - this.fire("beforeBegin"); - - if(delay > 0){ - setTimeout(dojo.lang.hitch(this, function(){ this.play(null, gotoStart); }), delay); - return this; // dojo.lfx.Animation - } - - this._startTime = new Date().valueOf(); - if(this._paused){ - this._startTime -= (this.duration * this._percent / 100); - } - this._endTime = this._startTime + this.duration; - - this._active = true; - this._paused = false; - - var step = this._percent / 100; - var value = this.curve.getValue(step); - if(this._percent == 0 ){ - if(!this._startRepeatCount){ - this._startRepeatCount = this.repeatCount; + if (rate) { + this.rate = rate; + } + if (handlers) { + dojo.lang.forEach(["handler", "beforeBegin", "onBegin", "onEnd", "onPlay", "onStop", "onAnimate"], function (item) { + if (handlers[item]) { + this.connect(item, handlers[item]); } - this.fire("handler", ["begin", value]); - this.fire("onBegin", [value]); - } - - this.fire("handler", ["play", value]); - this.fire("onPlay", [value]); - - this._cycle(); - return this; // dojo.lfx.Animation - }, - - pause: function(){ - // summary: Pauses a running animation. + }, this); + } + if (easing && dojo.lang.isFunction(easing)) { + this.easing = easing; + } +}; +dojo.inherits(dojo.lfx.Animation, dojo.lfx.IAnimation); +dojo.lang.extend(dojo.lfx.Animation, {_startTime:null, _endTime:null, _timer:null, _percent:0, _startRepeatCount:0, play:function (delay, gotoStart) { + if (gotoStart) { clearTimeout(this._timer); - if(!this._active){ return this; /*dojo.lfx.Animation*/} - this._paused = true; - var value = this.curve.getValue(this._percent / 100); - this.fire("handler", ["pause", value]); - this.fire("onPause", [value]); - return this; // dojo.lfx.Animation - }, - - gotoPercent: function(/*Decimal*/ pct, /*bool?*/ andPlay){ - // summary: Sets the progress of the animation. - // pct: A percentage in decimal notation (between and including 0.0 and 1.0). - // andPlay: If true, play the animation after setting the progress. - clearTimeout(this._timer); - this._active = true; - this._paused = true; - this._percent = pct; - if(andPlay){ this.play(); } - return this; // dojo.lfx.Animation - }, - - stop: function(/*bool?*/ gotoEnd){ - // summary: Stops a running animation. - // gotoEnd: If true, the animation will end. - clearTimeout(this._timer); - var step = this._percent / 100; - if(gotoEnd){ - step = 1; - } - var value = this.curve.getValue(step); - this.fire("handler", ["stop", value]); - this.fire("onStop", [value]); this._active = false; this._paused = false; - return this; // dojo.lfx.Animation - }, - - status: function(){ - // summary: Returns a string representation of the status of - // the animation. - if(this._active){ - return this._paused ? "paused" : "playing"; // String - }else{ - return "stopped"; // String + this._percent = 0; + } else { + if (this._active && !this._paused) { + return this; } + } + this.fire("handler", ["beforeBegin"]); + this.fire("beforeBegin"); + if (delay > 0) { + setTimeout(dojo.lang.hitch(this, function () { + this.play(null, gotoStart); + }), delay); return this; - }, - - // "private" methods - _cycle: function(){ - clearTimeout(this._timer); - if(this._active){ - var curr = new Date().valueOf(); - var step = (curr - this._startTime) / (this._endTime - this._startTime); - - if(step >= 1){ - step = 1; - this._percent = 100; - }else{ - this._percent = step * 100; - } - - // Perform easing - if((this.easing)&&(dojo.lang.isFunction(this.easing))){ - step = this.easing(step); - } - - var value = this.curve.getValue(step); - this.fire("handler", ["animate", value]); - this.fire("onAnimate", [value]); - - if( step < 1 ){ - this._timer = setTimeout(dojo.lang.hitch(this, "_cycle"), this.rate); - }else{ - this._active = false; - this.fire("handler", ["end"]); - this.fire("onEnd"); - - if(this.repeatCount > 0){ - this.repeatCount--; + } + this._startTime = new Date().valueOf(); + if (this._paused) { + this._startTime -= (this.duration * this._percent / 100); + } + this._endTime = this._startTime + this.duration; + this._active = true; + this._paused = false; + var step = this._percent / 100; + var value = this.curve.getValue(step); + if (this._percent == 0) { + if (!this._startRepeatCount) { + this._startRepeatCount = this.repeatCount; + } + this.fire("handler", ["begin", value]); + this.fire("onBegin", [value]); + } + this.fire("handler", ["play", value]); + this.fire("onPlay", [value]); + this._cycle(); + return this; +}, pause:function () { + clearTimeout(this._timer); + if (!this._active) { + return this; + } + this._paused = true; + var value = this.curve.getValue(this._percent / 100); + this.fire("handler", ["pause", value]); + this.fire("onPause", [value]); + return this; +}, gotoPercent:function (pct, andPlay) { + clearTimeout(this._timer); + this._active = true; + this._paused = true; + this._percent = pct; + if (andPlay) { + this.play(); + } + return this; +}, stop:function (gotoEnd) { + clearTimeout(this._timer); + var step = this._percent / 100; + if (gotoEnd) { + step = 1; + } + var value = this.curve.getValue(step); + this.fire("handler", ["stop", value]); + this.fire("onStop", [value]); + this._active = false; + this._paused = false; + return this; +}, status:function () { + if (this._active) { + return this._paused ? "paused" : "playing"; + } else { + return "stopped"; + } + return this; +}, _cycle:function () { + clearTimeout(this._timer); + if (this._active) { + var curr = new Date().valueOf(); + var step = (curr - this._startTime) / (this._endTime - this._startTime); + if (step >= 1) { + step = 1; + this._percent = 100; + } else { + this._percent = step * 100; + } + if ((this.easing) && (dojo.lang.isFunction(this.easing))) { + step = this.easing(step); + } + var value = this.curve.getValue(step); + this.fire("handler", ["animate", value]); + this.fire("onAnimate", [value]); + if (step < 1) { + this._timer = setTimeout(dojo.lang.hitch(this, "_cycle"), this.rate); + } else { + this._active = false; + this.fire("handler", ["end"]); + this.fire("onEnd"); + if (this.repeatCount > 0) { + this.repeatCount--; + this.play(null, true); + } else { + if (this.repeatCount == -1) { this.play(null, true); - }else if(this.repeatCount == -1){ - this.play(null, true); - }else{ - if(this._startRepeatCount){ + } else { + if (this._startRepeatCount) { this.repeatCount = this._startRepeatCount; this._startRepeatCount = 0; } } } } - return this; // dojo.lfx.Animation } -}); - -dojo.lfx.Combine = function(/*dojo.lfx.IAnimation...*/ animations){ - // summary: An animation object to play animations passed to it at the same time. + return this; +}}); +dojo.lfx.Combine = function (animations) { dojo.lfx.IAnimation.call(this); this._anims = []; this._animsEnded = 0; - var anims = arguments; - if(anims.length == 1 && (dojo.lang.isArray(anims[0]) || dojo.lang.isArrayLike(anims[0]))){ - /* animations: dojo.lfx.IAnimation[] - pId: a */ + if (anims.length == 1 && (dojo.lang.isArray(anims[0]) || dojo.lang.isArrayLike(anims[0]))) { anims = anims[0]; } - - dojo.lang.forEach(anims, function(anim){ + dojo.lang.forEach(anims, function (anim) { this._anims.push(anim); anim.connect("onEnd", dojo.lang.hitch(this, "_onAnimsEnded")); }, this); -} +}; dojo.inherits(dojo.lfx.Combine, dojo.lfx.IAnimation); -dojo.lang.extend(dojo.lfx.Combine, { - // private members - _animsEnded: 0, - - // public methods - play: function(/*int?*/ delay, /*bool?*/ gotoStart){ - // summary: Start the animations. - // delay: How many milliseconds to delay before starting. - // gotoStart: If true, starts the animations from the beginning; otherwise, - // starts them from their current position. - if( !this._anims.length ){ return this; /*dojo.lfx.Combine*/} - - this.fire("beforeBegin"); - - if(delay > 0){ - setTimeout(dojo.lang.hitch(this, function(){ this.play(null, gotoStart); }), delay); - return this; // dojo.lfx.Combine - } - - if(gotoStart || this._anims[0].percent == 0){ - this.fire("onBegin"); - } - this.fire("onPlay"); - this._animsCall("play", null, gotoStart); - return this; // dojo.lfx.Combine - }, - - pause: function(){ - // summary: Pauses the running animations. - this.fire("onPause"); - this._animsCall("pause"); - return this; // dojo.lfx.Combine - }, - - stop: function(/*bool?*/ gotoEnd){ - // summary: Stops the running animations. - // gotoEnd: If true, the animations will end. - this.fire("onStop"); - this._animsCall("stop", gotoEnd); - return this; // dojo.lfx.Combine - }, - - // private methods - _onAnimsEnded: function(){ - this._animsEnded++; - if(this._animsEnded >= this._anims.length){ - this.fire("onEnd"); - } - return this; // dojo.lfx.Combine - }, - - _animsCall: function(/*String*/ funcName){ - var args = []; - if(arguments.length > 1){ - for(var i = 1 ; i < arguments.length ; i++){ - args.push(arguments[i]); - } - } - var _this = this; - dojo.lang.forEach(this._anims, function(anim){ - anim[funcName](args); - }, _this); - return this; // dojo.lfx.Combine +dojo.lang.extend(dojo.lfx.Combine, {_animsEnded:0, play:function (delay, gotoStart) { + if (!this._anims.length) { + return this; } -}); - -dojo.lfx.Chain = function(/*dojo.lfx.IAnimation...*/ animations) { - // summary: An animation object to play animations passed to it - // one after another. + this.fire("beforeBegin"); + if (delay > 0) { + setTimeout(dojo.lang.hitch(this, function () { + this.play(null, gotoStart); + }), delay); + return this; + } + if (gotoStart || this._anims[0].percent == 0) { + this.fire("onBegin"); + } + this.fire("onPlay"); + this._animsCall("play", null, gotoStart); + return this; +}, pause:function () { + this.fire("onPause"); + this._animsCall("pause"); + return this; +}, stop:function (gotoEnd) { + this.fire("onStop"); + this._animsCall("stop", gotoEnd); + return this; +}, _onAnimsEnded:function () { + this._animsEnded++; + if (this._animsEnded >= this._anims.length) { + this.fire("onEnd"); + } + return this; +}, _animsCall:function (funcName) { + var args = []; + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args.push(arguments[i]); + } + } + var _this = this; + dojo.lang.forEach(this._anims, function (anim) { + anim[funcName](args); + }, _this); + return this; +}}); +dojo.lfx.Chain = function (animations) { dojo.lfx.IAnimation.call(this); this._anims = []; this._currAnim = -1; - var anims = arguments; - if(anims.length == 1 && (dojo.lang.isArray(anims[0]) || dojo.lang.isArrayLike(anims[0]))){ - /* animations: dojo.lfx.IAnimation[] - pId: a */ + if (anims.length == 1 && (dojo.lang.isArray(anims[0]) || dojo.lang.isArrayLike(anims[0]))) { anims = anims[0]; } - var _this = this; - dojo.lang.forEach(anims, function(anim, i, anims_arr){ + dojo.lang.forEach(anims, function (anim, i, anims_arr) { this._anims.push(anim); - if(i < anims_arr.length - 1){ - anim.connect("onEnd", dojo.lang.hitch(this, "_playNext") ); - }else{ - anim.connect("onEnd", dojo.lang.hitch(this, function(){ this.fire("onEnd"); }) ); + if (i < anims_arr.length - 1) { + anim.connect("onEnd", dojo.lang.hitch(this, "_playNext")); + } else { + anim.connect("onEnd", dojo.lang.hitch(this, function () { + this.fire("onEnd"); + })); } }, this); -} +}; dojo.inherits(dojo.lfx.Chain, dojo.lfx.IAnimation); -dojo.lang.extend(dojo.lfx.Chain, { - // private members - _currAnim: -1, - - // public methods - play: function(/*int?*/ delay, /*bool?*/ gotoStart){ - // summary: Start the animation sequence. - // delay: How many milliseconds to delay before starting. - // gotoStart: If true, starts the sequence from the beginning; otherwise, - // starts it from its current position. - if( !this._anims.length ) { return this; /*dojo.lfx.Chain*/} - if( gotoStart || !this._anims[this._currAnim] ) { - this._currAnim = 0; - } - - var currentAnimation = this._anims[this._currAnim]; - - this.fire("beforeBegin"); - if(delay > 0){ - setTimeout(dojo.lang.hitch(this, function(){ this.play(null, gotoStart); }), delay); - return this; // dojo.lfx.Chain - } - - if(currentAnimation){ - if(this._currAnim == 0){ - this.fire("handler", ["begin", this._currAnim]); - this.fire("onBegin", [this._currAnim]); - } - this.fire("onPlay", [this._currAnim]); - currentAnimation.play(null, gotoStart); - } - return this; // dojo.lfx.Chain - }, - - pause: function(){ - // summary: Pauses the running animation sequence. - if( this._anims[this._currAnim] ) { - this._anims[this._currAnim].pause(); - this.fire("onPause", [this._currAnim]); - } - return this; // dojo.lfx.Chain - }, - - playPause: function(){ - // summary: If the animation sequence is playing, pause it; otherwise, - // play it. - if(this._anims.length == 0){ return this; } - if(this._currAnim == -1){ this._currAnim = 0; } - var currAnim = this._anims[this._currAnim]; - if( currAnim ) { - if( !currAnim._active || currAnim._paused ) { - this.play(); - } else { - this.pause(); - } - } - return this; // dojo.lfx.Chain - }, - - stop: function(){ - // summary: Stops the running animations. - var currAnim = this._anims[this._currAnim]; - if(currAnim){ - currAnim.stop(); - this.fire("onStop", [this._currAnim]); - } - return currAnim; // dojo.lfx.IAnimation - }, - - // private methods - _playNext: function(){ - if( this._currAnim == -1 || this._anims.length == 0 ) { return this; } - this._currAnim++; - if( this._anims[this._currAnim] ){ - this._anims[this._currAnim].play(null, true); - } - return this; // dojo.lfx.Chain +dojo.lang.extend(dojo.lfx.Chain, {_currAnim:-1, play:function (delay, gotoStart) { + if (!this._anims.length) { + return this; } -}); - -dojo.lfx.combine = function(/*dojo.lfx.IAnimation...*/ animations){ - // summary: Convenience function. Returns a dojo.lfx.Combine created - // using the animations passed in. + if (gotoStart || !this._anims[this._currAnim]) { + this._currAnim = 0; + } + var currentAnimation = this._anims[this._currAnim]; + this.fire("beforeBegin"); + if (delay > 0) { + setTimeout(dojo.lang.hitch(this, function () { + this.play(null, gotoStart); + }), delay); + return this; + } + if (currentAnimation) { + if (this._currAnim == 0) { + this.fire("handler", ["begin", this._currAnim]); + this.fire("onBegin", [this._currAnim]); + } + this.fire("onPlay", [this._currAnim]); + currentAnimation.play(null, gotoStart); + } + return this; +}, pause:function () { + if (this._anims[this._currAnim]) { + this._anims[this._currAnim].pause(); + this.fire("onPause", [this._currAnim]); + } + return this; +}, playPause:function () { + if (this._anims.length == 0) { + return this; + } + if (this._currAnim == -1) { + this._currAnim = 0; + } + var currAnim = this._anims[this._currAnim]; + if (currAnim) { + if (!currAnim._active || currAnim._paused) { + this.play(); + } else { + this.pause(); + } + } + return this; +}, stop:function () { + var currAnim = this._anims[this._currAnim]; + if (currAnim) { + currAnim.stop(); + this.fire("onStop", [this._currAnim]); + } + return currAnim; +}, _playNext:function () { + if (this._currAnim == -1 || this._anims.length == 0) { + return this; + } + this._currAnim++; + if (this._anims[this._currAnim]) { + this._anims[this._currAnim].play(null, true); + } + return this; +}}); +dojo.lfx.combine = function (animations) { var anims = arguments; - if(dojo.lang.isArray(arguments[0])){ - /* animations: dojo.lfx.IAnimation[] - pId: a */ + if (dojo.lang.isArray(arguments[0])) { anims = arguments[0]; } - if(anims.length == 1){ return anims[0]; } - return new dojo.lfx.Combine(anims); // dojo.lfx.Combine -} - -dojo.lfx.chain = function(/*dojo.lfx.IAnimation...*/ animations){ - // summary: Convenience function. Returns a dojo.lfx.Chain created - // using the animations passed in. + if (anims.length == 1) { + return anims[0]; + } + return new dojo.lfx.Combine(anims); +}; +dojo.lfx.chain = function (animations) { var anims = arguments; - if(dojo.lang.isArray(arguments[0])){ - /* animations: dojo.lfx.IAnimation[] - pId: a */ + if (dojo.lang.isArray(arguments[0])) { anims = arguments[0]; } - if(anims.length == 1){ return anims[0]; } - return new dojo.lfx.Chain(anims); // dojo.lfx.Combine -} + if (anims.length == 1) { + return anims[0]; + } + return new dojo.lfx.Chain(anims); +}; + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lfx/__package__.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lfx/__package__.js index 7e12e1c9d..6ffe5347f 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lfx/__package__.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lfx/__package__.js @@ -8,8 +8,6 @@ http://dojotoolkit.org/community/licensing.shtml */ -dojo.kwCompoundRequire({ - browser: ["dojo.lfx.html"], - dashboard: ["dojo.lfx.html"] -}); -dojo.provide("dojo.lfx.*"); \ No newline at end of file +dojo.kwCompoundRequire({browser:["dojo.lfx.html"], dashboard:["dojo.lfx.html"]}); +dojo.provide("dojo.lfx.*"); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lfx/extras.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lfx/extras.js index 29605c9e7..033e5090e 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lfx/extras.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lfx/extras.js @@ -9,140 +9,70 @@ */ dojo.provide("dojo.lfx.extras"); - dojo.require("dojo.lfx.html"); dojo.require("dojo.lfx.Animation"); - -dojo.lfx.html.fadeWipeIn = function(/*DOMNode[]*/ nodes, /*int?*/ duration, /*Function?*/ easing, /*Function?*/ callback){ - // summary: Returns an animation that will fade "nodes" from its current - // opacity to fully opaque while wiping it in. - // nodes: An array of DOMNodes or one DOMNode. - // duration: Duration of the animation in milliseconds. - // easing: An easing function. - // callback: Function to run at the end of the animation. +dojo.lfx.html.fadeWipeIn = function (nodes, duration, easing, callback) { nodes = dojo.lfx.html._byId(nodes); - var anim = dojo.lfx.combine( - dojo.lfx.fadeIn(nodes, duration, easing), - dojo.lfx.wipeIn(nodes, duration, easing) - ); - - if(callback){ - anim.connect("onEnd", function(){ + var anim = dojo.lfx.combine(dojo.lfx.fadeIn(nodes, duration, easing), dojo.lfx.wipeIn(nodes, duration, easing)); + if (callback) { + anim.connect("onEnd", function () { callback(nodes, anim); }); } - - return anim; // dojo.lfx.Combine -} - -dojo.lfx.html.fadeWipeOut = function(/*DOMNode[]*/ nodes, /*int?*/ duration, /*Function?*/ easing, /*Function?*/ callback){ - // summary: Returns an animation that will fade "nodes" from its current - // opacity to fully transparent while wiping it out. - // nodes: An array of DOMNodes or one DOMNode. - // duration: Duration of the animation in milliseconds. - // easing: An easing function. - // callback: Function to run at the end of the animation. + return anim; +}; +dojo.lfx.html.fadeWipeOut = function (nodes, duration, easing, callback) { nodes = dojo.lfx.html._byId(nodes); - var anim = dojo.lfx.combine( - dojo.lfx.fadeOut(nodes, duration, easing), - dojo.lfx.wipeOut(nodes, duration, easing) - ); - - if(callback){ - /* callback: Function - pId: f */ - anim.connect("onEnd", function(){ + var anim = dojo.lfx.combine(dojo.lfx.fadeOut(nodes, duration, easing), dojo.lfx.wipeOut(nodes, duration, easing)); + if (callback) { + anim.connect("onEnd", function () { callback(nodes, anim); }); } - - return anim; // dojo.lfx.Combine -} - -dojo.lfx.html.scale = function(/*DOMNode[]*/nodes, - /*int*/ percentage, - /*bool?*/ scaleContent, - /*bool?*/ fromCenter, - /*int?*/ duration, - /*Function?*/ easing, - /*Function?*/ callback){ - // summary: Returns an animation that will scale "nodes" by "percentage". - // nodes: An array of DOMNodes or one DOMNode. - // percentage: A whole number representing the percentage to scale "nodes". - // scaleContent: If true, will scale the contents of "nodes". - // fromCenter: If true, will scale "nodes" from its center rather than the - // lower right corner. - // duration: Duration of the animation in milliseconds. - // easing: An easing function. - // callback: Function to run at the end of the animation. + return anim; +}; +dojo.lfx.html.scale = function (nodes, percentage, scaleContent, fromCenter, duration, easing, callback) { nodes = dojo.lfx.html._byId(nodes); var anims = []; - - dojo.lang.forEach(nodes, function(node){ + dojo.lang.forEach(nodes, function (node) { var outer = dojo.html.getMarginBox(node); - - var actualPct = percentage/100.0; - var props = [ - { property: "width", - start: outer.width, - end: outer.width * actualPct - }, - { property: "height", - start: outer.height, - end: outer.height * actualPct - }]; - - if(scaleContent){ - var fontSize = dojo.html.getStyle(node, 'font-size'); + var actualPct = percentage / 100; + var props = [{property:"width", start:outer.width, end:outer.width * actualPct}, {property:"height", start:outer.height, end:outer.height * actualPct}]; + if (scaleContent) { + var fontSize = dojo.html.getStyle(node, "font-size"); var fontSizeType = null; - if(!fontSize){ - fontSize = parseFloat('100%'); - fontSizeType = '%'; - }else{ - dojo.lang.some(['em','px','%'], function(item, index, arr){ - if(fontSize.indexOf(item)>0){ + if (!fontSize) { + fontSize = parseFloat("100%"); + fontSizeType = "%"; + } else { + dojo.lang.some(["em", "px", "%"], function (item, index, arr) { + if (fontSize.indexOf(item) > 0) { fontSize = parseFloat(fontSize); fontSizeType = item; return true; } }); } - props.push({ - property: "font-size", - start: fontSize, - end: fontSize * actualPct, - units: fontSizeType }); + props.push({property:"font-size", start:fontSize, end:fontSize * actualPct, units:fontSizeType}); } - - if(fromCenter){ + if (fromCenter) { var positioning = dojo.html.getStyle(node, "position"); var originalTop = node.offsetTop; var originalLeft = node.offsetLeft; - var endTop = ((outer.height * actualPct) - outer.height)/2; - var endLeft = ((outer.width * actualPct) - outer.width)/2; - props.push({ - property: "top", - start: originalTop, - end: (positioning == "absolute" ? originalTop - endTop : (-1*endTop)) - }); - props.push({ - property: "left", - start: originalLeft, - end: (positioning == "absolute" ? originalLeft - endLeft : (-1*endLeft)) - }); + var endTop = ((outer.height * actualPct) - outer.height) / 2; + var endLeft = ((outer.width * actualPct) - outer.width) / 2; + props.push({property:"top", start:originalTop, end:(positioning == "absolute" ? originalTop - endTop : (-1 * endTop))}); + props.push({property:"left", start:originalLeft, end:(positioning == "absolute" ? originalLeft - endLeft : (-1 * endLeft))}); } - var anim = dojo.lfx.propertyAnimation(node, props, duration, easing); - if(callback){ - anim.connect("onEnd", function(){ + if (callback) { + anim.connect("onEnd", function () { callback(node, anim); }); } - anims.push(anim); }); - - return dojo.lfx.combine(anims); // dojo.lfx.Combine -} - + return dojo.lfx.combine(anims); +}; dojo.lang.mixin(dojo.lfx, dojo.lfx.html); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lfx/html.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lfx/html.js index 1b3db2d39..06213a294 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lfx/html.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lfx/html.js @@ -9,726 +9,499 @@ */ dojo.provide("dojo.lfx.html"); - dojo.require("dojo.gfx.color"); dojo.require("dojo.lfx.Animation"); dojo.require("dojo.lang.array"); dojo.require("dojo.html.display"); dojo.require("dojo.html.color"); dojo.require("dojo.html.layout"); - -dojo.lfx.html._byId = function(nodes){ - if(!nodes){ return []; } - if(dojo.lang.isArrayLike(nodes)){ - if(!nodes.alreadyChecked){ +dojo.lfx.html._byId = function (nodes) { + if (!nodes) { + return []; + } + if (dojo.lang.isArrayLike(nodes)) { + if (!nodes.alreadyChecked) { var n = []; - dojo.lang.forEach(nodes, function(node){ + dojo.lang.forEach(nodes, function (node) { n.push(dojo.byId(node)); }); n.alreadyChecked = true; return n; - }else{ + } else { return nodes; } - }else{ + } else { var n = []; n.push(dojo.byId(nodes)); n.alreadyChecked = true; return n; } -} - -dojo.lfx.html.propertyAnimation = function( /*DOMNode[]*/ nodes, - /*Object[]*/ propertyMap, - /*int*/ duration, - /*function*/ easing, - /*Object*/ handlers){ - // summary: Returns an animation that will transition the properties of "nodes" - // depending how they are defined in "propertyMap". - // nodes: An array of DOMNodes or one DOMNode. - // propertyMap: { property: String, start: Decimal?, end: Decimal?, units: String? } - // An array of objects defining properties to change. - // duration: Duration of the animation in milliseconds. - // easing: An easing function. - // handlers: { handler: Function?, onstart: Function?, onstop: Function?, onanimate: Function? } +}; +dojo.lfx.html.propertyAnimation = function (nodes, propertyMap, duration, easing, handlers) { nodes = dojo.lfx.html._byId(nodes); - - var targs = { - "propertyMap": propertyMap, - "nodes": nodes, - "duration": duration, - "easing": easing||dojo.lfx.easeDefault - }; - - var setEmUp = function(args){ - if(args.nodes.length==1){ - // FIXME: we're only supporting start-value filling when one node is - // passed - + var targs = {"propertyMap":propertyMap, "nodes":nodes, "duration":duration, "easing":easing || dojo.lfx.easeDefault}; + var setEmUp = function (args) { + if (args.nodes.length == 1) { var pm = args.propertyMap; - if(!dojo.lang.isArray(args.propertyMap)){ - // it's stupid to have to pack an array with a set of objects - // when you can just pass in an object list + if (!dojo.lang.isArray(args.propertyMap)) { var parr = []; - for(var pname in pm){ + for (var pname in pm) { pm[pname].property = pname; parr.push(pm[pname]); } pm = args.propertyMap = parr; } - dojo.lang.forEach(pm, function(prop){ - if(dj_undef("start", prop)){ - if(prop.property != "opacity"){ + dojo.lang.forEach(pm, function (prop) { + if (dj_undef("start", prop)) { + if (prop.property != "opacity") { prop.start = parseInt(dojo.html.getComputedStyle(args.nodes[0], prop.property)); - }else{ + } else { prop.start = dojo.html.getOpacity(args.nodes[0]); } } }); } - } - - var coordsAsInts = function(coords){ + }; + var coordsAsInts = function (coords) { var cints = []; - dojo.lang.forEach(coords, function(c){ + dojo.lang.forEach(coords, function (c) { cints.push(Math.round(c)); }); return cints; - } - - var setStyle = function(n, style){ + }; + var setStyle = function (n, style) { n = dojo.byId(n); - if(!n || !n.style){ return; } - for(var s in style){ - if(s == "opacity"){ - dojo.html.setOpacity(n, style[s]); - }else{ - n.style[s] = style[s]; + if (!n || !n.style) { + return; + } + for (var s in style) { + try { + if (s == "opacity") { + dojo.html.setOpacity(n, style[s]); + } else { + n.style[s] = style[s]; + } + } + catch (e) { + dojo.debug(e); } } - } - - var propLine = function(properties){ + }; + var propLine = function (properties) { this._properties = properties; this.diffs = new Array(properties.length); - dojo.lang.forEach(properties, function(prop, i){ - // calculate the end - start to optimize a bit - if(dojo.lang.isFunction(prop.start)){ + dojo.lang.forEach(properties, function (prop, i) { + if (dojo.lang.isFunction(prop.start)) { prop.start = prop.start(prop, i); } - if(dojo.lang.isFunction(prop.end)){ + if (dojo.lang.isFunction(prop.end)) { prop.end = prop.end(prop, i); } - if(dojo.lang.isArray(prop.start)){ - // don't loop through the arrays + if (dojo.lang.isArray(prop.start)) { this.diffs[i] = null; - }else if(prop.start instanceof dojo.gfx.color.Color){ - // save these so we don't have to call toRgb() every getValue() call - prop.startRgb = prop.start.toRgb(); - prop.endRgb = prop.end.toRgb(); - }else{ - this.diffs[i] = prop.end - prop.start; + } else { + if (prop.start instanceof dojo.gfx.color.Color) { + prop.startRgb = prop.start.toRgb(); + prop.endRgb = prop.end.toRgb(); + } else { + this.diffs[i] = prop.end - prop.start; + } } }, this); - - this.getValue = function(n){ + this.getValue = function (n) { var ret = {}; - dojo.lang.forEach(this._properties, function(prop, i){ + dojo.lang.forEach(this._properties, function (prop, i) { var value = null; - if(dojo.lang.isArray(prop.start)){ - // FIXME: what to do here? - }else if(prop.start instanceof dojo.gfx.color.Color){ - value = (prop.units||"rgb") + "("; - for(var j = 0 ; j < prop.startRgb.length ; j++){ - value += Math.round(((prop.endRgb[j] - prop.startRgb[j]) * n) + prop.startRgb[j]) + (j < prop.startRgb.length - 1 ? "," : ""); + if (dojo.lang.isArray(prop.start)) { + } else { + if (prop.start instanceof dojo.gfx.color.Color) { + value = (prop.units || "rgb") + "("; + for (var j = 0; j < prop.startRgb.length; j++) { + value += Math.round(((prop.endRgb[j] - prop.startRgb[j]) * n) + prop.startRgb[j]) + (j < prop.startRgb.length - 1 ? "," : ""); + } + value += ")"; + } else { + value = ((this.diffs[i]) * n) + prop.start + (prop.property != "opacity" ? prop.units || "px" : ""); } - value += ")"; - }else{ - value = ((this.diffs[i]) * n) + prop.start + (prop.property != "opacity" ? prop.units||"px" : ""); } ret[dojo.html.toCamelCase(prop.property)] = value; }, this); return ret; - } - } - - var anim = new dojo.lfx.Animation({ - beforeBegin: function(){ - setEmUp(targs); - anim.curve = new propLine(targs.propertyMap); - }, - onAnimate: function(propValues){ - dojo.lang.forEach(targs.nodes, function(node){ - setStyle(node, propValues); - }); - } - }, - targs.duration, - null, - targs.easing - ); - if(handlers){ - for(var x in handlers){ - if(dojo.lang.isFunction(handlers[x])){ + }; + }; + var anim = new dojo.lfx.Animation({beforeBegin:function () { + setEmUp(targs); + anim.curve = new propLine(targs.propertyMap); + }, onAnimate:function (propValues) { + dojo.lang.forEach(targs.nodes, function (node) { + setStyle(node, propValues); + }); + }}, targs.duration, null, targs.easing); + if (handlers) { + for (var x in handlers) { + if (dojo.lang.isFunction(handlers[x])) { anim.connect(x, anim, handlers[x]); } } } - - return anim; // dojo.lfx.Animation -} - -dojo.lfx.html._makeFadeable = function(nodes){ - var makeFade = function(node){ - if(dojo.render.html.ie){ - // only set the zoom if the "tickle" value would be the same as the - // default - if( (node.style.zoom.length == 0) && - (dojo.html.getStyle(node, "zoom") == "normal") ){ - // make sure the node "hasLayout" - // NOTE: this has been tested with larger and smaller user-set text - // sizes and works fine + return anim; +}; +dojo.lfx.html._makeFadeable = function (nodes) { + var makeFade = function (node) { + if (dojo.render.html.ie) { + if ((node.style.zoom.length == 0) && (dojo.html.getStyle(node, "zoom") == "normal")) { node.style.zoom = "1"; - // node.style.zoom = "normal"; } - // don't set the width to auto if it didn't already cascade that way. - // We don't want to f anyones designs - if( (node.style.width.length == 0) && - (dojo.html.getStyle(node, "width") == "auto") ){ + if ((node.style.width.length == 0) && (dojo.html.getStyle(node, "width") == "auto")) { node.style.width = "auto"; } } - } - if(dojo.lang.isArrayLike(nodes)){ + }; + if (dojo.lang.isArrayLike(nodes)) { dojo.lang.forEach(nodes, makeFade); - }else{ + } else { makeFade(nodes); } -} - -dojo.lfx.html.fade = function(/*DOMNode[]*/ nodes, - /*Object*/values, - /*int?*/ duration, - /*Function?*/ easing, - /*Function?*/ callback){ - // summary:Returns an animation that will fade the "nodes" from the start to end values passed. - // nodes: An array of DOMNodes or one DOMNode. - // values: { start: Decimal?, end: Decimal? } - // duration: Duration of the animation in milliseconds. - // easing: An easing function. - // callback: Function to run at the end of the animation. +}; +dojo.lfx.html.fade = function (nodes, values, duration, easing, callback) { nodes = dojo.lfx.html._byId(nodes); - var props = { property: "opacity" }; - if(!dj_undef("start", values)){ + var props = {property:"opacity"}; + if (!dj_undef("start", values)) { props.start = values.start; - }else{ - props.start = function(){ return dojo.html.getOpacity(nodes[0]); }; + } else { + props.start = function () { + return dojo.html.getOpacity(nodes[0]); + }; } - - if(!dj_undef("end", values)){ + if (!dj_undef("end", values)) { props.end = values.end; - }else{ + } else { dojo.raise("dojo.lfx.html.fade needs an end value"); } - - var anim = dojo.lfx.propertyAnimation(nodes, [ props ], duration, easing); - anim.connect("beforeBegin", function(){ + var anim = dojo.lfx.propertyAnimation(nodes, [props], duration, easing); + anim.connect("beforeBegin", function () { dojo.lfx.html._makeFadeable(nodes); }); - if(callback){ - anim.connect("onEnd", function(){ callback(nodes, anim); }); + if (callback) { + anim.connect("onEnd", function () { + callback(nodes, anim); + }); } - - return anim; // dojo.lfx.Animation -} - -dojo.lfx.html.fadeIn = function(/*DOMNode[]*/ nodes, /*int?*/ duration, /*Function?*/ easing, /*Function?*/ callback){ - // summary: Returns an animation that will fade "nodes" from its current opacity to fully opaque. - // nodes: An array of DOMNodes or one DOMNode. - // duration: Duration of the animation in milliseconds. - // easing: An easing function. - // callback: Function to run at the end of the animation. - return dojo.lfx.html.fade(nodes, { end: 1 }, duration, easing, callback); // dojo.lfx.Animation -} - -dojo.lfx.html.fadeOut = function(/*DOMNode[]*/ nodes, /*int?*/ duration, /*Function?*/ easing, /*Function?*/ callback){ - // summary: Returns an animation that will fade "nodes" from its current opacity to fully transparent. - // nodes: An array of DOMNodes or one DOMNode. - // duration: Duration of the animation in milliseconds. - // easing: An easing function. - // callback: Function to run at the end of the animation. - return dojo.lfx.html.fade(nodes, { end: 0 }, duration, easing, callback); // dojo.lfx.Animation -} - -dojo.lfx.html.fadeShow = function(/*DOMNode[]*/ nodes, /*int?*/ duration, /*Function?*/ easing, /*Function?*/ callback){ - // summary: Returns an animation that will fade "nodes" from transparent to opaque and shows - // "nodes" at the end if it is hidden. - // nodes: An array of DOMNodes or one DOMNode. - // duration: Duration of the animation in milliseconds. - // easing: An easing function. - // callback: Function to run at the end of the animation. - nodes=dojo.lfx.html._byId(nodes); - dojo.lang.forEach(nodes, function(node){ - dojo.html.setOpacity(node, 0.0); + return anim; +}; +dojo.lfx.html.fadeIn = function (nodes, duration, easing, callback) { + return dojo.lfx.html.fade(nodes, {end:1}, duration, easing, callback); +}; +dojo.lfx.html.fadeOut = function (nodes, duration, easing, callback) { + return dojo.lfx.html.fade(nodes, {end:0}, duration, easing, callback); +}; +dojo.lfx.html.fadeShow = function (nodes, duration, easing, callback) { + nodes = dojo.lfx.html._byId(nodes); + dojo.lang.forEach(nodes, function (node) { + dojo.html.setOpacity(node, 0); }); - var anim = dojo.lfx.html.fadeIn(nodes, duration, easing, callback); - anim.connect("beforeBegin", function(){ - if(dojo.lang.isArrayLike(nodes)){ + anim.connect("beforeBegin", function () { + if (dojo.lang.isArrayLike(nodes)) { dojo.lang.forEach(nodes, dojo.html.show); - }else{ + } else { dojo.html.show(nodes); } }); - - return anim; // dojo.lfx.Animation -} - -dojo.lfx.html.fadeHide = function(/*DOMNode[]*/ nodes, /*int?*/ duration, /*Function?*/ easing, /*Function?*/ callback){ - // summary: Returns an animation that will fade "nodes" from its current opacity to opaque and hides - // "nodes" at the end. - // nodes: An array of DOMNodes or one DOMNode. - // duration: Duration of the animation in milliseconds. - // easing: An easing function. - // callback: Function to run at the end of the animation. - var anim = dojo.lfx.html.fadeOut(nodes, duration, easing, function(){ - if(dojo.lang.isArrayLike(nodes)){ + return anim; +}; +dojo.lfx.html.fadeHide = function (nodes, duration, easing, callback) { + var anim = dojo.lfx.html.fadeOut(nodes, duration, easing, function () { + if (dojo.lang.isArrayLike(nodes)) { dojo.lang.forEach(nodes, dojo.html.hide); - }else{ + } else { dojo.html.hide(nodes); } - if(callback){ callback(nodes, anim); } + if (callback) { + callback(nodes, anim); + } }); - - return anim; // dojo.lfx.Animation -} - -dojo.lfx.html.wipeIn = function(/*DOMNode[]*/ nodes, /*int?*/ duration, /*Function?*/ easing, /*Function?*/ callback){ - // summary: Returns an animation that will show and wipe in "nodes". - // nodes: An array of DOMNodes or one DOMNode. - // duration: Duration of the animation in milliseconds. - // easing: An easing function. - // callback: Function to run at the end of the animation. + return anim; +}; +dojo.lfx.html.wipeIn = function (nodes, duration, easing, callback) { nodes = dojo.lfx.html._byId(nodes); var anims = []; - - dojo.lang.forEach(nodes, function(node){ - var oprop = { }; // old properties of node (before we mucked w/them) - - // get node height, either it's natural height or it's height specified via style or class attributes - // (for FF, the node has to be (temporarily) rendered to measure height) - dojo.html.show(node); - var height = dojo.html.getBorderBox(node).height; - dojo.html.hide(node); - - var anim = dojo.lfx.propertyAnimation(node, - { "height": { - start: 1, // 0 causes IE to display the whole panel - end: function(){ return height; } - } - }, - duration, - easing); - - anim.connect("beforeBegin", function(){ + dojo.lang.forEach(nodes, function (node) { + var oprop = {}; + var origTop, origLeft, origPosition; + with (node.style) { + origTop = top; + origLeft = left; + origPosition = position; + top = "-9999px"; + left = "-9999px"; + position = "absolute"; + display = ""; + } + var nodeHeight = dojo.html.getBorderBox(node).height; + with (node.style) { + top = origTop; + left = origLeft; + position = origPosition; + display = "none"; + } + var anim = dojo.lfx.propertyAnimation(node, {"height":{start:1, end:function () { + return nodeHeight; + }}}, duration, easing); + anim.connect("beforeBegin", function () { oprop.overflow = node.style.overflow; oprop.height = node.style.height; - with(node.style){ + with (node.style) { overflow = "hidden"; - height = "1px"; // 0 causes IE to display the whole panel + height = "1px"; } dojo.html.show(node); }); - - anim.connect("onEnd", function(){ - with(node.style){ + anim.connect("onEnd", function () { + with (node.style) { overflow = oprop.overflow; height = oprop.height; } - if(callback){ callback(node, anim); } + if (callback) { + callback(node, anim); + } }); anims.push(anim); }); - - return dojo.lfx.combine(anims); // dojo.lfx.Combine -} - -dojo.lfx.html.wipeOut = function(/*DOMNode[]*/ nodes, /*int?*/ duration, /*Function?*/ easing, /*Function?*/ callback){ - // summary: Returns an animation that will wipe out and hide "nodes". - // nodes: An array of DOMNodes or one DOMNode. - // duration: Duration of the animation in milliseconds. - // easing: An easing function. - // callback: Function to run at the end of the animation. + return dojo.lfx.combine(anims); +}; +dojo.lfx.html.wipeOut = function (nodes, duration, easing, callback) { nodes = dojo.lfx.html._byId(nodes); var anims = []; - - dojo.lang.forEach(nodes, function(node){ - var oprop = { }; // old properties of node (before we mucked w/them) - var anim = dojo.lfx.propertyAnimation(node, - { "height": { - start: function(){ return dojo.html.getContentBox(node).height; }, - end: 1 // 0 causes IE to display the whole panel - } - }, - duration, - easing, - { - "beforeBegin": function(){ - oprop.overflow = node.style.overflow; - oprop.height = node.style.height; - with(node.style){ - overflow = "hidden"; - } - dojo.html.show(node); - }, - - "onEnd": function(){ - dojo.html.hide(node); - with(node.style){ - overflow = oprop.overflow; - height = oprop.height; - } - if(callback){ callback(node, anim); } - } + dojo.lang.forEach(nodes, function (node) { + var oprop = {}; + var anim = dojo.lfx.propertyAnimation(node, {"height":{start:function () { + return dojo.html.getContentBox(node).height; + }, end:1}}, duration, easing, {"beforeBegin":function () { + oprop.overflow = node.style.overflow; + oprop.height = node.style.height; + with (node.style) { + overflow = "hidden"; } - ); + dojo.html.show(node); + }, "onEnd":function () { + dojo.html.hide(node); + with (node.style) { + overflow = oprop.overflow; + height = oprop.height; + } + if (callback) { + callback(node, anim); + } + }}); anims.push(anim); }); - - return dojo.lfx.combine(anims); // dojo.lfx.Combine -} - -dojo.lfx.html.slideTo = function(/*DOMNode*/ nodes, - /*Object*/ coords, - /*int?*/ duration, - /*Function?*/ easing, - /*Function?*/ callback){ - // summary: Returns an animation that will slide "nodes" from its current position to - // the position defined in "coords". - // nodes: An array of DOMNodes or one DOMNode. - // coords: { top: Decimal?, left: Decimal? } - // duration: Duration of the animation in milliseconds. - // easing: An easing function. - // callback: Function to run at the end of the animation. + return dojo.lfx.combine(anims); +}; +dojo.lfx.html.slideTo = function (nodes, coords, duration, easing, callback) { nodes = dojo.lfx.html._byId(nodes); var anims = []; var compute = dojo.html.getComputedStyle; - - if(dojo.lang.isArray(coords)){ - /* coords: Array - pId: a */ - dojo.deprecated('dojo.lfx.html.slideTo(node, array)', 'use dojo.lfx.html.slideTo(node, {top: value, left: value});', '0.5'); - coords = { top: coords[0], left: coords[1] }; + if (dojo.lang.isArray(coords)) { + dojo.deprecated("dojo.lfx.html.slideTo(node, array)", "use dojo.lfx.html.slideTo(node, {top: value, left: value});", "0.5"); + coords = {top:coords[0], left:coords[1]}; } - dojo.lang.forEach(nodes, function(node){ + dojo.lang.forEach(nodes, function (node) { var top = null; var left = null; - - var init = (function(){ + var init = (function () { var innerNode = node; - return function(){ - var pos = compute(innerNode, 'position'); - top = (pos == 'absolute' ? node.offsetTop : parseInt(compute(node, 'top')) || 0); - left = (pos == 'absolute' ? node.offsetLeft : parseInt(compute(node, 'left')) || 0); - - if (!dojo.lang.inArray(['absolute', 'relative'], pos)) { + return function () { + var pos = compute(innerNode, "position"); + top = (pos == "absolute" ? node.offsetTop : parseInt(compute(node, "top")) || 0); + left = (pos == "absolute" ? node.offsetLeft : parseInt(compute(node, "left")) || 0); + if (!dojo.lang.inArray(["absolute", "relative"], pos)) { var ret = dojo.html.abs(innerNode, true); - dojo.html.setStyleAttributes(innerNode, "position:absolute;top:"+ret.y+"px;left:"+ret.x+"px;"); + dojo.html.setStyleAttributes(innerNode, "position:absolute;top:" + ret.y + "px;left:" + ret.x + "px;"); top = ret.y; left = ret.x; } - } + }; })(); init(); - - var anim = dojo.lfx.propertyAnimation(node, - { "top": { start: top, end: (coords.top||0) }, - "left": { start: left, end: (coords.left||0) } - }, - duration, - easing, - { "beforeBegin": init } - ); - - if(callback){ - anim.connect("onEnd", function(){ callback(nodes, anim); }); + var anim = dojo.lfx.propertyAnimation(node, {"top":{start:top, end:(coords.top || 0)}, "left":{start:left, end:(coords.left || 0)}}, duration, easing, {"beforeBegin":init}); + if (callback) { + anim.connect("onEnd", function () { + callback(nodes, anim); + }); } - anims.push(anim); }); - - return dojo.lfx.combine(anims); // dojo.lfx.Combine -} - -dojo.lfx.html.slideBy = function(/*DOMNode*/ nodes, /*Object*/ coords, /*int?*/ duration, /*Function?*/ easing, /*Function?*/ callback){ - // summary: Returns an animation that will slide "nodes" from its current position - // to its current position plus the numbers defined in "coords". - // nodes: An array of DOMNodes or one DOMNode. - // coords: { top: Decimal?, left: Decimal? } - // duration: Duration of the animation in milliseconds. - // easing: An easing function. - // callback: Function to run at the end of the animation. + return dojo.lfx.combine(anims); +}; +dojo.lfx.html.slideBy = function (nodes, coords, duration, easing, callback) { nodes = dojo.lfx.html._byId(nodes); var anims = []; var compute = dojo.html.getComputedStyle; - - if(dojo.lang.isArray(coords)){ - /* coords: Array - pId: a */ - dojo.deprecated('dojo.lfx.html.slideBy(node, array)', 'use dojo.lfx.html.slideBy(node, {top: value, left: value});', '0.5'); - coords = { top: coords[0], left: coords[1] }; + if (dojo.lang.isArray(coords)) { + dojo.deprecated("dojo.lfx.html.slideBy(node, array)", "use dojo.lfx.html.slideBy(node, {top: value, left: value});", "0.5"); + coords = {top:coords[0], left:coords[1]}; } - - dojo.lang.forEach(nodes, function(node){ + dojo.lang.forEach(nodes, function (node) { var top = null; var left = null; - - var init = (function(){ + var init = (function () { var innerNode = node; - return function(){ - var pos = compute(innerNode, 'position'); - top = (pos == 'absolute' ? node.offsetTop : parseInt(compute(node, 'top')) || 0); - left = (pos == 'absolute' ? node.offsetLeft : parseInt(compute(node, 'left')) || 0); - - if (!dojo.lang.inArray(['absolute', 'relative'], pos)) { + return function () { + var pos = compute(innerNode, "position"); + top = (pos == "absolute" ? node.offsetTop : parseInt(compute(node, "top")) || 0); + left = (pos == "absolute" ? node.offsetLeft : parseInt(compute(node, "left")) || 0); + if (!dojo.lang.inArray(["absolute", "relative"], pos)) { var ret = dojo.html.abs(innerNode, true); - dojo.html.setStyleAttributes(innerNode, "position:absolute;top:"+ret.y+"px;left:"+ret.x+"px;"); + dojo.html.setStyleAttributes(innerNode, "position:absolute;top:" + ret.y + "px;left:" + ret.x + "px;"); top = ret.y; left = ret.x; } - } + }; })(); init(); - - var anim = dojo.lfx.propertyAnimation(node, - { - "top": { start: top, end: top+(coords.top||0) }, - "left": { start: left, end: left+(coords.left||0) } - }, - duration, - easing).connect("beforeBegin", init); - - if(callback){ - anim.connect("onEnd", function(){ callback(nodes, anim); }); + var anim = dojo.lfx.propertyAnimation(node, {"top":{start:top, end:top + (coords.top || 0)}, "left":{start:left, end:left + (coords.left || 0)}}, duration, easing).connect("beforeBegin", init); + if (callback) { + anim.connect("onEnd", function () { + callback(nodes, anim); + }); } - anims.push(anim); }); - - return dojo.lfx.combine(anims); // dojo.lfx.Combine -} - -dojo.lfx.html.explode = function(/*DOMNode*/ start, - /*DOMNode*/ endNode, - /*int?*/ duration, - /*Function?*/ easing, - /*Function?*/ callback){ - // summary: Returns an animation that will - // start: - // endNode: - // duration: Duration of the animation in milliseconds. - // easing: An easing function. - // callback: Function to run at the end of the animation. + return dojo.lfx.combine(anims); +}; +dojo.lfx.html.explode = function (start, endNode, duration, easing, callback) { var h = dojo.html; start = dojo.byId(start); endNode = dojo.byId(endNode); var startCoords = h.toCoordinateObject(start, true); var outline = document.createElement("div"); h.copyStyle(outline, endNode); - if (endNode.explodeClassName) { outline.className = endNode.explodeClassName; } - with(outline.style){ + if (endNode.explodeClassName) { + outline.className = endNode.explodeClassName; + } + with (outline.style) { position = "absolute"; display = "none"; - // border = "1px solid black"; + var backgroundStyle = h.getStyle(start, "background-color"); + backgroundColor = backgroundStyle ? backgroundStyle.toLowerCase() : "transparent"; + backgroundColor = (backgroundColor == "transparent") ? "rgb(221, 221, 221)" : backgroundColor; } dojo.body().appendChild(outline); - - with(endNode.style){ + with (endNode.style) { visibility = "hidden"; display = "block"; } var endCoords = h.toCoordinateObject(endNode, true); - with(endNode.style){ + with (endNode.style) { display = "none"; visibility = "visible"; } - - var props = { opacity: { start: 0.5, end: 1.0 } }; - dojo.lang.forEach(["height", "width", "top", "left"], function(type){ - props[type] = { start: startCoords[type], end: endCoords[type] } + var props = {opacity:{start:0.5, end:1}}; + dojo.lang.forEach(["height", "width", "top", "left"], function (type) { + props[type] = {start:startCoords[type], end:endCoords[type]}; }); - - var anim = new dojo.lfx.propertyAnimation(outline, - props, - duration, - easing, - { - "beforeBegin": function(){ - h.setDisplay(outline, "block"); - }, - "onEnd": function(){ - h.setDisplay(endNode, "block"); - outline.parentNode.removeChild(outline); - } - } - ); - - if(callback){ - anim.connect("onEnd", function(){ callback(endNode, anim); }); + var anim = new dojo.lfx.propertyAnimation(outline, props, duration, easing, {"beforeBegin":function () { + h.setDisplay(outline, "block"); + }, "onEnd":function () { + h.setDisplay(endNode, "block"); + outline.parentNode.removeChild(outline); + }}); + if (callback) { + anim.connect("onEnd", function () { + callback(endNode, anim); + }); } - return anim; // dojo.lfx.Animation -} - -dojo.lfx.html.implode = function(/*DOMNode*/ startNode, - /*DOMNode*/ end, - /*int?*/ duration, - /*Function?*/ easing, - /*Function?*/ callback){ - // summary: Returns an animation that will - // startNode: - // end: - // duration: Duration of the animation in milliseconds. - // easing: An easing function. - // callback: Function to run at the end of the animation. + return anim; +}; +dojo.lfx.html.implode = function (startNode, end, duration, easing, callback) { var h = dojo.html; startNode = dojo.byId(startNode); end = dojo.byId(end); var startCoords = dojo.html.toCoordinateObject(startNode, true); var endCoords = dojo.html.toCoordinateObject(end, true); - var outline = document.createElement("div"); dojo.html.copyStyle(outline, startNode); - if (startNode.explodeClassName) { outline.className = startNode.explodeClassName; } + if (startNode.explodeClassName) { + outline.className = startNode.explodeClassName; + } dojo.html.setOpacity(outline, 0.3); - with(outline.style){ + with (outline.style) { position = "absolute"; display = "none"; backgroundColor = h.getStyle(startNode, "background-color").toLowerCase(); } dojo.body().appendChild(outline); - - var props = { opacity: { start: 1.0, end: 0.5 } }; - dojo.lang.forEach(["height", "width", "top", "left"], function(type){ - props[type] = { start: startCoords[type], end: endCoords[type] } + var props = {opacity:{start:1, end:0.5}}; + dojo.lang.forEach(["height", "width", "top", "left"], function (type) { + props[type] = {start:startCoords[type], end:endCoords[type]}; }); - - var anim = new dojo.lfx.propertyAnimation(outline, - props, - duration, - easing, - { - "beforeBegin": function(){ - dojo.html.hide(startNode); - dojo.html.show(outline); - }, - "onEnd": function(){ - outline.parentNode.removeChild(outline); - } - } - ); - - if(callback){ - anim.connect("onEnd", function(){ callback(startNode, anim); }); + var anim = new dojo.lfx.propertyAnimation(outline, props, duration, easing, {"beforeBegin":function () { + dojo.html.hide(startNode); + dojo.html.show(outline); + }, "onEnd":function () { + outline.parentNode.removeChild(outline); + }}); + if (callback) { + anim.connect("onEnd", function () { + callback(startNode, anim); + }); } - return anim; // dojo.lfx.Animation -} - -dojo.lfx.html.highlight = function(/*DOMNode[]*/ nodes, - /*dojo.gfx.color.Color*/ startColor, - /*int?*/ duration, - /*Function?*/ easing, - /*Function?*/ callback){ - // summary: Returns an animation that will set the background color - // of "nodes" to startColor and transition it to "nodes" - // original color. - // startColor: Color to transition from. - // duration: Duration of the animation in milliseconds. - // easing: An easing function. - // callback: Function to run at the end of the animation. + return anim; +}; +dojo.lfx.html.highlight = function (nodes, startColor, duration, easing, callback) { nodes = dojo.lfx.html._byId(nodes); var anims = []; - - dojo.lang.forEach(nodes, function(node){ + dojo.lang.forEach(nodes, function (node) { var color = dojo.html.getBackgroundColor(node); var bg = dojo.html.getStyle(node, "background-color").toLowerCase(); var bgImage = dojo.html.getStyle(node, "background-image"); var wasTransparent = (bg == "transparent" || bg == "rgba(0, 0, 0, 0)"); - while(color.length > 3) { color.pop(); } - + while (color.length > 3) { + color.pop(); + } var rgb = new dojo.gfx.color.Color(startColor); var endRgb = new dojo.gfx.color.Color(color); - - var anim = dojo.lfx.propertyAnimation(node, - { "background-color": { start: rgb, end: endRgb } }, - duration, - easing, - { - "beforeBegin": function(){ - if(bgImage){ - node.style.backgroundImage = "none"; - } - node.style.backgroundColor = "rgb(" + rgb.toRgb().join(",") + ")"; - }, - "onEnd": function(){ - if(bgImage){ - node.style.backgroundImage = bgImage; - } - if(wasTransparent){ - node.style.backgroundColor = "transparent"; - } - if(callback){ - callback(node, anim); - } - } + var anim = dojo.lfx.propertyAnimation(node, {"background-color":{start:rgb, end:endRgb}}, duration, easing, {"beforeBegin":function () { + if (bgImage) { + node.style.backgroundImage = "none"; } - ); - + node.style.backgroundColor = "rgb(" + rgb.toRgb().join(",") + ")"; + }, "onEnd":function () { + if (bgImage) { + node.style.backgroundImage = bgImage; + } + if (wasTransparent) { + node.style.backgroundColor = "transparent"; + } + if (callback) { + callback(node, anim); + } + }}); anims.push(anim); }); - return dojo.lfx.combine(anims); // dojo.lfx.Combine -} - -dojo.lfx.html.unhighlight = function(/*DOMNode[]*/ nodes, - /*dojo.gfx.color.Color*/ endColor, - /*int?*/ duration, - /*Function?*/ easing, - /*Function?*/ callback){ - // summary: Returns an animation that will transition "nodes" background color - // from its current color to "endColor". - // endColor: Color to transition to. - // duration: Duration of the animation in milliseconds. - // easing: An easing function. - // callback: Function to run at the end of the animation. + return dojo.lfx.combine(anims); +}; +dojo.lfx.html.unhighlight = function (nodes, endColor, duration, easing, callback) { nodes = dojo.lfx.html._byId(nodes); var anims = []; - - dojo.lang.forEach(nodes, function(node){ + dojo.lang.forEach(nodes, function (node) { var color = new dojo.gfx.color.Color(dojo.html.getBackgroundColor(node)); var rgb = new dojo.gfx.color.Color(endColor); - var bgImage = dojo.html.getStyle(node, "background-image"); - - var anim = dojo.lfx.propertyAnimation(node, - { "background-color": { start: color, end: rgb } }, - duration, - easing, - { - "beforeBegin": function(){ - if(bgImage){ - node.style.backgroundImage = "none"; - } - node.style.backgroundColor = "rgb(" + color.toRgb().join(",") + ")"; - }, - "onEnd": function(){ - if(callback){ - callback(node, anim); - } - } + var anim = dojo.lfx.propertyAnimation(node, {"background-color":{start:color, end:rgb}}, duration, easing, {"beforeBegin":function () { + if (bgImage) { + node.style.backgroundImage = "none"; } - ); + node.style.backgroundColor = "rgb(" + color.toRgb().join(",") + ")"; + }, "onEnd":function () { + if (callback) { + callback(node, anim); + } + }}); anims.push(anim); }); - return dojo.lfx.combine(anims); // dojo.lfx.Combine -} - + return dojo.lfx.combine(anims); +}; dojo.lang.mixin(dojo.lfx, dojo.lfx.html); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lfx/rounded.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lfx/rounded.js index aa4598b03..2043f5b64 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lfx/rounded.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lfx/rounded.js @@ -8,505 +8,435 @@ http://dojotoolkit.org/community/licensing.shtml */ -dojo.provide("dojo.lfx.rounded"); - -dojo.require("dojo.lang.common"); -dojo.require("dojo.html.common"); -dojo.require("dojo.html.style"); -dojo.require("dojo.html.display"); -dojo.require("dojo.html.layout"); - -/* Port of curvyCorners, by Cameron Cooke and Tim Hutchison. - * Original port done by Brian Lucas. - * Refactor and function by trt. - */ -dojo.lfx.rounded = function(/* object */settings /* ... */){ - // summary - // Creates a set of rounded corners based on settings. - var options={ - validTags:settings.validTags || ["div"], // tags we can apply this to - autoPad:settings.autoPad!=null ? settings.autoPad : true, // automatically pad - antiAlias:settings.antiAlias!=null ? settings.antiAlias : true, // anti-alias corners - radii:{ // corner radii - tl:(settings.tl && settings.tl.radius!=null) ? settings.tl.radius:5, - tr:(settings.tr && settings.tr.radius!=null) ? settings.tr.radius:5, - bl:(settings.bl && settings.bl.radius!=null) ? settings.bl.radius:5, - br:(settings.br && settings.br.radius!=null) ? settings.br.radius:5 - } - }; - - // get the node list to operate on. - var nodes; - if(typeof(arguments[1]) == "string"){ - // a CSS classname was passed, grab a node list. - nodes=dojo.html.getElementsByClass(arguments[1]); - } else if(dojo.lang.isArrayLike(arguments[1])){ - // we assume that the second argument is an array of nodes to apply this to. - nodes=arguments[1]; - for(var i=0; i0){ - node.innerHTML=""; - } - - var topHeight=Math.max(options.radii.tl, options.radii.tr); - var bottomHeight=Math.max(options.radii.bl, options.radii.br); - - // build the containers. - if(options.radii.tl || options.radii.tr){ - top = document.createElement("div"); - top.style.width="100%"; - top.style.fontSize="1px"; - top.style.overflow="hidden"; - top.style.position="absolute"; - top.style.paddingLeft=format.borderWidth+"px"; - top.style.paddingRight=format.borderWidth+"px"; - top.style.height=topHeight+"px"; - top.style.top=(0-topHeight)+"px"; - top.style.left=(0-format.borderWidth)+"px"; - node.appendChild(top); - } - if(options.radii.bl || options.radii.br){ // bottom - bottom = document.createElement("div"); - bottom.style.width="100%"; - bottom.style.fontSize="1px"; - bottom.style.overflow="hidden"; - bottom.style.position="absolute"; - bottom.style.paddingLeft=format.borderWidth+"px"; - bottom.style.paddingRight=format.borderWidth+"px"; - bottom.style.height=bottomHeight+"px"; - bottom.style.bottom=(0-bottomHeight)+"px"; - bottom.style.left=(0-format.borderWidth)+"px"; - node.appendChild(bottom); - } - - // turn off the borders - if(top){ node.style.borderTopWidth = "0px"; } - if(bottom){ node.style.borderBottomWidth = "0px"; } - - // do the corners - var corners = ["tr", "tl", "br", "bl"]; - for(var i=0; i= borderRadius){ var y1=-1; } - var y2=Math.ceil(Math.sqrt(Math.pow(borderRadius,2)-Math.pow(x,2))); - if(x >= borderRadius){ y2=-1; } - var y3=Math.floor(Math.sqrt(Math.pow(j,2)-Math.pow((x+1),2)))-1; - if((x+1) >= j){ y3=-1; } - var y4=Math.ceil(Math.sqrt(Math.pow(j, 2)-Math.pow(x, 2))); - if(x >= j){ y4=-1; } - - // start drawing - if(y1 > -1){ - fns.draw(x, 0, format.color, 100, (y1+1), corner, -1, j, topHeight, format); - } - - // cycle the y-axis - for(var y=(y1+1); y= y2){ - if(y2 == -1){ y2 = 0; } - fns.draw(x, y2, format.borderColor, 100, (y3-y2+1), corner, 0, 0, topHeight, format) - } else { - if(y3 >= y1){ - fns.draw(x, (y1+1), format.borderColor, 100, (y3-y1), corner, 0, 0, topHeight, format); - } - } - for(var y=(y3+1); y0 ? 0:-1), options.radii[cc], topHeight, format); - } - } else { - y3=y1; - } - } - - // reposition pixels if not the bottom right. - if(cc != "br"){ - for(var t=0, k=corner.childNodes.length; t0){ - var content=document.createElement("div"); - content.style.position="relative"; - content.innerHTML=format.content; - content.className="autoPadDiv"; - if(topHeight < format.padding){ - content.style.paddingTop = Math.abs(topHeight-format.padding)+"px"; - } - if(bottomHeight < format.padding){ - content.style.paddingBottom = Math.abs(bottomHeight-format.padding)+"px"; - } - content.style.paddingLeft=format.padding+"px"; - content.style.paddingRight=format.padding+"px"; - node.appendChild(content); - } -}; - -var count=0; - -// helper methods. -dojo.lfx.rounded._fns={ - blend:function(clr1, clr2, frac){ - var c1={ - r:parseInt(clr1.substr(1,2),16), - g:parseInt(clr1.substr(3,2),16), - b:parseInt(clr1.substr(5,2),16) - }; - var c2={ - r:parseInt(clr2.substr(1,2),16), - g:parseInt(clr2.substr(3,2),16), - b:parseInt(clr2.substr(5,2),16) - }; - if(frac>1||frac<0){ frac=1; } - var ret=[ - Math.min(Math.max(Math.round((c1.r*frac)+(c2.r*(1-frac))),0),255), - Math.min(Math.max(Math.round((c1.g*frac)+(c2.g*(1-frac))),0),255), - Math.min(Math.max(Math.round((c1.b*frac)+(c2.b*(1-frac))),0),255) - ]; - for(var i=0; i=y && intersect < (y+1)){ - whatsides="Left"; - xval[point]=0; - yval[point++]=intersect-y; - } - - intersect=Math.sqrt((Math.pow(r,2)-Math.pow(y+1,2))); - if(intersect >=x && intersect < (x+1)){ - whatsides += "Top"; - xval[point]=intersect-x; - yval[point++]=1; - } - - intersect=Math.sqrt((Math.pow(r,2)-Math.pow(x+1,2))); - if(intersect >= y && intersect < (y+1)){ - whatsides += "Right"; - xval[point]=1; - yval[point++] = intersect-y; - } - - intersect=Math.sqrt((Math.pow(r,2)-Math.pow(y,2))); - if(intersect >=x && intersect < (x+1)){ - whatsides += "Bottom"; - xval[point]=intersect-x; - yval[point]=1; - } - - switch(whatsides){ - case "LeftRight": - return Math.min(yval[0],yval[1]) + ((Math.max(yval[0],yval[1])-Math.min(yval[0],yval[1]))/2); - case "TopRight": - return 1-(((1-xval[0])*(1-yval[1]))/2); - case "TopBottom": - return Math.min(xval[0],xval[1]) + ((Math.max(xval[0],xval[1])-Math.min(xval[0],xval[1]))/2); - case "LeftBottom": - return (yval[0]*xval[1])/2; - default: return 1; - } - }, - draw:function(x, y, color, opac, height, corner, image, radius, top, format){ - var px=document.createElement("div"); - px.style.height=height+"px" - px.style.width="1px"; - px.style.position="absolute"; - px.style.fontSize="1px"; - px.style.overflow="hidden"; - if(image==-1 && format.bgImage!=""){ - px.style.backgroundImage=format.bgImage; - px.style.backgroundPosition="-"+(format.width-(radius-x)+format.borderWidth) - +"px -"+((format.height+top+y)-format.borderWidth)+"px"; - } else { - px.style.backgroundColor=color; - } - if(opac!=100){ dojo.html.setOpacity(px, (opac/100)); } - px.style.top=y+"px"; - px.style.left=x+"px"; - corner.appendChild(px); - }, - getRGB:function(clr){ - var ret="#ffffff"; - if(clr!="" && clr!="transparent"){ - if(clr.substr(0,3)=="rgb"){ - var t=clr.substring(4, clr.indexOf(")")); - t=t.split(","); - for(var i=0; i 0) { + node.innerHTML = ""; + } + var topHeight = Math.max(options.radii.tl, options.radii.tr); + var bottomHeight = Math.max(options.radii.bl, options.radii.br); + if (options.radii.tl || options.radii.tr) { + top = document.createElement("div"); + top.style.width = "100%"; + top.style.fontSize = "1px"; + top.style.overflow = "hidden"; + top.style.position = "absolute"; + top.style.paddingLeft = format.borderWidth + "px"; + top.style.paddingRight = format.borderWidth + "px"; + top.style.height = topHeight + "px"; + top.style.top = (0 - topHeight) + "px"; + top.style.left = (0 - format.borderWidth) + "px"; + node.appendChild(top); + } + if (options.radii.bl || options.radii.br) { + bottom = document.createElement("div"); + bottom.style.width = "100%"; + bottom.style.fontSize = "1px"; + bottom.style.overflow = "hidden"; + bottom.style.position = "absolute"; + bottom.style.paddingLeft = format.borderWidth + "px"; + bottom.style.paddingRight = format.borderWidth + "px"; + bottom.style.height = bottomHeight + "px"; + bottom.style.bottom = (0 - bottomHeight) + "px"; + bottom.style.left = (0 - format.borderWidth) + "px"; + node.appendChild(bottom); + } + if (top) { + node.style.borderTopWidth = "0px"; + } + if (bottom) { + node.style.borderBottomWidth = "0px"; + } + var corners = ["tr", "tl", "br", "bl"]; + for (var i = 0; i < corners.length; i++) { + var cc = corners[i]; + if (options.radii[cc] == 0) { + if ((cc.charAt(0) == "t" && top) || (cc.charAt(0) == "b" && bottom)) { + var corner = document.createElement("div"); + corner.style.position = "relative"; + corner.style.fontSize = "1px;"; + corner.style.overflow = "hidden"; + if (format.bgImage == "") { + corner.style.backgroundColor = format.color; + } else { + corner.style.backgroundImage = format.bgImage; + } + switch (cc) { + case "tl": + corner.style.height = topHeight - format.borderWidth + "px"; + corner.style.marginRight = options.radii[cc] - (format.borderWidth * 2) + "px"; + corner.style.borderLeft = format.borderString; + corner.style.borderTop = format.borderString; + corner.style.left = -format.borderWidth + "px"; + break; + case "tr": + corner.style.height = topHeight - format.borderWidth + "px"; + corner.style.marginLeft = options.radii[cc] - (format.borderWidth * 2) + "px"; + corner.style.borderRight = format.borderString; + corner.style.borderTop = format.borderString; + corner.style.backgroundPosition = "-" + (topHeight - format.borderWidth) + "px 0px"; + corner.style.left = format.borderWidth + "px"; + break; + case "bl": + corner.style.height = bottomHeight - format.borderWidth + "px"; + corner.style.marginRight = options.radii[cc] - (format.borderWidth * 2) + "px"; + corner.style.borderLeft = format.borderString; + corner.style.borderBottom = format.borderString; + corner.style.left = format.borderWidth + "px"; + corner.style.backgroundPosition = "-" + format.borderWidth + "px -" + (format.height + (bottomHeight + format.borderWidth)) + "px"; + break; + case "br": + corner.style.height = bottomHeight - format.borderWidth + "px"; + corner.style.marginLeft = options.radii[cc] - (format.borderWidth * 2) + "px"; + corner.style.borderRight = format.borderString; + corner.style.borderBottom = format.borderString; + corner.style.left = format.borderWidth + "px"; + corner.style.backgroundPosition = "-" + (bottomHeight + format.borderWidth) + "px -" + (format.height + (bottomHeight + format.borderWidth)) + "px"; + break; + } + } + } else { + var corner = document.createElement("div"); + corner.style.height = options.radii[cc] + "px"; + corner.style.width = options.radii[cc] + "px"; + corner.style.position = "absolute"; + corner.style.fontSize = "1px"; + corner.style.overflow = "hidden"; + var borderRadius = Math.floor(options.radii[cc] - format.borderWidth); + for (var x = 0, j = options.radii[cc]; x < j; x++) { + var y1 = Math.floor(Math.sqrt(Math.pow(borderRadius, 2) - Math.pow((x + 1), 2))) - 1; + if ((x + 1) >= borderRadius) { + var y1 = -1; + } + var y2 = Math.ceil(Math.sqrt(Math.pow(borderRadius, 2) - Math.pow(x, 2))); + if (x >= borderRadius) { + y2 = -1; + } + var y3 = Math.floor(Math.sqrt(Math.pow(j, 2) - Math.pow((x + 1), 2))) - 1; + if ((x + 1) >= j) { + y3 = -1; + } + var y4 = Math.ceil(Math.sqrt(Math.pow(j, 2) - Math.pow(x, 2))); + if (x >= j) { + y4 = -1; + } + if (y1 > -1) { + fns.draw(x, 0, format.color, 100, (y1 + 1), corner, -1, j, topHeight, format); + } + for (var y = (y1 + 1); y < y2; y++) { + if (options.antiAlias) { + if (format.bgImage != "") { + var fract = fns.fraction(x, y, borderRadius) * 100; + if (fract < 30) { + fns.draw(x, y, format.borderColor, 100, 1, corner, 0, options.radii[cc], topHeight, format); + } else { + fns.draw(x, y, format.borderColor, 100, 1, corner, -1, options.radii[cc], topHeight, format); + } + } else { + var clr = fns.blend(format.color, format.borderColor, fns.fraction(x, y, borderRadius)); + fns.draw(x, y, clr, 100, 1, corner, 0, options.radii[cc], topHeight, format); + } + } + } + if (options.antiAlias) { + if (y3 >= y2) { + if (y2 == -1) { + y2 = 0; + } + fns.draw(x, y2, format.borderColor, 100, (y3 - y2 + 1), corner, 0, 0, topHeight, format); + } else { + if (y3 >= y1) { + fns.draw(x, (y1 + 1), format.borderColor, 100, (y3 - y1), corner, 0, 0, topHeight, format); + } + } + for (var y = (y3 + 1); y < y4; y++) { + fns.draw(x, y, format.borderColor, (fns.fraction(x, y, j) * 100), 1, corner, (format.borderWidth > 0 ? 0 : -1), options.radii[cc], topHeight, format); + } + } else { + y3 = y1; + } + } + if (cc != "br") { + for (var t = 0, k = corner.childNodes.length; t < k; t++) { + var bar = corner.childNodes[t]; + var barTop = parseInt(dojo.html.getComputedStyle(bar, "top")); + var barLeft = parseInt(dojo.html.getComputedStyle(bar, "left")); + var barHeight = parseInt(dojo.html.getComputedStyle(bar, "height")); + if (cc.charAt(1) == "l") { + bar.style.left = (options.radii[cc] - barLeft - 1) + "px"; + } + if (cc == "tr") { + bar.style.top = (options.radii[cc] - barHeight - barTop) + "px"; + bar.style.backgroundPosition = "-" + Math.abs((format.width - options.radii[cc] + format.borderWidth) + barLeft) + "px -" + Math.abs(options.radii[cc] - barHeight - barTop - format.borderWidth) + "px"; + } else { + if (cc == "tl") { + bar.style.top = (options.radii[cc] - barHeight - barTop) + "px"; + bar.style.backgroundPosition = "-" + Math.abs((options.radii[cc] - barLeft - 1) - format.borderWidth) + "px -" + Math.abs(options.radii[cc] - barHeight - barTop - format.borderWidth) + "px"; + } else { + bar.style.backgroundPosition = "-" + Math.abs((options.radii[cc] + barLeft) + format.borderWidth) + "px -" + Math.abs((format.height + options.radii[cc] + barTop) - format.borderWidth) + "px"; + } + } + } + } + } + if (corner) { + var psn = []; + if (cc.charAt(0) == "t") { + psn.push("top"); + } else { + psn.push("bottom"); + } + if (cc.charAt(1) == "l") { + psn.push("left"); + } else { + psn.push("right"); + } + if (corner.style.position == "absolute") { + for (var z = 0; z < psn.length; z++) { + corner.style[psn[z]] = "0px"; + } + } + if (psn[0] == "top") { + if (top) { + top.appendChild(corner); + } + } else { + if (bottom) { + bottom.appendChild(corner); + } + } + } + } + var diff = {t:Math.abs(options.radii.tl - options.radii.tr), b:Math.abs(options.radii.bl - options.radii.br)}; + for (var z in diff) { + var smaller = (options.radii[z + "l"] < options.radii[z + "r"] ? z + "l" : z + "r"); + var filler = document.createElement("div"); + filler.style.height = diff[z] + "px"; + filler.style.width = options.radii[smaller] + "px"; + filler.style.position = "absolute"; + filler.style.fontSize = "1px"; + filler.style.overflow = "hidden"; + filler.style.backgroundColor = format.color; + switch (smaller) { + case "tl": + filler.style.bottom = "0px"; + filler.style.left = "0px"; + filler.style.borderLeft = format.borderString; + top.appendChild(filler); + break; + case "tr": + filler.style.bottom = "0px"; + filler.style.right = "0px"; + filler.style.borderRight = format.borderString; + top.appendChild(filler); + break; + case "bl": + filler.style.top = "0px"; + filler.style.left = "0px"; + filler.style.borderLeft = format.borderString; + bottom.appendChild(filler); + break; + case "br": + filler.style.top = "0px"; + filler.style.right = "0px"; + filler.style.borderRight = format.borderString; + bottom.appendChild(filler); + break; + } + var fillBar = document.createElement("div"); + fillBar.style.position = "relative"; + fillBar.style.fontSize = "1px"; + fillBar.style.overflow = "hidden"; + fillBar.style.backgroundColor = format.color; + fillBar.style.backgroundImage = format.bgImage; + if (z == "t") { + if (top) { + if (options.radii.tl && options.radii.tr) { + fillBar.style.height = (topHeight - format.borderWidth) + "px"; + fillBar.style.marginLeft = (options.radii.tl - format.borderWidth) + "px"; + fillBar.style.marginRight = (options.radii.tr - format.borderWidth) + "px"; + fillBar.style.borderTop = format.borderString; + if (format.bgImage != "") { + fillBar.style.backgroundPosition = "-" + (topHeight + format.borderWidth) + "px 0px"; + } + } + top.appendChild(fillBar); + } + } else { + if (bottom) { + if (options.radii.bl && options.radii.br) { + fillBar.style.height = (bottomHeight - format.borderWidth) + "px"; + fillBar.style.marginLeft = (options.radii.bl - format.borderWidth) + "px"; + fillBar.style.marginRight = (options.radii.br - format.borderWidth) + "px"; + fillBar.style.borderBottom = format.borderString; + if (format.bgImage != "") { + fillBar.style.backgroundPosition = "-" + (bottomHeight + format.borderWidth) + "px -" + (format.height + (topHeight + format.borderWidth)) + "px"; + } + } + bottom.appendChild(fillBar); + } + } + } + if (options.autoPad && format.padding > 0) { + var content = document.createElement("div"); + content.style.position = "relative"; + content.innerHTML = format.content; + content.className = "autoPadDiv"; + if (topHeight < format.padding) { + content.style.paddingTop = Math.abs(topHeight - format.padding) + "px"; + } + if (bottomHeight < format.padding) { + content.style.paddingBottom = Math.abs(bottomHeight - format.padding) + "px"; + } + content.style.paddingLeft = format.padding + "px"; + content.style.paddingRight = format.padding + "px"; + node.appendChild(content); + } +}; +var count = 0; +dojo.lfx.rounded._fns = {blend:function (clr1, clr2, frac) { + var c1 = {r:parseInt(clr1.substr(1, 2), 16), g:parseInt(clr1.substr(3, 2), 16), b:parseInt(clr1.substr(5, 2), 16)}; + var c2 = {r:parseInt(clr2.substr(1, 2), 16), g:parseInt(clr2.substr(3, 2), 16), b:parseInt(clr2.substr(5, 2), 16)}; + if (frac > 1 || frac < 0) { + frac = 1; + } + var ret = [Math.min(Math.max(Math.round((c1.r * frac) + (c2.r * (1 - frac))), 0), 255), Math.min(Math.max(Math.round((c1.g * frac) + (c2.g * (1 - frac))), 0), 255), Math.min(Math.max(Math.round((c1.b * frac) + (c2.b * (1 - frac))), 0), 255)]; + for (var i = 0; i < ret.length; i++) { + var n = ret[i].toString(16); + if (n.length < 2) { + n = "0" + n; + } + ret[i] = n; + } + return "#" + ret.join(""); +}, fraction:function (x, y, r) { + var frac = 0; + var xval = []; + var yval = []; + var point = 0; + var whatsides = ""; + var intersect = Math.sqrt((Math.pow(r, 2) - Math.pow(x, 2))); + if (intersect >= y && intersect < (y + 1)) { + whatsides = "Left"; + xval[point] = 0; + yval[point++] = intersect - y; + } + intersect = Math.sqrt((Math.pow(r, 2) - Math.pow(y + 1, 2))); + if (intersect >= x && intersect < (x + 1)) { + whatsides += "Top"; + xval[point] = intersect - x; + yval[point++] = 1; + } + intersect = Math.sqrt((Math.pow(r, 2) - Math.pow(x + 1, 2))); + if (intersect >= y && intersect < (y + 1)) { + whatsides += "Right"; + xval[point] = 1; + yval[point++] = intersect - y; + } + intersect = Math.sqrt((Math.pow(r, 2) - Math.pow(y, 2))); + if (intersect >= x && intersect < (x + 1)) { + whatsides += "Bottom"; + xval[point] = intersect - x; + yval[point] = 1; + } + switch (whatsides) { + case "LeftRight": + return Math.min(yval[0], yval[1]) + ((Math.max(yval[0], yval[1]) - Math.min(yval[0], yval[1])) / 2); + case "TopRight": + return 1 - (((1 - xval[0]) * (1 - yval[1])) / 2); + case "TopBottom": + return Math.min(xval[0], xval[1]) + ((Math.max(xval[0], xval[1]) - Math.min(xval[0], xval[1])) / 2); + case "LeftBottom": + return (yval[0] * xval[1]) / 2; + default: + return 1; + } +}, draw:function (x, y, color, opac, height, corner, image, radius, top, format) { + var px = document.createElement("div"); + px.style.height = height + "px"; + px.style.width = "1px"; + px.style.position = "absolute"; + px.style.fontSize = "1px"; + px.style.overflow = "hidden"; + if (image == -1 && format.bgImage != "") { + px.style.backgroundImage = format.bgImage; + px.style.backgroundPosition = "-" + (format.width - (radius - x) + format.borderWidth) + "px -" + ((format.height + top + y) - format.borderWidth) + "px"; + } else { + px.style.backgroundColor = color; + } + if (opac != 100) { + dojo.html.setOpacity(px, (opac / 100)); + } + px.style.top = y + "px"; + px.style.left = x + "px"; + corner.appendChild(px); +}, getRGB:function (clr) { + var ret = "#ffffff"; + if (clr != "" && clr != "transparent") { + if (clr.substr(0, 3) == "rgb") { + var t = clr.substring(4, clr.indexOf(")")); + t = t.split(","); + for (var i = 0; i < t.length; i++) { + var n = parseInt(t[i]).toString(16); + if (n.length < 2) { + n = "0" + n; + } + t[i] = n; + } + ret = "#" + t.join(""); + } else { + if (clr.length == 4) { + ret = "#" + clr.substring(1, 2) + clr.substring(1, 2) + clr.substring(2, 3) + clr.substring(2, 3) + clr.substring(3, 4) + clr.substring(3, 4); + } else { + ret = clr; + } + } + } + return ret; +}}; + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lfx/shadow.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lfx/shadow.js index 75b2fb1a7..d00311ebc 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lfx/shadow.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lfx/shadow.js @@ -9,78 +9,65 @@ */ dojo.provide("dojo.lfx.shadow"); - dojo.require("dojo.lang.common"); dojo.require("dojo.uri.Uri"); - -dojo.lfx.shadow = function(/* HTMLElement */node) { - // summary - // creates a shadow underneath node. - this.shadowPng = dojo.uri.dojoUri("src/html/images/shadow"); +dojo.lfx.shadow = function (node) { + this.shadowPng = dojo.uri.moduleUri("dojo.html", "images/shadow"); this.shadowThickness = 8; this.shadowOffset = 15; this.init(node); -} - -dojo.extend(dojo.lfx.shadow, { - init: function(/* HTMLElement */node){ - // summary - // Initializes the shadow. - this.node=node; - - // make all the pieces of the shadow, and position/size them as much - // as possible (but a lot of the coordinates are set in sizeShadow - this.pieces={}; - var x1 = -1 * this.shadowThickness; - var y0 = this.shadowOffset; - var y1 = this.shadowOffset + this.shadowThickness; - this._makePiece("tl", "top", y0, "left", x1); - this._makePiece("l", "top", y1, "left", x1, "scale"); - this._makePiece("tr", "top", y0, "left", 0); - this._makePiece("r", "top", y1, "left", 0, "scale"); - this._makePiece("bl", "top", 0, "left", x1); - this._makePiece("b", "top", 0, "left", 0, "crop"); - this._makePiece("br", "top", 0, "left", 0); - }, - - _makePiece: function(name, vertAttach, vertCoord, horzAttach, horzCoord, sizing){ - var img; - var url = this.shadowPng + name.toUpperCase() + ".png"; - if(dojo.render.html.ie55 || dojo.render.html.ie60){ - img=dojo.doc().createElement("div"); - img.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+url+"'"+ - (sizing?", sizingMethod='"+sizing+"'":"") + ")"; - }else{ - img=dojo.doc().createElement("img"); - img.src=url; - } - img.style.position="absolute"; - img.style[vertAttach]=vertCoord+"px"; - img.style[horzAttach]=horzCoord+"px"; - img.style.width=this.shadowThickness+"px"; - img.style.height=this.shadowThickness+"px"; - this.pieces[name]=img; - this.node.appendChild(img); - }, - - size: function(/* int */width, /* int */height){ - // summary - // Resizes the shadow based on width and height. - var sideHeight = height - (this.shadowOffset+this.shadowThickness+1); - if (sideHeight < 0) { sideHeight = 0; } - if (height < 1) { height = 1; } - if (width < 1) { width = 1; } - with(this.pieces){ - l.style.height = sideHeight+"px"; - r.style.height = sideHeight+"px"; - b.style.width = (width-1)+"px"; - bl.style.top = (height-1)+"px"; - b.style.top = (height-1)+"px"; - br.style.top = (height-1)+"px"; - tr.style.left = (width-1)+"px"; - r.style.left = (width-1)+"px"; - br.style.left = (width-1)+"px"; - } +}; +dojo.extend(dojo.lfx.shadow, {init:function (node) { + this.node = node; + this.pieces = {}; + var x1 = -1 * this.shadowThickness; + var y0 = this.shadowOffset; + var y1 = this.shadowOffset + this.shadowThickness; + this._makePiece("tl", "top", y0, "left", x1); + this._makePiece("l", "top", y1, "left", x1, "scale"); + this._makePiece("tr", "top", y0, "left", 0); + this._makePiece("r", "top", y1, "left", 0, "scale"); + this._makePiece("bl", "top", 0, "left", x1); + this._makePiece("b", "top", 0, "left", 0, "crop"); + this._makePiece("br", "top", 0, "left", 0); +}, _makePiece:function (name, vertAttach, vertCoord, horzAttach, horzCoord, sizing) { + var img; + var url = this.shadowPng + name.toUpperCase() + ".png"; + if (dojo.render.html.ie55 || dojo.render.html.ie60) { + img = dojo.doc().createElement("div"); + img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + url + "'" + (sizing ? ", sizingMethod='" + sizing + "'" : "") + ")"; + } else { + img = dojo.doc().createElement("img"); + img.src = url; } -}); + img.style.position = "absolute"; + img.style[vertAttach] = vertCoord + "px"; + img.style[horzAttach] = horzCoord + "px"; + img.style.width = this.shadowThickness + "px"; + img.style.height = this.shadowThickness + "px"; + this.pieces[name] = img; + this.node.appendChild(img); +}, size:function (width, height) { + var sideHeight = height - (this.shadowOffset + this.shadowThickness + 1); + if (sideHeight < 0) { + sideHeight = 0; + } + if (height < 1) { + height = 1; + } + if (width < 1) { + width = 1; + } + with (this.pieces) { + l.style.height = sideHeight + "px"; + r.style.height = sideHeight + "px"; + b.style.width = (width - 1) + "px"; + bl.style.top = (height - 1) + "px"; + b.style.top = (height - 1) + "px"; + br.style.top = (height - 1) + "px"; + tr.style.left = (width - 1) + "px"; + r.style.left = (width - 1) + "px"; + br.style.left = (width - 1) + "px"; + } +}}); diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lfx/toggle.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lfx/toggle.js index 45fdf739d..47937e056 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lfx/toggle.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/lfx/toggle.js @@ -10,45 +10,30 @@ dojo.provide("dojo.lfx.toggle"); dojo.require("dojo.lfx.*"); - -dojo.lfx.toggle.plain = { - show: function(node, duration, easing, callback){ - dojo.html.show(node); - if(dojo.lang.isFunction(callback)){ callback(); } - }, - - hide: function(node, duration, easing, callback){ - dojo.html.hide(node); - if(dojo.lang.isFunction(callback)){ callback(); } +dojo.lfx.toggle.plain = {show:function (node, duration, easing, callback) { + dojo.html.show(node); + if (dojo.lang.isFunction(callback)) { + callback(); } -} - -dojo.lfx.toggle.fade = { - show: function(node, duration, easing, callback){ - dojo.lfx.fadeShow(node, duration, easing, callback).play(); - }, - - hide: function(node, duration, easing, callback){ - dojo.lfx.fadeHide(node, duration, easing, callback).play(); +}, hide:function (node, duration, easing, callback) { + dojo.html.hide(node); + if (dojo.lang.isFunction(callback)) { + callback(); } -} +}}; +dojo.lfx.toggle.fade = {show:function (node, duration, easing, callback) { + dojo.lfx.fadeShow(node, duration, easing, callback).play(); +}, hide:function (node, duration, easing, callback) { + dojo.lfx.fadeHide(node, duration, easing, callback).play(); +}}; +dojo.lfx.toggle.wipe = {show:function (node, duration, easing, callback) { + dojo.lfx.wipeIn(node, duration, easing, callback).play(); +}, hide:function (node, duration, easing, callback) { + dojo.lfx.wipeOut(node, duration, easing, callback).play(); +}}; +dojo.lfx.toggle.explode = {show:function (node, duration, easing, callback, explodeSrc) { + dojo.lfx.explode(explodeSrc || {x:0, y:0, width:0, height:0}, node, duration, easing, callback).play(); +}, hide:function (node, duration, easing, callback, explodeSrc) { + dojo.lfx.implode(node, explodeSrc || {x:0, y:0, width:0, height:0}, duration, easing, callback).play(); +}}; -dojo.lfx.toggle.wipe = { - show: function(node, duration, easing, callback){ - dojo.lfx.wipeIn(node, duration, easing, callback).play(); - }, - - hide: function(node, duration, easing, callback){ - dojo.lfx.wipeOut(node, duration, easing, callback).play(); - } -} - -dojo.lfx.toggle.explode = { - show: function(node, duration, easing, callback, explodeSrc){ - dojo.lfx.explode(explodeSrc||{x:0,y:0,width:0,height:0}, node, duration, easing, callback).play(); - }, - - hide: function(node, duration, easing, callback, explodeSrc){ - dojo.lfx.implode(node, explodeSrc||{x:0,y:0,width:0,height:0}, duration, easing, callback).play(); - } -} diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/loader.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/loader.js index 2eca9ed60..1ccc3e2c0 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/loader.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/loader.js @@ -8,720 +8,439 @@ http://dojotoolkit.org/community/licensing.shtml */ -/* - * loader.js - A bootstrap module. Runs before the hostenv_*.js file. Contains all of the package loading methods. - */ - -//A semi-colon is at the start of the line because after doing a build, this function definition -//get compressed onto the same line as the last line in bootstrap1.js. That list line is just a -//curly bracket, and the browser complains about that syntax. The semicolon fixes it. Putting it -//here instead of at the end of bootstrap1.js, since it is more of an issue for this file, (using -//the closure), and bootstrap1.js could change in the future. -;(function(){ - //Additional properties for dojo.hostenv - var _addHostEnv = { - pkgFileName: "__package__", - - // for recursion protection - loading_modules_: {}, - loaded_modules_: {}, - addedToLoadingCount: [], - removedFromLoadingCount: [], - - inFlightCount: 0, - - // FIXME: it should be possible to pull module prefixes in from djConfig - modulePrefixes_: { - dojo: {name: "dojo", value: "src"} - }, - - setModulePrefix: function(/*String*/module, /*String*/prefix){ - // summary: establishes module/prefix pair - this.modulePrefixes_[module] = {name: module, value: prefix}; - }, - - moduleHasPrefix: function(/*String*/module){ - // summary: checks to see if module has been established - var mp = this.modulePrefixes_; - return Boolean(mp[module] && mp[module].value); // Boolean - }, - - getModulePrefix: function(/*String*/module){ - // summary: gets the prefix associated with module - if(this.moduleHasPrefix(module)){ - return this.modulePrefixes_[module].value; // String - } - return module; // String - }, - - getTextStack: [], - loadUriStack: [], - loadedUris: [], - - //WARNING: This variable is referenced by packages outside of bootstrap: FloatingPane.js and undo/browser.js - post_load_: false, - - //Egad! Lots of test files push on this directly instead of using dojo.addOnLoad. - modulesLoadedListeners: [], - unloadListeners: [], - loadNotifying: false - }; - - //Add all of these properties to dojo.hostenv - for(var param in _addHostEnv){ +(function () { + var _addHostEnv = {pkgFileName:"__package__", loading_modules_:{}, loaded_modules_:{}, addedToLoadingCount:[], removedFromLoadingCount:[], inFlightCount:0, modulePrefixes_:{dojo:{name:"dojo", value:"src"}}, setModulePrefix:function (module, prefix) { + this.modulePrefixes_[module] = {name:module, value:prefix}; + }, moduleHasPrefix:function (module) { + var mp = this.modulePrefixes_; + return Boolean(mp[module] && mp[module].value); + }, getModulePrefix:function (module) { + if (this.moduleHasPrefix(module)) { + return this.modulePrefixes_[module].value; + } + return module; + }, getTextStack:[], loadUriStack:[], loadedUris:[], post_load_:false, modulesLoadedListeners:[], unloadListeners:[], loadNotifying:false}; + for (var param in _addHostEnv) { dojo.hostenv[param] = _addHostEnv[param]; } })(); - -dojo.hostenv.loadPath = function(/*String*/relpath, /*String?*/module, /*Function?*/cb){ -// summary: -// Load a Javascript module given a relative path -// -// description: -// Loads and interprets the script located at relpath, which is relative to the -// script root directory. If the script is found but its interpretation causes -// a runtime exception, that exception is not caught by us, so the caller will -// see it. We return a true value if and only if the script is found. -// -// For now, we do not have an implementation of a true search path. We -// consider only the single base script uri, as returned by getBaseScriptUri(). -// -// relpath: A relative path to a script (no leading '/', and typically -// ending in '.js'). -// module: A module whose existance to check for after loading a path. -// Can be used to determine success or failure of the load. -// cb: a callback function to pass the result of evaluating the script - +dojo.hostenv.loadPath = function (relpath, module, cb) { var uri; - if(relpath.charAt(0) == '/' || relpath.match(/^\w+:/)){ - // dojo.raise("relpath '" + relpath + "'; must be relative"); + if (relpath.charAt(0) == "/" || relpath.match(/^\w+:/)) { uri = relpath; - }else{ + } else { uri = this.getBaseScriptUri() + relpath; } - if(djConfig.cacheBust && dojo.render.html.capable){ - uri += "?" + String(djConfig.cacheBust).replace(/\W+/g,""); + if (djConfig.cacheBust && dojo.render.html.capable) { + uri += "?" + String(djConfig.cacheBust).replace(/\W+/g, ""); } - try{ - return !module ? this.loadUri(uri, cb) : this.loadUriAndCheck(uri, module, cb); // Boolean - }catch(e){ + try { + return !module ? this.loadUri(uri, cb) : this.loadUriAndCheck(uri, module, cb); + } + catch (e) { dojo.debug(e); - return false; // Boolean + return false; } -} - -dojo.hostenv.loadUri = function(/*String (URL)*/uri, /*Function?*/cb){ -// summary: -// Loads JavaScript from a URI -// -// description: -// Reads the contents of the URI, and evaluates the contents. This is used to load modules as well -// as resource bundles. Returns true if it succeeded. Returns false if the URI reading failed. -// Throws if the evaluation throws. -// -// uri: a uri which points at the script to be loaded -// cb: a callback function to process the result of evaluating the script as an expression, typically -// used by the resource bundle loader to load JSON-style resources - - if(this.loadedUris[uri]){ - return true; // Boolean +}; +dojo.hostenv.loadUri = function (uri, cb) { + if (this.loadedUris[uri]) { + return true; } var contents = this.getText(uri, null, true); - if(!contents){ return false; } // Boolean + if (!contents) { + return false; + } this.loadedUris[uri] = true; - if(cb){ contents = '('+contents+')'; } + if (cb) { + contents = "(" + contents + ")"; + } var value = dj_eval(contents); - if(cb){ cb(value); } - return true; // Boolean -} - -// FIXME: probably need to add logging to this method -dojo.hostenv.loadUriAndCheck = function(/*String (URL)*/uri, /*String*/moduleName, /*Function?*/cb){ - // summary: calls loadUri then findModule and returns true if both succeed + if (cb) { + cb(value); + } + return true; +}; +dojo.hostenv.loadUriAndCheck = function (uri, moduleName, cb) { var ok = true; - try{ + try { ok = this.loadUri(uri, cb); - }catch(e){ + } + catch (e) { dojo.debug("failed loading ", uri, " with error: ", e); } - return Boolean(ok && this.findModule(moduleName, false)); // Boolean -} - -dojo.loaded = function(){ } -dojo.unloaded = function(){ } - -dojo.hostenv.loaded = function(){ + return Boolean(ok && this.findModule(moduleName, false)); +}; +dojo.loaded = function () { +}; +dojo.unloaded = function () { +}; +dojo.hostenv.loaded = function () { this.loadNotifying = true; this.post_load_ = true; var mll = this.modulesLoadedListeners; - for(var x=0; x 1) { - dh.modulesLoadedListeners.push(function() { - obj[functionName](); - }); + } else { + if (arguments.length > 1) { + dh.modulesLoadedListeners.push(function () { + obj[functionName](); + }); + } } - - //Added for xdomain loading. dojo.addOnLoad is used to - //indicate callbacks after doing some dojo.require() statements. - //In the xdomain case, if all the requires are loaded (after initial - //page load), then immediately call any listeners. - if(dh.post_load_ && dh.inFlightCount == 0 && !dh.loadNotifying){ + if (dh.post_load_ && dh.inFlightCount == 0 && !dh.loadNotifying) { dh.callLoaded(); } -} - -dojo.addOnUnload = function(/*Object?*/obj, /*String|Function?*/functionName){ -// summary: registers a function to be triggered when the page unloads -// -// usage: -// dojo.addOnLoad(functionPointer) -// dojo.addOnLoad(object, "functionName") +}; +dojo.addOnUnload = function (obj, functionName) { var dh = dojo.hostenv; - if(arguments.length == 1){ + if (arguments.length == 1) { dh.unloadListeners.push(obj); - } else if(arguments.length > 1) { - dh.unloadListeners.push(function() { - obj[functionName](); - }); + } else { + if (arguments.length > 1) { + dh.unloadListeners.push(function () { + obj[functionName](); + }); + } } -} - -dojo.hostenv.modulesLoaded = function(){ - if(this.post_load_){ return; } - if(this.loadUriStack.length==0 && this.getTextStack.length==0){ - if(this.inFlightCount > 0){ +}; +dojo.hostenv.modulesLoaded = function () { + if (this.post_load_) { + return; + } + if (this.loadUriStack.length == 0 && this.getTextStack.length == 0) { + if (this.inFlightCount > 0) { dojo.debug("files still in flight!"); return; } dojo.hostenv.callLoaded(); } -} - -dojo.hostenv.callLoaded = function(){ - if(typeof setTimeout == "object"){ +}; +dojo.hostenv.callLoaded = function () { + if (typeof setTimeout == "object" || (djConfig["useXDomain"] && dojo.render.html.opera)) { setTimeout("dojo.hostenv.loaded();", 0); - }else{ + } else { dojo.hostenv.loaded(); } -} - -dojo.hostenv.getModuleSymbols = function(/*String*/modulename){ -// summary: -// Converts a module name in dotted JS notation to an array representing the path in the source tree - +}; +dojo.hostenv.getModuleSymbols = function (modulename) { var syms = modulename.split("."); - for(var i = syms.length; i>0; i--){ + for (var i = syms.length; i > 0; i--) { var parentModule = syms.slice(0, i).join("."); - if ((i==1) && !this.moduleHasPrefix(parentModule)){ - //Support default module directory (sibling of dojo) + if ((i == 1) && !this.moduleHasPrefix(parentModule)) { syms[0] = "../" + syms[0]; - }else{ + } else { var parentModulePath = this.getModulePrefix(parentModule); - if(parentModulePath != parentModule){ + if (parentModulePath != parentModule) { syms.splice(0, i, parentModulePath); break; } } } - return syms; // Array -} - + return syms; +}; dojo.hostenv._global_omit_module_check = false; -dojo.hostenv.loadModule = function(/*String*/moduleName, /*Boolean?*/exactOnly, /*Boolean?*/omitModuleCheck){ -// summary: -// loads a Javascript module from the appropriate URI -// -// description: -// loadModule("A.B") first checks to see if symbol A.B is defined. -// If it is, it is simply returned (nothing to do). -// -// If it is not defined, it will look for "A/B.js" in the script root directory, -// followed by "A.js". -// -// It throws if it cannot find a file to load, or if the symbol A.B is not -// defined after loading. -// -// It returns the object A.B. -// -// This does nothing about importing symbols into the current package. -// It is presumed that the caller will take care of that. For example, to import -// all symbols: -// -// with (dojo.hostenv.loadModule("A.B")) { -// ... -// } -// -// And to import just the leaf symbol: -// -// var B = dojo.hostenv.loadModule("A.B"); -// ... -// -// dj_load is an alias for dojo.hostenv.loadModule - - if(!moduleName){ return; } +dojo.hostenv.loadModule = function (moduleName, exactOnly, omitModuleCheck) { + if (!moduleName) { + return; + } omitModuleCheck = this._global_omit_module_check || omitModuleCheck; var module = this.findModule(moduleName, false); - if(module){ + if (module) { return module; } - - // protect against infinite recursion from mutual dependencies - if(dj_undef(moduleName, this.loading_modules_)){ + if (dj_undef(moduleName, this.loading_modules_)) { this.addedToLoadingCount.push(moduleName); } this.loading_modules_[moduleName] = 1; - - // convert periods to slashes - var relpath = moduleName.replace(/\./g, '/') + '.js'; - + var relpath = moduleName.replace(/\./g, "/") + ".js"; var nsyms = moduleName.split("."); - - // this line allowed loading of a module manifest as if it were a namespace - // it's an interesting idea, but shouldn't be combined with 'namespaces' proper - // and leads to unwanted dependencies - // the effect can be achieved in other (albeit less-flexible) ways now, so I am - // removing this pending further design work - // perhaps we can explicitly define this idea of a 'module manifest', and subclass - // 'namespace manifest' from that - //dojo.getNamespace(nsyms[0]); - var syms = this.getModuleSymbols(moduleName); - var startedRelative = ((syms[0].charAt(0) != '/') && !syms[0].match(/^\w+:/)); + var startedRelative = ((syms[0].charAt(0) != "/") && !syms[0].match(/^\w+:/)); var last = syms[syms.length - 1]; var ok; - // figure out if we're looking for a full package, if so, we want to do - // things slightly diffrently - if(last=="*"){ - moduleName = nsyms.slice(0, -1).join('.'); - while(syms.length){ + if (last == "*") { + moduleName = nsyms.slice(0, -1).join("."); + while (syms.length) { syms.pop(); syms.push(this.pkgFileName); - relpath = syms.join("/") + '.js'; - if(startedRelative && relpath.charAt(0)=="/"){ + relpath = syms.join("/") + ".js"; + if (startedRelative && relpath.charAt(0) == "/") { relpath = relpath.slice(1); } ok = this.loadPath(relpath, !omitModuleCheck ? moduleName : null); - if(ok){ break; } + if (ok) { + break; + } syms.pop(); } - }else{ - relpath = syms.join("/") + '.js'; - moduleName = nsyms.join('.'); + } else { + relpath = syms.join("/") + ".js"; + moduleName = nsyms.join("."); var modArg = !omitModuleCheck ? moduleName : null; ok = this.loadPath(relpath, modArg); - if(!ok && !exactOnly){ + if (!ok && !exactOnly) { syms.pop(); - while(syms.length){ - relpath = syms.join('/') + '.js'; + while (syms.length) { + relpath = syms.join("/") + ".js"; ok = this.loadPath(relpath, modArg); - if(ok){ break; } + if (ok) { + break; + } syms.pop(); - relpath = syms.join('/') + '/'+this.pkgFileName+'.js'; - if(startedRelative && relpath.charAt(0)=="/"){ + relpath = syms.join("/") + "/" + this.pkgFileName + ".js"; + if (startedRelative && relpath.charAt(0) == "/") { relpath = relpath.slice(1); } ok = this.loadPath(relpath, modArg); - if(ok){ break; } + if (ok) { + break; + } } } - - if(!ok && !omitModuleCheck){ + if (!ok && !omitModuleCheck) { dojo.raise("Could not load '" + moduleName + "'; last tried '" + relpath + "'"); } } - - // check that the symbol was defined - //Don't bother if we're doing xdomain (asynchronous) loading. - if(!omitModuleCheck && !this["isXDomain"]){ - // pass in false so we can give better error + if (!omitModuleCheck && !this["isXDomain"]) { module = this.findModule(moduleName, false); - if(!module){ - dojo.raise("symbol '" + moduleName + "' is not defined after loading '" + relpath + "'"); + if (!module) { + dojo.raise("symbol '" + moduleName + "' is not defined after loading '" + relpath + "'"); } } - return module; -} - -dojo.hostenv.startPackage = function(/*String*/packageName){ -// summary: -// Creates a JavaScript package -// -// description: -// startPackage("A.B") follows the path, and at each level creates a new empty -// object or uses what already exists. It returns the result. -// -// packageName: the package to be created as a String in dot notation - - //Make sure we have a string. +}; +dojo.hostenv.startPackage = function (packageName) { var fullPkgName = String(packageName); var strippedPkgName = fullPkgName; - var syms = packageName.split(/\./); - if(syms[syms.length-1]=="*"){ + if (syms[syms.length - 1] == "*") { syms.pop(); strippedPkgName = syms.join("."); } var evaledPkg = dojo.evalObjPath(strippedPkgName, true); this.loaded_modules_[fullPkgName] = evaledPkg; this.loaded_modules_[strippedPkgName] = evaledPkg; - - return evaledPkg; // Object -} - -dojo.hostenv.findModule = function(/*String*/moduleName, /*Boolean?*/mustExist){ -// summary: -// Returns the Object representing the module, if it exists, otherwise null. -// -// moduleName A fully qualified module including package name, like 'A.B'. -// mustExist Optional, default false. throw instead of returning null -// if the module does not currently exist. - + return evaledPkg; +}; +dojo.hostenv.findModule = function (moduleName, mustExist) { var lmn = String(moduleName); - - if(this.loaded_modules_[lmn]){ - return this.loaded_modules_[lmn]; // Object + if (this.loaded_modules_[lmn]) { + return this.loaded_modules_[lmn]; } - - if(mustExist){ + if (mustExist) { dojo.raise("no loaded module named '" + moduleName + "'"); } - return null; // null -} - -//Start of old bootstrap2: - -dojo.kwCompoundRequire = function(/*Object containing Arrays*/modMap){ -// description: -// This method taks a "map" of arrays which one can use to optionally load dojo -// modules. The map is indexed by the possible dojo.hostenv.name_ values, with -// two additional values: "default" and "common". The items in the "default" -// array will be loaded if none of the other items have been choosen based on -// the hostenv.name_ item. The items in the "common" array will _always_ be -// loaded, regardless of which list is chosen. Here's how it's normally -// called: -// -// dojo.kwCompoundRequire({ -// browser: [ -// ["foo.bar.baz", true, true], // an example that passes multiple args to loadModule() -// "foo.sample.*", -// "foo.test, -// ], -// default: [ "foo.sample.*" ], -// common: [ "really.important.module.*" ] -// }); - - var common = modMap["common"]||[]; - var result = modMap[dojo.hostenv.name_] ? common.concat(modMap[dojo.hostenv.name_]||[]) : common.concat(modMap["default"]||[]); - - for(var x=0; x, - // relative to Dojo root. For example, module acme is mapped to ../acme. - // If you want to use a different module name, use dojo.registerModulePath. +}; +dojo.registerModulePath = function (module, prefix) { return dojo.hostenv.setModulePrefix(module, prefix); +}; +if (djConfig["modulePaths"]) { + for (var param in djConfig["modulePaths"]) { + dojo.registerModulePath(param, djConfig["modulePaths"][param]); + } } - -dojo.setModulePrefix = function(/*String*/module, /*String*/prefix){ - // summary: maps a module name to a path - dojo.deprecated('dojo.setModulePrefix("' + module + '", "' + prefix + '")', "replaced by dojo.registerModulePath", "0.5"); +dojo.setModulePrefix = function (module, prefix) { + dojo.deprecated("dojo.setModulePrefix(\"" + module + "\", \"" + prefix + "\")", "replaced by dojo.registerModulePath", "0.5"); return dojo.registerModulePath(module, prefix); -} - -dojo.exists = function(/*Object*/obj, /*String*/name){ - // summary: determine if an object supports a given method - // description: useful for longer api chains where you have to test each object in the chain +}; +dojo.exists = function (obj, name) { var p = name.split("."); - for(var i = 0; i < p.length; i++){ - if(!obj[p[i]]){ return false; } // Boolean + for (var i = 0; i < p.length; i++) { + if (!obj[p[i]]) { + return false; + } obj = obj[p[i]]; } - return true; // Boolean -} - -// Localization routines - -dojo.hostenv.normalizeLocale = function(/*String?*/locale){ -// summary: -// Returns canonical form of locale, as used by Dojo. All variants are case-insensitive and are separated by '-' -// as specified in RFC 3066. If no locale is specified, the user agent's default is returned. - - return locale ? locale.toLowerCase() : dojo.locale; // String + return true; }; - -dojo.hostenv.searchLocalePath = function(/*String*/locale, /*Boolean*/down, /*Function*/searchFunc){ -// summary: -// A helper method to assist in searching for locale-based resources. Will iterate through -// the variants of a particular locale, either up or down, executing a callback function. -// For example, "en-us" and true will try "en-us" followed by "en" and finally "ROOT". - +dojo.hostenv.normalizeLocale = function (locale) { + var result = locale ? locale.toLowerCase() : dojo.locale; + if (result == "root") { + result = "ROOT"; + } + return result; +}; +dojo.hostenv.searchLocalePath = function (locale, down, searchFunc) { locale = dojo.hostenv.normalizeLocale(locale); - - var elements = locale.split('-'); + var elements = locale.split("-"); var searchlist = []; - for(var i = elements.length; i > 0; i--){ - searchlist.push(elements.slice(0, i).join('-')); + for (var i = elements.length; i > 0; i--) { + searchlist.push(elements.slice(0, i).join("-")); } searchlist.push(false); - if(down){searchlist.reverse();} - - for(var j = searchlist.length - 1; j >= 0; j--){ + if (down) { + searchlist.reverse(); + } + for (var j = searchlist.length - 1; j >= 0; j--) { var loc = searchlist[j] || "ROOT"; var stop = searchFunc(loc); - if(stop){ break; } + if (stop) { + break; + } } -} - -//These two functions are placed outside of preloadLocalizations -//So that the xd loading can use/override them. -dojo.hostenv.localesGenerated /***BUILD:localesGenerated***/; // value will be inserted here at build time, if necessary - -dojo.hostenv.registerNlsPrefix = function(){ -// summary: -// Register module "nls" to point where Dojo can find pre-built localization files - dojo.registerModulePath("nls","nls"); -} - -dojo.hostenv.preloadLocalizations = function(){ -// summary: -// Load built, flattened resource bundles, if available for all locales used in the page. -// Execute only once. Note that this is a no-op unless there is a build. - - if(dojo.hostenv.localesGenerated){ +}; +dojo.hostenv.localesGenerated; +dojo.hostenv.registerNlsPrefix = function () { + dojo.registerModulePath("nls", "nls"); +}; +dojo.hostenv.preloadLocalizations = function () { + if (dojo.hostenv.localesGenerated) { dojo.hostenv.registerNlsPrefix(); - - function preload(locale){ + function preload(locale) { locale = dojo.hostenv.normalizeLocale(locale); - dojo.hostenv.searchLocalePath(locale, true, function(loc){ - for(var i=0; i bestLocale.length) { + bestLocale = flatLocales[i]; + } + } + } + if (!bestLocale) { + bestLocale = "ROOT"; + } + } + var tempLocale = availableFlatLocales ? bestLocale : targetLocale; + var bundle = dojo.hostenv.findModule(bundlePackage); + var localizedBundle = null; + if (bundle) { + if (djConfig.localizationComplete && bundle._built) { + return; + } + var jsLoc = tempLocale.replace("-", "_"); + var translationPackage = bundlePackage + "." + jsLoc; + localizedBundle = dojo.hostenv.findModule(translationPackage); + } + if (!localizedBundle) { + bundle = dojo.hostenv.startPackage(bundlePackage); + var syms = dojo.hostenv.getModuleSymbols(moduleName); + var modpath = syms.concat("nls").join("/"); + var parent; + dojo.hostenv.searchLocalePath(tempLocale, availableFlatLocales, function (loc) { + var jsLoc = loc.replace("-", "_"); + var translationPackage = bundlePackage + "." + jsLoc; + var loaded = false; + if (!dojo.hostenv.findModule(translationPackage)) { + dojo.hostenv.startPackage(translationPackage); + var module = [modpath]; + if (loc != "ROOT") { + module.push(loc); + } + module.push(bundleName); + var filespec = module.join("/") + ".js"; + loaded = dojo.hostenv.loadPath(filespec, null, function (hash) { + var clazz = function () { + }; + clazz.prototype = parent; + bundle[jsLoc] = new clazz(); + for (var j in hash) { + bundle[jsLoc][j] = hash[j]; + } + }); + } else { + loaded = true; + } + if (loaded && bundle[jsLoc]) { + parent = bundle[jsLoc]; + } else { + bundle[jsLoc] = parent; + } + if (availableFlatLocales) { + return true; + } + }); + } + if (availableFlatLocales && targetLocale != bestLocale) { + bundle[targetLocale.replace("-", "_")] = bundle[bestLocale.replace("-", "_")]; + } +}; +(function () { var extra = djConfig.extraLocale; - if(extra){ - if(!extra instanceof Array){ + if (extra) { + if (!extra instanceof Array) { extra = [extra]; } - var req = dojo.requireLocalization; - dojo.requireLocalization = function(m, b, locale){ - req(m,b,locale); - if(locale){return;} - for(var i=0; i 0){ + if (deps.length > 0) { output.push("depends: ["); - for(var i = 0; i < deps.length; i++){ - if(i > 0){ + for (var i = 0; i < deps.length; i++) { + if (i > 0) { output.push(",\n"); } output.push("[" + deps[i] + "]"); } output.push("],"); } - - //Add the contents of the file inside a function. - //Pass in dojo as an argument to the function to help with - //allowing multiple versions of dojo in a page. output.push("\ndefinePackage: function(dojo){"); output.push(contents); - output.push("\n}});"); - + output.push("\n}, resourceName: '" + resourceName + "', resourcePath: '" + resourcePath + "'});"); return output.join(""); -} - -dojo.hostenv.loadPath = function(relpath, module /*optional*/, cb /*optional*/){ - //Only do getBaseScriptUri if path does not start with a URL with a protocol. - //If there is a colon before the first / then, we have a URL with a protocol. +}; +dojo.hostenv.loadPath = function (relpath, module, cb) { var colonIndex = relpath.indexOf(":"); var slashIndex = relpath.indexOf("/"); var uri; var currentIsXDomain = false; - if(colonIndex > 0 && colonIndex < slashIndex){ + if (colonIndex > 0 && colonIndex < slashIndex) { uri = relpath; this.isXDomain = currentIsXDomain = true; - }else{ + } else { uri = this.getBaseScriptUri() + relpath; - - //Is ithe base script URI-based URL a cross domain URL? colonIndex = uri.indexOf(":"); slashIndex = uri.indexOf("/"); - if(colonIndex > 0 && colonIndex < slashIndex && (!location.host || uri.indexOf("http://" + location.host) != 0)){ + if (colonIndex > 0 && colonIndex < slashIndex && (!location.host || uri.indexOf("http://" + location.host) != 0)) { this.isXDomain = currentIsXDomain = true; } } - - if(djConfig.cacheBust && dojo.render.html.capable) { uri += "?" + String(djConfig.cacheBust).replace(/\W+/g,""); } - try{ + if (djConfig.cacheBust && dojo.render.html.capable) { + uri += "?" + String(djConfig.cacheBust).replace(/\W+/g, ""); + } + try { return ((!module || this.isXDomain) ? this.loadUri(uri, cb, currentIsXDomain, module) : this.loadUriAndCheck(uri, module, cb)); - }catch(e){ + } + catch (e) { dojo.debug(e); return false; } -} - -//Overriding loadUri for now. Wanted to override getText(), but it is used by -//the widget code in too many, synchronous ways right now. This means the xd stuff -//is not suitable for widgets yet. -dojo.hostenv.loadUri = function(uri, cb, currentIsXDomain, module){ - if(this.loadedUris[uri]){ +}; +dojo.hostenv.loadUri = function (uri, cb, currentIsXDomain, module) { + if (this.loadedUris[uri]) { return 1; } - - //Add the module (package) to the list of modules. - if(this.isXDomain){ - //Curious: is this array going to get whacked with multiple access since scripts - //load asynchronously and may be accessing the array at the same time? - //JS is single-threaded supposedly, so it should be ok. And we don't need - //a precise ordering. - this.xdOrderedReqs.push(module); - - //Add to waiting packages. - //If this is a __package__.js file, then this must be - //a package.* request (since xdomain can only work with the first - //path in a package search list. However, .* module names are not - //passed to this function, so do an adjustment here. - if(uri.indexOf("__package__") != -1){ + if (this.isXDomain) { + if (uri.indexOf("__package__") != -1) { module += ".*"; } - - this.xdInFlight[module] = true; - - //Increment inFlightCount - //This will stop the modulesLoaded from firing all the way. - this.inFlightCount++; - - //Start timer - if(!this.xdTimer){ + this.xdOrderedReqs.push(module); + if (currentIsXDomain) { + this.xdInFlight[module] = true; + this.inFlightCount++; + } + if (!this.xdTimer) { this.xdTimer = setInterval("dojo.hostenv.watchInFlightXDomain();", 100); } this.xdStartTime = (new Date()).getTime(); } - - if (currentIsXDomain){ - //Fix name to be a .xd.fileextension name. - var lastIndex = uri.lastIndexOf('.'); - if(lastIndex <= 0){ + if (currentIsXDomain) { + var lastIndex = uri.lastIndexOf("."); + if (lastIndex <= 0) { lastIndex = uri.length - 1; } - var xdUri = uri.substring(0, lastIndex) + ".xd"; - if(lastIndex != uri.length - 1){ + if (lastIndex != uri.length - 1) { xdUri += uri.substring(lastIndex, uri.length); } - - //Add to script src var element = document.createElement("script"); element.type = "text/javascript"; element.src = xdUri; - if(!this.headElement){ + if (!this.headElement) { this.headElement = document.getElementsByTagName("head")[0]; + if (!this.headElement) { + this.headElement = document.getElementsByTagName("html")[0]; + } } this.headElement.appendChild(element); - }else{ + } else { var contents = this.getText(uri, null, true); - if(contents == null){ return 0; } - - if(this.isXDomain){ - var pkg = this.createXdPackage(contents); + if (contents == null) { + return 0; + } + if (this.isXDomain && uri.indexOf("/nls/") == -1) { + var pkg = this.createXdPackage(contents, module, uri); dj_eval(pkg); - }else{ - if(cb){ contents = '('+contents+')'; } + } else { + if (cb) { + contents = "(" + contents + ")"; + } var value = dj_eval(contents); - if(cb){ + if (cb) { cb(value); } } } - - //These steps are done in the non-xd loader version of this function. - //Maintain these steps to fit in with the existing system. this.loadedUris[uri] = true; return 1; -} - -dojo.hostenv.packageLoaded = function(pkg){ +}; +dojo.hostenv.packageLoaded = function (pkg) { var deps = pkg.depends; var requireList = null; var requireAfterList = null; var provideList = []; - if(deps && deps.length > 0){ + if (deps && deps.length > 0) { var dep = null; var insertHint = 0; var attachedPackage = false; - for(var i = 0; i < deps.length; i++){ + for (var i = 0; i < deps.length; i++) { dep = deps[i]; - - //Look for specific dependency indicators. - if (dep[0] == "provide" || dep[0] == "hostenv.moduleLoaded"){ + if (dep[0] == "provide" || dep[0] == "hostenv.moduleLoaded") { provideList.push(dep[1]); - }else{ - if(!requireList){ + } else { + if (!requireList) { requireList = []; } - if(!requireAfterList){ + if (!requireAfterList) { requireAfterList = []; } - var unpackedDeps = this.unpackXdDependency(dep); - if(unpackedDeps.requires){ + if (unpackedDeps.requires) { requireList = requireList.concat(unpackedDeps.requires); } - if(unpackedDeps.requiresAfter){ + if (unpackedDeps.requiresAfter) { requireAfterList = requireAfterList.concat(unpackedDeps.requiresAfter); } } - - //Call the dependency indicator to allow for the normal dojo setup. - //Only allow for one dot reference, for the hostenv.* type calls. var depType = dep[0]; var objPath = depType.split("."); - if(objPath.length == 2){ + if (objPath.length == 2) { dojo[objPath[0]][objPath[1]].apply(dojo[objPath[0]], dep.slice(1)); - }else{ + } else { dojo[depType].apply(dojo, dep.slice(1)); } } - - //Save off the package contents for definition later. - var contentIndex = this.xdContents.push({content: pkg.definePackage, isDefined: false}) - 1; - - //Add provide/requires to dependency map. - for(var i = 0; i < provideList.length; i++){ - this.xdDepMap[provideList[i]] = { requires: requireList, requiresAfter: requireAfterList, contentIndex: contentIndex }; + var contentIndex = this.xdContents.push({content:pkg.definePackage, resourceName:pkg["resourceName"], resourcePath:pkg["resourcePath"], isDefined:false}) - 1; + for (var i = 0; i < provideList.length; i++) { + this.xdDepMap[provideList[i]] = {requires:requireList, requiresAfter:requireAfterList, contentIndex:contentIndex}; } - - //Now update the inflight status for any provided packages in this loaded package. - //Do this at the very end (in a *separate* for loop) to avoid shutting down the - //inflight timer check too soon. - for(var i = 0; i < provideList.length; i++){ + for (var i = 0; i < provideList.length; i++) { this.xdInFlight[provideList[i]] = false; } } -} - -//This is a bit brittle: it has to know about the dojo methods that deal with dependencies -//It would be ideal to intercept the actual methods and do something fancy at that point, -//but I have concern about knowing which provide to match to the dependency in that case, -//since scripts can load whenever they want, and trigger new calls to dojo.hostenv.packageLoaded(). -dojo.hostenv.unpackXdDependency = function(dep){ - //Extract the dependency(ies). +}; +dojo.hostenv.xdLoadFlattenedBundle = function (moduleName, bundleName, locale, bundleData) { + locale = locale || "root"; + var jsLoc = dojo.hostenv.normalizeLocale(locale).replace("-", "_"); + var bundlePackage = [moduleName, "nls", bundleName].join("."); + var bundle = dojo.hostenv.startPackage(bundlePackage); + bundle[jsLoc] = bundleData; + var mapName = [moduleName, jsLoc, bundleName].join("."); + var bundleMap = dojo.hostenv.xdBundleMap[mapName]; + if (bundleMap) { + for (var param in bundleMap) { + bundle[param] = bundleData; + } + } +}; +dojo.hostenv.xdBundleMap = {}; +dojo.xdRequireLocalization = function (moduleName, bundleName, locale, availableFlatLocales) { + var locales = availableFlatLocales.split(","); + var jsLoc = dojo.hostenv.normalizeLocale(locale); + var bestLocale = ""; + for (var i = 0; i < locales.length; i++) { + if (jsLoc.indexOf(locales[i]) == 0) { + if (locales[i].length > bestLocale.length) { + bestLocale = locales[i]; + } + } + } + var fixedBestLocale = bestLocale.replace("-", "_"); + var bundlePackage = dojo.evalObjPath([moduleName, "nls", bundleName].join(".")); + if (bundlePackage && bundlePackage[fixedBestLocale]) { + bundle[jsLoc.replace("-", "_")] = bundlePackage[fixedBestLocale]; + } else { + var mapName = [moduleName, (fixedBestLocale || "root"), bundleName].join("."); + var bundleMap = dojo.hostenv.xdBundleMap[mapName]; + if (!bundleMap) { + bundleMap = dojo.hostenv.xdBundleMap[mapName] = {}; + } + bundleMap[jsLoc.replace("-", "_")] = true; + dojo.require(moduleName + ".nls" + (bestLocale ? "." + bestLocale : "") + "." + bundleName); + } +}; +(function () { + var extra = djConfig.extraLocale; + if (extra) { + if (!extra instanceof Array) { + extra = [extra]; + } + dojo._xdReqLoc = dojo.xdRequireLocalization; + dojo.xdRequireLocalization = function (m, b, locale, fLocales) { + dojo._xdReqLoc(m, b, locale, fLocales); + if (locale) { + return; + } + for (var i = 0; i < extra.length; i++) { + dojo._xdReqLoc(m, b, extra[i], fLocales); + } + }; + } +})(); +dojo.hostenv.unpackXdDependency = function (dep) { var newDeps = null; var newAfterDeps = null; - switch(dep[0]){ - case "requireIf": - case "requireAfterIf": - case "conditionalRequire": - //First arg (dep[1]) is the test. Depedency is dep[2]. - if((dep[1] === true)||(dep[1]=="common")||(dep[1] && dojo.render[dep[1]].capable)){ - newDeps = [{name: dep[2], content: null}]; - } - break; - case "requireAll": - //the arguments are an array, each element a call to require. - //Get rid of first item, which is "requireAll". - dep.shift(); - newDeps = dep; - dojo.hostenv.flattenRequireArray(newDeps); - break; - case "kwCompoundRequire": - case "hostenv.conditionalLoadModule": - var modMap = dep[1]; - var common = modMap["common"]||[]; - var newDeps = (modMap[dojo.hostenv.name_]) ? common.concat(modMap[dojo.hostenv.name_]||[]) : common.concat(modMap["default"]||[]); - dojo.hostenv.flattenRequireArray(newDeps); - break; - case "require": - case "requireAfter": - case "hostenv.loadModule": - //Just worry about dep[1] - newDeps = [{name: dep[1], content: null}]; - break; + switch (dep[0]) { + case "requireIf": + case "requireAfterIf": + case "conditionalRequire": + if ((dep[1] === true) || (dep[1] == "common") || (dep[1] && dojo.render[dep[1]].capable)) { + newDeps = [{name:dep[2], content:null}]; + } + break; + case "requireAll": + dep.shift(); + newDeps = dep; + dojo.hostenv.flattenRequireArray(newDeps); + break; + case "kwCompoundRequire": + case "hostenv.conditionalLoadModule": + var modMap = dep[1]; + var common = modMap["common"] || []; + var newDeps = (modMap[dojo.hostenv.name_]) ? common.concat(modMap[dojo.hostenv.name_] || []) : common.concat(modMap["default"] || []); + dojo.hostenv.flattenRequireArray(newDeps); + break; + case "require": + case "requireAfter": + case "hostenv.loadModule": + newDeps = [{name:dep[1], content:null}]; + break; } - - //The requireAfterIf or requireAfter needs to be evaluated after the current package is evaluated. - if(dep[0] == "requireAfterIf"){ + if (dep[0] == "requireAfterIf" || dep[0] == "requireIf") { newAfterDeps = newDeps; newDeps = null; } - return {requires: newDeps, requiresAfter: newAfterDeps}; -} - -//Walks the requires and evaluates package contents in -//the right order. -dojo.hostenv.xdWalkReqs = function(){ + return {requires:newDeps, requiresAfter:newAfterDeps}; +}; +dojo.hostenv.xdWalkReqs = function () { var reqChain = null; var req; - for(var i = 0; i < this.xdOrderedReqs.length; i++){ + for (var i = 0; i < this.xdOrderedReqs.length; i++) { req = this.xdOrderedReqs[i]; - if(this.xdDepMap[req]){ + if (this.xdDepMap[req]) { reqChain = [req]; - reqChain[req] = true; //Allow for fast lookup of the req in the array + reqChain[req] = true; this.xdEvalReqs(reqChain); } } -} - -//Trace down any requires. -dojo.hostenv.xdTraceReqs = function(reqs, reqChain){ - if(reqs && reqs.length > 0){ - var nextReq; - for(var i = 0; i < reqs.length; i++){ - nextReq = reqs[i].name; - if(nextReq && !reqChain[nextReq]){ - //New req depedency. Follow it down. - reqChain.push(nextReq); - reqChain[nextReq] = true; - this.xdEvalReqs(reqChain); - } - } - } -} - -//Do a depth first, breadth second search and eval or reqs. -dojo.hostenv.xdEvalReqs = function(reqChain){ - if(reqChain.length > 0){ +}; +dojo.hostenv.xdEvalReqs = function (reqChain) { + while (reqChain.length > 0) { var req = reqChain[reqChain.length - 1]; var pkg = this.xdDepMap[req]; - if(pkg){ - //Trace down any requires for this package. - this.xdTraceReqs(pkg.requires, reqChain); - - //Evaluate the package. + if (pkg) { + var reqs = pkg.requires; + if (reqs && reqs.length > 0) { + var nextReq; + for (var i = 0; i < reqs.length; i++) { + nextReq = reqs[i].name; + if (nextReq && !reqChain[nextReq]) { + reqChain.push(nextReq); + reqChain[nextReq] = true; + this.xdEvalReqs(reqChain); + } + } + } var contents = this.xdContents[pkg.contentIndex]; - if(!contents.isDefined){ - //Evaluate the package to bring it into being. - //Pass dojo in so that later, to support multiple versions of dojo - //in a page, we can pass which version of dojo to use. - contents.content(dojo); + if (!contents.isDefined) { + var content = contents.content; + content["resourceName"] = contents["resourceName"]; + content["resourcePath"] = contents["resourcePath"]; + this.xdDefList.push(content); contents.isDefined = true; } this.xdDepMap[req] = null; - - //Trace down any requireAfters for this package.. - this.xdTraceReqs(pkg.requiresAfter, reqChain); + var reqs = pkg.requiresAfter; + if (reqs && reqs.length > 0) { + var nextReq; + for (var i = 0; i < reqs.length; i++) { + nextReq = reqs[i].name; + if (nextReq && !reqChain[nextReq]) { + reqChain.push(nextReq); + reqChain[nextReq] = true; + this.xdEvalReqs(reqChain); + } + } + } } - - //Done with that require. Remove it and go to the next one. reqChain.pop(); - this.xdEvalReqs(reqChain); } -} - -dojo.hostenv.clearXdInterval = function(){ +}; +dojo.hostenv.clearXdInterval = function () { clearInterval(this.xdTimer); this.xdTimer = 0; -} - -dojo.hostenv.watchInFlightXDomain = function(){ - //Make sure we haven't waited timed out. - var waitInterval = (djConfig.xdWaitSeconds || 30) * 1000; - - if(this.xdStartTime + waitInterval < (new Date()).getTime()){ +}; +dojo.hostenv.watchInFlightXDomain = function () { + var waitInterval = (djConfig.xdWaitSeconds || 15) * 1000; + if (this.xdStartTime + waitInterval < (new Date()).getTime()) { this.clearXdInterval(); var noLoads = ""; - for(var param in this.xdInFlight){ - if(this.xdInFlight[param]){ + for (var param in this.xdInFlight) { + if (this.xdInFlight[param]) { noLoads += param + " "; } } dojo.raise("Could not load cross-domain packages: " + noLoads); } - - //If any are true, then still waiting. - //Come back later. - for(var param in this.xdInFlight){ - if(this.xdInFlight[param]){ + for (var param in this.xdInFlight) { + if (this.xdInFlight[param]) { return; } } - - //All done loading. Clean up and notify that we are loaded. this.clearXdInterval(); - this.xdWalkReqs(); - - //Evaluate any packages that were not evaled before. - //This normally shouldn't happen with proper dojo.provide and dojo.require - //usage, but providing it just in case. Note that these may not be executed - //in the original order that the developer intended. - //Pass dojo in so that later, to support multiple versions of dojo - //in a page, we can pass which version of dojo to use. - for(var i = 0; i < this.xdContents.length; i++){ + var defLength = this.xdDefList.length; + for (var i = 0; i < defLength; i++) { + var content = dojo.hostenv.xdDefList[i]; + if (djConfig["debugAtAllCosts"] && content["resourceName"]) { + if (!this["xdDebugQueue"]) { + this.xdDebugQueue = []; + } + this.xdDebugQueue.push({resourceName:content.resourceName, resourcePath:content.resourcePath}); + } else { + content(dojo); + } + } + for (var i = 0; i < this.xdContents.length; i++) { var current = this.xdContents[i]; - if(current.content && !current.isDefined){ + if (current.content && !current.isDefined) { current.content(dojo); } } - - //Clean up for the next round of xd loading. this.resetXd(); - - //Clear inflight count so we will finally do finish work. - this.inFlightCount = 0; + if (this["xdDebugQueue"] && this.xdDebugQueue.length > 0) { + this.xdDebugFileLoaded(); + } else { + this.xdNotifyLoaded(); + } +}; +dojo.hostenv.xdNotifyLoaded = function () { + this.inFlightCount = 0; this.callLoaded(); -} - -dojo.hostenv.flattenRequireArray = function(target){ - //Each result could be an array of 3 elements (the 3 arguments to dojo.require). - //We only need the first one. - if(target){ - for(var i = 0; i < target.length; i++){ - if(target[i] instanceof Array){ - target[i] = {name: target[i][0], content: null}; - }else{ - target[i] = {name: target[i], content: null}; +}; +dojo.hostenv.flattenRequireArray = function (target) { + if (target) { + for (var i = 0; i < target.length; i++) { + if (target[i] instanceof Array) { + target[i] = {name:target[i][0], content:null}; + } else { + target[i] = {name:target[i], content:null}; } } } -} - -//Need to preload any flattened i18n bundles before we start -//executing code, since we cannot do it synchronously, as the -//i18n code normally expects. +}; dojo.hostenv.xdHasCalledPreload = false; dojo.hostenv.xdRealCallLoaded = dojo.hostenv.callLoaded; -dojo.hostenv.callLoaded = function(){ - //If getModulePrefix for dojo returns anything other than "src", that means - //there is a path registered for dojo, with implies that dojo was xdomain loaded. - if(this.xdHasCalledPreload || dojo.hostenv.getModulePrefix("dojo") == "src"){ +dojo.hostenv.callLoaded = function () { + if (this.xdHasCalledPreload || dojo.hostenv.getModulePrefix("dojo") == "src" || !this.localesGenerated) { this.xdRealCallLoaded(); this.xdHasCalledPreload = true; - }else{ - if(this.localesGenerated){ - this.registerNlsPrefix = function(){ - //Need to set the nls prefix to be the xd location. - dojo.registerModulePath("nls", dojo.hostenv.getModulePrefix("dojo") + "/../nls"); + } else { + if (this.localesGenerated) { + this.registerNlsPrefix = function () { + dojo.registerModulePath("nls", dojo.hostenv.getModulePrefix("dojo") + "/../nls"); }; this.preloadLocalizations(); } this.xdHasCalledPreload = true; } -} +}; + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/logging/ConsoleLogger.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/logging/ConsoleLogger.js index 4e3b41cb3..c0d4cd1b6 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/logging/ConsoleLogger.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/logging/ConsoleLogger.js @@ -10,99 +10,75 @@ dojo.provide("dojo.logging.ConsoleLogger"); dojo.require("dojo.logging.Logger"); - -dojo.lang.extend(dojo.logging.MemoryLogHandler,{ - - debug:function(){ - dojo.hostenv.println.apply(this,arguments); - }, - info:function(){ - dojo.hostenv.println.apply(this,arguments); - }, - warn:function(){ - dojo.hostenv.println.apply(this,arguments); - }, - error:function(){ - dojo.hostenv.println.apply(this,arguments); - }, - critical:function(){ - dojo.hostenv.println.apply(this,arguments); - }, - - emit:function(record){ - if (!djConfig.isDebug) { return; } - - var funcName=null; - switch(record.level){ - case 1: - funcName="debug"; - break; - case 2: - funcName="info"; - break; - case 3: - funcName="warn"; - break; - case 4: - funcName="error"; - break; - case 5: - funcName="critical"; - break; - default: - funcName="debug"; - } - - var logStr = String(dojo.log.getLevelName(record.level)+": " - +record.time.toLocaleTimeString())+": "+record.message; - if(record.msgArgs && record.msgArgs.length > 0){ - this[funcName].call(this, logStr, record.msgArgs); - } else { - this[funcName].call(this, logStr); - } - - this.data.push(record); - if(this.numRecords != -1){ - while(this.data.length>this.numRecords){ - this.data.shift(); - } +dojo.lang.extend(dojo.logging.MemoryLogHandler, {debug:function () { + dojo.hostenv.println.apply(this, arguments); +}, info:function () { + dojo.hostenv.println.apply(this, arguments); +}, warn:function () { + dojo.hostenv.println.apply(this, arguments); +}, error:function () { + dojo.hostenv.println.apply(this, arguments); +}, critical:function () { + dojo.hostenv.println.apply(this, arguments); +}, emit:function (record) { + if (!djConfig.isDebug) { + return; + } + var funcName = null; + switch (record.level) { + case 1: + funcName = "debug"; + break; + case 2: + funcName = "info"; + break; + case 3: + funcName = "warn"; + break; + case 4: + funcName = "error"; + break; + case 5: + funcName = "critical"; + break; + default: + funcName = "debug"; + } + var logStr = String(dojo.log.getLevelName(record.level) + ": " + record.time.toLocaleTimeString()) + ": " + record.message; + if (record.msgArgs && record.msgArgs.length > 0) { + this[funcName].call(this, logStr, record.msgArgs); + } else { + this[funcName].call(this, logStr); + } + this.data.push(record); + if (this.numRecords != -1) { + while (this.data.length > this.numRecords) { + this.data.shift(); } } -}); - -if(!dj_undef("console") && !dj_undef("info", console)){ -dojo.lang.extend(dojo.logging.MemoryLogHandler,{ - debug:function(){ +}}); +if (!dj_undef("console") && !dj_undef("info", console)) { + dojo.lang.extend(dojo.logging.MemoryLogHandler, {debug:function () { console.debug.apply(this, arguments); - }, - info:function(){ + }, info:function () { console.info.apply(this, arguments); - }, - warn:function(){ + }, warn:function () { console.warn.apply(this, arguments); - }, - error:function(){ + }, error:function () { console.error.apply(this, arguments); - }, - critical:function(){ + }, critical:function () { console.error.apply(this, arguments); - } -}); - -dojo.lang.extend(dojo.logging.Logger,{ - exception: function(msg, e, squelch){ - var args=[msg]; - - if(e){ - msg+=" : "+ e.name + " " + (e.description||e.message); + }}); + dojo.lang.extend(dojo.logging.Logger, {exception:function (msg, e, squelch) { + var args = [msg]; + if (e) { + msg += " : " + e.name + " " + (e.description || e.message); args.push(e); } - this.logType("ERROR", args); - if(!squelch){ + if (!squelch) { throw e; } - } -}); - + }}); } + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/logging/Logger.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/logging/Logger.js index 63312990a..2d989aa4d 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/logging/Logger.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/logging/Logger.js @@ -8,380 +8,207 @@ http://dojotoolkit.org/community/licensing.shtml */ -/* This is the dojo logging facility, which is imported from nWidgets - (written by Alex Russell, CLA on file), which is patterned on the - Python logging module, which in turn has been heavily influenced by - log4j (execpt with some more pythonic choices, which we adopt as well). - - While the dojo logging facilities do provide a set of familiar - interfaces, many of the details are changed to reflect the constraints - of the browser environment. Mainly, file and syslog-style logging - facilites are not provided, with HTTP POST and GET requests being the - only ways of getting data from the browser back to a server. Minimal - support for this (and XML serialization of logs) is provided, but may - not be of practical use in a deployment environment. - - The Dojo logging classes are agnostic of any environment, and while - default loggers are provided for browser-based interpreter - environments, this file and the classes it define are explicitly - designed to be portable to command-line interpreters and other - ECMA-262v3 envrionments. - - the logger needs to accomidate: - log "levels" - type identifiers - file? - message - tic/toc? - - The logger should ALWAYS record: - time/date logged - message - type - level -*/ -// TODO: conver documentation to javadoc style once we confirm that is our choice -// TODO: define DTD for XML-formatted log messages -// TODO: write XML Formatter class -// TODO: write HTTP Handler which uses POST to send log lines/sections - -// Filename: LogCore.js -// Purpose: a common logging infrastructure for dojo -// Classes: dojo.logging, dojo.logging.Logger, dojo.logging.Record, dojo.logging.LogFilter -// Global Objects: dojo.logging -// Dependencies: none - dojo.provide("dojo.logging.Logger"); +dojo.provide("dojo.logging.LogFilter"); +dojo.provide("dojo.logging.Record"); +dojo.provide("dojo.log"); dojo.require("dojo.lang.common"); - -/* - A simple data structure class that stores information for and about - a logged event. Objects of this type are created automatically when - an event is logged and are the internal format in which information - about log events is kept. -*/ - -dojo.logging.Record = function(lvl, msg){ - this.level = lvl; +dojo.require("dojo.lang.declare"); +dojo.logging.Record = function (logLevel, message) { + this.level = logLevel; this.message = ""; this.msgArgs = []; this.time = new Date(); - - if(dojo.lang.isArray(msg)){ - if(msg.length > 0 && dojo.lang.isString(msg[0])){ - this.message=msg.shift(); + if (dojo.lang.isArray(message)) { + if (message.length > 0 && dojo.lang.isString(message[0])) { + this.message = message.shift(); } - this.msgArgs=msg; - }else{ - this.message=msg; + this.msgArgs = message; + } else { + this.message = message; } - // FIXME: what other information can we receive/discover here? -} - -// an empty parent (abstract) class which concrete filters should inherit from. -dojo.logging.LogFilter = function(loggerChain){ +}; +dojo.logging.LogFilter = function (loggerChain) { this.passChain = loggerChain || ""; - this.filter = function(record){ - // FIXME: need to figure out a way to enforce the loggerChain - // restriction - return true; // pass all records - } -} - -dojo.logging.Logger = function(){ + this.filter = function (record) { + return true; + }; +}; +dojo.logging.Logger = function () { this.cutOffLevel = 0; this.propagate = true; this.parent = null; - // storage for dojo.logging.Record objects seen and accepted by this logger this.data = []; this.filters = []; this.handlers = []; -} - -dojo.extend(dojo.logging.Logger,{ - argsToArr: function(args){ - // utility function, reproduced from __util__ here to remove dependency - var ret = []; - for(var x=0; x= this.cutOffLevel; - }, - - getEffectiveLevel: function(){ - if((this.cutOffLevel==0)&&(this.parent)){ - return this.parent.getEffectiveLevel(); - } - return this.cutOffLevel; - }, - - addFilter: function(flt){ - this.filters.push(flt); - return this.filters.length-1; - }, - - removeFilterByIndex: function(fltIndex){ - if(this.filters[fltIndex]){ - delete this.filters[fltIndex]; +}; +dojo.extend(dojo.logging.Logger, {_argsToArr:function (args) { + var ret = []; + for (var x = 0; x < args.length; x++) { + ret.push(args[x]); + } + return ret; +}, setLevel:function (lvl) { + this.cutOffLevel = parseInt(lvl); +}, isEnabledFor:function (lvl) { + return parseInt(lvl) >= this.cutOffLevel; +}, getEffectiveLevel:function () { + if ((this.cutOffLevel == 0) && (this.parent)) { + return this.parent.getEffectiveLevel(); + } + return this.cutOffLevel; +}, addFilter:function (flt) { + this.filters.push(flt); + return this.filters.length - 1; +}, removeFilterByIndex:function (fltIndex) { + if (this.filters[fltIndex]) { + delete this.filters[fltIndex]; + return true; + } + return false; +}, removeFilter:function (fltRef) { + for (var x = 0; x < this.filters.length; x++) { + if (this.filters[x] === fltRef) { + delete this.filters[x]; return true; } - return false; - }, - - removeFilter: function(fltRef){ - for(var x=0; x=this.cutOffLevel)){ - this.parent.log(lvl, msg); + } + return false; +}, removeAllFilters:function () { + this.filters = []; +}, filter:function (rec) { + for (var x = 0; x < this.filters.length; x++) { + if ((this.filters[x]["filter"]) && (!this.filters[x].filter(rec)) || (rec.level < this.cutOffLevel)) { return false; } - // FIXME: need to call logging providers here! - this.handle(new dojo.logging.Record(lvl, msg)); - return true; - }, - - // logger helpers - debug:function(msg){ - return this.logType("DEBUG", this.argsToArr(arguments)); - }, - - info: function(msg){ - return this.logType("INFO", this.argsToArr(arguments)); - }, - - warning: function(msg){ - return this.logType("WARNING", this.argsToArr(arguments)); - }, - - error: function(msg){ - return this.logType("ERROR", this.argsToArr(arguments)); - }, - - critical: function(msg){ - return this.logType("CRITICAL", this.argsToArr(arguments)); - }, - - exception: function(msg, e, squelch){ - // FIXME: this needs to be modified to put the exception in the msg - // if we're on Moz, we can get the following from the exception object: - // lineNumber - // message - // fileName - // stack - // name - // on IE, we get: - // name - // message (from MDA?) - // number - // description (same as message!) - if(e){ - var eparts = [e.name, (e.description||e.message)]; - if(e.fileName){ - eparts.push(e.fileName); - eparts.push("line "+e.lineNumber); - // eparts.push(e.stack); - } - msg += " "+eparts.join(" : "); - } - - this.logType("ERROR", msg); - if(!squelch){ - throw e; - } - }, - - logType: function(type, args){ - return this.log.apply(this, [dojo.logging.log.getLevel(type), - args]); - }, - - warn:function(){ - this.warning.apply(this,arguments); - }, - err:function(){ - this.error.apply(this,arguments); - }, - crit:function(){ - this.critical.apply(this,arguments); } -}); - -// the Handler class -dojo.logging.LogHandler = function(level){ + return true; +}, addHandler:function (hdlr) { + this.handlers.push(hdlr); + return this.handlers.length - 1; +}, handle:function (rec) { + if ((!this.filter(rec)) || (rec.level < this.cutOffLevel)) { + return false; + } + for (var x = 0; x < this.handlers.length; x++) { + if (this.handlers[x]["handle"]) { + this.handlers[x].handle(rec); + } + } + return true; +}, log:function (lvl, msg) { + if ((this.propagate) && (this.parent) && (this.parent.rec.level >= this.cutOffLevel)) { + this.parent.log(lvl, msg); + return false; + } + this.handle(new dojo.logging.Record(lvl, msg)); + return true; +}, debug:function (msg) { + return this.logType("DEBUG", this._argsToArr(arguments)); +}, info:function (msg) { + return this.logType("INFO", this._argsToArr(arguments)); +}, warning:function (msg) { + return this.logType("WARNING", this._argsToArr(arguments)); +}, error:function (msg) { + return this.logType("ERROR", this._argsToArr(arguments)); +}, critical:function (msg) { + return this.logType("CRITICAL", this._argsToArr(arguments)); +}, exception:function (msg, e, squelch) { + if (e) { + var eparts = [e.name, (e.description || e.message)]; + if (e.fileName) { + eparts.push(e.fileName); + eparts.push("line " + e.lineNumber); + } + msg += " " + eparts.join(" : "); + } + this.logType("ERROR", msg); + if (!squelch) { + throw e; + } +}, logType:function (type, args) { + return this.log.apply(this, [dojo.logging.log.getLevel(type), args]); +}, warn:function () { + this.warning.apply(this, arguments); +}, err:function () { + this.error.apply(this, arguments); +}, crit:function () { + this.critical.apply(this, arguments); +}}); +dojo.logging.LogHandler = function (level) { this.cutOffLevel = (level) ? level : 0; - this.formatter = null; // FIXME: default formatter? + this.formatter = null; this.data = []; this.filters = []; -} -dojo.lang.extend(dojo.logging.LogHandler,{ - - setFormatter:function(formatter){ - dojo.unimplemented("setFormatter"); - }, - - flush:function(){}, - close:function(){}, - handleError:function(){}, - - handle:function(record){ - if((this.filter(record))&&(record.level>=this.cutOffLevel)){ - this.emit(record); - } - }, - - emit:function(record){ - dojo.unimplemented("emit"); +}; +dojo.lang.extend(dojo.logging.LogHandler, {setFormatter:function (formatter) { + dojo.unimplemented("setFormatter"); +}, flush:function () { +}, close:function () { +}, handleError:function () { + dojo.deprecated("dojo.logging.LogHandler.handleError", "use handle()", "0.6"); +}, handle:function (record) { + if ((this.filter(record)) && (record.level >= this.cutOffLevel)) { + this.emit(record); } -}); - -// set aliases since we don't want to inherit from dojo.logging.Logger -void(function(){ // begin globals protection closure - var names = [ - "setLevel", "addFilter", "removeFilterByIndex", "removeFilter", - "removeAllFilters", "filter" - ]; +}, emit:function (record) { + dojo.unimplemented("emit"); +}}); +void (function () { + var names = ["setLevel", "addFilter", "removeFilterByIndex", "removeFilter", "removeAllFilters", "filter"]; var tgt = dojo.logging.LogHandler.prototype; var src = dojo.logging.Logger.prototype; - for(var x=0; xthis.numRecords){ - this.data.shift(); - } + this.numRecords = (typeof djConfig["loggingNumRecords"] != "undefined") ? djConfig["loggingNumRecords"] : ((recordsToKeep) ? recordsToKeep : -1); + this.postType = (typeof djConfig["loggingPostType"] != "undefined") ? djConfig["loggingPostType"] : (postType || -1); + this.postInterval = (typeof djConfig["loggingPostInterval"] != "undefined") ? djConfig["loggingPostInterval"] : (postType || -1); +}, emit:function (record) { + if (!djConfig.isDebug) { + return; + } + var logStr = String(dojo.log.getLevelName(record.level) + ": " + record.time.toLocaleTimeString()) + ": " + record.message; + if (!dj_undef("println", dojo.hostenv)) { + dojo.hostenv.println(logStr, record.msgArgs); + } + this.data.push(record); + if (this.numRecords != -1) { + while (this.data.length > this.numRecords) { + this.data.shift(); } } -}); - -dojo.logging.logQueueHandler = new dojo.logging.MemoryLogHandler(0,50,0,10000); - +}}); +dojo.logging.logQueueHandler = new dojo.logging.MemoryLogHandler(0, 50, 0, 10000); dojo.logging.log.addHandler(dojo.logging.logQueueHandler); dojo.log = dojo.logging.log; + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/logging/__package__.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/logging/__package__.js index f3b606375..087bf9f36 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/logging/__package__.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/logging/__package__.js @@ -8,8 +8,6 @@ http://dojotoolkit.org/community/licensing.shtml */ -dojo.kwCompoundRequire({ - common: [["dojo.logging.Logger", false, false]], - rhino: ["dojo.logging.RhinoLogger"] -}); +dojo.kwCompoundRequire({common:[["dojo.logging.Logger", false, false]], rhino:["dojo.logging.RhinoLogger"]}); dojo.provide("dojo.logging.*"); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/math.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/math.js index 6410101c6..612ad9e1f 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/math.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/math.js @@ -9,50 +9,38 @@ */ dojo.provide("dojo.math"); - -dojo.math.degToRad = function(/* float */x) { - // summary - // Converts degrees to radians. - return (x*Math.PI) / 180; // float -} -dojo.math.radToDeg = function(/* float */x) { - // summary - // Converts radians to degrees. - return (x*180) / Math.PI; // float -} - -dojo.math.factorial = function(/* integer */n){ - // summary - // Returns n! - if(n<1){ return 0; } +dojo.math.degToRad = function (x) { + return (x * Math.PI) / 180; +}; +dojo.math.radToDeg = function (x) { + return (x * 180) / Math.PI; +}; +dojo.math.factorial = function (n) { + if (n < 1) { + return 0; + } var retVal = 1; - for(var i=1;i<=n;i++){ retVal *= i; } - return retVal; // integer -} - -dojo.math.permutations = function(/* integer */n, /* integer */k) { - // summary - // The number of ways of obtaining an ordered subset of k elements from a set of n elements - if(n==0 || k==0) return 1; - return (dojo.math.factorial(n) / dojo.math.factorial(n-k)); // float -} - -dojo.math.combinations = function (/* integer */n, /* integer */r) { - // summary - // The number of ways of picking n unordered outcomes from r possibilities - if(n==0 || r==0) return 1; - return (dojo.math.factorial(n) / (dojo.math.factorial(n-r) * dojo.math.factorial(r))); // float -} - -dojo.math.bernstein = function(/* float */t, /* float */n, /* float */i) { - // summary - // Calculates a weighted average based on the Bernstein theorem. - return (dojo.math.combinations(n,i) * Math.pow(t,i) * Math.pow(1-t,n-i)); // float -} - -dojo.math.gaussianRandom = function(){ - // summary - // Returns random numbers with a Gaussian distribution, with the mean set at 0 and the variance set at 1. + for (var i = 1; i <= n; i++) { + retVal *= i; + } + return retVal; +}; +dojo.math.permutations = function (n, k) { + if (n == 0 || k == 0) { + return 1; + } + return (dojo.math.factorial(n) / dojo.math.factorial(n - k)); +}; +dojo.math.combinations = function (n, r) { + if (n == 0 || r == 0) { + return 1; + } + return (dojo.math.factorial(n) / (dojo.math.factorial(n - r) * dojo.math.factorial(r))); +}; +dojo.math.bernstein = function (t, n, i) { + return (dojo.math.combinations(n, i) * Math.pow(t, i) * Math.pow(1 - t, n - i)); +}; +dojo.math.gaussianRandom = function () { var k = 2; do { var i = 2 * Math.random() - 1; @@ -60,68 +48,59 @@ dojo.math.gaussianRandom = function(){ k = i * i + j * j; } while (k >= 1); k = Math.sqrt((-2 * Math.log(k)) / k); - return i * k; // float -} - -dojo.math.mean = function() { - // summary - // Calculates the mean of an Array of numbers. + return i * k; +}; +dojo.math.mean = function () { var array = dojo.lang.isArray(arguments[0]) ? arguments[0] : arguments; var mean = 0; - for (var i = 0; i < array.length; i++) { mean += array[i]; } - return mean / array.length; // float -} - -dojo.math.round = function(/* float */number, /* integer */places) { - // summary - // Extends Math.round by adding a second argument specifying the number of decimal places to round to. - // TODO: add support for significant figures - if (!places) { var shift = 1; } - else { var shift = Math.pow(10, places); } - return Math.round(number * shift) / shift; // float -} - -dojo.math.sd = dojo.math.standardDeviation = function(/* array */){ - // summary - // Calculates the standard deviation of an Array of numbers + for (var i = 0; i < array.length; i++) { + mean += array[i]; + } + return mean / array.length; +}; +dojo.math.round = function (number, places) { + if (!places) { + var shift = 1; + } else { + var shift = Math.pow(10, places); + } + return Math.round(number * shift) / shift; +}; +dojo.math.sd = dojo.math.standardDeviation = function () { var array = dojo.lang.isArray(arguments[0]) ? arguments[0] : arguments; - return Math.sqrt(dojo.math.variance(array)); // float -} - -dojo.math.variance = function(/* array */) { - // summary - // Calculates the variance of an Array of numbers + return Math.sqrt(dojo.math.variance(array)); +}; +dojo.math.variance = function () { var array = dojo.lang.isArray(arguments[0]) ? arguments[0] : arguments; var mean = 0, squares = 0; for (var i = 0; i < array.length; i++) { mean += array[i]; squares += Math.pow(array[i], 2); } - return (squares / array.length) - Math.pow(mean / array.length, 2); // float -} + return (squares / array.length) - Math.pow(mean / array.length, 2); +}; +dojo.math.range = function (a, b, step) { + if (arguments.length < 2) { + b = a; + a = 0; + } + if (arguments.length < 3) { + step = 1; + } + var range = []; + if (step > 0) { + for (var i = a; i < b; i += step) { + range.push(i); + } + } else { + if (step < 0) { + for (var i = a; i > b; i += step) { + range.push(i); + } + } else { + throw new Error("dojo.math.range: step must be non-zero"); + } + } + return range; +}; -dojo.math.range = function(/* integer */a, /* integer */b, /* integer */step) { - // summary - // implementation of Python's range() - if(arguments.length < 2) { - b = a; - a = 0; - } - if(arguments.length < 3) { - step = 1; - } - - var range = []; - if(step > 0) { - for(var i = a; i < b; i += step) { - range.push(i); - } - } else if(step < 0) { - for(var i = a; i > b; i += step) { - range.push(i); - } - } else { - throw new Error("dojo.math.range: step must be non-zero"); - } - return range; // array -} diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/math/__package__.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/math/__package__.js index 942aaa1cf..4f74fd26e 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/math/__package__.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/math/__package__.js @@ -8,11 +8,6 @@ http://dojotoolkit.org/community/licensing.shtml */ -dojo.kwCompoundRequire({ - common: [ - ["dojo.math", false, false], - ["dojo.math.curves", false, false], - ["dojo.math.points", false, false] - ] -}); +dojo.kwCompoundRequire({common:[["dojo.math", false, false], ["dojo.math.curves", false, false], ["dojo.math.points", false, false]]}); dojo.provide("dojo.math.*"); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/math/curves.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/math/curves.js index 26751ebf1..fe4cd8591 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/math/curves.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/math/curves.js @@ -10,233 +10,173 @@ dojo.provide("dojo.math.curves"); dojo.require("dojo.math"); - -/* Curves from Dan's 13th lib stuff. - * See: http://pupius.co.uk/js/Toolkit.Drawing.js - * http://pupius.co.uk/dump/dojo/Dojo.Math.js - */ - -dojo.math.curves = { - Line: function(/* array */start, /* array */end) { - // summary - // Creates a straight line object - this.start = start; - this.end = end; - this.dimensions = start.length; - - for(var i = 0; i < start.length; i++) { - start[i] = Number(start[i]); - } - - for(var i = 0; i < end.length; i++) { - end[i] = Number(end[i]); - } - - //simple function to find point on an n-dimensional, straight line - this.getValue = function(/* float */n){ - // summary - // Returns the point at point N (in terms of percentage) on this line. - var retVal = new Array(this.dimensions); - for(var i=0;i= 1) return this.p[this.p.length-1]; // if step>=1 we must be at the end of the curve - if(step <= 0) return this.p[0]; // if step<=0 we must be at the start of the curve - var retVal = new Array(this.p[0].length); - for(var k=0;j= this.p.length) i1 = this.p.length-1; - var i2 = node+2; if(i2 >= this.p.length) i2 = this.p.length-1; - - var u = progress; - var u2 = progress*progress; - var u3 = progress*progress*progress; - - var retVal = new Array(this.p[0].length); - for(var k=0;k 2D point for center of arc - // radius => scalar quantity for radius of arc - // start => to define an arc specify start angle (default: 0) - // end => to define an arc specify start angle - this.center = center; - this.radius = radius; - this.start = start || 0; - this.end = end; - - this.getValue = function(/* float */n) { - // summary - // Returns the point at point N (in terms of percentage) on this curve. - var retVal = new Array(2); - var theta = dojo.math.degToRad(this.start+((this.end-this.start)*n)); - - retVal[0] = this.center[0] + this.radius*Math.sin(theta); - retVal[1] = this.center[1] - this.radius*Math.cos(theta); - - return retVal; // array - } - - return this; // dojo.math.curves.CenteredArc - }, - - Circle : function(/* array */center, /* float */radius) { - // summary - // Special case of Arc (start = 0, end = 360) - dojo.math.curves.CenteredArc.call(this, center, radius, 0, 360); - return this; // dojo.math.curves.Circle - }, - - Path : function() { - // summary - // Generic path shape, created from curve segments - var curves = []; - var weights = []; - var ranges = []; - var totalWeight = 0; - - this.add = function(/* dojo.math.curves.* */curve, /* float */weight) { - // summary - // Add a curve segment to this path - if( weight < 0 ) { dojo.raise("dojo.math.curves.Path.add: weight cannot be less than 0"); } - curves.push(curve); - weights.push(weight); - totalWeight += weight; - computeRanges(); - } - - this.remove = function(/* dojo.math.curves.* */curve) { - // summary - // Remove a curve segment from this path - for(var i = 0; i < curves.length; i++) { - if( curves[i] == curve ) { - curves.splice(i, 1); - totalWeight -= weights.splice(i, 1)[0]; - break; - } - } - computeRanges(); - } - - this.removeAll = function() { - // summary - // Remove all curve segments - curves = []; - weights = []; - totalWeight = 0; - } - - this.getValue = function(/* float */n) { - // summary - // Returns the point at point N (in terms of percentage) on this curve. - var found = false, value = 0; - for(var i = 0; i < ranges.length; i++) { - var r = ranges[i]; - //w(r.join(" ... ")); - if( n >= r[0] && n < r[1] ) { - var subN = (n - r[0]) / r[2]; - value = curves[i].getValue(subN); - found = true; - break; - } - } - - // FIXME: Do we want to assume we're at the end? - if( !found ) { - value = curves[curves.length-1].getValue(1); - } - - for(var j = 0; j < i; j++) { - value = dojo.math.points.translate(value, curves[j].getValue(1)); - } - return value; // array - } - - function computeRanges() { - var start = 0; - for(var i = 0; i < weights.length; i++) { - var end = start + weights[i] / totalWeight; - var len = end - start; - ranges[i] = [start, end, len]; - start = end; - } - } - - return this; // dojo.math.curves.Path +dojo.math.curves = {Line:function (start, end) { + this.start = start; + this.end = end; + this.dimensions = start.length; + for (var i = 0; i < start.length; i++) { + start[i] = Number(start[i]); } -}; + for (var i = 0; i < end.length; i++) { + end[i] = Number(end[i]); + } + this.getValue = function (n) { + var retVal = new Array(this.dimensions); + for (var i = 0; i < this.dimensions; i++) { + retVal[i] = ((this.end[i] - this.start[i]) * n) + this.start[i]; + } + return retVal; + }; + return this; +}, Bezier:function (pnts) { + this.getValue = function (step) { + if (step >= 1) { + return this.p[this.p.length - 1]; + } + if (step <= 0) { + return this.p[0]; + } + var retVal = new Array(this.p[0].length); + for (var k = 0; j < this.p[0].length; k++) { + retVal[k] = 0; + } + for (var j = 0; j < this.p[0].length; j++) { + var C = 0; + var D = 0; + for (var i = 0; i < this.p.length; i++) { + C += this.p[i][j] * this.p[this.p.length - 1][0] * dojo.math.bernstein(step, this.p.length, i); + } + for (var l = 0; l < this.p.length; l++) { + D += this.p[this.p.length - 1][0] * dojo.math.bernstein(step, this.p.length, l); + } + retVal[j] = C / D; + } + return retVal; + }; + this.p = pnts; + return this; +}, CatmullRom:function (pnts, c) { + this.getValue = function (step) { + var percent = step * (this.p.length - 1); + var node = Math.floor(percent); + var progress = percent - node; + var i0 = node - 1; + if (i0 < 0) { + i0 = 0; + } + var i = node; + var i1 = node + 1; + if (i1 >= this.p.length) { + i1 = this.p.length - 1; + } + var i2 = node + 2; + if (i2 >= this.p.length) { + i2 = this.p.length - 1; + } + var u = progress; + var u2 = progress * progress; + var u3 = progress * progress * progress; + var retVal = new Array(this.p[0].length); + for (var k = 0; k < this.p[0].length; k++) { + var x1 = (-this.c * this.p[i0][k]) + ((2 - this.c) * this.p[i][k]) + ((this.c - 2) * this.p[i1][k]) + (this.c * this.p[i2][k]); + var x2 = (2 * this.c * this.p[i0][k]) + ((this.c - 3) * this.p[i][k]) + ((3 - 2 * this.c) * this.p[i1][k]) + (-this.c * this.p[i2][k]); + var x3 = (-this.c * this.p[i0][k]) + (this.c * this.p[i1][k]); + var x4 = this.p[i][k]; + retVal[k] = x1 * u3 + x2 * u2 + x3 * u + x4; + } + return retVal; + }; + if (!c) { + this.c = 0.7; + } else { + this.c = c; + } + this.p = pnts; + return this; +}, Arc:function (start, end, ccw) { + var center = dojo.math.points.midpoint(start, end); + var sides = dojo.math.points.translate(dojo.math.points.invert(center), start); + var rad = Math.sqrt(Math.pow(sides[0], 2) + Math.pow(sides[1], 2)); + var theta = dojo.math.radToDeg(Math.atan(sides[1] / sides[0])); + if (sides[0] < 0) { + theta -= 90; + } else { + theta += 90; + } + dojo.math.curves.CenteredArc.call(this, center, rad, theta, theta + (ccw ? -180 : 180)); +}, CenteredArc:function (center, radius, start, end) { + this.center = center; + this.radius = radius; + this.start = start || 0; + this.end = end; + this.getValue = function (n) { + var retVal = new Array(2); + var theta = dojo.math.degToRad(this.start + ((this.end - this.start) * n)); + retVal[0] = this.center[0] + this.radius * Math.sin(theta); + retVal[1] = this.center[1] - this.radius * Math.cos(theta); + return retVal; + }; + return this; +}, Circle:function (center, radius) { + dojo.math.curves.CenteredArc.call(this, center, radius, 0, 360); + return this; +}, Path:function () { + var curves = []; + var weights = []; + var ranges = []; + var totalWeight = 0; + this.add = function (curve, weight) { + if (weight < 0) { + dojo.raise("dojo.math.curves.Path.add: weight cannot be less than 0"); + } + curves.push(curve); + weights.push(weight); + totalWeight += weight; + computeRanges(); + }; + this.remove = function (curve) { + for (var i = 0; i < curves.length; i++) { + if (curves[i] == curve) { + curves.splice(i, 1); + totalWeight -= weights.splice(i, 1)[0]; + break; + } + } + computeRanges(); + }; + this.removeAll = function () { + curves = []; + weights = []; + totalWeight = 0; + }; + this.getValue = function (n) { + var found = false, value = 0; + for (var i = 0; i < ranges.length; i++) { + var r = ranges[i]; + if (n >= r[0] && n < r[1]) { + var subN = (n - r[0]) / r[2]; + value = curves[i].getValue(subN); + found = true; + break; + } + } + if (!found) { + value = curves[curves.length - 1].getValue(1); + } + for (var j = 0; j < i; j++) { + value = dojo.math.points.translate(value, curves[j].getValue(1)); + } + return value; + }; + function computeRanges() { + var start = 0; + for (var i = 0; i < weights.length; i++) { + var end = start + weights[i] / totalWeight; + var len = end - start; + ranges[i] = [start, end, len]; + start = end; + } + } + return this; +}}; + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/math/matrix.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/math/matrix.js index 61ad99db1..c0936b51c 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/math/matrix.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/math/matrix.js @@ -9,207 +9,146 @@ */ dojo.provide("dojo.math.matrix"); - -// some of this code is based on -// http://www.mkaz.com/math/MatrixCalculator.java -// (published under a BSD Open Source License) -// -// the rest is from my vague memory of matricies in school [cal] -// -// the copying of arguments is a little excessive, and could be trimmed back in -// the case where a function doesn't modify them at all (but some do!) -// -// 2006-06-25: Some enhancements submitted by Erel Segal: -// * addition: a tolerance constant for determinant calculations. -// * performance fix: removed unnecessary argument copying. -// * addition: function "product" for multiplying more than 2 matrices -// * addition: function "sum" for adding any number of matrices -// * bug fix: inversion of a 1x1 matrix without using the adjoint -// * performance fixes: upperTriangle -// * addition: argument "value" to function create, to initialize the matrix with a custom val -// * addition: functions "ones" and "zeros" - like Matlab[TM] functions with the same name. -// * addition: function "identity" for creating an identity matrix of a given size. -// * addition: argument "decimal_points" to function format -// * bug fix: adjoint of a 0-size matrix -// * performance fixes: adjoint -// - dojo.math.matrix.iDF = 0; - -// Erel: values lower than this value are considered zero (in detereminant calculations). -// It is analogous to Maltab[TM]'s "eps". dojo.math.matrix.ALMOST_ZERO = 1e-10; -dojo.math.matrix.multiply = function(a, b){ +dojo.math.matrix.multiply = function (a, b) { var ay = a.length; var ax = a[0].length; var by = b.length; var bx = b[0].length; - - if (ax != by){ - dojo.debug("Can't multiply matricies of sizes "+ax+','+ay+' and '+bx+','+by); + if (ax != by) { + dojo.debug("Can't multiply matricies of sizes " + ax + "," + ay + " and " + bx + "," + by); return [[0]]; } - var c = []; - for(var k=0; k0? a[0].length: 0; - var buffer = ''; - for (var y=0; y 0 ? a[0].length : 0; + var buffer = ""; + for (var y = 0; y < ya; y++) { + buffer += "| "; + for (var x = 0; x < xa; x++) { + buffer += format_int(a[y][x], decimal_points) + " "; } - buffer += '|\n'; + buffer += "|\n"; } return buffer; -} - -dojo.math.matrix.copy = function(a){ +}; +dojo.math.matrix.copy = function (a) { var ya = a.length; var xa = a[0].length; var m = dojo.math.matrix.create(xa, ya); - for (var y=0; y by convention - if(!dojo.hostenv.moduleHasPrefix(name)){ - dojo.registerModulePath(name, "../" + name); - } - req([name, 'manifest'].join('.'), false, true); - } - if(!this.namespaces[name]){ - this.failed[name] = true; //only look for a namespace once - } - }finally{ - this.loading[name]=false; - } - return this.namespaces[name]; // Ns - } -} - -dojo.ns.Ns = function(/*String*/name, /*String*/module, /*Function?*/resolver){ - // summary: this object simply encapsulates namespace data - this.name = name; - this.module = module; - this.resolver = resolver; - this._loaded = [ ]; - this._failed = [ ]; -} - -dojo.ns.Ns.prototype.resolve = function(/*String*/name, /*String*/domain, /*Boolean?*/omitModuleCheck){ - //summary: map component with 'name' and 'domain' to a module via namespace resolver, if specified - if(!this.resolver || djConfig["skipAutoRequire"]){return false;} // Boolean - var fullName = this.resolver(name, domain); - //only load a widget once. This is a quicker check than dojo.require does - if((fullName)&&(!this._loaded[fullName])&&(!this._failed[fullName])){ - //workaround so we don't break the build system - var req = dojo.require; - req(fullName, false, true); //omit the module check, we'll do it ourselves. - if(dojo.hostenv.findModule(fullName, false)){ - this._loaded[fullName] = true; - }else{ - if(!omitModuleCheck){dojo.raise("dojo.ns.Ns.resolve: module '" + fullName + "' not found after loading via namespace '" + this.name + "'");} - this._failed[fullName] = true; - } - } - return Boolean(this._loaded[fullName]); // Boolean -} - -dojo.registerNamespace = function(/*String*/name, /*String*/module, /*Function?*/resolver){ - // summary: maps a module name to a namespace for widgets, and optionally maps widget names to modules for auto-loading - // description: An unregistered namespace is mapped to an eponymous module. - // For example, namespace acme is mapped to module acme, and widgets are - // assumed to belong to acme.widget. If you want to use a different widget - // module, use dojo.registerNamespace. - dojo.ns.register.apply(dojo.ns, arguments); -} - -dojo.registerNamespaceResolver = function(/*String*/name, /*Function*/resolver){ - // summary: a resolver function maps widget names to modules, so the - // widget manager can auto-load needed widget implementations - // - // description: The resolver provides information to allow Dojo - // to load widget modules on demand. When a widget is created, - // a namespace resolver can tell Dojo what module to require - // to ensure that the widget implementation code is loaded. - // - // name: will always be lower-case. - // - // example: - // dojo.registerNamespaceResolver("acme", - // function(name){ - // return "acme.widget."+dojo.string.capitalize(name); - // } - // ); - var n = dojo.ns.namespaces[name]; - if(n){ - n.resolver = resolver; - } -} - -dojo.registerNamespaceManifest = function(/*String*/module, /*String*/path, /*String*/name, /*String*/widgetModule, /*Function?*/resolver){ - // summary: convenience function to register a module path, a namespace, and optionally a resolver all at once. - dojo.registerModulePath(name, path); - dojo.registerNamespace(name, widgetModule, resolver); -} - -// NOTE: rather put this in dojo.widget.Widget, but that fubars debugAtAllCosts -dojo.registerNamespace("dojo", "dojo.widget"); +dojo.provide("dojo.ns"); +dojo.ns = {namespaces:{}, failed:{}, loading:{}, loaded:{}, register:function (name, module, resolver, noOverride) { + if (!noOverride || !this.namespaces[name]) { + this.namespaces[name] = new dojo.ns.Ns(name, module, resolver); + } +}, allow:function (name) { + if (this.failed[name]) { + return false; + } + if ((djConfig.excludeNamespace) && (dojo.lang.inArray(djConfig.excludeNamespace, name))) { + return false; + } + return ((name == this.dojo) || (!djConfig.includeNamespace) || (dojo.lang.inArray(djConfig.includeNamespace, name))); +}, get:function (name) { + return this.namespaces[name]; +}, require:function (name) { + var ns = this.namespaces[name]; + if ((ns) && (this.loaded[name])) { + return ns; + } + if (!this.allow(name)) { + return false; + } + if (this.loading[name]) { + dojo.debug("dojo.namespace.require: re-entrant request to load namespace \"" + name + "\" must fail."); + return false; + } + var req = dojo.require; + this.loading[name] = true; + try { + if (name == "dojo") { + req("dojo.namespaces.dojo"); + } else { + if (!dojo.hostenv.moduleHasPrefix(name)) { + dojo.registerModulePath(name, "../" + name); + } + req([name, "manifest"].join("."), false, true); + } + if (!this.namespaces[name]) { + this.failed[name] = true; + } + } + finally { + this.loading[name] = false; + } + return this.namespaces[name]; +}}; +dojo.ns.Ns = function (name, module, resolver) { + this.name = name; + this.module = module; + this.resolver = resolver; + this._loaded = []; + this._failed = []; +}; +dojo.ns.Ns.prototype.resolve = function (name, domain, omitModuleCheck) { + if (!this.resolver || djConfig["skipAutoRequire"]) { + return false; + } + var fullName = this.resolver(name, domain); + if ((fullName) && (!this._loaded[fullName]) && (!this._failed[fullName])) { + var req = dojo.require; + req(fullName, false, true); + if (dojo.hostenv.findModule(fullName, false)) { + this._loaded[fullName] = true; + } else { + if (!omitModuleCheck) { + dojo.raise("dojo.ns.Ns.resolve: module '" + fullName + "' not found after loading via namespace '" + this.name + "'"); + } + this._failed[fullName] = true; + } + } + return Boolean(this._loaded[fullName]); +}; +dojo.registerNamespace = function (name, module, resolver) { + dojo.ns.register.apply(dojo.ns, arguments); +}; +dojo.registerNamespaceResolver = function (name, resolver) { + var n = dojo.ns.namespaces[name]; + if (n) { + n.resolver = resolver; + } +}; +dojo.registerNamespaceManifest = function (module, path, name, widgetModule, resolver) { + dojo.registerModulePath(name, path); + dojo.registerNamespace(name, widgetModule, resolver); +}; +dojo.registerNamespace("dojo", "dojo.widget"); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/profile.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/profile.js index 6f1dd8be6..2722dd298 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/profile.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/profile.js @@ -9,138 +9,94 @@ */ dojo.provide("dojo.profile"); - -// summary: -// provides a manual profiling utility that can be used to gather relative -// timing data. - - -// FIXME: need to tie into the event system or provide a closure-based way to -// watch timings of functions without manually instrumenting them. -// FIXME: need to make the dump() function work in command line environments - -dojo.profile = { - _profiles: {}, - _pns: [], - - start:function(/*String*/ name){ - // summary: - // start an iteration for the profiling target with the specified - // name. If a previously started iteration has not yet been ended - // for this name, it's automatically closed out and a new - // iteration begun. - // name: - // a unique name to identify the thing being profiled - if(!this._profiles[name]){ - this._profiles[name] = {iters: 0, total: 0}; - this._pns[this._pns.length] = name; - }else{ - if(this._profiles[name]["start"]){ - this.end(name); - } +dojo.profile = {_profiles:{}, _pns:[], start:function (name) { + if (!this._profiles[name]) { + this._profiles[name] = {iters:0, total:0}; + this._pns[this._pns.length] = name; + } else { + if (this._profiles[name]["start"]) { + this.end(name); } - this._profiles[name].end = null; - this._profiles[name].start = new Date(); - }, - - end:function(/*String*/ name){ - // summary: - // closes a timing loop for the named profiling target - // name: - // a unique name to identify the thing being profiled. The name - // passed to end() should be the same as that passed to start() - var ed = new Date(); - if((this._profiles[name])&&(this._profiles[name]["start"])){ - with(this._profiles[name]){ - end = ed; - total += (end - start); - start = null; - iters++; - } - }else{ - // oops! bad call to end(), what should we do here? - return true; + } + this._profiles[name].end = null; + this._profiles[name].start = new Date(); +}, end:function (name) { + var ed = new Date(); + if ((this._profiles[name]) && (this._profiles[name]["start"])) { + with (this._profiles[name]) { + end = ed; + total += (end - start); + start = null; + iters++; } - }, - - dump:function(/*boolean*/ appendToDoc){ - // summary: - // output profiling data to an HTML table, optionally adding it to - // the bottom of the document. If profiling data has already been - // generated and appended to the document, it's replaced with the - // new data. - // appendToDoc: - // optional. Defautls to "false". Should profiling information be - // added to the document? - var tbl = document.createElement("table"); - with(tbl.style){ - border = "1px solid black"; - borderCollapse = "collapse"; + } else { + return true; + } +}, dump:function (appendToDoc) { + var tbl = document.createElement("table"); + with (tbl.style) { + border = "1px solid black"; + borderCollapse = "collapse"; + } + var hdr = tbl.createTHead(); + var hdrtr = hdr.insertRow(0); + var cols = ["Identifier", "Calls", "Total", "Avg"]; + for (var x = 0; x < cols.length; x++) { + var ntd = hdrtr.insertCell(x); + with (ntd.style) { + backgroundColor = "#225d94"; + color = "white"; + borderBottom = "1px solid black"; + borderRight = "1px solid black"; + fontFamily = "tahoma"; + fontWeight = "bolder"; + paddingLeft = paddingRight = "5px"; } - var hdr = tbl.createTHead(); - var hdrtr = hdr.insertRow(0); - // document.createElement("tr"); - var cols = ["Identifier","Calls","Total","Avg"]; - for(var x=0; x0){ - var bdytr = tbl.insertRow(true); - var vals = [this._pns[x], prf.iters, prf.total, parseInt(prf.total/prf.iters)]; - for(var y=0; y0){ - textAlign = "right"; - borderRight = "1px solid gray"; - }else{ - borderRight = "1px solid black"; - } + ntd.appendChild(document.createTextNode(cols[x])); + } + for (var x = 0; x < this._pns.length; x++) { + var prf = this._profiles[this._pns[x]]; + this.end(this._pns[x]); + if (prf.iters > 0) { + var bdytr = tbl.insertRow(true); + var vals = [this._pns[x], prf.iters, prf.total, parseInt(prf.total / prf.iters)]; + for (var y = 0; y < vals.length; y++) { + var cc = bdytr.insertCell(y); + cc.appendChild(document.createTextNode(vals[y])); + with (cc.style) { + borderBottom = "1px solid gray"; + paddingLeft = paddingRight = "5px"; + if (x % 2) { + backgroundColor = "#e1f1ff"; + } + if (y > 0) { + textAlign = "right"; + borderRight = "1px solid gray"; + } else { + borderRight = "1px solid black"; } } } } - - if(appendToDoc){ - var ne = document.createElement("div"); - ne.id = "profileOutputTable"; - with(ne.style){ - fontFamily = "Courier New, monospace"; - fontSize = "12px"; - lineHeight = "16px"; - borderTop = "1px solid black"; - padding = "10px"; - } - if(document.getElementById("profileOutputTable")){ - dojo.body().replaceChild(ne, document.getElementById("profileOutputTable")); - }else{ - dojo.body().appendChild(ne); - } - ne.appendChild(tbl); - } - - return tbl; // DOMNode } -} - + if (appendToDoc) { + var ne = document.createElement("div"); + ne.id = "profileOutputTable"; + with (ne.style) { + fontFamily = "Courier New, monospace"; + fontSize = "12px"; + lineHeight = "16px"; + borderTop = "1px solid black"; + padding = "10px"; + } + if (document.getElementById("profileOutputTable")) { + dojo.body().replaceChild(ne, document.getElementById("profileOutputTable")); + } else { + dojo.body().appendChild(ne); + } + ne.appendChild(tbl); + } + return tbl; +}}; dojo.profile.stop = dojo.profile.end; + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/regexp.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/regexp.js index 8d55a57d8..b351d94ca 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/regexp.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/regexp.js @@ -9,486 +9,321 @@ */ dojo.provide("dojo.regexp"); -dojo.evalObjPath("dojo.regexp.us", true); // this file also defines stuff in the dojo.regexp.us module (TODO: move to separate file?) - -// *** Regular Expression Generators *** - -dojo.regexp.tld = function(/*Object?*/flags){ - // summary: Builds a RE that matches a top-level domain - // - // flags: - // flags.allowCC Include 2 letter country code domains. Default is true. - // flags.allowGeneric Include the generic domains. Default is true. - // flags.allowInfra Include infrastructure domains. Default is true. - - // assign default values to missing paramters +dojo.evalObjPath("dojo.regexp.us", true); +dojo.regexp.tld = function (flags) { flags = (typeof flags == "object") ? flags : {}; - if(typeof flags.allowCC != "boolean"){ flags.allowCC = true; } - if(typeof flags.allowInfra != "boolean"){ flags.allowInfra = true; } - if(typeof flags.allowGeneric != "boolean"){ flags.allowGeneric = true; } - - // Infrastructure top-level domain - only one at present + if (typeof flags.allowCC != "boolean") { + flags.allowCC = true; + } + if (typeof flags.allowInfra != "boolean") { + flags.allowInfra = true; + } + if (typeof flags.allowGeneric != "boolean") { + flags.allowGeneric = true; + } var infraRE = "arpa"; - - // Generic top-level domains RE. - var genericRE = - "aero|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|xxx|jobs|mobi|post"; - - // Country Code top-level domains RE - var ccRE = - "ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|" + - "bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|" + - "ec|ee|eg|er|es|et|fi|fj|fk|fm|fo|fr|ga|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|" + - "hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kr|kw|ky|kz|la|" + - "lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|" + - "mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|" + - "ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sk|sl|sm|sn|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|" + - "to|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw"; - - // Build top-level domain RE + var genericRE = "aero|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|xxx|jobs|mobi|post"; + var ccRE = "ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|" + "bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|" + "ec|ee|eg|er|eu|es|et|fi|fj|fk|fm|fo|fr|ga|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|" + "gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kr|kw|ky|kz|" + "la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|" + "my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|" + "re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sk|sl|sm|sn|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|" + "tn|to|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw"; var a = []; - if(flags.allowInfra){ a.push(infraRE); } - if(flags.allowGeneric){ a.push(genericRE); } - if(flags.allowCC){ a.push(ccRE); } - + if (flags.allowInfra) { + a.push(infraRE); + } + if (flags.allowGeneric) { + a.push(genericRE); + } + if (flags.allowCC) { + a.push(ccRE); + } var tldRE = ""; if (a.length > 0) { tldRE = "(" + a.join("|") + ")"; } - - return tldRE; // String -} - -dojo.regexp.ipAddress = function(/*Object?*/flags){ - // summary: Builds a RE that matches an IP Address - // - // description: - // Supports 5 formats for IPv4: dotted decimal, dotted hex, dotted octal, decimal and hexadecimal. - // Supports 2 formats for Ipv6. - // - // flags An object. All flags are boolean with default = true. - // flags.allowDottedDecimal Example, 207.142.131.235. No zero padding. - // flags.allowDottedHex Example, 0x18.0x11.0x9b.0x28. Case insensitive. Zero padding allowed. - // flags.allowDottedOctal Example, 0030.0021.0233.0050. Zero padding allowed. - // flags.allowDecimal Example, 3482223595. A decimal number between 0-4294967295. - // flags.allowHex Example, 0xCF8E83EB. Hexadecimal number between 0x0-0xFFFFFFFF. - // Case insensitive. Zero padding allowed. - // flags.allowIPv6 IPv6 address written as eight groups of four hexadecimal digits. - // flags.allowHybrid IPv6 address written as six groups of four hexadecimal digits - // followed by the usual 4 dotted decimal digit notation of IPv4. x:x:x:x:x:x:d.d.d.d - - // assign default values to missing paramters + return tldRE; +}; +dojo.regexp.ipAddress = function (flags) { flags = (typeof flags == "object") ? flags : {}; - if(typeof flags.allowDottedDecimal != "boolean"){ flags.allowDottedDecimal = true; } - if(typeof flags.allowDottedHex != "boolean"){ flags.allowDottedHex = true; } - if(typeof flags.allowDottedOctal != "boolean"){ flags.allowDottedOctal = true; } - if(typeof flags.allowDecimal != "boolean"){ flags.allowDecimal = true; } - if(typeof flags.allowHex != "boolean"){ flags.allowHex = true; } - if(typeof flags.allowIPv6 != "boolean"){ flags.allowIPv6 = true; } - if(typeof flags.allowHybrid != "boolean"){ flags.allowHybrid = true; } - - // decimal-dotted IP address RE. - var dottedDecimalRE = - // Each number is between 0-255. Zero padding is not allowed. - "((\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.){3}(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])"; - - // dotted hex IP address RE. Each number is between 0x0-0xff. Zero padding is allowed, e.g. 0x00. + if (typeof flags.allowDottedDecimal != "boolean") { + flags.allowDottedDecimal = true; + } + if (typeof flags.allowDottedHex != "boolean") { + flags.allowDottedHex = true; + } + if (typeof flags.allowDottedOctal != "boolean") { + flags.allowDottedOctal = true; + } + if (typeof flags.allowDecimal != "boolean") { + flags.allowDecimal = true; + } + if (typeof flags.allowHex != "boolean") { + flags.allowHex = true; + } + if (typeof flags.allowIPv6 != "boolean") { + flags.allowIPv6 = true; + } + if (typeof flags.allowHybrid != "boolean") { + flags.allowHybrid = true; + } + var dottedDecimalRE = "((\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.){3}(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])"; var dottedHexRE = "(0[xX]0*[\\da-fA-F]?[\\da-fA-F]\\.){3}0[xX]0*[\\da-fA-F]?[\\da-fA-F]"; - - // dotted octal IP address RE. Each number is between 0000-0377. - // Zero padding is allowed, but each number must have at least 4 characters. var dottedOctalRE = "(0+[0-3][0-7][0-7]\\.){3}0+[0-3][0-7][0-7]"; - - // decimal IP address RE. A decimal number between 0-4294967295. - var decimalRE = "(0|[1-9]\\d{0,8}|[1-3]\\d{9}|4[01]\\d{8}|42[0-8]\\d{7}|429[0-3]\\d{6}|" + - "4294[0-8]\\d{5}|42949[0-5]\\d{4}|429496[0-6]\\d{3}|4294967[01]\\d{2}|42949672[0-8]\\d|429496729[0-5])"; - - // hexadecimal IP address RE. - // A hexadecimal number between 0x0-0xFFFFFFFF. Case insensitive. Zero padding is allowed. + var decimalRE = "(0|[1-9]\\d{0,8}|[1-3]\\d{9}|4[01]\\d{8}|42[0-8]\\d{7}|429[0-3]\\d{6}|" + "4294[0-8]\\d{5}|42949[0-5]\\d{4}|429496[0-6]\\d{3}|4294967[01]\\d{2}|42949672[0-8]\\d|429496729[0-5])"; var hexRE = "0[xX]0*[\\da-fA-F]{1,8}"; - - // IPv6 address RE. - // The format is written as eight groups of four hexadecimal digits, x:x:x:x:x:x:x:x, - // where x is between 0000-ffff. Zero padding is optional. Case insensitive. var ipv6RE = "([\\da-fA-F]{1,4}\\:){7}[\\da-fA-F]{1,4}"; - - // IPv6/IPv4 Hybrid address RE. - // The format is written as six groups of four hexadecimal digits, - // followed by the 4 dotted decimal IPv4 format. x:x:x:x:x:x:d.d.d.d - var hybridRE = "([\\da-fA-F]{1,4}\\:){6}" + - "((\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.){3}(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])"; - - // Build IP Address RE + var hybridRE = "([\\da-fA-F]{1,4}\\:){6}" + "((\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.){3}(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])"; var a = []; - if(flags.allowDottedDecimal){ a.push(dottedDecimalRE); } - if(flags.allowDottedHex){ a.push(dottedHexRE); } - if(flags.allowDottedOctal){ a.push(dottedOctalRE); } - if(flags.allowDecimal){ a.push(decimalRE); } - if(flags.allowHex){ a.push(hexRE); } - if(flags.allowIPv6){ a.push(ipv6RE); } - if(flags.allowHybrid){ a.push(hybridRE); } - + if (flags.allowDottedDecimal) { + a.push(dottedDecimalRE); + } + if (flags.allowDottedHex) { + a.push(dottedHexRE); + } + if (flags.allowDottedOctal) { + a.push(dottedOctalRE); + } + if (flags.allowDecimal) { + a.push(decimalRE); + } + if (flags.allowHex) { + a.push(hexRE); + } + if (flags.allowIPv6) { + a.push(ipv6RE); + } + if (flags.allowHybrid) { + a.push(hybridRE); + } var ipAddressRE = ""; - if(a.length > 0){ + if (a.length > 0) { ipAddressRE = "(" + a.join("|") + ")"; } - - return ipAddressRE; // String -} - -dojo.regexp.host = function(/*Object?*/flags){ - // summary: Builds a RE that matches a host - // description: A host is a domain name or an IP address, possibly followed by a port number. - // flags: An object. - // flags.allowIP Allow an IP address for hostname. Default is true. - // flags.allowLocal Allow the host to be "localhost". Default is false. - // flags.allowPort Allow a port number to be present. Default is true. - // flags in regexp.ipAddress can be applied. - // flags in regexp.tld can be applied. - - // assign default values to missing paramters + return ipAddressRE; +}; +dojo.regexp.host = function (flags) { flags = (typeof flags == "object") ? flags : {}; - if(typeof flags.allowIP != "boolean"){ flags.allowIP = true; } - if(typeof flags.allowLocal != "boolean"){ flags.allowLocal = false; } - if(typeof flags.allowPort != "boolean"){ flags.allowPort = true; } - - // Domain names can not end with a dash. + if (typeof flags.allowIP != "boolean") { + flags.allowIP = true; + } + if (typeof flags.allowLocal != "boolean") { + flags.allowLocal = false; + } + if (typeof flags.allowPort != "boolean") { + flags.allowPort = true; + } var domainNameRE = "([0-9a-zA-Z]([-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?\\.)+" + dojo.regexp.tld(flags); - - // port number RE - var portRE = ( flags.allowPort ) ? "(\\:" + dojo.regexp.integer({signed: false}) + ")?" : ""; - - // build host RE + var portRE = (flags.allowPort) ? "(\\:" + dojo.regexp.integer({signed:false}) + ")?" : ""; var hostNameRE = domainNameRE; - if(flags.allowIP){ hostNameRE += "|" + dojo.regexp.ipAddress(flags); } - if(flags.allowLocal){ hostNameRE += "|localhost"; } - - return "(" + hostNameRE + ")" + portRE; // String -} - -dojo.regexp.url = function(/*Object?*/flags){ - // summary: Builds a regular expression that matches a URL - // - // flags: An object - // flags.scheme Can be true, false, or [true, false]. - // This means: required, not allowed, or match either one. - // flags in regexp.host can be applied. - // flags in regexp.ipAddress can be applied. - // flags in regexp.tld can be applied. - - // assign default values to missing paramters + if (flags.allowIP) { + hostNameRE += "|" + dojo.regexp.ipAddress(flags); + } + if (flags.allowLocal) { + hostNameRE += "|localhost"; + } + return "(" + hostNameRE + ")" + portRE; +}; +dojo.regexp.url = function (flags) { flags = (typeof flags == "object") ? flags : {}; - if(typeof flags.scheme == "undefined"){ flags.scheme = [true, false]; } - - // Scheme RE - var protocolRE = dojo.regexp.buildGroupRE(flags.scheme, - function(q){ if(q){ return "(https?|ftps?)\\://"; } return ""; } - ); - - // Path and query and anchor RE + if (typeof flags.scheme == "undefined") { + flags.scheme = [true, false]; + } + var protocolRE = dojo.regexp.buildGroupRE(flags.scheme, function (q) { + if (q) { + return "(https?|ftps?)\\://"; + } + return ""; + }); var pathRE = "(/([^?#\\s/]+/)*)?([^?#\\s/]+(\\?[^?#\\s/]*)?(#[A-Za-z][\\w.:-]*)?)?"; - return protocolRE + dojo.regexp.host(flags) + pathRE; -} - - -dojo.regexp.emailAddress = function(/*Object?*/flags){ - // summary: Builds a regular expression that matches an email address - // - //flags: An object - // flags.allowCruft Allow address like . Default is false. - // flags in regexp.host can be applied. - // flags in regexp.ipAddress can be applied. - // flags in regexp.tld can be applied. - - // assign default values to missing paramters +}; +dojo.regexp.emailAddress = function (flags) { flags = (typeof flags == "object") ? flags : {}; - if (typeof flags.allowCruft != "boolean") { flags.allowCruft = false; } - flags.allowPort = false; // invalid in email addresses - - // user name RE - apostrophes are valid if there's not 2 in a row + if (typeof flags.allowCruft != "boolean") { + flags.allowCruft = false; + } + flags.allowPort = false; var usernameRE = "([\\da-z]+[-._+&'])*[\\da-z]+"; - - // build emailAddress RE var emailAddressRE = usernameRE + "@" + dojo.regexp.host(flags); - - // Allow email addresses with cruft - if ( flags.allowCruft ) { + if (flags.allowCruft) { emailAddressRE = "?"; } - - return emailAddressRE; // String -} - -dojo.regexp.emailAddressList = function(/*Object?*/flags){ - // summary: Builds a regular expression that matches a list of email addresses. - // - // flags: An object. - // flags.listSeparator The character used to separate email addresses. Default is ";", ",", "\n" or " ". - // flags in regexp.emailAddress can be applied. - // flags in regexp.host can be applied. - // flags in regexp.ipAddress can be applied. - // flags in regexp.tld can be applied. - - // assign default values to missing paramters + return emailAddressRE; +}; +dojo.regexp.emailAddressList = function (flags) { flags = (typeof flags == "object") ? flags : {}; - if(typeof flags.listSeparator != "string"){ flags.listSeparator = "\\s;,"; } - - // build a RE for an Email Address List - var emailAddressRE = dojo.regexp.emailAddress(flags); - var emailAddressListRE = "(" + emailAddressRE + "\\s*[" + flags.listSeparator + "]\\s*)*" + - emailAddressRE + "\\s*[" + flags.listSeparator + "]?\\s*"; - - return emailAddressListRE; // String -} - -dojo.regexp.integer = function(/*Object?*/flags){ - // summary: Builds a regular expression that matches an integer - // - // flags: An object - // flags.signed The leading plus-or-minus sign. Can be true, false, or [true, false]. - // Default is [true, false], (i.e. will match if it is signed or unsigned). - // flags.separator The character used as the thousands separator. Default is no separator. - // For more than one symbol use an array, e.g. [",", ""], makes ',' optional. - // flags.groupSize group size between separators - // flags.groupSize2 second grouping (for India) - - // assign default values to missing paramters - flags = (typeof flags == "object") ? flags : {}; - if(typeof flags.signed == "undefined"){ flags.signed = [true, false]; } - if(typeof flags.separator == "undefined"){ - flags.separator = ""; - } else if(typeof flags.groupSize == "undefined"){ - flags.groupSize = 3; + if (typeof flags.listSeparator != "string") { + flags.listSeparator = "\\s;,"; } - // build sign RE - var signRE = dojo.regexp.buildGroupRE(flags.signed, - function(q) { return q ? "[-+]" : ""; } - ); - - // number RE - var numberRE = dojo.regexp.buildGroupRE(flags.separator, - function(sep){ - if(sep == ""){ - return "(0|[1-9]\\d*)"; - } - var grp = flags.groupSize, grp2 = flags.groupSize2; - if(typeof grp2 != "undefined"){ - var grp2RE = "(0|[1-9]\\d{0," + (grp2-1) + "}([" + sep + "]\\d{" + grp2 + "})*[" + sep + "]\\d{" + grp + "})"; - return ((grp-grp2) > 0) ? "(" + grp2RE + "|(0|[1-9]\\d{0," + (grp-1) + "}))" : grp2RE; - } - return "(0|[1-9]\\d{0," + (grp-1) + "}([" + sep + "]\\d{" + grp + "})*)"; - } - ); - - // integer RE - return signRE + numberRE; // String -} - -dojo.regexp.realNumber = function(/*Object?*/flags){ - // summary: Builds a regular expression to match a real number in exponential notation - // - // flags:An object - // flags.places The integer number of decimal places. - // If not given, the decimal part is optional and the number of places is unlimited. - // flags.decimal A string for the character used as the decimal point. Default is ".". - // flags.fractional Whether decimal places are allowed. - // Can be true, false, or [true, false]. Default is [true, false] - // flags.exponent Express in exponential notation. Can be true, false, or [true, false]. - // Default is [true, false], (i.e. will match if the exponential part is present are not). - // flags.eSigned The leading plus-or-minus sign on the exponent. Can be true, false, - // or [true, false]. Default is [true, false], (i.e. will match if it is signed or unsigned). - // flags in regexp.integer can be applied. - - // assign default values to missing paramters + var emailAddressRE = dojo.regexp.emailAddress(flags); + var emailAddressListRE = "(" + emailAddressRE + "\\s*[" + flags.listSeparator + "]\\s*)*" + emailAddressRE + "\\s*[" + flags.listSeparator + "]?\\s*"; + return emailAddressListRE; +}; +dojo.regexp.integer = function (flags) { flags = (typeof flags == "object") ? flags : {}; - if(typeof flags.places != "number"){ flags.places = Infinity; } - if(typeof flags.decimal != "string"){ flags.decimal = "."; } - if(typeof flags.fractional == "undefined"){ flags.fractional = [true, false]; } - if(typeof flags.exponent == "undefined"){ flags.exponent = [true, false]; } - if(typeof flags.eSigned == "undefined"){ flags.eSigned = [true, false]; } - - // integer RE + if (typeof flags.signed == "undefined") { + flags.signed = [true, false]; + } + if (typeof flags.separator == "undefined") { + flags.separator = ""; + } else { + if (typeof flags.groupSize == "undefined") { + flags.groupSize = 3; + } + } + var signRE = dojo.regexp.buildGroupRE(flags.signed, function (q) { + return q ? "[-+]" : ""; + }); + var numberRE = dojo.regexp.buildGroupRE(flags.separator, function (sep) { + if (sep == "") { + return "(0|[1-9]\\d*)"; + } + var grp = flags.groupSize, grp2 = flags.groupSize2; + if (typeof grp2 != "undefined") { + var grp2RE = "(0|[1-9]\\d{0," + (grp2 - 1) + "}([" + sep + "]\\d{" + grp2 + "})*[" + sep + "]\\d{" + grp + "})"; + return ((grp - grp2) > 0) ? "(" + grp2RE + "|(0|[1-9]\\d{0," + (grp - 1) + "}))" : grp2RE; + } + return "(0|[1-9]\\d{0," + (grp - 1) + "}([" + sep + "]\\d{" + grp + "})*)"; + }); + return signRE + numberRE; +}; +dojo.regexp.realNumber = function (flags) { + flags = (typeof flags == "object") ? flags : {}; + if (typeof flags.places != "number") { + flags.places = Infinity; + } + if (typeof flags.decimal != "string") { + flags.decimal = "."; + } + if (typeof flags.fractional == "undefined") { + flags.fractional = [true, false]; + } + if (typeof flags.exponent == "undefined") { + flags.exponent = [true, false]; + } + if (typeof flags.eSigned == "undefined") { + flags.eSigned = [true, false]; + } var integerRE = dojo.regexp.integer(flags); - - // decimal RE - var decimalRE = dojo.regexp.buildGroupRE(flags.fractional, - function(q){ - var re = ""; - if(q && (flags.places > 0)){ - re = "\\" + flags.decimal; - if(flags.places == Infinity){ - re = "(" + re + "\\d+)?"; - }else{ - re = re + "\\d{" + flags.places + "}"; - } + var decimalRE = dojo.regexp.buildGroupRE(flags.fractional, function (q) { + var re = ""; + if (q && (flags.places > 0)) { + re = "\\" + flags.decimal; + if (flags.places == Infinity) { + re = "(" + re + "\\d+)?"; + } else { + re = re + "\\d{" + flags.places + "}"; } - - return re; } - ); - - // exponent RE - var exponentRE = dojo.regexp.buildGroupRE(flags.exponent, - function(q){ - if(q){ return "([eE]" + dojo.regexp.integer({ signed: flags.eSigned}) + ")"; } - return ""; + return re; + }); + var exponentRE = dojo.regexp.buildGroupRE(flags.exponent, function (q) { + if (q) { + return "([eE]" + dojo.regexp.integer({signed:flags.eSigned}) + ")"; } - ); - - // real number RE - return integerRE + decimalRE + exponentRE; // String -} - -dojo.regexp.currency = function(/*Object?*/flags){ - // summary: Builds a regular expression to match a monetary value - // - // flags: An object - // flags.symbol A currency symbol such as Yen "�", Pound "�", or the Euro sign "�". - // Default is "$". For more than one symbol use an array, e.g. ["$", ""], makes $ optional. - // flags.placement The symbol can come "before" the number or "after" the number. Default is "before". - // flags.signPlacement The sign can come "before" the number or "after" the sign, - // "around" to put parentheses around negative values, or "end" for the final char. Default is "before". - // flags.cents deprecated, in favor of flags.fractional - // flags in regexp.realNumber can be applied except exponent, eSigned. - - // assign default values to missing paramters + return ""; + }); + return integerRE + decimalRE + exponentRE; +}; +dojo.regexp.currency = function (flags) { flags = (typeof flags == "object") ? flags : {}; - if(typeof flags.signed == "undefined"){ flags.signed = [true, false]; } - if(typeof flags.symbol == "undefined"){ flags.symbol = "$"; } - if(typeof flags.placement != "string"){ flags.placement = "before"; } - if(typeof flags.signPlacement != "string"){ flags.signPlacement = "before"; } - if(typeof flags.separator == "undefined"){ flags.separator = ","; } - if(typeof flags.fractional == "undefined" && typeof flags.cents != "undefined"){ + if (typeof flags.signed == "undefined") { + flags.signed = [true, false]; + } + if (typeof flags.symbol == "undefined") { + flags.symbol = "$"; + } + if (typeof flags.placement != "string") { + flags.placement = "before"; + } + if (typeof flags.signPlacement != "string") { + flags.signPlacement = "before"; + } + if (typeof flags.separator == "undefined") { + flags.separator = ","; + } + if (typeof flags.fractional == "undefined" && typeof flags.cents != "undefined") { dojo.deprecated("dojo.regexp.currency: flags.cents", "use flags.fractional instead", "0.5"); flags.fractional = flags.cents; } - if(typeof flags.decimal != "string"){ flags.decimal = "."; } - - // build sign RE - var signRE = dojo.regexp.buildGroupRE(flags.signed, - function(q){ if (q){ return "[-+]"; } return ""; } - ); - - // build symbol RE - var symbolRE = dojo.regexp.buildGroupRE(flags.symbol, - function(symbol){ - // escape all special characters - return "\\s?" + symbol.replace( /([.$?*!=:|\\\/^])/g, "\\$1") + "\\s?"; + if (typeof flags.decimal != "string") { + flags.decimal = "."; + } + var signRE = dojo.regexp.buildGroupRE(flags.signed, function (q) { + if (q) { + return "[-+]"; } - ); - - switch (flags.signPlacement){ - case "before": - symbolRE = signRE + symbolRE; - break; - case "after": - symbolRE = symbolRE + signRE; - break; + return ""; + }); + var symbolRE = dojo.regexp.buildGroupRE(flags.symbol, function (symbol) { + return "\\s?" + symbol.replace(/([.$?*!=:|\\\/^])/g, "\\$1") + "\\s?"; + }); + switch (flags.signPlacement) { + case "before": + symbolRE = signRE + symbolRE; + break; + case "after": + symbolRE = symbolRE + signRE; + break; } - - // number RE - var flagsCopy = flags; //TODO: copy by value? - flagsCopy.signed = false; flagsCopy.exponent = false; + var flagsCopy = flags; + flagsCopy.signed = false; + flagsCopy.exponent = false; var numberRE = dojo.regexp.realNumber(flagsCopy); - - // build currency RE var currencyRE; - switch (flags.placement){ - case "before": - currencyRE = symbolRE + numberRE; - break; - case "after": - currencyRE = numberRE + symbolRE; - break; + switch (flags.placement) { + case "before": + currencyRE = symbolRE + numberRE; + break; + case "after": + currencyRE = numberRE + symbolRE; + break; } - - switch (flags.signPlacement){ - case "around": - currencyRE = "(" + currencyRE + "|" + "\\(" + currencyRE + "\\)" + ")"; - break; - case "begin": - currencyRE = signRE + currencyRE; - break; - case "end": - currencyRE = currencyRE + signRE; - break; + switch (flags.signPlacement) { + case "around": + currencyRE = "(" + currencyRE + "|" + "\\(" + currencyRE + "\\)" + ")"; + break; + case "begin": + currencyRE = signRE + currencyRE; + break; + case "end": + currencyRE = currencyRE + signRE; + break; } - return currencyRE; // String -} - - -dojo.regexp.us.state = function(/*Object?*/flags){ - // summary: A regular expression to match US state and territory abbreviations - // - // flags An object. - // flags.allowTerritories Allow Guam, Puerto Rico, etc. Default is true. - // flags.allowMilitary Allow military 'states', e.g. Armed Forces Europe (AE). Default is true. - - // assign default values to missing paramters + return currencyRE; +}; +dojo.regexp.us.state = function (flags) { flags = (typeof flags == "object") ? flags : {}; - if(typeof flags.allowTerritories != "boolean"){ flags.allowTerritories = true; } - if(typeof flags.allowMilitary != "boolean"){ flags.allowMilitary = true; } - - // state RE - var statesRE = - "AL|AK|AZ|AR|CA|CO|CT|DE|DC|FL|GA|HI|ID|IL|IN|IA|KS|KY|LA|ME|MD|MA|MI|MN|MS|MO|MT|" + - "NE|NV|NH|NJ|NM|NY|NC|ND|OH|OK|OR|PA|RI|SC|SD|TN|TX|UT|VT|VA|WA|WV|WI|WY"; - - // territories RE + if (typeof flags.allowTerritories != "boolean") { + flags.allowTerritories = true; + } + if (typeof flags.allowMilitary != "boolean") { + flags.allowMilitary = true; + } + var statesRE = "AL|AK|AZ|AR|CA|CO|CT|DE|DC|FL|GA|HI|ID|IL|IN|IA|KS|KY|LA|ME|MD|MA|MI|MN|MS|MO|MT|" + "NE|NV|NH|NJ|NM|NY|NC|ND|OH|OK|OR|PA|RI|SC|SD|TN|TX|UT|VT|VA|WA|WV|WI|WY"; var territoriesRE = "AS|FM|GU|MH|MP|PW|PR|VI"; - - // military states RE var militaryRE = "AA|AE|AP"; - - // Build states and territories RE - if(flags.allowTerritories){ statesRE += "|" + territoriesRE; } - if(flags.allowMilitary){ statesRE += "|" + militaryRE; } - - return "(" + statesRE + ")"; // String -} - -dojo.regexp.time = function(/*Object?*/flags){ - // summary: Builds a regular expression to match any International format for time - // description: The RE can match one format or one of multiple formats. - // - // Format - // h 12 hour, no zero padding. - // hh 12 hour, has leading zero. - // H 24 hour, no zero padding. - // HH 24 hour, has leading zero. - // m minutes, no zero padding. - // mm minutes, has leading zero. - // s seconds, no zero padding. - // ss seconds, has leading zero. - // t am or pm, case insensitive. - // All other characters must appear literally in the expression. - // - // Example - // "h:m:s t" -> 2:5:33 PM - // "HH:mm:ss" -> 14:05:33 - // - // flags: An object - // flags.format A string or an array of strings. Default is "h:mm:ss t". - // flags.amSymbol The symbol used for AM. Default is "AM". - // flags.pmSymbol The symbol used for PM. Default is "PM". - + if (flags.allowTerritories) { + statesRE += "|" + territoriesRE; + } + if (flags.allowMilitary) { + statesRE += "|" + militaryRE; + } + return "(" + statesRE + ")"; +}; +dojo.regexp.time = function (flags) { dojo.deprecated("dojo.regexp.time", "Use dojo.date.parse instead", "0.5"); - - // assign default values to missing paramters flags = (typeof flags == "object") ? flags : {}; - if(typeof flags.format == "undefined"){ flags.format = "h:mm:ss t"; } - if(typeof flags.amSymbol != "string"){ flags.amSymbol = "AM"; } - if(typeof flags.pmSymbol != "string"){ flags.pmSymbol = "PM"; } - - // Converts a time format to a RE - var timeRE = function(format){ - // escape all special characters - format = format.replace( /([.$?*!=:|{}\(\)\[\]\\\/^])/g, "\\$1"); - var amRE = flags.amSymbol.replace( /([.$?*!=:|{}\(\)\[\]\\\/^])/g, "\\$1"); - var pmRE = flags.pmSymbol.replace( /([.$?*!=:|{}\(\)\[\]\\\/^])/g, "\\$1"); - - // replace tokens with Regular Expressions + if (typeof flags.format == "undefined") { + flags.format = "h:mm:ss t"; + } + if (typeof flags.amSymbol != "string") { + flags.amSymbol = "AM"; + } + if (typeof flags.pmSymbol != "string") { + flags.pmSymbol = "PM"; + } + var timeRE = function (format) { + format = format.replace(/([.$?*!=:|{}\(\)\[\]\\\/^])/g, "\\$1"); + var amRE = flags.amSymbol.replace(/([.$?*!=:|{}\(\)\[\]\\\/^])/g, "\\$1"); + var pmRE = flags.pmSymbol.replace(/([.$?*!=:|{}\(\)\[\]\\\/^])/g, "\\$1"); format = format.replace("hh", "(0[1-9]|1[0-2])"); format = format.replace("h", "([1-9]|1[0-2])"); format = format.replace("HH", "([01][0-9]|2[0-3])"); @@ -497,80 +332,32 @@ dojo.regexp.time = function(/*Object?*/flags){ format = format.replace("m", "([1-5][0-9]|[0-9])"); format = format.replace("ss", "([0-5][0-9])"); format = format.replace("s", "([1-5][0-9]|[0-9])"); - format = format.replace("t", "\\s?(" + amRE + "|" + pmRE + ")\\s?" ); - - return format; // String + format = format.replace("t", "\\s?(" + amRE + "|" + pmRE + ")\\s?"); + return format; }; - - // build RE for multiple time formats - return dojo.regexp.buildGroupRE(flags.format, timeRE); // String -} - -dojo.regexp.numberFormat = function(/*Object?*/flags){ - // summary: Builds a regular expression to match any sort of number based format - // description: - // Use this method for phone numbers, social security numbers, zip-codes, etc. - // The RE can match one format or one of multiple formats. - // - // Format - // # Stands for a digit, 0-9. - // ? Stands for an optional digit, 0-9 or nothing. - // All other characters must appear literally in the expression. - // - // Example - // "(###) ###-####" -> (510) 542-9742 - // "(###) ###-#### x#???" -> (510) 542-9742 x153 - // "###-##-####" -> 506-82-1089 i.e. social security number - // "#####-####" -> 98225-1649 i.e. zip code - // - // flags: An object - // flags.format A string or an Array of strings for multiple formats. - - // assign default values to missing paramters + return dojo.regexp.buildGroupRE(flags.format, timeRE); +}; +dojo.regexp.numberFormat = function (flags) { flags = (typeof flags == "object") ? flags : {}; - if(typeof flags.format == "undefined"){ flags.format = "###-###-####"; } - - // Converts a number format to RE. - var digitRE = function(format){ - // escape all special characters, except '?' - format = format.replace( /([.$*!=:|{}\(\)\[\]\\\/^])/g, "\\$1"); - - // Now replace '?' with Regular Expression - format = format.replace(/\?/g, "\\d?"); - - // replace # with Regular Expression - format = format.replace(/#/g, "\\d"); - - return format; // String - }; - - // build RE for multiple number formats - return dojo.regexp.buildGroupRE(flags.format, digitRE); //String -} - - -dojo.regexp.buildGroupRE = function(/*value or Array of values*/a, /*Function(x) returns a regular expression as a String*/re){ - // summary: Builds a regular expression that groups subexpressions - // description: A utility function used by some of the RE generators. - // The subexpressions are constructed by the function, re, in the second parameter. - // re builds one subexpression for each elem in the array a, in the first parameter. - // Returns a string for a regular expression that groups all the subexpressions. - // - // a: A single value or an array of values. - // re: A function. Takes one parameter and converts it to a regular expression. - - // case 1: a is a single value. - if(!(a instanceof Array)){ - return re(a); // String + if (typeof flags.format == "undefined") { + flags.format = "###-###-####"; + } + var digitRE = function (format) { + format = format.replace(/([.$*!=:|{}\(\)\[\]\\\/^])/g, "\\$1"); + format = format.replace(/\?/g, "\\d?"); + format = format.replace(/#/g, "\\d"); + return format; + }; + return dojo.regexp.buildGroupRE(flags.format, digitRE); +}; +dojo.regexp.buildGroupRE = function (a, re) { + if (!(a instanceof Array)) { + return re(a); } - - // case 2: a is an array var b = []; - for (var i = 0; i < a.length; i++){ - // convert each elem to a RE + for (var i = 0; i < a.length; i++) { b.push(re(a[i])); } + return "(" + b.join("|") + ")"; +}; - // join the REs as alternatives in a RE group. - return "(" + b.join("|") + ")"; // String -} diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/rpc/Deferred.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/rpc/Deferred.js index 1e49dc90a..7b3aa6526 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/rpc/Deferred.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/rpc/Deferred.js @@ -10,7 +10,7 @@ dojo.provide("dojo.rpc.Deferred"); dojo.require("dojo.Deferred"); - dojo.deprecated("dojo.rpc.Deferred", "replaced by dojo.Deferred", "0.6"); dojo.rpc.Deferred = dojo.Deferred; dojo.rpc.Deferred.prototype = dojo.Deferred.prototype; + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/rpc/JotService.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/rpc/JotService.js index 2d63e0d30..3754c5927 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/rpc/JotService.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/rpc/JotService.js @@ -9,35 +9,17 @@ */ dojo.provide("dojo.rpc.JotService"); -dojo.require("dojo.rpc.RpcService"); dojo.require("dojo.rpc.JsonService"); dojo.require("dojo.json"); dojo.rpc.JotService = function(){ +dojo.require("dojo.rpc.RpcService"); +dojo.require("dojo.rpc.JsonService"); +dojo.require("dojo.json"); +dojo.rpc.JotService = function () { this.serviceUrl = "/_/jsonrpc"; -} - +}; dojo.inherits(dojo.rpc.JotService, dojo.rpc.JsonService); +dojo.lang.extend(dojo.rpc.JotService, {bind:function (method, parameters, deferredRequestHandler, url) { + dojo.io.bind({url:url || this.serviceUrl, content:{json:this.createRequest(method, parameters)}, method:"POST", mimetype:"text/json", load:this.resultCallback(deferredRequestHandler), error:this.errorCallback(deferredRequestHandler), preventCache:true}); +}, createRequest:function (method, params) { + var req = {"params":params, "method":method, "id":this.lastSubmissionId++}; + return dojo.json.serialize(req); +}}); -dojo.lang.extend(dojo.rpc.JotService, { - bind: function(method, parameters, deferredRequestHandler, url){ - //summary - //Jot bind method. Takes remote method, parameters, deferred, - //and a url, calls createRequest to make a Jot RPC envelope and - //passes that off with bind. - dojo.io.bind({ - url: url||this.serviceUrl, - content: { - json: this.createRequest(method, parameters) - }, - method: "POST", - mimetype: "text/json", - load: this.resultCallback(deferredRequestHandler), - error: this.errorCallback(deferredRequestHandler), - preventCache: true - }); - }, - - createRequest: function(method, params){ - //summary - //create the json portion of the Jot request - var req = { "params": params, "method": method, "id": this.lastSubmissionId++ }; - return dojo.json.serialize(req); - } -}); diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/rpc/JsonService.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/rpc/JsonService.js index 31ae727f9..d3195c30a 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/rpc/JsonService.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/rpc/JsonService.js @@ -13,107 +13,57 @@ dojo.require("dojo.rpc.RpcService"); dojo.require("dojo.io.*"); dojo.require("dojo.json"); dojo.require("dojo.lang.common"); - -dojo.rpc.JsonService = function(args){ - // passing just the URL isn't terribly useful. It's expected that at - // various times folks will want to specify: - // - just the serviceUrl (for use w/ remoteCall()) - // - the text of the SMD to evaluate - // - a raw SMD object - // - the SMD URL - if(args){ - if(dojo.lang.isString(args)){ - // we assume it's an SMD file to be processed, since this was the - // earlier function signature - - // FIXME: also accept dojo.uri.Uri objects? +dojo.rpc.JsonService = function (args) { + if (args) { + if (dojo.lang.isString(args)) { this.connect(args); - }else{ - // otherwise we assume it's an arguments object with the following - // (optional) properties: - // - serviceUrl - // - strictArgChecks - // - smdUrl - // - smdStr - // - smdObj - if(args["smdUrl"]){ + } else { + if (args["smdUrl"]) { this.connect(args.smdUrl); } - if(args["smdStr"]){ - this.processSmd(dj_eval("("+args.smdStr+")")); + if (args["smdStr"]) { + this.processSmd(dj_eval("(" + args.smdStr + ")")); } - if(args["smdObj"]){ + if (args["smdObj"]) { this.processSmd(args.smdObj); } - if(args["serviceUrl"]){ + if (args["serviceUrl"]) { this.serviceUrl = args.serviceUrl; } - if(typeof args["strictArgChecks"] != "undefined"){ + if (typeof args["strictArgChecks"] != "undefined") { this.strictArgChecks = args.strictArgChecks; } } } -} - +}; dojo.inherits(dojo.rpc.JsonService, dojo.rpc.RpcService); - -dojo.extend(dojo.rpc.JsonService, { - - bustCache: false, - - contentType: "application/json-rpc", - - lastSubmissionId: 0, - - callRemote: function(method, params){ - //summary - // call an arbitrary remote method without requiring it - // to be predefined with SMD - var deferred = new dojo.Deferred(); - this.bind(method, params, deferred); - return deferred; - }, - - bind: function(method, parameters, deferredRequestHandler, url){ - //summary - //JSON-RPC bind method. Takes remote method, parameters, deferred, - //and a url, calls createRequest to make a JSON-RPC envelope and - //passes that off with bind. - - dojo.io.bind({ - url: url||this.serviceUrl, - postContent: this.createRequest(method, parameters), - method: "POST", - contentType: this.contentType, - mimetype: "text/json", - load: this.resultCallback(deferredRequestHandler), - error: this.errorCallback(deferredRequestHandler), - preventCache:this.bustCache - }); - }, - - createRequest: function(method, params){ - //summary - //create a JSON-RPC envelope for the request - var req = { "params": params, "method": method, "id": ++this.lastSubmissionId }; - var data = dojo.json.serialize(req); - dojo.debug("JsonService: JSON-RPC Request: " + data); - return data; - }, - - parseResults: function(obj){ - //summary - //parse the result envelope and pass the results back to - // to the callback function - if(!obj){ return; } - if (obj["Result"]!=null){ - return obj["Result"]; - }else if(obj["result"]!=null){ - return obj["result"]; - }else if(obj["ResultSet"]){ - return obj["ResultSet"]; - }else{ - return obj; +dojo.extend(dojo.rpc.JsonService, {bustCache:false, contentType:"application/json-rpc", lastSubmissionId:0, callRemote:function (method, params) { + var deferred = new dojo.Deferred(); + this.bind(method, params, deferred); + return deferred; +}, bind:function (method, parameters, deferredRequestHandler, url) { + dojo.io.bind({url:url || this.serviceUrl, postContent:this.createRequest(method, parameters), method:"POST", contentType:this.contentType, mimetype:"text/json", load:this.resultCallback(deferredRequestHandler), error:this.errorCallback(deferredRequestHandler), preventCache:this.bustCache}); +}, createRequest:function (method, params) { + var req = {"params":params, "method":method, "id":++this.lastSubmissionId}; + var data = dojo.json.serialize(req); + dojo.debug("JsonService: JSON-RPC Request: " + data); + return data; +}, parseResults:function (obj) { + if (!obj) { + return; + } + if (obj["Result"] != null) { + return obj["Result"]; + } else { + if (obj["result"] != null) { + return obj["result"]; + } else { + if (obj["ResultSet"]) { + return obj["ResultSet"]; + } else { + return obj; + } } } -}); +}}); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/rpc/RpcService.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/rpc/RpcService.js index 1968dad13..b33ecb1cb 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/rpc/RpcService.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/rpc/RpcService.js @@ -13,110 +13,60 @@ dojo.require("dojo.io.*"); dojo.require("dojo.json"); dojo.require("dojo.lang.func"); dojo.require("dojo.Deferred"); - -dojo.rpc.RpcService = function(url){ - // summary - // constructor for rpc base class - if(url){ +dojo.rpc.RpcService = function (url) { + if (url) { this.connect(url); } -} - -dojo.lang.extend(dojo.rpc.RpcService, { - - strictArgChecks: true, - serviceUrl: "", - - parseResults: function(obj){ - // summary - // parse the results coming back from an rpc request. - // this base implementation, just returns the full object - // subclasses should parse and only return the actual results - return obj; - }, - - errorCallback: function(/* dojo.Deferred */ deferredRequestHandler){ - // summary - // create callback that calls the Deferres errback method - return function(type, e){ - deferredRequestHandler.errback(new Error(e.message)); +}; +dojo.lang.extend(dojo.rpc.RpcService, {strictArgChecks:true, serviceUrl:"", parseResults:function (obj) { + return obj; +}, errorCallback:function (deferredRequestHandler) { + return function (type, e) { + deferredRequestHandler.errback(new Error(e.message)); + }; +}, resultCallback:function (deferredRequestHandler) { + var tf = dojo.lang.hitch(this, function (type, obj, e) { + if (obj["error"] != null) { + var err = new Error(obj.error); + err.id = obj.id; + deferredRequestHandler.errback(err); + } else { + var results = this.parseResults(obj); + deferredRequestHandler.callback(results); } - }, - - resultCallback: function(/* dojo.Deferred */ deferredRequestHandler){ - // summary - // create callback that calls the Deferred's callback method - var tf = dojo.lang.hitch(this, - function(type, obj, e){ - if (obj["error"]!=null) { - var err = new Error(obj.error); - err.id = obj.id; - deferredRequestHandler.errback(err); + }); + return tf; +}, generateMethod:function (method, parameters, url) { + return dojo.lang.hitch(this, function () { + var deferredRequestHandler = new dojo.Deferred(); + if ((this.strictArgChecks) && (parameters != null) && (arguments.length != parameters.length)) { + dojo.raise("Invalid number of parameters for remote method."); + } else { + this.bind(method, arguments, deferredRequestHandler, url); + } + return deferredRequestHandler; + }); +}, processSmd:function (object) { + dojo.debug("RpcService: Processing returned SMD."); + if (object.methods) { + dojo.lang.forEach(object.methods, function (m) { + if (m && m["name"]) { + dojo.debug("RpcService: Creating Method: this.", m.name, "()"); + this[m.name] = this.generateMethod(m.name, m.parameters, m["url"] || m["serviceUrl"] || m["serviceURL"]); + if (dojo.lang.isFunction(this[m.name])) { + dojo.debug("RpcService: Successfully created", m.name, "()"); } else { - var results = this.parseResults(obj); - deferredRequestHandler.callback(results); + dojo.debug("RpcService: Failed to create", m.name, "()"); } } - ); - return tf; - }, - - - generateMethod: function(/*string*/ method, /*array*/ parameters, /*string*/ url){ - // summary - // generate the local bind methods for the remote object - return dojo.lang.hitch(this, function(){ - var deferredRequestHandler = new dojo.Deferred(); - - // if params weren't specified, then we can assume it's varargs - if( (this.strictArgChecks) && - (parameters != null) && - (arguments.length != parameters.length) - ){ - // put error stuff here, no enough params - dojo.raise("Invalid number of parameters for remote method."); - } else { - this.bind(method, arguments, deferredRequestHandler, url); - } - - return deferredRequestHandler; - }); - }, - - processSmd: function(/*json*/ object){ - // summary - // callback method for reciept of a smd object. Parse the smd and - // generate functions based on the description - dojo.debug("RpcService: Processing returned SMD."); - if(object.methods){ - dojo.lang.forEach(object.methods, function(m){ - if(m && m["name"]){ - dojo.debug("RpcService: Creating Method: this.", m.name, "()"); - this[m.name] = this.generateMethod( m.name, - m.parameters, - m["url"]||m["serviceUrl"]||m["serviceURL"]); - if(dojo.lang.isFunction(this[m.name])){ - dojo.debug("RpcService: Successfully created", m.name, "()"); - }else{ - dojo.debug("RpcService: Failed to create", m.name, "()"); - } - } - }, this); - } - - this.serviceUrl = object.serviceUrl||object.serviceURL; - dojo.debug("RpcService: Dojo RpcService is ready for use."); - }, - - connect: function(/*String*/ smdUrl){ - // summary - // connect to a remote url and retrieve a smd object - dojo.debug("RpcService: Attempting to load SMD document from:", smdUrl); - dojo.io.bind({ - url: smdUrl, - mimetype: "text/json", - load: dojo.lang.hitch(this, function(type, object, e){ return this.processSmd(object); }), - sync: true - }); + }, this); } -}); + this.serviceUrl = object.serviceUrl || object.serviceURL; + dojo.debug("RpcService: Dojo RpcService is ready for use."); +}, connect:function (smdUrl) { + dojo.debug("RpcService: Attempting to load SMD document from:", smdUrl); + dojo.io.bind({url:smdUrl, mimetype:"text/json", load:dojo.lang.hitch(this, function (type, object, e) { + return this.processSmd(object); + }), sync:true}); +}}); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/rpc/YahooService.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/rpc/YahooService.js index e69561179..67d5bb65c 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/rpc/YahooService.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/rpc/YahooService.js @@ -14,46 +14,26 @@ dojo.require("dojo.rpc.JsonService"); dojo.require("dojo.json"); dojo.require("dojo.uri.*"); dojo.require("dojo.io.ScriptSrcIO"); - -dojo.rpc.YahooService = function(appId){ +dojo.rpc.YahooService = function (appId) { this.appId = appId; - if(!appId){ + if (!appId) { this.appId = "dojotoolkit"; - dojo.debug( "please initialize the YahooService class with your own", - "application ID. Using the default may cause problems during", - "deployment of your application"); + dojo.debug("please initialize the YahooService class with your own", "application ID. Using the default may cause problems during", "deployment of your application"); } - this.connect(dojo.uri.dojoUri("src/rpc/yahoo.smd")); + if (djConfig["useXDomain"] && !djConfig["yahooServiceSmdUrl"]) { + dojo.debug("dojo.rpc.YahooService: When using cross-domain Dojo builds," + " please save yahoo.smd to your domain and set djConfig.yahooServiceSmdUrl" + " to the path on your domain to yahoo.smd"); + } + this.connect(djConfig["yahooServiceSmdUrl"] || dojo.uri.moduleUri("dojo.rpc", "yahoo.smd")); this.strictArgChecks = false; -} - +}; dojo.inherits(dojo.rpc.YahooService, dojo.rpc.JsonService); - -dojo.lang.extend(dojo.rpc.YahooService, { - strictArgChecks: false, - - bind: function(method, parameters, deferredRequestHandler, url){ - //summary - //Yahoo RPC bind method. Takes remote method, parameters, deferred, - //and a url and sends of a ScriptSrcIO request to connect to Yahoo - //services crossplatform - var params = parameters; - if( (dojo.lang.isArrayLike(parameters))&& - (parameters.length == 1)){ - params = parameters[0]; - } - params.output = "json"; - params.appid= this.appId; - dojo.io.bind({ - url: url||this.serviceUrl, - transport: "ScriptSrcTransport", - // FIXME: need to get content interpolation fixed - content: params, - jsonParamName: "callback", - mimetype: "text/json", - load: this.resultCallback(deferredRequestHandler), - error: this.errorCallback(deferredRequestHandler), - preventCache: true - }); +dojo.lang.extend(dojo.rpc.YahooService, {strictArgChecks:false, bind:function (method, parameters, deferredRequestHandler, url) { + var params = parameters; + if ((dojo.lang.isArrayLike(parameters)) && (parameters.length == 1)) { + params = parameters[0]; } -}); + params.output = "json"; + params.appid = this.appId; + dojo.io.bind({url:url || this.serviceUrl, transport:"ScriptSrcTransport", content:params, jsonParamName:"callback", mimetype:"text/json", load:this.resultCallback(deferredRequestHandler), error:this.errorCallback(deferredRequestHandler), preventCache:true}); +}}); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/rpc/__package__.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/rpc/__package__.js index 7fb4f9c9d..94de073d5 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/rpc/__package__.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/rpc/__package__.js @@ -8,7 +8,6 @@ http://dojotoolkit.org/community/licensing.shtml */ -dojo.kwCompoundRequire({ - common: [["dojo.rpc.JsonService", false, false]] -}); +dojo.kwCompoundRequire({common:[["dojo.rpc.JsonService", false, false]]}); dojo.provide("dojo.rpc.*"); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/rpc/yahoo.smd b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/rpc/yahoo.smd index 85648fa4d..0a305caef 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/rpc/yahoo.smd +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/rpc/yahoo.smd @@ -86,9 +86,6 @@ // // WEB SEARCH // - - // NOTE: contextual search and term extraction are not stubbed out - // becaues I'm not sure if we can POST via script src inclusion method { // http://developer.yahoo.com/search/web/V1/webSearch.html "name":"webSearch", @@ -124,6 +121,35 @@ { "name":"results", "type":"INTEGER" } // 1-50, defaults to 10 ] }, + { + // http://developer.yahoo.com/search/content/V1/termExtraction.html + "name":"termExtraction", + "serviceURL": "http://search.yahooapis.com/ContentAnalysisService/V1/termExtraction", + "parameters":[ + { "name":"query", "type":"STRING" }, + { "name":"context", "type":"STRING" }, + { "name":"results", "type":"INTEGER" } // 1-50, defaults to 10 + ] + }, + { + // http://developer.yahoo.com/search/web/V1/contextSearch.html + "name":"contextSearch", + "serviceURL": "http://search.yahooapis.com/WebSearchService/V1/contextSearch", + "parameters":[ + { "name":"query", "type":"STRING" }, + { "name":"context", "type":"STRING" }, + { "name":"type", "type":"STRING" }, // defaults to "all" + { "name":"results", "type":"INTEGER" }, // defaults to 10 + { "name":"start", "type":"INTEGER" }, // defaults to 1 + { "name":"format", "type":"STRING" }, // defaults to "any", can be "html", "msword", "pdf", "ppt", "rst", "txt", or "xls" + { "name":"adult_ok", "type":"INTEGER" }, // defaults to null + { "name":"similar_ok", "type":"INTEGER" }, // defaults to null + { "name":"language", "type":"STRING" }, // defaults to null + { "name":"country", "type":"STRING" }, // defaults to null + { "name":"site", "type":"STRING" }, // defaults to null + { "name":"license", "type":"STRING" } // defaults to "any", could be "cc_any", "cc_commercial", "cc_modifiable" + ] + }, // // IMAGE SEARCH // diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/selection/Selection.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/selection/Selection.js index a96f5a559..81be1d7fa 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/selection/Selection.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/selection/Selection.js @@ -11,415 +11,304 @@ dojo.provide("dojo.selection.Selection"); dojo.require("dojo.lang.array"); dojo.require("dojo.lang.func"); +dojo.require("dojo.lang.common"); dojo.require("dojo.math"); - -dojo.selection.Selection = function(items, isCollection) { +dojo.declare("dojo.selection.Selection", null, {initializer:function (items, isCollection) { this.items = []; this.selection = []; this._pivotItems = []; this.clearItems(); - - if(items) { - if(isCollection) { + if (items) { + if (isCollection) { this.setItemsCollection(items); } else { this.setItems(items); } } -} -dojo.lang.extend(dojo.selection.Selection, { - items: null, // items to select from, order matters for growable selections - - selection: null, // items selected, aren't stored in order (see sorted()) - lastSelected: null, // last item selected - - allowImplicit: true, // if true, grow selection will start from 0th item when nothing is selected - length: 0, // number of *selected* items - - // if true, the selection is treated as an in-order and can grow by ranges, not just by single item - isGrowable: true, - - _pivotItems: null, // stack of pivot items - _pivotItem: null, // item we grow selections from, top of stack - - // event handlers - onSelect: function(item) {}, - onDeselect: function(item) {}, - onSelectChange: function(item, selected) {}, - - _find: function(item, inSelection) { - if(inSelection) { - return dojo.lang.find(this.selection, item); - } else { - return dojo.lang.find(this.items, item); +}, items:null, selection:null, lastSelected:null, allowImplicit:true, length:0, isGrowable:true, _pivotItems:null, _pivotItem:null, onSelect:function (item) { +}, onDeselect:function (item) { +}, onSelectChange:function (item, selected) { +}, _find:function (item, inSelection) { + if (inSelection) { + return dojo.lang.find(this.selection, item); + } else { + return dojo.lang.find(this.items, item); + } +}, isSelectable:function (item) { + return true; +}, setItems:function () { + this.clearItems(); + this.addItems.call(this, arguments); +}, setItemsCollection:function (collection) { + this.items = collection; +}, addItems:function () { + var args = dojo.lang.unnest(arguments); + for (var i = 0; i < args.length; i++) { + this.items.push(args[i]); + } +}, addItemsAt:function (item, before) { + if (this.items.length == 0) { + return this.addItems(dojo.lang.toArray(arguments, 2)); + } + if (!this.isItem(item)) { + item = this.items[item]; + } + if (!item) { + throw new Error("addItemsAt: item doesn't exist"); + } + var idx = this._find(item); + if (idx > 0 && before) { + idx--; + } + for (var i = 2; i < arguments.length; i++) { + if (!this.isItem(arguments[i])) { + this.items.splice(idx++, 0, arguments[i]); } - }, - - isSelectable: function(item) { - // user-customizable, will filter items through this - return true; - }, - - setItems: function(/* ... */) { - this.clearItems(); - this.addItems.call(this, arguments); - }, - - // this is in case you have an active collection array-like object - // (i.e. getElementsByTagName collection) that manages its own order - // and item list - setItemsCollection: function(collection) { - this.items = collection; - }, - - addItems: function(/* ... */) { - var args = dojo.lang.unnest(arguments); - for(var i = 0; i < args.length; i++) { - this.items.push(args[i]); + } +}, removeItem:function (item) { + var idx = this._find(item); + if (idx > -1) { + this.items.splice(idx, 1); + } + idx = this._find(item, true); + if (idx > -1) { + this.selection.splice(idx, 1); + } +}, clearItems:function () { + this.items = []; + this.deselectAll(); +}, isItem:function (item) { + return this._find(item) > -1; +}, isSelected:function (item) { + return this._find(item, true) > -1; +}, selectFilter:function (item, selection, add, grow) { + return true; +}, update:function (item, add, grow, noToggle) { + if (!this.isItem(item)) { + return false; + } + if (this.isGrowable && grow) { + if ((!this.isSelected(item)) && this.selectFilter(item, this.selection, false, true)) { + this.grow(item); + this.lastSelected = item; } - }, - - addItemsAt: function(item, before /* ... */) { - if(this.items.length == 0) { // work for empy case - return this.addItems(dojo.lang.toArray(arguments, 2)); - } - - if(!this.isItem(item)) { - item = this.items[item]; - } - if(!item) { throw new Error("addItemsAt: item doesn't exist"); } - var idx = this._find(item); - if(idx > 0 && before) { idx--; } - for(var i = 2; i < arguments.length; i++) { - if(!this.isItem(arguments[i])) { - this.items.splice(idx++, 0, arguments[i]); - } - } - }, - - removeItem: function(item) { - // remove item - var idx = this._find(item); - if(idx > -1) { - this.items.splice(idx, 1); - } - // remove from selection - // FIXME: do we call deselect? I don't think so because this isn't how - // you usually want to deselect an item. For example, if you deleted an - // item, you don't really want to deselect it -- you want it gone. -DS - idx = this._find(item, true); - if(idx > -1) { - this.selection.splice(idx, 1); - } - }, - - clearItems: function() { - this.items = []; - this.deselectAll(); - }, - - isItem: function(item) { - return this._find(item) > -1; - }, - - isSelected: function(item) { - return this._find(item, true) > -1; - }, - - /** - * allows you to filter item in or out of the selection - * depending on the current selection and action to be taken - **/ - selectFilter: function(item, selection, add, grow) { - return true; - }, - - /** - * update -- manages selections, most selecting should be done here - * item => item which may be added/grown to/only selected/deselected - * add => behaves like ctrl in windows selection world - * grow => behaves like shift - * noToggle => if true, don't toggle selection on item - **/ - update: function(item, add, grow, noToggle) { - if(!this.isItem(item)) { return false; } - - if(this.isGrowable && grow) { - if(!this.isSelected(item) - && this.selectFilter(item, this.selection, false, true)) { - this.grow(item); - this.lastSelected = item; - } - } else if(add) { - if(this.selectFilter(item, this.selection, true, false)) { - if(noToggle) { - if(this.select(item)) { + } else { + if (add) { + if (this.selectFilter(item, this.selection, true, false)) { + if (noToggle) { + if (this.select(item)) { + this.lastSelected = item; + } + } else { + if (this.toggleSelected(item)) { this.lastSelected = item; } - } else if(this.toggleSelected(item)) { - this.lastSelected = item; } } } else { this.deselectAll(); this.select(item); } - - this.length = this.selection.length; - }, - - /** - * Grow a selection. - * toItem => which item to grow selection to - * fromItem => which item to start the growth from (it won't be selected) - * - * Any items in (fromItem, lastSelected] that aren't part of - * (fromItem, toItem] will be deselected - **/ - grow: function(toItem, fromItem) { - if(!this.isGrowable) { return; } - - if(arguments.length == 1) { - fromItem = this._pivotItem; - if(!fromItem && this.allowImplicit) { - fromItem = this.items[0]; - } + } + this.length = this.selection.length; + return true; +}, grow:function (toItem, fromItem) { + if (!this.isGrowable) { + return; + } + if (arguments.length == 1) { + fromItem = this._pivotItem; + if (!fromItem && this.allowImplicit) { + fromItem = this.items[0]; } - if(!toItem || !fromItem) { return false; } - - var fromIdx = this._find(fromItem); - - // get items to deselect (fromItem, lastSelected] - var toDeselect = {}; - var lastIdx = -1; - if(this.lastSelected) { - lastIdx = this._find(this.lastSelected); - var step = fromIdx < lastIdx ? -1 : 1; - var range = dojo.math.range(lastIdx, fromIdx, step); - for(var i = 0; i < range.length; i++) { - toDeselect[range[i]] = true; - } + } + if (!toItem || !fromItem) { + return false; + } + var fromIdx = this._find(fromItem); + var toDeselect = {}; + var lastIdx = -1; + if (this.lastSelected) { + lastIdx = this._find(this.lastSelected); + var step = fromIdx < lastIdx ? -1 : 1; + var range = dojo.math.range(lastIdx, fromIdx, step); + for (var i = 0; i < range.length; i++) { + toDeselect[range[i]] = true; } - - // add selection (fromItem, toItem] - var toIdx = this._find(toItem); - var step = fromIdx < toIdx ? -1 : 1; - var shrink = lastIdx >= 0 && step == 1 ? lastIdx < toIdx : lastIdx > toIdx; - var range = dojo.math.range(toIdx, fromIdx, step); - if(range.length) { - for(var i = range.length-1; i >= 0; i--) { - var item = this.items[range[i]]; - if(this.selectFilter(item, this.selection, false, true)) { - if(this.select(item, true) || shrink) { - this.lastSelected = item; - } - if(range[i] in toDeselect) { - delete toDeselect[range[i]]; - } + } + var toIdx = this._find(toItem); + var step = fromIdx < toIdx ? -1 : 1; + var shrink = lastIdx >= 0 && step == 1 ? lastIdx < toIdx : lastIdx > toIdx; + var range = dojo.math.range(toIdx, fromIdx, step); + if (range.length) { + for (var i = range.length - 1; i >= 0; i--) { + var item = this.items[range[i]]; + if (this.selectFilter(item, this.selection, false, true)) { + if (this.select(item, true) || shrink) { + this.lastSelected = item; + } + if (range[i] in toDeselect) { + delete toDeselect[range[i]]; } } - } else { - this.lastSelected = fromItem; } - - // now deselect... - for(var i in toDeselect) { - if(this.items[i] == this.lastSelected) { - //dojo.debug("oops!"); - } - this.deselect(this.items[i]); + } else { + this.lastSelected = fromItem; + } + for (var i in toDeselect) { + if (this.items[i] == this.lastSelected) { } - - // make sure everything is all kosher after selections+deselections - this._updatePivot(); - }, - - /** - * Grow selection upwards one item from lastSelected - **/ - growUp: function() { - if(!this.isGrowable) { return; } - - var idx = this._find(this.lastSelected) - 1; - while(idx >= 0) { - if(this.selectFilter(this.items[idx], this.selection, false, true)) { - this.grow(this.items[idx]); - break; - } - idx--; + this.deselect(this.items[i]); + } + this._updatePivot(); +}, growUp:function () { + if (!this.isGrowable) { + return; + } + var idx = this._find(this.lastSelected) - 1; + while (idx >= 0) { + if (this.selectFilter(this.items[idx], this.selection, false, true)) { + this.grow(this.items[idx]); + break; } - }, - - /** - * Grow selection downwards one item from lastSelected - **/ - growDown: function() { - if(!this.isGrowable) { return; } - - var idx = this._find(this.lastSelected); - if(idx < 0 && this.allowImplicit) { - this.select(this.items[0]); - idx = 0; + idx--; + } +}, growDown:function () { + if (!this.isGrowable) { + return; + } + var idx = this._find(this.lastSelected); + if (idx < 0 && this.allowImplicit) { + this.select(this.items[0]); + idx = 0; + } + idx++; + while (idx > 0 && idx < this.items.length) { + if (this.selectFilter(this.items[idx], this.selection, false, true)) { + this.grow(this.items[idx]); + break; } idx++; - while(idx > 0 && idx < this.items.length) { - if(this.selectFilter(this.items[idx], this.selection, false, true)) { - this.grow(this.items[idx]); - break; - } - idx++; - } - }, - - toggleSelected: function(item, noPivot) { - if(this.isItem(item)) { - if(this.select(item, noPivot)) { return 1; } - if(this.deselect(item)) { return -1; } - } - return 0; - }, - - select: function(item, noPivot) { - if(this.isItem(item) && !this.isSelected(item) - && this.isSelectable(item)) { - this.selection.push(item); - this.lastSelected = item; - this.onSelect(item); - this.onSelectChange(item, true); - if(!noPivot) { - this._addPivot(item); - } - this.length = this.selection.length; - return true; - } - return false; - }, - - deselect: function(item) { - var idx = this._find(item, true); - if(idx > -1) { - this.selection.splice(idx, 1); - this.onDeselect(item); - this.onSelectChange(item, false); - if(item == this.lastSelected) { - this.lastSelected = null; - } - this._removePivot(item); - this.length = this.selection.length; - return true; - } - return false; - }, - - selectAll: function() { - for(var i = 0; i < this.items.length; i++) { - this.select(this.items[i]); - } - }, - - deselectAll: function() { - while(this.selection && this.selection.length) { - this.deselect(this.selection[0]); - } - }, - - selectNext: function() { - var idx = this._find(this.lastSelected); - while(idx > -1 && ++idx < this.items.length) { - if(this.isSelectable(this.items[idx])) { - this.deselectAll(); - this.select(this.items[idx]); - return true; - } - } - return false; - }, - - selectPrevious: function() { - //debugger; - var idx = this._find(this.lastSelected); - while(idx-- > 0) { - if(this.isSelectable(this.items[idx])) { - this.deselectAll(); - this.select(this.items[idx]); - return true; - } - } - return false; - }, - - // select first selectable item - selectFirst: function() { - this.deselectAll(); - var idx = 0; - while(this.items[idx] && !this.select(this.items[idx])) { - idx++; - } - return this.items[idx] ? true : false; - }, - - // select last selectable item - selectLast: function() { - this.deselectAll(); - var idx = this.items.length-1; - while(this.items[idx] && !this.select(this.items[idx])) { - idx--; - } - return this.items[idx] ? true : false; - }, - - _addPivot: function(item, andClear) { - this._pivotItem = item; - if(andClear) { - this._pivotItems = [item]; - } else { - this._pivotItems.push(item); - } - }, - - _removePivot: function(item) { - var i = dojo.lang.find(this._pivotItems, item); - if(i > -1) { - this._pivotItems.splice(i, 1); - this._pivotItem = this._pivotItems[this._pivotItems.length-1]; - } - - this._updatePivot(); - }, - - _updatePivot: function() { - if(this._pivotItems.length == 0) { - if(this.lastSelected) { - this._addPivot(this.lastSelected); - } - } - }, - - sorted: function() { - return dojo.lang.toArray(this.selection).sort( - dojo.lang.hitch(this, function(a, b) { - var A = this._find(a), B = this._find(b); - if(A > B) { - return 1; - } else if(A < B) { - return -1; - } else { - return 0; - } - }) - ); - }, - - // remove any items from the selection that are no longer in this.items - updateSelected: function() { - for(var i = 0; i < this.selection.length; i++) { - if(this._find(this.selection[i]) < 0) { - var removed = this.selection.splice(i, 1); - - this._removePivot(removed[0]); - } - } - - this.length = this.selection.length; } -}); +}, toggleSelected:function (item, noPivot) { + if (this.isItem(item)) { + if (this.select(item, noPivot)) { + return 1; + } + if (this.deselect(item)) { + return -1; + } + } + return 0; +}, select:function (item, noPivot) { + if (this.isItem(item) && !this.isSelected(item) && this.isSelectable(item)) { + this.selection.push(item); + this.lastSelected = item; + this.onSelect(item); + this.onSelectChange(item, true); + if (!noPivot) { + this._addPivot(item); + } + this.length = this.selection.length; + return true; + } + return false; +}, deselect:function (item) { + var idx = this._find(item, true); + if (idx > -1) { + this.selection.splice(idx, 1); + this.onDeselect(item); + this.onSelectChange(item, false); + if (item == this.lastSelected) { + this.lastSelected = null; + } + this._removePivot(item); + this.length = this.selection.length; + return true; + } + return false; +}, selectAll:function () { + for (var i = 0; i < this.items.length; i++) { + this.select(this.items[i]); + } +}, deselectAll:function () { + while (this.selection && this.selection.length) { + this.deselect(this.selection[0]); + } +}, selectNext:function () { + var idx = this._find(this.lastSelected); + while (idx > -1 && ++idx < this.items.length) { + if (this.isSelectable(this.items[idx])) { + this.deselectAll(); + this.select(this.items[idx]); + return true; + } + } + return false; +}, selectPrevious:function () { + var idx = this._find(this.lastSelected); + while (idx-- > 0) { + if (this.isSelectable(this.items[idx])) { + this.deselectAll(); + this.select(this.items[idx]); + return true; + } + } + return false; +}, selectFirst:function () { + this.deselectAll(); + var idx = 0; + while (this.items[idx] && !this.select(this.items[idx])) { + idx++; + } + return this.items[idx] ? true : false; +}, selectLast:function () { + this.deselectAll(); + var idx = this.items.length - 1; + while (this.items[idx] && !this.select(this.items[idx])) { + idx--; + } + return this.items[idx] ? true : false; +}, _addPivot:function (item, andClear) { + this._pivotItem = item; + if (andClear) { + this._pivotItems = [item]; + } else { + this._pivotItems.push(item); + } +}, _removePivot:function (item) { + var i = dojo.lang.find(this._pivotItems, item); + if (i > -1) { + this._pivotItems.splice(i, 1); + this._pivotItem = this._pivotItems[this._pivotItems.length - 1]; + } + this._updatePivot(); +}, _updatePivot:function () { + if (this._pivotItems.length == 0) { + if (this.lastSelected) { + this._addPivot(this.lastSelected); + } + } +}, sorted:function () { + return dojo.lang.toArray(this.selection).sort(dojo.lang.hitch(this, function (a, b) { + var A = this._find(a), B = this._find(b); + if (A > B) { + return 1; + } else { + if (A < B) { + return -1; + } else { + return 0; + } + } + })); +}, updateSelected:function () { + for (var i = 0; i < this.selection.length; i++) { + if (this._find(this.selection[i]) < 0) { + var removed = this.selection.splice(i, 1); + this._removePivot(removed[0]); + } + } + this.length = this.selection.length; +}}); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/storage.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/storage.js index 4fc3a47b8..afac085fd 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/storage.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/storage.js @@ -8,357 +8,118 @@ http://dojotoolkit.org/community/licensing.shtml */ -/** - FIXME: Write better docs. - - @author Brad Neuberg, bkn3@columbia.edu -*/ dojo.provide("dojo.storage"); - dojo.require("dojo.lang.*"); dojo.require("dojo.event.*"); - -// create an empty "StorageProvider", which was being created as a side-effect -// of the erroneous dojo.provide("dojo.storage.StorageProvider") -dojo.storage.StorageProvider = {} - - -/** The base class for all storage providers. */ - -/** - The constructor for a storage provider. You should avoid initialization - in the constructor; instead, define initialization in your initialize() - method. -*/ -dojo.declare("dojo.storage", null, { - /** A put() call to a storage provider was succesful. */ - SUCCESS: "success", - - /** A put() call to a storage provider failed. */ - FAILED: "failed", - - /** A put() call to a storage provider is pending user approval. */ - PENDING: "pending", - - /** - Returned by getMaximumSize() if this storage provider can not determine - the maximum amount of data it can support. - */ - SIZE_NOT_AVAILABLE: "Size not available", - - /** - Returned by getMaximumSize() if this storage provider has no theoretical - limit on the amount of data it can store. - */ - SIZE_NO_LIMIT: "No size limit", - - /** - The namespace for all storage operations. This is useful if several - applications want access to the storage system from the same domain but - want different storage silos. - */ - "namespace": "dojoStorage", - - /** - If a function is assigned to this property, then when the settings - provider's UI is closed this function is called. Useful, for example, - if the user has just cleared out all storage for this provider using - the settings UI, and you want to update your UI. - */ - onHideSettingsUI: null, - - initialize: function(){ - // summary: - // Allows this storage provider to initialize itself. This is - // called after the page has finished loading, so you can not do - // document.writes(). - dojo.unimplemented("dojo.storage.initialize"); - }, - - isAvailable: function(){ /*Boolean*/ - // summary: - // Returns whether this storage provider is available on this - // platform. - dojo.unimplemented("dojo.storage.isAvailable"); - }, - - /** - - */ - put: function( /*string*/ key, - /*object*/ value, - /*function*/ resultsHandler){ - // summary: - // Puts a key and value into this storage system. - // key: - // A string key to use when retrieving this value in the future. - // value: - // A value to store; this can be any JavaScript type. - // resultsHandler: - // A callback function that will receive three arguments. The - // first argument is one of three values: dojo.storage.SUCCESS, - // dojo.storage.FAILED, or dojo.storage.PENDING; these values - // determine how the put request went. In some storage systems - // users can deny a storage request, resulting in a - // dojo.storage.FAILED, while in other storage systems a storage - // request must wait for user approval, resulting in a - // dojo.storage.PENDING status until the request is either - // approved or denied, resulting in another call back with - // dojo.storage.SUCCESS. - // The second argument in the call back is the key name that was being stored. - // The third argument in the call back is an optional message that - // details possible error messages that might have occurred during - // the storage process. - -// Example: -// var resultsHandler = function(status, key, message){ -// alert("status="+status+", key="+key+", message="+message); -// }; -// dojo.storage.put("test", "hello world", resultsHandler); - dojo.unimplemented("dojo.storage.put"); - }, - - get: function(/*string*/ key){ /*Object*/ - // summary: - // Gets the value with the given key. Returns null if this key is - // not in the storage system. - // key: - // A string key to get the value of. - // return: Returns any JavaScript object type; null if the key is not present - dojo.unimplemented("dojo.storage.get"); - }, - - hasKey: function(/*string*/ key){ /*Boolean*/ - // summary: Determines whether the storage has the given key. - return (this.get(key) != null); - }, - - /** - - getKeys: function(){ //Array - // summary: Enumerates all of the available keys in this storage system. - dojo.unimplemented("dojo.storage.getKeys"); - }, - - */ - clear: function(){ - // summary: - // Completely clears this storage system of all of it's values and - // keys. - dojo.unimplemented("dojo.storage.clear"); - }, - - /** Removes the given key from the storage system. */ - remove: function(key){ - dojo.unimplemented("dojo.storage.remove"); - }, - - isPermanent: function(){ /*Boolean*/ - // summary: - // Returns whether this storage provider's values are persisted - // when this platform is shutdown. - dojo.unimplemented("dojo.storage.isPermanent"); - }, - - /** - The maximum storage allowed by this provider. - - @returns Returns the maximum storage size - supported by this provider, in - thousands of bytes (i.e., if it - returns 60 then this means that 60K - of storage is supported). - - If this provider can not determine - it's maximum size, then - dojo.storage.SIZE_NOT_AVAILABLE is - returned; if there is no theoretical - limit on the amount of storage - this provider can return, then - dojo.storage.SIZE_NO_LIMIT is - returned - */ - getMaximumSize: function(){ - dojo.unimplemented("dojo.storage.getMaximumSize"); - }, - - hasSettingsUI: function(){ /*Boolean*/ - // summary: Determines whether this provider has a settings UI. +dojo.storage = new function () { +}; +dojo.declare("dojo.storage", null, {SUCCESS:"success", FAILED:"failed", PENDING:"pending", SIZE_NOT_AVAILABLE:"Size not available", SIZE_NO_LIMIT:"No size limit", namespace:"default", onHideSettingsUI:null, initialize:function () { + dojo.unimplemented("dojo.storage.initialize"); +}, isAvailable:function () { + dojo.unimplemented("dojo.storage.isAvailable"); +}, put:function (key, value, resultsHandler) { + dojo.unimplemented("dojo.storage.put"); +}, get:function (key) { + dojo.unimplemented("dojo.storage.get"); +}, hasKey:function (key) { + return (this.get(key) != null); +}, getKeys:function () { + dojo.unimplemented("dojo.storage.getKeys"); +}, clear:function () { + dojo.unimplemented("dojo.storage.clear"); +}, remove:function (key) { + dojo.unimplemented("dojo.storage.remove"); +}, isPermanent:function () { + dojo.unimplemented("dojo.storage.isPermanent"); +}, getMaximumSize:function () { + dojo.unimplemented("dojo.storage.getMaximumSize"); +}, hasSettingsUI:function () { + return false; +}, showSettingsUI:function () { + dojo.unimplemented("dojo.storage.showSettingsUI"); +}, hideSettingsUI:function () { + dojo.unimplemented("dojo.storage.hideSettingsUI"); +}, getType:function () { + dojo.unimplemented("dojo.storage.getType"); +}, isValidKey:function (keyName) { + if ((keyName == null) || (typeof keyName == "undefined")) { return false; - }, - - showSettingsUI: function(){ - // summary: If this provider has a settings UI, it is shown. - dojo.unimplemented("dojo.storage.showSettingsUI"); - }, - - hideSettingsUI: function(){ - // summary: If this provider has a settings UI, hides it. - dojo.unimplemented("dojo.storage.hideSettingsUI"); - }, - - getType: function(){ /*String*/ - // summary: - // The provider name as a string, such as - // "dojo.storage.FlashStorageProvider". - dojo.unimplemented("dojo.storage.getType"); - }, - - isValidKey: function(/*string*/ keyName){ /*Boolean*/ - // summary: - // Subclasses can call this to ensure that the key given is valid - // in a consistent way across different storage providers. We use - // the lowest common denominator for key values allowed: only - // letters, numbers, and underscores are allowed. No spaces. - if((keyName == null)||(typeof keyName == "undefined")){ - return false; - } - - return /^[0-9A-Za-z_]*$/.test(keyName); } -}); - - - - -/** - Initializes the storage systems and figures out the best available - storage options on this platform. -*/ -dojo.storage.manager = new function(){ + return /^[0-9A-Za-z_]*$/.test(keyName); +}}); +dojo.storage.manager = new function () { this.currentProvider = null; this.available = false; - this.initialized = false; - this.providers = []; - - // TODO: Provide a way for applications to override the default namespace - this["namespace"] = "dojo.storage"; - - this.initialize = function(){ - // summary: - // Initializes the storage system and autodetects the best storage - // provider we can provide on this platform + this._initialized = false; + this._providers = []; + this.namespace = "default"; + this.initialize = function () { this.autodetect(); }; - - /** - - */ - this.register = function(/*string*/ name, /*Object*/ instance) { - // summary: - // Registers the existence of a new storage provider; used by - // subclasses to inform the manager of their existence. - // name: - // The full class name of this provider, such as - // "dojo.storage.browser.Flash6StorageProvider". - // instance: - // An instance of this provider, which we will use to call - // isAvailable() on. - this.providers[this.providers.length] = instance; - this.providers[name] = instance; + this.register = function (name, instance) { + this._providers[this._providers.length] = instance; + this._providers[name] = instance; }; - - /** - - */ - this.setProvider = function(storageClass){ - // summary: - // Instructs the storageManager to use the given storage class for - // all storage requests. - // description: - // Example: - // dojo.storage.setProvider( - // dojo.storage.browser.IEStorageProvider) - + this.setProvider = function (storageClass) { }; - - this.autodetect = function(){ - // summary: - // Autodetects the best possible persistent storage provider - // available on this platform. - if(this.initialized == true) // already finished + this.autodetect = function () { + if (this._initialized == true) { return; - - // go through each provider, seeing if it can be used + } var providerToUse = null; - for(var i = 0; i < this.providers.length; i++) { - providerToUse = this.providers[i]; - if(providerToUse.isAvailable()){ + for (var i = 0; i < this._providers.length; i++) { + providerToUse = this._providers[i]; + if (dojo.lang.isUndefined(djConfig["forceStorageProvider"]) == false && providerToUse.getType() == djConfig["forceStorageProvider"]) { + providerToUse.isAvailable(); break; + } else { + if (dojo.lang.isUndefined(djConfig["forceStorageProvider"]) == true && providerToUse.isAvailable()) { + break; + } } - } - - if(providerToUse == null){ // no provider available - this.initialized = true; + } + if (providerToUse == null) { + this._initialized = true; this.available = false; this.currentProvider = null; dojo.raise("No storage provider found for this platform"); } - - // create this provider and copy over it's properties this.currentProvider = providerToUse; - for(var i in providerToUse){ - dojo.storage[i] = providerToUse[i]; + for (var i in providerToUse) { + dojo.storage[i] = providerToUse[i]; } dojo.storage.manager = this; - - // have the provider initialize itself dojo.storage.initialize(); - - this.initialized = true; + this._initialized = true; this.available = true; }; - - this.isAvailable = function(){ /*Boolean*/ - // summary: Returns whether any storage options are available. + this.isAvailable = function () { return this.available; }; - - this.isInitialized = function(){ /*Boolean*/ - // summary: - // Returns whether the storage system is initialized and ready to - // be used. - - // FIXME: This should _really_ not be in here, but it fixes a bug - if(dojo.flash.ready == false){ + this.isInitialized = function () { + if (this.currentProvider.getType() == "dojo.storage.browser.FlashStorageProvider" && dojo.flash.ready == false) { return false; - }else{ - return this.initialized; + } else { + return this._initialized; } }; - - this.supportsProvider = function(/*string*/ storageClass){ - // summary: Determines if this platform supports the given storage provider. - // description: - // Example: - // dojo.storage.manager.supportsProvider( - // "dojo.storage.browser.InternetExplorerStorageProvider"); - - // construct this class dynamically - try{ - // dynamically call the given providers class level isAvailable() - // method + this.supportsProvider = function (storageClass) { + try { var provider = eval("new " + storageClass + "()"); var results = provider.isAvailable(); - if(results == null || typeof results == "undefined") + if (results == null || typeof results == "undefined") { return false; + } return results; - }catch (exception){ - dojo.debug("exception="+exception); + } + catch (exception) { return false; } }; - - /** Gets the current provider. */ - this.getProvider = function(){ + this.getProvider = function () { return this.currentProvider; }; - - this.loaded = function(){ - // summary: - // The storage provider should call this method when it is loaded - // and ready to be used. Clients who will use the provider will - // connect to this method to know when they can use the storage - // system: + this.loaded = function () { }; }; + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/storage/__package__.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/storage/__package__.js index 212cea621..e20d98a8c 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/storage/__package__.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/storage/__package__.js @@ -8,10 +8,6 @@ http://dojotoolkit.org/community/licensing.shtml */ -dojo.kwCompoundRequire({ - common: ["dojo.storage"], - browser: ["dojo.storage.browser"], - dashboard: ["dojo.storage.dashboard"] -}); +dojo.kwCompoundRequire({common:["dojo.storage"], browser:["dojo.storage.browser"]}); dojo.provide("dojo.storage.*"); diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/storage/browser.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/storage/browser.js index 2d831d955..4529b520a 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/storage/browser.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/storage/browser.js @@ -9,187 +9,540 @@ */ dojo.provide("dojo.storage.browser"); - dojo.require("dojo.storage"); dojo.require("dojo.flash"); dojo.require("dojo.json"); dojo.require("dojo.uri.*"); - -/** - Storage provider that uses features in Flash to achieve permanent storage. - - @author Brad Neuberg, bkn3@columbia.edu -*/ -dojo.storage.browser.FlashStorageProvider = function(){ -} - -dojo.inherits(dojo.storage.browser.FlashStorageProvider, dojo.storage); - -// instance methods and properties -dojo.lang.extend(dojo.storage.browser.FlashStorageProvider, { - "namespace": "default", - initialized: false, - _available: null, - _statusHandler: null, - - initialize: function(){ - if(djConfig["disableFlashStorage"] == true){ - return; - } - - // initialize our Flash - var loadedListener = function(){ - dojo.storage._flashLoaded(); - } - dojo.flash.addLoadedListener(loadedListener); - var swfloc6 = dojo.uri.dojoUri("Storage_version6.swf").toString(); - var swfloc8 = dojo.uri.dojoUri("Storage_version8.swf").toString(); - dojo.flash.setSwf({flash6: swfloc6, flash8: swfloc8, visible: false}); - }, - - isAvailable: function(){ - if(djConfig["disableFlashStorage"] == true){ - this._available = false; - } - - return this._available; - }, - - setNamespace: function(ns){ - this["namespace"] = ns; - }, - - put: function(key, value, resultsHandler){ - if(this.isValidKey(key) == false){ - dojo.raise("Invalid key given: " + key); - } - - this._statusHandler = resultsHandler; - - // serialize the value - // Handle strings differently so they have better performance - if(dojo.lang.isString(value)){ - value = "string:" + value; - }else{ - value = dojo.json.serialize(value); - } - - dojo.flash.comm.put(key, value, this["namespace"]); - }, - - get: function(key){ - if(this.isValidKey(key) == false){ - dojo.raise("Invalid key given: " + key); - } - - var results = dojo.flash.comm.get(key, this["namespace"]); - - if(results == ""){ - return null; - } - - // destringify the content back into a - // real JavaScript object - // Handle strings differently so they have better performance - if(!dojo.lang.isUndefined(results) && results != null - && /^string:/.test(results)){ - results = results.substring("string:".length); - }else{ - results = dojo.json.evalJson(results); - } - - return results; - }, - - getKeys: function(){ - var results = dojo.flash.comm.getKeys(this["namespace"]); - - if(results == ""){ - return []; - } - - // the results are returned comma seperated; split them - return results.split(","); - }, - - clear: function(){ - dojo.flash.comm.clear(this["namespace"]); - }, - - remove: function(key){ - }, - - isPermanent: function(){ - return true; - }, - - getMaximumSize: function(){ - return dojo.storage.SIZE_NO_LIMIT; - }, - - hasSettingsUI: function(){ - return true; - }, - - showSettingsUI: function(){ - dojo.flash.comm.showSettings(); - dojo.flash.obj.setVisible(true); - dojo.flash.obj.center(); - }, - - hideSettingsUI: function(){ - // hide the dialog - dojo.flash.obj.setVisible(false); - - // call anyone who wants to know the dialog is - // now hidden - if(dojo.storage.onHideSettingsUI != null && - !dojo.lang.isUndefined(dojo.storage.onHideSettingsUI)){ - dojo.storage.onHideSettingsUI.call(null); - } - }, - - /** - The provider name as a string, such as - "dojo.storage.FlashStorageProvider". - */ - getType: function(){ - return "dojo.storage.FlashStorageProvider"; - }, - - /** Called when the Flash is finished loading. */ - _flashLoaded: function(){ - this.initialized = true; - - // indicate that this storage provider is now loaded - dojo.storage.manager.loaded(); - }, - - /** - Called if the storage system needs to tell us about the status - of a put() request. - */ - _onStatus: function(statusResult, key){ - var ds = dojo.storage; - var dfo = dojo.flash.obj; - //dojo.debug("_onStatus, statusResult="+statusResult+", key="+key); - if(statusResult == ds.PENDING){ - dfo.center(); - dfo.setVisible(true); - }else{ - dfo.setVisible(false); - } - - if((!dj_undef("_statusHandler", ds))&&(ds._statusHandler != null)){ - ds._statusHandler.call(null, statusResult, key); +dojo.storage.browser.FileStorageProvider = function () { +}; +dojo.inherits(dojo.storage.browser.FileStorageProvider, dojo.storage); +dojo.storage.browser.FileStorageProvider._KEY_INDEX_FILENAME = "__dojoAllKeys"; +dojo.storage.browser.FileStorageProvider._APPLET_ID = "__dojoFileJavaObj"; +dojo.lang.extend(dojo.storage.browser.FileStorageProvider, {namespace:"default", initialized:false, _available:null, _statusHandler:null, _keyIndex:new Array(), initialize:function () { + if (djConfig["disableFileStorage"] == true) { + return; + } + this._loadKeyIndex(); + this.initialized = true; + dojo.storage.manager.loaded(); +}, isAvailable:function () { + this._available = false; + var protocol = window.location.protocol; + if (protocol.indexOf("file") != -1 || protocol.indexOf("chrome") != -1) { + this._available = this._isAvailableXPCOM(); + if (this._available == false) { + this._available = this._isAvailableActiveX(); } } -}); - -// register the existence of our storage providers -dojo.storage.manager.register("dojo.storage.browser.FlashStorageProvider", - new dojo.storage.browser.FlashStorageProvider()); - -// now that we are loaded and registered tell the storage manager to initialize -// itself + return this._available; +}, put:function (key, value, resultsHandler) { + if (this.isValidKey(key) == false) { + dojo.raise("Invalid key given: " + key); + } + this._statusHandler = resultsHandler; + try { + this._save(key, value); + resultsHandler.call(null, dojo.storage.SUCCESS, key); + } + catch (e) { + this._statusHandler.call(null, dojo.storage.FAILED, key, e.toString()); + } +}, get:function (key) { + if (this.isValidKey(key) == false) { + dojo.raise("Invalid key given: " + key); + } + var results = this._load(key); + return results; +}, getKeys:function () { + return this._keyIndex; +}, hasKey:function (key) { + if (this.isValidKey(key) == false) { + dojo.raise("Invalid key given: " + key); + } + this._loadKeyIndex(); + var exists = false; + for (var i = 0; i < this._keyIndex.length; i++) { + if (this._keyIndex[i] == key) { + exists = true; + } + } + return exists; +}, clear:function () { + this._loadKeyIndex(); + var keyIndex = new Array(); + for (var i = 0; i < this._keyIndex.length; i++) { + keyIndex[keyIndex.length] = new String(this._keyIndex[i]); + } + for (var i = 0; i < keyIndex.length; i++) { + this.remove(keyIndex[i]); + } +}, remove:function (key) { + if (this.isValidKey(key) == false) { + dojo.raise("Invalid key given: " + key); + } + this._loadKeyIndex(); + for (var i = 0; i < this._keyIndex.length; i++) { + if (this._keyIndex[i] == key) { + this._keyIndex.splice(i, 1); + break; + } + } + this._save(dojo.storage.browser.FileStorageProvider._KEY_INDEX_FILENAME, this._keyIndex, false); + var fullPath = this._getPagePath() + key + ".txt"; + if (this._isAvailableXPCOM()) { + this._removeXPCOM(fullPath); + } else { + if (this._isAvailableActiveX()) { + this._removeActiveX(fullPath); + } + } +}, isPermanent:function () { + return true; +}, getMaximumSize:function () { + return dojo.storage.SIZE_NO_LIMIT; +}, hasSettingsUI:function () { + return false; +}, showSettingsUI:function () { + dojo.raise(this.getType() + " does not support a storage settings user-interface"); +}, hideSettingsUI:function () { + dojo.raise(this.getType() + " does not support a storage settings user-interface"); +}, getType:function () { + return "dojo.storage.browser.FileStorageProvider"; +}, _save:function (key, value, updateKeyIndex) { + if (typeof updateKeyIndex == "undefined") { + updateKeyIndex = true; + } + if (dojo.lang.isString(value) == false) { + value = dojo.json.serialize(value); + value = "/* JavaScript */\n" + value + "\n\n"; + } + var fullPath = this._getPagePath() + key + ".txt"; + if (this._isAvailableXPCOM()) { + this._saveFileXPCOM(fullPath, value); + } else { + if (this._isAvailableActiveX()) { + this._saveFileActiveX(fullPath, value); + } + } + if (updateKeyIndex) { + this._updateKeyIndex(key); + } +}, _load:function (key) { + var fullPath = this._getPagePath() + key + ".txt"; + var results = null; + if (this._isAvailableXPCOM()) { + results = this._loadFileXPCOM(fullPath); + } else { + if (this._isAvailableActiveX()) { + results = this._loadFileActiveX(fullPath); + } else { + if (this._isAvailableJava()) { + results = this._loadFileJava(fullPath); + } + } + } + if (results == null) { + return null; + } + if (!dojo.lang.isUndefined(results) && results != null && /^\/\* JavaScript \*\//.test(results)) { + results = dojo.json.evalJson(results); + } + return results; +}, _updateKeyIndex:function (key) { + this._loadKeyIndex(); + var alreadyAdded = false; + for (var i = 0; i < this._keyIndex.length; i++) { + if (this._keyIndex[i] == key) { + alreadyAdded = true; + break; + } + } + if (alreadyAdded == false) { + this._keyIndex[this._keyIndex.length] = key; + } + this._save(dojo.storage.browser.FileStorageProvider._KEY_INDEX_FILENAME, this._keyIndex, false); +}, _loadKeyIndex:function () { + var indexContents = this._load(dojo.storage.browser.FileStorageProvider._KEY_INDEX_FILENAME); + if (indexContents == null) { + this._keyIndex = new Array(); + } else { + this._keyIndex = indexContents; + } +}, _saveFileXPCOM:function (filename, value) { + try { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + var f = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); + f.initWithPath(filename); + var ouputStream = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream); + ouputStream.init(f, 32 | 4 | 8, 256 + 128, null); + ouputStream.write(value, value.length); + ouputStream.close(); + } + catch (e) { + var msg = e.toString(); + if (e.name && e.message) { + msg = e.name + ": " + e.message; + } + dojo.raise("dojo.storage.browser.FileStorageProvider._saveFileXPCOM(): " + msg); + } +}, _loadFileXPCOM:function (filename) { + try { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + var f = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); + f.initWithPath(filename); + if (f.exists() == false) { + return null; + } + var inp = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream); + inp.init(f, 1, 4, null); + var inputStream = Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance(Components.interfaces.nsIScriptableInputStream); + inputStream.init(inp); + var results = inputStream.read(inputStream.available()); + return results; + } + catch (e) { + var msg = e.toString(); + if (e.name && e.message) { + msg = e.name + ": " + e.message; + } + dojo.raise("dojo.storage.browser.FileStorageProvider._loadFileXPCOM(): " + msg); + } + return null; +}, _saveFileActiveX:function (filename, value) { + try { + var fileSystem = new ActiveXObject("Scripting.FileSystemObject"); + var f = fileSystem.OpenTextFile(filename, 2, true); + f.Write(value); + f.Close(); + } + catch (e) { + var msg = e.toString(); + if (e.name && e.message) { + msg = e.name + ": " + e.message; + } + dojo.raise("dojo.storage.browser.FileStorageProvider._saveFileActiveX(): " + msg); + } +}, _loadFileActiveX:function (filename) { + try { + var fileSystem = new ActiveXObject("Scripting.FileSystemObject"); + if (fileSystem.FileExists(filename) == false) { + return null; + } + var f = fileSystem.OpenTextFile(filename, 1); + var results = f.ReadAll(); + f.Close(); + return results; + } + catch (e) { + var msg = e.toString(); + if (e.name && e.message) { + msg = e.name + ": " + e.message; + } + dojo.raise("dojo.storage.browser.FileStorageProvider._loadFileActiveX(): " + msg); + } +}, _saveFileJava:function (filename, value) { + try { + var applet = dojo.byId(dojo.storage.browser.FileStorageProvider._APPLET_ID); + applet.save(filename, value); + } + catch (e) { + var msg = e.toString(); + if (e.name && e.message) { + msg = e.name + ": " + e.message; + } + dojo.raise("dojo.storage.browser.FileStorageProvider._saveFileJava(): " + msg); + } +}, _loadFileJava:function (filename) { + try { + var applet = dojo.byId(dojo.storage.browser.FileStorageProvider._APPLET_ID); + var results = applet.load(filename); + return results; + } + catch (e) { + var msg = e.toString(); + if (e.name && e.message) { + msg = e.name + ": " + e.message; + } + dojo.raise("dojo.storage.browser.FileStorageProvider._loadFileJava(): " + msg); + } +}, _isAvailableActiveX:function () { + try { + if (window.ActiveXObject) { + var fileSystem = new window.ActiveXObject("Scripting.FileSystemObject"); + return true; + } + } + catch (e) { + dojo.debug(e); + } + return false; +}, _isAvailableXPCOM:function () { + try { + if (window.Components) { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); + return true; + } + } + catch (e) { + dojo.debug(e); + } + return false; +}, _isAvailableJava:function () { + try { + if (dojo.render.html.safari == true || dojo.render.html.opera == true()) { + if (navigator.javaEnabled() == true) { + return true; + } + } + } + catch (e) { + dojo.debug(e); + } + return false; +}, _getPagePath:function () { + var path = window.location.pathname; + if (/\.html?$/i.test(path)) { + path = path.replace(/(?:\/|\\)?[^\.\/\\]*\.html?$/, ""); + } + if (/^\/?[a-z]+\:/i.test(path)) { + path = path.replace(/^\/?/, ""); + path = path.replace(/\//g, "\\"); + } else { + if (/^[\/\\]{2,3}[^\/]/.test(path)) { + path = path.replace(/^[\/\\]{2,3}/, ""); + path = path.replace(/\//g, "\\"); + path = "\\\\" + path; + } + } + if (/\/$/.test(path) == false && /\\$/.test(path) == false) { + if (/\//.test(path)) { + path += "/"; + } else { + path += "\\"; + } + } + path = unescape(path); + return path; +}, _removeXPCOM:function (filename) { + try { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + var f = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); + f.initWithPath(filename); + if (f.exists() == false || f.isDirectory()) { + return; + } + if (f.isFile()) { + f.remove(false); + } + } + catch (e) { + dojo.raise("dojo.storage.browser.FileStorageProvider.remove(): " + e.toString()); + } +}, _removeActiveX:function (filename) { + try { + var fileSystem = new ActiveXObject("Scripting.FileSystemObject"); + fileSystem.DeleteFile(filename); + } + catch (e) { + dojo.raise("dojo.storage.browser.FileStorageProvider.remove(): " + e.toString()); + } +}, _removeJava:function (filename) { + try { + var applet = dojo.byId(dojo.storage.browser.FileStorageProvider._APPLET_ID); + applet.remove(filename); + } + catch (e) { + var msg = e.toString(); + if (e.name && e.message) { + msg = e.name + ": " + e.message; + } + dojo.raise("dojo.storage.browser.FileStorageProvider._removeJava(): " + msg); + } +}, _writeApplet:function () { + var archive = dojo.uri.moduleUri("dojo", "../DojoFileStorageProvider.jar").toString(); + var tag = "" + ""; + document.writeln(tag); +}}); +dojo.storage.browser.WhatWGStorageProvider = function () { +}; +dojo.inherits(dojo.storage.browser.WhatWGStorageProvider, dojo.storage); +dojo.lang.extend(dojo.storage.browser.WhatWGStorageProvider, {namespace:"default", initialized:false, _domain:null, _available:null, _statusHandler:null, initialize:function () { + if (djConfig["disableWhatWGStorage"] == true) { + return; + } + this._domain = location.hostname; + this.initialized = true; + dojo.storage.manager.loaded(); +}, isAvailable:function () { + try { + var myStorage = globalStorage[location.hostname]; + } + catch (e) { + this._available = false; + return this._available; + } + this._available = true; + return this._available; +}, put:function (key, value, resultsHandler) { + if (this.isValidKey(key) == false) { + dojo.raise("Invalid key given: " + key); + } + this._statusHandler = resultsHandler; + if (dojo.lang.isString(value)) { + value = "string:" + value; + } else { + value = dojo.json.serialize(value); + } + window.addEventListener("storage", function (evt) { + resultsHandler.call(null, dojo.storage.SUCCESS, key); + }, false); + try { + var myStorage = globalStorage[this._domain]; + myStorage.setItem(key, value); + } + catch (e) { + this._statusHandler.call(null, dojo.storage.FAILED, key, e.toString()); + } +}, get:function (key) { + if (this.isValidKey(key) == false) { + dojo.raise("Invalid key given: " + key); + } + var myStorage = globalStorage[this._domain]; + var results = myStorage.getItem(key); + if (results == null) { + return null; + } + results = results.value; + if (!dojo.lang.isUndefined(results) && results != null && /^string:/.test(results)) { + results = results.substring("string:".length); + } else { + results = dojo.json.evalJson(results); + } + return results; +}, getKeys:function () { + var myStorage = globalStorage[this._domain]; + var keysArray = new Array(); + for (i = 0; i < myStorage.length; i++) { + keysArray[i] = myStorage.key(i); + } + return keysArray; +}, clear:function () { + var myStorage = globalStorage[this._domain]; + var keys = new Array(); + for (var i = 0; i < myStorage.length; i++) { + keys[keys.length] = myStorage.key(i); + } + for (var i = 0; i < keys.length; i++) { + myStorage.removeItem(keys[i]); + } +}, remove:function (key) { + var myStorage = globalStorage[this._domain]; + myStorage.removeItem(key); +}, isPermanent:function () { + return true; +}, getMaximumSize:function () { + return dojo.storage.SIZE_NO_LIMIT; +}, hasSettingsUI:function () { + return false; +}, showSettingsUI:function () { + dojo.raise(this.getType() + " does not support a storage settings user-interface"); +}, hideSettingsUI:function () { + dojo.raise(this.getType() + " does not support a storage settings user-interface"); +}, getType:function () { + return "dojo.storage.browser.WhatWGProvider"; +}}); +dojo.storage.browser.FlashStorageProvider = function () { +}; +dojo.inherits(dojo.storage.browser.FlashStorageProvider, dojo.storage); +dojo.lang.extend(dojo.storage.browser.FlashStorageProvider, {namespace:"default", initialized:false, _available:null, _statusHandler:null, initialize:function () { + if (djConfig["disableFlashStorage"] == true) { + return; + } + var loadedListener = function () { + dojo.storage._flashLoaded(); + }; + dojo.flash.addLoadedListener(loadedListener); + var swfloc6 = dojo.uri.moduleUri("dojo", "../Storage_version6.swf").toString(); + var swfloc8 = dojo.uri.moduleUri("dojo", "../Storage_version8.swf").toString(); + dojo.flash.setSwf({flash6:swfloc6, flash8:swfloc8, visible:false}); +}, isAvailable:function () { + if (djConfig["disableFlashStorage"] == true) { + this._available = false; + } else { + this._available = true; + } + return this._available; +}, put:function (key, value, resultsHandler) { + if (this.isValidKey(key) == false) { + dojo.raise("Invalid key given: " + key); + } + this._statusHandler = resultsHandler; + if (dojo.lang.isString(value)) { + value = "string:" + value; + } else { + value = dojo.json.serialize(value); + } + dojo.flash.comm.put(key, value, this.namespace); +}, get:function (key) { + if (this.isValidKey(key) == false) { + dojo.raise("Invalid key given: " + key); + } + var results = dojo.flash.comm.get(key, this.namespace); + if (results == "") { + return null; + } + if (!dojo.lang.isUndefined(results) && results != null && /^string:/.test(results)) { + results = results.substring("string:".length); + } else { + results = dojo.json.evalJson(results); + } + return results; +}, getKeys:function () { + var results = dojo.flash.comm.getKeys(this.namespace); + if (results == "") { + return []; + } + return results.split(","); +}, clear:function () { + dojo.flash.comm.clear(this.namespace); +}, remove:function (key) { + dojo.unimplemented("dojo.storage.browser.FlashStorageProvider.remove"); +}, isPermanent:function () { + return true; +}, getMaximumSize:function () { + return dojo.storage.SIZE_NO_LIMIT; +}, hasSettingsUI:function () { + return true; +}, showSettingsUI:function () { + dojo.flash.comm.showSettings(); + dojo.flash.obj.setVisible(true); + dojo.flash.obj.center(); +}, hideSettingsUI:function () { + dojo.flash.obj.setVisible(false); + if (dojo.storage.onHideSettingsUI != null && !dojo.lang.isUndefined(dojo.storage.onHideSettingsUI)) { + dojo.storage.onHideSettingsUI.call(null); + } +}, getType:function () { + return "dojo.storage.browser.FlashStorageProvider"; +}, _flashLoaded:function () { + this._initialized = true; + dojo.storage.manager.loaded(); +}, _onStatus:function (statusResult, key) { + var ds = dojo.storage; + var dfo = dojo.flash.obj; + if (statusResult == ds.PENDING) { + dfo.center(); + dfo.setVisible(true); + } else { + dfo.setVisible(false); + } + if ((!dj_undef("_statusHandler", ds)) && (ds._statusHandler != null)) { + ds._statusHandler.call(null, statusResult, key); + } +}}); +dojo.storage.manager.register("dojo.storage.browser.FileStorageProvider", new dojo.storage.browser.FileStorageProvider()); +dojo.storage.manager.register("dojo.storage.browser.WhatWGStorageProvider", new dojo.storage.browser.WhatWGStorageProvider()); +dojo.storage.manager.register("dojo.storage.browser.FlashStorageProvider", new dojo.storage.browser.FlashStorageProvider()); dojo.storage.manager.initialize(); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/string.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/string.js index 565b73d42..c9689d94f 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/string.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/string.js @@ -10,3 +10,4 @@ dojo.provide("dojo.string"); dojo.require("dojo.string.common"); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/string/Builder.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/string/Builder.js index 4dec5dd27..07d7b3b6d 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/string/Builder.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/string/Builder.js @@ -11,118 +11,92 @@ dojo.provide("dojo.string.Builder"); dojo.require("dojo.string"); dojo.require("dojo.lang.common"); - -// NOTE: testing shows that direct "+=" concatenation is *much* faster on -// Spidermoneky and Rhino, while arr.push()/arr.join() style concatenation is -// significantly quicker on IE (Jscript/wsh/etc.). - -dojo.string.Builder = function(/* string? */str){ - // summary +dojo.string.Builder = function (str) { this.arrConcat = (dojo.render.html.capable && dojo.render.html["ie"]); - var a = []; var b = ""; var length = this.length = b.length; - - if(this.arrConcat){ - if(b.length > 0){ + if (this.arrConcat) { + if (b.length > 0) { a.push(b); } b = ""; } - - this.toString = this.valueOf = function(){ - // summary - // Concatenate internal buffer and return as a string - return (this.arrConcat) ? a.join("") : b; // string + this.toString = this.valueOf = function () { + return (this.arrConcat) ? a.join("") : b; }; - - this.append = function(){ - // summary - // Append all arguments to the end of the internal buffer - for(var x=0; x0){ - s = b.substring(0, (f-1)); + a = []; + if (f > 0) { + s = b.substring(0, (f - 1)); } - b = s + b.substring(f + l); - length = this.length = b.length; - if(this.arrConcat){ + b = s + b.substring(f + l); + length = this.length = b.length; + if (this.arrConcat) { a.push(b); - b=""; + b = ""; } - return this; // dojo.string.Builder + return this; }; - - this.replace = function(/* string */o, /* string */n){ - // summary - // replace phrase *o* with phrase *n*. - if(this.arrConcat){ - b = a.join(""); + this.replace = function (o, n) { + if (this.arrConcat) { + b = a.join(""); } - a = []; - b = b.replace(o,n); - length = this.length = b.length; - if(this.arrConcat){ + a = []; + b = b.replace(o, n); + length = this.length = b.length; + if (this.arrConcat) { a.push(b); - b=""; + b = ""; } - return this; // dojo.string.Builder + return this; }; - - this.insert = function(/* integer */idx, /* string */s){ - // summary - // Insert string s at index idx. - if(this.arrConcat){ - b = a.join(""); + this.insert = function (idx, s) { + if (this.arrConcat) { + b = a.join(""); } - a=[]; - if(idx == 0){ + a = []; + if (idx == 0) { b = s + b; - }else{ + } else { var t = b.split(""); - t.splice(idx,0,s); - b = t.join("") + t.splice(idx, 0, s); + b = t.join(""); } - length = this.length = b.length; - if(this.arrConcat){ - a.push(b); - b=""; + length = this.length = b.length; + if (this.arrConcat) { + a.push(b); + b = ""; } - return this; // dojo.string.Builder + return this; }; - this.append.apply(this, arguments); }; + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/string/__package__.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/string/__package__.js index 9a4cded8c..e4499e3bc 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/string/__package__.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/string/__package__.js @@ -8,12 +8,6 @@ http://dojotoolkit.org/community/licensing.shtml */ -dojo.kwCompoundRequire({ - common: [ - "dojo.string", - "dojo.string.common", - "dojo.string.extras", - "dojo.string.Builder" - ] -}); +dojo.kwCompoundRequire({common:["dojo.string", "dojo.string.common", "dojo.string.extras", "dojo.string.Builder"]}); dojo.provide("dojo.string.*"); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/string/common.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/string/common.js index 363028a61..3f8b7f3fd 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/string/common.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/string/common.js @@ -9,70 +9,53 @@ */ dojo.provide("dojo.string.common"); - -dojo.string.trim = function(/* string */str, /* integer? */wh){ - // summary - // Trim whitespace from str. If wh > 0, trim from start, if wh < 0, trim from end, else both - if(!str.replace){ return str; } - if(!str.length){ return str; } +dojo.string.trim = function (str, wh) { + if (!str.replace) { + return str; + } + if (!str.length) { + return str; + } var re = (wh > 0) ? (/^\s+/) : (wh < 0) ? (/\s+$/) : (/^\s+|\s+$/g); - return str.replace(re, ""); // string -} - -dojo.string.trimStart = function(/* string */str) { - // summary - // Trim whitespace at the beginning of 'str' - return dojo.string.trim(str, 1); // string -} - -dojo.string.trimEnd = function(/* string */str) { - // summary - // Trim whitespace at the end of 'str' + return str.replace(re, ""); +}; +dojo.string.trimStart = function (str) { + return dojo.string.trim(str, 1); +}; +dojo.string.trimEnd = function (str) { return dojo.string.trim(str, -1); -} - -dojo.string.repeat = function(/* string */str, /* integer */count, /* string? */separator) { - // summary - // Return 'str' repeated 'count' times, optionally placing 'separator' between each rep +}; +dojo.string.repeat = function (str, count, separator) { var out = ""; - for(var i = 0; i < count; i++) { + for (var i = 0; i < count; i++) { out += str; - if(separator && i < count - 1) { + if (separator && i < count - 1) { out += separator; } } - return out; // string -} - -dojo.string.pad = function(/* string */str, /* integer */len/*=2*/, /* string */ c/*='0'*/, /* integer */dir/*=1*/) { - // summary - // Pad 'str' to guarantee that it is at least 'len' length with the character 'c' at either the - // start (dir=1) or end (dir=-1) of the string + return out; +}; +dojo.string.pad = function (str, len, c, dir) { var out = String(str); - if(!c) { - c = '0'; + if (!c) { + c = "0"; } - if(!dir) { + if (!dir) { dir = 1; } - while(out.length < len) { - if(dir > 0) { + while (out.length < len) { + if (dir > 0) { out = c + out; } else { out += c; } } - return out; // string -} + return out; +}; +dojo.string.padLeft = function (str, len, c) { + return dojo.string.pad(str, len, c, 1); +}; +dojo.string.padRight = function (str, len, c) { + return dojo.string.pad(str, len, c, -1); +}; -dojo.string.padLeft = function(/* string */str, /* integer */len, /* string */c) { - // summary - // same as dojo.string.pad(str, len, c, 1) - return dojo.string.pad(str, len, c, 1); // string -} - -dojo.string.padRight = function(/* string */str, /* integer */len, /* string */c) { - // summary - // same as dojo.string.pad(str, len, c, -1) - return dojo.string.pad(str, len, c, -1); // string -} diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/string/extras.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/string/extras.js index 9ccec434b..500bdf8d2 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/string/extras.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/string/extras.js @@ -9,253 +9,168 @@ */ dojo.provide("dojo.string.extras"); - dojo.require("dojo.string.common"); dojo.require("dojo.lang.common"); dojo.require("dojo.lang.array"); - -//TODO: should we use ${} substitution syntax instead, like widgets do? -dojo.string.substituteParams = function(/*string*/template, /* object - optional or ... */hash){ -// summary: -// Performs parameterized substitutions on a string. Throws an exception if any parameter is unmatched. -// -// description: -// For example, -// dojo.string.substituteParams("File '%{0}' is not found in directory '%{1}'.","foo.html","/temp"); -// returns -// "File 'foo.html' is not found in directory '/temp'." -// -// template: the original string template with %{values} to be replaced -// hash: name/value pairs (type object) to provide substitutions. Alternatively, substitutions may be -// included as arguments 1..n to this function, corresponding to template parameters 0..n-1 - - var map = (typeof hash == 'object') ? hash : dojo.lang.toArray(arguments, 1); - - return template.replace(/\%\{(\w+)\}/g, function(match, key){ - if(typeof(map[key]) != "undefined" && map[key] != null){ +dojo.string.substituteParams = function (template, hash) { + var map = (typeof hash == "object") ? hash : dojo.lang.toArray(arguments, 1); + return template.replace(/\%\{(\w+)\}/g, function (match, key) { + if (typeof (map[key]) != "undefined" && map[key] != null) { return map[key]; } dojo.raise("Substitution not found: " + key); - }); // string + }); }; - -dojo.string.capitalize = function(/*string*/str){ -// summary: -// Uppercases the first letter of each word - - if(!dojo.lang.isString(str)){ return ""; } - if(arguments.length == 0){ str = this; } - - var words = str.split(' '); - for(var i=0; i"' -// Optionally skips escapes for single quotes - - str = str.replace(/&/gm, "&").replace(//gm, ">").replace(/"/gm, """); - if(!noSingleQuotes){ str = str.replace(/'/gm, "'"); } - return str; // string -} - -dojo.string.escapeSql = function(/*string*/str){ -//summary: -// Adds escape sequences for single quotes in SQL expressions - - return str.replace(/'/gm, "''"); //string -} - -dojo.string.escapeRegExp = function(/*string*/str){ -//summary: -// Adds escape sequences for special characters in regular expressions - - return str.replace(/\\/gm, "\\\\").replace(/([\f\b\n\t\r[\^$|?*+(){}])/gm, "\\$1"); // string -} - -//FIXME: should this one also escape backslash? -dojo.string.escapeJavaScript = function(/*string*/str){ -//summary: -// Adds escape sequences for single and double quotes as well -// as non-visible characters in JavaScript string literal expressions - - return str.replace(/(["'\f\b\n\t\r])/gm, "\\$1"); // string -} - -//FIXME: looks a lot like escapeJavaScript, just adds quotes? deprecate one? -dojo.string.escapeString = function(/*string*/str){ -//summary: -// Adds escape sequences for non-visual characters, double quote and backslash -// and surrounds with double quotes to form a valid string literal. - return ('"' + str.replace(/(["\\])/g, '\\$1') + '"' - ).replace(/[\f]/g, "\\f" - ).replace(/[\b]/g, "\\b" - ).replace(/[\n]/g, "\\n" - ).replace(/[\t]/g, "\\t" - ).replace(/[\r]/g, "\\r"); // string -} - -// TODO: make an HTML version -dojo.string.summary = function(/*string*/str, /*number*/len){ -// summary: -// Truncates 'str' after 'len' characters and appends periods as necessary so that it ends with "..." - - if(!len || str.length <= len){ - return str; // string +}; +dojo.string.escapeXml = function (str, noSingleQuotes) { + str = str.replace(/&/gm, "&").replace(//gm, ">").replace(/"/gm, """); + if (!noSingleQuotes) { + str = str.replace(/'/gm, "'"); } - - return str.substring(0, len).replace(/\.+$/, "") + "..."; // string -} - -dojo.string.endsWith = function(/*string*/str, /*string*/end, /*boolean*/ignoreCase){ -// summary: -// Returns true if 'str' ends with 'end' - - if(ignoreCase){ + return str; +}; +dojo.string.escapeSql = function (str) { + return str.replace(/'/gm, "''"); +}; +dojo.string.escapeRegExp = function (str) { + return str.replace(/\\/gm, "\\\\").replace(/([\f\b\n\t\r[\^$|?*+(){}])/gm, "\\$1"); +}; +dojo.string.escapeJavaScript = function (str) { + return str.replace(/(["'\f\b\n\t\r])/gm, "\\$1"); +}; +dojo.string.escapeString = function (str) { + return ("\"" + str.replace(/(["\\])/g, "\\$1") + "\"").replace(/[\f]/g, "\\f").replace(/[\b]/g, "\\b").replace(/[\n]/g, "\\n").replace(/[\t]/g, "\\t").replace(/[\r]/g, "\\r"); +}; +dojo.string.summary = function (str, len) { + if (!len || str.length <= len) { + return str; + } + return str.substring(0, len).replace(/\.+$/, "") + "..."; +}; +dojo.string.endsWith = function (str, end, ignoreCase) { + if (ignoreCase) { str = str.toLowerCase(); end = end.toLowerCase(); } - if((str.length - end.length) < 0){ - return false; // boolean + if ((str.length - end.length) < 0) { + return false; } - return str.lastIndexOf(end) == str.length - end.length; // boolean -} - -dojo.string.endsWithAny = function(/*string*/str /* , ... */){ -// summary: -// Returns true if 'str' ends with any of the arguments[2 -> n] - - for(var i = 1; i < arguments.length; i++) { - if(dojo.string.endsWith(str, arguments[i])) { - return true; // boolean + return str.lastIndexOf(end) == str.length - end.length; +}; +dojo.string.endsWithAny = function (str) { + for (var i = 1; i < arguments.length; i++) { + if (dojo.string.endsWith(str, arguments[i])) { + return true; } } - return false; // boolean -} - -dojo.string.startsWith = function(/*string*/str, /*string*/start, /*boolean*/ignoreCase){ -// summary: -// Returns true if 'str' starts with 'start' - - if(ignoreCase) { + return false; +}; +dojo.string.startsWith = function (str, start, ignoreCase) { + if (ignoreCase) { str = str.toLowerCase(); start = start.toLowerCase(); } - return str.indexOf(start) == 0; // boolean -} - -dojo.string.startsWithAny = function(/*string*/str /* , ... */){ -// summary: -// Returns true if 'str' starts with any of the arguments[2 -> n] - - for(var i = 1; i < arguments.length; i++) { - if(dojo.string.startsWith(str, arguments[i])) { - return true; // boolean + return str.indexOf(start) == 0; +}; +dojo.string.startsWithAny = function (str) { + for (var i = 1; i < arguments.length; i++) { + if (dojo.string.startsWith(str, arguments[i])) { + return true; } } - return false; // boolean -} - -dojo.string.has = function(/*string*/str /* , ... */) { -// summary: -// Returns true if 'str' contains any of the arguments 2 -> n - - for(var i = 1; i < arguments.length; i++) { - if(str.indexOf(arguments[i]) > -1){ - return true; // boolean + return false; +}; +dojo.string.has = function (str) { + for (var i = 1; i < arguments.length; i++) { + if (str.indexOf(arguments[i]) > -1) { + return true; } } - return false; // boolean -} - -dojo.string.normalizeNewlines = function(/*string*/text, /*string? (\n or \r)*/newlineChar){ -// summary: -// Changes occurences of CR and LF in text to CRLF, or if newlineChar is provided as '\n' or '\r', -// substitutes newlineChar for occurrences of CR/LF and CRLF - - if (newlineChar == "\n"){ + return false; +}; +dojo.string.normalizeNewlines = function (text, newlineChar) { + if (newlineChar == "\n") { text = text.replace(/\r\n/g, "\n"); text = text.replace(/\r/g, "\n"); - } else if (newlineChar == "\r"){ - text = text.replace(/\r\n/g, "\r"); - text = text.replace(/\n/g, "\r"); - }else{ - text = text.replace(/([^\r])\n/g, "$1\r\n").replace(/\r([^\n])/g, "\r\n$1"); + } else { + if (newlineChar == "\r") { + text = text.replace(/\r\n/g, "\r"); + text = text.replace(/\n/g, "\r"); + } else { + text = text.replace(/([^\r])\n/g, "$1\r\n").replace(/\r([^\n])/g, "\r\n$1"); + } } - return text; // string -} - -dojo.string.splitEscaped = function(/*string*/str, /*string of length=1*/charac){ -// summary: -// Splits 'str' into an array separated by 'charac', but skips characters escaped with a backslash - + return text; +}; +dojo.string.splitEscaped = function (str, charac) { var components = []; - for (var i = 0, prevcomma = 0; i < str.length; i++){ - if (str.charAt(i) == '\\'){ i++; continue; } - if (str.charAt(i) == charac){ + for (var i = 0, prevcomma = 0; i < str.length; i++) { + if (str.charAt(i) == "\\") { + i++; + continue; + } + if (str.charAt(i) == charac) { components.push(str.substring(prevcomma, i)); prevcomma = i + 1; } } components.push(str.substr(prevcomma)); - return components; // array -} + return components; +}; + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/style.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/style.js index 5beec47ee..c7d3a1cf3 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/style.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/style.js @@ -9,7 +9,8 @@ */ dojo.provide("dojo.style"); -dojo.kwCompoundRequire({ - browser: ["dojo.html.style"] -}); +dojo.require("dojo.lang.common"); +dojo.kwCompoundRequire({browser:["dojo.html.style"]}); dojo.deprecated("dojo.style", "replaced by dojo.html.style", "0.5"); +dojo.lang.mixin(dojo.style, dojo.html); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/svg.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/svg.js index cd0d21406..25ac1fe24 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/svg.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/svg.js @@ -11,310 +11,247 @@ dojo.provide("dojo.svg"); dojo.require("dojo.lang.common"); dojo.require("dojo.dom"); - dojo.mixin(dojo.svg, dojo.dom); - -dojo.svg.graphics=dojo.svg.g=new function(/* DOMDocument */ d){ - // summary - // Singleton to encapsulate SVG rendering functions. - this.suspend=function(){ - // summary - // Suspend the rendering engine - try { d.documentElement.suspendRedraw(0); } catch(e){ } - }; - this.resume=function(){ - // summary - // Resume the rendering engine - try { d.documentElement.unsuspendRedraw(0); } catch(e){ } - }; - this.force=function(){ - // summary - // Force the render engine to redraw - try { d.documentElement.forceRedraw(); } catch(e){ } - }; -}(document); - -dojo.svg.animations=dojo.svg.anim=new function(/* DOMDocument */ d){ - // summary - // Singleton to encapsulate SVG animation functionality. - this.arePaused=function(){ - // summary - // check to see if all animations are paused +dojo.svg.graphics = dojo.svg.g = new function (d) { + this.suspend = function () { try { - return d.documentElement.animationsPaused(); // bool - } catch(e){ - return false; // bool + d.documentElement.suspendRedraw(0); + } + catch (e) { } - } ; - this.pause=function(){ - // summary - // pause all animations - try { d.documentElement.pauseAnimations(); } catch(e){ } }; - this.resume=function(){ - // summary - // resume all animations - try { d.documentElement.unpauseAnimations(); } catch(e){ } + this.resume = function () { + try { + d.documentElement.unsuspendRedraw(0); + } + catch (e) { + } + }; + this.force = function () { + try { + d.documentElement.forceRedraw(); + } + catch (e) { + } }; }(document); - -// fixme: these functions should be mixed in from dojo.style, but dojo.style is HTML-centric and needs to change. -dojo.svg.toCamelCase=function(/* string */ selector){ - // summary - // converts a CSS-style selector to a camelCased one - var arr=selector.split('-'), cc=arr[0]; - for(var i=1; i < arr.length; i++) { +dojo.svg.animations = dojo.svg.anim = new function (d) { + this.arePaused = function () { + try { + return d.documentElement.animationsPaused(); + } + catch (e) { + return false; + } + }; + this.pause = function () { + try { + d.documentElement.pauseAnimations(); + } + catch (e) { + } + }; + this.resume = function () { + try { + d.documentElement.unpauseAnimations(); + } + catch (e) { + } + }; +}(document); +dojo.svg.toCamelCase = function (selector) { + var arr = selector.split("-"), cc = arr[0]; + for (var i = 1; i < arr.length; i++) { cc += arr[i].charAt(0).toUpperCase() + arr[i].substring(1); } - return cc; // string + return cc; }; -dojo.svg.toSelectorCase=function(/* string */ selector) { - // summary - // converts a camelCased selector to a CSS style one - return selector.replace(/([A-Z])/g, "-$1" ).toLowerCase(); // string +dojo.svg.toSelectorCase = function (selector) { + return selector.replace(/([A-Z])/g, "-$1").toLowerCase(); }; -dojo.svg.getStyle=function(/* SVGElement */ node, /* string */ cssSelector){ - // summary - // get the computed style of selector for node. - return document.defaultView.getComputedStyle(node, cssSelector); // object +dojo.svg.getStyle = function (node, cssSelector) { + return document.defaultView.getComputedStyle(node, cssSelector); }; -dojo.svg.getNumericStyle=function(/* SVGElement */ node, /* string */ cssSelector){ - // summary - // return the numeric version of the computed style of selector on node. +dojo.svg.getNumericStyle = function (node, cssSelector) { return parseFloat(dojo.svg.getStyle(node, cssSelector)); }; - -// fixme: there are different ways of doing the following, need to take into account -dojo.svg.getOpacity=function(/* SVGElement */node){ - // summary - // Return the opacity of the passed element - return Math.min(1.0, dojo.svg.getNumericStyle(node, "fill-opacity")); // float +dojo.svg.getOpacity = function (node) { + return Math.min(1, dojo.svg.getNumericStyle(node, "fill-opacity")); }; -dojo.svg.setOpacity=function(/* SVGElement */ node, /* float */ opacity){ - // summary - // set the opacity of node using attributes. +dojo.svg.setOpacity = function (node, opacity) { node.setAttributeNS(this.xmlns.svg, "fill-opacity", opacity); node.setAttributeNS(this.xmlns.svg, "stroke-opacity", opacity); }; -dojo.svg.clearOpacity=function(/* SVGElement */ node){ - // summary - // Set any attributes setting opacity to opaque (1.0) +dojo.svg.clearOpacity = function (node) { node.setAttributeNS(this.xmlns.svg, "fill-opacity", "1.0"); node.setAttributeNS(this.xmlns.svg, "stroke-opacity", "1.0"); }; - -/** - * Coordinates and dimensions. - */ - -// TODO ////////////////////////////////////////////////////////// TODO -dojo.svg.getCoords=function(/* SVGElement */ node){ - // summary - // Returns the x/y coordinates of the passed node, if available. +dojo.svg.getCoords = function (node) { if (node.getBBox) { - var box=node.getBBox(); - return { x: box.x, y: box.y }; // object + var box = node.getBBox(); + return {x:box.x, y:box.y}; } - return null; // object + return null; }; -dojo.svg.setCoords=function(/* SVGElement */node, /* object */coords){ - // summary - // Set the x/y coordinates of the passed node - var p=dojo.svg.getCoords(); - if (!p) return; - var dx=p.x - coords.x; - var dy=p.y - coords.y; +dojo.svg.setCoords = function (node, coords) { + var p = dojo.svg.getCoords(); + if (!p) { + return; + } + var dx = p.x - coords.x; + var dy = p.y - coords.y; dojo.svg.translate(node, dx, dy); }; -dojo.svg.getDimensions=function(/* SVGElement */node){ - // summary - // Get the height and width of the passed node. - if (node.getBBox){ - var box=node.getBBox(); - return { width: box.width, height : box.height }; // object +dojo.svg.getDimensions = function (node) { + if (node.getBBox) { + var box = node.getBBox(); + return {width:box.width, height:box.height}; } - return null; // object + return null; }; -dojo.svg.setDimensions=function(/* SVGElement */node, /* object */dim){ - // summary - // Set the dimensions of the passed element if possible. - // will only support shape-based and container elements; path-based elements are ignored. - if (node.width){ - node.width.baseVal.value=dim.width; - node.height.baseVal.value=dim.height; - } - else if (node.r){ - node.r.baseVal.value=Math.min(dim.width, dim.height)/2; - } - else if (node.rx){ - node.rx.baseVal.value=dim.width/2; - node.ry.baseVal.value=dim.height/2; +dojo.svg.setDimensions = function (node, dim) { + if (node.width) { + node.width.baseVal.value = dim.width; + node.height.baseVal.value = dim.height; + } else { + if (node.r) { + node.r.baseVal.value = Math.min(dim.width, dim.height) / 2; + } else { + if (node.rx) { + node.rx.baseVal.value = dim.width / 2; + node.ry.baseVal.value = dim.height / 2; + } + } } }; - -/** - * Transformations. - */ -dojo.svg.translate=function(/* SVGElement */node, /* int */dx, /* int */dy){ - // summary - // Translates the passed node by dx and dy - if (node.transform && node.ownerSVGElement && node.ownerSVGElement.createSVGTransform){ - var t=node.ownerSVGElement.createSVGTransform(); +dojo.svg.translate = function (node, dx, dy) { + if (node.transform && node.ownerSVGElement && node.ownerSVGElement.createSVGTransform) { + var t = node.ownerSVGElement.createSVGTransform(); t.setTranslate(dx, dy); node.transform.baseVal.appendItem(t); } }; -dojo.svg.scale=function(/* SVGElement */node, /* float */scaleX, /* float? */scaleY){ - // summary - // Scales the passed element by factor scaleX and scaleY. If scaleY not passed, scaleX is used. - if (!scaleY) var scaleY=scaleX; - if (node.transform && node.ownerSVGElement && node.ownerSVGElement.createSVGTransform){ - var t=node.ownerSVGElement.createSVGTransform(); +dojo.svg.scale = function (node, scaleX, scaleY) { + if (!scaleY) { + var scaleY = scaleX; + } + if (node.transform && node.ownerSVGElement && node.ownerSVGElement.createSVGTransform) { + var t = node.ownerSVGElement.createSVGTransform(); t.setScale(scaleX, scaleY); node.transform.baseVal.appendItem(t); } }; -dojo.svg.rotate=function(/* SVGElement */node, /* float */ang, /* int? */cx, /* int? */cy){ - // summary - // rotate the passed node by ang, with optional cx/cy as the rotation point. - if (node.transform && node.ownerSVGElement && node.ownerSVGElement.createSVGTransform){ - var t=node.ownerSVGElement.createSVGTransform(); - if (cx == null) t.setMatrix(t.matrix.rotate(ang)); - else t.setRotate(ang, cx, cy); +dojo.svg.rotate = function (node, ang, cx, cy) { + if (node.transform && node.ownerSVGElement && node.ownerSVGElement.createSVGTransform) { + var t = node.ownerSVGElement.createSVGTransform(); + if (cx == null) { + t.setMatrix(t.matrix.rotate(ang)); + } else { + t.setRotate(ang, cx, cy); + } node.transform.baseVal.appendItem(t); } }; -dojo.svg.skew=function(/* SVGElement */node, /* float */ang, /* string? */axis){ - // summary - // skew the passed node by ang over axis. - var dir=axis || "x"; - if (node.transform && node.ownerSVGElement && node.ownerSVGElement.createSVGTransform){ - var t=node.ownerSVGElement.createSVGTransform(); - if (dir != "x") t.setSkewY(ang); - else t.setSkewX(ang); +dojo.svg.skew = function (node, ang, axis) { + var dir = axis || "x"; + if (node.transform && node.ownerSVGElement && node.ownerSVGElement.createSVGTransform) { + var t = node.ownerSVGElement.createSVGTransform(); + if (dir != "x") { + t.setSkewY(ang); + } else { + t.setSkewX(ang); + } node.transform.baseVal.appendItem(t); } }; -dojo.svg.flip=function(/* SVGElement */node, /* string? */axis){ - // summary - // flip the passed element over axis - var dir=axis || "x"; - if (node.transform && node.ownerSVGElement && node.ownerSVGElement.createSVGTransform){ - var t=node.ownerSVGElement.createSVGTransform(); +dojo.svg.flip = function (node, axis) { + var dir = axis || "x"; + if (node.transform && node.ownerSVGElement && node.ownerSVGElement.createSVGTransform) { + var t = node.ownerSVGElement.createSVGTransform(); t.setMatrix((dir != "x") ? t.matrix.flipY() : t.matrix.flipX()); node.transform.baseVal.appendItem(t); } }; -dojo.svg.invert=function(/* SVGElement */node){ - // summary - // transform the passed node by the inverse of the current matrix - if (node.transform && node.ownerSVGElement && node.ownerSVGElement.createSVGTransform){ - var t=node.ownerSVGElement.createSVGTransform(); +dojo.svg.invert = function (node) { + if (node.transform && node.ownerSVGElement && node.ownerSVGElement.createSVGTransform) { + var t = node.ownerSVGElement.createSVGTransform(); t.setMatrix(t.matrix.inverse()); node.transform.baseVal.appendItem(t); } }; -dojo.svg.applyMatrix=function( - /* SVGElement */node, - /* int || SVGMatrix */a, - /* int? */b, - /* int? */c, - /* int? */d, - /* int? */e, - /* int? */f -){ - // summary - // apply the passed matrix to node. If params b - f are passed, a matrix will be created. - if (node.transform && node.ownerSVGElement && node.ownerSVGElement.createSVGTransform){ +dojo.svg.applyMatrix = function (node, a, b, c, d, e, f) { + if (node.transform && node.ownerSVGElement && node.ownerSVGElement.createSVGTransform) { var m; - if (b){ - var m=node.ownerSVGElement.createSVGMatrix(); - m.a=a; - m.b=b; - m.c=c; - m.d=d; - m.e=e; - m.f=f; - } else m=a; - var t=node.ownerSVGElement.createSVGTransform(); + if (b) { + var m = node.ownerSVGElement.createSVGMatrix(); + m.a = a; + m.b = b; + m.c = c; + m.d = d; + m.e = e; + m.f = f; + } else { + m = a; + } + var t = node.ownerSVGElement.createSVGTransform(); t.setMatrix(m); node.transform.baseVal.appendItem(t); } }; - -/** - * Grouping and z-index operations. - */ -dojo.svg.group=function(/* Nodelist || array */nodes){ - // summary - // expect an array of nodes, attaches the group to the parent of the first node. - var p=nodes.item(0).parentNode; - var g=document.createElementNS(this.xmlns.svg, "g"); - for (var i=0; i < nodes.length; i++) g.appendChild(nodes.item(i)); +dojo.svg.group = function (nodes) { + var p = nodes.item(0).parentNode; + var g = document.createElementNS(this.xmlns.svg, "g"); + for (var i = 0; i < nodes.length; i++) { + g.appendChild(nodes.item(i)); + } p.appendChild(g); return g; }; -dojo.svg.ungroup=function(/* SVGGElement */g){ - // summary - // puts the children of the group on the same level as group was. - var p=g.parentNode; - while (g.childNodes.length > 0) p.appendChild(g.childNodes.item(0)); +dojo.svg.ungroup = function (g) { + var p = g.parentNode; + while (g.childNodes.length > 0) { + p.appendChild(g.childNodes.item(0)); + } p.removeChild(g); }; -// if the node is part of a group, return the group, else return null. -dojo.svg.getGroup=function(/* SVGElement */node){ - // summary - // if the node is part of a group, return the group, else return null. - var a=this.getAncestors(node); - for (var i=0; i < a.length; i++){ - if (a[i].nodeType == this.ELEMENT_NODE && a[i].nodeName.toLowerCase() == "g") +dojo.svg.getGroup = function (node) { + var a = this.getAncestors(node); + for (var i = 0; i < a.length; i++) { + if (a[i].nodeType == this.ELEMENT_NODE && a[i].nodeName.toLowerCase() == "g") { return a[i]; + } } return null; }; -dojo.svg.bringToFront=function(/* SVGElement */node){ - // summary - // move the passed node the to top of the group (i.e. last child) - var n=this.getGroup(node) || node; +dojo.svg.bringToFront = function (node) { + var n = this.getGroup(node) || node; n.ownerSVGElement.appendChild(n); }; -dojo.svg.sendToBack=function(/* SVGElement */node){ - // summary - // move the passed node to the bottom of the group (i.e. first child) - var n=this.getGroup(node) || node; +dojo.svg.sendToBack = function (node) { + var n = this.getGroup(node) || node; n.ownerSVGElement.insertBefore(n, n.ownerSVGElement.firstChild); }; - -// TODO: possibly push node up a level in the DOM if it's at the beginning or end of the childNodes list. -dojo.svg.bringForward=function(/* SVGElement */node){ - // summary - // move the passed node up one in the child node chain - var n=this.getGroup(node) || node; - if (this.getLastChildElement(n.parentNode) != n){ +dojo.svg.bringForward = function (node) { + var n = this.getGroup(node) || node; + if (this.getLastChildElement(n.parentNode) != n) { this.insertAfter(n, this.getNextSiblingElement(n), true); } }; -dojo.svg.sendBackward=function(/* SVGElement */node){ - // summary - // move the passed node down one in the child node chain - var n=this.getGroup(node) || node; - if (this.getFirstChildElement(n.parentNode) != n){ +dojo.svg.sendBackward = function (node) { + var n = this.getGroup(node) || node; + if (this.getFirstChildElement(n.parentNode) != n) { this.insertBefore(n, this.getPreviousSiblingElement(n), true); } }; -// END TODO ////////////////////////////////////////////////////// TODO - -dojo.svg.createNodesFromText=function(/* string */ txt, /* bool? */ wrap){ - // summary - // Create a list of nodes from text - var docFrag=(new DOMParser()).parseFromString(txt, "text/xml").normalize(); - if(wrap){ - return [docFrag.firstChild.cloneNode(true)]; // array +dojo.svg.createNodesFromText = function (txt, wrap) { + var docFrag = (new DOMParser()).parseFromString(txt, "text/xml").normalize(); + if (wrap) { + return [docFrag.firstChild.cloneNode(true)]; } - var nodes=[]; - for(var x=0; x 0; - this.canRedo = this._redoStack.length > 0; - }, - - clear: function() { - this._undoStack = []; - this._redoStack = []; - this._currentManager = this; - - this.isUndoing = false; - this.isRedoing = false; - +dojo.extend(dojo.undo.Manager, {_parent:null, _undoStack:null, _redoStack:null, _currentManager:null, canUndo:false, canRedo:false, isUndoing:false, isRedoing:false, onUndo:function (manager, item) { +}, onRedo:function (manager, item) { +}, onUndoAny:function (manager, item) { +}, onRedoAny:function (manager, item) { +}, _updateStatus:function () { + this.canUndo = this._undoStack.length > 0; + this.canRedo = this._redoStack.length > 0; +}, clear:function () { + this._undoStack = []; + this._redoStack = []; + this._currentManager = this; + this.isUndoing = false; + this.isRedoing = false; + this._updateStatus(); +}, undo:function () { + if (!this.canUndo) { + return false; + } + this.endAllTransactions(); + this.isUndoing = true; + var top = this._undoStack.pop(); + if (top instanceof dojo.undo.Manager) { + top.undoAll(); + } else { + top.undo(); + } + if (top.redo) { + this._redoStack.push(top); + } + this.isUndoing = false; + this._updateStatus(); + this.onUndo(this, top); + if (!(top instanceof dojo.undo.Manager)) { + this.getTop().onUndoAny(this, top); + } + return true; +}, redo:function () { + if (!this.canRedo) { + return false; + } + this.isRedoing = true; + var top = this._redoStack.pop(); + if (top instanceof dojo.undo.Manager) { + top.redoAll(); + } else { + top.redo(); + } + this._undoStack.push(top); + this.isRedoing = false; + this._updateStatus(); + this.onRedo(this, top); + if (!(top instanceof dojo.undo.Manager)) { + this.getTop().onRedoAny(this, top); + } + return true; +}, undoAll:function () { + while (this._undoStack.length > 0) { + this.undo(); + } +}, redoAll:function () { + while (this._redoStack.length > 0) { + this.redo(); + } +}, push:function (undo, redo, description) { + if (!undo) { + return; + } + if (this._currentManager == this) { + this._undoStack.push({undo:undo, redo:redo, description:description}); + } else { + this._currentManager.push.apply(this._currentManager, arguments); + } + this._redoStack = []; + this._updateStatus(); +}, concat:function (manager) { + if (!manager) { + return; + } + if (this._currentManager == this) { + for (var x = 0; x < manager._undoStack.length; x++) { + this._undoStack.push(manager._undoStack[x]); + } + if (manager._undoStack.length > 0) { + this._redoStack = []; + } this._updateStatus(); - }, - - undo: function() { - if(!this.canUndo) { return false; } - - this.endAllTransactions(); - - this.isUndoing = true; - var top = this._undoStack.pop(); - if(top instanceof dojo.undo.Manager){ - top.undoAll(); - }else{ - top.undo(); - } - if(top.redo){ - this._redoStack.push(top); - } - this.isUndoing = false; - - this._updateStatus(); - this.onUndo(this, top); - if(!(top instanceof dojo.undo.Manager)) { - this.getTop().onUndoAny(this, top); - } - return true; - }, - - redo: function() { - if(!this.canRedo){ return false; } - - this.isRedoing = true; - var top = this._redoStack.pop(); - if(top instanceof dojo.undo.Manager) { - top.redoAll(); - }else{ - top.redo(); - } - this._undoStack.push(top); - this.isRedoing = false; - - this._updateStatus(); - this.onRedo(this, top); - if(!(top instanceof dojo.undo.Manager)){ - this.getTop().onRedoAny(this, top); - } - return true; - }, - - undoAll: function() { - while(this._undoStack.length > 0) { - this.undo(); - } - }, - - redoAll: function() { - while(this._redoStack.length > 0) { - this.redo(); - } - }, - - push: function(undo, redo /* optional */, description /* optional */) { - if(!undo) { return; } - - if(this._currentManager == this) { - this._undoStack.push({ - undo: undo, - redo: redo, - description: description - }); - } else { - this._currentManager.push.apply(this._currentManager, arguments); - } - // adding a new undo-able item clears out the redo stack - this._redoStack = []; - this._updateStatus(); - }, - - concat: function(manager) { - if ( !manager ) { return; } - - if (this._currentManager == this ) { - for(var x=0; x < manager._undoStack.length; x++) { - this._undoStack.push(manager._undoStack[x]); - } - // adding a new undo-able item clears out the redo stack - if (manager._undoStack.length > 0) { - this._redoStack = []; - } - this._updateStatus(); - } else { - this._currentManager.concat.apply(this._currentManager, arguments); - } - }, - - beginTransaction: function(description /* optional */) { - if(this._currentManager == this) { - var mgr = new dojo.undo.Manager(this); - mgr.description = description ? description : ""; - this._undoStack.push(mgr); - this._currentManager = mgr; - return mgr; - } else { - //for nested transactions need to make sure the top level _currentManager is set - this._currentManager = this._currentManager.beginTransaction.apply(this._currentManager, arguments); - } - }, - - endTransaction: function(flatten /* optional */) { - if(this._currentManager == this) { - if(this._parent) { - this._parent._currentManager = this._parent; - // don't leave empty transactions hangin' around - if(this._undoStack.length == 0 || flatten) { - var idx = dojo.lang.find(this._parent._undoStack, this); - if (idx >= 0) { - this._parent._undoStack.splice(idx, 1); - //add the current transaction to parents undo stack - if (flatten) { - for(var x=0; x < this._undoStack.length; x++){ - this._parent._undoStack.splice(idx++, 0, this._undoStack[x]); - } - this._updateStatus(); + } else { + this._currentManager.concat.apply(this._currentManager, arguments); + } +}, beginTransaction:function (description) { + if (this._currentManager == this) { + var mgr = new dojo.undo.Manager(this); + mgr.description = description ? description : ""; + this._undoStack.push(mgr); + this._currentManager = mgr; + return mgr; + } else { + this._currentManager = this._currentManager.beginTransaction.apply(this._currentManager, arguments); + } +}, endTransaction:function (flatten) { + if (this._currentManager == this) { + if (this._parent) { + this._parent._currentManager = this._parent; + if (this._undoStack.length == 0 || flatten) { + var idx = dojo.lang.find(this._parent._undoStack, this); + if (idx >= 0) { + this._parent._undoStack.splice(idx, 1); + if (flatten) { + for (var x = 0; x < this._undoStack.length; x++) { + this._parent._undoStack.splice(idx++, 0, this._undoStack[x]); } + this._updateStatus(); } } - return this._parent; } - } else { - //for nested transactions need to make sure the top level _currentManager is set - this._currentManager = this._currentManager.endTransaction.apply(this._currentManager, arguments); - } - }, - - endAllTransactions: function() { - while(this._currentManager != this) { - this.endTransaction(); - } - }, - - // find the top parent of an undo manager - getTop: function() { - if(this._parent) { - return this._parent.getTop(); - } else { - return this; + return this._parent; } + } else { + this._currentManager = this._currentManager.endTransaction.apply(this._currentManager, arguments); } -}); +}, endAllTransactions:function () { + while (this._currentManager != this) { + this.endTransaction(); + } +}, getTop:function () { + if (this._parent) { + return this._parent.getTop(); + } else { + return this; + } +}}); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/undo/__package__.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/undo/__package__.js index 4a1bb6ec2..e40bcba30 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/undo/__package__.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/undo/__package__.js @@ -10,3 +10,4 @@ dojo.require("dojo.undo.Manager"); dojo.provide("dojo.undo.*"); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/undo/browser.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/undo/browser.js index 90e2470f7..de3b3976a 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/undo/browser.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/undo/browser.js @@ -10,300 +10,192 @@ dojo.provide("dojo.undo.browser"); dojo.require("dojo.io.common"); - -try{ - if((!djConfig["preventBackButtonFix"])&&(!dojo.hostenv.post_load_)){ - document.write(""); +try { + if ((!djConfig["preventBackButtonFix"]) && (!dojo.hostenv.post_load_)) { + document.write(""); } -}catch(e){/* squelch */} - -if(dojo.render.html.opera){ +} +catch (e) { +} +if (dojo.render.html.opera) { dojo.debug("Opera is not supported with dojo.undo.browser, so back/forward detection will not work."); } - -/* NOTES: - * Safari 1.2: - * back button "works" fine, however it's not possible to actually - * DETECT that you've moved backwards by inspecting window.location. - * Unless there is some other means of locating. - * FIXME: perhaps we can poll on history.length? - * Safari 2.0.3+ (and probably 1.3.2+): - * works fine, except when changeUrl is used. When changeUrl is used, - * Safari jumps all the way back to whatever page was shown before - * the page that uses dojo.undo.browser support. - * IE 5.5 SP2: - * back button behavior is macro. It does not move back to the - * previous hash value, but to the last full page load. This suggests - * that the iframe is the correct way to capture the back button in - * these cases. - * Don't test this page using local disk for MSIE. MSIE will not create - * a history list for iframe_history.html if served from a file: URL. - * The XML served back from the XHR tests will also not be properly - * created if served from local disk. Serve the test pages from a web - * server to test in that browser. - * IE 6.0: - * same behavior as IE 5.5 SP2 - * Firefox 1.0+: - * the back button will return us to the previous hash on the same - * page, thereby not requiring an iframe hack, although we do then - * need to run a timer to detect inter-page movement. - */ - -dojo.undo.browser = { - initialHref: window.location.href, - initialHash: window.location.hash, - - moveForward: false, - historyStack: [], - forwardStack: [], - historyIframe: null, - bookmarkAnchor: null, - locationTimer: null, - - /** - * setInitialState sets the state object and back callback for the very first page that is loaded. - * It is recommended that you call this method as part of an event listener that is registered via - * dojo.addOnLoad(). - */ - setInitialState: function(args){ - this.initialState = this._createState(this.initialHref, args, this.initialHash); - }, - - //FIXME: Would like to support arbitrary back/forward jumps. Have to rework iframeLoaded among other things. - //FIXME: is there a slight race condition in moz using change URL with the timer check and when - // the hash gets set? I think I have seen a back/forward call in quick succession, but not consistent. - /** - * addToHistory takes one argument, and it is an object that defines the following functions: - * - To support getting back button notifications, the object argument should implement a - * function called either "back", "backButton", or "handle". The string "back" will be - * passed as the first and only argument to this callback. - * - To support getting forward button notifications, the object argument should implement a - * function called either "forward", "forwardButton", or "handle". The string "forward" will be - * passed as the first and only argument to this callback. - * - If you want the browser location string to change, define "changeUrl" on the object. If the - * value of "changeUrl" is true, then a unique number will be appended to the URL as a fragment - * identifier (http://some.domain.com/path#uniquenumber). If it is any other value that does - * not evaluate to false, that value will be used as the fragment identifier. For example, - * if changeUrl: 'page1', then the URL will look like: http://some.domain.com/path#page1 - * - * Full example: - * - * dojo.undo.browser.addToHistory({ - * back: function() { alert('back pressed'); }, - * forward: function() { alert('forward pressed'); }, - * changeUrl: true - * }); - */ - addToHistory: function(args){ - //If addToHistory is called, then that means we prune the - //forward stack -- the user went back, then wanted to - //start a new forward path. - this.forwardStack = []; - - var hash = null; - var url = null; - if(!this.historyIframe){ - this.historyIframe = window.frames["djhistory"]; +dojo.undo.browser = {initialHref:(!dj_undef("window")) ? window.location.href : "", initialHash:(!dj_undef("window")) ? window.location.hash : "", moveForward:false, historyStack:[], forwardStack:[], historyIframe:null, bookmarkAnchor:null, locationTimer:null, setInitialState:function (args) { + this.initialState = this._createState(this.initialHref, args, this.initialHash); +}, addToHistory:function (args) { + this.forwardStack = []; + var hash = null; + var url = null; + if (!this.historyIframe) { + if (djConfig["useXDomain"] && !djConfig["dojoIframeHistoryUrl"]) { + dojo.debug("dojo.undo.browser: When using cross-domain Dojo builds," + " please save iframe_history.html to your domain and set djConfig.dojoIframeHistoryUrl" + " to the path on your domain to iframe_history.html"); } - if(!this.bookmarkAnchor){ - this.bookmarkAnchor = document.createElement("a"); - dojo.body().appendChild(this.bookmarkAnchor); - this.bookmarkAnchor.style.display = "none"; - } - if(args["changeUrl"]){ - hash = "#"+ ((args["changeUrl"]!==true) ? args["changeUrl"] : (new Date()).getTime()); - - //If the current hash matches the new one, just replace the history object with - //this new one. It doesn't make sense to track different state objects for the same - //logical URL. This matches the browser behavior of only putting in one history - //item no matter how many times you click on the same #hash link, at least in Firefox - //and Safari, and there is no reliable way in those browsers to know if a #hash link - //has been clicked on multiple times. So making this the standard behavior in all browsers - //so that dojo.undo.browser's behavior is the same in all browsers. - if(this.historyStack.length == 0 && this.initialState.urlHash == hash){ - this.initialState = this._createState(url, args, hash); - return; - }else if(this.historyStack.length > 0 && this.historyStack[this.historyStack.length - 1].urlHash == hash){ + this.historyIframe = window.frames["djhistory"]; + } + if (!this.bookmarkAnchor) { + this.bookmarkAnchor = document.createElement("a"); + dojo.body().appendChild(this.bookmarkAnchor); + this.bookmarkAnchor.style.display = "none"; + } + if (args["changeUrl"]) { + hash = "#" + ((args["changeUrl"] !== true) ? args["changeUrl"] : (new Date()).getTime()); + if (this.historyStack.length == 0 && this.initialState.urlHash == hash) { + this.initialState = this._createState(url, args, hash); + return; + } else { + if (this.historyStack.length > 0 && this.historyStack[this.historyStack.length - 1].urlHash == hash) { this.historyStack[this.historyStack.length - 1] = this._createState(url, args, hash); return; } - - this.changingUrl = true; - setTimeout("window.location.href = '"+hash+"'; dojo.undo.browser.changingUrl = false;", 1); - this.bookmarkAnchor.href = hash; - - if(dojo.render.html.ie){ - url = this._loadIframeHistory(); - - var oldCB = args["back"]||args["backButton"]||args["handle"]; - - //The function takes handleName as a parameter, in case the - //callback we are overriding was "handle". In that case, - //we will need to pass the handle name to handle. - var tcb = function(handleName){ - if(window.location.hash != ""){ - setTimeout("window.location.href = '"+hash+"';", 1); - } - //Use apply to set "this" to args, and to try to avoid memory leaks. - oldCB.apply(this, [handleName]); + } + this.changingUrl = true; + setTimeout("window.location.href = '" + hash + "'; dojo.undo.browser.changingUrl = false;", 1); + this.bookmarkAnchor.href = hash; + if (dojo.render.html.ie) { + url = this._loadIframeHistory(); + var oldCB = args["back"] || args["backButton"] || args["handle"]; + var tcb = function (handleName) { + if (window.location.hash != "") { + setTimeout("window.location.href = '" + hash + "';", 1); } - - //Set interceptor function in the right place. - if(args["back"]){ - args.back = tcb; - }else if(args["backButton"]){ + oldCB.apply(this, [handleName]); + }; + if (args["back"]) { + args.back = tcb; + } else { + if (args["backButton"]) { args.backButton = tcb; - }else if(args["handle"]){ - args.handle = tcb; - } - - var oldFW = args["forward"]||args["forwardButton"]||args["handle"]; - - //The function takes handleName as a parameter, in case the - //callback we are overriding was "handle". In that case, - //we will need to pass the handle name to handle. - var tfw = function(handleName){ - if(window.location.hash != ""){ - window.location.href = hash; - } - if(oldFW){ // we might not actually have one - //Use apply to set "this" to args, and to try to avoid memory leaks. - oldFW.apply(this, [handleName]); + } else { + if (args["handle"]) { + args.handle = tcb; } } - - //Set interceptor function in the right place. - if(args["forward"]){ - args.forward = tfw; - }else if(args["forwardButton"]){ + } + var oldFW = args["forward"] || args["forwardButton"] || args["handle"]; + var tfw = function (handleName) { + if (window.location.hash != "") { + window.location.href = hash; + } + if (oldFW) { + oldFW.apply(this, [handleName]); + } + }; + if (args["forward"]) { + args.forward = tfw; + } else { + if (args["forwardButton"]) { args.forwardButton = tfw; - }else if(args["handle"]){ - args.handle = tfw; + } else { + if (args["handle"]) { + args.handle = tfw; + } } - - }else if(dojo.render.html.moz){ - // start the timer - if(!this.locationTimer){ + } + } else { + if (dojo.render.html.moz) { + if (!this.locationTimer) { this.locationTimer = setInterval("dojo.undo.browser.checkLocation();", 200); } } - }else{ - url = this._loadIframeHistory(); } - - this.historyStack.push(this._createState(url, args, hash)); - }, - - checkLocation: function(){ - if (!this.changingUrl){ - var hsl = this.historyStack.length; - - if((window.location.hash == this.initialHash||window.location.href == this.initialHref)&&(hsl == 1)){ - // FIXME: could this ever be a forward button? - // we can't clear it because we still need to check for forwards. Ugg. - // clearInterval(this.locationTimer); + } else { + url = this._loadIframeHistory(); + } + this.historyStack.push(this._createState(url, args, hash)); +}, checkLocation:function () { + if (!this.changingUrl) { + var hsl = this.historyStack.length; + if ((window.location.hash == this.initialHash || window.location.href == this.initialHref) && (hsl == 1)) { + this.handleBackButton(); + return; + } + if (this.forwardStack.length > 0) { + if (this.forwardStack[this.forwardStack.length - 1].urlHash == window.location.hash) { + this.handleForwardButton(); + return; + } + } + if ((hsl >= 2) && (this.historyStack[hsl - 2])) { + if (this.historyStack[hsl - 2].urlHash == window.location.hash) { this.handleBackButton(); return; } - - // first check to see if we could have gone forward. We always halt on - // a no-hash item. - if(this.forwardStack.length > 0){ - if(this.forwardStack[this.forwardStack.length-1].urlHash == window.location.hash){ - this.handleForwardButton(); - return; - } - } - - // ok, that didn't work, try someplace back in the history stack - if((hsl >= 2)&&(this.historyStack[hsl-2])){ - if(this.historyStack[hsl-2].urlHash==window.location.hash){ - this.handleBackButton(); - return; - } - } } - }, - - iframeLoaded: function(evt, ifrLoc){ - if(!dojo.render.html.opera){ - var query = this._getUrlQuery(ifrLoc.href); - if(query == null){ - // alert("iframeLoaded"); - // we hit the end of the history, so we should go back - if(this.historyStack.length == 1){ - this.handleBackButton(); - } - return; - } - if(this.moveForward){ - // we were expecting it, so it's not either a forward or backward movement - this.moveForward = false; - return; - } - - //Check the back stack first, since it is more likely. - //Note that only one step back or forward is supported. - if(this.historyStack.length >= 2 && query == this._getUrlQuery(this.historyStack[this.historyStack.length-2].url)){ + } +}, iframeLoaded:function (evt, ifrLoc) { + if (!dojo.render.html.opera) { + var query = this._getUrlQuery(ifrLoc.href); + if (query == null) { + if (this.historyStack.length == 1) { this.handleBackButton(); } - else if(this.forwardStack.length > 0 && query == this._getUrlQuery(this.forwardStack[this.forwardStack.length-1].url)){ + return; + } + if (this.moveForward) { + this.moveForward = false; + return; + } + if (this.historyStack.length >= 2 && query == this._getUrlQuery(this.historyStack[this.historyStack.length - 2].url)) { + this.handleBackButton(); + } else { + if (this.forwardStack.length > 0 && query == this._getUrlQuery(this.forwardStack[this.forwardStack.length - 1].url)) { this.handleForwardButton(); } } - }, - - handleBackButton: function(){ - //The "current" page is always at the top of the history stack. - var current = this.historyStack.pop(); - if(!current){ return; } - var last = this.historyStack[this.historyStack.length-1]; - if(!last && this.historyStack.length == 0){ - last = this.initialState; - } - if (last){ - if(last.kwArgs["back"]){ - last.kwArgs["back"](); - }else if(last.kwArgs["backButton"]){ + } +}, handleBackButton:function () { + var current = this.historyStack.pop(); + if (!current) { + return; + } + var last = this.historyStack[this.historyStack.length - 1]; + if (!last && this.historyStack.length == 0) { + last = this.initialState; + } + if (last) { + if (last.kwArgs["back"]) { + last.kwArgs["back"](); + } else { + if (last.kwArgs["backButton"]) { last.kwArgs["backButton"](); - }else if(last.kwArgs["handle"]){ - last.kwArgs.handle("back"); + } else { + if (last.kwArgs["handle"]) { + last.kwArgs.handle("back"); + } } } - this.forwardStack.push(current); - }, - - handleForwardButton: function(){ - var last = this.forwardStack.pop(); - if(!last){ return; } - if(last.kwArgs["forward"]){ - last.kwArgs.forward(); - }else if(last.kwArgs["forwardButton"]){ - last.kwArgs.forwardButton(); - }else if(last.kwArgs["handle"]){ - last.kwArgs.handle("forward"); - } - this.historyStack.push(last); - }, - - _createState: function(url, args, hash){ - return {"url": url, "kwArgs": args, "urlHash": hash}; - }, - - _getUrlQuery: function(url){ - var segments = url.split("?"); - if (segments.length < 2){ - return null; - } - else{ - return segments[1]; - } - }, - - _loadIframeHistory: function(){ - var url = dojo.hostenv.getBaseScriptUri()+"iframe_history.html?"+(new Date()).getTime(); - this.moveForward = true; - dojo.io.setIFrameSrc(this.historyIframe, url, false); - return url; } -} + this.forwardStack.push(current); +}, handleForwardButton:function () { + var last = this.forwardStack.pop(); + if (!last) { + return; + } + if (last.kwArgs["forward"]) { + last.kwArgs.forward(); + } else { + if (last.kwArgs["forwardButton"]) { + last.kwArgs.forwardButton(); + } else { + if (last.kwArgs["handle"]) { + last.kwArgs.handle("forward"); + } + } + } + this.historyStack.push(last); +}, _createState:function (url, args, hash) { + return {"url":url, "kwArgs":args, "urlHash":hash}; +}, _getUrlQuery:function (url) { + var segments = url.split("?"); + if (segments.length < 2) { + return null; + } else { + return segments[1]; + } +}, _loadIframeHistory:function () { + var url = (djConfig["dojoIframeHistoryUrl"] || dojo.hostenv.getBaseScriptUri() + "iframe_history.html") + "?" + (new Date()).getTime(); + this.moveForward = true; + dojo.io.setIFrameSrc(this.historyIframe, url, false); + return url; +}}; + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uri/Uri.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uri/Uri.js index d9866de78..d9d8eb172 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uri/Uri.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uri/Uri.js @@ -9,102 +9,105 @@ */ dojo.provide("dojo.uri.Uri"); - -dojo.uri = new function() { - this.dojoUri = function (/*dojo.uri.Uri||String*/uri) { - // summary: returns a Uri object resolved relative to the dojo root +dojo.uri = new function () { + this.dojoUri = function (uri) { return new dojo.uri.Uri(dojo.hostenv.getBaseScriptUri(), uri); - } - - this.moduleUri = function(/*String*/module, /*dojo.uri.Uri||String*/uri){ - // summary: returns a Uri object relative to a (top-level) module - // description: Examples: dojo.uri.moduleUri("dojo","Editor"), or dojo.uri.moduleUri("acme","someWidget") - var loc = dojo.hostenv.getModulePrefix(module); - if(!loc){return null;} - if(loc.lastIndexOf("/") != loc.length-1){loc += "/";} - return new dojo.uri.Uri(dojo.hostenv.getBaseScriptUri()+loc,uri); - } - - this.Uri = function (/*dojo.uri.Uri||String...*/) { - // summary: Constructor to create an object representing a URI. - // description: - // Each argument is evaluated in order relative to the next until - // a canonical uri is produced. To get an absolute Uri relative - // to the current document use - // new dojo.uri.Uri(document.baseURI, uri) - - // TODO: support for IPv6, see RFC 2732 - - // resolve uri components relative to each other + }; + this.moduleUri = function (module, uri) { + var loc = dojo.hostenv.getModuleSymbols(module).join("/"); + if (!loc) { + return null; + } + if (loc.lastIndexOf("/") != loc.length - 1) { + loc += "/"; + } + var colonIndex = loc.indexOf(":"); + var slashIndex = loc.indexOf("/"); + if (loc.charAt(0) != "/" && (colonIndex == -1 || colonIndex > slashIndex)) { + loc = dojo.hostenv.getBaseScriptUri() + loc; + } + return new dojo.uri.Uri(loc, uri); + }; + this.Uri = function () { var uri = arguments[0]; for (var i = 1; i < arguments.length; i++) { - if(!arguments[i]) { continue; } - - // Safari doesn't support this.constructor so we have to be explicit + if (!arguments[i]) { + continue; + } var relobj = new dojo.uri.Uri(arguments[i].toString()); var uriobj = new dojo.uri.Uri(uri.toString()); - - if ((relobj.path=="")&&(relobj.scheme==null)&&(relobj.authority==null)&&(relobj.query==null)) { - if (relobj.fragment != null) { uriobj.fragment = relobj.fragment; } + if ((relobj.path == "") && (relobj.scheme == null) && (relobj.authority == null) && (relobj.query == null)) { + if (relobj.fragment != null) { + uriobj.fragment = relobj.fragment; + } relobj = uriobj; - } else if (relobj.scheme == null) { - relobj.scheme = uriobj.scheme; - - if (relobj.authority == null) { - relobj.authority = uriobj.authority; - - if (relobj.path.charAt(0) != "/") { - var path = uriobj.path.substring(0, - uriobj.path.lastIndexOf("/") + 1) + relobj.path; - - var segs = path.split("/"); - for (var j = 0; j < segs.length; j++) { - if (segs[j] == ".") { - if (j == segs.length - 1) { segs[j] = ""; } - else { segs.splice(j, 1); j--; } - } else if (j > 0 && !(j == 1 && segs[0] == "") && - segs[j] == ".." && segs[j-1] != "..") { - - if (j == segs.length - 1) { segs.splice(j, 1); segs[j - 1] = ""; } - else { segs.splice(j - 1, 2); j -= 2; } + } else { + if (relobj.scheme == null) { + relobj.scheme = uriobj.scheme; + if (relobj.authority == null) { + relobj.authority = uriobj.authority; + if (relobj.path.charAt(0) != "/") { + var path = uriobj.path.substring(0, uriobj.path.lastIndexOf("/") + 1) + relobj.path; + var segs = path.split("/"); + for (var j = 0; j < segs.length; j++) { + if (segs[j] == ".") { + if (j == segs.length - 1) { + segs[j] = ""; + } else { + segs.splice(j, 1); + j--; + } + } else { + if (j > 0 && !(j == 1 && segs[0] == "") && segs[j] == ".." && segs[j - 1] != "..") { + if (j == segs.length - 1) { + segs.splice(j, 1); + segs[j - 1] = ""; + } else { + segs.splice(j - 1, 2); + j -= 2; + } + } + } } + relobj.path = segs.join("/"); } - relobj.path = segs.join("/"); } } } - uri = ""; - if (relobj.scheme != null) { uri += relobj.scheme + ":"; } - if (relobj.authority != null) { uri += "//" + relobj.authority; } + if (relobj.scheme != null) { + uri += relobj.scheme + ":"; + } + if (relobj.authority != null) { + uri += "//" + relobj.authority; + } uri += relobj.path; - if (relobj.query != null) { uri += "?" + relobj.query; } - if (relobj.fragment != null) { uri += "#" + relobj.fragment; } + if (relobj.query != null) { + uri += "?" + relobj.query; + } + if (relobj.fragment != null) { + uri += "#" + relobj.fragment; + } } - this.uri = uri.toString(); - - // break the uri into its main components var regexp = "^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$"; - var r = this.uri.match(new RegExp(regexp)); - + var r = this.uri.match(new RegExp(regexp)); this.scheme = r[2] || (r[1] ? "" : null); this.authority = r[4] || (r[3] ? "" : null); - this.path = r[5]; // can never be undefined + this.path = r[5]; this.query = r[7] || (r[6] ? "" : null); - this.fragment = r[9] || (r[8] ? "" : null); - + this.fragment = r[9] || (r[8] ? "" : null); if (this.authority != null) { - // server based naming authority regexp = "^((([^:]+:)?([^@]+))@)?([^:]*)(:([0-9]+))?$"; r = this.authority.match(new RegExp(regexp)); - this.user = r[3] || null; this.password = r[4] || null; this.host = r[5]; this.port = r[7] || null; } - - this.toString = function(){ return this.uri; } - } + this.toString = function () { + return this.uri; + }; + }; }; + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uri/__package__.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uri/__package__.js index 68680078e..974e8d890 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uri/__package__.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uri/__package__.js @@ -8,7 +8,6 @@ http://dojotoolkit.org/community/licensing.shtml */ -dojo.kwCompoundRequire({ - common: [["dojo.uri.Uri", false, false]] -}); +dojo.kwCompoundRequire({common:[["dojo.uri.Uri", false, false]]}); dojo.provide("dojo.uri.*"); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uri/cache.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uri/cache.js new file mode 100644 index 000000000..3e14af0ca --- /dev/null +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uri/cache.js @@ -0,0 +1,30 @@ +/* + Copyright (c) 2004-2006, The Dojo Foundation + All Rights Reserved. + + Licensed under the Academic Free License version 2.1 or above OR the + modified BSD license. For more information on Dojo licensing, see: + + http://dojotoolkit.org/community/licensing.shtml +*/ + +dojo.provide("dojo.uri.cache"); +dojo.uri.cache = {_cache:{}, set:function (uri, content) { + this._cache[uri.toString()] = content; + return uri; +}, remove:function (uri) { + delete this._cache[uri.toString()]; +}, get:function (uri) { + var key = uri.toString(); + var value = this._cache[key]; + if (!value) { + value = dojo.hostenv.getText(key); + if (value) { + this._cache[key] = value; + } + } + return value; +}, allow:function (uri) { + return uri; +}}; + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uuid/LightweightGenerator.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uuid/LightweightGenerator.js index 498bfc044..ebc4bf58c 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uuid/LightweightGenerator.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uuid/LightweightGenerator.js @@ -9,54 +9,20 @@ */ dojo.provide("dojo.uuid.LightweightGenerator"); - -/* - * summary: - * The LightweightGenerator is intended to be small and fast, - * but not necessarily good. - * - * description: - * Small: The LightweightGenerator has a small footprint. - * Once comments are stripped, it's only about 25 lines of - * code, and it doesn't dojo.require() any other packages. - * - * Fast: The LightweightGenerator can generate lots of new - * UUIDs fairly quickly (at least, more quickly than the other - * dojo UUID generators). - * - * Not necessarily good: We use Math.random() as our source - * of randomness, which may or may not provide much randomness. - */ - -dojo.uuid.LightweightGenerator = new function() { +dojo.uuid.LightweightGenerator = new function () { var HEX_RADIX = 16; - function _generateRandomEightCharacterHexString() { - // Make random32bitNumber be a randomly generated floating point number - // between 0 and (4,294,967,296 - 1), inclusive. - var random32bitNumber = Math.floor( (Math.random() % 1) * Math.pow(2, 32) ); + var random32bitNumber = Math.floor((Math.random() % 1) * Math.pow(2, 32)); var eightCharacterHexString = random32bitNumber.toString(HEX_RADIX); while (eightCharacterHexString.length < 8) { eightCharacterHexString = "0" + eightCharacterHexString; } - return eightCharacterHexString; // for example: "3B12F1DF" + return eightCharacterHexString; } - - this.generate = function(/* constructor? */ returnType) { - // summary: - // This function generates random UUIDs, meaning "version 4" UUIDs. - // description: - // A typical generated value would be something like this: - // "3b12f1df-5232-4804-897e-917bf397618a" - // returnType: The type of object to return. Usually String or dojo.uuid.Uuid - - // examples: - // var string = dojo.uuid.LightweightGenerator.generate(); - // var string = dojo.uuid.LightweightGenerator.generate(String); - // var uuid = dojo.uuid.LightweightGenerator.generate(dojo.uuid.Uuid); + this.generate = function (returnType) { var hyphen = "-"; - var versionCodeForRandomlyGeneratedUuids = "4"; // 8 == binary2hex("0100") - var variantCodeForDCEUuids = "8"; // 8 == binary2hex("1000") + var versionCodeForRandomlyGeneratedUuids = "4"; + var variantCodeForDCEUuids = "8"; var a = _generateRandomEightCharacterHexString(); var b = _generateRandomEightCharacterHexString(); b = b.substring(0, 4) + hyphen + versionCodeForRandomlyGeneratedUuids + b.substring(5, 8); @@ -71,3 +37,4 @@ dojo.uuid.LightweightGenerator = new function() { return returnValue; }; }(); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uuid/NameBasedGenerator.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uuid/NameBasedGenerator.js index 8a4c8601b..dfcaaeb4c 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uuid/NameBasedGenerator.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uuid/NameBasedGenerator.js @@ -9,30 +9,14 @@ */ dojo.provide("dojo.uuid.NameBasedGenerator"); - -dojo.uuid.NameBasedGenerator = new function() { - this.generate = function(/* constructor? */ returnType) { - // summary: - // This function generates name-based UUIDs, meaning "version 3" - // and "version 5" UUIDs. - // returnType: The type of object to return. Usually String or dojo.uuid.Uuid - - // examples: - // var string = dojo.uuid.NameBasedGenerator.generate(); - // var string = dojo.uuid.NameBasedGenerator.generate(String); - // var uuid = dojo.uuid.NameBasedGenerator.generate(dojo.uuid.Uuid); - - dojo.unimplemented('dojo.uuid.NameBasedGenerator.generate'); - - // FIXME: - // For an algorithm to generate name-based UUIDs, - // see sections 4.3 of RFC 4122: - // http://www.ietf.org/rfc/rfc4122.txt - - var returnValue = "00000000-0000-0000-0000-000000000000"; // FIXME +dojo.uuid.NameBasedGenerator = new function () { + this.generate = function (returnType) { + dojo.unimplemented("dojo.uuid.NameBasedGenerator.generate"); + var returnValue = "00000000-0000-0000-0000-000000000000"; if (returnType && (returnType != String)) { returnValue = new returnType(returnValue); } - return returnValue; // object + return returnValue; }; -}(); \ No newline at end of file +}(); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uuid/NilGenerator.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uuid/NilGenerator.js index d676d9645..1b1a10027 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uuid/NilGenerator.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uuid/NilGenerator.js @@ -9,24 +9,13 @@ */ dojo.provide("dojo.uuid.NilGenerator"); - -dojo.uuid.NilGenerator = new function() { - this.generate = function(/* constructor? */ returnType) { - // summary: - // This function returns the Nil UUID: "00000000-0000-0000-0000-000000000000". - // description: - // The Nil UUID is described in section 4.1.7 of - // RFC 4122: http://www.ietf.org/rfc/rfc4122.txt - // returnType: The type of object to return. Usually String or dojo.uuid.Uuid - - // examples: - // var string = dojo.uuid.NilGenerator.generate(); - // var string = dojo.uuid.NilGenerator.generate(String); - // var uuid = dojo.uuid.NilGenerator.generate(dojo.uuid.Uuid); +dojo.uuid.NilGenerator = new function () { + this.generate = function (returnType) { var returnValue = "00000000-0000-0000-0000-000000000000"; if (returnType && (returnType != String)) { returnValue = new returnType(returnValue); } - return returnValue; // object + return returnValue; }; -}(); \ No newline at end of file +}(); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uuid/RandomGenerator.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uuid/RandomGenerator.js index 45e317878..2e2a38150 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uuid/RandomGenerator.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uuid/RandomGenerator.js @@ -9,31 +9,14 @@ */ dojo.provide("dojo.uuid.RandomGenerator"); - -dojo.uuid.RandomGenerator = new function() { - this.generate = function(/* constructor? */ returnType) { - // summary: - // This function generates random UUIDs, meaning "version 4" UUIDs. - // description: - // A typical generated value would be something like this: - // "3b12f1df-5232-4804-897e-917bf397618a" - // returnType: The type of object to return. Usually String or dojo.uuid.Uuid - - // examples: - // var string = dojo.uuid.RandomGenerator.generate(); - // var string = dojo.uuid.RandomGenerator.generate(String); - // var uuid = dojo.uuid.RandomGenerator.generate(dojo.uuid.Uuid); - - dojo.unimplemented('dojo.uuid.RandomGenerator.generate'); - // FIXME: - // For an algorithm to generate a random UUID, see - // sections 4.4 and 4.5 of RFC 4122: - // http://www.ietf.org/rfc/rfc4122.txt - - var returnValue = "00000000-0000-0000-0000-000000000000"; // FIXME +dojo.uuid.RandomGenerator = new function () { + this.generate = function (returnType) { + dojo.unimplemented("dojo.uuid.RandomGenerator.generate"); + var returnValue = "00000000-0000-0000-0000-000000000000"; if (returnType && (returnType != String)) { returnValue = new returnType(returnValue); } - return returnValue; // object + return returnValue; }; }(); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uuid/TimeBasedGenerator.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uuid/TimeBasedGenerator.js index 9109c9add..9ddf0acc8 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uuid/TimeBasedGenerator.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uuid/TimeBasedGenerator.js @@ -12,18 +12,8 @@ dojo.provide("dojo.uuid.TimeBasedGenerator"); dojo.require("dojo.lang.common"); dojo.require("dojo.lang.type"); dojo.require("dojo.lang.assert"); - -dojo.uuid.TimeBasedGenerator = new function() { - - // -------------------------------------------------- - // Public constants: - // Number of hours between October 15, 1582 and January 1, 1970: +dojo.uuid.TimeBasedGenerator = new function () { this.GREGORIAN_CHANGE_OFFSET_IN_HOURS = 3394248; - // Number of seconds between October 15, 1582 and January 1, 1970: - // this.GREGORIAN_CHANGE_OFFSET_IN_SECONDS = 12219292800; - - // -------------------------------------------------- - // Private variables: var _uuidPseudoNodeString = null; var _uuidClockSeqString = null; var _dateValueOfPreviousUuid = null; @@ -31,86 +21,68 @@ dojo.uuid.TimeBasedGenerator = new function() { var _cachedMillisecondsBetween1582and1970 = null; var _cachedHundredNanosecondIntervalsPerMillisecond = null; var _uniformNode = null; - - // -------------------------------------------------- - // Private constants: var HEX_RADIX = 16; - - function _carry(/* array */ arrayA) { - // summary: - // Given an array which holds a 64-bit number broken into 4 16-bit - // elements, this method carries any excess bits (greater than 16-bits) - // from each array element into the next. - // arrayA: An array with 4 elements, each of which is a 16-bit number. + function _carry(arrayA) { arrayA[2] += arrayA[3] >>> 16; - arrayA[3] &= 0xFFFF; + arrayA[3] &= 65535; arrayA[1] += arrayA[2] >>> 16; - arrayA[2] &= 0xFFFF; + arrayA[2] &= 65535; arrayA[0] += arrayA[1] >>> 16; - arrayA[1] &= 0xFFFF; + arrayA[1] &= 65535; dojo.lang.assert((arrayA[0] >>> 16) === 0); } - - function _get64bitArrayFromFloat(/* float */ x) { - // summary: - // Given a floating point number, this method returns an array which - // holds a 64-bit number broken into 4 16-bit elements. + function _get64bitArrayFromFloat(x) { var result = new Array(0, 0, 0, 0); - result[3] = x % 0x10000; + result[3] = x % 65536; x -= result[3]; - x /= 0x10000; - result[2] = x % 0x10000; + x /= 65536; + result[2] = x % 65536; x -= result[2]; - x /= 0x10000; - result[1] = x % 0x10000; + x /= 65536; + result[1] = x % 65536; x -= result[1]; - x /= 0x10000; + x /= 65536; result[0] = x; - return result; // Array with 4 elements, each of which is a 16-bit number. + return result; } - - function _addTwo64bitArrays(/* array */ arrayA, /* array */ arrayB) { - // summary: - // Takes two arrays, each of which holds a 64-bit number broken into 4 - // 16-bit elements, and returns a new array that holds a 64-bit number - // that is the sum of the two original numbers. - // arrayA: An array with 4 elements, each of which is a 16-bit number. - // arrayB: An array with 4 elements, each of which is a 16-bit number. + function _addTwo64bitArrays(arrayA, arrayB) { dojo.lang.assertType(arrayA, Array); dojo.lang.assertType(arrayB, Array); dojo.lang.assert(arrayA.length == 4); dojo.lang.assert(arrayB.length == 4); - var result = new Array(0, 0, 0, 0); result[3] = arrayA[3] + arrayB[3]; result[2] = arrayA[2] + arrayB[2]; result[1] = arrayA[1] + arrayB[1]; result[0] = arrayA[0] + arrayB[0]; _carry(result); - return result; // Array with 4 elements, each of which is a 16-bit number. + return result; } - - function _multiplyTwo64bitArrays(/* array */ arrayA, /* array */ arrayB) { - // summary: - // Takes two arrays, each of which holds a 64-bit number broken into 4 - // 16-bit elements, and returns a new array that holds a 64-bit number - // that is the product of the two original numbers. - // arrayA: An array with 4 elements, each of which is a 16-bit number. - // arrayB: An array with 4 elements, each of which is a 16-bit number. + function _multiplyTwo64bitArrays(arrayA, arrayB) { dojo.lang.assertType(arrayA, Array); dojo.lang.assertType(arrayB, Array); dojo.lang.assert(arrayA.length == 4); dojo.lang.assert(arrayB.length == 4); - var overflow = false; - if (arrayA[0] * arrayB[0] !== 0) { overflow = true; } - if (arrayA[0] * arrayB[1] !== 0) { overflow = true; } - if (arrayA[0] * arrayB[2] !== 0) { overflow = true; } - if (arrayA[1] * arrayB[0] !== 0) { overflow = true; } - if (arrayA[1] * arrayB[1] !== 0) { overflow = true; } - if (arrayA[2] * arrayB[0] !== 0) { overflow = true; } + if (arrayA[0] * arrayB[0] !== 0) { + overflow = true; + } + if (arrayA[0] * arrayB[1] !== 0) { + overflow = true; + } + if (arrayA[0] * arrayB[2] !== 0) { + overflow = true; + } + if (arrayA[1] * arrayB[0] !== 0) { + overflow = true; + } + if (arrayA[1] * arrayB[1] !== 0) { + overflow = true; + } + if (arrayA[2] * arrayB[0] !== 0) { + overflow = true; + } dojo.lang.assert(!overflow); - var result = new Array(0, 0, 0, 0); result[0] += arrayA[0] * arrayB[3]; _carry(result); @@ -132,50 +104,24 @@ dojo.uuid.TimeBasedGenerator = new function() { _carry(result); result[3] += arrayA[3] * arrayB[3]; _carry(result); - return result; // Array with 4 elements, each of which is a 16-bit number. + return result; } - - function _padWithLeadingZeros(/* string */ string, /* int */ desiredLength) { - // summary: - // Pads a string with leading zeros and returns the result. - // string: A string to add padding to. - // desiredLength: The number of characters the return string should have. - - // examples: - // result = _padWithLeadingZeros("abc", 6); - // dojo.lang.assert(result == "000abc"); + function _padWithLeadingZeros(string, desiredLength) { while (string.length < desiredLength) { string = "0" + string; } - return string; // string + return string; } - function _generateRandomEightCharacterHexString() { - // summary: - // Returns a randomly generated 8-character string of hex digits. - - // FIXME: This probably isn't a very high quality random number. - - // Make random32bitNumber be a randomly generated floating point number - // between 0 and (4,294,967,296 - 1), inclusive. - var random32bitNumber = Math.floor( (Math.random() % 1) * Math.pow(2, 32) ); - + var random32bitNumber = Math.floor((Math.random() % 1) * Math.pow(2, 32)); var eightCharacterString = random32bitNumber.toString(HEX_RADIX); while (eightCharacterString.length < 8) { eightCharacterString = "0" + eightCharacterString; } - return eightCharacterString; // String (an 8-character hex string) + return eightCharacterString; } - - function _generateUuidString(/* string? */ node) { - // summary: - // Generates a time-based UUID, meaning a version 1 UUID. - // description: - // JavaScript code running in a browser doesn't have access to the - // IEEE 802.3 address of the computer, so if a node value isn't - // supplied, we generate a random pseudonode value instead. - // node: An optional 12-character string to use as the node in the new UUID. - dojo.lang.assertType(node, String, {optional: true}); + function _generateUuidString(node) { + dojo.lang.assertType(node, String, {optional:true}); if (node) { dojo.lang.assert(node.length == 12); } else { @@ -183,8 +129,8 @@ dojo.uuid.TimeBasedGenerator = new function() { node = _uniformNode; } else { if (!_uuidPseudoNodeString) { - var pseudoNodeIndicatorBit = 0x8000; - var random15bitNumber = Math.floor( (Math.random() % 1) * Math.pow(2, 15) ); + var pseudoNodeIndicatorBit = 32768; + var random15bitNumber = Math.floor((Math.random() % 1) * Math.pow(2, 15)); var leftmost4HexCharacters = (pseudoNodeIndicatorBit | random15bitNumber).toString(HEX_RADIX); _uuidPseudoNodeString = leftmost4HexCharacters + _generateRandomEightCharacterHexString(); } @@ -192,18 +138,12 @@ dojo.uuid.TimeBasedGenerator = new function() { } } if (!_uuidClockSeqString) { - var variantCodeForDCEUuids = 0x8000; // 10--------------, i.e. uses only first two of 16 bits. - var random14bitNumber = Math.floor( (Math.random() % 1) * Math.pow(2, 14) ); + var variantCodeForDCEUuids = 32768; + var random14bitNumber = Math.floor((Math.random() % 1) * Math.pow(2, 14)); _uuidClockSeqString = (variantCodeForDCEUuids | random14bitNumber).toString(HEX_RADIX); } - - // Maybe we should think about trying to make the code more readable to - // newcomers by creating a class called "WholeNumber" that encapsulates - // the methods and data structures for working with these arrays that - // hold 4 16-bit numbers? And then these variables below have names - // like "wholeSecondsPerHour" rather than "arraySecondsPerHour"? var now = new Date(); - var millisecondsSince1970 = now.valueOf(); // milliseconds since midnight 01 January, 1970 UTC. + var millisecondsSince1970 = now.valueOf(); var nowArray = _get64bitArrayFromFloat(millisecondsSince1970); if (!_cachedMillisecondsBetween1582and1970) { var arraySecondsPerHour = _get64bitArrayFromFloat(60 * 60); @@ -216,18 +156,11 @@ dojo.uuid.TimeBasedGenerator = new function() { var arrayMillisecondsSince1970 = nowArray; var arrayMillisecondsSince1582 = _addTwo64bitArrays(_cachedMillisecondsBetween1582and1970, arrayMillisecondsSince1970); var arrayHundredNanosecondIntervalsSince1582 = _multiplyTwo64bitArrays(arrayMillisecondsSince1582, _cachedHundredNanosecondIntervalsPerMillisecond); - if (now.valueOf() == _dateValueOfPreviousUuid) { arrayHundredNanosecondIntervalsSince1582[3] += _nextIntraMillisecondIncrement; _carry(arrayHundredNanosecondIntervalsSince1582); _nextIntraMillisecondIncrement += 1; if (_nextIntraMillisecondIncrement == 10000) { - // If we've gotten to here, it means we've already generated 10,000 - // UUIDs in this single millisecond, which is the most that the UUID - // timestamp field allows for. So now we'll just sit here and wait - // for a fraction of a millisecond, so as to ensure that the next - // time this method is called there will be a different millisecond - // value in the timestamp field. while (now.valueOf() == _dateValueOfPreviousUuid) { now = new Date(); } @@ -236,8 +169,7 @@ dojo.uuid.TimeBasedGenerator = new function() { _dateValueOfPreviousUuid = now.valueOf(); _nextIntraMillisecondIncrement = 1; } - - var hexTimeLowLeftHalf = arrayHundredNanosecondIntervalsSince1582[2].toString(HEX_RADIX); + var hexTimeLowLeftHalf = arrayHundredNanosecondIntervalsSince1582[2].toString(HEX_RADIX); var hexTimeLowRightHalf = arrayHundredNanosecondIntervalsSince1582[3].toString(HEX_RADIX); var hexTimeLow = _padWithLeadingZeros(hexTimeLowLeftHalf, 4) + _padWithLeadingZeros(hexTimeLowRightHalf, 4); var hexTimeMid = arrayHundredNanosecondIntervalsSince1582[1].toString(HEX_RADIX); @@ -245,65 +177,23 @@ dojo.uuid.TimeBasedGenerator = new function() { var hexTimeHigh = arrayHundredNanosecondIntervalsSince1582[0].toString(HEX_RADIX); hexTimeHigh = _padWithLeadingZeros(hexTimeHigh, 3); var hyphen = "-"; - var versionCodeForTimeBasedUuids = "1"; // binary2hex("0001") - var resultUuid = hexTimeLow + hyphen + hexTimeMid + hyphen + - versionCodeForTimeBasedUuids + hexTimeHigh + hyphen + - _uuidClockSeqString + hyphen + node; + var versionCodeForTimeBasedUuids = "1"; + var resultUuid = hexTimeLow + hyphen + hexTimeMid + hyphen + versionCodeForTimeBasedUuids + hexTimeHigh + hyphen + _uuidClockSeqString + hyphen + node; resultUuid = resultUuid.toLowerCase(); - return resultUuid; // String (a 36 character string, which will look something like "b4308fb0-86cd-11da-a72b-0800200c9a66") + return resultUuid; } - - this.setNode = function(/* string? */ node) { - // summary: - // Sets the 'node' value that will be included in generated UUIDs. - // node: A 12-character hex string representing a pseudoNode or hardwareNode. + this.setNode = function (node) { dojo.lang.assert((node === null) || (node.length == 12)); _uniformNode = node; }; - - this.getNode = function() { - // summary: - // Returns the 'node' value that will be included in generated UUIDs. - return _uniformNode; // String (a 12-character hex string representing a pseudoNode or hardwareNode) + this.getNode = function () { + return _uniformNode; }; - - this.generate = function(/* misc? */ input) { - // summary: - // This function generates time-based UUIDs, meaning "version 1" UUIDs. - // description: - // For more info, see - // http://www.webdav.org/specs/draft-leach-uuids-guids-01.txt - // http://www.infonuovo.com/dma/csdocs/sketch/instidid.htm - // http://kruithof.xs4all.nl/uuid/uuidgen - // http://www.opengroup.org/onlinepubs/009629399/apdxa.htm#tagcjh_20 - // http://jakarta.apache.org/commons/sandbox/id/apidocs/org/apache/commons/id/uuid/clock/Clock.html - - // examples: - // var generate = dojo.uuid.TimeBasedGenerator.generate; - // var uuid; // an instance of dojo.uuid.Uuid - // var string; // a simple string literal - // string = generate(); - // string = generate(String); - // uuid = generate(dojo.uuid.Uuid); - // string = generate("017bf397618a"); - // string = generate({node: "017bf397618a"}); // hardwareNode - // string = generate({node: "f17bf397618a"}); // pseudoNode - // string = generate({hardwareNode: "017bf397618a"}); - // string = generate({pseudoNode: "f17bf397618a"}); - // string = generate({node: "017bf397618a", returnType: String}); - // uuid = generate({node: "017bf397618a", returnType: dojo.uuid.Uuid}); - // dojo.uuid.TimeBasedGenerator.setNode("017bf397618a"); - // string = generate(); // the generated UUID has node == "017bf397618a" - // uuid = generate(dojo.uuid.Uuid); // the generated UUID has node == "017bf397618a" + this.generate = function (input) { var nodeString = null; var returnType = null; - if (input) { if (dojo.lang.isObject(input) && !dojo.lang.isBuiltIn(input)) { - // input: object {node: string, hardwareNode: string, pseudoNode: string} - // node: A 12-character hex string representing a pseudoNode or hardwareNode. - // hardwareNode: A 12-character hex string containing an IEEE 802.3 network node identificator. - // pseudoNode: A 12-character hex string representing a pseudoNode. var namedParameters = input; dojo.lang.assertValidKeywords(namedParameters, ["node", "hardwareNode", "pseudoNode", "returnType"]); var node = namedParameters["node"]; @@ -314,22 +204,20 @@ dojo.uuid.TimeBasedGenerator = new function() { var firstCharacter = nodeString.charAt(0); var firstDigit = parseInt(firstCharacter, HEX_RADIX); if (hardwareNode) { - dojo.lang.assert((firstDigit >= 0x0) && (firstDigit <= 0x7)); + dojo.lang.assert((firstDigit >= 0) && (firstDigit <= 7)); } if (pseudoNode) { - dojo.lang.assert((firstDigit >= 0x8) && (firstDigit <= 0xF)); + dojo.lang.assert((firstDigit >= 8) && (firstDigit <= 15)); } } returnType = namedParameters["returnType"]; - dojo.lang.assertType(returnType, Function, {optional: true}); + dojo.lang.assertType(returnType, Function, {optional:true}); } else { if (dojo.lang.isString(input)) { - // input: string A 12-character hex string representing a pseudoNode or hardwareNode. nodeString = input; returnType = null; } else { if (dojo.lang.isFunction(input)) { - // input: constructor The type of object to return. Usually String or dojo.uuid.Uuid nodeString = null; returnType = input; } @@ -340,9 +228,8 @@ dojo.uuid.TimeBasedGenerator = new function() { var integer = parseInt(nodeString, HEX_RADIX); dojo.lang.assert(isFinite(integer)); } - dojo.lang.assertType(returnType, Function, {optional: true}); + dojo.lang.assertType(returnType, Function, {optional:true}); } - var uuidString = _generateUuidString(nodeString); var returnValue; if (returnType && (returnType != String)) { @@ -350,6 +237,7 @@ dojo.uuid.TimeBasedGenerator = new function() { } else { returnValue = uuidString; } - return returnValue; // object + return returnValue; }; }(); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uuid/Uuid.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uuid/Uuid.js index 6695fd183..047c98d75 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uuid/Uuid.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uuid/Uuid.js @@ -11,35 +11,18 @@ dojo.provide("dojo.uuid.Uuid"); dojo.require("dojo.lang.common"); dojo.require("dojo.lang.assert"); - -dojo.uuid.Uuid = function(/* string || generator */ input) { - // summary: - // This is the constructor for the Uuid class. The Uuid class offers - // methods for inspecting existing UUIDs. - - // examples: - // var uuid; - // uuid = new dojo.uuid.Uuid("3b12f1df-5232-4804-897e-917bf397618a"); - // uuid = new dojo.uuid.Uuid(); // "00000000-0000-0000-0000-000000000000" - // uuid = new dojo.uuid.Uuid(dojo.uuid.RandomGenerator); - // uuid = new dojo.uuid.Uuid(dojo.uuid.TimeBasedGenerator); - // dojo.uuid.Uuid.setGenerator(dojo.uuid.RandomGenerator); - // uuid = new dojo.uuid.Uuid(); - // dojo.lang.assert(!uuid.isEqual(dojo.uuid.Uuid.NIL_UUID)); +dojo.uuid.Uuid = function (input) { this._uuidString = dojo.uuid.Uuid.NIL_UUID; if (input) { if (dojo.lang.isString(input)) { - // input: string? A 36-character string that conforms to the UUID spec. this._uuidString = input.toLowerCase(); dojo.lang.assert(this.isValid()); } else { if (dojo.lang.isObject(input) && input.generate) { - // input: generator A UUID generator, such as dojo.uuid.TimeBasedGenerator. var generator = input; this._uuidString = generator.generate(); dojo.lang.assert(this.isValid()); } else { - // we got passed something other than a string dojo.lang.assert(false, "The dojo.uuid.Uuid() constructor must be initializated with a UUID string."); } } @@ -51,134 +34,63 @@ dojo.uuid.Uuid = function(/* string || generator */ input) { } } }; - -// ------------------------------------------------------------------- -// Public constants -// ------------------------------------------------------------------- dojo.uuid.Uuid.NIL_UUID = "00000000-0000-0000-0000-000000000000"; -dojo.uuid.Uuid.Version = { - UNKNOWN: 0, - TIME_BASED: 1, - DCE_SECURITY: 2, - NAME_BASED_MD5: 3, - RANDOM: 4, - NAME_BASED_SHA1: 5 }; -dojo.uuid.Uuid.Variant = { - NCS: "0", - DCE: "10", - MICROSOFT: "110", - UNKNOWN: "111" }; +dojo.uuid.Uuid.Version = {UNKNOWN:0, TIME_BASED:1, DCE_SECURITY:2, NAME_BASED_MD5:3, RANDOM:4, NAME_BASED_SHA1:5}; +dojo.uuid.Uuid.Variant = {NCS:"0", DCE:"10", MICROSOFT:"110", UNKNOWN:"111"}; dojo.uuid.Uuid.HEX_RADIX = 16; - -dojo.uuid.Uuid.compare = function(/* dojo.uuid.Uuid */ uuidOne, /* dojo.uuid.Uuid */ uuidTwo) { - // summary: - // Given two UUIDs to compare, this method returns 0, 1, or -1. - // description: - // This method is designed to be used by sorting routines, like the - // JavaScript built-in Array sort() method. This implementation is - // intended to match the sample implementation in IETF RFC 4122: - // http://www.ietf.org/rfc/rfc4122.txt - // uuidOne: Any object that has toString() method that returns a 36-character string that conforms to the UUID spec. - // uuidTwo: Any object that has toString() method that returns a 36-character string that conforms to the UUID spec. - - // examples: - // var uuid; - // var generator = dojo.uuid.TimeBasedGenerator; - // var a = new dojo.uuid.Uuid(generator); - // var b = new dojo.uuid.Uuid(generator); - // var c = new dojo.uuid.Uuid(generator); - // var array = new Array(a, b, c); - // array.sort(dojo.uuid.Uuid.compare); +dojo.uuid.Uuid.compare = function (uuidOne, uuidTwo) { var uuidStringOne = uuidOne.toString(); var uuidStringTwo = uuidTwo.toString(); - if (uuidStringOne > uuidStringTwo) return 1; // integer - if (uuidStringOne < uuidStringTwo) return -1; // integer - return 0; // integer (either 0, 1, or -1) + if (uuidStringOne > uuidStringTwo) { + return 1; + } + if (uuidStringOne < uuidStringTwo) { + return -1; + } + return 0; }; - -dojo.uuid.Uuid.setGenerator = function(/* generator? */ generator) { - // summary: - // Sets the default generator, which will be used by the - // "new dojo.uuid.Uuid()" constructor if no parameters - // are passed in. - // generator: A UUID generator, such as dojo.uuid.TimeBasedGenerator. +dojo.uuid.Uuid.setGenerator = function (generator) { dojo.lang.assert(!generator || (dojo.lang.isObject(generator) && generator.generate)); dojo.uuid.Uuid._ourGenerator = generator; }; - -dojo.uuid.Uuid.getGenerator = function() { - // summary: - // Returns the default generator. See setGenerator(). - return dojo.uuid.Uuid._ourGenerator; // generator (A UUID generator, such as dojo.uuid.TimeBasedGenerator). +dojo.uuid.Uuid.getGenerator = function () { + return dojo.uuid.Uuid._ourGenerator; }; - -dojo.uuid.Uuid.prototype.toString = function(/* string? */format) { - // summary: - // By default this method returns a standard 36-character string representing - // the UUID, such as "3b12f1df-5232-4804-897e-917bf397618a". You can also - // pass in an optional format specifier to request the output in any of - // a half dozen slight variations. - // format: One of these strings: '{}', '()', '""', "''", 'urn', '!-' - - // examples: - // var uuid = new dojo.uuid.Uuid(dojo.uuid.TimeBasedGenerator); - // var s; - // s = uuid.toString(); // eb529fec-6498-11d7-b236-000629ba5445 - // s = uuid.toString('{}'); // {eb529fec-6498-11d7-b236-000629ba5445} - // s = uuid.toString('()'); // (eb529fec-6498-11d7-b236-000629ba5445) - // s = uuid.toString('""'); // "eb529fec-6498-11d7-b236-000629ba5445" - // s = uuid.toString("''"); // 'eb529fec-6498-11d7-b236-000629ba5445' - // s = uuid.toString('!-'); // eb529fec649811d7b236000629ba5445 - // s = uuid.toString('urn'); // urn:uuid:eb529fec-6498-11d7-b236-000629ba5445 +dojo.uuid.Uuid.prototype.toString = function (format) { if (format) { switch (format) { - case '{}': - return '{' + this._uuidString + '}'; - break; - case '()': - return '(' + this._uuidString + ')'; - break; - case '""': - return '"' + this._uuidString + '"'; - break; - case "''": - return "'" + this._uuidString + "'"; - break; - case 'urn': - return 'urn:uuid:' + this._uuidString; - break; - case '!-': - return this._uuidString.split('-').join(''); - break; - default: - // we got passed something other than what we expected - dojo.lang.assert(false, "The toString() method of dojo.uuid.Uuid was passed a bogus format."); + case "{}": + return "{" + this._uuidString + "}"; + break; + case "()": + return "(" + this._uuidString + ")"; + break; + case "\"\"": + return "\"" + this._uuidString + "\""; + break; + case "''": + return "'" + this._uuidString + "'"; + break; + case "urn": + return "urn:uuid:" + this._uuidString; + break; + case "!-": + return this._uuidString.split("-").join(""); + break; + default: + dojo.lang.assert(false, "The toString() method of dojo.uuid.Uuid was passed a bogus format."); } } else { - return this._uuidString; // string + return this._uuidString; } }; - -dojo.uuid.Uuid.prototype.compare = function(/* dojo.uuid.Uuid */ otherUuid) { - // summary: - // Compares this UUID to another UUID, and returns 0, 1, or -1. - // description: - // This implementation is intended to match the sample implementation - // in IETF RFC 4122: http://www.ietf.org/rfc/rfc4122.txt - // otherUuid: Any object that has toString() method that returns a 36-character string that conforms to the UUID spec. - return dojo.uuid.Uuid.compare(this, otherUuid); // integer (either 0, 1, or -1) +dojo.uuid.Uuid.prototype.compare = function (otherUuid) { + return dojo.uuid.Uuid.compare(this, otherUuid); }; - -dojo.uuid.Uuid.prototype.isEqual = function(/* dojo.uuid.Uuid */ otherUuid) { - // summary: - // Returns true if this UUID is equal to the otherUuid, or false otherwise. - // otherUuid: Any object that has toString() method that returns a 36-character string that conforms to the UUID spec. - return (this.compare(otherUuid) == 0); // boolean +dojo.uuid.Uuid.prototype.isEqual = function (otherUuid) { + return (this.compare(otherUuid) == 0); }; - -dojo.uuid.Uuid.prototype.isValid = function() { - // summary: - // Returns true if the UUID was initialized with a valid value. +dojo.uuid.Uuid.prototype.isValid = function () { try { dojo.lang.assertType(this._uuidString, String); dojo.lang.assert(this._uuidString.length == 36); @@ -195,185 +107,107 @@ dojo.uuid.Uuid.prototype.isValid = function() { var integer = parseInt(part, dojo.uuid.Uuid.HEX_RADIX); dojo.lang.assert(isFinite(integer)); } - return true; // boolean - } catch (e) { - return false; // boolean + return true; + } + catch (e) { + return false; } }; - -dojo.uuid.Uuid.prototype.getVariant = function() { - // summary: - // Returns a variant code that indicates what type of UUID this is. - // Returns one of the enumerated dojo.uuid.Uuid.Variant values. - - // example: - // var uuid = new dojo.uuid.Uuid("3b12f1df-5232-4804-897e-917bf397618a"); - // var variant = uuid.getVariant(); - // dojo.lang.assert(variant == dojo.uuid.Uuid.Variant.DCE); - // example: - // "3b12f1df-5232-4804-897e-917bf397618a" - // ^ - // | - // (variant "10__" == DCE) +dojo.uuid.Uuid.prototype.getVariant = function () { var variantCharacter = this._uuidString.charAt(19); var variantNumber = parseInt(variantCharacter, dojo.uuid.Uuid.HEX_RADIX); dojo.lang.assert((variantNumber >= 0) && (variantNumber <= 16)); - if (!dojo.uuid.Uuid._ourVariantLookupTable) { var Variant = dojo.uuid.Uuid.Variant; var lookupTable = []; - - lookupTable[0x0] = Variant.NCS; // 0000 - lookupTable[0x1] = Variant.NCS; // 0001 - lookupTable[0x2] = Variant.NCS; // 0010 - lookupTable[0x3] = Variant.NCS; // 0011 - - lookupTable[0x4] = Variant.NCS; // 0100 - lookupTable[0x5] = Variant.NCS; // 0101 - lookupTable[0x6] = Variant.NCS; // 0110 - lookupTable[0x7] = Variant.NCS; // 0111 - - lookupTable[0x8] = Variant.DCE; // 1000 - lookupTable[0x9] = Variant.DCE; // 1001 - lookupTable[0xA] = Variant.DCE; // 1010 - lookupTable[0xB] = Variant.DCE; // 1011 - - lookupTable[0xC] = Variant.MICROSOFT; // 1100 - lookupTable[0xD] = Variant.MICROSOFT; // 1101 - lookupTable[0xE] = Variant.UNKNOWN; // 1110 - lookupTable[0xF] = Variant.UNKNOWN; // 1111 - + lookupTable[0] = Variant.NCS; + lookupTable[1] = Variant.NCS; + lookupTable[2] = Variant.NCS; + lookupTable[3] = Variant.NCS; + lookupTable[4] = Variant.NCS; + lookupTable[5] = Variant.NCS; + lookupTable[6] = Variant.NCS; + lookupTable[7] = Variant.NCS; + lookupTable[8] = Variant.DCE; + lookupTable[9] = Variant.DCE; + lookupTable[10] = Variant.DCE; + lookupTable[11] = Variant.DCE; + lookupTable[12] = Variant.MICROSOFT; + lookupTable[13] = Variant.MICROSOFT; + lookupTable[14] = Variant.UNKNOWN; + lookupTable[15] = Variant.UNKNOWN; dojo.uuid.Uuid._ourVariantLookupTable = lookupTable; } - - return dojo.uuid.Uuid._ourVariantLookupTable[variantNumber]; // dojo.uuid.Uuid.Variant + return dojo.uuid.Uuid._ourVariantLookupTable[variantNumber]; }; - -dojo.uuid.Uuid.prototype.getVersion = function() { - // summary: - // Returns a version number that indicates what type of UUID this is. - // Returns one of the enumerated dojo.uuid.Uuid.Version values. - - // example: - // var uuid = new dojo.uuid.Uuid("b4308fb0-86cd-11da-a72b-0800200c9a66"); - // var version = uuid.getVersion(); - // dojo.lang.assert(version == dojo.uuid.Uuid.Version.TIME_BASED); - // exceptions: - // Throws an Error if this is not a DCE Variant UUID. +dojo.uuid.Uuid.prototype.getVersion = function () { if (!this._versionNumber) { var errorMessage = "Called getVersion() on a dojo.uuid.Uuid that was not a DCE Variant UUID."; dojo.lang.assert(this.getVariant() == dojo.uuid.Uuid.Variant.DCE, errorMessage); - - // "b4308fb0-86cd-11da-a72b-0800200c9a66" - // ^ - // | - // (version 1 == TIME_BASED) var versionCharacter = this._uuidString.charAt(14); this._versionNumber = parseInt(versionCharacter, dojo.uuid.Uuid.HEX_RADIX); } - return this._versionNumber; // dojo.uuid.Uuid.Version + return this._versionNumber; }; - -dojo.uuid.Uuid.prototype.getNode = function() { - // summary: - // If this is a version 1 UUID (a time-based UUID), getNode() returns a - // 12-character string with the "node" or "pseudonode" portion of the UUID, - // which is the rightmost 12 characters. - - // exceptions: - // Throws an Error if this is not a version 1 UUID. +dojo.uuid.Uuid.prototype.getNode = function () { if (!this._nodeString) { var errorMessage = "Called getNode() on a dojo.uuid.Uuid that was not a TIME_BASED UUID."; dojo.lang.assert(this.getVersion() == dojo.uuid.Uuid.Version.TIME_BASED, errorMessage); - - var arrayOfStrings = this._uuidString.split('-'); + var arrayOfStrings = this._uuidString.split("-"); this._nodeString = arrayOfStrings[4]; } - return this._nodeString; // String (a 12-character string, which will look something like "917bf397618a") + return this._nodeString; }; - -dojo.uuid.Uuid.prototype.getTimestamp = function(/* misc. */ returnType) { - // summary: - // If this is a version 1 UUID (a time-based UUID), this method returns - // the timestamp value encoded in the UUID. The caller can ask for the - // timestamp to be returned either as a JavaScript Date object or as a - // 15-character string of hex digits. - // returnType: Any of these five values: "string", String, "hex", "date", Date - - // returns: - // Returns the timestamp value as a JavaScript Date object or a 15-character string of hex digits. - // examples: - // var uuid = new dojo.uuid.Uuid("b4308fb0-86cd-11da-a72b-0800200c9a66"); - // var date, string, hexString; - // date = uuid.getTimestamp(); // returns a JavaScript Date - // date = uuid.getTimestamp(Date); // - // string = uuid.getTimestamp(String); // "Mon, 16 Jan 2006 20:21:41 GMT" - // hexString = uuid.getTimestamp("hex"); // "1da86cdb4308fb0" - // exceptions: - // Throws an Error if this is not a version 1 UUID. +dojo.uuid.Uuid.prototype.getTimestamp = function (returnType) { var errorMessage = "Called getTimestamp() on a dojo.uuid.Uuid that was not a TIME_BASED UUID."; dojo.lang.assert(this.getVersion() == dojo.uuid.Uuid.Version.TIME_BASED, errorMessage); - - if (!returnType) {returnType = null}; + if (!returnType) { + returnType = null; + } switch (returnType) { - case "string": - case String: - return this.getTimestamp(Date).toUTCString(); // String (e.g. "Mon, 16 Jan 2006 20:21:41 GMT") - break; - case "hex": - // Return a 15-character string of hex digits containing the - // timestamp for this UUID, with the high-order bits first. - if (!this._timestampAsHexString) { - var arrayOfStrings = this._uuidString.split('-'); - var hexTimeLow = arrayOfStrings[0]; - var hexTimeMid = arrayOfStrings[1]; - var hexTimeHigh = arrayOfStrings[2]; - - // Chop off the leading "1" character, which is the UUID - // version number for time-based UUIDs. - hexTimeHigh = hexTimeHigh.slice(1); - - this._timestampAsHexString = hexTimeHigh + hexTimeMid + hexTimeLow; - dojo.lang.assert(this._timestampAsHexString.length == 15); - } - return this._timestampAsHexString; // String (e.g. "1da86cdb4308fb0") - break; - case null: // no returnType was specified, so default to Date - case "date": - case Date: - // Return a JavaScript Date object. - if (!this._timestampAsDate) { - var GREGORIAN_CHANGE_OFFSET_IN_HOURS = 3394248; - - var arrayOfParts = this._uuidString.split('-'); - var timeLow = parseInt(arrayOfParts[0], dojo.uuid.Uuid.HEX_RADIX); - var timeMid = parseInt(arrayOfParts[1], dojo.uuid.Uuid.HEX_RADIX); - var timeHigh = parseInt(arrayOfParts[2], dojo.uuid.Uuid.HEX_RADIX); - var hundredNanosecondIntervalsSince1582 = timeHigh & 0x0FFF; - hundredNanosecondIntervalsSince1582 <<= 16; - hundredNanosecondIntervalsSince1582 += timeMid; - // What we really want to do next is shift left 32 bits, but the - // result will be too big to fit in an int, so we'll multiply by 2^32, - // and the result will be a floating point approximation. - hundredNanosecondIntervalsSince1582 *= 0x100000000; - hundredNanosecondIntervalsSince1582 += timeLow; - var millisecondsSince1582 = hundredNanosecondIntervalsSince1582 / 10000; - - // Again, this will be a floating point approximation. - // We can make things exact later if we need to. - var secondsPerHour = 60 * 60; - var hoursBetween1582and1970 = GREGORIAN_CHANGE_OFFSET_IN_HOURS; - var secondsBetween1582and1970 = hoursBetween1582and1970 * secondsPerHour; - var millisecondsBetween1582and1970 = secondsBetween1582and1970 * 1000; - var millisecondsSince1970 = millisecondsSince1582 - millisecondsBetween1582and1970; - - this._timestampAsDate = new Date(millisecondsSince1970); - } - return this._timestampAsDate; // Date - break; - default: - // we got passed something other than a valid returnType - dojo.lang.assert(false, "The getTimestamp() method dojo.uuid.Uuid was passed a bogus returnType: " + returnType); - break; + case "string": + case String: + return this.getTimestamp(Date).toUTCString(); + break; + case "hex": + if (!this._timestampAsHexString) { + var arrayOfStrings = this._uuidString.split("-"); + var hexTimeLow = arrayOfStrings[0]; + var hexTimeMid = arrayOfStrings[1]; + var hexTimeHigh = arrayOfStrings[2]; + hexTimeHigh = hexTimeHigh.slice(1); + this._timestampAsHexString = hexTimeHigh + hexTimeMid + hexTimeLow; + dojo.lang.assert(this._timestampAsHexString.length == 15); + } + return this._timestampAsHexString; + break; + case null: + case "date": + case Date: + if (!this._timestampAsDate) { + var GREGORIAN_CHANGE_OFFSET_IN_HOURS = 3394248; + var arrayOfParts = this._uuidString.split("-"); + var timeLow = parseInt(arrayOfParts[0], dojo.uuid.Uuid.HEX_RADIX); + var timeMid = parseInt(arrayOfParts[1], dojo.uuid.Uuid.HEX_RADIX); + var timeHigh = parseInt(arrayOfParts[2], dojo.uuid.Uuid.HEX_RADIX); + var hundredNanosecondIntervalsSince1582 = timeHigh & 4095; + hundredNanosecondIntervalsSince1582 <<= 16; + hundredNanosecondIntervalsSince1582 += timeMid; + hundredNanosecondIntervalsSince1582 *= 4294967296; + hundredNanosecondIntervalsSince1582 += timeLow; + var millisecondsSince1582 = hundredNanosecondIntervalsSince1582 / 10000; + var secondsPerHour = 60 * 60; + var hoursBetween1582and1970 = GREGORIAN_CHANGE_OFFSET_IN_HOURS; + var secondsBetween1582and1970 = hoursBetween1582and1970 * secondsPerHour; + var millisecondsBetween1582and1970 = secondsBetween1582and1970 * 1000; + var millisecondsSince1970 = millisecondsSince1582 - millisecondsBetween1582and1970; + this._timestampAsDate = new Date(millisecondsSince1970); + } + return this._timestampAsDate; + break; + default: + dojo.lang.assert(false, "The getTimestamp() method dojo.uuid.Uuid was passed a bogus returnType: " + returnType); + break; } }; + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uuid/__package__.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uuid/__package__.js index 9ed3319c6..35bcbbfb7 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uuid/__package__.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/uuid/__package__.js @@ -8,15 +8,6 @@ http://dojotoolkit.org/community/licensing.shtml */ -dojo.kwCompoundRequire({ - common: [ - "dojo.uuid.Uuid", - "dojo.uuid.LightweightGenerator", - "dojo.uuid.RandomGenerator", - "dojo.uuid.TimeBasedGenerator", - "dojo.uuid.NameBasedGenerator", - "dojo.uuid.NilGenerator" - ] -}); +dojo.kwCompoundRequire({common:["dojo.uuid.Uuid", "dojo.uuid.LightweightGenerator", "dojo.uuid.RandomGenerator", "dojo.uuid.TimeBasedGenerator", "dojo.uuid.NameBasedGenerator", "dojo.uuid.NilGenerator"]}); dojo.provide("dojo.uuid.*"); diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate.js index e1764795b..13c6e3d94 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate.js @@ -10,3 +10,4 @@ dojo.provide("dojo.validate"); dojo.require("dojo.validate.common"); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/__package__.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/__package__.js index 6feb1d9cc..ee9bb2f7b 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/__package__.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/__package__.js @@ -9,13 +9,6 @@ */ dojo.require("dojo.validate"); -dojo.kwCompoundRequire({ - common: ["dojo.validate.check", - "dojo.validate.datetime", - "dojo.validate.de", - "dojo.validate.jp", - "dojo.validate.us", - "dojo.validate.web" - ] -}); +dojo.kwCompoundRequire({common:["dojo.validate.check", "dojo.validate.datetime", "dojo.validate.de", "dojo.validate.jp", "dojo.validate.us", "dojo.validate.web"]}); dojo.provide("dojo.validate.*"); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/check.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/check.js index 908d47cd3..e7c51a819 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/check.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/check.js @@ -11,253 +11,222 @@ dojo.provide("dojo.validate.check"); dojo.require("dojo.validate.common"); dojo.require("dojo.lang.common"); - -dojo.validate.check = function(/*HTMLFormElement*/form, /*Object*/profile){ - // summary: validates user input of an HTML form based on input profile - // - // description: - // returns an object that contains several methods summarizing the results of the validation - // - // form: form to be validated - // profile: specifies how the form fields are to be validated - // {trim:Array, uppercase:Array, lowercase:Array, ucfirst:Array, digit:Array, - // required:Array, dependencies:Object, constraints:Object, confirm:Object} - - // Essentially private properties of results object +dojo.validate.check = function (form, profile) { var missing = []; var invalid = []; - - // results object summarizes the validation - var results = { - isSuccessful: function() {return ( !this.hasInvalid() && !this.hasMissing() );}, - hasMissing: function() {return ( missing.length > 0 );}, - getMissing: function() {return missing;}, - isMissing: function(elemname) { - for(var i = 0; i < missing.length; i++){ - if(elemname == missing[i]){ return true; } + var results = {isSuccessful:function () { + return (!this.hasInvalid() && !this.hasMissing()); + }, hasMissing:function () { + return (missing.length > 0); + }, getMissing:function () { + return missing; + }, isMissing:function (elemname) { + for (var i = 0; i < missing.length; i++) { + if (elemname == missing[i]) { + return true; } - return false; - }, - hasInvalid: function() {return ( invalid.length > 0 );}, - getInvalid: function() {return invalid;}, - isInvalid: function(elemname){ - for(var i = 0; i < invalid.length; i++){ - if(elemname == invalid[i]){ return true; } - } - return false; } - }; - - // Filters are applied before fields are validated. - // Trim removes white space at the front and end of the fields. - if(profile.trim instanceof Array){ - for(var i = 0; i < profile.trim.length; i++){ + return false; + }, hasInvalid:function () { + return (invalid.length > 0); + }, getInvalid:function () { + return invalid; + }, isInvalid:function (elemname) { + for (var i = 0; i < invalid.length; i++) { + if (elemname == invalid[i]) { + return true; + } + } + return false; + }}; + if (profile.trim instanceof Array) { + for (var i = 0; i < profile.trim.length; i++) { var elem = form[profile.trim[i]]; - if(elem.type != "text" && elem.type != "textarea" && elem.type != "password"){ continue; } + if (dj_undef("type", elem) || elem.type != "text" && elem.type != "textarea" && elem.type != "password") { + continue; + } elem.value = elem.value.replace(/(^\s*|\s*$)/g, ""); } } - // Convert to uppercase - if(profile.uppercase instanceof Array){ - for(var i = 0; i < profile.uppercase.length; i++){ + if (profile.uppercase instanceof Array) { + for (var i = 0; i < profile.uppercase.length; i++) { var elem = form[profile.uppercase[i]]; - if(elem.type != "text" && elem.type != "textarea" && elem.type != "password"){ continue; } + if (dj_undef("type", elem) || elem.type != "text" && elem.type != "textarea" && elem.type != "password") { + continue; + } elem.value = elem.value.toUpperCase(); } } - // Convert to lowercase - if(profile.lowercase instanceof Array){ - for (var i = 0; i < profile.lowercase.length; i++){ + if (profile.lowercase instanceof Array) { + for (var i = 0; i < profile.lowercase.length; i++) { var elem = form[profile.lowercase[i]]; - if(elem.type != "text" && elem.type != "textarea" && elem.type != "password"){ continue; } + if (dj_undef("type", elem) || elem.type != "text" && elem.type != "textarea" && elem.type != "password") { + continue; + } elem.value = elem.value.toLowerCase(); } } - // Uppercase first letter - if(profile.ucfirst instanceof Array){ - for(var i = 0; i < profile.ucfirst.length; i++){ + if (profile.ucfirst instanceof Array) { + for (var i = 0; i < profile.ucfirst.length; i++) { var elem = form[profile.ucfirst[i]]; - if(elem.type != "text" && elem.type != "textarea" && elem.type != "password"){ continue; } - elem.value = elem.value.replace(/\b\w+\b/g, function(word) { return word.substring(0,1).toUpperCase() + word.substring(1).toLowerCase(); }); + if (dj_undef("type", elem) || elem.type != "text" && elem.type != "textarea" && elem.type != "password") { + continue; + } + elem.value = elem.value.replace(/\b\w+\b/g, function (word) { + return word.substring(0, 1).toUpperCase() + word.substring(1).toLowerCase(); + }); } } - // Remove non digits characters from the input. - if(profile.digit instanceof Array){ - for(var i = 0; i < profile.digit.length; i++){ + if (profile.digit instanceof Array) { + for (var i = 0; i < profile.digit.length; i++) { var elem = form[profile.digit[i]]; - if(elem.type != "text" && elem.type != "textarea" && elem.type != "password"){ continue; } + if (dj_undef("type", elem) || elem.type != "text" && elem.type != "textarea" && elem.type != "password") { + continue; + } elem.value = elem.value.replace(/\D/g, ""); } } - - // See if required input fields have values missing. - if(profile.required instanceof Array){ - for(var i = 0; i < profile.required.length; i++){ - if(!dojo.lang.isString(profile.required[i])){ continue; } - var elem = form[profile.required[i]]; - // Are textbox, textarea, or password fields blank. - if((elem.type == "text" || elem.type == "textarea" || elem.type == "password") && /^\s*$/.test(elem.value)){ - missing[missing.length] = elem.name; - } - // Does drop-down box have option selected. - else if((elem.type == "select-one" || elem.type == "select-multiple") - && (elem.selectedIndex == -1 - || /^\s*$/.test(elem.options[elem.selectedIndex].value))){ - missing[missing.length] = elem.name; - } - // Does radio button group (or check box group) have option checked. - else if(elem instanceof Array){ - var checked = false; - for(var j = 0; j < elem.length; j++){ - if (elem[j].checked) { checked = true; } - } - if(!checked){ - missing[missing.length] = elem[0].name; - } - } - } - } - - // See if checkbox groups and select boxes have x number of required values. - if(profile.required instanceof Array){ - for (var i = 0; i < profile.required.length; i++){ - if(!dojo.lang.isObject(profile.required[i])){ continue; } - var elem, numRequired; - for(var name in profile.required[i]){ - elem = form[name]; - numRequired = profile.required[i][name]; - } - // case 1: elem is a check box group - if(elem instanceof Array){ - var checked = 0; - for(var j = 0; j < elem.length; j++){ - if(elem[j].checked){ checked++; } - } - if(checked < numRequired){ - missing[missing.length] = elem[0].name; - } - } - // case 2: elem is a select box - else if(elem.type == "select-multiple" ){ - var selected = 0; - for(var j = 0; j < elem.options.length; j++){ - if (elem.options[j].selected && !/^\s*$/.test(elem.options[j].value)) { selected++; } - } - if(selected < numRequired){ - missing[missing.length] = elem.name; - } - } - } - } - - // Dependent fields are required when the target field is present (not blank). - // Todo: Support dependent and target fields that are radio button groups, or select drop-down lists. - // Todo: Make the dependency based on a specific value of the target field. - // Todo: allow dependent fields to have several required values, like {checkboxgroup: 3}. - if(dojo.lang.isObject(profile.dependencies) || dojo.lang.isObject(profile.dependancies)){ - if(profile["dependancies"]){ - dojo.deprecated("dojo.validate.check", "profile 'dependancies' is deprecated, please use " - + "'dependencies'", "0.5"); - profile.dependencies=profile.dependancies; - } - // properties of dependencies object are the names of dependent fields to be checked - for(name in profile.dependencies){ - var elem = form[name]; // the dependent element - if(elem.type != "text" && elem.type != "textarea" && elem.type != "password"){ continue; } // limited support - if(/\S+/.test(elem.value)){ continue; } // has a value already - if(results.isMissing(elem.name)){ continue; } // already listed as missing - var target = form[profile.dependencies[name]]; - if(target.type != "text" && target.type != "textarea" && target.type != "password"){ continue; } // limited support - if(/^\s*$/.test(target.value)){ continue; } // skip if blank - missing[missing.length] = elem.name; // ok the dependent field is missing - } - } - - // Find invalid input fields. - if(dojo.lang.isObject(profile.constraints)){ - // constraint properties are the names of fields to bevalidated - for(name in profile.constraints){ - var elem = form[name]; - if( (elem.type != "text")&& - (elem.type != "textarea")&& - (elem.type != "password")){ + if (profile.required instanceof Array) { + for (var i = 0; i < profile.required.length; i++) { + if (!dojo.lang.isString(profile.required[i])) { continue; } - // skip if blank - its optional unless required, in which case it - // is already listed as missing. - if(/^\s*$/.test(elem.value)){ continue; } - - var isValid = true; - // case 1: constraint value is validation function - if(dojo.lang.isFunction(profile.constraints[name])){ - isValid = profile.constraints[name](elem.value); - }else if(dojo.lang.isArray(profile.constraints[name])){ - // handle nested arrays for multiple constraints - if(dojo.lang.isArray(profile.constraints[name][0])){ - for (var i=0; i= 0 || elem.tagName.toLowerCase().indexOf("textarea") >= 0) && /^\s*$/.test(elem.value)) { + continue; + } + var isValid = true; + if (dojo.lang.isFunction(profile.constraints[name])) { + isValid = profile.constraints[name](elem.value); + } else { + if (dojo.lang.isArray(profile.constraints[name])) { + if (dojo.lang.isArray(profile.constraints[name][0])) { + for (var i = 0; i < profile.constraints[name].length; i++) { + isValid = dojo.validate.evaluateConstraint(profile, profile.constraints[name][i], name, elem); + if (!isValid) { + break; + } + } + } else { + isValid = dojo.validate.evaluateConstraint(profile, profile.constraints[name], name, elem); + } + } + } + if (!isValid) { invalid[invalid.length] = elem.name; } } } - - // Find unequal confirm fields and report them as Invalid. - if(dojo.lang.isObject(profile.confirm)){ - for(name in profile.confirm){ - var elem = form[name]; // the confirm element + if (dojo.lang.isObject(profile.confirm)) { + for (name in profile.confirm) { + var elem = form[name]; var target = form[profile.confirm[name]]; - if ( (elem.type != "text" && elem.type != "textarea" && elem.type != "password") - ||(target.type != elem.type) - ||(target.value == elem.value) // it's valid - ||(results.isInvalid(elem.name))// already listed as invalid - ||(/^\s*$/.test(target.value))) // skip if blank - only confirm if target has a value - { - continue; - } + if (dj_undef("type", elem) || dj_undef("type", target) || (elem.type != "text" && elem.type != "textarea" && elem.type != "password") || (target.type != elem.type) || (target.value == elem.value) || (results.isInvalid(elem.name)) || (/^\s*$/.test(target.value))) { + continue; + } invalid[invalid.length] = elem.name; } } - - return results; // Object -} - -//TODO: evaluateConstraint doesn't use profile or fieldName args? -dojo.validate.evaluateConstraint=function(profile, /*Array*/constraint, fieldName, elem){ - // summary: - // Evaluates dojo.validate.check() constraints that are specified as array - // arguments - // - // description: The arrays are expected to be in the format of: - // constraints:{ - // fieldName: [functionToCall, param1, param2, etc.], - // fieldName: [[functionToCallFirst, param1],[functionToCallSecond,param2]] - // } - // - // This function evaluates a single array function in the format of: - // [functionName, argument1, argument2, etc] - // - // The function will be parsed out and evaluated against the incoming parameters. - // - // profile: The dojo.validate.check() profile that this evaluation is against. - // constraint: The single [] array of function and arguments for the function. - // fieldName: The form dom name of the field being validated. - // elem: The form element field. - - var isValidSomething = constraint[0]; + return results; +}; +dojo.validate.evaluateConstraint = function (profile, constraint, fieldName, elem) { + var isValidSomething = constraint[0]; var params = constraint.slice(1); params.unshift(elem.value); - if(typeof isValidSomething != "undefined"){ + if (typeof isValidSomething != "undefined") { return isValidSomething.apply(null, params); } - return false; // Boolean -} + return false; +}; + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/common.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/common.js index df7471e87..2c97f57f4 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/common.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/common.js @@ -9,240 +9,86 @@ */ dojo.provide("dojo.validate.common"); - dojo.require("dojo.regexp"); - - -dojo.validate.isText = function(/*String*/value, /*Object?*/flags){ -// summary: -// Checks if a string has non whitespace characters. -// Parameters allow you to constrain the length. -// -// value: A string -// flags: {length: Number, minlength: Number, maxlength: Number} -// flags.length If set, checks if there are exactly flags.length number of characters. -// flags.minlength If set, checks if there are at least flags.minlength number of characters. -// flags.maxlength If set, checks if there are at most flags.maxlength number of characters. - +dojo.validate.isText = function (value, flags) { flags = (typeof flags == "object") ? flags : {}; - - // test for text - if(/^\s*$/.test(value)){ return false; } // Boolean - - // length tests - if(typeof flags.length == "number" && flags.length != value.length){ return false; } // Boolean - if(typeof flags.minlength == "number" && flags.minlength > value.length){ return false; } // Boolean - if(typeof flags.maxlength == "number" && flags.maxlength < value.length){ return false; } // Boolean - - return true; // Boolean -} - -dojo.validate.isInteger = function(/*String*/value, /*Object?*/flags){ -// summary: -// Validates whether a string is in an integer format -// -// value A string -// flags {signed: Boolean|[true,false], separator: String} -// flags.signed The leading plus-or-minus sign. Can be true, false, or [true, false]. -// Default is [true, false], (i.e. sign is optional). -// flags.separator The character used as the thousands separator. Default is no separator. -// For more than one symbol use an array, e.g. [",", ""], makes ',' optional. - - var re = new RegExp("^" + dojo.regexp.integer(flags) + "$"); - return re.test(value); // Boolean -} - -dojo.validate.isRealNumber = function(/*String*/value, /*Object?*/flags){ -// summary: -// Validates whether a string is a real valued number. -// Format is the usual exponential notation. -// -// value: A string -// flags: {places: Number, decimal: String, exponent: Boolean|[true,false], eSigned: Boolean|[true,false], ...} -// flags.places The integer number of decimal places. -// If not given, the decimal part is optional and the number of places is unlimited. -// flags.decimal The character used for the decimal point. Default is ".". -// flags.exponent Express in exponential notation. Can be true, false, or [true, false]. -// Default is [true, false], (i.e. the exponential part is optional). -// flags.eSigned The leading plus-or-minus sign on the exponent. Can be true, false, -// or [true, false]. Default is [true, false], (i.e. sign is optional). -// flags in regexp.integer can be applied. - - var re = new RegExp("^" + dojo.regexp.realNumber(flags) + "$"); - return re.test(value); // Boolean -} - -dojo.validate.isCurrency = function(/*String*/value, /*Object?*/flags){ -// summary: -// Validates whether a string denotes a monetary value. -// value: A string -// flags: {signed:Boolean|[true,false], symbol:String, placement:String, separator:String, -// fractional:Boolean|[true,false], decimal:String} -// flags.signed The leading plus-or-minus sign. Can be true, false, or [true, false]. -// Default is [true, false], (i.e. sign is optional). -// flags.symbol A currency symbol such as Yen "�", Pound "�", or the Euro sign "�". -// Default is "$". For more than one symbol use an array, e.g. ["$", ""], makes $ optional. -// flags.placement The symbol can come "before" the number or "after". Default is "before". -// flags.separator The character used as the thousands separator. The default is ",". -// flags.fractional The appropriate number of decimal places for fractional currency (e.g. cents) -// Can be true, false, or [true, false]. Default is [true, false], (i.e. cents are optional). -// flags.decimal The character used for the decimal point. Default is ".". - - var re = new RegExp("^" + dojo.regexp.currency(flags) + "$"); - return re.test(value); // Boolean -} - -dojo.validate.isInRange = function(/*String*/value, /*Object?*/flags){ -//summary: -// Validates whether a string denoting an integer, -// real number, or monetary value is between a max and min. -// -// value: A string -// flags: {max:Number, min:Number, decimal:String} -// flags.max A number, which the value must be less than or equal to for the validation to be true. -// flags.min A number, which the value must be greater than or equal to for the validation to be true. -// flags.decimal The character used for the decimal point. Default is ".". - - //stripping the seperator allows NaN to perform as expected, if no separator, we assume ',' - //once i18n support is ready for this, instead of assuming, we default to i18n's recommended value - value = value.replace((dojo.lang.has(flags,'separator'))?flags.separator:',',''); - if(isNaN(value)){ - return false; // Boolean + if (/^\s*$/.test(value)) { + return false; + } + if (typeof flags.length == "number" && flags.length != value.length) { + return false; + } + if (typeof flags.minlength == "number" && flags.minlength > value.length) { + return false; + } + if (typeof flags.maxlength == "number" && flags.maxlength < value.length) { + return false; + } + return true; +}; +dojo.validate.isInteger = function (value, flags) { + var re = new RegExp("^" + dojo.regexp.integer(flags) + "$"); + return re.test(value); +}; +dojo.validate.isRealNumber = function (value, flags) { + var re = new RegExp("^" + dojo.regexp.realNumber(flags) + "$"); + return re.test(value); +}; +dojo.validate.isCurrency = function (value, flags) { + var re = new RegExp("^" + dojo.regexp.currency(flags) + "$"); + return re.test(value); +}; +dojo.validate._isInRangeCache = {}; +dojo.validate.isInRange = function (value, flags) { + value = value.replace(dojo.lang.has(flags, "separator") ? flags.separator : ",", "", "g").replace(dojo.lang.has(flags, "symbol") ? flags.symbol : "$", ""); + if (isNaN(value)) { + return false; } - // assign default values to missing paramters flags = (typeof flags == "object") ? flags : {}; var max = (typeof flags.max == "number") ? flags.max : Infinity; var min = (typeof flags.min == "number") ? flags.min : -Infinity; var dec = (typeof flags.decimal == "string") ? flags.decimal : "."; - - // splice out anything not part of a number + var cache = dojo.validate._isInRangeCache; + var cacheIdx = value + "max" + max + "min" + min + "dec" + dec; + if (typeof cache[cacheIdx] != "undefined") { + return cache[cacheIdx]; + } var pattern = "[^" + dec + "\\deE+-]"; value = value.replace(RegExp(pattern, "g"), ""); - - // trim ends of things like e, E, or the decimal character value = value.replace(/^([+-]?)(\D*)/, "$1"); value = value.replace(/(\D*)$/, ""); - - // replace decimal with ".". The minus sign '-' could be the decimal! pattern = "(\\d)[" + dec + "](\\d)"; value = value.replace(RegExp(pattern, "g"), "$1.$2"); - value = Number(value); - if ( value < min || value > max ) { return false; } // Boolean - - return true; // Boolean -} - -dojo.validate.isNumberFormat = function(/*String*/value, /*Object?*/flags){ -// summary: -// Validates any sort of number based format -// -// description: -// Use it for phone numbers, social security numbers, zip-codes, etc. -// The value can be validated against one format or one of multiple formats. -// -// Format -// # Stands for a digit, 0-9. -// ? Stands for an optional digit, 0-9 or nothing. -// All other characters must appear literally in the expression. -// -// Example -// "(###) ###-####" -> (510) 542-9742 -// "(###) ###-#### x#???" -> (510) 542-9742 x153 -// "###-##-####" -> 506-82-1089 i.e. social security number -// "#####-####" -> 98225-1649 i.e. zip code -// -// value: A string -// flags: {format:String} -// flags.format A string or an Array of strings for multiple formats. - + if (value < min || value > max) { + cache[cacheIdx] = false; + return false; + } + cache[cacheIdx] = true; + return true; +}; +dojo.validate.isNumberFormat = function (value, flags) { var re = new RegExp("^" + dojo.regexp.numberFormat(flags) + "$", "i"); - return re.test(value); // Boolean -} - -dojo.validate.isValidLuhn = function(/*String*/value){ -//summary: Compares value against the Luhn algorithm to verify its integrity + return re.test(value); +}; +dojo.validate.isValidLuhn = function (value) { var sum, parity, curDigit; - if(typeof value!='string'){ + if (typeof value != "string") { value = String(value); } - value = value.replace(/[- ]/g,''); //ignore dashes and whitespaces - parity = value.length%2; - sum=0; - for(var i=0;i9){ - curDigit-=9; + if (curDigit > 9) { + curDigit -= 9; } - sum+=curDigit; + sum += curDigit; } - return !(sum%10); -} + return !(sum % 10); +}; -/** - Procedural API Description - - The main aim is to make input validation expressible in a simple format. - You define profiles which declare the required and optional fields and any constraints they might have. - The results are provided as an object that makes it easy to handle missing and invalid input. - - Usage - - var results = dojo.validate.check(form, profile); - - Profile Object - - var profile = { - // filters change the field value and are applied before validation. - trim: ["tx1", "tx2"], - uppercase: ["tx9"], - lowercase: ["tx5", "tx6", "tx7"], - ucfirst: ["tx10"], - digit: ["tx11"], - - // required input fields that are blank will be reported missing. - // required radio button groups and drop-down lists with no selection will be reported missing. - // checkbox groups and selectboxes can be required to have more than one value selected. - // List required fields by name and use this notation to require more than one value: {checkboxgroup: 2}, {selectboxname: 3}. - required: ["tx7", "tx8", "pw1", "ta1", "rb1", "rb2", "cb3", "s1", {"doubledip":2}, {"tripledip":3}], - - // dependant/conditional fields are required if the target field is present and not blank. - // At present only textbox, password, and textarea fields are supported. - dependencies: { - cc_exp: "cc_no", - cc_type: "cc_no", - }, - - // Fields can be validated using any boolean valued function. - // Use arrays to specify parameters in addition to the field value. - constraints: { - field_name1: myValidationFunction, - field_name2: dojo.validate.isInteger, - field_name3: [myValidationFunction, additional parameters], - field_name4: [dojo.validate.isValidDate, "YYYY.MM.DD"], - field_name5: [dojo.validate.isEmailAddress, false, true], - }, - - // Confirm is a sort of conditional validation. - // It associates each field in its property list with another field whose value should be equal. - // If the values are not equal, the field in the property list is reported as Invalid. Unless the target field is blank. - confirm: { - email_confirm: "email", - pw2: "pw1", - } - }; - - Results Object - - isSuccessful(): Returns true if there were no invalid or missing fields, else it returns false. - hasMissing(): Returns true if the results contain any missing fields. - getMissing(): Returns a list of required fields that have values missing. - isMissing(field): Returns true if the field is required and the value is missing. - hasInvalid(): Returns true if the results contain fields with invalid data. - getInvalid(): Returns a list of fields that have invalid values. - isInvalid(field): Returns true if the field has an invalid value. - -*/ diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/creditCard.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/creditCard.js index 671a06989..4364ca484 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/creditCard.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/creditCard.js @@ -8,83 +8,55 @@ http://dojotoolkit.org/community/licensing.shtml */ -dojo.provide('dojo.validate.creditCard'); - +dojo.provide("dojo.validate.creditCard"); dojo.require("dojo.lang.common"); dojo.require("dojo.validate.common"); - -/* - Validates Credit Cards using account number rules in conjunction with the Luhn algorightm - - */ - -dojo.validate.isValidCreditCard = function(value,ccType){ - //checks if type matches the # scheme, and if Luhn checksum is accurate (unless its an Enroute card, the checkSum is skipped) - if(value&&ccType&&((ccType.toLowerCase()=='er'||dojo.validate.isValidLuhn(value))&&(dojo.validate.isValidCreditCardNumber(value,ccType.toLowerCase())))){ - return true; - } - return false; -} -dojo.validate.isValidCreditCardNumber = function(value,ccType) { - //only checks if the # matches the pattern for that card or any card types if none is specified - //value == CC #, white spaces and dashes are ignored - //ccType is of the values in cardinfo -- if Omitted it it returns a | delimited string of matching card types, or false if no matches found - if(typeof value!='string'){ - value = String(value); - } - value = value.replace(/[- ]/g,''); //ignore dashes and whitespaces - /* FIXME: not sure on all the abbreviations for credit cards,below is what each stands for atleast to my knowledge - mc: Mastercard - ec: Eurocard - vi: Visa - ax: American Express - dc: Diners Club - bl: Carte Blanch - di: Discover - jcb: JCB - er: Enroute - */ - var results=[]; - var cardinfo = { - 'mc':'5[1-5][0-9]{14}','ec':'5[1-5][0-9]{14}','vi':'4([0-9]{12}|[0-9]{15})', - 'ax':'3[47][0-9]{13}', 'dc':'3(0[0-5][0-9]{11}|[68][0-9]{12})', - 'bl':'3(0[0-5][0-9]{11}|[68][0-9]{12})','di':'6011[0-9]{12}', - 'jcb':'(3[0-9]{15}|(2131|1800)[0-9]{11})','er':'2(014|149)[0-9]{11}' - }; - if(ccType&&dojo.lang.has(cardinfo,ccType.toLowerCase())){ - return Boolean(value.match(cardinfo[ccType.toLowerCase()])); // boolean - }else{ - for(var p in cardinfo){ - if(value.match('^'+cardinfo[p]+'$')!=null){ - results.push(p); - } - } - return (results.length)?results.join('|'):false; // string | boolean - } -} - -dojo.validate.isValidCvv = function(value, ccType) { - if(typeof value!='string'){ - value=String(value); - } - var format; - switch (ccType.toLowerCase()){ - case 'mc': - case 'ec': - case 'vi': - case 'di': - format = '###'; - break; - case 'ax': - format = '####'; - break; - default: - return false; - } - var flags = {format:format}; - //FIXME? Why does isNumberFormat take an object for flags when its only parameter is either a string or an array inside the object? - if ((value.length == format.length)&&(dojo.validate.isNumberFormat(value, flags))){ +dojo.validate.isValidCreditCard = function (value, ccType) { + if (value && ccType && ((ccType.toLowerCase() == "er" || dojo.validate.isValidLuhn(value)) && (dojo.validate.isValidCreditCardNumber(value, ccType.toLowerCase())))) { return true; } return false; -} \ No newline at end of file +}; +dojo.validate.isValidCreditCardNumber = function (value, ccType) { + if (typeof value != "string") { + value = String(value); + } + value = value.replace(/[- ]/g, ""); + var results = []; + var cardinfo = {"mc":"5[1-5][0-9]{14}", "ec":"5[1-5][0-9]{14}", "vi":"4([0-9]{12}|[0-9]{15})", "ax":"3[47][0-9]{13}", "dc":"3(0[0-5][0-9]{11}|[68][0-9]{12})", "bl":"3(0[0-5][0-9]{11}|[68][0-9]{12})", "di":"6011[0-9]{12}", "jcb":"(3[0-9]{15}|(2131|1800)[0-9]{11})", "er":"2(014|149)[0-9]{11}"}; + if (ccType && dojo.lang.has(cardinfo, ccType.toLowerCase())) { + return Boolean(value.match(cardinfo[ccType.toLowerCase()])); + } else { + for (var p in cardinfo) { + if (value.match("^" + cardinfo[p] + "$") != null) { + results.push(p); + } + } + return (results.length) ? results.join("|") : false; + } +}; +dojo.validate.isValidCvv = function (value, ccType) { + if (typeof value != "string") { + value = String(value); + } + var format; + switch (ccType.toLowerCase()) { + case "mc": + case "ec": + case "vi": + case "di": + format = "###"; + break; + case "ax": + format = "####"; + break; + default: + return false; + } + var flags = {format:format}; + if ((value.length == format.length) && (dojo.validate.isNumberFormat(value, flags))) { + return true; + } + return false; +}; + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/datetime.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/datetime.js index 1ae9494e1..68e0f5f50 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/datetime.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/datetime.js @@ -10,163 +10,81 @@ dojo.provide("dojo.validate.datetime"); dojo.require("dojo.validate.common"); - -/** - Validates a time value in any International format. - The value can be validated against one format or one of multiple formats. - - Format - h 12 hour, no zero padding. - hh 12 hour, has leading zero. - H 24 hour, no zero padding. - HH 24 hour, has leading zero. - m minutes, no zero padding. - mm minutes, has leading zero. - s seconds, no zero padding. - ss seconds, has leading zero. - All other characters must appear literally in the expression. - - Example - "h:m:s t" -> 2:5:33 PM - "HH:mm:ss" -> 14:05:33 - - @param value A string. - @param flags An object. - flags.format A string or an array of strings. Default is "h:mm:ss t". - flags.amSymbol The symbol used for AM. Default is "AM". - flags.pmSymbol The symbol used for PM. Default is "PM". - @return true or false -*/ -dojo.validate.isValidTime = function(value, flags) { +dojo.validate.isValidTime = function (value, flags) { dojo.deprecated("dojo.validate.datetime", "use dojo.date.parse instead", "0.5"); var re = new RegExp("^" + dojo.regexp.time(flags) + "$", "i"); return re.test(value); -} - -/** - Validates 12-hour time format. - Zero-padding is not allowed for hours, required for minutes and seconds. - Seconds are optional. - - @param value A string. - @return true or false -*/ -dojo.validate.is12HourTime = function(value) { +}; +dojo.validate.is12HourTime = function (value) { dojo.deprecated("dojo.validate.datetime", "use dojo.date.parse instead", "0.5"); - return dojo.validate.isValidTime(value, {format: ["h:mm:ss t", "h:mm t"]}); -} - -/** - Validates 24-hour military time format. - Zero-padding is required for hours, minutes, and seconds. - Seconds are optional. - - @param value A string. - @return true or false -*/ -dojo.validate.is24HourTime = function(value) { + return dojo.validate.isValidTime(value, {format:["h:mm:ss t", "h:mm t"]}); +}; +dojo.validate.is24HourTime = function (value) { dojo.deprecated("dojo.validate.datetime", "use dojo.date.parse instead", "0.5"); - return dojo.validate.isValidTime(value, {format: ["HH:mm:ss", "HH:mm"]} ); -} - -/** - Returns true if the date conforms to the format given and is a valid date. Otherwise returns false. - - @param dateValue A string for the date. - @param format A string, default is "MM/DD/YYYY". - @return true or false - - Accepts any type of format, including ISO8601. - All characters in the format string are treated literally except the following tokens: - - YYYY - matches a 4 digit year - M - matches a non zero-padded month - MM - matches a zero-padded month - D - matches a non zero-padded date - DD - matches a zero-padded date - DDD - matches an ordinal date, 001-365, and 366 on leapyear - ww - matches week of year, 01-53 - d - matches day of week, 1-7 - - Examples: These are all today's date. - - Date Format - 2005-W42-3 YYYY-Www-d - 2005-292 YYYY-DDD - 20051019 YYYYMMDD - 10/19/2005 M/D/YYYY - 19.10.2005 D.M.YYYY -*/ -dojo.validate.isValidDate = function(dateValue, format) { + return dojo.validate.isValidTime(value, {format:["HH:mm:ss", "HH:mm"]}); +}; +dojo.validate.isValidDate = function (dateValue, format) { dojo.deprecated("dojo.validate.datetime", "use dojo.date.parse instead", "0.5"); - // Default is the American format - if (typeof format == "object" && typeof format.format == "string"){ format = format.format; } - if (typeof format != "string") { format = "MM/DD/YYYY"; } - - // Create a literal regular expression based on format + if (typeof format == "object" && typeof format.format == "string") { + format = format.format; + } + if (typeof format != "string") { + format = "MM/DD/YYYY"; + } var reLiteral = format.replace(/([$^.*+?=!:|\/\\\(\)\[\]\{\}])/g, "\\$1"); - - // Convert all the tokens to RE elements - reLiteral = reLiteral.replace( "YYYY", "([0-9]{4})" ); - reLiteral = reLiteral.replace( "MM", "(0[1-9]|10|11|12)" ); - reLiteral = reLiteral.replace( "M", "([1-9]|10|11|12)" ); - reLiteral = reLiteral.replace( "DDD", "(00[1-9]|0[1-9][0-9]|[12][0-9][0-9]|3[0-5][0-9]|36[0-6])" ); - reLiteral = reLiteral.replace( "DD", "(0[1-9]|[12][0-9]|30|31)" ); - reLiteral = reLiteral.replace( "D", "([1-9]|[12][0-9]|30|31)" ); - reLiteral = reLiteral.replace( "ww", "(0[1-9]|[1-4][0-9]|5[0-3])" ); - reLiteral = reLiteral.replace( "d", "([1-7])" ); - - // Anchor pattern to begining and end of string + reLiteral = reLiteral.replace("YYYY", "([0-9]{4})"); + reLiteral = reLiteral.replace("MM", "(0[1-9]|10|11|12)"); + reLiteral = reLiteral.replace("M", "([1-9]|10|11|12)"); + reLiteral = reLiteral.replace("DDD", "(00[1-9]|0[1-9][0-9]|[12][0-9][0-9]|3[0-5][0-9]|36[0-6])"); + reLiteral = reLiteral.replace("DD", "(0[1-9]|[12][0-9]|30|31)"); + reLiteral = reLiteral.replace("D", "([1-9]|[12][0-9]|30|31)"); + reLiteral = reLiteral.replace("ww", "(0[1-9]|[1-4][0-9]|5[0-3])"); + reLiteral = reLiteral.replace("d", "([1-7])"); reLiteral = "^" + reLiteral + "$"; - - // Dynamic RE that parses the original format given var re = new RegExp(reLiteral); - - // Test if date is in a valid format - if (!re.test(dateValue)) return false; - - // Parse date to get elements and check if date is valid - // Assume valid values for date elements not given. + if (!re.test(dateValue)) { + return false; + } var year = 0, month = 1, date = 1, dayofyear = 1, week = 1, day = 1; - - // Capture tokens - var tokens = format.match( /(YYYY|MM|M|DDD|DD|D|ww|d)/g ); - - // Capture date values + var tokens = format.match(/(YYYY|MM|M|DDD|DD|D|ww|d)/g); var values = re.exec(dateValue); - - // Match up tokens with date values for (var i = 0; i < tokens.length; i++) { switch (tokens[i]) { - case "YYYY": - year = Number(values[i+1]); break; - case "M": - case "MM": - month = Number(values[i+1]); break; - case "D": - case "DD": - date = Number(values[i+1]); break; - case "DDD": - dayofyear = Number(values[i+1]); break; - case "ww": - week = Number(values[i+1]); break; - case "d": - day = Number(values[i+1]); break; + case "YYYY": + year = Number(values[i + 1]); + break; + case "M": + case "MM": + month = Number(values[i + 1]); + break; + case "D": + case "DD": + date = Number(values[i + 1]); + break; + case "DDD": + dayofyear = Number(values[i + 1]); + break; + case "ww": + week = Number(values[i + 1]); + break; + case "d": + day = Number(values[i + 1]); + break; } } - - // Leap years are divisible by 4, but not by 100, unless by 400 var leapyear = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); - - // 31st of a month with 30 days - if (date == 31 && (month == 4 || month == 6 || month == 9 || month == 11)) return false; - - // February 30th or 31st - if (date >= 30 && month == 2) return false; - - // February 29th outside a leap year - if (date == 29 && month == 2 && !leapyear) return false; - if (dayofyear == 366 && !leapyear) return false; - + if (date == 31 && (month == 4 || month == 6 || month == 9 || month == 11)) { + return false; + } + if (date >= 30 && month == 2) { + return false; + } + if (date == 29 && month == 2 && !leapyear) { + return false; + } + if (dayofyear == 366 && !leapyear) { + return false; + } return true; -} +}; + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/de.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/de.js index 43be273b2..886220588 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/de.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/de.js @@ -10,17 +10,8 @@ dojo.provide("dojo.validate.de"); dojo.require("dojo.validate.common"); - -dojo.validate.isGermanCurrency = function(/*String*/value) { - //summary: checks to see if 'value' is a valid representation of German currency (Euros) - var flags = { - symbol: "\u20AC", - placement: "after", - signPlacement: "begin", //TODO: this is really locale-dependent. Will get fixed in v0.5 currency rewrite. - decimal: ",", - separator: "." - }; - return dojo.validate.isCurrency(value, flags); // Boolean -} - +dojo.validate.isGermanCurrency = function (value) { + var flags = {symbol:"\u20ac", placement:"after", signPlacement:"begin", decimal:",", separator:"."}; + return dojo.validate.isCurrency(value, flags); +}; diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/jp.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/jp.js index a46fc45f4..bfd970493 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/jp.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/jp.js @@ -10,14 +10,8 @@ dojo.provide("dojo.validate.jp"); dojo.require("dojo.validate.common"); - -dojo.validate.isJapaneseCurrency = function(/*String*/value) { - //summary: checks to see if 'value' is a valid representation of Japanese currency - var flags = { - symbol: "\u00a5", - fractional: false - }; - return dojo.validate.isCurrency(value, flags); // Boolean -} - +dojo.validate.isJapaneseCurrency = function (value) { + var flags = {symbol:"\xa5", fractional:false}; + return dojo.validate.isCurrency(value, flags); +}; diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/us.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/us.js index 09f5b3c69..cb727a179 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/us.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/us.js @@ -10,75 +10,23 @@ dojo.provide("dojo.validate.us"); dojo.require("dojo.validate.common"); - -dojo.validate.us.isCurrency = function(/*String*/value, /*Object?*/flags){ - // summary: Validates U.S. currency - // value: the representation to check - // flags: flags in validate.isCurrency can be applied. - return dojo.validate.isCurrency(value, flags); // Boolean -} - - -dojo.validate.us.isState = function(/*String*/value, /*Object?*/flags){ - // summary: Validates US state and territory abbreviations. - // - // value: A two character string - // flags: An object - // flags.allowTerritories Allow Guam, Puerto Rico, etc. Default is true. - // flags.allowMilitary Allow military 'states', e.g. Armed Forces Europe (AE). Default is true. - +dojo.validate.us.isCurrency = function (value, flags) { + return dojo.validate.isCurrency(value, flags); +}; +dojo.validate.us.isState = function (value, flags) { var re = new RegExp("^" + dojo.regexp.us.state(flags) + "$", "i"); - return re.test(value); // Boolean -} + return re.test(value); +}; +dojo.validate.us.isPhoneNumber = function (value) { + var flags = {format:["###-###-####", "(###) ###-####", "(###) ### ####", "###.###.####", "###/###-####", "### ### ####", "###-###-#### x#???", "(###) ###-#### x#???", "(###) ### #### x#???", "###.###.#### x#???", "###/###-#### x#???", "### ### #### x#???", "##########"]}; + return dojo.validate.isNumberFormat(value, flags); +}; +dojo.validate.us.isSocialSecurityNumber = function (value) { + var flags = {format:["###-##-####", "### ## ####", "#########"]}; + return dojo.validate.isNumberFormat(value, flags); +}; +dojo.validate.us.isZipCode = function (value) { + var flags = {format:["#####-####", "##### ####", "#########", "#####"]}; + return dojo.validate.isNumberFormat(value, flags); +}; -dojo.validate.us.isPhoneNumber = function(/*String*/value){ - // summary: Validates 10 US digit phone number for several common formats - // value: The telephone number string - - var flags = { - format: [ - "###-###-####", - "(###) ###-####", - "(###) ### ####", - "###.###.####", - "###/###-####", - "### ### ####", - "###-###-#### x#???", - "(###) ###-#### x#???", - "(###) ### #### x#???", - "###.###.#### x#???", - "###/###-#### x#???", - "### ### #### x#???", - "##########" - ] - }; - - return dojo.validate.isNumberFormat(value, flags); // Boolean -} - -dojo.validate.us.isSocialSecurityNumber = function(/*String*/value){ -// summary: Validates social security number - var flags = { - format: [ - "###-##-####", - "### ## ####", - "#########" - ] - }; - - return dojo.validate.isNumberFormat(value, flags); // Boolean -} - -dojo.validate.us.isZipCode = function(/*String*/value){ -// summary: Validates U.S. zip-code - var flags = { - format: [ - "#####-####", - "##### ####", - "#########", - "#####" - ] - }; - - return dojo.validate.isNumberFormat(value, flags); // Boolean -} diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/web.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/web.js index f6f2a9c35..c7339fbca 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/web.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/validate/web.js @@ -10,86 +10,32 @@ dojo.provide("dojo.validate.web"); dojo.require("dojo.validate.common"); - -dojo.validate.isIpAddress = function(/*String*/value, /*Object?*/flags) { - // summary: Validates an IP address - // - // description: - // Supports 5 formats for IPv4: dotted decimal, dotted hex, dotted octal, decimal and hexadecimal. - // Supports 2 formats for Ipv6. - // - // value A string. - // flags An object. All flags are boolean with default = true. - // flags.allowDottedDecimal Example, 207.142.131.235. No zero padding. - // flags.allowDottedHex Example, 0x18.0x11.0x9b.0x28. Case insensitive. Zero padding allowed. - // flags.allowDottedOctal Example, 0030.0021.0233.0050. Zero padding allowed. - // flags.allowDecimal Example, 3482223595. A decimal number between 0-4294967295. - // flags.allowHex Example, 0xCF8E83EB. Hexadecimal number between 0x0-0xFFFFFFFF. - // Case insensitive. Zero padding allowed. - // flags.allowIPv6 IPv6 address written as eight groups of four hexadecimal digits. - // flags.allowHybrid IPv6 address written as six groups of four hexadecimal digits - // followed by the usual 4 dotted decimal digit notation of IPv4. x:x:x:x:x:x:d.d.d.d - +dojo.validate.isIpAddress = function (value, flags) { var re = new RegExp("^" + dojo.regexp.ipAddress(flags) + "$", "i"); - return re.test(value); // Boolean -} - - -dojo.validate.isUrl = function(/*String*/value, /*Object?*/flags) { - // summary: Checks if a string could be a valid URL - // value: A string - // flags: An object - // flags.scheme Can be true, false, or [true, false]. - // This means: required, not allowed, or either. - // flags in regexp.host can be applied. - // flags in regexp.ipAddress can be applied. - // flags in regexp.tld can be applied. - + return re.test(value); +}; +dojo.validate.isUrl = function (value, flags) { var re = new RegExp("^" + dojo.regexp.url(flags) + "$", "i"); - return re.test(value); // Boolean -} - -dojo.validate.isEmailAddress = function(/*String*/value, /*Object?*/flags) { - // summary: Checks if a string could be a valid email address - // - // value: A string - // flags: An object - // flags.allowCruft Allow address like . Default is false. - // flags in regexp.host can be applied. - // flags in regexp.ipAddress can be applied. - // flags in regexp.tld can be applied. - + return re.test(value); +}; +dojo.validate.isEmailAddress = function (value, flags) { var re = new RegExp("^" + dojo.regexp.emailAddress(flags) + "$", "i"); - return re.test(value); // Boolean -} - -dojo.validate.isEmailAddressList = function(/*String*/value, /*Object?*/flags) { - // summary: Checks if a string could be a valid email address list. - // - // value A string. - // flags An object. - // flags.listSeparator The character used to separate email addresses. Default is ";", ",", "\n" or " ". - // flags in regexp.emailAddress can be applied. - // flags in regexp.host can be applied. - // flags in regexp.ipAddress can be applied. - // flags in regexp.tld can be applied. - + return re.test(value); +}; +dojo.validate.isEmailAddressList = function (value, flags) { var re = new RegExp("^" + dojo.regexp.emailAddressList(flags) + "$", "i"); - return re.test(value); // Boolean -} - -dojo.validate.getEmailAddressList = function(/*String*/value, /*Object?*/flags) { - // summary: Check if value is an email address list. If an empty list - // is returned, the value didn't pass the test or it was empty. - // - // value: A string - // flags: An object (same as dojo.validate.isEmailAddressList) - - if(!flags) { flags = {}; } - if(!flags.listSeparator) { flags.listSeparator = "\\s;,"; } - - if ( dojo.validate.isEmailAddressList(value, flags) ) { - return value.split(new RegExp("\\s*[" + flags.listSeparator + "]\\s*")); // Array + return re.test(value); +}; +dojo.validate.getEmailAddressList = function (value, flags) { + if (!flags) { + flags = {}; } - return []; // Array -} + if (!flags.listSeparator) { + flags.listSeparator = "\\s;,"; + } + if (dojo.validate.isEmailAddressList(value, flags)) { + return value.split(new RegExp("\\s*[" + flags.listSeparator + "]\\s*")); + } + return []; +}; + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/AccordionContainer.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/AccordionContainer.js index d4ac5cd7c..f5fa27f54 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/AccordionContainer.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/AccordionContainer.js @@ -9,271 +9,118 @@ */ dojo.provide("dojo.widget.AccordionContainer"); - dojo.require("dojo.widget.*"); dojo.require("dojo.html.*"); dojo.require("dojo.lfx.html"); dojo.require("dojo.html.selection"); dojo.require("dojo.widget.html.layout"); dojo.require("dojo.widget.PageContainer"); - - -/** - *summary - * Holds a set of panes where every pane's title is visible, but only one pane's content is visible at a time, - * and switching between panes is visualized by sliding the other panes up/down. - * - * description - * Front view (3 panes, pane #2 open) - * ------------------------ - * |:::Pane#1 title::: | - * |:::Pane#2 title::: | - * | | - * | pane#2 contents | - * | | - * |:::Pane#3 title::: | - * ------------------------ - * - * Side view (showing implementation): - * - * viewport pane#3 pane#2 pane#1 - * = - * | = - * | = | - * front | | | - * | | = - * | = - * | = - * = | - * | - * = - * - * Panes are stacked by z-index like a stack of cards, so they can be slid correctly. - * The panes on the bottom extend past the bottom of the viewport (but are hidden). - * - * usage - *
- *
...
- * ... - *
- * - * TODO: - * * this widget should extend PageContainer - * * call child.onShow(), child.onHide() so you can attach to those methods if you want - */ - dojo.widget.defineWidget( - "dojo.widget.AccordionContainer", - dojo.widget.HtmlWidget, - { - isContainer: true, - - // String - // CSS class name for dom node w/the title - labelNodeClass: "label", - - // String - // CSS class name for dom node holding the content - containerNodeClass: "accBody", - - // Integer - // Amount of time (in ms) it takes to slide panes - duration: 250, - - fillInTemplate: function(){ - with(this.domNode.style){ - // position must be either relative or absolute - if(position!="absolute"){ - position="relative"; - } - overflow="hidden"; - } - }, - - addChild: function(/*Widget*/ widget){ - var child = this._addChild(widget); - this._setSizes(); - return child; // Widget - }, - - _addChild: function(/*Widget*/ widget){ - // summary - // Internal call to add child, used during postCreate() and by the real addChild() call - if(widget.open){ - dojo.deprecated("open parameter deprecated, use 'selected=true' instead will be removed in ", "0.5"); - dojo.debug(widget.widgetId + ": open == " + widget.open); - widget.selected=true; - } - if (widget.widgetType != "AccordionPane") { - var wrapper=dojo.widget.createWidget("AccordionPane",{label: widget.label, selected: widget.selected, labelNodeClass: this.labelNodeClass, containerNodeClass: this.containerNodeClass, allowCollapse: this.allowCollapse }); - wrapper.addChild(widget); - this.addWidgetAsDirectChild(wrapper); - this.registerChild(wrapper, this.children.length); - return wrapper; // Widget +dojo.widget.defineWidget("dojo.widget.AccordionContainer", dojo.widget.HtmlWidget, {isContainer:true, labelNodeClass:"label", containerNodeClass:"accBody", duration:250, fillInTemplate:function () { + with (this.domNode.style) { + if (position != "absolute") { + position = "relative"; + } + overflow = "hidden"; + } +}, addChild:function (widget) { + var child = this._addChild(widget); + this._setSizes(); + return child; +}, _addChild:function (widget) { + if (widget.open) { + dojo.deprecated("open parameter deprecated, use 'selected=true' instead will be removed in ", "0.5"); + dojo.debug(widget.widgetId + ": open == " + widget.open); + widget.selected = true; + } + if (widget.widgetType != "AccordionPane") { + var wrapper = dojo.widget.createWidget("AccordionPane", {label:widget.label, selected:widget.selected, labelNodeClass:this.labelNodeClass, containerNodeClass:this.containerNodeClass, allowCollapse:this.allowCollapse}); + wrapper.addChild(widget); + this.addWidgetAsDirectChild(wrapper); + this.registerChild(wrapper, this.children.length); + return wrapper; + } else { + dojo.html.addClass(widget.containerNode, this.containerNodeClass); + dojo.html.addClass(widget.labelNode, this.labelNodeClass); + this.addWidgetAsDirectChild(widget); + this.registerChild(widget, this.children.length); + return widget; + } +}, postCreate:function () { + var tmpChildren = this.children; + this.children = []; + dojo.html.removeChildren(this.domNode); + dojo.lang.forEach(tmpChildren, dojo.lang.hitch(this, "_addChild")); + this._setSizes(); +}, removeChild:function (widget) { + dojo.widget.AccordionContainer.superclass.removeChild.call(this, widget); + this._setSizes(); +}, onResized:function () { + this._setSizes(); +}, _setSizes:function () { + var totalCollapsedHeight = 0; + var openIdx = 0; + dojo.lang.forEach(this.children, function (child, idx) { + totalCollapsedHeight += child.getLabelHeight(); + if (child.selected) { + openIdx = idx; + } + }); + var mySize = dojo.html.getContentBox(this.domNode); + var y = 0; + dojo.lang.forEach(this.children, function (child, idx) { + var childCollapsedHeight = child.getLabelHeight(); + child.resizeTo(mySize.width, mySize.height - totalCollapsedHeight + childCollapsedHeight); + child.domNode.style.zIndex = idx + 1; + child.domNode.style.position = "absolute"; + child.domNode.style.top = y + "px"; + y += (idx == openIdx) ? dojo.html.getBorderBox(child.domNode).height : childCollapsedHeight; + }); +}, selectChild:function (page) { + dojo.lang.forEach(this.children, function (child) { + child.setSelected(child == page); + }); + var y = 0; + var anims = []; + dojo.lang.forEach(this.children, function (child, idx) { + if (child.domNode.style.top != (y + "px")) { + anims.push(dojo.lfx.html.slideTo(child.domNode, {top:y, left:0}, this.duration)); + } + y += child.selected ? dojo.html.getBorderBox(child.domNode).height : child.getLabelHeight(); + }, this); + dojo.lfx.combine(anims).play(); +}}); +dojo.widget.defineWidget("dojo.widget.AccordionPane", dojo.widget.HtmlWidget, {label:"", "class":"dojoAccordionPane", labelNodeClass:"label", containerNodeClass:"accBody", selected:false, templateString:"
\n
${this.label}
\n
\n
\n", templateCssString:".dojoAccordionPane .label {\n\tcolor: #000;\n\tfont-weight: bold;\n\tbackground: url(\"images/soriaAccordionOff.gif\") repeat-x top left #85aeec;\n\tborder:1px solid #d9d9d9;\n\tfont-size:0.9em;\n}\n\n.dojoAccordionPane-selected .label {\n\tbackground: url(\"images/soriaAccordionSelected.gif\") repeat-x top left #85aeec;\n\tborder:1px solid #84a3d1;\n}\n\n.dojoAccordionPane .label:hover {\n\tcursor: pointer;\n}\n\n.dojoAccordionPane .accBody {\n\tbackground: #fff;\n\toverflow: auto;\n\tborder:1px solid #84a3d1;\n}\n", templateCssPath:dojo.uri.moduleUri("dojo.widget", "templates/AccordionPane.css"), isContainer:true, fillInTemplate:function () { + dojo.html.addClass(this.domNode, this["class"]); + dojo.widget.AccordionPane.superclass.fillInTemplate.call(this); + dojo.html.disableSelection(this.labelNode); + this.setSelected(this.selected); +}, setLabel:function (label) { + this.labelNode.innerHTML = label; +}, resizeTo:function (width, height) { + dojo.html.setMarginBox(this.domNode, {width:width, height:height}); + var children = [{domNode:this.labelNode, layoutAlign:"top"}, {domNode:this.containerNode, layoutAlign:"client"}]; + dojo.widget.html.layout(this.domNode, children); + var childSize = dojo.html.getContentBox(this.containerNode); + this.children[0].resizeTo(childSize.width, childSize.height); +}, getLabelHeight:function () { + return dojo.html.getMarginBox(this.labelNode).height; +}, onLabelClick:function () { + this.parent.selectChild(this); +}, setSelected:function (isSelected) { + this.selected = isSelected; + (isSelected ? dojo.html.addClass : dojo.html.removeClass)(this.domNode, this["class"] + "-selected"); + var child = this.children[0]; + if (child) { + if (isSelected) { + if (!child.isShowing()) { + child.show(); } else { - dojo.html.addClass(widget.containerNode, this.containerNodeClass); - dojo.html.addClass(widget.labelNode, this.labelNodeClass); - this.addWidgetAsDirectChild(widget); - this.registerChild(widget, this.children.length); - return widget; // Widget + child.onShow(); } - }, - - postCreate: function() { - var tmpChildren = this.children; - this.children=[]; - dojo.html.removeChildren(this.domNode); - dojo.lang.forEach(tmpChildren, dojo.lang.hitch(this,"_addChild")); - this._setSizes(); - }, - - removeChild: function(/*Widget*/ widget) { - dojo.widget.AccordionContainer.superclass.removeChild.call(this, widget); - this._setSizes(); - }, - - onResized: function(){ - this._setSizes(); - }, - - _setSizes: function() { - // summary - // Set panes' size/position based on my size, and the current open node. - - // get cumulative height of all the title bars, and figure out which pane is open - var totalCollapsedHeight = 0; - var openIdx = 0; - dojo.lang.forEach(this.children, function(child, idx){ - totalCollapsedHeight += child.getLabelHeight(); - if(child.selected){ openIdx=idx; } - }); - - // size and position each pane - var mySize=dojo.html.getContentBox(this.domNode); - var y = 0; - dojo.lang.forEach(this.children, function(child, idx){ - var childCollapsedHeight = child.getLabelHeight(); - child.resizeTo(mySize.width, mySize.height-totalCollapsedHeight+childCollapsedHeight); - child.domNode.style.zIndex=idx+1; - child.domNode.style.position="absolute"; - child.domNode.style.top = y+"px"; - y += (idx==openIdx) ? dojo.html.getBorderBox(child.domNode).height : childCollapsedHeight; - }); - }, - - selectChild: function(/*Widget*/ page){ - // summary - // close the current page and select a new one - dojo.lang.forEach(this.children, function(child){child.setSelected(child==page);}); - - // slide each pane that needs to be moved - var y = 0; - var anims = []; - dojo.lang.forEach(this.children, function(child, idx){ - if(child.domNode.style.top != (y+"px")){ - anims.push(dojo.lfx.html.slideTo(child.domNode, {top: y, left: 0}, this.duration)); - } - y += child.selected ? dojo.html.getBorderBox(child.domNode).height : child.getLabelHeight(); - }); - dojo.lfx.combine(anims).play(); + } else { + child.onHide(); } } -); +}}); +dojo.lang.extend(dojo.widget.Widget, {open:false}); -/** - * summary - * AccordionPane is a box with a title that contains another widget (often a ContentPane). - * It's a widget used internally by AccordionContainer. - */ -dojo.widget.defineWidget( - "dojo.widget.AccordionPane", - dojo.widget.HtmlWidget, -{ - // parameters - - // String - // label to print on top of AccordionPane - label: "", - - // String - // CSS class name for the AccordionPane's dom node - "class": "dojoAccordionPane", - - // String - // CSS class name for the AccordionPane's label node - labelNodeClass: "label", - - // String - // CSS class name for the AccordionPane's container node - containerNodeClass: "accBody", - - // Boolean - // if true, this is the open pane - selected: false, - - templatePath: dojo.uri.dojoUri("src/widget/templates/AccordionPane.html"), - templateCssPath: dojo.uri.dojoUri("src/widget/templates/AccordionPane.css"), - - isContainer: true, - - fillInTemplate: function() { - dojo.html.addClass(this.domNode, this["class"]); - dojo.widget.AccordionPane.superclass.fillInTemplate.call(this); - dojo.html.disableSelection(this.labelNode); - this.setSelected(this.selected); - }, - - setLabel: function(/*String*/ label) { - // summary: set the title of the node - this.labelNode.innerHTML=label; - }, - - resizeTo: function(width, height){ - dojo.html.setMarginBox(this.domNode, {width: width, height: height}); - var children = [ - {domNode: this.labelNode, layoutAlign: "top"}, - {domNode: this.containerNode, layoutAlign: "client"} - ]; - dojo.widget.html.layout(this.domNode, children); - var childSize = dojo.html.getContentBox(this.containerNode); - this.children[0].resizeTo(childSize.width, childSize.height); - }, - - getLabelHeight: function() { - // summary: returns the height of the title dom node - return dojo.html.getMarginBox(this.labelNode).height; // Integer - }, - - onLabelClick: function() { - // summary: callback when someone clicks my label - this.parent.selectChild(this); - }, - - setSelected: function(/*Boolean*/ isSelected){ - this.selected=isSelected; - (isSelected ? dojo.html.addClass : dojo.html.removeClass)(this.domNode, this["class"]+"-selected"); - - // make sure child is showing (lazy load), and also that onShow()/onHide() is called - var child = this.children[0]; - if(child){ - if(isSelected){ - if(!child.isShowing()){ - child.show(); - }else{ - child.onShow(); - } - }else{ - child.onHide(); - } - } - } -}); - -// These arguments can be specified for the children of an AccordionContainer -// Since any widget can be specified as a child, mix them -// into the base widget class. (This is a hack, but it's effective.) -dojo.lang.extend(dojo.widget.Widget, { - // String - // is this the selected child? - // DEPRECATED: will be removed in 0.5. Used "selected" attribute instead. - open: false -}); diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/AnimatedPng.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/AnimatedPng.js index 24d114c7f..9ed8ad4d3 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/AnimatedPng.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/AnimatedPng.js @@ -9,90 +9,37 @@ */ dojo.provide("dojo.widget.AnimatedPng"); - dojo.require("dojo.widget.*"); dojo.require("dojo.widget.HtmlWidget"); - -// summary -// PNGs have great tranparency, but lack animation. -// This widget lets you point an img tag at an animated gif for graceful degrading, -// while letting you specify a png containing a grid of cells to animate between. -// -// usage -// -// -// var params = {src: "images/animatedpng_static.gif", aniSrc: "images/animatedpng_frames.gif", width: 20, height: 20, interval: 50}; -// var widget = dojo.widget.createWidget("AnimatedPng", params, document.getElementById("pngContainer")); -// -dojo.widget.defineWidget( - "dojo.widget.AnimatedPng", - dojo.widget.HtmlWidget, - { - isContainer: false, - - // Integer - // width (of each frame) in pixels - width: 0, - - // Integer - // height (of each frame) in pixels - height: 0, - - // String - // pathname to png file containing frames to be animated (ie, displayed sequentially) - aniSrc: '', - - // Integer - // time to display each frame - interval: 100, - - _blankSrc: dojo.uri.dojoUri("src/widget/templates/images/blank.gif"), - - templateString: '', - - postCreate: function(){ - this.cellWidth = this.width; - this.cellHeight = this.height; - - var img = new Image(); - var self = this; - - img.onload = function(){ self._initAni(img.width, img.height); }; - img.src = this.aniSrc; - }, - - _initAni: function(w, h){ - this.domNode.src = this._blankSrc; - this.domNode.width = this.cellWidth; - this.domNode.height = this.cellHeight; - this.domNode.style.backgroundImage = 'url('+this.aniSrc+')'; - this.domNode.style.backgroundRepeat = 'no-repeat'; - - this.aniCols = Math.floor(w/this.cellWidth); - this.aniRows = Math.floor(h/this.cellHeight); - this.aniCells = this.aniCols * this.aniRows; - this.aniFrame = 0; - - window.setInterval(dojo.lang.hitch(this, '_tick'), this.interval); - }, - - _tick: function(){ - this.aniFrame++; - if (this.aniFrame == this.aniCells) this.aniFrame = 0; - - var col = this.aniFrame % this.aniCols; - var row = Math.floor(this.aniFrame / this.aniCols); - - var bx = -1 * col * this.cellWidth; - var by = -1 * row * this.cellHeight; - - this.domNode.style.backgroundPosition = bx+'px '+by+'px'; - } +dojo.widget.defineWidget("dojo.widget.AnimatedPng", dojo.widget.HtmlWidget, {isContainer:false, width:0, height:0, aniSrc:"", interval:100, _blankSrc:dojo.uri.moduleUri("dojo.widget", "templates/images/blank.gif"), templateString:"", postCreate:function () { + this.cellWidth = this.width; + this.cellHeight = this.height; + var img = new Image(); + var self = this; + img.onload = function () { + self._initAni(img.width, img.height); + }; + img.src = this.aniSrc; +}, _initAni:function (w, h) { + this.domNode.src = this._blankSrc; + this.domNode.width = this.cellWidth; + this.domNode.height = this.cellHeight; + this.domNode.style.backgroundImage = "url(" + this.aniSrc + ")"; + this.domNode.style.backgroundRepeat = "no-repeat"; + this.aniCols = Math.floor(w / this.cellWidth); + this.aniRows = Math.floor(h / this.cellHeight); + this.aniCells = this.aniCols * this.aniRows; + this.aniFrame = 0; + window.setInterval(dojo.lang.hitch(this, "_tick"), this.interval); +}, _tick:function () { + this.aniFrame++; + if (this.aniFrame == this.aniCells) { + this.aniFrame = 0; } -); + var col = this.aniFrame % this.aniCols; + var row = Math.floor(this.aniFrame / this.aniCols); + var bx = -1 * col * this.cellWidth; + var by = -1 * row * this.cellHeight; + this.domNode.style.backgroundPosition = bx + "px " + by + "px"; +}}); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/Button.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/Button.js index ce07dd6e2..faf65c3cd 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/Button.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/Button.js @@ -9,424 +9,249 @@ */ dojo.provide("dojo.widget.Button"); - dojo.require("dojo.lang.extras"); dojo.require("dojo.html.*"); dojo.require("dojo.html.selection"); dojo.require("dojo.widget.*"); - -/* - * summary - * Basically the same thing as a normal HTML button, but with special styling. - * usage - * - * - * var button1 = dojo.widget.createWidget("Button", {caption: "hello world", onClick: foo}); - * document.body.appendChild(button1.domNode); - */ -dojo.widget.defineWidget( - "dojo.widget.Button", - dojo.widget.HtmlWidget, - { - isContainer: true, - - // String - // text to display in button - caption: "", - - // Boolean - // if true, cannot click button - disabled: false, - - templatePath: dojo.uri.dojoUri("src/widget/templates/ButtonTemplate.html"), - templateCssPath: dojo.uri.dojoUri("src/widget/templates/ButtonTemplate.css"), - - // Url - // prefix of filename holding images (left, center, right) for button in normal state - inactiveImg: "src/widget/templates/images/soriaButton-", - - // Url - // prefix of filename holding images (left, center, right) for button when it's being hovered over - activeImg: "src/widget/templates/images/soriaActive-", - - // Url - // prefix of filename holding images (left, center, right) for button between mouse-down and mouse-up - pressedImg: "src/widget/templates/images/soriaPressed-", - - // Url - // prefix of filename holding images (left, center, right) for button when it's disabled (aka, grayed-out) - disabledImg: "src/widget/templates/images/soriaDisabled-", - - // Number - // shape of the button's end pieces; - // the height of the end pieces is a function of the button's height (which in turn is a function of the button's content), - // and then the width of the end pieces is relative to their height. - width2height: 1.0/3.0, - - fillInTemplate: function(){ - if(this.caption){ - this.containerNode.appendChild(document.createTextNode(this.caption)); - } - dojo.html.disableSelection(this.containerNode); - }, - - postCreate: function(){ - this._sizeMyself(); - }, - - _sizeMyself: function(){ - // we cannot size correctly if any of our ancestors are hidden (display:none), - // so temporarily attach to document.body - if(this.domNode.parentNode){ - var placeHolder = document.createElement("span"); - dojo.html.insertBefore(placeHolder, this.domNode); - } - dojo.body().appendChild(this.domNode); - - this._sizeMyselfHelper(); - - // Put this.domNode back where it was originally - if(placeHolder){ - dojo.html.insertBefore(this.domNode, placeHolder); - dojo.html.removeNode(placeHolder); - } - }, - - _sizeMyselfHelper: function(){ - var mb = dojo.html.getMarginBox(this.containerNode); - this.height = mb.height; - this.containerWidth = mb.width; - var endWidth= this.height * this.width2height; - - this.containerNode.style.left=endWidth+"px"; - - this.leftImage.height = this.rightImage.height = this.centerImage.height = this.height; - this.leftImage.width = this.rightImage.width = endWidth+1; - this.centerImage.width = this.containerWidth; - this.centerImage.style.left=endWidth+"px"; - this._setImage(this.disabled ? this.disabledImg : this.inactiveImg); - - if ( this.disabled ) { - dojo.html.prependClass(this.domNode, "dojoButtonDisabled"); - this.domNode.removeAttribute("tabIndex"); - dojo.widget.wai.setAttr(this.domNode, "waiState", "disabled", true); - } else { - dojo.html.removeClass(this.domNode, "dojoButtonDisabled"); - this.domNode.setAttribute("tabIndex", "0"); - dojo.widget.wai.setAttr(this.domNode, "waiState", "disabled", false); - } - - this.domNode.style.height=this.height + "px"; - this.domNode.style.width= (this.containerWidth+2*endWidth) + "px"; - }, - - onMouseOver: function(/*Event*/ e){ - // summary: callback when user mouses-over the button - if( this.disabled ){ return; } - dojo.html.prependClass(this.buttonNode, "dojoButtonHover"); - this._setImage(this.activeImg); - }, - - onMouseDown: function(/*Event*/ e){ - // summary: callback when user starts to click the button - if( this.disabled ){ return; } - dojo.html.prependClass(this.buttonNode, "dojoButtonDepressed"); - dojo.html.removeClass(this.buttonNode, "dojoButtonHover"); - this._setImage(this.pressedImg); - }, - - onMouseUp: function(/*Event*/ e){ - // summary: callback when the user finishes clicking - if( this.disabled ){ return; } - dojo.html.prependClass(this.buttonNode, "dojoButtonHover"); - dojo.html.removeClass(this.buttonNode, "dojoButtonDepressed"); - this._setImage(this.activeImg); - }, - - onMouseOut: function(/*Event*/ e){ - // summary: callback when the user moves the mouse off the button - if( this.disabled ){ return; } - if( e.toElement && dojo.html.isDescendantOf(e.toElement, this.buttonNode) ){ - return; // Ignore IE mouseOut events that dont actually leave button - Prevents hover image flicker in IE - } - dojo.html.removeClass(this.buttonNode, "dojoButtonHover"); - this._setImage(this.inactiveImg); - }, - - onKey: function(/*Event*/ e){ - // summary: callback when the user presses a key (on key-down) - if (!e.key) { return; } - var menu = dojo.widget.getWidgetById(this.menuId); - if (e.key == e.KEY_ENTER || e.key == " "){ - this.onMouseDown(e); - this.buttonClick(e); - dojo.lang.setTimeout(this, "onMouseUp", 75, e); - dojo.event.browser.stopEvent(e); - } - if(menu && menu.isShowingNow && e.key == e.KEY_DOWN_ARROW){ - // disconnect onBlur when focus moves into menu +dojo.widget.defineWidget("dojo.widget.Button", dojo.widget.HtmlWidget, {isContainer:true, caption:"", templateString:"
\n
\n \n \n \n
\n", templateCssString:"/* ---- button --- */\n.dojoButton {\n\tpadding: 0 0 0 0;\n\tfont-size: 8pt;\n\twhite-space: nowrap;\n\tcursor: pointer;\n\tfont-family: Myriad, Tahoma, Verdana, sans-serif;\n}\n\n.dojoButton .dojoButtonContents {\n\tpadding: 2px 2px 2px 2px;\n\ttext-align: center;\t\t/* if icon and label are split across two lines, center icon */\n\tcolor: white;\n}\n\n.dojoButtonLeftPart .dojoButtonContents {\n\tpadding-right: 8px;\n}\n\n.dojoButtonDisabled {\n\tcursor: url(\"images/no.gif\"), default;\n}\n\n\n.dojoButtonContents img {\n\tvertical-align: middle;\t/* if icon and label are on same line, center them */\n}\n\n/* -------- colors ------------ */\n\n.dojoButtonHover .dojoButtonContents {\n}\n\n.dojoButtonDepressed .dojoButtonContents {\n\tcolor: #293a4b;\n}\n\n.dojoButtonDisabled .dojoButtonContents {\n\tcolor: #aaa;\n}\n\n\n/* ---------- drop down button specific ---------- */\n\n/* border between label and arrow (for drop down buttons */\n.dojoButton .border {\n\twidth: 1px;\n\tbackground: gray;\n}\n\n/* button arrow */\n.dojoButton .downArrow {\n\tpadding-left: 10px;\n\ttext-align: center;\n}\n\n.dojoButton.disabled .downArrow {\n\tcursor : default;\n}\n", templateCssPath:dojo.uri.moduleUri("dojo.widget", "templates/ButtonTemplate.css"), inactiveImg:"templates/images/soriaButton-", activeImg:"templates/images/soriaActive-", pressedImg:"templates/images/soriaPressed-", disabledImg:"templates/images/soriaDisabled-", width2height:1 / 3, fillInTemplate:function () { + if (this.caption) { + this.containerNode.appendChild(document.createTextNode(this.caption)); + } + dojo.html.disableSelection(this.containerNode); +}, postCreate:function () { + this._sizeMyself(); +}, _sizeMyself:function () { + if (this.domNode.parentNode) { + var placeHolder = document.createElement("span"); + dojo.html.insertBefore(placeHolder, this.domNode); + } + dojo.body().appendChild(this.domNode); + this._sizeMyselfHelper(); + if (placeHolder) { + dojo.html.insertBefore(this.domNode, placeHolder); + dojo.html.removeNode(placeHolder); + } +}, _sizeMyselfHelper:function () { + var mb = dojo.html.getMarginBox(this.containerNode); + this.height = mb.height; + this.containerWidth = mb.width; + var endWidth = this.height * this.width2height; + this.containerNode.style.left = endWidth + "px"; + this.leftImage.height = this.rightImage.height = this.centerImage.height = this.height; + this.leftImage.width = this.rightImage.width = endWidth + 1; + this.centerImage.width = this.containerWidth; + this.centerImage.style.left = endWidth + "px"; + this._setImage(this.disabled ? this.disabledImg : this.inactiveImg); + if (this.disabled) { + dojo.html.prependClass(this.domNode, "dojoButtonDisabled"); + this.domNode.removeAttribute("tabIndex"); + dojo.widget.wai.setAttr(this.domNode, "waiState", "disabled", true); + } else { + dojo.html.removeClass(this.domNode, "dojoButtonDisabled"); + this.domNode.setAttribute("tabIndex", "0"); + dojo.widget.wai.setAttr(this.domNode, "waiState", "disabled", false); + } + this.domNode.style.height = this.height + "px"; + this.domNode.style.width = (this.containerWidth + 2 * endWidth) + "px"; +}, onMouseOver:function (e) { + if (this.disabled) { + return; + } + if (!dojo.html.hasClass(this.buttonNode, "dojoButtonHover")) { + dojo.html.prependClass(this.buttonNode, "dojoButtonHover"); + } + this._setImage(this.activeImg); +}, onMouseDown:function (e) { + if (this.disabled) { + return; + } + dojo.html.prependClass(this.buttonNode, "dojoButtonDepressed"); + dojo.html.removeClass(this.buttonNode, "dojoButtonHover"); + this._setImage(this.pressedImg); +}, onMouseUp:function (e) { + if (this.disabled) { + return; + } + dojo.html.prependClass(this.buttonNode, "dojoButtonHover"); + dojo.html.removeClass(this.buttonNode, "dojoButtonDepressed"); + this._setImage(this.activeImg); +}, onMouseOut:function (e) { + if (this.disabled) { + return; + } + if (e.toElement && dojo.html.isDescendantOf(e.toElement, this.buttonNode)) { + return; + } + dojo.html.removeClass(this.buttonNode, "dojoButtonHover"); + dojo.html.removeClass(this.buttonNode, "dojoButtonDepressed"); + this._setImage(this.inactiveImg); +}, onKey:function (e) { + if (!e.key) { + return; + } + var menu = dojo.widget.getWidgetById(this.menuId); + if (e.key == e.KEY_ENTER || e.key == " ") { + this.onMouseDown(e); + this.buttonClick(e); + dojo.lang.setTimeout(this, "onMouseUp", 75, e); + dojo.event.browser.stopEvent(e); + } + if (menu && menu.isShowingNow && e.key == e.KEY_DOWN_ARROW) { + dojo.event.disconnect(this.domNode, "onblur", this, "onBlur"); + } +}, onFocus:function (e) { + var menu = dojo.widget.getWidgetById(this.menuId); + if (menu) { + dojo.event.connectOnce(this.domNode, "onblur", this, "onBlur"); + } +}, onBlur:function (e) { + var menu = dojo.widget.getWidgetById(this.menuId); + if (!menu) { + return; + } + if (menu.close && menu.isShowingNow) { + menu.close(); + } +}, buttonClick:function (e) { + if (!this.disabled) { + try { + this.domNode.focus(); + } + catch (e2) { + } + this.onClick(e); + } +}, onClick:function (e) { +}, _setImage:function (prefix) { + this.leftImage.src = dojo.uri.moduleUri("dojo.widget", prefix + "l.gif"); + this.centerImage.src = dojo.uri.moduleUri("dojo.widget", prefix + "c.gif"); + this.rightImage.src = dojo.uri.moduleUri("dojo.widget", prefix + "r.gif"); +}, _toggleMenu:function (menuId) { + var menu = dojo.widget.getWidgetById(menuId); + if (!menu) { + return; + } + if (menu.open && !menu.isShowingNow) { + var pos = dojo.html.getAbsolutePosition(this.domNode, false); + menu.open(pos.x, pos.y + this.height, this); + dojo.event.disconnect(this.domNode, "onblur", this, "onBlur"); + } else { + if (menu.close && menu.isShowingNow) { + menu.close(); + } else { + menu.toggle(); + } + } +}, setCaption:function (content) { + this.caption = content; + this.containerNode.innerHTML = content; + this._sizeMyself(); +}, setDisabled:function (disabled) { + this.disabled = disabled; + this._sizeMyself(); +}}); +dojo.widget.defineWidget("dojo.widget.DropDownButton", dojo.widget.Button, {menuId:"", downArrow:"templates/images/whiteDownArrow.gif", disabledDownArrow:"templates/images/whiteDownArrow.gif", fillInTemplate:function () { + dojo.widget.DropDownButton.superclass.fillInTemplate.apply(this, arguments); + this.arrow = document.createElement("img"); + dojo.html.setClass(this.arrow, "downArrow"); + dojo.widget.wai.setAttr(this.domNode, "waiState", "haspopup", this.menuId); +}, _sizeMyselfHelper:function () { + this.arrow.src = dojo.uri.moduleUri("dojo.widget", this.disabled ? this.disabledDownArrow : this.downArrow); + this.containerNode.appendChild(this.arrow); + dojo.widget.DropDownButton.superclass._sizeMyselfHelper.call(this); +}, onClick:function (e) { + this._toggleMenu(this.menuId); +}}); +dojo.widget.defineWidget("dojo.widget.ComboButton", dojo.widget.Button, {menuId:"", templateString:"
\n\n\t
\n\t\t
\n\t\t\n\t\t\n\t
\n\n\t
\n\t\t\n\t\t\n\t\t\n\t
\n\n
\n", splitWidth:2, arrowWidth:5, _sizeMyselfHelper:function (e) { + var mb = dojo.html.getMarginBox(this.containerNode); + this.height = mb.height; + this.containerWidth = mb.width; + var endWidth = this.height / 3; + if (this.disabled) { + dojo.widget.wai.setAttr(this.domNode, "waiState", "disabled", true); + this.domNode.removeAttribute("tabIndex"); + } else { + dojo.widget.wai.setAttr(this.domNode, "waiState", "disabled", false); + this.domNode.setAttribute("tabIndex", "0"); + } + this.leftImage.height = this.rightImage.height = this.centerImage.height = this.arrowBackgroundImage.height = this.height; + this.leftImage.width = endWidth + 1; + this.centerImage.width = this.containerWidth; + this.buttonNode.style.height = this.height + "px"; + this.buttonNode.style.width = endWidth + this.containerWidth + "px"; + this._setImage(this.disabled ? this.disabledImg : this.inactiveImg); + this.arrowBackgroundImage.width = this.arrowWidth; + this.rightImage.width = endWidth + 1; + this.rightPart.style.height = this.height + "px"; + this.rightPart.style.width = this.arrowWidth + endWidth + "px"; + this._setImageR(this.disabled ? this.disabledImg : this.inactiveImg); + this.domNode.style.height = this.height + "px"; + var totalWidth = this.containerWidth + this.splitWidth + this.arrowWidth + 2 * endWidth; + this.domNode.style.width = totalWidth + "px"; +}, _setImage:function (prefix) { + this.leftImage.src = dojo.uri.moduleUri("dojo.widget", prefix + "l.gif"); + this.centerImage.src = dojo.uri.moduleUri("dojo.widget", prefix + "c.gif"); +}, rightOver:function (e) { + if (this.disabled) { + return; + } + dojo.html.prependClass(this.rightPart, "dojoButtonHover"); + this._setImageR(this.activeImg); +}, rightDown:function (e) { + if (this.disabled) { + return; + } + dojo.html.prependClass(this.rightPart, "dojoButtonDepressed"); + dojo.html.removeClass(this.rightPart, "dojoButtonHover"); + this._setImageR(this.pressedImg); +}, rightUp:function (e) { + if (this.disabled) { + return; + } + dojo.html.prependClass(this.rightPart, "dojoButtonHover"); + dojo.html.removeClass(this.rightPart, "dojoButtonDepressed"); + this._setImageR(this.activeImg); +}, rightOut:function (e) { + if (this.disabled) { + return; + } + dojo.html.removeClass(this.rightPart, "dojoButtonHover"); + dojo.html.removeClass(this.rightPart, "dojoButtonDepressed"); + this._setImageR(this.inactiveImg); +}, rightClick:function (e) { + if (this.disabled) { + return; + } + try { + this.domNode.focus(); + } + catch (e2) { + } + this._toggleMenu(this.menuId); +}, _setImageR:function (prefix) { + this.arrowBackgroundImage.src = dojo.uri.moduleUri("dojo.widget", prefix + "c.gif"); + this.rightImage.src = dojo.uri.moduleUri("dojo.widget", prefix + "r.gif"); +}, onKey:function (e) { + if (!e.key) { + return; + } + var menu = dojo.widget.getWidgetById(this.menuId); + if (e.key == e.KEY_ENTER || e.key == " ") { + this.onMouseDown(e); + this.buttonClick(e); + dojo.lang.setTimeout(this, "onMouseUp", 75, e); + dojo.event.browser.stopEvent(e); + } else { + if (e.key == e.KEY_DOWN_ARROW && e.altKey) { + this.rightDown(e); + this.rightClick(e); + dojo.lang.setTimeout(this, "rightUp", 75, e); + dojo.event.browser.stopEvent(e); + } else { + if (menu && menu.isShowingNow && e.key == e.KEY_DOWN_ARROW) { dojo.event.disconnect(this.domNode, "onblur", this, "onBlur"); - // allow event to propagate to menu - } - }, - - onFocus: function(/*Event*/ e){ - // summary: callback on focus to the button - var menu = dojo.widget.getWidgetById(this.menuId); - if (menu){ - dojo.event.connectOnce(this.domNode, "onblur", this, "onBlur"); - } - }, - - onBlur: function(/*Event*/ e){ - // summary: callback when button loses focus - var menu = dojo.widget.getWidgetById(this.menuId); - if ( !menu ) { return; } - - if ( menu.close && menu.isShowingNow ){ - menu.close(); - } - }, - - buttonClick: function(/*Event*/ e){ - // summary: internal function for handling button clicks - if(!this.disabled){ - // focus may fail when tabIndex is not supported on div's - // by the browser, or when the node is disabled - try { this.domNode.focus(); } catch(e2) {}; - this.onClick(e); - } - }, - - onClick: function(/*Event*/ e) { - // summary: callback for when button is clicked; user can override this function - }, - - _setImage: function(/*String*/ prefix){ - this.leftImage.src=dojo.uri.dojoUri(prefix + "l.gif"); - this.centerImage.src=dojo.uri.dojoUri(prefix + "c.gif"); - this.rightImage.src=dojo.uri.dojoUri(prefix + "r.gif"); - }, - - _toggleMenu: function(/*String*/ menuId){ - var menu = dojo.widget.getWidgetById(menuId); - if ( !menu ) { return; } - if ( menu.open && !menu.isShowingNow) { - var pos = dojo.html.getAbsolutePosition(this.domNode, false); - menu.open(pos.x, pos.y+this.height, this); - } else if ( menu.close && menu.isShowingNow ){ - menu.close(); - } else { - menu.toggle(); - } - }, - - setCaption: function(/*String*/ content){ - // summary: reset the caption (text) of the button; takes an HTML string - this.caption=content; - this.containerNode.innerHTML=content; - this._sizeMyself(); - }, - - setDisabled: function(/*Boolean*/ disabled){ - // summary: set disabled state of button - this.disabled=disabled; - this._sizeMyself(); - } - }); - -/* - * summary - * push the button and a menu shows up - * usage - * - * - * var button1 = dojo.widget.createWidget("DropDownButton", {caption: "hello world", menuId: foo}); - * document.body.appendChild(button1.domNode); - */ -dojo.widget.defineWidget( - "dojo.widget.DropDownButton", - dojo.widget.Button, - { - // String - // widget id of the menu that this button should activate - menuId: "", - - // Url - // path of arrow image to display to the right of the button text - downArrow: "src/widget/templates/images/whiteDownArrow.gif", - - // Url - // path of arrow image to display to the right of the button text, when the button is disabled - disabledDownArrow: "src/widget/templates/images/whiteDownArrow.gif", - - fillInTemplate: function(){ - dojo.widget.DropDownButton.superclass.fillInTemplate.apply(this, arguments); - - this.arrow = document.createElement("img"); - dojo.html.setClass(this.arrow, "downArrow"); - - dojo.widget.wai.setAttr(this.domNode, "waiState", "haspopup", this.menuId); - }, - - _sizeMyselfHelper: function(){ - // draw the arrow (todo: why is the arror in containerNode rather than outside it?) - this.arrow.src = dojo.uri.dojoUri(this.disabled ? this.disabledDownArrow : this.downArrow); - this.containerNode.appendChild(this.arrow); - - dojo.widget.DropDownButton.superclass._sizeMyselfHelper.call(this); - }, - - onClick: function(/*Event*/ e){ - // summary: callback when button is clicked; user shouldn't override this function or else the menu won't toggle - this._toggleMenu(this.menuId); - } - }); - -/* - * summary - * left side is normal button, right side displays menu - * usage - * - * - * var button1 = dojo.widget.createWidget("DropDownButton", {caption: "hello world", onClick: foo, menuId: "myMenu"}); - * document.body.appendChild(button1.domNode); - */ -dojo.widget.defineWidget( - "dojo.widget.ComboButton", - dojo.widget.Button, - { - // String - // widget id of the menu that this button should activate - menuId: "", - - templatePath: dojo.uri.dojoUri("src/widget/templates/ComboButtonTemplate.html"), - - // Integer - // # of pixels between left & right part of button - splitWidth: 2, - - // Integer - // width of segment holding down arrow - arrowWidth: 5, - - _sizeMyselfHelper: function(/*Event*/ e){ - var mb = dojo.html.getMarginBox(this.containerNode); - this.height = mb.height; - this.containerWidth = mb.width; - - var endWidth= this.height/3; - - if(this.disabled){ - dojo.widget.wai.setAttr(this.domNode, "waiState", "disabled", true); - this.domNode.removeAttribute("tabIndex"); - } - else { - dojo.widget.wai.setAttr(this.domNode, "waiState", "disabled", false); - this.domNode.setAttribute("tabIndex", "0"); - } - - // left part - this.leftImage.height = this.rightImage.height = this.centerImage.height = - this.arrowBackgroundImage.height = this.height; - this.leftImage.width = endWidth+1; - this.centerImage.width = this.containerWidth; - this.buttonNode.style.height = this.height + "px"; - this.buttonNode.style.width = endWidth + this.containerWidth + "px"; - this._setImage(this.disabled ? this.disabledImg : this.inactiveImg); - - // right part - this.arrowBackgroundImage.width=this.arrowWidth; - this.rightImage.width = endWidth+1; - this.rightPart.style.height = this.height + "px"; - this.rightPart.style.width = this.arrowWidth + endWidth + "px"; - this._setImageR(this.disabled ? this.disabledImg : this.inactiveImg); - - // outer container - this.domNode.style.height=this.height + "px"; - var totalWidth = this.containerWidth+this.splitWidth+this.arrowWidth+2*endWidth; - this.domNode.style.width= totalWidth + "px"; - }, - - _setImage: function(prefix){ - this.leftImage.src=dojo.uri.dojoUri(prefix + "l.gif"); - this.centerImage.src=dojo.uri.dojoUri(prefix + "c.gif"); - }, - - /*** functions on right part of button ***/ - rightOver: function(/*Event*/ e){ - // summary: - // callback when mouse-over right part of button; - // onMouseOver() is the callback for the left side of the button. - if( this.disabled ){ return; } - dojo.html.prependClass(this.rightPart, "dojoButtonHover"); - this._setImageR(this.activeImg); - }, - - rightDown: function(/*Event*/ e){ - // summary: - // callback when mouse-down right part of button; - // onMouseDown() is the callback for the left side of the button. - if( this.disabled ){ return; } - dojo.html.prependClass(this.rightPart, "dojoButtonDepressed"); - dojo.html.removeClass(this.rightPart, "dojoButtonHover"); - this._setImageR(this.pressedImg); - }, - - rightUp: function(/*Event*/ e){ - // summary: - // callback when mouse-up right part of button; - // onMouseUp() is the callback for the left side of the button. - if( this.disabled ){ return; } - dojo.html.prependClass(this.rightPart, "dojoButtonHover"); - dojo.html.removeClass(this.rightPart, "dojoButtonDepressed"); - this._setImageR(this.activeImg); - }, - - rightOut: function(/*Event*/ e){ - // summary: - // callback when moving the mouse off of the right part of button; - // onMouseOut() is the callback for the left side of the button. - if( this.disabled ){ return; } - dojo.html.removeClass(this.rightPart, "dojoButtonHover"); - this._setImageR(this.inactiveImg); - }, - - rightClick: function(/*Event*/ e){ - // summary: - // callback when clicking the right part of button; - // onClick() is the callback for the left side of the button. - if( this.disabled ){ return; } - // focus may fail when tabIndex is not supported on div's - // by the browser, or when the node is disabled - try { this.domNode.focus(); } catch(e2) {}; - this._toggleMenu(this.menuId); - }, - - _setImageR: function(prefix){ - this.arrowBackgroundImage.src=dojo.uri.dojoUri(prefix + "c.gif"); - this.rightImage.src=dojo.uri.dojoUri(prefix + "r.gif"); - }, - - /*** keyboard functions ***/ - - onKey: function(/*Event*/ e){ - if (!e.key) { return; } - var menu = dojo.widget.getWidgetById(this.menuId); - if(e.key== e.KEY_ENTER || e.key == " "){ - this.onMouseDown(e); - this.buttonClick(e); - dojo.lang.setTimeout(this, "onMouseUp", 75, e); - dojo.event.browser.stopEvent(e); - } else if (e.key == e.KEY_DOWN_ARROW && e.altKey){ - this.rightDown(e); - this.rightClick(e); - dojo.lang.setTimeout(this, "rightUp", 75, e); - dojo.event.browser.stopEvent(e); - } else if(menu && menu.isShowingNow && e.key == e.KEY_DOWN_ARROW){ - // disconnect onBlur when focus moves into menu - dojo.event.disconnect(this.domNode, "onblur", this, "onBlur"); - // allow event to propagate to menu } } - }); + } +}}); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/Chart.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/Chart.js index 824304509..2236bc10b 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/Chart.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/Chart.js @@ -9,249 +9,223 @@ */ dojo.provide("dojo.widget.Chart"); - dojo.require("dojo.widget.*"); dojo.require("dojo.gfx.color"); dojo.require("dojo.gfx.color.hsl"); - -// Base class for svg and vml implementations of Chart -dojo.declare( - "dojo.widget.Chart", - null, - function(){ - this.series = []; - }, -{ - isContainer: false, - - assignColors: function(){ - // summary - // Assigns/generates a color for a data series. - var hue=30; - var sat=120; - var lum=120; - var steps = Math.round(330/this.series.length); - - for(var i=0; i<..> - - // assume column 0 == X - for (var i=1; i=range.start; i--){ - var n = parseFloat(this.values[i].value); - if(!isNaN(n)){ t += n; c++; } - } - t /= Math.max(c,1); - return t; - }, - - getMovingAverage: function(len){ - var range = this.createRange(len); - if(range.index<0){ return 0; } - var t = 0; - var c = 0; - for(var i=range.index; i>=range.start; i--){ - var n = parseFloat(this.values[i].value); - if(!isNaN(n)){ t += n; c++; } - } - t /= Math.max(c,1); - return t; - }, - - getVariance: function(len){ - var range = this.createRange(len); - if(range.index < 0){ return 0; } - var t = 0; // FIXME: for tom: wtf are t, c, and s? - var s = 0; - var c = 0; - for(var i=range.index; i>=range.start; i--){ - var n = parseFloat(this.values[i].value); - if(!isNaN(n)){ - t += n; - s += Math.pow(n,2); - c++; - } - } - return (s/c)-Math.pow(t/c,2); - }, - - getStandardDeviation: function(len){ - return Math.sqrt(this.getVariance(len)); - }, - - getMax: function(len){ - var range = this.createRange(len); - if(range.index < 0){ return 0; } - var t = 0; - for (var i=range.index; i>=range.start; i--){ - var n=parseFloat(this.values[i].value); - if (!isNaN(n)){ - t=Math.max(n,t); - } - } - return t; - }, - - getMin: function(len){ - var range=this.createRange(len); - if(range.index < 0){ return 0; } - var t = 0; - for(var i=range.index; i>=range.start; i--){ - var n = parseFloat(this.values[i].value); - if(!isNaN(n)){ - t=Math.min(n,t); - } - } - return t; - }, - - getMedian: function(len){ - var range = this.createRange(len); - - if(range.index<0){ return 0; } - - var a = []; - for (var i=range.index; i>=range.start; i--){ - var n=parseFloat(this.values[i].value); - if (!isNaN(n)){ - var b=false; - for(var j=0; j0){ return a[Math.ceil(a.length/2)]; } + return {x:{min:xMin, max:xMax}, y:{min:yMin, max:yMax}}; +}}); +dojo.declare("dojo.widget.Chart.DataSeries", null, function (key, label, plotType, color) { + this.id = "DataSeries" + dojo.widget.Chart.DataSeries.count++; + this.key = key; + this.label = label || this.id; + this.plotType = plotType || "line"; + this.color = color; + this.values = []; +}, {add:function (v) { + if (v.x == null || v.value == null) { + dojo.raise("dojo.widget.Chart.DataSeries.add: v must have both an 'x' and 'value' property."); + } + this.values.push(v); +}, clear:function () { + this.values = []; +}, createRange:function (len) { + var idx = this.values.length - 1; + var length = (len || this.values.length); + return {"index":idx, "length":length, "start":Math.max(idx - length, 0)}; +}, getMean:function (len) { + var range = this.createRange(len); + if (range.index < 0) { return 0; - }, - - getMode: function(len){ - var range=this.createRange(len); - if(range.index<0){ return 0; } - var o = {}; - var ret = 0 - var m = 0; - for(var i=range.index; i>=range.start; i--){ - var n=parseFloat(this.values[i].value); - if(!isNaN(n)){ - if (!o[this.values[i].value]) o[this.values[i].value] = 1; - else o[this.values[i].value]++; + } + var t = 0; + var c = 0; + for (var i = range.index; i >= range.start; i--) { + var n = parseFloat(this.values[i].value); + if (!isNaN(n)) { + t += n; + c++; + } + } + t /= Math.max(c, 1); + return t; +}, getMovingAverage:function (len) { + var range = this.createRange(len); + if (range.index < 0) { + return 0; + } + var t = 0; + var c = 0; + for (var i = range.index; i >= range.start; i--) { + var n = parseFloat(this.values[i].value); + if (!isNaN(n)) { + t += n; + c++; + } + } + t /= Math.max(c, 1); + return t; +}, getVariance:function (len) { + var range = this.createRange(len); + if (range.index < 0) { + return 0; + } + var t = 0; + var s = 0; + var c = 0; + for (var i = range.index; i >= range.start; i--) { + var n = parseFloat(this.values[i].value); + if (!isNaN(n)) { + t += n; + s += Math.pow(n, 2); + c++; + } + } + return (s / c) - Math.pow(t / c, 2); +}, getStandardDeviation:function (len) { + return Math.sqrt(this.getVariance(len)); +}, getMax:function (len) { + var range = this.createRange(len); + if (range.index < 0) { + return 0; + } + var t = 0; + for (var i = range.index; i >= range.start; i--) { + var n = parseFloat(this.values[i].value); + if (!isNaN(n)) { + t = Math.max(n, t); + } + } + return t; +}, getMin:function (len) { + var range = this.createRange(len); + if (range.index < 0) { + return 0; + } + var t = 0; + for (var i = range.index; i >= range.start; i--) { + var n = parseFloat(this.values[i].value); + if (!isNaN(n)) { + t = Math.min(n, t); + } + } + return t; +}, getMedian:function (len) { + var range = this.createRange(len); + if (range.index < 0) { + return 0; + } + var a = []; + for (var i = range.index; i >= range.start; i--) { + var n = parseFloat(this.values[i].value); + if (!isNaN(n)) { + var b = false; + for (var j = 0; j < a.length && !b; j++) { + if (n == a[j]) { + b = true; + } + } + if (!b) { + a.push(n); } } - for(var p in o){ - if(m 0) { + return a[Math.ceil(a.length / 2)]; + } + return 0; +}, getMode:function (len) { + var range = this.createRange(len); + if (range.index < 0) { + return 0; + } + var o = {}; + var ret = 0; + var m = 0; + for (var i = range.index; i >= range.start; i--) { + var n = parseFloat(this.values[i].value); + if (!isNaN(n)) { + if (!o[this.values[i].value]) { + o[this.values[i].value] = 1; + } else { + o[this.values[i].value]++; + } + } + } + for (var p in o) { + if (m < o[p]) { + m = o[p]; + ret = p; + } + } + return parseFloat(ret); +}}); +dojo.requireIf(dojo.render.svg.capable, "dojo.widget.svg.Chart"); +dojo.requireIf(!dojo.render.svg.capable && dojo.render.vml.capable, "dojo.widget.vml.Chart"); -dojo["requireIf"](dojo.render.svg.capable, "dojo.widget.svg.Chart"); -dojo["requireIf"](!dojo.render.svg.capable && dojo.render.vml.capable, "dojo.widget.vml.Chart"); diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/Checkbox.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/Checkbox.js index c467341ef..176935cb1 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/Checkbox.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/Checkbox.js @@ -9,174 +9,93 @@ */ dojo.provide("dojo.widget.Checkbox"); - dojo.require("dojo.widget.*"); dojo.require("dojo.widget.HtmlWidget"); dojo.require("dojo.event.*"); dojo.require("dojo.html.style"); dojo.require("dojo.html.selection"); - -// summary -// Same as an HTML checkbox, but with fancy styling -dojo.widget.defineWidget( - "dojo.widget.Checkbox", - dojo.widget.HtmlWidget, - { - templatePath: dojo.uri.dojoUri('src/widget/templates/Checkbox.html'), - templateCssPath: dojo.uri.dojoUri('src/widget/templates/Checkbox.css'), - - // Boolean - // if true, clicking will not change the state of the checkbox. - // in markup, this is specified as "disabled='disabled'", or just "disabled", - disabled: false, - - // String - // name used when submitting form; same as "name" attribute or plain HTML elements - name: "", - - // String - // id attached to the checkbox, used when submitting form - id: "", - - // Boolean - // if true, checkbox is initially marked turned on; - // in markup, specified as "checked='checked'" or just "checked" - checked: false, - - // Integer - // order fields are traversed when user hits the tab key - tabIndex: "", - - // Value - // equivalent to value field on normal checkbox (if checked, the value is passed as - // the value when form is submitted) - value: "on", - - postMixInProperties: function(){ - dojo.widget.Checkbox.superclass.postMixInProperties.apply(this, arguments); - - // set tabIndex="0" because if tabIndex=="" user won't be able to tab to the field - if(!this.disabled && this.tabIndex==""){ this.tabIndex="0"; } - }, - - fillInTemplate: function(){ - this._setInfo(); - }, - - postCreate: function(){ - // find any associated label and create a labelled-by relationship - // assumes rather than - // - var notcon = true; - this.id = this.id !="" ? this.id : this.widgetId; - if(this.id != ""){ - var labels = document.getElementsByTagName("label"); - if (labels != null && labels.length > 0){ - for(var i=0; i\n\t\"\"\n\t\n\n", templateCssString:".dojoHtmlCheckbox {\n\tborder: 0px;\n\twidth: 16px;\n\theight: 16px;\n\tmargin: 2px;\n\tvertical-align: middle;\n}\n\n.dojoHtmlCheckboxOn {\n\tbackground: url(check.gif) 0px 0px;\n}\n.dojoHtmlCheckboxOff {\n\tbackground: url(check.gif) -16px 0px;\n}\n.dojoHtmlCheckboxDisabledOn {\n\tbackground: url(check.gif) -32px 0px;\n}\n.dojoHtmlCheckboxDisabledOff {\n\tbackground: url(check.gif) -48px 0px;\n}\n.dojoHtmlCheckboxOnHover {\n\tbackground: url(check.gif) -64px 0px;\n}\n.dojoHtmlCheckboxOffHover {\n\tbackground: url(check.gif) -80px 0px;\n}\n", templateCssPath:dojo.uri.moduleUri("dojo.widget", "templates/Checkbox.css"), name:"", id:"", checked:false, tabIndex:"", value:"on", postMixInProperties:function () { + dojo.widget.Checkbox.superclass.postMixInProperties.apply(this, arguments); + if (!this.disabled && this.tabIndex == "") { + this.tabIndex = "0"; + } +}, fillInTemplate:function () { + this._setInfo(); +}, postCreate:function () { + var notcon = true; + this.id = this.id != "" ? this.id : this.widgetId; + if (this.id != "") { + var labels = document.getElementsByTagName("label"); + if (labels != null && labels.length > 0) { + for (var i = 0; i < labels.length; i++) { + if (labels[i].htmlFor == this.id) { + labels[i].id = (labels[i].htmlFor + "label"); + this._connectEvents(labels[i]); + dojo.widget.wai.setAttr(this.domNode, "waiState", "labelledby", labels[i].id); + break; } } - this._connectEvents(this.domNode); - // this is needed here for IE - this.inputNode.checked=this.checked; - }, - - _connectEvents: function(/*DomNode*/ node){ - dojo.event.connect(node, "onmouseover", this, "mouseOver"); - dojo.event.connect(node, "onmouseout", this, "mouseOut"); - dojo.event.connect(node, "onkey", this, "onKey"); - dojo.event.connect(node, "onclick", this, "_onClick"); - dojo.html.disableSelection(node); - }, - - _onClick: function(/*Event*/ e){ - if(this.disabled == false){ - this.checked = !this.checked; - this._setInfo(); - } - e.preventDefault(); - e.stopPropagation(); - this.onClick(); - }, - - onClick: function(){ - // summary: user overridable callback function for checkbox being clicked - }, - - onKey: function(/*Event*/ e){ - // summary: callback when user hits a key - var k = dojo.event.browser.keys; - if(e.key == " "){ - this._onClick(e); - } - }, - - mouseOver: function(/*Event*/ e){ - // summary: callback when user moves mouse over checkbox - this._hover(e, true); - }, - - mouseOut: function(/*Event*/ e){ - // summary: callback when user moves mouse off of checkbox - this._hover(e, false); - }, - - _hover: function(/*Event*/ e, /*Boolean*/ isOver){ - if (this.disabled == false){ - var state = this.checked ? "On" : "Off"; - var style = "dojoHtmlCheckbox" + state + "Hover"; - if (isOver){ - dojo.html.addClass(this.imageNode, style); - }else{ - dojo.html.removeClass(this.imageNode,style); - } - } - }, - - _setInfo: function(){ - // summary: - // set state of hidden checkbox node to correspond to displayed value. - // also set CSS class string according to checked/unchecked and disabled/enabled state - var state = "dojoHtmlCheckbox" + (this.disabled ? "Disabled" : "") + (this.checked ? "On" : "Off"); - dojo.html.setClass(this.imageNode, "dojoHtmlCheckbox " + state); - this.inputNode.checked = this.checked; - if(this.disabled){ - this.inputNode.setAttribute("disabled",true); - }else{ - this.inputNode.removeAttribute("disabled"); - } - dojo.widget.wai.setAttr(this.domNode, "waiState", "checked", this.checked); } } -); - -// summary -// variation on Checkbox widget to be display on monitors in high-contrast mode (that don't display CSS background images) -dojo.widget.defineWidget( - "dojo.widget.a11y.Checkbox", - dojo.widget.Checkbox, - { - templatePath: dojo.uri.dojoUri('src/widget/templates/CheckboxA11y.html'), - - fillInTemplate: function(){ - }, - - postCreate: function(args, frag){ - this.inputNode.checked=this.checked; - //only set disabled if true since FF interprets any value for disabled as true - if (this.disabled){ - this.inputNode.setAttribute("disabled",true); - } - }, - - _onClick: function(){ - this.onClick(); + this._connectEvents(this.domNode); + this.inputNode.checked = this.checked; +}, _connectEvents:function (node) { + dojo.event.connect(node, "onmouseover", this, "mouseOver"); + dojo.event.connect(node, "onmouseout", this, "mouseOut"); + dojo.event.connect(node, "onkey", this, "onKey"); + dojo.event.connect(node, "onclick", this, "_onClick"); + dojo.html.disableSelection(node); +}, _onClick:function (e) { + if (this.disabled == false) { + this.checked = !this.checked; + this._setInfo(); + } + e.preventDefault(); + e.stopPropagation(); + this.onClick(); +}, setValue:function (bool) { + if (this.disabled == false) { + this.checked = bool; + this._setInfo(); + } +}, onClick:function () { +}, onKey:function (e) { + var k = dojo.event.browser.keys; + if (e.key == " ") { + this._onClick(e); + } +}, mouseOver:function (e) { + this._hover(e, true); +}, mouseOut:function (e) { + this._hover(e, false); +}, _hover:function (e, isOver) { + if (this.disabled == false) { + var state = this.checked ? "On" : "Off"; + var style = "dojoHtmlCheckbox" + state + "Hover"; + if (isOver) { + dojo.html.addClass(this.imageNode, style); + } else { + dojo.html.removeClass(this.imageNode, style); } } -); \ No newline at end of file +}, _setInfo:function () { + var state = "dojoHtmlCheckbox" + (this.disabled ? "Disabled" : "") + (this.checked ? "On" : "Off"); + dojo.html.setClass(this.imageNode, "dojoHtmlCheckbox " + state); + this.inputNode.checked = this.checked; + if (this.disabled) { + this.inputNode.setAttribute("disabled", true); + } else { + this.inputNode.removeAttribute("disabled"); + } + dojo.widget.wai.setAttr(this.domNode, "waiState", "checked", this.checked); +}}); +dojo.widget.defineWidget("dojo.widget.a11y.Checkbox", dojo.widget.Checkbox, {templateString:"\n\t \n\n", fillInTemplate:function () { +}, postCreate:function (args, frag) { + this.inputNode.checked = this.checked; + if (this.disabled) { + this.inputNode.setAttribute("disabled", true); + } +}, _onClick:function () { + this.onClick(); +}}); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/Clock.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/Clock.js index 9e2b4c5a9..0d0fcd720 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/Clock.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/Clock.js @@ -8,204 +8,133 @@ http://dojotoolkit.org/community/licensing.shtml */ -dojo.provide("dojo.widget.Clock"); - -dojo.require("dojo.widget.*"); -dojo.require("dojo.gfx.*"); -dojo.require("dojo.uri.Uri"); -dojo.require("dojo.lang.common"); -dojo.require("dojo.lang.timing.Timer"); - -dojo.widget.defineWidget( - "dojo.widget.Clock", - dojo.widget.HtmlWidget, - function(){ - var self=this; - this.timeZoneOffset=0; // this is fun. - this.label=""; // optional label. - - this.date=new Date(); - - this.handColor="#788598"; - this.handStroke="#6f7b8c"; - // this.secondHandColor="#c90405"; - this.secondHandColor=[201, 4, 5, 0.8]; - this.topLabelColor="#efefef"; - this.labelColor="#fff"; - - // timer - this.timer = new dojo.lang.timing.Timer(1000); - - // shapes - this.center={ x:75, y:75 }; - this.hands={ - hour:null, - minute:null, - second:null - }; - this.shadows={ - hour:{ shadow:null, shift:{ dx:2, dy:2} }, - minute:{ shadow:null, shift:{ dx:2, dy:3} }, - second:{ shadow:null, shift:{ dx:4, dy:4} } - }; - this.image = dojo.uri.dojoUri("src/widget/templates/images/clock.png"); - this.surface=null; - this.labelNode=null; - this.topLabelNode=null; - - this.draw=function(){ - self.date=new Date(); - var h=(self.date.getHours()+self.timeZoneOffset) % 12; - var m=self.date.getMinutes(); - var s=self.date.getSeconds(); - - self.placeHour(h, m, s); - self.placeMinute(m, s); - self.placeSecond(s); - - self.topLabelNode.innerHTML=((self.date.getHours()+self.timeZoneOffset)>11)?"PM":"AM"; - }; - - this.timer.onTick=self.draw; - }, - { - set:function(/* Date */dt){ - this.date=dt; - if(!this.timer.isRunning){ - this.draw(); - } - }, - start:function(){ this.timer.start(); }, - stop:function(){ this.timer.stop(); }, - - _initPoly:function(parent, points){ - var path = parent.createPath(); - var first = true; - dojo.lang.forEach(points, function(c){ - if(first){ - path.moveTo(c.x, c.y); - first=false; - } else { - path.lineTo(c.x, c.y); - } - }); - return path; - }, - _placeHand:function(shape, angle, shift){ - var move = { dx:this.center.x + (shift?shift.dx:0), dy:this.center.y+(shift?shift.dy:0) }; - return shape.setTransform([move, dojo.gfx.matrix.rotateg(-angle)]); - }, - placeHour:function(h, m, s){ - var angle=30 *(h + m/60 + s/3600); - this._placeHand(this.hands.hour, angle); - this._placeHand(this.shadows.hour.shadow, angle, this.shadows.hour.shift); - }, - placeMinute:function(m, s){ - var angle=6 * (m + s/60); - this._placeHand(this.hands.minute, angle); - this._placeHand(this.shadows.minute.shadow, angle, this.shadows.minute.shift); - }, - placeSecond:function(s){ - var angle=6 * s; - this._placeHand(this.hands.second, angle); - this._placeHand(this.shadows.second.shadow, angle, this.shadows.second.shift); - }, - - init:function(){ - // start by setting up the domNode - if(this.domNode.style.position != "absolute"){ - this.domNode.style.position = "relative"; - } - - // clean out any children - while(this.domNode.childNodes.length>0){ - this.domNode.removeChild(this.domNode.childNodes[0]); - } - - // set ourselves up. - this.domNode.style.width="150px"; - this.domNode.style.height="150px"; - - this.surface=dojo.gfx.createSurface(this.domNode, 150, 150); - this.surface.createRect({width: 150, height: 150}); - this.surface.createImage({width: 150, height: 150, src: this.image+""}); - - var hP=[ {x: -3, y: -4}, {x: 3, y: -4}, {x: 1, y: -27}, { x:-1, y:-27}, {x: -3, y: -4} ]; - var mP=[ {x: -3, y: -4}, {x: 3, y: -4}, {x: 1, y: -38}, {x:-1, y:-38}, {x: -3, y: -4} ]; - var sP=[ {x: -2, y: -2}, {x: 2, y: -2}, {x: 1, y: -45}, {x: -1, y: -45}, {x: -2, y: -2} ]; - - this.shadows.hour.shadow = this._initPoly(this.surface, hP) - .setFill([0, 0, 0, 0.1]); - this.hands.hour = this._initPoly(this.surface, hP) - .setStroke({color: this.handStroke, width:1 }) - .setFill({ - type:"linear", - x1:0, y1:0, x2:0, y2:-27, - colors:[{offset:0, color:"#fff"}, {offset:0.33, color:this.handColor}] - }); - this.shadows.minute.shadow = this._initPoly(this.surface, mP) - .setFill([0, 0, 0, 0.1]); - this.hands.minute = this._initPoly(this.surface, mP) - .setStroke({color: this.handStroke, width:1 }) - .setFill({ - type:"linear", - x1:0, y1:0, x2:0, y2:-38, - colors:[{offset:0, color:"#fff"}, {offset:0.33, color:this.handColor}] - }); - - this.surface.createCircle({r: 6}) - .setStroke({color: this.handStroke, width:2 }) - .setFill("#fff") - .setTransform({dx: 75, dy: 75}); - - this.shadows.second.shadow = this._initPoly(this.surface, sP) - .setFill([0, 0, 0, 0.1]); - this.hands.second = this._initPoly(this.surface, sP) - .setFill(this.secondHandColor); - - // clock centers, doesn't move. - this.surface.createCircle({r: 4}) - .setFill(this.secondHandColor) - .setTransform({dx: 75, dy: 75}); - - // labels - this.topLabelNode=document.createElement("div"); - with(this.topLabelNode.style){ - position="absolute"; - top="3px"; - left="0px"; - color=this.topLabelColor; - textAlign="center"; - width="150px"; - fontFamily="sans-serif"; - fontSize="11px"; - textTransform="uppercase"; - fontWeight="bold"; - } - this.topLabelNode.innerHTML=((this.date.getHours()+this.timeZoneOffset)>11)?"PM":"AM"; - this.domNode.appendChild(this.topLabelNode); - - this.labelNode=document.createElement("div"); - with(this.labelNode.style){ - position="absolute"; - top="134px"; - left="0px"; - color=this.labelColor; - textAlign="center"; - width="150px"; - fontFamily="sans-serif"; - fontSize="10px"; - textTransform="uppercase"; - fontWeight="bold"; - } - this.labelNode.innerHTML=this.label||" "; - this.domNode.appendChild(this.labelNode); - - this.draw(); - }, - postCreate:function(){ - this.init(); - this.start(); - } - } -); +dojo.provide("dojo.widget.Clock"); +dojo.require("dojo.widget.*"); +dojo.require("dojo.gfx.*"); +dojo.require("dojo.uri.Uri"); +dojo.require("dojo.lang.common"); +dojo.require("dojo.lang.timing.Timer"); +dojo.widget.defineWidget("dojo.widget.Clock", dojo.widget.HtmlWidget, function () { + var self = this; + this.timeZoneOffset = 0; + this.label = ""; + this.date = new Date(); + this.handColor = "#788598"; + this.handStroke = "#6f7b8c"; + this.secondHandColor = [201, 4, 5, 0.8]; + this.topLabelColor = "#efefef"; + this.labelColor = "#fff"; + this.timer = new dojo.lang.timing.Timer(1000); + this.center = {x:75, y:75}; + this.hands = {hour:null, minute:null, second:null}; + this.shadows = {hour:{shadow:null, shift:{dx:2, dy:2}}, minute:{shadow:null, shift:{dx:2, dy:3}}, second:{shadow:null, shift:{dx:4, dy:4}}}; + this.image = dojo.uri.moduleUri("dojo.widget", "templates/images/clock.png"); + this.surface = null; + this.labelNode = null; + this.topLabelNode = null; + this.draw = function () { + self.date = new Date(); + var h = (self.date.getHours() + self.timeZoneOffset) % 12; + var m = self.date.getMinutes(); + var s = self.date.getSeconds(); + self.placeHour(h, m, s); + self.placeMinute(m, s); + self.placeSecond(s); + self.topLabelNode.innerHTML = ((self.date.getHours() + self.timeZoneOffset) > 11) ? "PM" : "AM"; + }; + this.timer.onTick = self.draw; +}, {set:function (dt) { + this.date = dt; + if (!this.timer.isRunning) { + this.draw(); + } +}, start:function () { + this.timer.start(); +}, stop:function () { + this.timer.stop(); +}, _initPoly:function (parent, points) { + var path = parent.createPath(); + var first = true; + dojo.lang.forEach(points, function (c) { + if (first) { + path.moveTo(c.x, c.y); + first = false; + } else { + path.lineTo(c.x, c.y); + } + }); + return path; +}, _placeHand:function (shape, angle, shift) { + var move = {dx:this.center.x + (shift ? shift.dx : 0), dy:this.center.y + (shift ? shift.dy : 0)}; + return shape.setTransform([move, dojo.gfx.matrix.rotateg(-angle)]); +}, placeHour:function (h, m, s) { + var angle = 30 * (h + m / 60 + s / 3600); + this._placeHand(this.hands.hour, angle); + this._placeHand(this.shadows.hour.shadow, angle, this.shadows.hour.shift); +}, placeMinute:function (m, s) { + var angle = 6 * (m + s / 60); + this._placeHand(this.hands.minute, angle); + this._placeHand(this.shadows.minute.shadow, angle, this.shadows.minute.shift); +}, placeSecond:function (s) { + var angle = 6 * s; + this._placeHand(this.hands.second, angle); + this._placeHand(this.shadows.second.shadow, angle, this.shadows.second.shift); +}, init:function () { + if (this.domNode.style.position != "absolute") { + this.domNode.style.position = "relative"; + } + while (this.domNode.childNodes.length > 0) { + this.domNode.removeChild(this.domNode.childNodes[0]); + } + this.domNode.style.width = "150px"; + this.domNode.style.height = "150px"; + this.surface = dojo.gfx.createSurface(this.domNode, 150, 150); + this.surface.createRect({width:150, height:150}); + this.surface.createImage({width:150, height:150, src:this.image + ""}); + var hP = [{x:-3, y:-4}, {x:3, y:-4}, {x:1, y:-27}, {x:-1, y:-27}, {x:-3, y:-4}]; + var mP = [{x:-3, y:-4}, {x:3, y:-4}, {x:1, y:-38}, {x:-1, y:-38}, {x:-3, y:-4}]; + var sP = [{x:-2, y:-2}, {x:2, y:-2}, {x:1, y:-45}, {x:-1, y:-45}, {x:-2, y:-2}]; + this.shadows.hour.shadow = this._initPoly(this.surface, hP).setFill([0, 0, 0, 0.1]); + this.hands.hour = this._initPoly(this.surface, hP).setStroke({color:this.handStroke, width:1}).setFill({type:"linear", x1:0, y1:0, x2:0, y2:-27, colors:[{offset:0, color:"#fff"}, {offset:0.33, color:this.handColor}]}); + this.shadows.minute.shadow = this._initPoly(this.surface, mP).setFill([0, 0, 0, 0.1]); + this.hands.minute = this._initPoly(this.surface, mP).setStroke({color:this.handStroke, width:1}).setFill({type:"linear", x1:0, y1:0, x2:0, y2:-38, colors:[{offset:0, color:"#fff"}, {offset:0.33, color:this.handColor}]}); + this.surface.createCircle({r:6}).setStroke({color:this.handStroke, width:2}).setFill("#fff").setTransform({dx:75, dy:75}); + this.shadows.second.shadow = this._initPoly(this.surface, sP).setFill([0, 0, 0, 0.1]); + this.hands.second = this._initPoly(this.surface, sP).setFill(this.secondHandColor); + this.surface.createCircle({r:4}).setFill(this.secondHandColor).setTransform({dx:75, dy:75}); + this.topLabelNode = document.createElement("div"); + with (this.topLabelNode.style) { + position = "absolute"; + top = "3px"; + left = "0px"; + color = this.topLabelColor; + textAlign = "center"; + width = "150px"; + fontFamily = "sans-serif"; + fontSize = "11px"; + textTransform = "uppercase"; + fontWeight = "bold"; + } + this.topLabelNode.innerHTML = ((this.date.getHours() + this.timeZoneOffset) > 11) ? "PM" : "AM"; + this.domNode.appendChild(this.topLabelNode); + this.labelNode = document.createElement("div"); + with (this.labelNode.style) { + position = "absolute"; + top = "134px"; + left = "0px"; + color = this.labelColor; + textAlign = "center"; + width = "150px"; + fontFamily = "sans-serif"; + fontSize = "10px"; + textTransform = "uppercase"; + fontWeight = "bold"; + } + this.labelNode.innerHTML = this.label || " "; + this.domNode.appendChild(this.labelNode); + this.draw(); +}, postCreate:function () { + this.init(); + this.start(); +}}); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/ColorPalette.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/ColorPalette.js index 83b2c0564..e8e755afd 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/ColorPalette.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/ColorPalette.js @@ -13,111 +13,46 @@ dojo.require("dojo.widget.*"); dojo.require("dojo.html.layout"); dojo.require("dojo.html.display"); dojo.require("dojo.html.selection"); - -dojo.widget.defineWidget( - "dojo.widget.ColorPalette", - dojo.widget.HtmlWidget, -{ - palette: "7x10", - - bgIframe: null, - - palettes: { - "7x10": [["fff", "fcc", "fc9", "ff9", "ffc", "9f9", "9ff", "cff", "ccf", "fcf"], - ["ccc", "f66", "f96", "ff6", "ff3", "6f9", "3ff", "6ff", "99f", "f9f"], - ["c0c0c0", "f00", "f90", "fc6", "ff0", "3f3", "6cc", "3cf", "66c", "c6c"], - ["999", "c00", "f60", "fc3", "fc0", "3c0", "0cc", "36f", "63f", "c3c"], - ["666", "900", "c60", "c93", "990", "090", "399", "33f", "60c", "939"], - ["333", "600", "930", "963", "660", "060", "366", "009", "339", "636"], - ["000", "300", "630", "633", "330", "030", "033", "006", "309", "303"]], - - "3x4": [["ffffff"/*white*/, "00ff00"/*lime*/, "008000"/*green*/, "0000ff"/*blue*/], - ["c0c0c0"/*silver*/, "ffff00"/*yellow*/, "ff00ff"/*fuchsia*/, "000080"/*navy*/], - ["808080"/*gray*/, "ff0000"/*red*/, "800080"/*purple*/, "000000"/*black*/]] - //["00ffff"/*aqua*/, "808000"/*olive*/, "800000"/*maroon*/, "008080"/*teal*/]]; - }, - - buildRendering: function () { - this.domNode = document.createElement("table"); -// dojo.body().appendChild(this.domNode); - dojo.html.disableSelection(this.domNode); - dojo.event.connect(this.domNode, "onmousedown", function (e) { - e.preventDefault(); - }); - with (this.domNode) { // set the table's properties - cellPadding = "0"; cellSpacing = "1"; border = "1"; - style.backgroundColor = "white"; //style.position = "absolute"; - } - var colors = this.palettes[this.palette]; - for (var i = 0; i < colors.length; i++) { - var tr = this.domNode.insertRow(-1); - for (var j = 0; j < colors[i].length; j++) { - if (colors[i][j].length == 3) { - colors[i][j] = colors[i][j].replace(/(.)(.)(.)/, "$1$1$2$2$3$3"); - } - - var td = tr.insertCell(-1); - with (td.style) { - backgroundColor = "#" + colors[i][j]; - border = "1px solid gray"; - width = height = "15px"; - fontSize = "1px"; - } - - td.color = "#" + colors[i][j]; - - td.onmouseover = function (e) { this.style.borderColor = "white"; } - td.onmouseout = function (e) { this.style.borderColor = "gray"; } - dojo.event.connect(td, "onmousedown", this, "click"); - - td.innerHTML = " "; +dojo.widget.defineWidget("dojo.widget.ColorPalette", dojo.widget.HtmlWidget, {palette:"7x10", _palettes:{"7x10":[["fff", "fcc", "fc9", "ff9", "ffc", "9f9", "9ff", "cff", "ccf", "fcf"], ["ccc", "f66", "f96", "ff6", "ff3", "6f9", "3ff", "6ff", "99f", "f9f"], ["c0c0c0", "f00", "f90", "fc6", "ff0", "3f3", "6cc", "3cf", "66c", "c6c"], ["999", "c00", "f60", "fc3", "fc0", "3c0", "0cc", "36f", "63f", "c3c"], ["666", "900", "c60", "c93", "990", "090", "399", "33f", "60c", "939"], ["333", "600", "930", "963", "660", "060", "366", "009", "339", "636"], ["000", "300", "630", "633", "330", "030", "033", "006", "309", "303"]], "3x4":[["ffffff", "00ff00", "008000", "0000ff"], ["c0c0c0", "ffff00", "ff00ff", "000080"], ["808080", "ff0000", "800080", "000000"]]}, buildRendering:function () { + this.domNode = document.createElement("table"); + dojo.html.disableSelection(this.domNode); + dojo.event.connect(this.domNode, "onmousedown", function (e) { + e.preventDefault(); + }); + with (this.domNode) { + cellPadding = "0"; + cellSpacing = "1"; + border = "1"; + style.backgroundColor = "white"; + } + var colors = this._palettes[this.palette]; + for (var i = 0; i < colors.length; i++) { + var tr = this.domNode.insertRow(-1); + for (var j = 0; j < colors[i].length; j++) { + if (colors[i][j].length == 3) { + colors[i][j] = colors[i][j].replace(/(.)(.)(.)/, "$1$1$2$2$3$3"); } - } - - if(dojo.render.html.ie){ - this.bgIframe = document.createElement("\n\n", templateCssString:".demoPane {\n\twidth: 100%;\n\theight: 100%;\n\tpadding: 0px;\n\tmargin: 0px;\n\toverflow: hidden;\n}\n\n.demoPane iframe {\n\twidth: 100%;\n\theight: 100%;\n\tborder: 0px;\n\tborder: none;\n\toverflow: auto;\n\tpadding: 0px;\n\tmargin:0px;\n\tbackground: #ffffff;\n}\n", templateCssPath:dojo.uri.moduleUri("dojo.widget", "demoEngine/templates/DemoPane.css"), postCreate:function () { + dojo.html.addClass(this.domNode, this.domNodeClass); + dojo.debug("PostCreate"); + this._launchDemo(); +}, _launchDemo:function () { + dojo.debug("Launching Demo"); + dojo.debug(this.demoNode); + this.demoNode.src = this.href; +}, setHref:function (url) { + this.href = url; + this._launchDemo(); +}}, "", function () { + dojo.debug("DemoPane Init"); + this.domNodeClass = "demoPane"; + this.demoNode = ""; + this.href = ""; +}); -dojo.widget.defineWidget("my.widget.demoEngine.DemoPane", - dojo.widget.HtmlWidget, - { - templatePath: dojo.uri.dojoUri("src/widget/demoEngine/templates/DemoPane.html"), - templateCssPath: dojo.uri.dojoUri("src/widget/demoEngine/templates/DemoPane.css"), - postCreate: function() { - dojo.html.addClass(this.domNode,this.domNodeClass); - dojo.debug("PostCreate"); - this._launchDemo(); - }, - - _launchDemo: function() { - dojo.debug("Launching Demo"); - dojo.debug(this.demoNode); - this.demoNode.src=this.href; - }, - - setHref: function(url) { - this.href = url; - this._launchDemo(); - } - }, - "", - function() { - dojo.debug("DemoPane Init"); - this.domNodeClass="demoPane"; - this.demoNode = ""; - this.href = ""; - } -); diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/demoEngine/SourcePane.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/demoEngine/SourcePane.js index 8a3a0f7d0..5538849d1 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/demoEngine/SourcePane.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/demoEngine/SourcePane.js @@ -12,41 +12,22 @@ dojo.provide("dojo.widget.demoEngine.SourcePane"); dojo.require("dojo.widget.*"); dojo.require("dojo.widget.HtmlWidget"); dojo.require("dojo.io.*"); - -dojo.widget.defineWidget("my.widget.demoEngine.SourcePane", - dojo.widget.HtmlWidget, - { - templatePath: dojo.uri.dojoUri("src/widget/demoEngine/templates/SourcePane.html"), - templateCssPath: dojo.uri.dojoUri("src/widget/demoEngine/templates/SourcePane.css"), - postCreate: function() { - dojo.html.addClass(this.domNode,this.domNodeClass); - dojo.debug("PostCreate"); - }, - - getSource: function() { - if (this.href) { - dojo.io.bind({ - url: this.href, - load: dojo.lang.hitch(this, "fillInSource"), - mimetype: "text/plain" - }); - } - }, - - fillInSource: function(type, source, e) { - this.sourceNode.value=source; - }, - - setHref: function(url) { - this.href = url; - this.getSource(); - } - }, - "", - function() { - dojo.debug("SourcePane Init"); - this.domNodeClass="sourcePane"; - this.sourceNode = ""; - this.href = ""; +dojo.widget.defineWidget("my.widget.demoEngine.SourcePane", dojo.widget.HtmlWidget, {templateString:"
\n\t\n
\n", templateCssString:".sourcePane {\n\twidth: 100%;\n\theight: 100%;\n\tpadding: 0px;\n\tmargin: 0px;\n\toverflow: hidden;\n}\n\n.sourcePane textarea{\n\twidth: 100%;\n\theight: 100%;\n\tborder: 0px;\n\toverflow: auto;\n\tpadding: 0px;\n\tmargin:0px;\n}\n\n* html .sourcePane {\n\toverflow: auto;\n}\n", templateCssPath:dojo.uri.moduleUri("dojo.widget", "demoEngine/templates/SourcePane.css"), postCreate:function () { + dojo.html.addClass(this.domNode, this.domNodeClass); + dojo.debug("PostCreate"); +}, getSource:function () { + if (this.href) { + dojo.io.bind({url:this.href, load:dojo.lang.hitch(this, "fillInSource"), mimetype:"text/plain"}); } -); +}, fillInSource:function (type, source, e) { + this.sourceNode.value = source; +}, setHref:function (url) { + this.href = url; + this.getSource(); +}}, "", function () { + dojo.debug("SourcePane Init"); + this.domNodeClass = "sourcePane"; + this.sourceNode = ""; + this.href = ""; +}); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/demoEngine/__package__.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/demoEngine/__package__.js index 8118fd80a..4a096ad83 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/demoEngine/__package__.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/demoEngine/__package__.js @@ -8,13 +8,6 @@ http://dojotoolkit.org/community/licensing.shtml */ -dojo.kwCompoundRequire({ - browser: [ - "dojo.widget.demoEngine.DemoItem", - "dojo.widget.demoEngine.DemoNavigator", - "dojo.widget.demoEngine.DemoPane", - "dojo.widget.demoEngine.SourcePane", - "dojo.widget.demoEngine.DemoContainer" - ] -}); +dojo.kwCompoundRequire({browser:["dojo.widget.demoEngine.DemoItem", "dojo.widget.demoEngine.DemoNavigator", "dojo.widget.demoEngine.DemoPane", "dojo.widget.demoEngine.SourcePane", "dojo.widget.demoEngine.DemoContainer"]}); dojo.provide("dojo.widget.demoEngine.*"); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/html/layout.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/html/layout.js index e35cd87b5..e8099b9f9 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/html/layout.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/html/layout.js @@ -9,113 +9,84 @@ */ dojo.provide("dojo.widget.html.layout"); - dojo.require("dojo.lang.common"); dojo.require("dojo.string.extras"); dojo.require("dojo.html.style"); dojo.require("dojo.html.layout"); - -/** - * Layout a bunch of child dom nodes within a parent dom node - * Input is an array of objects like: - * @ container - parent node - * @ layoutPriority - "top-bottom" or "left-right" - * @ children an array like [ {domNode: foo, layoutAlign: "bottom" }, {domNode: bar, layoutAlign: "client"} ] - */ -dojo.widget.html.layout = function(container, children, layoutPriority) { +dojo.widget.html.layout = function (container, children, layoutPriority) { dojo.html.addClass(container, "dojoLayoutContainer"); - - // Copy children array and remove elements w/out layout. - // Also record each child's position in the input array, for sorting purposes. - children = dojo.lang.filter(children, function(child, idx){ + children = dojo.lang.filter(children, function (child, idx) { child.idx = idx; - return dojo.lang.inArray(["top","bottom","left","right","client","flood"], child.layoutAlign) + return dojo.lang.inArray(["top", "bottom", "left", "right", "client", "flood"], child.layoutAlign); }); - - // Order the children according to layoutPriority. - // Multiple children w/the same layoutPriority will be sorted by their position in the input array. - if(layoutPriority && layoutPriority!="none"){ - var rank = function(child){ - switch(child.layoutAlign){ - case "flood": - return 1; - case "left": - case "right": - return (layoutPriority=="left-right") ? 2 : 3; - case "top": - case "bottom": - return (layoutPriority=="left-right") ? 3 : 2; - default: - return 4; + if (layoutPriority && layoutPriority != "none") { + var rank = function (child) { + switch (child.layoutAlign) { + case "flood": + return 1; + case "left": + case "right": + return (layoutPriority == "left-right") ? 2 : 3; + case "top": + case "bottom": + return (layoutPriority == "left-right") ? 3 : 2; + default: + return 4; } }; - children.sort(function(a,b){ - return (rank(a)-rank(b)) || (a.idx - b.idx); + children.sort(function (a, b) { + return (rank(a) - rank(b)) || (a.idx - b.idx); }); } - - // remaining space (blank area where nothing has been written) - var f={ - top: dojo.html.getPixelValue(container, "padding-top", true), - left: dojo.html.getPixelValue(container, "padding-left", true) - }; + var f = {top:dojo.html.getPixelValue(container, "padding-top", true), left:dojo.html.getPixelValue(container, "padding-left", true)}; dojo.lang.mixin(f, dojo.html.getContentBox(container)); - - // set positions/sizes - dojo.lang.forEach(children, function(child){ - var elm=child.domNode; - var pos=child.layoutAlign; - // set elem to upper left corner of unused space; may move it later - with(elm.style){ - left = f.left+"px"; - top = f.top+"px"; + dojo.lang.forEach(children, function (child) { + var elm = child.domNode; + var pos = child.layoutAlign; + with (elm.style) { + left = f.left + "px"; + top = f.top + "px"; bottom = "auto"; right = "auto"; } dojo.html.addClass(elm, "dojoAlign" + dojo.string.capitalize(pos)); - - // set size && adjust record of remaining space. - // note that setting the width of a
may affect it's height. - // TODO: same is true for widgets but need to implement API to support that - if ( (pos=="top")||(pos=="bottom") ) { - dojo.html.setMarginBox(elm, { width: f.width }); + if ((pos == "top") || (pos == "bottom")) { + dojo.html.setMarginBox(elm, {width:f.width}); var h = dojo.html.getMarginBox(elm).height; f.height -= h; - if(pos=="top"){ + if (pos == "top") { f.top += h; - }else{ + } else { elm.style.top = f.top + f.height + "px"; } - }else if(pos=="left" || pos=="right"){ - var w = dojo.html.getMarginBox(elm).width; - // width needs to be set for Firefox (#941) - dojo.html.setMarginBox(elm, { width: w, height: f.height }); - - f.width -= w; - if(pos=="left"){ - f.left += w; - }else{ - elm.style.left = f.left + f.width + "px"; + if (child.onResized) { + child.onResized(); + } + } else { + if (pos == "left" || pos == "right") { + var w = dojo.html.getMarginBox(elm).width; + if (child.resizeTo) { + child.resizeTo(w, f.height); + } else { + dojo.html.setMarginBox(elm, {width:w, height:f.height}); + } + f.width -= w; + if (pos == "left") { + f.left += w; + } else { + elm.style.left = f.left + f.width + "px"; + } + } else { + if (pos == "flood" || pos == "client") { + if (child.resizeTo) { + child.resizeTo(f.width, f.height); + } else { + dojo.html.setMarginBox(elm, {width:f.width, height:f.height}); + } + } } - } else if(pos=="flood" || pos=="client"){ - dojo.html.setMarginBox(elm, { width: f.width, height: f.height }); - } - - // TODO: for widgets I want to call resizeTo(), but for top/bottom - // alignment I only want to set the width, and have the size determined - // dynamically. (The thinner you make a div, the more height it consumes.) - if(child.onResized){ - child.onResized(); } }); }; - -// This is essential CSS to make layout work (it isn't "styling" CSS) -// make sure that the position:absolute in dojoAlign* overrides other classes -dojo.html.insertCssText( - ".dojoLayoutContainer{ position: relative; display: block; }\n" + - "body .dojoAlignTop, body .dojoAlignBottom, body .dojoAlignLeft, body .dojoAlignRight { position: absolute; overflow: hidden; }\n" + - "body .dojoAlignClient { position: absolute }\n" + - ".dojoAlignClient { overflow: auto; }\n" -); +dojo.html.insertCssText(".dojoLayoutContainer{ position: relative; display: block; overflow: hidden; }\n" + "body .dojoAlignTop, body .dojoAlignBottom, body .dojoAlignLeft, body .dojoAlignRight { position: absolute; overflow: hidden; }\n" + "body .dojoAlignClient { position: absolute }\n" + ".dojoAlignClient { overflow: auto; }\n"); diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/html/loader.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/html/loader.js index 531c46b64..dfdfa04d0 100644 --- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/html/loader.js +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/widget/html/loader.js @@ -9,835 +9,612 @@ */ dojo.provide("dojo.widget.html.loader"); - dojo.require("dojo.widget.HtmlWidget"); dojo.require("dojo.io.*"); dojo.require("dojo.lang.common"); dojo.require("dojo.lang.extras"); - dojo.require("dojo.experimental"); - -// as this is a singleton dojo.declare doesn't buy us anything here -dojo.widget.html.loader = new (function(){ - // summary: - // loading stuff moved out of contentpane to make it directly accessible by other widgets - this.toString = function(){ return "dojo.widget.html.loader"; } +dojo.experimental("dojo.widget.html.loader"); +dojo.widget.html.loader = new (function () { + this.toString = function () { + return "dojo.widget.html.loader"; + }; var _loader = this; - - // back/forward tracking - dojo.addOnLoad(function(){ + dojo.addOnLoad(function () { dojo.experimental(_loader.toString()); var undo = dojo.evalObjPath("dojo.undo.browser"); - if(djConfig["preventBackButtonFix"] && undo && !undo.initialState){ + if (djConfig["preventBackButtonFix"] && undo && !undo.initialState) { undo.setInitialState(new trackerObj); } }); - var logger = {}; - var trackerObj = function(id, data){ + var trackerObj = function (id, data) { this.id = id; - this.data = data + this.data = data; }; - trackerObj.prototype.handle = function(type){ - if(typeof dojo == 'undefined'){ return; } // wtf? how can dojo become undef? + trackerObj.prototype.handle = function (type) { + if (typeof dojo == "undefined") { + return; + } var wg = dojo.widget.byId(this.id); - if(wg){ wg.setContent(this.data, true); } + if (wg) { + wg.setContent(this.data, true); + } }; - - this._log = function(widget, data){ - // if a loader widget B is a child of loader widget A - // we need to destroy all of B's undo if we switch content - if(widget.trackHistory){ - if(!logger[widget.widgetId]){ - logger[widget.widgetId] = { childrenIds: [], stack:[data] }; - }var children = logger[widget.widgetId].childrenIds; - while(children && children.length){ + this._log = function (widget, data) { + if (widget.trackHistory) { + if (!logger[widget.widgetId]) { + logger[widget.widgetId] = {childrenIds:[], stack:[data]}; + } + var children = logger[widget.widgetId].childrenIds; + while (children && children.length) { delete logger[children.pop()]; } - for(var child in widget.children){ + for (var child in widget.children) { logger[widget.widgetId].childrenIds = child.widgetId; } dojo.undo.browser.addToHistory(new trackerObj(widget.widgetId, dojo.lang.shallowCopy(data, true))); } - } - - // shortCuts + }; var undef = dojo.lang.isUndefined; var isFunc = dojo.lang.isFunction; - - - - /************ private needed functions, no need to be part of widget API ***********/ - // useful if user wants to prevent default behaviour ie: _setContent("Error...") - function handleDefaults(e, handler, useAlert){ - if(!handler){ handler = "onContentError"; } - if(dojo.lang.isString(e)){ e = {_text: e}; } - if(!e._text){ e._text = e.toString(); } - e.toString = function(){ return this._text; }; - if(typeof e.returnValue != "boolean"){ - e.returnValue = true; + function handleDefaults(e, handler, useAlert) { + if (!handler) { + handler = "onContentError"; } - if(typeof e.preventDefault != "function"){ - e.preventDefault = function(){ this.returnValue = false; }; + if (dojo.lang.isString(e)) { + e = {_text:e}; + } + if (!e._text) { + e._text = e.toString(); + } + e.toString = function () { + return this._text; + }; + if (typeof e.returnValue != "boolean") { + e.returnValue = true; + } + if (typeof e.preventDefault != "function") { + e.preventDefault = function () { + this.returnValue = false; + }; } - // call our handler this[handler](e); - if(e.returnValue){ - if(useAlert){ + if (e.returnValue) { + if (useAlert) { alert(e.toString()); - }else{ + } else { this.loader.callOnUnLoad.call(this, false); this.onSetContent(e.toString()); } } - }; - - // set up downloader, used by both scripts and content + } function downloader(bindArgs) { - for(var x in this.bindArgs){ + for (var x in this.bindArgs) { bindArgs[x] = (undef(bindArgs[x]) ? this.bindArgs[x] : undefined); } var cache = this.cacheContent; - if(undef(bindArgs.useCache)){ bindArgs.useCache = cache; } - if(undef(bindArgs.preventCache)){ bindArgs.preventCache = !cache; } - if(undef(bindArgs.mimetype)){ bindArgs.mimetype = "text/html"; } + if (undef(bindArgs.useCache)) { + bindArgs.useCache = cache; + } + if (undef(bindArgs.preventCache)) { + bindArgs.preventCache = !cache; + } + if (undef(bindArgs.mimetype)) { + bindArgs.mimetype = "text/html"; + } this.loader.bindObj = dojo.io.bind(bindArgs); - }; - - // runs addOnLoad/addOnUnLoad functions - function stackRunner(st){ + } + function stackRunner(st) { var err = "", func = null; var scope = this.scriptScope || dojo.global(); - while(st.length){ + while (st.length) { func = st.shift(); - try{ + try { func.call(scope); - }catch(e){ - err += "\n"+func+" failed: "+e; + } + catch (e) { + err += "\n" + func + " failed: " + e; } } - if(err.length){ - var name = (st== this.loader.addOnLoads) ? "addOnLoad" : "addOnUnLoad"; - handleDefaults.call(this, name+" failure\n "+err, "onExecError", true); + if (err.length) { + var name = (st == this.loader.addOnLoads) ? "addOnLoad" : "addOnUnLoad"; + handleDefaults.call(this, name + " failure\n " + err, "onExecError", true); } - }; - - // push addOnLoad and addOnUnLoad functions onto stack - function stackPusher(st, obj, func){ - if(typeof func == 'undefined') { + } + function stackPusher(st, obj, func) { + if (typeof func == "undefined") { st.push(obj); - }else{ - st.push(function(){ obj[func](); }); + } else { + st.push(function () { + obj[func](); + }); } - }; - - // code saver, collects onLoad, onResized and isLoaded - function refreshed(){ + } + function refreshed() { this.onResized(); this.onLoad(); this.isLoaded = true; - }; - - // runs scripts and starts the content parser - function asyncParse(data){ - if(this.executeScripts){ + } + function asyncParse(data) { + if (this.executeScripts) { this.onExecScript.call(this, data.scripts); } - if(this.parseContent){ + if (this.parseContent) { this.onContentParse.call(this); } refreshed.call(this); - }; - - // run java function - function runHandler(){ - //FIXME: current behaviour is to return false if handler is there; is that intended? - if(dojo.lang.isFunction(this.handler)) { - this.handler(this, this.containerNode||this.domNode); + } + function runHandler() { + if (dojo.lang.isFunction(this.handler)) { + this.handler(this, this.containerNode || this.domNode); refreshed.call(this); return false; } return true; - }; - - // divided up splitAndFixPaths in different parts - this.htmlContentBasicFix = function(/*string*/s, /*string||dojo.uri.Uri*/url){ - // summary: - // strips out ***********/ - // khtml can't attach a