From a4835a7a18b7dacd9705f937f5f372b5f3f8a38f Mon Sep 17 00:00:00 2001 From: Musachy Barroso Date: Sat, 31 Mar 2007 14:20:00 +0000 Subject: [PATCH] WW-1536 Add a "cache" property to the head tag, that when true, uses an struts dojo profile, instead of standard dojo profile, enabling the browser to catch the downloaded javascript files git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@524433 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/struts2/dojo/components/Head.java | 13 +- .../struts2/dojo/views/jsp/ui/HeadTag.java | 6 + .../apache/struts2/static/dojo/struts_dojo.js | 17011 ++++++++++ .../dojo/struts_dojo.js.uncompressed.js | 27562 ++++++++++++++++ .../src/main/resources/template/ajax/head.ftl | 19 +- .../dojo/views/jsp/ui/HeadTagTest.java | 16 + .../dojo/views/jsp/ui/HeadTagTest-1.txt | 4 +- .../dojo/views/jsp/ui/HeadTagTest-2.txt | 24 + 8 files changed, 44649 insertions(+), 6 deletions(-) create mode 100644 plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/struts_dojo.js create mode 100644 plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/struts_dojo.js.uncompressed.js create mode 100644 plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/HeadTagTest-2.txt diff --git a/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Head.java b/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Head.java index 55601172c..0df4914e8 100644 --- a/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Head.java +++ b/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Head.java @@ -75,6 +75,7 @@ public class Head extends org.apache.struts2.components.Head { private String baseRelativePath; private String extraLocales; private String locale; + private String cache; public Head(ValueStack stack, HttpServletRequest request, HttpServletResponse response) { super(stack, request, response); @@ -99,6 +100,8 @@ public class Head extends org.apache.struts2.components.Head { } if (this.locale != null) addParameter("locale", findString(this.locale)); + if (this.cache != null) + addParameter("cache", findValue(this.cache, Boolean.class)); } @Override @@ -116,12 +119,12 @@ public class Head extends org.apache.struts2.components.Head { return debug != null && Boolean.parseBoolean(debug); } - @StrutsTagAttribute(description="Set to true to enable Dojo debug messages", defaultValue="false") + @StrutsTagAttribute(description="Enable Dojo debug messages", defaultValue="false", type="Boolean") public void setDebug(String debug) { this.debug = debug; } - @StrutsTagAttribute(description="Use compressed version of dojo.js", defaultValue="true") + @StrutsTagAttribute(description="Use compressed version of dojo.js", defaultValue="true", type="Boolean") public void setCompressed(String compressed) { this.compressed = compressed; } @@ -140,4 +143,10 @@ public class Head extends org.apache.struts2.components.Head { public void setLocale(String locale) { this.locale = locale; } + + @StrutsTagAttribute(description="Use Struts Dojo profile, which contains all Struts widgets in one file, making it possible to be chached by " + + "the browser", defaultValue="true", type="Boolean") + public void setCache(String cache) { + this.cache = cache; + } } diff --git a/plugins/dojo/src/main/java/org/apache/struts2/dojo/views/jsp/ui/HeadTag.java b/plugins/dojo/src/main/java/org/apache/struts2/dojo/views/jsp/ui/HeadTag.java index 41237824e..67e35ec48 100644 --- a/plugins/dojo/src/main/java/org/apache/struts2/dojo/views/jsp/ui/HeadTag.java +++ b/plugins/dojo/src/main/java/org/apache/struts2/dojo/views/jsp/ui/HeadTag.java @@ -41,6 +41,7 @@ public class HeadTag extends AbstractUITag { private String baseRelativePath; private String extraLocales; private String locale; + private String cache; public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) { return new Head(stack, req, res); @@ -55,6 +56,7 @@ public class HeadTag extends AbstractUITag { head.setBaseRelativePath(baseRelativePath); head.setExtraLocales(extraLocales); head.setLocale(locale); + head.setCache(cache); } public void setDebug(String debug) { @@ -76,4 +78,8 @@ public class HeadTag extends AbstractUITag { public void setLocale(String locale) { this.locale = locale; } + + public void setCache(String cache) { + this.cache = cache; + } } diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/struts_dojo.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/struts_dojo.js new file mode 100644 index 000000000..6f2f8e449 --- /dev/null +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/struts_dojo.js @@ -0,0 +1,17011 @@ +/* + 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 +*/ + +/* + This is a compiled version of Dojo, built for deployment and not for + development. To get an editable version, please visit: + + http://dojotoolkit.org + + for documentation and information on getting the source. +*/ + +if(typeof dojo=="undefined"){ +var dj_global=this; +var dj_currentContext=this; +function dj_undef(_1,_2){ +return (typeof (_2||dj_currentContext)[_1]=="undefined"); +} +if(dj_undef("djConfig",this)){ +var djConfig={}; +} +if(dj_undef("dojo",this)){ +var dojo={}; +} +dojo.global=function(){ +return dj_currentContext; +}; +dojo.locale=djConfig.locale; +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+")"; +} +}}; +dojo.evalProp=function(_3,_4,_5){ +if((!_4)||(!_3)){ +return undefined; +} +if(!dj_undef(_3,_4)){ +return _4[_3]; +} +return (_5?(_4[_3]={}):undefined); +}; +dojo.parseObjPath=function(_6,_7,_8){ +var _9=(_7||dojo.global()); +var _a=_6.split("."); +var _b=_a.pop(); +for(var i=0,l=_a.length;i1){ +dh.modulesLoadedListeners.push(function(){ +obj[_3d](); +}); +} +} +if(dh.post_load_&&dh.inFlightCount==0&&!dh.loadNotifying){ +dh.callLoaded(); +} +}; +dojo.addOnUnload=function(obj,_40){ +var dh=dojo.hostenv; +if(arguments.length==1){ +dh.unloadListeners.push(obj); +}else{ +if(arguments.length>1){ +dh.unloadListeners.push(function(){ +obj[_40](); +}); +} +} +}; +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"||(djConfig["useXDomain"]&&dojo.render.html.opera)){ +setTimeout("dojo.hostenv.loaded();",0); +}else{ +dojo.hostenv.loaded(); +} +}; +dojo.hostenv.getModuleSymbols=function(_42){ +var _43=_42.split("."); +for(var i=_43.length;i>0;i--){ +var _45=_43.slice(0,i).join("."); +if((i==1)&&!this.moduleHasPrefix(_45)){ +_43[0]="../"+_43[0]; +}else{ +var _46=this.getModulePrefix(_45); +if(_46!=_45){ +_43.splice(0,i,_46); +break; +} +} +} +return _43; +}; +dojo.hostenv._global_omit_module_check=false; +dojo.hostenv.loadModule=function(_47,_48,_49){ +if(!_47){ +return; +} +_49=this._global_omit_module_check||_49; +var _4a=this.findModule(_47,false); +if(_4a){ +return _4a; +} +if(dj_undef(_47,this.loading_modules_)){ +this.addedToLoadingCount.push(_47); +} +this.loading_modules_[_47]=1; +var _4b=_47.replace(/\./g,"/")+".js"; +var _4c=_47.split("."); +var _4d=this.getModuleSymbols(_47); +var _4e=((_4d[0].charAt(0)!="/")&&!_4d[0].match(/^\w+:/)); +var _4f=_4d[_4d.length-1]; +var ok; +if(_4f=="*"){ +_47=_4c.slice(0,-1).join("."); +while(_4d.length){ +_4d.pop(); +_4d.push(this.pkgFileName); +_4b=_4d.join("/")+".js"; +if(_4e&&_4b.charAt(0)=="/"){ +_4b=_4b.slice(1); +} +ok=this.loadPath(_4b,!_49?_47:null); +if(ok){ +break; +} +_4d.pop(); +} +}else{ +_4b=_4d.join("/")+".js"; +_47=_4c.join("."); +var _51=!_49?_47:null; +ok=this.loadPath(_4b,_51); +if(!ok&&!_48){ +_4d.pop(); +while(_4d.length){ +_4b=_4d.join("/")+".js"; +ok=this.loadPath(_4b,_51); +if(ok){ +break; +} +_4d.pop(); +_4b=_4d.join("/")+"/"+this.pkgFileName+".js"; +if(_4e&&_4b.charAt(0)=="/"){ +_4b=_4b.slice(1); +} +ok=this.loadPath(_4b,_51); +if(ok){ +break; +} +} +} +if(!ok&&!_49){ +dojo.raise("Could not load '"+_47+"'; last tried '"+_4b+"'"); +} +} +if(!_49&&!this["isXDomain"]){ +_4a=this.findModule(_47,false); +if(!_4a){ +dojo.raise("symbol '"+_47+"' is not defined after loading '"+_4b+"'"); +} +} +return _4a; +}; +dojo.hostenv.startPackage=function(_52){ +var _53=String(_52); +var _54=_53; +var _55=_52.split(/\./); +if(_55[_55.length-1]=="*"){ +_55.pop(); +_54=_55.join("."); +} +var _56=dojo.evalObjPath(_54,true); +this.loaded_modules_[_53]=_56; +this.loaded_modules_[_54]=_56; +return _56; +}; +dojo.hostenv.findModule=function(_57,_58){ +var lmn=String(_57); +if(this.loaded_modules_[lmn]){ +return this.loaded_modules_[lmn]; +} +if(_58){ +dojo.raise("no loaded module named '"+_57+"'"); +} +return null; +}; +dojo.kwCompoundRequire=function(_5a){ +var _5b=_5a["common"]||[]; +var _5c=_5a[dojo.hostenv.name_]?_5b.concat(_5a[dojo.hostenv.name_]||[]):_5b.concat(_5a["default"]||[]); +for(var x=0;x<_5c.length;x++){ +var _5e=_5c[x]; +if(_5e.constructor==Array){ +dojo.hostenv.loadModule.apply(dojo.hostenv,_5e); +}else{ +dojo.hostenv.loadModule(_5e); +} +} +}; +dojo.require=function(_5f){ +dojo.hostenv.loadModule.apply(dojo.hostenv,arguments); +}; +dojo.requireIf=function(_60,_61){ +var _62=arguments[0]; +if((_62===true)||(_62=="common")||(_62&&dojo.render[_62].capable)){ +var _63=[]; +for(var i=1;i0;i--){ +_74.push(_73.slice(0,i).join("-")); +} +_74.push(false); +if(_71){ +_74.reverse(); +} +for(var j=_74.length-1;j>=0;j--){ +var loc=_74[j]||"ROOT"; +var _78=_72(loc); +if(_78){ +break; +} +} +}; +dojo.hostenv.localesGenerated=["ROOT","es-es","es","it-it","pt-br","de","fr-fr","zh-cn","pt","en-us","zh","fr","zh-tw","it","en-gb","xx","de-de","ko-kr","ja-jp","ko","en","ja"]; +dojo.hostenv.registerNlsPrefix=function(){ +dojo.registerModulePath("nls","nls"); +}; +dojo.hostenv.preloadLocalizations=function(){ +if(dojo.hostenv.localesGenerated){ +dojo.hostenv.registerNlsPrefix(); +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 _8a=_87.replace("-","_"); +var _8b=_83+"."+_8a; +_89=dojo.hostenv.findModule(_8b); +} +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"){ +_93.push(loc); +} +_93.push(_7f); +var _94=_93.join("/")+".js"; +_92=dojo.hostenv.loadPath(_94,null,function(_95){ +var _96=function(){ +}; +_96.prototype=_8e; +_88[_90]=new _96(); +for(var j in _95){ +_88[_90][j]=_95[j]; +} +}); +}else{ +_92=true; +} +if(_92&&_88[_90]){ +_8e=_88[_90]; +}else{ +_88[_90]=_8e; +} +if(_81){ +return true; +} +}); +} +if(_81&&_82!=_84){ +_88[_82.replace("-","_")]=_88[_84.replace("-","_")]; +} +}; +(function(){ +var _98=djConfig.extraLocale; +if(_98){ +if(!_98 instanceof Array){ +_98=[_98]; +} +var req=dojo.requireLocalization; +dojo.requireLocalization=function(m,b,_9c,_9d){ +req(m,b,_9c,_9d); +if(_9c){ +return; +} +for(var i=0;i<_98.length;i++){ +req(m,b,_98[i],_9d); +} +}; +} +})(); +} +if(typeof window!="undefined"){ +(function(){ +if(djConfig.allowQueryConfig){ +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{ +djConfig[opt]=eval(sp[1]); +} +catch(e){ +djConfig[opt]=sp[1]; +} +} +} +} +} +if(((djConfig["baseScriptUri"]=="")||(djConfig["baseRelativePath"]==""))&&(document&&document.getElementsByTagName)){ +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(_a7); +if(m){ +var _ab=src.substring(0,m.index); +if(src.indexOf("bootstrap1")>-1){ +_ab+="../"; +} +if(!this["djConfig"]){ +djConfig={}; +} +if(djConfig["baseScriptUri"]==""){ +djConfig["baseScriptUri"]=_ab; +} +if(djConfig["baseRelativePath"]==""){ +djConfig["baseRelativePath"]=_ab; +} +break; +} +} +} +var dr=dojo.render; +var drh=dojo.render.html; +var drs=dojo.render.svg; +var dua=(drh.UA=navigator.userAgent); +var dav=(drh.AV=navigator.appVersion); +var t=true; +var f=false; +drh.capable=t; +drh.support.builtin=t; +dr.ver=parseFloat(drh.AV); +dr.os.mac=dav.indexOf("Macintosh")>=0; +dr.os.win=dav.indexOf("Windows")>=0; +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 _b3=dua.indexOf("Gecko"); +drh.mozilla=drh.moz=(_b3>=0)&&(!drh.khtml); +if(drh.mozilla){ +drh.geckoVersion=dua.substring(_b3+6,_b3+14); +} +drh.ie=(document.all)&&(!drh.opera); +drh.ie50=drh.ie&&dav.indexOf("MSIE 5.0")>=0; +drh.ie55=drh.ie&&dav.indexOf("MSIE 5.5")>=0; +drh.ie60=drh.ie&&dav.indexOf("MSIE 6.0")>=0; +drh.ie70=drh.ie&&dav.indexOf("MSIE 7.0")>=0; +var cm=document["compatMode"]; +drh.quirks=(cm=="BackCompat")||(cm=="QuirksMode")||drh.ie55||drh.ie50; +dojo.locale=dojo.locale||(drh.ie?navigator.userLanguage:navigator.language).toLowerCase(); +dr.vml.capable=drh.ie; +drs.capable=f; +drs.support.plugin=f; +drs.support.builtin=f; +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; +drs.support.plugin=f; +} +if(drh.safari){ +var tmp=dua.split("AppleWebKit/")[1]; +var ver=parseFloat(tmp.split(" ")[0]); +if(ver>=420){ +drs.capable=t; +drs.support.builtin=t; +drs.support.plugin=f; +} +}else{ +} +})(); +dojo.hostenv.startPackage("dojo.hostenv"); +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 _b9=null; +var _ba=null; +try{ +_b9=new XMLHttpRequest(); +} +catch(e){ +} +if(!_b9){ +for(var i=0;i<3;++i){ +var _bc=dojo.hostenv._XMLHTTP_PROGIDS[i]; +try{ +_b9=new ActiveXObject(_bc); +} +catch(e){ +_ba=e; +} +if(_b9){ +dojo.hostenv._XMLHTTP_PROGIDS=[_bc]; +break; +} +} +} +if(!_b9){ +return dojo.raise("XMLHTTP not available",_ba); +} +return _b9; +}; +dojo.hostenv._blockAsync=false; +dojo.hostenv.getText=function(uri,_be,_bf){ +if(!_be){ +this._blockAsync=true; +} +var _c0=this.getXmlhttpObject(); +function isDocumentOk(_c1){ +var _c2=_c1["status"]; +return Boolean((!_c2)||((200<=_c2)&&(300>_c2))||(_c2==304)); +} +if(_be){ +var _c3=this,_c4=null,gbl=dojo.global(); +var xhr=dojo.evalObjPath("dojo.io.XMLHTTPTransport"); +_c0.onreadystatechange=function(){ +if(_c4){ +gbl.clearTimeout(_c4); +_c4=null; +} +if(_c3._blockAsync||(xhr&&xhr._blockAsync)){ +_c4=gbl.setTimeout(function(){ +_c0.onreadystatechange.apply(this); +},10); +}else{ +if(4==_c0.readyState){ +if(isDocumentOk(_c0)){ +_be(_c0.responseText); +} +} +} +}; +} +_c0.open("GET",uri,_be?true:false); +try{ +_c0.send(null); +if(_be){ +return null; +} +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((_bf)&&(!_be)){ +return null; +}else{ +throw e; +} +} +this._blockAsync=false; +return _c0.responseText; +}; +dojo.hostenv.defaultDebugContainerId="dojoDebug"; +dojo.hostenv._println_buffer=[]; +dojo.hostenv._println_safe=false; +dojo.hostenv.println=function(_c8){ +if(!dojo.hostenv._println_safe){ +dojo.hostenv._println_buffer.push(_c8); +}else{ +try{ +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(_c8)); +_c9.appendChild(div); +} +catch(e){ +try{ +document.write("
"+_c8+"
"); +} +catch(e2){ +window.status=_c8; +} +} +} +}; +dojo.addOnLoad(function(){ +dojo.hostenv._println_safe=true; +while(dojo.hostenv._println_buffer.length>0){ +dojo.hostenv.println(dojo.hostenv._println_buffer.shift()); +} +}); +function dj_addNodeEvtHdlr(_cb,_cc,fp){ +var _ce=_cb["on"+_cc]||function(){ +}; +_cb["on"+_cc]=function(){ +fp.apply(_cb,arguments); +_ce.apply(_cb,arguments); +}; +return true; +} +function dj_load_init(e){ +var _d0=(e&&e.type)?e.type.toLowerCase():"load"; +if(arguments.callee.initialized||(_d0!="domcontentloaded"&&_d0!="load")){ +return; +} +arguments.callee.initialized=true; +if(typeof (_timer)!="undefined"){ +clearInterval(_timer); +delete _timer; +} +var _d1=function(){ +if(dojo.render.html.ie){ +dojo.hostenv.makeWidgets(); +} +}; +if(dojo.hostenv.inFlightCount==0){ +_d1(); +dojo.hostenv.modulesLoaded(); +}else{ +dojo.hostenv.modulesLoadedListeners.unshift(_d1); +} +} +if(document.addEventListener){ +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); +} +if(dojo.render.html.ie&&dojo.render.os.win){ +document.attachEvent("onreadystatechange",function(e){ +if(document.readyState=="complete"){ +dj_load_init(); +} +}); +} +if(/(WebKit|khtml)/i.test(navigator.userAgent)){ +var _timer=setInterval(function(){ +if(/loaded|complete/.test(document.readyState)){ +dj_load_init(); +} +},10); +} +if(dojo.render.html.ie){ +dj_addNodeEvtHdlr(window,"beforeunload",function(){ +dojo.hostenv._unloading=true; +window.setTimeout(function(){ +dojo.hostenv._unloading=false; +},0); +}); +} +dj_addNodeEvtHdlr(window,"unload",function(){ +dojo.hostenv.unloaded(); +if((!dojo.render.html.ie)||(dojo.render.html.ie&&dojo.hostenv._unloading)){ +dojo.hostenv.unloaded(); +} +}); +dojo.hostenv.makeWidgets=function(){ +var _d3=[]; +if(djConfig.searchIds&&djConfig.searchIds.length>0){ +_d3=_d3.concat(djConfig.searchIds); +} +if(dojo.hostenv.searchIds&&dojo.hostenv.searchIds.length>0){ +_d3=_d3.concat(dojo.hostenv.searchIds); +} +if((djConfig.parseWidgets)||(_d3.length>0)){ +if(dojo.evalObjPath("dojo.widget.Parse")){ +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 _d7=_d4.parseElement(_d6,null,true); +dojo.widget.getParser().createComponents(_d7); +} +}else{ +if(djConfig.parseWidgets){ +var _d7=_d4.parseElement(dojo.body(),null,true); +dojo.widget.getParser().createComponents(_d7); +} +} +} +} +}; +dojo.addOnLoad(function(){ +if(!dojo.render.html.ie){ +dojo.hostenv.makeWidgets(); +} +}); +try{ +if(dojo.render.html.ie){ +document.namespaces.add("v","urn:schemas-microsoft-com:vml"); +document.createStyleSheet().addRule("v\\:*","behavior:url(#default#VML)"); +} +} +catch(e){ +} +dojo.hostenv.writeIncludes=function(){ +}; +if(!dj_undef("document",this)){ +dj_currentDocument=this.document; +} +dojo.doc=function(){ +return dj_currentDocument; +}; +dojo.body=function(){ +return dojo.doc().body||dojo.doc().getElementsByTagName("body")[0]; +}; +dojo.byId=function(id,doc){ +if((id)&&((typeof id=="string")||(id instanceof String))){ +if(!doc){ +doc=dj_currentDocument; +} +var ele=doc.getElementById(id); +if(ele&&(ele.id!=id)&&doc.all){ +ele=null; +eles=doc.all[id]; +if(eles){ +if(eles.length){ +for(var i=0;i0)?(/^\s+/):(wh<0)?(/\s+$/):(/^\s+|\s+$/g); +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(str,_f4,_f5){ +var out=""; +for(var i=0;i<_f4;i++){ +out+=str; +if(_f5&&i<_f4-1){ +out+=_f5; +} +} +return out; +}; +dojo.string.pad=function(str,len,c,dir){ +var out=String(str); +if(!c){ +c="0"; +} +if(!dir){ +dir=1; +} +while(out.length0){ +out=c+out; +}else{ +out+=c; +} +} +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.provide("dojo.string"); +dojo.provide("dojo.lang.common"); +dojo.lang.inherits=function(_103,_104){ +if(!dojo.lang.isFunction(_104)){ +dojo.raise("dojo.inherits: superclass argument ["+_104+"] must be a function (subclass: ["+_103+"']"); +} +_103.prototype=new _104(); +_103.prototype.constructor=_103; +_103.superclass=_104.prototype; +_103["super"]=_104.prototype; +}; +dojo.lang._mixin=function(obj,_106){ +var tobj={}; +for(var x in _106){ +if((typeof tobj[x]=="undefined")||(tobj[x]!=_106[x])){ +obj[x]=_106[x]; +} +} +if(dojo.render.html.ie&&(typeof (_106["toString"])=="function")&&(_106["toString"]!=obj["toString"])&&(_106["toString"]!=tobj["toString"])){ +obj.toString=_106.toString; +} +return obj; +}; +dojo.lang.mixin=function(obj,_10a){ +for(var i=1,l=arguments.length;i-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.provide("dojo.lang.extras"); +dojo.lang.setTimeout=function(func,_12a){ +var _12b=window,_12c=2; +if(!dojo.lang.isFunction(func)){ +_12b=func; +func=_12a; +_12a=arguments[2]; +_12c++; +} +if(dojo.lang.isString(func)){ +func=_12b[func]; +} +var args=[]; +for(var i=_12c;i0){ +dojo.io.bind(dojo.io._bindQueue.shift()); +}else{ +dojo.io._queueBindInFlight=false; +} +} +}; +dojo.io._bindQueue=[]; +dojo.io._queueBindInFlight=false; +dojo.io.argsFromMap=function(map,_168,last){ +var enc=/utf/i.test(_168||"")?encodeURIComponent:dojo.string.encodeAscii; +var _16b=[]; +var _16c=new Object(); +for(var name in map){ +var _16e=function(elt){ +var val=enc(name)+"="+enc(elt); +_16b[(last==name)?"push":"unshift"](val); +}; +if(!_16c[name]){ +var _171=map[name]; +if(dojo.lang.isArray(_171)){ +dojo.lang.forEach(_171,_16e); +}else{ +_16e(_171); +} +} +} +return _16b.join("&"); +}; +dojo.io.setIFrameSrc=function(_172,src,_174){ +try{ +var r=dojo.render.html; +if(!_174){ +if(r.safari){ +_172.location=src; +}else{ +frames[_172.name].location=src; +} +}else{ +var idoc; +if(r.ie){ +idoc=_172.contentWindow.document; +}else{ +if(r.safari){ +idoc=_172.document; +}else{ +idoc=_172.contentWindow; +} +} +if(!idoc){ +_172.location=src; +return; +}else{ +idoc.location.replace(src); +} +} +} +catch(e){ +dojo.debug(e); +dojo.debug("setIFrameSrc: "+e); +} +}; +dojo.provide("dojo.lang.array"); +dojo.lang.mixin(dojo.lang,{has:function(obj,name){ +try{ +return typeof obj[name]!="undefined"; +} +catch(e){ +return false; +} +},isEmpty:function(obj){ +if(dojo.lang.isObject(obj)){ +var tmp={}; +var _17b=0; +for(var x in obj){ +if(obj[x]&&(!tmp[x])){ +_17b++; +break; +} +} +return _17b==0; +}else{ +if(dojo.lang.isArrayLike(obj)||dojo.lang.isString(obj)){ +return obj.length==0; +} +} +},map:function(arr,obj,_17f){ +var _180=dojo.lang.isString(arr); +if(_180){ +arr=arr.split(""); +} +if(dojo.lang.isFunction(obj)&&(!_17f)){ +_17f=obj; +obj=dj_global; +}else{ +if(dojo.lang.isFunction(obj)&&_17f){ +var _181=obj; +obj=_17f; +_17f=_181; +} +} +if(Array.map){ +var _182=Array.map(arr,_17f,obj); +}else{ +var _182=[]; +for(var i=0;i=3){ +dojo.raise("thisObject doesn't exist!"); +} +_1a0=dj_global; +} +_1a2=[]; +for(var i=0;i/gm,">").replace(/"/gm,"""); +if(!_1e1){ +str=str.replace(/'/gm,"'"); +} +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,_1ea){ +if(_1ea){ +str=str.toLowerCase(); +end=end.toLowerCase(); +} +if((str.length-end.length)<0){ +return false; +} +return str.lastIndexOf(end)==str.length-end.length; +}; +dojo.string.endsWithAny=function(str){ +for(var i=1;i-1){ +return true; +} +} +return false; +}; +dojo.string.normalizeNewlines=function(text,_1f5){ +if(_1f5=="\n"){ +text=text.replace(/\r\n/g,"\n"); +text=text.replace(/\r/g,"\n"); +}else{ +if(_1f5=="\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; +}; +dojo.string.splitEscaped=function(str,_1f7){ +var _1f8=[]; +for(var i=0,_1fa=0;i0){ +return _21d[0]; +} +node=node.parentNode; +} +if(_21c){ +return null; +} +return _21d; +}; +dojo.dom.getAncestorsByTag=function(node,tag,_221){ +tag=tag.toLowerCase(); +return dojo.dom.getAncestors(node,function(el){ +return ((el.tagName)&&(el.tagName.toLowerCase()==tag)); +},_221); +}; +dojo.dom.getFirstAncestorByTag=function(node,tag){ +return dojo.dom.getAncestorsByTag(node,tag,true); +}; +dojo.dom.isDescendantOf=function(node,_226,_227){ +if(_227&&node){ +node=node.parentNode; +} +while(node){ +if(node==_226){ +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 _22a=dojo.doc(); +if(!dj_undef("ActiveXObject")){ +var _22b=["MSXML2","Microsoft","MSXML","MSXML3"]; +for(var i=0;i<_22b.length;i++){ +try{ +doc=new ActiveXObject(_22b[i]+".XMLDOM"); +} +catch(e){ +} +if(doc){ +break; +} +} +}else{ +if((_22a.implementation)&&(_22a.implementation.createDocument)){ +doc=_22a.implementation.createDocument("","",null); +} +} +return doc; +}; +dojo.dom.createDocumentFromText=function(str,_22e){ +if(!_22e){ +_22e="text/xml"; +} +if(!dj_undef("DOMParser")){ +var _22f=new DOMParser(); +return _22f.parseFromString(str,_22e); +}else{ +if(!dj_undef("ActiveXObject")){ +var _230=dojo.dom.createDocument(); +if(_230){ +_230.async=false; +_230.loadXML(str); +return _230; +}else{ +dojo.debug("toXml didn't work?"); +} +}else{ +var _231=dojo.doc(); +if(_231.createElement){ +var tmp=_231.createElement("xml"); +tmp.innerHTML=str; +if(_231.implementation&&_231.implementation.createDocument){ +var _233=_231.implementation.createDocument("foo","",null); +for(var i=0;i1){ +var _248=dojo.doc(); +dojo.dom.replaceChildren(node,_248.createTextNode(text)); +return text; +}else{ +if(node.textContent!=undefined){ +return node.textContent; +} +var _249=""; +if(node==null){ +return _249; +} +for(var i=0;i"); +} +} +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:(!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){ +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 _258=args["back"]||args["backButton"]||args["handle"]; +var tcb=function(_25a){ +if(window.location.hash!=""){ +setTimeout("window.location.href = '"+hash+"';",1); +} +_258.apply(this,[_25a]); +}; +if(args["back"]){ +args.back=tcb; +}else{ +if(args["backButton"]){ +args.backButton=tcb; +}else{ +if(args["handle"]){ +args.handle=tcb; +} +} +} +var _25b=args["forward"]||args["forwardButton"]||args["handle"]; +var tfw=function(_25d){ +if(window.location.hash!=""){ +window.location.href=hash; +} +if(_25b){ +_25b.apply(this,[_25d]); +} +}; +if(args["forward"]){ +args.forward=tfw; +}else{ +if(args["forwardButton"]){ +args.forwardButton=tfw; +}else{ +if(args["handle"]){ +args.handle=tfw; +} +} +} +}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)){ +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; +} +} +} +},iframeLoaded:function(evt,_260){ +if(!dojo.render.html.opera){ +var _261=this._getUrlQuery(_260.href); +if(_261==null){ +if(this.historyStack.length==1){ +this.handleBackButton(); +} +return; +} +if(this.moveForward){ +this.moveForward=false; +return; +} +if(this.historyStack.length>=2&&_261==this._getUrlQuery(this.historyStack[this.historyStack.length-2].url)){ +this.handleBackButton(); +}else{ +if(this.forwardStack.length>0&&_261==this._getUrlQuery(this.forwardStack[this.forwardStack.length-1].url)){ +this.handleForwardButton(); +} +} +} +},handleBackButton:function(){ +var _262=this.historyStack.pop(); +if(!_262){ +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"); +} +} +} +} +this.forwardStack.push(_262); +},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 _269=url.split("?"); +if(_269.length<2){ +return null; +}else{ +return _269[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; +}}; +dojo.provide("dojo.io.BrowserIO"); +if(!dj_undef("window")){ +dojo.io.checkChildrenForFile=function(node){ +var _26c=false; +var _26d=node.getElementsByTagName("input"); +dojo.lang.forEach(_26d,function(_26e){ +if(_26c){ +return; +} +if(_26e.getAttribute("type")=="file"){ +_26c=true; +} +}); +return _26c; +}; +dojo.io.formHasFile=function(_26f){ +return dojo.io.checkChildrenForFile(_26f); +}; +dojo.io.updateNode=function(node,_271){ +node=dojo.byId(node); +var args=_271; +if(dojo.lang.isString(_271)){ +args={url:_271}; +} +args.mimetype="text/html"; +args.load=function(t,d,e){ +while(node.firstChild){ +dojo.dom.destroyNode(node.firstChild); +} +node.innerHTML=d; +}; +dojo.io.bind(args); +}; +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(_278,_279,_27a){ +if((!_278)||(!_278.tagName)||(!_278.tagName.toLowerCase()=="form")){ +dojo.raise("Attempted to encode a non-form element."); +} +if(!_27a){ +_27a=dojo.io.formFilter; +} +var enc=/utf/i.test(_279||"")?encodeURIComponent:dojo.string.encodeAscii; +var _27c=[]; +for(var i=0;i<_278.elements.length;i++){ +var elm=_278.elements[i]; +if(!elm||elm.tagName.toLowerCase()=="fieldset"||!_27a(elm)){ +continue; +} +var name=enc(elm.name); +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(_2a3.method.toLowerCase()=="head"){ +var _2a9=http.getAllResponseHeaders(); +ret={}; +ret.toString=function(){ +return _2a9; +}; +var _2aa=_2a9.split(/[\r\n]+/g); +for(var i=0;i<_2aa.length;i++){ +var pair=_2aa[i].match(/^([^:]+)\s*:\s*(.+)$/i); +if(pair){ +ret[pair[1]]=pair[2]; +} +} +}else{ +if(_2a3.mimetype=="text/javascript"){ +try{ +ret=dj_eval(http.responseText); +} +catch(e){ +dojo.debug(e); +dojo.debug(http.responseText); +ret=null; +} +}else{ +if(_2a3.mimetype=="text/json"||_2a3.mimetype=="application/json"){ +try{ +ret=dj_eval("("+http.responseText+")"); +} +catch(e){ +dojo.debug(e); +dojo.debug(http.responseText); +ret=false; +} +}else{ +if((_2a3.mimetype=="application/xml")||(_2a3.mimetype=="text/xml")){ +ret=http.responseXML; +if(!ret||typeof ret=="string"||!http.getResponseHeader("Content-Type")){ +ret=dojo.dom.createDocumentFromText(http.responseText); +} +}else{ +ret=http.responseText; +} +} +} +} +if(_2a7){ +addToCache(url,_2a6,_2a3.method,http); +} +_2a3[(typeof _2a3.load=="function")?"load":"handle"]("load",ret,http,_2a3); +}else{ +var _2ad=new dojo.io.Error("XMLHttpTransport Error: "+http.status+" "+http.statusText); +_2a3[(typeof _2a3.error=="function")?"error":"handle"]("error",_2ad,http,_2a3); +} +} +function setHeaders(http,_2af){ +if(_2af["headers"]){ +for(var _2b0 in _2af["headers"]){ +if(_2b0.toLowerCase()=="content-type"&&!_2af["contentType"]){ +_2af["contentType"]=_2af["headers"][_2b0]; +}else{ +http.setRequestHeader(_2b0,_2af["headers"][_2b0]); +} +} +} +} +this.inFlight=[]; +this.inFlightTimer=null; +this.startWatchingInFlight=function(){ +if(!this.inFlightTimer){ +this.inFlightTimer=setTimeout("dojo.io.XMLHTTPTransport.watchInFlight();",10); +} +}; +this.watchInFlight=function(){ +var now=null; +if(!dojo.hostenv._blockAsync&&!_297._blockAsync){ +for(var x=this.inFlight.length-1;x>=0;x--){ +try{ +var tif=this.inFlight[x]; +if(!tif||tif.http._aborted||!tif.http.readyState){ +this.inFlight.splice(x,1); +continue; +} +if(4==tif.http.readyState){ +this.inFlight.splice(x,1); +doLoad(tif.req,tif.http,tif.url,tif.query,tif.useCache); +}else{ +if(tif.startTime){ +if(!now){ +now=(new Date()).getTime(); +} +if(tif.startTime+(tif.req.timeoutSeconds*1000)-1){ +dojo.debug("Warning: dojo.io.bind: stripping hash values from url:",url); +url=url.split("#")[0]; +} +if(_2b7["file"]){ +_2b7.method="post"; +} +if(!_2b7["method"]){ +_2b7.method="get"; +} +if(_2b7.method.toLowerCase()=="get"){ +_2b7.multipart=false; +}else{ +if(_2b7["file"]){ +_2b7.multipart=true; +}else{ +if(!_2b7["multipart"]){ +_2b7.multipart=false; +} +} +} +if(_2b7["backButton"]||_2b7["back"]||_2b7["changeUrl"]){ +dojo.undo.browser.addToHistory(_2b7); +} +var _2bc=_2b7["content"]||{}; +if(_2b7.sendTransport){ +_2bc["dojo.transport"]="xmlhttp"; +} +do{ +if(_2b7.postContent){ +_2b9=_2b7.postContent; +break; +} +if(_2bc){ +_2b9+=dojo.io.argsFromMap(_2bc,_2b7.encoding); +} +if(_2b7.method.toLowerCase()=="get"||!_2b7.multipart){ +break; +} +var t=[]; +if(_2b9.length){ +var q=_2b9.split("&"); +for(var i=0;i-1?"&":"?")+_2b9; +} +if(_2c3){ +_2c9+=(dojo.string.endsWithAny(_2c9,"?","&")?"":(_2c9.indexOf("?")>-1?"&":"?"))+"dojo.preventCache="+new Date().valueOf(); +} +if(!_2b7.user){ +http.open(_2b7.method.toUpperCase(),_2c9,_2c2); +}else{ +http.open(_2b7.method.toUpperCase(),_2c9,_2c2,_2b7.user,_2b7.password); +} +setHeaders(http,_2b7); +try{ +http.send(null); +} +catch(e){ +if(typeof http.abort=="function"){ +http.abort(); +} +doLoad(_2b7,{status:404},url,_2b9,_2c4); +} +} +if(!_2c2){ +doLoad(_2b7,http,url,_2b9,_2c4); +_297._blockAsync=false; +} +_2b7.abort=function(){ +try{ +http._aborted=true; +} +catch(e){ +} +return http.abort(); +}; +return; +}; +dojo.io.transports.addTransport("XMLHTTPTransport"); +}; +} +dojo.provide("dojo.io.cookie"); +dojo.io.cookie.setCookie=function(name,_2cb,days,path,_2ce,_2cf){ +var _2d0=-1; +if((typeof days=="number")&&(days>=0)){ +var d=new Date(); +d.setTime(d.getTime()+(days*24*60*60*1000)); +_2d0=d.toGMTString(); +} +_2cb=escape(_2cb); +document.cookie=name+"="+_2cb+";"+(_2d0!=-1?" expires="+_2d0+";":"")+(path?"path="+path:"")+(_2ce?"; domain="+_2ce:"")+(_2cf?"; secure":""); +}; +dojo.io.cookie.set=dojo.io.cookie.setCookie; +dojo.io.cookie.getCookie=function(name){ +var idx=document.cookie.lastIndexOf(name+"="); +if(idx==-1){ +return null; +} +var _2d4=document.cookie.substring(idx+name.length+1); +var end=_2d4.indexOf(";"); +if(end==-1){ +end=_2d4.length; +} +_2d4=_2d4.substring(0,end); +_2d4=unescape(_2d4); +return _2d4; +}; +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,_2db,_2dc,_2dd){ +if(arguments.length==5){ +_2dd=_2db; +_2db=null; +_2dc=null; +} +var _2de=[],_2df,_2e0=""; +if(!_2dd){ +_2df=dojo.io.cookie.getObjectCookie(name); +} +if(days>=0){ +if(!_2df){ +_2df={}; +} +for(var prop in obj){ +if(obj[prop]==null){ +delete _2df[prop]; +}else{ +if((typeof obj[prop]=="string")||(typeof obj[prop]=="number")){ +_2df[prop]=obj[prop]; +} +} +} +prop=null; +for(var prop in _2df){ +_2de.push(escape(prop)+"="+escape(_2df[prop])); +} +_2e0=_2de.join("&"); +} +dojo.io.cookie.setCookie(name,_2e0,days,path,_2db,_2dc); +}; +dojo.io.cookie.getObjectCookie=function(name){ +var _2e3=null,_2e4=dojo.io.cookie.getCookie(name); +if(_2e4){ +_2e3={}; +var _2e5=_2e4.split("&"); +for(var i=0;i<_2e5.length;i++){ +var pair=_2e5[i].split("="); +var _2e8=pair[1]; +if(isNaN(_2e8)){ +_2e8=unescape(pair[1]); +} +_2e3[unescape(pair[0])]=_2e8; +} +} +return _2e3; +}; +dojo.io.cookie.isSupported=function(){ +if(typeof navigator.cookieEnabled!="boolean"){ +dojo.io.cookie.setCookie("__TestingYourBrowserForCookieSupport__","CookiesAllowed",90,null); +var _2e9=dojo.io.cookie.getCookie("__TestingYourBrowserForCookieSupport__"); +navigator.cookieEnabled=(_2e9=="CookiesAllowed"); +if(navigator.cookieEnabled){ +this.deleteCookie("__TestingYourBrowserForCookieSupport__"); +} +} +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.event.common"); +dojo.event=new function(){ +this._canTimeout=dojo.lang.isFunction(dj_global["setTimeout"])||dojo.lang.isAlien(dj_global["setTimeout"]); +function interpolateArgs(args,_2eb){ +var dl=dojo.lang; +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; +case 1: +return; +case 2: +ao.srcFunc=args[0]; +ao.adviceFunc=args[1]; +break; +case 3: +if((dl.isObject(args[0]))&&(dl.isString(args[1]))&&(dl.isString(args[2]))){ +ao.adviceType="after"; +ao.srcObj=args[0]; +ao.srcFunc=args[1]; +ao.adviceFunc=args[2]; +}else{ +if((dl.isString(args[1]))&&(dl.isString(args[2]))){ +ao.srcFunc=args[1]; +ao.adviceFunc=args[2]; +}else{ +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 _2ee=dl.nameAnonFunc(args[2],ao.adviceObj,_2eb); +ao.adviceFunc=_2ee; +}else{ +if((dl.isFunction(args[0]))&&(dl.isObject(args[1]))&&(dl.isString(args[2]))){ +ao.adviceType="after"; +ao.srcObj=dj_global; +var _2ee=dl.nameAnonFunc(args[0],ao.srcObj,_2eb); +ao.srcFunc=_2ee; +ao.adviceObj=args[1]; +ao.adviceFunc=args[2]; +} +} +} +} +break; +case 4: +if((dl.isObject(args[0]))&&(dl.isObject(args[2]))){ +ao.adviceType="after"; +ao.srcObj=args[0]; +ao.srcFunc=args[1]; +ao.adviceObj=args[2]; +ao.adviceFunc=args[3]; +}else{ +if((dl.isString(args[0]))&&(dl.isString(args[1]))&&(dl.isObject(args[2]))){ +ao.adviceType=args[0]; +ao.srcObj=dj_global; +ao.srcFunc=args[1]; +ao.adviceObj=args[2]; +ao.adviceFunc=args[3]; +}else{ +if((dl.isString(args[0]))&&(dl.isFunction(args[1]))&&(dl.isObject(args[2]))){ +ao.adviceType=args[0]; +ao.srcObj=dj_global; +var _2ee=dl.nameAnonFunc(args[1],dj_global,_2eb); +ao.srcFunc=_2ee; +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 _2ee=dl.nameAnonFunc(args[3],dj_global,_2eb); +ao.adviceObj=dj_global; +ao.adviceFunc=_2ee; +}else{ +if(dl.isObject(args[1])){ +ao.srcObj=args[1]; +ao.srcFunc=args[2]; +ao.adviceObj=dj_global; +ao.adviceFunc=args[3]; +}else{ +if(dl.isObject(args[2])){ +ao.srcObj=dj_global; +ao.srcFunc=args[1]; +ao.adviceObj=args[2]; +ao.adviceFunc=args[3]; +}else{ +ao.srcObj=ao.adviceObj=ao.aroundObj=dj_global; +ao.srcFunc=args[1]; +ao.adviceFunc=args[2]; +ao.aroundFunc=args[3]; +} +} +} +} +} +} +break; +case 6: +ao.srcObj=args[1]; +ao.srcFunc=args[2]; +ao.adviceObj=args[3]; +ao.adviceFunc=args[4]; +ao.aroundFunc=args[5]; +ao.aroundObj=dj_global; +break; +default: +ao.srcObj=args[1]; +ao.srcFunc=args[2]; +ao.adviceObj=args[3]; +ao.adviceFunc=args[4]; +ao.aroundObj=args[5]; +ao.aroundFunc=args[6]; +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 _2ee=dl.nameAnonFunc(ao.aroundFunc,ao.aroundObj,_2eb); +ao.aroundFunc=_2ee; +} +if(dl.isFunction(ao.srcFunc)){ +ao.srcFunc=dl.getNameInObj(ao.srcObj,ao.srcFunc); +} +if(dl.isFunction(ao.adviceFunc)){ +ao.adviceFunc=dl.getNameInObj(ao.adviceObj,ao.adviceFunc); +} +if((ao.aroundObj)&&(dl.isFunction(ao.aroundFunc))){ +ao.aroundFunc=dl.getNameInObj(ao.aroundObj,ao.aroundFunc); +} +if(!ao.srcObj){ +dojo.raise("bad srcObj for srcFunc: "+ao.srcFunc); +} +if(!ao.adviceObj){ +dojo.raise("bad adviceObj for adviceFunc: "+ao.adviceFunc); +} +if(!ao.adviceFunc){ +dojo.debug("bad adviceFunc for srcFunc: "+ao.srcFunc); +dojo.debugShallow(ao); +} +return ao; +} +this.connect=function(){ +if(arguments.length==1){ +var ao=arguments[0]; +}else{ +var ao=interpolateArgs(arguments,true); +} +if(dojo.lang.isArray(ao.srcObj)&&ao.srcObj!=""){ +var _2f0={}; +for(var x in ao){ +_2f0[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); +} +_2f0.srcObj=src; +mjps.push(dojo.event.connect.call(dojo.event,_2f0)); +}); +return mjps; +} +var mjp=dojo.event.MethodJoinPoint.getForMethod(ao.srcObj,ao.srcFunc); +if(ao.adviceFunc){ +var mjp2=dojo.event.MethodJoinPoint.getForMethod(ao.adviceObj,ao.adviceFunc); +} +mjp.kwAddAdvice(ao); +return mjp; +}; +this.log=function(a1,a2){ +var _2f8; +if((arguments.length==1)&&(typeof a1=="object")){ +_2f8=a1; +}else{ +_2f8={srcObj:a1,srcFunc:a2}; +} +_2f8.adviceFunc=function(){ +var _2f9=[]; +for(var x=0;x=this.jp_.around.length){ +return this.jp_.object[this.jp_.methodname].apply(this.jp_.object,this.args); +}else{ +var ti=this.jp_.around[this.around_index]; +var mobj=ti[0]||dj_global; +var meth=ti[1]; +return mobj[meth].call(mobj,this); +} +}; +dojo.event.MethodJoinPoint=function(obj,_311){ +this.object=obj||dj_global; +this.methodname=_311; +this.methodfunc=this.object[_311]; +this.squelch=false; +}; +dojo.event.MethodJoinPoint.getForMethod=function(obj,_313){ +if(!obj){ +obj=dj_global; +} +var ofn=obj[_313]; +if(!ofn){ +ofn=obj[_313]=function(){ +}; +if(!obj[_313]){ +dojo.raise("Cannot set do-nothing method on that object "+_313); +} +}else{ +if((typeof ofn!="function")&&(!dojo.lang.isFunction(ofn))&&(!dojo.lang.isAlien(ofn))){ +return null; +} +} +var _315=_313+"$joinpoint"; +var _316=_313+"$joinpoint$method"; +var _317=obj[_315]; +if(!_317){ +var _318=false; +if(dojo.event["browser"]){ +if((obj["attachEvent"])||(obj["nodeType"])||(obj["addEventListener"])){ +_318=true; +dojo.event.browser.addClobberNodeAttrs(obj,[_315,_316,_313]); +} +} +var _319=ofn.length; +obj[_316]=ofn; +_317=obj[_315]=new dojo.event.MethodJoinPoint(obj,_316); +if(!_318){ +obj[_313]=function(){ +return _317.run.apply(_317,arguments); +}; +}else{ +obj[_313]=function(){ +var args=[]; +if(!arguments.length){ +var evt=null; +try{ +if(obj.ownerDocument){ +evt=obj.ownerDocument.parentWindow.event; +}else{ +if(obj.documentElement){ +evt=obj.documentElement.ownerDocument.parentWindow.event; +}else{ +if(obj.event){ +evt=obj.event; +}else{ +evt=window.event; +} +} +} +} +catch(e){ +evt=window.event; +} +if(evt){ +args.push(dojo.event.browser.fixEvent(evt,this)); +} +}else{ +for(var x=0;x-1){ +if(_328==0){ +return; +} +marr[7]--; +} +var _329; +var to={args:[],jp_:this,object:obj,proceed:function(){ +return _323[_324].apply(_323,to.args); +}}; +to.args=_31f; +var _32b=parseInt(marr[4]); +var _32c=((!isNaN(_32b))&&(marr[4]!==null)&&(typeof marr[4]!="undefined")); +if(marr[5]){ +var rate=parseInt(marr[5]); +var cur=new Date(); +var _32f=false; +if((marr["last"])&&((cur-marr.last)<=rate)){ +if(dojo.event._canTimeout){ +if(marr["delayTimer"]){ +clearTimeout(marr.delayTimer); +} +var tod=parseInt(rate*2); +var mcpy=dojo.lang.shallowCopy(marr); +marr.delayTimer=setTimeout(function(){ +mcpy[5]=0; +_321(mcpy); +},tod); +} +return; +}else{ +marr.last=cur; +} +} +if(_326){ +_325[_326].call(_325,to); +}else{ +if((_32c)&&((dojo.render.html)||(dojo.render.svg))){ +dj_global["setTimeout"](function(){ +if(msg){ +_323[_324].call(_323,to); +}else{ +_323[_324].apply(_323,args); +} +},_32b); +}else{ +if(msg){ +_323[_324].call(_323,to); +}else{ +_323[_324].apply(_323,args); +} +} +} +}; +var _332=function(){ +if(this.squelch){ +try{ +return _321.apply(this,arguments); +} +catch(e){ +dojo.debug(e); +} +}else{ +return _321.apply(this,arguments); +} +}; +if((this["before"])&&(this.before.length>0)){ +dojo.lang.forEach(this.before.concat(new Array()),_332); +} +var _333; +try{ +if((this["around"])&&(this.around.length>0)){ +var mi=new dojo.event.MethodInvocation(this,obj,args); +_333=mi.proceed(); +}else{ +if(this.methodfunc){ +_333=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()),_332); +} +return (this.methodfunc)?_333:null; +},getArr:function(kind){ +var type="after"; +if((typeof kind=="string")&&(kind.indexOf("before")!=-1)){ +type="before"; +}else{ +if(kind=="around"){ +type="around"; +} +} +if(!this[type]){ +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"],args["maxCalls"]); +},addAdvice:function(_338,_339,_33a,_33b,_33c,_33d,once,_33f,rate,_341,_342){ +var arr=this.getArr(_33c); +if(!arr){ +dojo.raise("bad this: "+this); +} +var ao=[_338,_339,_33a,_33b,_33f,rate,_341,_342]; +if(once){ +if(this.hasAdvice(_338,_339,_33c,arr)>=0){ +return; +} +} +if(_33d=="first"){ +arr.unshift(ao); +}else{ +arr.push(ao); +} +},hasAdvice:function(_345,_346,_347,arr){ +if(!arr){ +arr=this.getArr(_347); +} +var ind=-1; +for(var x=0;x=0;i=i-1){ +var el=na[i]; +try{ +if(el&&el["__clobberAttrs__"]){ +for(var j=0;j=65&&_399<=90&&evt.shiftKey==false){ +_399+=32; +} +if(_399>=1&&_399<=26&&evt.ctrlKey){ +_399+=96; +} +evt.key=String.fromCharCode(_399); +} +} +}else{ +if(evt["type"]=="keypress"){ +if(dojo.render.html.opera){ +if(evt.which==0){ +evt.key=evt.keyCode; +}else{ +if(evt.which>0){ +switch(evt.which){ +case evt.KEY_SHIFT: +case evt.KEY_CTRL: +case evt.KEY_ALT: +case evt.KEY_CAPS_LOCK: +case evt.KEY_NUM_LOCK: +case evt.KEY_SCROLL_LOCK: +break; +case evt.KEY_PAUSE: +case evt.KEY_TAB: +case evt.KEY_BACKSPACE: +case evt.KEY_ENTER: +case evt.KEY_ESCAPE: +evt.key=evt.which; +break; +default: +var _399=evt.which; +if((evt.ctrlKey||evt.altKey||evt.metaKey)&&(evt.which>=65&&evt.which<=90&&evt.shiftKey==false)){ +_399+=32; +} +evt.key=String.fromCharCode(_399); +} +} +} +}else{ +if(dojo.render.html.ie){ +if(!evt.ctrlKey&&!evt.altKey&&evt.keyCode>=evt.KEY_SPACE){ +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; +case 63233: +evt.key=evt.KEY_DOWN_ARROW; +break; +case 63234: +evt.key=evt.KEY_LEFT_ARROW; +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>=evt.KEY_SPACE?String.fromCharCode(evt.charCode):evt.keyCode; +} +}else{ +evt.key=evt.charCode>0?String.fromCharCode(evt.charCode):evt.keyCode; +} +} +} +} +} +} +if(dojo.render.html.ie){ +if(!evt.target){ +evt.target=evt.srcElement; +} +if(!evt.currentTarget){ +evt.currentTarget=(_397?_397:evt.srcElement); +} +if(!evt.layerX){ +evt.layerX=evt.offsetX; +} +if(!evt.layerY){ +evt.layerY=evt.offsetY; +} +var doc=(evt.srcElement&&evt.srcElement.ownerDocument)?evt.srcElement.ownerDocument:document; +var _39b=((dojo.render.html.ie55)||(doc["compatMode"]=="BackCompat"))?doc.body:doc.documentElement; +if(!evt.pageX){ +evt.pageX=evt.clientX+(_39b.scrollLeft||0); +} +if(!evt.pageY){ +evt.pageY=evt.clientY+(_39b.scrollTop||0); +} +if(evt.type=="mouseover"){ +evt.relatedTarget=evt.fromElement; +} +if(evt.type=="mouseout"){ +evt.relatedTarget=evt.toElement; +} +this.currentEvent=evt; +evt.callListener=this.callListener; +evt.stopPropagation=this._stopPropagation; +evt.preventDefault=this._preventDefault; +} +return evt; +}; +this.stopEvent=function(evt){ +if(window.event){ +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.gfx.color"); +dojo.gfx.color.Color=function(r,g,b,a){ +if(dojo.lang.isArray(r)){ +this.r=r[0]; +this.g=r[1]; +this.b=r[2]; +this.a=r[3]||1; +}else{ +if(dojo.lang.isString(r)){ +var rgb=dojo.gfx.color.extractRGB(r); +this.r=rgb[0]; +this.g=rgb[1]; +this.b=rgb[2]; +this.a=g||1; +}else{ +if(r instanceof dojo.gfx.color.Color){ +this.r=r.r; +this.b=r.b; +this.g=r.g; +this.a=r.a; +}else{ +this.r=r; +this.g=g; +this.b=b; +this.a=a; +} +} +} +}; +dojo.gfx.color.Color.fromArray=function(arr){ +return new dojo.gfx.color.Color(arr[0],arr[1],arr[2],arr[3]); +}; +dojo.extend(dojo.gfx.color.Color,{toRgb:function(_3a3){ +if(_3a3){ +return this.toRgba(); +}else{ +return [this.r,this.g,this.b]; +} +},toRgba:function(){ +return [this.r,this.g,this.b,this.a]; +},toHex:function(){ +return dojo.gfx.color.rgb2hex(this.toRgb()); +},toCss:function(){ +return "rgb("+this.toRgb().join()+")"; +},toString:function(){ +return this.toHex(); +},blend:function(_3a4,_3a5){ +var rgb=null; +if(dojo.lang.isArray(_3a4)){ +rgb=_3a4; +}else{ +if(_3a4 instanceof dojo.gfx.color.Color){ +rgb=_3a4.toRgb(); +}else{ +rgb=new dojo.gfx.color.Color(_3a4).toRgb(); +} +} +return dojo.gfx.color.blend(this.toRgb(),rgb,_3a5); +}}); +dojo.gfx.color.named={white:[255,255,255],black:[0,0,0],red:[255,0,0],green:[0,255,0],lime:[0,255,0],blue:[0,0,255],navy:[0,0,128],gray:[128,128,128],silver:[192,192,192]}; +dojo.gfx.color.blend=function(a,b,_3a9){ +if(typeof a=="string"){ +return dojo.gfx.color.blendHex(a,b,_3a9); +} +if(!_3a9){ +_3a9=0; +} +_3a9=Math.min(Math.max(-1,_3a9),1); +_3a9=((_3a9+1)/2); +var c=[]; +for(var x=0;x<3;x++){ +c[x]=parseInt(b[x]+((a[x]-b[x])*_3a9)); +} +return c; +}; +dojo.gfx.color.blendHex=function(a,b,_3ae){ +return dojo.gfx.color.rgb2hex(dojo.gfx.color.blend(dojo.gfx.color.hex2rgb(a),dojo.gfx.color.hex2rgb(b),_3ae)); +}; +dojo.gfx.color.extractRGB=function(_3af){ +var hex="0123456789abcdef"; +_3af=_3af.toLowerCase(); +if(_3af.indexOf("rgb")==0){ +var _3b1=_3af.match(/rgba*\((\d+), *(\d+), *(\d+)/i); +var ret=_3b1.splice(1,3); +return ret; +}else{ +var _3b3=dojo.gfx.color.hex2rgb(_3af); +if(_3b3){ +return _3b3; +}else{ +return dojo.gfx.color.named[_3af]||[255,255,255]; +} +} +}; +dojo.gfx.color.hex2rgb=function(hex){ +var _3b5="0123456789ABCDEF"; +var rgb=new Array(3); +if(hex.indexOf("#")==0){ +hex=hex.substring(1); +} +hex=hex.toUpperCase(); +if(hex.replace(new RegExp("["+_3b5+"]","g"),"")!=""){ +return null; +} +if(hex.length==3){ +rgb[0]=hex.charAt(0)+hex.charAt(0); +rgb[1]=hex.charAt(1)+hex.charAt(1); +rgb[2]=hex.charAt(2)+hex.charAt(2); +}else{ +rgb[0]=hex.substring(0,2); +rgb[1]=hex.substring(2,4); +rgb[2]=hex.substring(4); +} +for(var i=0;i0){ +this.duration=_3d6; +} +if(_3d9){ +this.repeatCount=_3d9; +} +if(rate){ +this.rate=rate; +} +if(_3d5){ +dojo.lang.forEach(["handler","beforeBegin","onBegin","onEnd","onPlay","onStop","onAnimate"],function(item){ +if(_3d5[item]){ +this.connect(item,_3d5[item]); +} +},this); +} +if(_3d8&&dojo.lang.isFunction(_3d8)){ +this.easing=_3d8; +} +}; +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(_3dc,_3dd){ +if(_3dd){ +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(_3dc>0){ +setTimeout(dojo.lang.hitch(this,function(){ +this.play(null,_3dd); +}),_3dc); +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 _3df=this.curve.getValue(step); +if(this._percent==0){ +if(!this._startRepeatCount){ +this._startRepeatCount=this.repeatCount; +} +this.fire("handler",["begin",_3df]); +this.fire("onBegin",[_3df]); +} +this.fire("handler",["play",_3df]); +this.fire("onPlay",[_3df]); +this._cycle(); +return this; +},pause:function(){ +clearTimeout(this._timer); +if(!this._active){ +return this; +} +this._paused=true; +var _3e0=this.curve.getValue(this._percent/100); +this.fire("handler",["pause",_3e0]); +this.fire("onPause",[_3e0]); +return this; +},gotoPercent:function(pct,_3e2){ +clearTimeout(this._timer); +this._active=true; +this._paused=true; +this._percent=pct; +if(_3e2){ +this.play(); +} +return this; +},stop:function(_3e3){ +clearTimeout(this._timer); +var step=this._percent/100; +if(_3e3){ +step=1; +} +var _3e5=this.curve.getValue(step); +this.fire("handler",["stop",_3e5]); +this.fire("onStop",[_3e5]); +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 _3e8=this.curve.getValue(step); +this.fire("handler",["animate",_3e8]); +this.fire("onAnimate",[_3e8]); +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(_3e9){ +dojo.lfx.IAnimation.call(this); +this._anims=[]; +this._animsEnded=0; +var _3ea=arguments; +if(_3ea.length==1&&(dojo.lang.isArray(_3ea[0])||dojo.lang.isArrayLike(_3ea[0]))){ +_3ea=_3ea[0]; +} +dojo.lang.forEach(_3ea,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(_3ec,_3ed){ +if(!this._anims.length){ +return this; +} +this.fire("beforeBegin"); +if(_3ec>0){ +setTimeout(dojo.lang.hitch(this,function(){ +this.play(null,_3ed); +}),_3ec); +return this; +} +if(_3ed||this._anims[0].percent==0){ +this.fire("onBegin"); +} +this.fire("onPlay"); +this._animsCall("play",null,_3ed); +return this; +},pause:function(){ +this.fire("onPause"); +this._animsCall("pause"); +return this; +},stop:function(_3ee){ +this.fire("onStop"); +this._animsCall("stop",_3ee); +return this; +},_onAnimsEnded:function(){ +this._animsEnded++; +if(this._animsEnded>=this._anims.length){ +this.fire("onEnd"); +} +return this; +},_animsCall:function(_3ef){ +var args=[]; +if(arguments.length>1){ +for(var i=1;i0){ +setTimeout(dojo.lang.hitch(this,function(){ +this.play(null,_3fb); +}),_3fa); +return this; +} +if(_3fc){ +if(this._currAnim==0){ +this.fire("handler",["begin",this._currAnim]); +this.fire("onBegin",[this._currAnim]); +} +this.fire("onPlay",[this._currAnim]); +_3fc.play(null,_3fb); +} +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 _3fd=this._anims[this._currAnim]; +if(_3fd){ +if(!_3fd._active||_3fd._paused){ +this.play(); +}else{ +this.pause(); +} +} +return this; +},stop:function(){ +var _3fe=this._anims[this._currAnim]; +if(_3fe){ +_3fe.stop(); +this.fire("onStop",[this._currAnim]); +} +return _3fe; +},_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(_3ff){ +var _400=arguments; +if(dojo.lang.isArray(arguments[0])){ +_400=arguments[0]; +} +if(_400.length==1){ +return _400[0]; +} +return new dojo.lfx.Combine(_400); +}; +dojo.lfx.chain=function(_401){ +var _402=arguments; +if(dojo.lang.isArray(arguments[0])){ +_402=arguments[0]; +} +if(_402.length==1){ +return _402[0]; +} +return new dojo.lfx.Chain(_402); +}; +dojo.provide("dojo.html.common"); +dojo.lang.mixin(dojo.html,dojo.dom); +dojo.html.body=function(){ +dojo.deprecated("dojo.html.body() moved to dojo.body()","0.5"); +return dojo.body(); +}; +dojo.html.getEventTarget=function(evt){ +if(!evt){ +evt=dojo.global().event||{}; +} +var t=(evt.srcElement?evt.srcElement:(evt.target?evt.target:null)); +while((t)&&(t.nodeType!=1)){ +t=t.parentNode; +} +return t; +}; +dojo.html.getViewport=function(){ +var _405=dojo.global(); +var _406=dojo.doc(); +var w=0; +var h=0; +if(dojo.render.html.mozilla){ +w=_406.documentElement.clientWidth; +h=_405.innerHeight; +}else{ +if(!dojo.render.html.opera&&_405.innerWidth){ +w=_405.innerWidth; +h=_405.innerHeight; +}else{ +if(!dojo.render.html.opera&&dojo.exists(_406,"documentElement.clientWidth")){ +var w2=_406.documentElement.clientWidth; +if(!w||w2&&w2_42e)){ +loc=dojo.hostenv.getBaseScriptUri()+loc; +} +return new dojo.uri.Uri(loc,uri); +}; +this.Uri=function(){ +var uri=arguments[0]; +for(var i=1;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; +} +} +} +} +_431.path=segs.join("/"); +} +} +} +} +uri=""; +if(_431.scheme!=null){ +uri+=_431.scheme+":"; +} +if(_431.authority!=null){ +uri+="//"+_431.authority; +} +uri+=_431.path; +if(_431.query!=null){ +uri+="?"+_431.query; +} +if(_431.fragment!=null){ +uri+="#"+_431.fragment; +} +} +this.uri=uri.toString(); +var _436="^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$"; +var r=this.uri.match(new RegExp(_436)); +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){ +_436="^((([^:]+:)?([^@]+))@)?([^:]*)(:([0-9]+))?$"; +r=this.authority.match(new RegExp(_436)); +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,_43d){ +return (new RegExp("(^|\\s+)"+_43d+"(\\s+|$)")).test(dojo.html.getClass(node)); +}; +dojo.html.prependClass=function(node,_43f){ +_43f+=" "+dojo.html.getClass(node); +return dojo.html.setClass(node,_43f); +}; +dojo.html.addClass=function(node,_441){ +if(dojo.html.hasClass(node,_441)){ +return false; +} +_441=(dojo.html.getClass(node)+" "+_441).replace(/^\s+|\s+$/g,""); +return dojo.html.setClass(node,_441); +}; +dojo.html.setClass=function(node,_443){ +node=dojo.byId(node); +var cs=new String(_443); +try{ +if(typeof node.className=="string"){ +node.className=cs; +}else{ +if(node.setAttribute){ +node.setAttribute("class",_443); +node.className=cs; +}else{ +return false; +} +} +} +catch(e){ +dojo.debug("dojo.html.setClass() failed",e); +} +return true; +}; +dojo.html.removeClass=function(node,_446,_447){ +try{ +if(!_447){ +var _448=dojo.html.getClass(node).replace(new RegExp("(^|\\s+)"+_446+"(\\s+|$)"),"$1$2"); +}else{ +var _448=dojo.html.getClass(node).replace(_446,""); +} +dojo.html.setClass(node,_448); +} +catch(e){ +dojo.debug("dojo.html.removeClass() failed",e); +} +return true; +}; +dojo.html.replaceClass=function(node,_44a,_44b){ +dojo.html.removeClass(node,_44b); +dojo.html.addClass(node,_44a); +}; +dojo.html.classMatchType={ContainsAll:0,ContainsAny:1,IsOnly:2}; +dojo.html.getElementsByClass=function(_44c,_44d,_44e,_44f,_450){ +_450=false; +var _451=dojo.doc(); +_44d=dojo.byId(_44d)||_451; +var _452=_44c.split(/\s+/g); +var _453=[]; +if(_44f!=1&&_44f!=2){ +_44f=0; +} +var _454=new RegExp("(\\s|^)(("+_452.join(")|(")+"))(\\s|$)"); +var _455=_452.join(" ").length; +var _456=[]; +if(!_450&&_451.evaluate){ +var _457=".//"+(_44e||"*")+"[contains("; +if(_44f!=dojo.html.classMatchType.ContainsAny){ +_457+="concat(' ',@class,' '), ' "+_452.join(" ') and contains(concat(' ',@class,' '), ' ")+" ')"; +if(_44f==2){ +_457+=" and string-length(@class)="+_455+"]"; +}else{ +_457+="]"; +} +}else{ +_457+="concat(' ',@class,' '), ' "+_452.join(" ') or contains(concat(' ',@class,' '), ' ")+" ')]"; +} +var _458=_451.evaluate(_457,_44d,null,XPathResult.ANY_TYPE,null); +var _459=_458.iterateNext(); +while(_459){ +try{ +_456.push(_459); +_459=_458.iterateNext(); +} +catch(e){ +break; +} +} +return _456; +}else{ +if(!_44e){ +_44e="*"; +} +_456=_44d.getElementsByTagName(_44e); +var node,i=0; +outer: +while(node=_456[i++]){ +var _45c=dojo.html.getClasses(node); +if(_45c.length==0){ +continue outer; +} +var _45d=0; +for(var j=0;j<_45c.length;j++){ +if(_454.test(_45c[j])){ +if(_44f==dojo.html.classMatchType.ContainsAny){ +_453.push(node); +continue outer; +}else{ +_45d++; +} +}else{ +if(_44f==dojo.html.classMatchType.IsOnly){ +continue outer; +} +} +} +if(_45d==_452.length){ +if((_44f==dojo.html.classMatchType.IsOnly)&&(_45d==_45c.length)){ +_453.push(node); +}else{ +if(_44f==dojo.html.classMatchType.ContainsAll){ +_453.push(node); +} +} +} +} +return _453; +} +}; +dojo.html.getElementsByClassName=dojo.html.getElementsByClass; +dojo.html.toCamelCase=function(_45f){ +var arr=_45f.split("-"),cc=arr[0]; +for(var i=1;i=1){ +if(h.ie){ +dojo.html.clearOpacity(node); +return; +}else{ +_4cf=0.999999; +} +}else{ +if(_4cf<0){ +_4cf=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.color"); +dojo.html.getBackgroundColor=function(node){ +node=dojo.byId(node); +var _4db; +do{ +_4db=dojo.html.getStyle(node,"background-color"); +if(_4db.toLowerCase()=="rgba(0, 0, 0, 0)"){ +_4db="transparent"; +} +if(node==document.getElementsByTagName("body")[0]){ +node=null; +break; +} +node=node.parentNode; +}while(node&&dojo.lang.inArray(["transparent",""],_4db)); +if(_4db=="transparent"){ +_4db=[255,255,255,0]; +}else{ +_4db=dojo.gfx.color.extractRGB(_4db); +} +return _4db; +}; +dojo.provide("dojo.html.layout"); +dojo.html.sumAncestorProperties=function(node,prop){ +node=dojo.byId(node); +if(!node){ +return 0; +} +var _4de=0; +while(node){ +if(dojo.html.getComputedStyle(node,"position")=="fixed"){ +return 0; +} +var val=node[prop]; +if(val){ +_4de+=val-0; +if(node==dojo.body()){ +break; +} +} +node=node.parentNode; +} +return _4de; +}; +dojo.html.setStyleAttributes=function(node,_4e1){ +node=dojo.byId(node); +var _4e2=_4e1.replace(/(;)?\s*$/,"").split(";"); +for(var i=0;i<_4e2.length;i++){ +var _4e4=_4e2[i].split(":"); +var name=_4e4[0].replace(/\s*$/,"").replace(/^\s*/,"").toLowerCase(); +var _4e6=_4e4[1].replace(/\s*$/,"").replace(/^\s*/,""); +switch(name){ +case "opacity": +dojo.html.setOpacity(node,_4e6); +break; +case "content-height": +dojo.html.setContentBox(node,{height:_4e6}); +break; +case "content-width": +dojo.html.setContentBox(node,{width:_4e6}); +break; +case "outer-height": +dojo.html.setMarginBox(node,{height:_4e6}); +break; +case "outer-width": +dojo.html.setMarginBox(node,{width:_4e6}); +break; +default: +node.style[dojo.html.toCamelCase(name)]=_4e6; +} +} +}; +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,_4e8,_4e9){ +node=dojo.byId(node,node.ownerDocument); +var ret={x:0,y:0}; +var bs=dojo.html.boxSizing; +if(!_4e9){ +_4e9=bs.CONTENT_BOX; +} +var _4ec=2; +var _4ed; +switch(_4e9){ +case bs.MARGIN_BOX: +_4ed=3; +break; +case bs.BORDER_BOX: +_4ed=2; +break; +case bs.PADDING_BOX: +default: +_4ed=1; +break; +case bs.CONTENT_BOX: +_4ed=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){ +_4ec=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 _4f1; +if((h.safari)&&(node.style.getPropertyValue("position")=="absolute")&&(node.parentNode==db)){ +_4f1=db; +}else{ +_4f1=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 _4f3=node; +do{ +var n=_4f3["offsetLeft"]; +if(!h.opera||n>0){ +ret.x+=isNaN(n)?0:n; +} +var m=_4f3["offsetTop"]; +ret.y+=isNaN(m)?0:m; +_4f3=_4f3.offsetParent; +}while((_4f3!=_4f1)&&(_4f3!=null)); +}else{ +if(node["x"]&&node["y"]){ +ret.x+=isNaN(node.x)?0:node.x; +ret.y+=isNaN(node.y)?0:node.y; +} +} +} +} +if(_4e8){ +var _4f6=dojo.html.getScroll(); +ret.y+=_4f6.top; +ret.x+=_4f6.left; +} +var _4f7=[dojo.html.getPaddingExtent,dojo.html.getBorderExtent,dojo.html.getMarginExtent]; +if(_4ec>_4ed){ +for(var i=_4ed;i<_4ec;++i){ +ret.y+=_4f7[i](node,"top"); +ret.x+=_4f7[i](node,"left"); +} +}else{ +if(_4ec<_4ed){ +for(var i=_4ed;i>_4ec;--i){ +ret.y-=_4f7[i-1](node,"top"); +ret.x-=_4f7[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,_4fb,_4fc){ +var _4fd=0; +for(var x=0;x<_4fb.length;x++){ +_4fd+=dojo.html.getPixelValue(node,_4fb[x],_4fc); +} +return _4fd; +}; +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 _50a=dojo.html.getBorder(node); +return {width:pad.width+_50a.width,height:pad.height+_50a.height}; +}; +dojo.html.getBoxSizing=function(node){ +var h=dojo.render.html; +var bs=dojo.html.boxSizing; +if(((h.ie)||(h.opera))&&node.nodeName.toLowerCase()!="img"){ +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 _50f; +if(!h.ie){ +_50f=dojo.html.getStyle(node,"-moz-box-sizing"); +if(!_50f){ +_50f=dojo.html.getStyle(node,"box-sizing"); +} +} +return (_50f?_50f: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 _514=dojo.html.getBorder(node); +return {width:box.width-_514.width,height:box.height-_514.height}; +}; +dojo.html.getContentBox=function(node){ +node=dojo.byId(node); +var _516=dojo.html.getPadBorder(node); +return {width:node.offsetWidth-_516.width,height:node.offsetHeight-_516.height}; +}; +dojo.html.setContentBox=function(node,args){ +node=dojo.byId(node); +var _519=0; +var _51a=0; +var isbb=dojo.html.isBorderBox(node); +var _51c=(isbb?dojo.html.getPadBorder(node):{width:0,height:0}); +var ret={}; +if(typeof args.width!="undefined"){ +_519=args.width+_51c.width; +ret.width=dojo.html.setPositivePixelValue(node,"width",_519); +} +if(typeof args.height!="undefined"){ +_51a=args.height+_51c.height; +ret.height=dojo.html.setPositivePixelValue(node,"height",_51a); +} +return ret; +}; +dojo.html.getMarginBox=function(node){ +var _51f=dojo.html.getBorderBox(node); +var _520=dojo.html.getMargin(node); +return {width:_51f.width+_520.width,height:_51f.height+_520.height}; +}; +dojo.html.setMarginBox=function(node,args){ +node=dojo.byId(node); +var _523=0; +var _524=0; +var isbb=dojo.html.isBorderBox(node); +var _526=(!isbb?dojo.html.getPadBorder(node):{width:0,height:0}); +var _527=dojo.html.getMargin(node); +var ret={}; +if(typeof args.width!="undefined"){ +_523=args.width-_526.width; +_523-=_527.width; +ret.width=dojo.html.setPositivePixelValue(node,"width",_523); +} +if(typeof args.height!="undefined"){ +_524=args.height-_526.height; +_524-=_527.height; +ret.height=dojo.html.setPositivePixelValue(node,"height",_524); +} +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(_52c,_52d,_52e){ +if(_52c instanceof Array||typeof _52c=="array"){ +dojo.deprecated("dojo.html.toCoordinateArray","use dojo.html.toCoordinateObject({left: , top: , width: , height: }) instead","0.5"); +while(_52c.length<4){ +_52c.push(0); +} +while(_52c.length>4){ +_52c.pop(); +} +var ret={left:_52c[0],top:_52c[1],width:_52c[2],height:_52c[3]}; +}else{ +if(!_52c.nodeType&&!(_52c instanceof String||typeof _52c=="string")&&("width" in _52c||"height" in _52c||"left" in _52c||"x" in _52c||"top" in _52c||"y" in _52c)){ +var ret={left:_52c.left||_52c.x||0,top:_52c.top||_52c.y||0,width:_52c.width||0,height:_52c.height||0}; +}else{ +var node=dojo.byId(_52c); +var pos=dojo.html.abs(node,_52d,_52e); +var _532=dojo.html.getMarginBox(node); +var ret={left:pos.left,top:pos.top,width:_532.width,height:_532.height}; +} +} +ret.x=ret.left; +ret.y=ret.top; +return ret; +}; +dojo.html.setMarginBoxWidth=dojo.html.setOuterWidth=function(node,_534){ +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,_537){ +return dojo.html._callDeprecated("getTotalOffset","getAbsolutePosition",arguments,null,type); +}; +dojo.html.getAbsoluteX=function(node,_539){ +return dojo.html._callDeprecated("getAbsoluteX","getAbsolutePosition",arguments,null,"x"); +}; +dojo.html.getAbsoluteY=function(node,_53b){ +return dojo.html._callDeprecated("getAbsoluteY","getAbsolutePosition",arguments,null,"y"); +}; +dojo.html.totalOffsetLeft=function(node,_53d){ +return dojo.html._callDeprecated("totalOffsetLeft","getAbsolutePosition",arguments,null,"left"); +}; +dojo.html.totalOffsetTop=function(node,_53f){ +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,_549){ +return dojo.html._callDeprecated("setContentBoxWidth","setContentBox",arguments,"width"); +}; +dojo.html.setContentBoxHeight=dojo.html.setContentHeight=function(node,_54b){ +return dojo.html._callDeprecated("setContentBoxHeight","setContentBox",arguments,"height"); +}; +dojo.provide("dojo.lfx.html"); +dojo.lfx.html._byId=function(_54c){ +if(!_54c){ +return []; +} +if(dojo.lang.isArrayLike(_54c)){ +if(!_54c.alreadyChecked){ +var n=[]; +dojo.lang.forEach(_54c,function(node){ +n.push(dojo.byId(node)); +}); +n.alreadyChecked=true; +return n; +}else{ +return _54c; +} +}else{ +var n=[]; +n.push(dojo.byId(_54c)); +n.alreadyChecked=true; +return n; +} +}; +dojo.lfx.html.propertyAnimation=function(_54f,_550,_551,_552,_553){ +_54f=dojo.lfx.html._byId(_54f); +var _554={"propertyMap":_550,"nodes":_54f,"duration":_551,"easing":_552||dojo.lfx.easeDefault}; +var _555=function(args){ +if(args.nodes.length==1){ +var pm=args.propertyMap; +if(!dojo.lang.isArray(args.propertyMap)){ +var parr=[]; +for(var _559 in pm){ +pm[_559].property=_559; +parr.push(pm[_559]); +} +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 _55b=function(_55c){ +var _55d=[]; +dojo.lang.forEach(_55c,function(c){ +_55d.push(Math.round(c)); +}); +return _55d; +}; +var _55f=function(n,_561){ +n=dojo.byId(n); +if(!n||!n.style){ +return; +} +for(var s in _561){ +try{ +if(s=="opacity"){ +dojo.html.setOpacity(n,_561[s]); +}else{ +n.style[s]=_561[s]; +} +} +catch(e){ +dojo.debug(e); +} +} +}; +var _563=function(_564){ +this._properties=_564; +this.diffs=new Array(_564.length); +dojo.lang.forEach(_564,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 _56b=null; +if(dojo.lang.isArray(prop.start)){ +}else{ +if(prop.start instanceof dojo.gfx.color.Color){ +_56b=(prop.units||"rgb")+"("; +for(var j=0;j3){ +_5e0.pop(); +} +var rgb=new dojo.gfx.color.Color(_5da); +var _5e5=new dojo.gfx.color.Color(_5e0); +var anim=dojo.lfx.propertyAnimation(node,{"background-color":{start:rgb,end:_5e5}},_5db,_5dc,{"beforeBegin":function(){ +if(_5e2){ +node.style.backgroundImage="none"; +} +node.style.backgroundColor="rgb("+rgb.toRgb().join(",")+")"; +},"onEnd":function(){ +if(_5e2){ +node.style.backgroundImage=_5e2; +} +if(_5e3){ +node.style.backgroundColor="transparent"; +} +if(_5dd){ +_5dd(node,anim); +} +}}); +_5de.push(anim); +}); +return dojo.lfx.combine(_5de); +}; +dojo.lfx.html.unhighlight=function(_5e7,_5e8,_5e9,_5ea,_5eb){ +_5e7=dojo.lfx.html._byId(_5e7); +var _5ec=[]; +dojo.lang.forEach(_5e7,function(node){ +var _5ee=new dojo.gfx.color.Color(dojo.html.getBackgroundColor(node)); +var rgb=new dojo.gfx.color.Color(_5e8); +var _5f0=dojo.html.getStyle(node,"background-image"); +var anim=dojo.lfx.propertyAnimation(node,{"background-color":{start:_5ee,end:rgb}},_5e9,_5ea,{"beforeBegin":function(){ +if(_5f0){ +node.style.backgroundImage="none"; +} +node.style.backgroundColor="rgb("+_5ee.toRgb().join(",")+")"; +},"onEnd":function(){ +if(_5eb){ +_5eb(node,anim); +} +}}); +_5ec.push(anim); +}); +return dojo.lfx.combine(_5ec); +}; +dojo.lang.mixin(dojo.lfx,dojo.lfx.html); +dojo.kwCompoundRequire({browser:["dojo.lfx.html"],dashboard:["dojo.lfx.html"]}); +dojo.provide("dojo.lfx.*"); +if(!this["dojo"]){ +alert("\"dojo/__package__.js\" is now located at \"dojo/dojo.js\". Please update your includes accordingly"); +} +dojo.provide("dojo.xml.Parse"); +dojo.xml.Parse=function(){ +var isIE=((dojo.render.html.capable)&&(dojo.render.html.ie)); +function getTagName(node){ +try{ +return node.tagName.toLowerCase(); +} +catch(e){ +return ""; +} +} +function getDojoTagName(node){ +var _5f5=getTagName(node); +if(!_5f5){ +return ""; +} +if((dojo.widget)&&(dojo.widget.tags[_5f5])){ +return _5f5; +} +var p=_5f5.indexOf(":"); +if(p>=0){ +return _5f5; +} +if(_5f5.substr(0,5)=="dojo:"){ +return _5f5; +} +if(dojo.render.html.capable&&dojo.render.html.ie&&node.scopeName!="HTML"){ +return node.scopeName.toLowerCase()+":"+_5f5; +} +if(_5f5.substr(0,4)=="dojo"){ +return "dojo:"+_5f5.substring(4); +} +var djt=node.getAttribute("dojoType")||node.getAttribute("dojotype"); +if(djt){ +if(djt.indexOf(":")<0){ +djt="dojo:"+djt; +} +return djt.toLowerCase(); +} +djt=node.getAttributeNS&&node.getAttributeNS(dojo.dom.dojoml,"type"); +if(djt){ +return "dojo:"+djt.toLowerCase(); +} +try{ +djt=node.getAttribute("dojo:type"); +} +catch(e){ +} +if(djt){ +return "dojo:"+djt.toLowerCase(); +} +if((dj_global["djConfig"])&&(!djConfig["ignoreClassNames"])){ +var _5f8=node.className||node.getAttribute("class"); +if((_5f8)&&(_5f8.indexOf)&&(_5f8.indexOf("dojo-")!=-1)){ +var _5f9=_5f8.split(" "); +for(var x=0,c=_5f9.length;x0){ +var ns=_600.substring(0,pos); +_604["ns"]=ns; +if((dojo.ns)&&(!dojo.ns.allow(ns))){ +_602=false; +} +} +if(_602){ +var _607=this.parseAttributes(node); +for(var attr in _607){ +if((!_604[_600][attr])||(typeof _604[_600][attr]!="array")){ +_604[_600][attr]=[]; +} +_604[_600][attr].push(_607[attr]); +} +_604[_600].nodeRef=node; +_604.tagName=_600; +_604.index=_5ff||0; +} +var _608=0; +for(var i=0;i=0;x--){ +try{ +this.widgets[x].destroy(true); +delete this.widgets[x]; +} +catch(e){ +} +} +}; +this.remove=function(_64e){ +if(dojo.lang.isNumber(_64e)){ +var tw=this.widgets[_64e].widgetId; +delete this.topWidgets[tw]; +delete this.widgetIds[tw]; +this.widgets.splice(_64e,1); +}else{ +this.removeById(_64e); +} +}; +this.removeById=function(id){ +if(!dojo.lang.isString(id)){ +id=id["widgetId"]; +if(!id){ +dojo.debug("invalid widget or id passed to removeById"); +return; +} +} +for(var i=0;i0){ +return _68a[n]; +} +return _68a; +}; +g("registerWidgetPackage"); +g("getImplementation","getWidgetImplementation"); +g("getImplementationName","getWidgetImplementationName"); +dw.widgets=dwm.widgets; +dw.widgetIds=dwm.widgetIds; +dw.root=dwm.root; +})(); +dojo.kwCompoundRequire({common:[["dojo.uri.Uri",false,false]]}); +dojo.provide("dojo.uri.*"); +dojo.provide("dojo.a11y"); +dojo.a11y={imgPath:dojo.uri.moduleUri("dojo.widget","templates/images"),doAccessibleCheck:true,accessible:null,checkAccessible:function(){ +if(this.accessible===null){ +this.accessible=false; +if(this.doAccessibleCheck==true){ +this.accessible=this.testAccessible(); +} +} +return this.accessible; +},testAccessible:function(){ +this.accessible=false; +if(dojo.render.html.ie||dojo.render.html.mozilla){ +var div=document.createElement("div"); +div.style.backgroundImage="url(\""+this.imgPath+"/tab_close.gif\")"; +dojo.body().appendChild(div); +var _68c=null; +if(window.getComputedStyle){ +var _68d=getComputedStyle(div,""); +_68c=_68d.getPropertyValue("background-image"); +}else{ +_68c=div.currentStyle.backgroundImage; +} +var _68e=false; +if(_68c!=null&&(_68c=="none"||_68c=="url(invalid-url:)")){ +this.accessible=true; +} +dojo.body().removeChild(div); +} +return this.accessible; +},setCheckAccessible:function(_68f){ +this.doAccessibleCheck=_68f; +},setAccessibleMode:function(){ +if(this.accessible===null){ +if(this.checkAccessible()){ +dojo.render.html.prefixes.unshift("a11y"); +} +} +return this.accessible; +}}; +dojo.provide("dojo.widget.Widget"); +dojo.declare("dojo.widget.Widget",null,function(){ +this.children=[]; +this.extraArgs={}; +},{parent:null,isTopLevel:false,disabled:false,isContainer:false,widgetId:"",widgetType:"Widget",ns:"dojo",getNamespacedType:function(){ +return (this.ns?this.ns+":"+this.widgetType:this.widgetType).toLowerCase(); +},toString:function(){ +return "[Widget "+this.getNamespacedType()+", "+(this.widgetId||"NO ID")+"]"; +},repr:function(){ +return this.toString(); +},enable:function(){ +this.disabled=false; +},disable:function(){ +this.disabled=true; +},onResized:function(){ +this.notifyChildrenOfResize(); +},notifyChildrenOfResize:function(){ +for(var i=0;ii){ +_697=this.children[i]; +if(_697 instanceof dojo.widget.Widget){ +this.removeChild(_697); +_697.destroy(); +continue; +} +i++; +} +},getChildrenOfType:function(type,_69a){ +var ret=[]; +var _69c=dojo.lang.isFunction(type); +if(!_69c){ +type=type.toLowerCase(); +} +for(var x=0;xsi)){ +this[x][_6ab[y].substr(0,si).replace(/^\s+|\s+$/g,"")]=_6ab[y].substr(si+1); +} +} +} +}else{ +this[x]=args[x]; +} +} +} +} +} +} +} +} +}else{ +this.extraArgs[x.toLowerCase()]=args[x]; +} +} +},postMixInProperties:function(args,frag,_6af){ +},initialize:function(args,frag,_6b2){ +return false; +},postInitialize:function(args,frag,_6b5){ +return false; +},postCreate:function(args,frag,_6b8){ +return false; +},uninitialize:function(){ +return false; +},buildRendering:function(args,frag,_6bb){ +dojo.unimplemented("dojo.widget.Widget.buildRendering, on "+this.toString()+", "); +return false; +},destroyRendering:function(){ +dojo.unimplemented("dojo.widget.Widget.destroyRendering"); +return false; +},addedTo:function(_6bc){ +},addChild:function(_6bd){ +dojo.unimplemented("dojo.widget.Widget.addChild"); +return false; +},removeChild:function(_6be){ +for(var x=0;x-1)?_6e1.substring(0,pos):_6e1; +_6e0=(_6e0)||{}; +_6e0.widgetType=type; +if((!init)&&(_6e0["classConstructor"])){ +init=_6e0.classConstructor; +delete _6e0.classConstructor; +} +dojo.declare(_6dc,_6de,init,_6e0); +}; +dojo.provide("dojo.widget.Parse"); +dojo.widget.Parse=function(_6e7){ +this.propertySetsList=[]; +this.fragment=_6e7; +this.createComponents=function(frag,_6e9){ +var _6ea=[]; +var _6eb=false; +try{ +if(frag&&frag.tagName&&(frag!=frag.nodeRef)){ +var _6ec=dojo.widget.tags; +var tna=String(frag.tagName).split(";"); +for(var x=0;x-1)?name.substring(0,pos):"dojo"; +if(pos>-1){ +name=name.substring(pos+1); +} +var _71f=name.toLowerCase(); +var _720=ns+":"+_71f; +_71b=(dojo.byId(name)&&!dojo.widget.tags[_720]); +} +if((arguments.length==1)&&(_71b||!_71c)){ +var xp=new dojo.xml.Parse(); +var tn=_71b?dojo.byId(name):name; +return dojo.widget.getParser().createComponents(xp.parseElement(tn,null,true))[0]; +} +function fromScript(_723,name,_725,ns){ +_725[_720]={dojotype:[{value:_71f}],nodeRef:_723,fastMixIn:true}; +_725.ns=ns; +return dojo.widget.getParser().createComponentFromScript(_723,name,_725,ns); +} +_718=_718||{}; +var _727=false; +var tn=null; +var h=dojo.render.html.capable; +if(h){ +tn=document.createElement("span"); +} +if(!_719){ +_727=true; +_719=tn; +if(h){ +dojo.body().appendChild(_719); +} +}else{ +if(_71a){ +dojo.dom.insertAtPosition(tn,_719,_71a); +}else{ +tn=_719; +} +} +var _729=fromScript(tn,name.toLowerCase(),_718,ns); +if((!_729)||(!_729[0])||(typeof _729[0].widgetType=="undefined")){ +throw new Error("createWidget: Creation of \""+name+"\" widget failed."); +} +try{ +if(_727&&_729[0].domNode.parentNode){ +_729[0].domNode.parentNode.removeChild(_729[0].domNode); +} +} +catch(e){ +dojo.debug(e); +} +return _729[0]; +}; +dojo.provide("dojo.widget.DomWidget"); +dojo.widget._cssFiles={}; +dojo.widget._cssStrings={}; +dojo.widget._templateCache={}; +dojo.widget.defaultStrings={dojoRoot:dojo.hostenv.getBaseScriptUri(),dojoWidgetModuleUri:dojo.uri.moduleUri("dojo.widget"),baseScriptUri:dojo.hostenv.getBaseScriptUri()}; +dojo.widget.fillFromTemplateCache=function(obj,_72b,_72c,_72d){ +var _72e=_72b||obj.templatePath; +var _72f=dojo.widget._templateCache; +if(!_72e&&!obj["widgetType"]){ +do{ +var _730="__dummyTemplate__"+dojo.widget._templateCache.dummyCount++; +}while(_72f[_730]); +obj.widgetType=_730; +} +var wt=_72e?_72e.toString():obj.widgetType; +var ts=_72f[wt]; +if(!ts){ +_72f[wt]={"string":null,"node":null}; +if(_72d){ +ts={}; +}else{ +ts=_72f[wt]; +} +} +if((!obj.templateString)&&(!_72d)){ +obj.templateString=_72c||ts["string"]; +} +if(obj.templateString){ +obj.templateString=this._sanitizeTemplateString(obj.templateString); +} +if((!obj.templateNode)&&(!_72d)){ +obj.templateNode=ts["node"]; +} +if((!obj.templateNode)&&(!obj.templateString)&&(_72e)){ +var _733=this._sanitizeTemplateString(dojo.hostenv.getText(_72e)); +obj.templateString=_733; +if(!_72d){ +_72f[wt]["string"]=_733; +} +} +if((!ts["string"])&&(!_72d)){ +ts.string=obj.templateString; +} +}; +dojo.widget._sanitizeTemplateString=function(_734){ +if(_734){ +_734=_734.replace(/^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im,""); +var _735=_734.match(/]*>\s*([\s\S]+)\s*<\/body>/im); +if(_735){ +_734=_735[1]; +} +}else{ +_734=""; +} +return _734; +}; +dojo.widget._templateCache.dummyCount=0; +dojo.widget.attachProperties=["dojoAttachPoint","id"]; +dojo.widget.eventAttachProperty="dojoAttachEvent"; +dojo.widget.onBuildProperty="dojoOnBuild"; +dojo.widget.waiNames=["waiRole","waiState"]; +dojo.widget.wai={waiRole:{name:"waiRole","namespace":"http://www.w3.org/TR/xhtml2",alias:"x2",prefix:"wairole:"},waiState:{name:"waiState","namespace":"http://www.w3.org/2005/07/aaa",alias:"aaa",prefix:""},setAttr:function(node,ns,attr,_739){ +if(dojo.render.html.ie){ +node.setAttribute(this[ns].alias+":"+attr,this[ns].prefix+_739); +}else{ +node.setAttributeNS(this[ns]["namespace"],attr,this[ns].prefix+_739); +} +},getAttr:function(node,ns,attr){ +if(dojo.render.html.ie){ +return node.getAttribute(this[ns].alias+":"+attr); +}else{ +return node.getAttributeNS(this[ns]["namespace"],attr); +} +},removeAttr:function(node,ns,attr){ +var _740=true; +if(dojo.render.html.ie){ +_740=node.removeAttribute(this[ns].alias+":"+attr); +}else{ +node.removeAttributeNS(this[ns]["namespace"],attr); +} +return _740; +}}; +dojo.widget.attachTemplateNodes=function(_741,_742,_743){ +var _744=dojo.dom.ELEMENT_NODE; +function trim(str){ +return str.replace(/^\s+|\s+$/g,""); +} +if(!_741){ +_741=_742.domNode; +} +if(_741.nodeType!=_744){ +return; +} +var _746=_741.all||_741.getElementsByTagName("*"); +var _747=_742; +for(var x=-1;x<_746.length;x++){ +var _749=(x==-1)?_741:_746[x]; +var _74a=[]; +if(!_742.widgetsInTemplate||!_749.getAttribute("dojoType")){ +for(var y=0;y=0){ +var _752=tevt.split(":"); +tevt=trim(_752[0]); +_750=trim(_752[1]); +} +if(!_750){ +_750=tevt; +} +var tf=function(){ +var ntf=new String(_750); +return function(evt){ +if(_747[ntf]){ +_747[ntf](dojo.event.browser.fixEvent(evt,this)); +} +}; +}(); +dojo.event.browser.addListener(_749,tevt,tf,false,true); +} +} +for(var y=0;y<_743.length;y++){ +var _756=_749.getAttribute(_743[y]); +if((_756)&&(_756.length)){ +var _750=null; +var _757=_743[y].substr(4); +_750=trim(_756); +var _758=[_750]; +if(_750.indexOf(";")>=0){ +_758=dojo.lang.map(_750.split(";"),trim); +} +for(var z=0;z<_758.length;z++){ +if(!_758[z].length){ +continue; +} +var tf=function(){ +var ntf=new String(_758[z]); +return function(evt){ +if(_747[ntf]){ +_747[ntf](dojo.event.browser.fixEvent(evt,this)); +} +}; +}(); +dojo.event.browser.addListener(_749,_757,tf,false,true); +} +} +} +} +var _75b=_749.getAttribute(this.templateProperty); +if(_75b){ +_742[_75b]=_749; +} +dojo.lang.forEach(dojo.widget.waiNames,function(name){ +var wai=dojo.widget.wai[name]; +var val=_749.getAttribute(wai.name); +if(val){ +if(val.indexOf("-")==-1){ +dojo.widget.wai.setAttr(_749,wai.name,"role",val); +}else{ +var _75f=val.split("-"); +dojo.widget.wai.setAttr(_749,wai.name,_75f[0],_75f[1]); +} +} +},this); +var _760=_749.getAttribute(this.onBuildProperty); +if(_760){ +eval("var node = baseNode; var widget = targetObj; "+_760); +} +} +}; +dojo.widget.getDojoEventsFromStr=function(str){ +var re=/(dojoOn([a-z]+)(\s?))=/gi; +var evts=str?str.match(re)||[]:[]; +var ret=[]; +var lem={}; +for(var x=0;x0)&&(typeof arguments[0]=="object")){ +this.create(arguments[0]); +} +},{templateNode:null,templateString:null,templateCssString:null,preventClobber:false,domNode:null,containerNode:null,widgetsInTemplate:false,addChild:function(_768,_769,pos,ref,_76c){ +if(!this.isContainer){ +dojo.debug("dojo.widget.DomWidget.addChild() attempted on non-container widget"); +return null; +}else{ +if(_76c==undefined){ +_76c=this.children.length; +} +this.addWidgetAsDirectChild(_768,_769,pos,ref,_76c); +this.registerChild(_768,_76c); +} +return _768; +},addWidgetAsDirectChild:function(_76d,_76e,pos,ref,_771){ +if((!this.containerNode)&&(!_76e)){ +this.containerNode=this.domNode; +} +var cn=(_76e)?_76e:this.containerNode; +if(!pos){ +pos="after"; +} +if(!ref){ +if(!cn){ +cn=dojo.body(); +} +ref=cn.lastChild; +} +if(!_771){ +_771=0; +} +_76d.domNode.setAttribute("dojoinsertionindex",_771); +if(!ref){ +cn.appendChild(_76d.domNode); +}else{ +if(pos=="insertAtIndex"){ +dojo.dom.insertAtIndex(_76d.domNode,ref.parentNode,_771); +}else{ +if((pos=="after")&&(ref===cn.lastChild)){ +cn.appendChild(_76d.domNode); +}else{ +dojo.dom.insertAtPosition(_76d.domNode,cn,pos); +} +} +} +},registerChild:function(_773,_774){ +_773.dojoInsertionIndex=_774; +var idx=-1; +for(var i=0;i=0){ +var _78c=tevt.split(":"); +tevt=dojo.string.trim(_78c[0]); +_78a=dojo.string.trim(_78c[1]); +} +if(!_78a){ +_78a=tevt; +} +if(dojo.lang.isFunction(_787[tevt])){ +dojo.event.kwConnect({srcObj:_787,srcFunc:tevt,targetObj:this,targetFunc:_78a}); +}else{ +alert(tevt+" is not a function in widget "+_787); +} +} +} +if(_787.extraArgs["dojoattachpoint"]){ +this[_787.extraArgs["dojoattachpoint"]]=_787; +} +} +} +if(this.isContainer&&!frag["dojoDontFollow"]){ +dojo.widget.getParser().createSubComponents(frag,this); +} +},buildRendering:function(args,frag){ +var ts=dojo.widget._templateCache[this.widgetType]; +if(args["templatecsspath"]){ +args["templateCssPath"]=args["templatecsspath"]; +} +var _790=args["templateCssPath"]||this.templateCssPath; +if(_790&&!dojo.widget._cssFiles[_790.toString()]){ +if((!this.templateCssString)&&(_790)){ +this.templateCssString=dojo.hostenv.getText(_790); +this.templateCssPath=null; +} +dojo.widget._cssFiles[_790.toString()]=true; +} +if((this["templateCssString"])&&(!dojo.widget._cssStrings[this.templateCssString])){ +dojo.html.insertCssText(this.templateCssString,null,_790); +dojo.widget._cssStrings[this.templateCssString]=true; +} +if((!this.preventClobber)&&((this.templatePath)||(this.templateNode)||((this["templateString"])&&(this.templateString.length))||((typeof ts!="undefined")&&((ts["string"])||(ts["node"]))))){ +this.buildFromTemplate(args,frag); +}else{ +this.domNode=this.getFragNodeRef(frag); +} +this.fillInTemplate(args,frag); +},buildFromTemplate:function(args,frag){ +var _793=false; +if(args["templatepath"]){ +args["templatePath"]=args["templatepath"]; +} +dojo.widget.fillFromTemplateCache(this,args["templatePath"],null,_793); +var ts=dojo.widget._templateCache[this.templatePath?this.templatePath.toString():this.widgetType]; +if((ts)&&(!_793)){ +if(!this.templateString.length){ +this.templateString=ts["string"]; +} +if(!this.templateNode){ +this.templateNode=ts["node"]; +} +} +var _795=false; +var node=null; +var tstr=this.templateString; +if((!this.templateNode)&&(this.templateString)){ +_795=this.templateString.match(/\$\{([^\}]+)\}/g); +if(_795){ +var hash=this.strings||{}; +for(var key in dojo.widget.defaultStrings){ +if(dojo.lang.isUndefined(hash[key])){ +hash[key]=dojo.widget.defaultStrings[key]; +} +} +for(var i=0;i<_795.length;i++){ +var key=_795[i]; +key=key.substring(2,key.length-1); +var kval=(key.substring(0,5)=="this.")?dojo.lang.getObjPathValue(key.substring(5),this):hash[key]; +var _79c; +if((kval)||(dojo.lang.isString(kval))){ +_79c=new String((dojo.lang.isFunction(kval))?kval.call(this,key,this.templateString):kval); +while(_79c.indexOf("\"")>-1){ +_79c=_79c.replace("\"","""); +} +tstr=tstr.replace(_795[i],_79c); +} +} +}else{ +this.templateNode=this.createNodesFromText(this.templateString,true)[0]; +if(!_793){ +ts.node=this.templateNode; +} +} +} +if((!this.templateNode)&&(!_795)){ +dojo.debug("DomWidget.buildFromTemplate: could not create template"); +return false; +}else{ +if(!_795){ +node=this.templateNode.cloneNode(true); +if(!node){ +return false; +} +}else{ +node=this.createNodesFromText(tstr,true)[0]; +} +} +this.domNode=node; +this.attachTemplateNodes(); +if(this.isContainer&&this.containerNode){ +var src=this.getFragNodeRef(frag); +if(src){ +dojo.dom.moveChildren(src,this.containerNode); +} +} +},attachTemplateNodes:function(_79e,_79f){ +if(!_79e){ +_79e=this.domNode; +} +if(!_79f){ +_79f=this; +} +return dojo.widget.attachTemplateNodes(_79e,_79f,dojo.widget.getDojoEventsFromStr(this.templateString)); +},fillInTemplate:function(){ +},destroyRendering:function(){ +try{ +dojo.dom.destroyNode(this.domNode); +delete this.domNode; +} +catch(e){ +} +if(this._sourceNodeRef){ +try{ +dojo.dom.destroyNode(this._sourceNodeRef); +} +catch(e){ +} +} +},createNodesFromText:function(){ +dojo.unimplemented("dojo.widget.DomWidget.createNodesFromText"); +}}); +dojo.provide("dojo.html.util"); +dojo.html.getElementWindow=function(_7a0){ +return dojo.html.getDocumentWindow(_7a0.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&&_7af.x<=_7b5&&_7af.y>=top&&_7af.y<=_7b3); +}; +dojo.html.renderedTextContent=function(node){ +node=dojo.byId(node); +var _7b7=""; +if(node==null){ +return _7b7; +} +for(var i=0;i]/i).test(txt.replace(/^\s+/))){ +txt=""+txt+"
"; +_7c0="cell"; +}else{ +if((/^]/i).test(txt.replace(/^\s+/))){ +txt=""+txt+"
"; +_7c0="row"; +}else{ +if((/^<(thead|tbody|tfoot)[\s\r\n>]/i).test(txt.replace(/^\s+/))){ +txt=""+txt+"
"; +_7c0="section"; +} +} +} +tn.innerHTML=txt; +if(tn["normalize"]){ +tn.normalize(); +} +var _7c1=null; +switch(_7c0){ +case "cell": +_7c1=tn.getElementsByTagName("tr")[0]; +break; +case "row": +_7c1=tn.getElementsByTagName("tbody")[0]; +break; +case "section": +_7c1=tn.getElementsByTagName("table")[0]; +break; +default: +_7c1=tn; +break; +} +var _7c2=[]; +for(var x=0;x<_7c1.childNodes.length;x++){ +_7c2.push(_7c1.childNodes[x].cloneNode(true)); +} +tn.style.display="none"; +dojo.html.destroyNode(tn); +return _7c2; +}; +dojo.html.placeOnScreen=function(node,_7c5,_7c6,_7c7,_7c8,_7c9,_7ca){ +if(_7c5 instanceof Array||typeof _7c5=="array"){ +_7ca=_7c9; +_7c9=_7c8; +_7c8=_7c7; +_7c7=_7c6; +_7c6=_7c5[1]; +_7c5=_7c5[0]; +} +if(_7c9 instanceof String||typeof _7c9=="string"){ +_7c9=_7c9.split(","); +} +if(!isNaN(_7c7)){ +_7c7=[Number(_7c7),Number(_7c7)]; +}else{ +if(!(_7c7 instanceof Array||typeof _7c7=="array")){ +_7c7=[0,0]; +} +} +var _7cb=dojo.html.getScroll().offset; +var view=dojo.html.getViewport(); +node=dojo.byId(node); +var _7cd=node.style.display; +node.style.display=""; +var bb=dojo.html.getBorderBox(node); +var w=bb.width; +var h=bb.height; +node.style.display=_7cd; +if(!(_7c9 instanceof Array||typeof _7c9=="array")){ +_7c9=["TL"]; +} +var _7d1,_7d2,_7d3=Infinity,_7d4; +for(var _7d5=0;_7d5<_7c9.length;++_7d5){ +var _7d6=_7c9[_7d5]; +var _7d7=true; +var tryX=_7c5-(_7d6.charAt(1)=="L"?0:w)+_7c7[0]*(_7d6.charAt(1)=="L"?1:-1); +var tryY=_7c6-(_7d6.charAt(0)=="T"?0:h)+_7c7[1]*(_7d6.charAt(0)=="T"?1:-1); +if(_7c8){ +tryX-=_7cb.x; +tryY-=_7cb.y; +} +if(tryX<0){ +tryX=0; +_7d7=false; +} +if(tryY<0){ +tryY=0; +_7d7=false; +} +var x=tryX+w; +if(x>view.width){ +x=view.width-w; +_7d7=false; +}else{ +x=tryX; +} +x=Math.max(_7c7[0],x)+_7cb.x; +var y=tryY+h; +if(y>view.height){ +y=view.height-h; +_7d7=false; +}else{ +y=tryY; +} +y=Math.max(_7c7[1],y)+_7cb.y; +if(_7d7){ +_7d1=x; +_7d2=y; +_7d3=0; +_7d4=_7d6; +break; +}else{ +var dist=Math.pow(x-tryX-_7cb.x,2)+Math.pow(y-tryY-_7cb.y,2); +if(_7d3>dist){ +_7d3=dist; +_7d1=x; +_7d2=y; +_7d4=_7d6; +} +} +} +if(!_7ca){ +node.style.left=_7d1+"px"; +node.style.top=_7d2+"px"; +} +return {left:_7d1,top:_7d2,x:_7d1,y:_7d2,dist:_7d3,corner:_7d4}; +}; +dojo.html.placeOnScreenPoint=function(node,_7de,_7df,_7e0,_7e1){ +dojo.deprecated("dojo.html.placeOnScreenPoint","use dojo.html.placeOnScreen() instead","0.5"); +return dojo.html.placeOnScreen(node,_7de,_7df,_7e0,_7e1,["TL","TR","BL","BR"]); +}; +dojo.html.placeOnScreenAroundElement=function(node,_7e3,_7e4,_7e5,_7e6,_7e7){ +var best,_7e9=Infinity; +_7e3=dojo.byId(_7e3); +var _7ea=_7e3.style.display; +_7e3.style.display=""; +var mb=dojo.html.getElementBox(_7e3,_7e5); +var _7ec=mb.width; +var _7ed=mb.height; +var _7ee=dojo.html.getAbsolutePosition(_7e3,true,_7e5); +_7e3.style.display=_7ea; +for(var _7ef in _7e6){ +var pos,_7f1,_7f2; +var _7f3=_7e6[_7ef]; +_7f1=_7ee.x+(_7ef.charAt(1)=="L"?0:_7ec); +_7f2=_7ee.y+(_7ef.charAt(0)=="T"?0:_7ed); +pos=dojo.html.placeOnScreen(node,_7f1,_7f2,_7e4,true,_7f3,true); +if(pos.dist==0){ +best=pos; +break; +}else{ +if(_7e9>pos.dist){ +_7e9=pos.dist; +best=pos; +} +} +} +if(!_7e7){ +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).height<=node.parentNode.scrollHeight){ +node.scrollIntoView(false); +} +}else{ +if(dojo.render.html.mozilla){ +node.scrollIntoView(false); +}else{ +var _7f5=node.parentNode; +var _7f6=_7f5.scrollTop+dojo.html.getBorderBox(_7f5).height; +var _7f7=node.offsetTop+dojo.html.getMarginBox(node).height; +if(_7f6<_7f7){ +_7f5.scrollTop+=(_7f7-_7f6); +}else{ +if(_7f5.scrollTop>node.offsetTop){ +_7f5.scrollTop-=(_7f5.scrollTop-node.offsetTop); +} +} +} +} +}; +dojo.provide("dojo.lfx.toggle"); +dojo.lfx.toggle.plain={show:function(node,_7f9,_7fa,_7fb){ +dojo.html.show(node); +if(dojo.lang.isFunction(_7fb)){ +_7fb(); +} +},hide:function(node,_7fd,_7fe,_7ff){ +dojo.html.hide(node); +if(dojo.lang.isFunction(_7ff)){ +_7ff(); +} +}}; +dojo.lfx.toggle.fade={show:function(node,_801,_802,_803){ +dojo.lfx.fadeShow(node,_801,_802,_803).play(); +},hide:function(node,_805,_806,_807){ +dojo.lfx.fadeHide(node,_805,_806,_807).play(); +}}; +dojo.lfx.toggle.wipe={show:function(node,_809,_80a,_80b){ +dojo.lfx.wipeIn(node,_809,_80a,_80b).play(); +},hide:function(node,_80d,_80e,_80f){ +dojo.lfx.wipeOut(node,_80d,_80e,_80f).play(); +}}; +dojo.lfx.toggle.explode={show:function(node,_811,_812,_813,_814){ +dojo.lfx.explode(_814||{x:0,y:0,width:0,height:0},node,_811,_812,_813).play(); +},hide:function(node,_816,_817,_818,_819){ +dojo.lfx.implode(node,_819||{x:0,y:0,width:0,height:0},_816,_817,_818).play(); +}}; +dojo.provide("dojo.widget.HtmlWidget"); +dojo.declare("dojo.widget.HtmlWidget",dojo.widget.DomWidget,{templateCssPath:null,templatePath:null,lang:"",toggle:"plain",toggleDuration:150,initialize:function(args,frag){ +},postMixInProperties:function(args,frag){ +if(this.lang===""){ +this.lang=null; +} +this.toggleObj=dojo.lfx.toggle[this.toggle.toLowerCase()]||dojo.lfx.toggle.plain; +},createNodesFromText:function(txt,wrap){ +return dojo.html.createNodesFromText(txt,wrap); +},destroyRendering:function(_820){ +try{ +if(this.bgIframe){ +this.bgIframe.remove(); +delete this.bgIframe; +} +if(!_820&&this.domNode){ +dojo.event.browser.clean(this.domNode); +} +dojo.widget.HtmlWidget.superclass.destroyRendering.call(this); +} +catch(e){ +} +},isShowing:function(){ +return dojo.html.isShowing(this.domNode); +},toggleShowing:function(){ +if(this.isShowing()){ +this.hide(); +}else{ +this.show(); +} +},show:function(){ +if(this.isShowing()){ +return; +} +this.animationInProgress=true; +this.toggleObj.show(this.domNode,this.toggleDuration,null,dojo.lang.hitch(this,this.onShow),this.explodeSrc); +},onShow:function(){ +this.animationInProgress=false; +this.checkSize(); +},hide:function(){ +if(!this.isShowing()){ +return; +} +this.animationInProgress=true; +this.toggleObj.hide(this.domNode,this.toggleDuration,null,dojo.lang.hitch(this,this.onHide),this.explodeSrc); +},onHide:function(){ +this.animationInProgress=false; +},_isResized:function(w,h){ +if(!this.isShowing()){ +return false; +} +var wh=dojo.html.getMarginBox(this.domNode); +var _824=w||wh.width; +var _825=h||wh.height; +if(this.width==_824&&this.height==_825){ +return false; +} +this.width=_824; +this.height=_825; +return true; +},checkSize:function(){ +if(!this._isResized()){ +return; +} +this.onResized(); +},resizeTo:function(w,h){ +dojo.html.setMarginBox(this.domNode,{width:w,height:h}); +if(this.isShowing()){ +this.onResized(); +} +},resizeSoon:function(){ +if(this.isShowing()){ +dojo.lang.setTimeout(this,this.onResized,0); +} +},onResized:function(){ +dojo.lang.forEach(this.children,function(_828){ +if(_828.checkSize){ +_828.checkSize(); +} +}); +}}); +dojo.kwCompoundRequire({common:["dojo.xml.Parse","dojo.widget.Widget","dojo.widget.Parse","dojo.widget.Manager"],browser:["dojo.widget.DomWidget","dojo.widget.HtmlWidget"],dashboard:["dojo.widget.DomWidget","dojo.widget.HtmlWidget"],svg:["dojo.widget.SvgWidget"],rhino:["dojo.widget.SwtWidget"]}); +dojo.provide("dojo.widget.*"); +dojo.kwCompoundRequire({common:["dojo.html.common","dojo.html.style"]}); +dojo.provide("dojo.html.*"); +dojo.provide("dojo.html.selection"); +dojo.html.selectionType={NONE:0,TEXT:1,CONTROL:2}; +dojo.html.clearSelection=function(){ +var _829=dojo.global(); +var _82a=dojo.doc(); +try{ +if(_829["getSelection"]){ +if(dojo.render.html.safari){ +_829.getSelection().collapse(); +}else{ +_829.getSelection().removeAllRanges(); +} +}else{ +if(_82a.selection){ +if(_82a.selection.empty){ +_82a.selection.empty(); +}else{ +if(_82a.selection.clear){ +_82a.selection.clear(); +} +} +} +} +return true; +} +catch(e){ +dojo.debug(e); +return false; +} +}; +dojo.html.disableSelection=function(_82b){ +_82b=dojo.byId(_82b)||dojo.body(); +var h=dojo.render.html; +if(h.mozilla){ +_82b.style.MozUserSelect="none"; +}else{ +if(h.safari){ +_82b.style.KhtmlUserSelect="none"; +}else{ +if(h.ie){ +_82b.unselectable="on"; +}else{ +return false; +} +} +} +return true; +}; +dojo.html.enableSelection=function(_82d){ +_82d=dojo.byId(_82d)||dojo.body(); +var h=dojo.render.html; +if(h.mozilla){ +_82d.style.MozUserSelect=""; +}else{ +if(h.safari){ +_82d.style.KhtmlUserSelect=""; +}else{ +if(h.ie){ +_82d.unselectable="off"; +}else{ +return false; +} +} +} +return true; +}; +dojo.html.selectElement=function(_82f){ +dojo.deprecated("dojo.html.selectElement","replaced by dojo.html.selection.selectElementChildren",0.5); +}; +dojo.html.selectInputText=function(_830){ +var _831=dojo.global(); +var _832=dojo.doc(); +_830=dojo.byId(_830); +if(_832["selection"]&&dojo.body()["createTextRange"]){ +var _833=_830.createTextRange(); +_833.moveStart("character",0); +_833.moveEnd("character",_830.value.length); +_833.select(); +}else{ +if(_831["getSelection"]){ +var _834=_831.getSelection(); +_830.setSelectionRange(0,_830.value.length); +} +} +_830.focus(); +}; +dojo.html.isSelectionCollapsed=function(){ +dojo.deprecated("dojo.html.isSelectionCollapsed","replaced by dojo.html.selection.isCollapsed",0.5); +return dojo.html.selection.isCollapsed(); +}; +dojo.lang.mixin(dojo.html.selection,{getType:function(){ +if(dojo.doc()["selection"]){ +return dojo.html.selectionType[dojo.doc().selection.type.toUpperCase()]; +}else{ +var _835=dojo.html.selectionType.TEXT; +var oSel; +try{ +oSel=dojo.global().getSelection(); +} +catch(e){ +} +if(oSel&&oSel.rangeCount==1){ +var _837=oSel.getRangeAt(0); +if(_837.startContainer==_837.endContainer&&(_837.endOffset-_837.startOffset)==1&&_837.startContainer.nodeType!=dojo.dom.TEXT_NODE){ +_835=dojo.html.selectionType.CONTROL; +} +} +return _835; +} +},isCollapsed:function(){ +var _838=dojo.global(); +var _839=dojo.doc(); +if(_839["selection"]){ +return _839.selection.createRange().text==""; +}else{ +if(_838["getSelection"]){ +var _83a=_838.getSelection(); +if(dojo.lang.isString(_83a)){ +return _83a==""; +}else{ +return _83a.isCollapsed||_83a.toString()==""; +} +} +} +},getSelectedElement:function(){ +if(dojo.html.selection.getType()==dojo.html.selectionType.CONTROL){ +if(dojo.doc()["selection"]){ +var _83b=dojo.doc().selection.createRange(); +if(_83b&&_83b.item){ +return dojo.doc().selection.createRange().item(0); +} +}else{ +var _83c=dojo.global().getSelection(); +return _83c.anchorNode.childNodes[_83c.anchorOffset]; +} +} +},getParentElement:function(){ +if(dojo.html.selection.getType()==dojo.html.selectionType.CONTROL){ +var p=dojo.html.selection.getSelectedElement(); +if(p){ +return p.parentNode; +} +}else{ +if(dojo.doc()["selection"]){ +return dojo.doc().selection.createRange().parentElement(); +}else{ +var _83e=dojo.global().getSelection(); +if(_83e){ +var node=_83e.anchorNode; +while(node&&node.nodeType!=dojo.dom.ELEMENT_NODE){ +node=node.parentNode; +} +return node; +} +} +} +},getSelectedText:function(){ +if(dojo.doc()["selection"]){ +if(dojo.html.selection.getType()==dojo.html.selectionType.CONTROL){ +return null; +} +return dojo.doc().selection.createRange().text; +}else{ +var _840=dojo.global().getSelection(); +if(_840){ +return _840.toString(); +} +} +},getSelectedHtml:function(){ +if(dojo.doc()["selection"]){ +if(dojo.html.selection.getType()==dojo.html.selectionType.CONTROL){ +return null; +} +return dojo.doc().selection.createRange().htmlText; +}else{ +var _841=dojo.global().getSelection(); +if(_841&&_841.rangeCount){ +var frag=_841.getRangeAt(0).cloneContents(); +var div=document.createElement("div"); +div.appendChild(frag); +return div.innerHTML; +} +return null; +} +},hasAncestorElement:function(_844){ +return (dojo.html.selection.getAncestorElement.apply(this,arguments)!=null); +},getAncestorElement:function(_845){ +var node=dojo.html.selection.getSelectedElement()||dojo.html.selection.getParentElement(); +while(node){ +if(dojo.html.selection.isTag(node,arguments).length>0){ +return node; +} +node=node.parentNode; +} +return null; +},isTag:function(node,tags){ +if(node&&node.tagName){ +for(var i=0;i=0)){ +this._fire(); +} +},_continue:function(res){ +this._resback(res); +this._unpause(); +},_resback:function(res){ +this.fired=((res instanceof Error)?1:0); +this.results[this.fired]=res; +this._fire(); +},_check:function(){ +if(this.fired!=-1){ +if(!this.silentlyCancelled){ +dojo.raise("already called!"); +} +this.silentlyCancelled=false; +return; +} +},callback:function(res){ +this._check(); +this._resback(res); +},errback:function(res){ +this._check(); +if(!(res instanceof Error)){ +res=new Error(res); +} +this._resback(res); +},addBoth:function(cb,cbfn){ +var _86c=this.getFunctionFromArgs(cb,cbfn); +if(arguments.length>2){ +_86c=dojo.lang.curryArguments(null,_86c,arguments,2); +} +return this.addCallbacks(_86c,_86c); +},addCallback:function(cb,cbfn){ +var _86f=this.getFunctionFromArgs(cb,cbfn); +if(arguments.length>2){ +_86f=dojo.lang.curryArguments(null,_86f,arguments,2); +} +return this.addCallbacks(_86f,null); +},addErrback:function(cb,cbfn){ +var _872=this.getFunctionFromArgs(cb,cbfn); +if(arguments.length>2){ +_872=dojo.lang.curryArguments(null,_872,arguments,2); +} +return this.addCallbacks(null,_872); +return this.addCallbacks(null,cbfn); +},addCallbacks:function(cb,eb){ +this.chain.push([cb,eb]); +if(this.fired>=0){ +this._fire(); +} +return this; +},_fire:function(){ +var _875=this.chain; +var _876=this.fired; +var res=this.results[_876]; +var self=this; +var cb=null; +while(_875.length>0&&this.paused==0){ +var pair=_875.shift(); +var f=pair[_876]; +if(f==null){ +continue; +} +try{ +res=f(res); +_876=((res instanceof Error)?1:0); +if(res instanceof dojo.Deferred){ +cb=function(res){ +self._continue(res); +}; +this._pause(); +} +} +catch(err){ +_876=1; +res=err; +} +} +this.fired=_876; +this.results[_876]=res; +if((cb)&&(this.paused)){ +res.addBoth(cb); +} +}}); +dojo.provide("dojo.widget.RichText"); +if(!djConfig["useXDomain"]||djConfig["allowXdRichTextSave"]){ +if(dojo.hostenv.post_load_){ +(function(){ +var _87d=dojo.doc().createElement("textarea"); +_87d.id="dojo.widget.RichText.savedContent"; +_87d.style="display:none;position:absolute;top:-100px;left:-100px;height:3px;width:3px;overflow:hidden;"; +dojo.body().appendChild(_87d); +})(); +}else{ +try{ +dojo.doc().write(""); +} +catch(e){ +} +} +} +dojo.widget.defineWidget("dojo.widget.RichText",dojo.widget.HtmlWidget,function(){ +this.contentPreFilters=[]; +this.contentPostFilters=[]; +this.contentDomPreFilters=[]; +this.contentDomPostFilters=[]; +this.editingAreaStyleSheets=[]; +if(dojo.render.html.moz){ +this.contentPreFilters.push(this._fixContentForMoz); +} +this._keyHandlers={}; +if(dojo.Deferred){ +this.onLoadDeferred=new dojo.Deferred(); +} +},{inheritWidth:false,focusOnLoad:false,saveName:"",styleSheets:"",_content:"",height:"",minHeight:"1em",isClosed:true,isLoaded:false,useActiveX:false,relativeImageUrls:false,_SEPARATOR:"@@**%%__RICHTEXTBOUNDRY__%%**@@",onLoadDeferred:null,fillInTemplate:function(){ +dojo.event.topic.publish("dojo.widget.RichText::init",this); +this.open(); +dojo.event.connect(this,"onKeyPressed",this,"afterKeyPress"); +dojo.event.connect(this,"onKeyPress",this,"keyPress"); +dojo.event.connect(this,"onKeyDown",this,"keyDown"); +dojo.event.connect(this,"onKeyUp",this,"keyUp"); +this.setupDefaultShortcuts(); +},setupDefaultShortcuts:function(){ +var ctrl=this.KEY_CTRL; +var exec=function(cmd,arg){ +return arguments.length==1?function(){ +this.execCommand(cmd); +}:function(){ +this.execCommand(cmd,arg); +}; +}; +this.addKeyHandler("b",ctrl,exec("bold")); +this.addKeyHandler("i",ctrl,exec("italic")); +this.addKeyHandler("u",ctrl,exec("underline")); +this.addKeyHandler("a",ctrl,exec("selectall")); +this.addKeyHandler("s",ctrl,function(){ +this.save(true); +}); +this.addKeyHandler("1",ctrl,exec("formatblock","h1")); +this.addKeyHandler("2",ctrl,exec("formatblock","h2")); +this.addKeyHandler("3",ctrl,exec("formatblock","h3")); +this.addKeyHandler("4",ctrl,exec("formatblock","h4")); +this.addKeyHandler("\\",ctrl,exec("insertunorderedlist")); +if(!dojo.render.html.ie){ +this.addKeyHandler("Z",ctrl,exec("redo")); +} +},events:["onBlur","onFocus","onKeyPress","onKeyDown","onKeyUp","onClick"],open:function(_882){ +if(this.onLoadDeferred.fired>=0){ +this.onLoadDeferred=new dojo.Deferred(); +} +var h=dojo.render.html; +if(!this.isClosed){ +this.close(); +} +dojo.event.topic.publish("dojo.widget.RichText::open",this); +this._content=""; +if((arguments.length==1)&&(_882["nodeName"])){ +this.domNode=_882; +} +if((this.domNode["nodeName"])&&(this.domNode.nodeName.toLowerCase()=="textarea")){ +this.textarea=this.domNode; +var html=this._preFilterContent(this.textarea.value); +this.domNode=dojo.doc().createElement("div"); +dojo.html.copyStyle(this.domNode,this.textarea); +var _885=dojo.lang.hitch(this,function(){ +with(this.textarea.style){ +display="block"; +position="absolute"; +left=top="-1000px"; +if(h.ie){ +this.__overflow=overflow; +overflow="hidden"; +} +} +}); +if(h.ie){ +setTimeout(_885,10); +}else{ +_885(); +} +if(!h.safari){ +dojo.html.insertBefore(this.domNode,this.textarea); +} +if(this.textarea.form){ +dojo.event.connect("before",this.textarea.form,"onsubmit",dojo.lang.hitch(this,function(){ +this.textarea.value=this.getEditorContent(); +})); +} +var _886=this; +dojo.event.connect(this,"postCreate",function(){ +dojo.html.insertAfter(_886.textarea,_886.domNode); +}); +}else{ +var html=this._preFilterContent(dojo.string.trim(this.domNode.innerHTML)); +} +if(html==""){ +html=" "; +} +var _887=dojo.html.getContentBox(this.domNode); +this._oldHeight=_887.height; +this._oldWidth=_887.width; +this._firstChildContributingMargin=this._getContributingMargin(this.domNode,"top"); +this._lastChildContributingMargin=this._getContributingMargin(this.domNode,"bottom"); +this.savedContent=html; +this.domNode.innerHTML=""; +this.editingArea=dojo.doc().createElement("div"); +this.domNode.appendChild(this.editingArea); +if((this.domNode["nodeName"])&&(this.domNode.nodeName=="LI")){ +this.domNode.innerHTML="
"; +} +if(this.saveName!=""&&(!djConfig["useXDomain"]||djConfig["allowXdRichTextSave"])){ +var _888=dojo.doc().getElementById("dojo.widget.RichText.savedContent"); +if(_888.value!=""){ +var _889=_888.value.split(this._SEPARATOR); +for(var i=0;i<_889.length;i++){ +var data=_889[i].split(":"); +if(data[0]==this.saveName){ +html=data[1]; +_889.splice(i,1); +break; +} +} +} +dojo.event.connect("before",window,"onunload",this,"_saveContent"); +} +if(h.ie70&&this.useActiveX){ +dojo.debug("activeX in ie70 is not currently supported, useActiveX is ignored for now."); +this.useActiveX=false; +} +if(this.useActiveX&&h.ie){ +var self=this; +setTimeout(function(){ +self._drawObject(html); +},0); +}else{ +if(h.ie||this._safariIsLeopard()||h.opera){ +this.iframe=dojo.doc().createElement("iframe"); +this.iframe.src="javascript:void(0)"; +this.editorObject=this.iframe; +with(this.iframe.style){ +border="0"; +width="100%"; +} +this.iframe.frameBorder=0; +this.editingArea.appendChild(this.iframe); +this.window=this.iframe.contentWindow; +this.document=this.window.document; +this.document.open(); +this.document.write("
"); +this.document.close(); +this.editNode=this.document.body.firstChild; +this.editNode.contentEditable=true; +with(this.iframe.style){ +if(h.ie70){ +if(this.height){ +height=this.height; +} +if(this.minHeight){ +minHeight=this.minHeight; +} +}else{ +height=this.height?this.height:this.minHeight; +} +} +var _88d=["p","pre","address","h1","h2","h3","h4","h5","h6","ol","div","ul"]; +var _88e=""; +for(var i in _88d){ +if(_88d[i].charAt(1)!="l"){ +_88e+="<"+_88d[i]+">content"; +}else{ +_88e+="<"+_88d[i]+">
  • content
  • "; +} +} +with(this.editNode.style){ +position="absolute"; +left="-2000px"; +top="-2000px"; +} +this.editNode.innerHTML=_88e; +var node=this.editNode.firstChild; +while(node){ +dojo.withGlobal(this.window,"selectElement",dojo.html.selection,[node.firstChild]); +var _890=node.tagName.toLowerCase(); +this._local2NativeFormatNames[_890]=this.queryCommandValue("formatblock"); +this._native2LocalFormatNames[this._local2NativeFormatNames[_890]]=_890; +node=node.nextSibling; +} +with(this.editNode.style){ +position=""; +left=""; +top=""; +} +this.editNode.innerHTML=html; +if(this.height){ +this.document.body.style.overflowY="scroll"; +} +dojo.lang.forEach(this.events,function(e){ +dojo.event.connect(this.editNode,e.toLowerCase(),this,e); +},this); +this.onLoad(); +}else{ +this._drawIframe(html); +this.editorObject=this.iframe; +} +} +if(this.domNode.nodeName=="LI"){ +this.domNode.lastChild.style.marginTop="-1.2em"; +} +dojo.html.addClass(this.domNode,"RichTextEditable"); +this.isClosed=false; +},_hasCollapseableMargin:function(_892,side){ +if(dojo.html.getPixelValue(_892,"border-"+side+"-width",false)){ +return false; +}else{ +if(dojo.html.getPixelValue(_892,"padding-"+side,false)){ +return false; +}else{ +return true; +} +} +},_getContributingMargin:function(_894,_895){ +if(_895=="top"){ +var _896="previousSibling"; +var _897="nextSibling"; +var _898="firstChild"; +var _899="margin-top"; +var _89a="margin-bottom"; +}else{ +var _896="nextSibling"; +var _897="previousSibling"; +var _898="lastChild"; +var _899="margin-bottom"; +var _89a="margin-top"; +} +var _89b=dojo.html.getPixelValue(_894,_899,false); +function isSignificantNode(_89c){ +return !(_89c.nodeType==3&&dojo.string.isBlank(_89c.data))&&dojo.html.getStyle(_89c,"display")!="none"&&!dojo.html.isPositionAbsolute(_89c); +} +var _89d=0; +var _89e=_894[_898]; +while(_89e){ +while((!isSignificantNode(_89e))&&_89e[_897]){ +_89e=_89e[_897]; +} +_89d=Math.max(_89d,dojo.html.getPixelValue(_89e,_899,false)); +if(!this._hasCollapseableMargin(_89e,_895)){ +break; +} +_89e=_89e[_898]; +} +if(!this._hasCollapseableMargin(_894,_895)){ +return parseInt(_89d); +} +var _89f=0; +var _8a0=_894[_896]; +while(_8a0){ +if(isSignificantNode(_8a0)){ +_89f=dojo.html.getPixelValue(_8a0,_89a,false); +break; +} +_8a0=_8a0[_896]; +} +if(!_8a0){ +_89f=dojo.html.getPixelValue(_894.parentNode,_899,false); +} +if(_89d>_89b){ +return parseInt(Math.max((_89d-_89b)-_89f,0)); +}else{ +return 0; +} +},_drawIframe:function(html){ +var _8a2=Boolean(dojo.render.html.moz&&(typeof window.XML=="undefined")); +if(!this.iframe){ +var _8a3=(new dojo.uri.Uri(dojo.doc().location)).host; +this.iframe=dojo.doc().createElement("iframe"); +with(this.iframe){ +style.border="none"; +style.lineHeight="0"; +style.verticalAlign="bottom"; +scrolling=this.height?"auto":"no"; +} +} +if(djConfig["useXDomain"]&&!djConfig["dojoRichTextFrameUrl"]){ +dojo.debug("dojo.widget.RichText: When using cross-domain Dojo builds,"+" please save src/widget/templates/richtextframe.html to your domain and set djConfig.dojoRichTextFrameUrl"+" to the path on your domain to richtextframe.html"); +} +this.iframe.src=(djConfig["dojoRichTextFrameUrl"]||dojo.uri.moduleUri("dojo.widget","templates/richtextframe.html"))+((dojo.doc().domain!=_8a3)?("#"+dojo.doc().domain):""); +this.iframe.width=this.inheritWidth?this._oldWidth:"100%"; +if(this.height){ +this.iframe.style.height=this.height; +}else{ +var _8a4=this._oldHeight; +if(this._hasCollapseableMargin(this.domNode,"top")){ +_8a4+=this._firstChildContributingMargin; +} +if(this._hasCollapseableMargin(this.domNode,"bottom")){ +_8a4+=this._lastChildContributingMargin; +} +this.iframe.height=_8a4; +} +var _8a5=dojo.doc().createElement("div"); +_8a5.innerHTML=html; +this.editingArea.appendChild(_8a5); +if(this.relativeImageUrls){ +var imgs=_8a5.getElementsByTagName("img"); +for(var i=0;i *:first-child{padding-top:0 !important;margin-top:"+this._firstChildContributingMargin+"px !important;}"+"body > *:last-child{padding-bottom:0 !important;margin-bottom:"+this._lastChildContributingMargin+"px !important;}"+"li > ul:-moz-first-node, li > ol:-moz-first-node{padding-top:1.2em;}\n"+"li{min-height:1.2em;}"+"",this.document); +dojo.html.removeNode(_8a5); +this.document.body.innerHTML=html; +if(_8a2||dojo.render.html.safari){ +this.document.designMode="on"; +} +this.onLoad(); +}else{ +dojo.html.removeNode(_8a5); +this.editNode.innerHTML=html; +this.onDisplayChanged(); +} +}); +if(this.editNode){ +_8ab(); +}else{ +if(dojo.render.html.moz){ +this.iframe.onload=function(){ +setTimeout(_8ab,250); +}; +}else{ +this.iframe.onload=_8ab; +} +} +},_applyEditingAreaStyleSheets:function(){ +var _8b2=[]; +if(this.styleSheets){ +_8b2=this.styleSheets.split(";"); +this.styleSheets=""; +} +_8b2=_8b2.concat(this.editingAreaStyleSheets); +this.editingAreaStyleSheets=[]; +if(_8b2.length>0){ +for(var i=0;i<_8b2.length;i++){ +var url=_8b2[i]; +if(url){ +this.addStyleSheet(dojo.uri.dojoUri(url)); +} +} +} +},addStyleSheet:function(uri){ +var url=uri.toString(); +if(dojo.lang.find(this.editingAreaStyleSheets,url)>-1){ +dojo.debug("dojo.widget.RichText.addStyleSheet: Style sheet "+url+" is already applied to the editing area!"); +return; +} +if(url.charAt(0)=="."||(url.charAt(0)!="/"&&!uri.host)){ +url=(new dojo.uri.Uri(dojo.global().location,url)).toString(); +} +this.editingAreaStyleSheets.push(url); +if(this.document.createStyleSheet){ +this.document.createStyleSheet(url); +}else{ +var head=this.document.getElementsByTagName("head")[0]; +var _8b8=this.document.createElement("link"); +with(_8b8){ +rel="stylesheet"; +type="text/css"; +href=url; +} +head.appendChild(_8b8); +} +},removeStyleSheet:function(uri){ +var url=uri.toString(); +if(url.charAt(0)=="."||(url.charAt(0)!="/"&&!uri.host)){ +url=(new dojo.uri.Uri(dojo.global().location,url)).toString(); +} +var _8bb=dojo.lang.find(this.editingAreaStyleSheets,url); +if(_8bb==-1){ +dojo.debug("dojo.widget.RichText.removeStyleSheet: Style sheet "+url+" is not applied to the editing area so it can not be removed!"); +return; +} +delete this.editingAreaStyleSheets[_8bb]; +var _8bc=this.document.getElementsByTagName("link"); +for(var i=0;i<_8bc.length;i++){ +if(_8bc[i].href==url){ +if(dojo.render.html.ie){ +_8bc[i].href=""; +} +dojo.html.removeNode(_8bc[i]); +break; +} +} +},_drawObject:function(html){ +this.object=dojo.html.createExternalElement(dojo.doc(),"object"); +with(this.object){ +classid="clsid:2D360201-FFF5-11D1-8D03-00A0C959BC0A"; +width=this.inheritWidth?this._oldWidth:"100%"; +style.height=this.height?this.height:(this._oldHeight+"px"); +Scrollbars=this.height?true:false; +Appearance=this._activeX.appearance.flat; +} +this.editorObject=this.object; +this.editingArea.appendChild(this.object); +this.object.attachEvent("DocumentComplete",dojo.lang.hitch(this,"onLoad")); +dojo.lang.forEach(this.events,function(e){ +this.object.attachEvent(e.toLowerCase(),dojo.lang.hitch(this,e)); +},this); +this.object.DocumentHTML=""+""+""+"
    "+html+"
    "; +this._cacheLocalBlockFormatNames(); +},_local2NativeFormatNames:{},_native2LocalFormatNames:{},_cacheLocalBlockFormatNames:function(){ +if(!this._native2LocalFormatNames["p"]){ +var obj=this.object; +var _8c1=false; +if(!obj){ +try{ +obj=dojo.html.createExternalElement(dojo.doc(),"object"); +obj.classid="clsid:2D360201-FFF5-11D1-8D03-00A0C959BC0A"; +dojo.body().appendChild(obj); +obj.DocumentHTML=""; +} +catch(e){ +_8c1=true; +} +} +try{ +var _8c2=new ActiveXObject("DEGetBlockFmtNamesParam.DEGetBlockFmtNamesParam"); +obj.ExecCommand(this._activeX.command["getblockformatnames"],0,_8c2); +var _8c3=new VBArray(_8c2.Names); +var _8c4=_8c3.toArray(); +var _8c5=["p","pre","address","h1","h2","h3","h4","h5","h6","ol","ul","","","","","div"]; +for(var i=0;i<_8c5.length;++i){ +if(_8c5[i].length>0){ +this._local2NativeFormatNames[_8c4[i]]=_8c5[i]; +this._native2LocalFormatNames[_8c5[i]]=_8c4[i]; +} +} +} +catch(e){ +_8c1=true; +} +if(obj&&!this.object){ +dojo.body().removeChild(obj); +} +} +return !_8c1; +},_isResized:function(){ +return false; +},onLoad:function(e){ +this.isLoaded=true; +if(this.object){ +this.document=this.object.DOM; +this.window=this.document.parentWindow; +this.editNode=this.document.body.firstChild; +this.editingArea.style.height=this.height?this.height:this.minHeight; +if(!this.height){ +this.connect(this,"onDisplayChanged","_updateHeight"); +} +this.window._frameElement=this.object; +}else{ +if(this.iframe&&!dojo.render.html.ie){ +this.editNode=this.document.body; +if(!this.height){ +this.connect(this,"onDisplayChanged","_updateHeight"); +} +try{ +this.document.execCommand("useCSS",false,true); +this.document.execCommand("styleWithCSS",false,false); +} +catch(e2){ +} +if(dojo.render.html.safari){ +this.connect(this.editNode,"onblur","onBlur"); +this.connect(this.editNode,"onfocus","onFocus"); +this.connect(this.editNode,"onclick","onFocus"); +this.interval=setInterval(dojo.lang.hitch(this,"onDisplayChanged"),750); +}else{ +if(dojo.render.html.mozilla||dojo.render.html.opera){ +var doc=this.document; +var _8c9=dojo.event.browser.addListener; +var self=this; +dojo.lang.forEach(this.events,function(e){ +var l=_8c9(self.document,e.substr(2).toLowerCase(),dojo.lang.hitch(self,e)); +if(e=="onBlur"){ +var _8cd={unBlur:function(e){ +dojo.event.browser.removeListener(doc,"blur",l); +}}; +dojo.event.connect("before",self,"close",_8cd,"unBlur"); +} +}); +} +} +}else{ +if(dojo.render.html.ie){ +if(!this.height){ +this.connect(this,"onDisplayChanged","_updateHeight"); +} +this.editNode.style.zoom=1; +} +} +} +this._applyEditingAreaStyleSheets(); +if(this.focusOnLoad){ +this.focus(); +} +this.onDisplayChanged(e); +if(this.onLoadDeferred){ +this.onLoadDeferred.callback(true); +} +},onKeyDown:function(e){ +if((!e)&&(this.object)){ +e=dojo.event.browser.fixEvent(this.window.event); +} +if((dojo.render.html.ie)&&(e.keyCode==e.KEY_TAB)){ +e.preventDefault(); +e.stopPropagation(); +this.execCommand((e.shiftKey?"outdent":"indent")); +}else{ +if(dojo.render.html.ie){ +if((65<=e.keyCode)&&(e.keyCode<=90)){ +e.charCode=e.keyCode; +this.onKeyPress(e); +} +} +} +},onKeyUp:function(e){ +return; +},KEY_CTRL:1,onKeyPress:function(e){ +if((!e)&&(this.object)){ +e=dojo.event.browser.fixEvent(this.window.event); +} +var _8d2=e.ctrlKey?this.KEY_CTRL:0; +if(this._keyHandlers[e.key]){ +var _8d3=this._keyHandlers[e.key],i=0,_8d5; +while(_8d5=_8d3[i++]){ +if(_8d2==_8d5.modifiers){ +e.preventDefault(); +_8d5.handler.call(this); +break; +} +} +} +dojo.lang.setTimeout(this,this.onKeyPressed,1,e); +},addKeyHandler:function(key,_8d7,_8d8){ +if(!(this._keyHandlers[key] instanceof Array)){ +this._keyHandlers[key]=[]; +} +this._keyHandlers[key].push({modifiers:_8d7||0,handler:_8d8}); +},onKeyPressed:function(e){ +this.onDisplayChanged(); +},onClick:function(e){ +this.onDisplayChanged(e); +},onBlur:function(e){ +},_initialFocus:true,onFocus:function(e){ +if((dojo.render.html.mozilla)&&(this._initialFocus)){ +this._initialFocus=false; +if(dojo.string.trim(this.editNode.innerHTML)==" "){ +this.placeCursorAtStart(); +} +} +},blur:function(){ +if(this.iframe){ +this.window.blur(); +}else{ +if(this.object){ +this.document.body.blur(); +}else{ +if(this.editNode){ +this.editNode.blur(); +} +} +} +},focus:function(){ +if(this.iframe&&!dojo.render.html.ie){ +this.window.focus(); +}else{ +if(this.object){ +this.document.focus(); +}else{ +if(this.editNode&&this.editNode.focus){ +this.editNode.focus(); +}else{ +dojo.debug("Have no idea how to focus into the editor!"); +} +} +} +},onDisplayChanged:function(e){ +},_activeX:{command:{bold:5000,italic:5023,underline:5048,justifycenter:5024,justifyleft:5025,justifyright:5026,cut:5003,copy:5002,paste:5032,"delete":5004,undo:5049,redo:5033,removeformat:5034,selectall:5035,unlink:5050,indent:5018,outdent:5031,insertorderedlist:5030,insertunorderedlist:5051,inserttable:5022,insertcell:5019,insertcol:5020,insertrow:5021,deletecells:5005,deletecols:5006,deleterows:5007,mergecells:5029,splitcell:5047,setblockformat:5043,getblockformat:5011,getblockformatnames:5012,setfontname:5044,getfontname:5013,setfontsize:5045,getfontsize:5014,setbackcolor:5042,getbackcolor:5010,setforecolor:5046,getforecolor:5015,findtext:5008,font:5009,hyperlink:5016,image:5017,lockelement:5027,makeabsolute:5028,sendbackward:5036,bringforward:5037,sendbelowtext:5038,bringabovetext:5039,sendtoback:5040,bringtofront:5041,properties:5052},ui:{"default":0,prompt:1,noprompt:2},status:{notsupported:0,disabled:1,enabled:3,latched:7,ninched:11},appearance:{flat:0,inset:1},state:{unchecked:0,checked:1,gray:2}},_normalizeCommand:function(cmd){ +var drh=dojo.render.html; +var _8e0=cmd.toLowerCase(); +if(_8e0=="formatblock"){ +if(drh.safari){ +_8e0="heading"; +} +}else{ +if(this.object){ +switch(_8e0){ +case "createlink": +_8e0="hyperlink"; +break; +case "insertimage": +_8e0="image"; +break; +} +}else{ +if(_8e0=="hilitecolor"&&!drh.mozilla){ +_8e0="backcolor"; +} +} +} +return _8e0; +},_safariIsLeopard:function(){ +var _8e1=false; +if(dojo.render.html.safari){ +var tmp=dojo.render.html.UA.split("AppleWebKit/")[1]; +var ver=parseFloat(tmp.split(" ")[0]); +if(ver>=420){ +_8e1=true; +} +} +return _8e1; +},queryCommandAvailable:function(_8e4){ +var ie=1; +var _8e6=1<<1; +var _8e7=1<<2; +var _8e8=1<<3; +var _8e9=1<<4; +var _8ea=this._safariIsLeopard(); +function isSupportedBy(_8eb){ +return {ie:Boolean(_8eb&ie),mozilla:Boolean(_8eb&_8e6),safari:Boolean(_8eb&_8e7),safari420:Boolean(_8eb&_8e9),opera:Boolean(_8eb&_8e8)}; +} +var _8ec=null; +switch(_8e4.toLowerCase()){ +case "bold": +case "italic": +case "underline": +case "subscript": +case "superscript": +case "fontname": +case "fontsize": +case "forecolor": +case "hilitecolor": +case "justifycenter": +case "justifyfull": +case "justifyleft": +case "justifyright": +case "delete": +case "selectall": +_8ec=isSupportedBy(_8e6|ie|_8e7|_8e8); +break; +case "createlink": +case "unlink": +case "removeformat": +case "inserthorizontalrule": +case "insertimage": +case "insertorderedlist": +case "insertunorderedlist": +case "indent": +case "outdent": +case "formatblock": +case "inserthtml": +case "undo": +case "redo": +case "strikethrough": +_8ec=isSupportedBy(_8e6|ie|_8e8|_8e9); +break; +case "blockdirltr": +case "blockdirrtl": +case "dirltr": +case "dirrtl": +case "inlinedirltr": +case "inlinedirrtl": +_8ec=isSupportedBy(ie); +break; +case "cut": +case "copy": +case "paste": +_8ec=isSupportedBy(ie|_8e6|_8e9); +break; +case "inserttable": +_8ec=isSupportedBy(_8e6|(this.object?ie:0)); +break; +case "insertcell": +case "insertcol": +case "insertrow": +case "deletecells": +case "deletecols": +case "deleterows": +case "mergecells": +case "splitcell": +_8ec=isSupportedBy(this.object?ie:0); +break; +default: +return false; +} +return (dojo.render.html.ie&&_8ec.ie)||(dojo.render.html.mozilla&&_8ec.mozilla)||(dojo.render.html.safari&&_8ec.safari)||(_8ea&&_8ec.safari420)||(dojo.render.html.opera&&_8ec.opera); +},execCommand:function(_8ed,_8ee){ +var _8ef; +this.focus(); +_8ed=this._normalizeCommand(_8ed); +if(_8ee!=undefined){ +if(_8ed=="heading"){ +throw new Error("unimplemented"); +}else{ +if(_8ed=="formatblock"){ +if(this.object){ +_8ee=this._native2LocalFormatNames[_8ee]; +}else{ +if(dojo.render.html.ie){ +_8ee="<"+_8ee+">"; +} +} +} +} +} +if(this.object){ +switch(_8ed){ +case "hilitecolor": +_8ed="setbackcolor"; +break; +case "forecolor": +case "backcolor": +case "fontsize": +case "fontname": +_8ed="set"+_8ed; +break; +case "formatblock": +_8ed="setblockformat"; +} +if(_8ed=="strikethrough"){ +_8ed="inserthtml"; +var _8f0=this.document.selection.createRange(); +if(!_8f0.htmlText){ +return; +} +_8ee=_8f0.htmlText.strike(); +}else{ +if(_8ed=="inserthorizontalrule"){ +_8ed="inserthtml"; +_8ee="
    "; +} +} +if(_8ed=="inserthtml"){ +var _8f0=this.document.selection.createRange(); +if(this.document.selection.type.toUpperCase()=="CONTROL"){ +for(var i=0;i<_8f0.length;i++){ +_8f0.item(i).outerHTML=_8ee; +} +}else{ +_8f0.pasteHTML(_8ee); +_8f0.select(); +} +_8ef=true; +}else{ +if(arguments.length==1){ +_8ef=this.object.ExecCommand(this._activeX.command[_8ed],this._activeX.ui.noprompt); +}else{ +_8ef=this.object.ExecCommand(this._activeX.command[_8ed],this._activeX.ui.noprompt,_8ee); +} +} +}else{ +if(_8ed=="inserthtml"){ +if(dojo.render.html.ie){ +var _8f2=this.document.selection.createRange(); +_8f2.pasteHTML(_8ee); +_8f2.select(); +return true; +}else{ +return this.document.execCommand(_8ed,false,_8ee); +} +}else{ +if((_8ed=="unlink")&&(this.queryCommandEnabled("unlink"))&&(dojo.render.html.mozilla)){ +var _8f3=this.window.getSelection(); +var _8f4=_8f3.getRangeAt(0); +var _8f5=_8f4.startContainer; +var _8f6=_8f4.startOffset; +var _8f7=_8f4.endContainer; +var _8f8=_8f4.endOffset; +var a=dojo.withGlobal(this.window,"getAncestorElement",dojo.html.selection,["a"]); +dojo.withGlobal(this.window,"selectElement",dojo.html.selection,[a]); +_8ef=this.document.execCommand("unlink",false,null); +var _8f4=this.document.createRange(); +_8f4.setStart(_8f5,_8f6); +_8f4.setEnd(_8f7,_8f8); +_8f3.removeAllRanges(); +_8f3.addRange(_8f4); +return _8ef; +}else{ +if((_8ed=="hilitecolor")&&(dojo.render.html.mozilla)){ +this.document.execCommand("useCSS",false,false); +_8ef=this.document.execCommand(_8ed,false,_8ee); +this.document.execCommand("useCSS",false,true); +}else{ +if((dojo.render.html.ie)&&((_8ed=="backcolor")||(_8ed=="forecolor"))){ +_8ee=arguments.length>1?_8ee:null; +_8ef=this.document.execCommand(_8ed,false,_8ee); +}else{ +_8ee=arguments.length>1?_8ee:null; +if(_8ee||_8ed!="createlink"){ +_8ef=this.document.execCommand(_8ed,false,_8ee); +} +} +} +} +} +} +this.onDisplayChanged(); +return _8ef; +},queryCommandEnabled:function(_8fa){ +_8fa=this._normalizeCommand(_8fa); +if(this.object){ +switch(_8fa){ +case "hilitecolor": +_8fa="setbackcolor"; +break; +case "forecolor": +case "backcolor": +case "fontsize": +case "fontname": +_8fa="set"+_8fa; +break; +case "formatblock": +_8fa="setblockformat"; +break; +case "strikethrough": +_8fa="bold"; +break; +case "inserthorizontalrule": +return true; +} +if(typeof this._activeX.command[_8fa]=="undefined"){ +return false; +} +var _8fb=this.object.QueryStatus(this._activeX.command[_8fa]); +return ((_8fb!=this._activeX.status.notsupported)&&(_8fb!=this._activeX.status.disabled)); +}else{ +if(dojo.render.html.mozilla){ +if(_8fa=="unlink"){ +return dojo.withGlobal(this.window,"hasAncestorElement",dojo.html.selection,["a"]); +}else{ +if(_8fa=="inserttable"){ +return true; +} +} +} +var elem=(dojo.render.html.ie)?this.document.selection.createRange():this.document; +return elem.queryCommandEnabled(_8fa); +} +},queryCommandState:function(_8fd){ +_8fd=this._normalizeCommand(_8fd); +if(this.object){ +if(_8fd=="forecolor"){ +_8fd="setforecolor"; +}else{ +if(_8fd=="backcolor"){ +_8fd="setbackcolor"; +}else{ +if(_8fd=="strikethrough"){ +return dojo.withGlobal(this.window,"hasAncestorElement",dojo.html.selection,["strike"]); +}else{ +if(_8fd=="inserthorizontalrule"){ +return false; +} +} +} +} +if(typeof this._activeX.command[_8fd]=="undefined"){ +return null; +} +var _8fe=this.object.QueryStatus(this._activeX.command[_8fd]); +return ((_8fe==this._activeX.status.latched)||(_8fe==this._activeX.status.ninched)); +}else{ +return this.document.queryCommandState(_8fd); +} +},queryCommandValue:function(_8ff){ +_8ff=this._normalizeCommand(_8ff); +if(this.object){ +switch(_8ff){ +case "forecolor": +case "backcolor": +case "fontsize": +case "fontname": +_8ff="get"+_8ff; +return this.object.execCommand(this._activeX.command[_8ff],this._activeX.ui.noprompt); +case "formatblock": +var _900=this.object.execCommand(this._activeX.command["getblockformat"],this._activeX.ui.noprompt); +if(_900){ +return this._local2NativeFormatNames[_900]; +} +} +}else{ +if(dojo.render.html.ie&&_8ff=="formatblock"){ +return this._local2NativeFormatNames[this.document.queryCommandValue(_8ff)]||this.document.queryCommandValue(_8ff); +} +return this.document.queryCommandValue(_8ff); +} +},placeCursorAtStart:function(){ +this.focus(); +if(dojo.render.html.moz&&this.editNode.firstChild&&this.editNode.firstChild.nodeType!=dojo.dom.TEXT_NODE){ +dojo.withGlobal(this.window,"selectElementChildren",dojo.html.selection,[this.editNode.firstChild]); +}else{ +dojo.withGlobal(this.window,"selectElementChildren",dojo.html.selection,[this.editNode]); +} +dojo.withGlobal(this.window,"collapse",dojo.html.selection,[true]); +},placeCursorAtEnd:function(){ +this.focus(); +if(dojo.render.html.moz&&this.editNode.lastChild&&this.editNode.lastChild.nodeType!=dojo.dom.TEXT_NODE){ +dojo.withGlobal(this.window,"selectElementChildren",dojo.html.selection,[this.editNode.lastChild]); +}else{ +dojo.withGlobal(this.window,"selectElementChildren",dojo.html.selection,[this.editNode]); +} +dojo.withGlobal(this.window,"collapse",dojo.html.selection,[false]); +},replaceEditorContent:function(html){ +html=this._preFilterContent(html); +if(this.isClosed){ +this.domNode.innerHTML=html; +}else{ +if(this.window&&this.window.getSelection&&!dojo.render.html.moz){ +this.editNode.innerHTML=html; +}else{ +if((this.window&&this.window.getSelection)||(this.document&&this.document.selection)){ +this.execCommand("selectall"); +if(dojo.render.html.moz&&!html){ +html=" "; +} +this.execCommand("inserthtml",html); +} +} +} +},_preFilterContent:function(html){ +var ec=html; +dojo.lang.forEach(this.contentPreFilters,function(ef){ +ec=ef(ec); +}); +if(this.contentDomPreFilters.length>0){ +var dom=dojo.doc().createElement("div"); +dom.style.display="none"; +dojo.body().appendChild(dom); +dom.innerHTML=ec; +dojo.lang.forEach(this.contentDomPreFilters,function(ef){ +dom=ef(dom); +}); +ec=dom.innerHTML; +dojo.body().removeChild(dom); +} +return ec; +},_postFilterContent:function(html){ +var ec=html; +if(this.contentDomPostFilters.length>0){ +var dom=this.document.createElement("div"); +dom.innerHTML=ec; +dojo.lang.forEach(this.contentDomPostFilters,function(ef){ +dom=ef(dom); +}); +ec=dom.innerHTML; +} +dojo.lang.forEach(this.contentPostFilters,function(ef){ +ec=ef(ec); +}); +return ec; +},_lastHeight:0,_updateHeight:function(){ +if(!this.isLoaded){ +return; +} +if(this.height){ +return; +} +var _90c=dojo.html.getBorderBox(this.editNode).height; +if(!_90c){ +_90c=dojo.html.getBorderBox(this.document.body).height; +} +if(_90c==0){ +dojo.debug("Can not figure out the height of the editing area!"); +return; +} +this._lastHeight=_90c; +this.editorObject.style.height=this._lastHeight+"px"; +this.window.scrollTo(0,0); +},_saveContent:function(e){ +var _90e=dojo.doc().getElementById("dojo.widget.RichText.savedContent"); +_90e.value+=this._SEPARATOR+this.saveName+":"+this.getEditorContent(); +},getEditorContent:function(){ +var ec=""; +try{ +ec=(this._content.length>0)?this._content:this.editNode.innerHTML; +if(dojo.string.trim(ec)==" "){ +ec=""; +} +} +catch(e){ +} +if(dojo.render.html.ie&&!this.object){ +var re=new RegExp("(?:

     

    [\n\r]*)+$","i"); +ec=ec.replace(re,""); +} +ec=this._postFilterContent(ec); +if(this.relativeImageUrls){ +var _911=dojo.global().location.protocol+"//"+dojo.global().location.host; +var _912=dojo.global().location.pathname; +if(_912.match(/\/$/)){ +}else{ +var _913=_912.split("/"); +if(_913.length){ +_913.pop(); +} +_912=_913.join("/")+"/"; +} +var _914=new RegExp("(]* src=[\"'])("+_911+"("+_912+")?)","ig"); +ec=ec.replace(_914,"$1"); +} +return ec; +},close:function(save,_916){ +if(this.isClosed){ +return false; +} +if(arguments.length==0){ +save=true; +} +this._content=this._postFilterContent(this.editNode.innerHTML); +var _917=(this.savedContent!=this._content); +if(this.interval){ +clearInterval(this.interval); +} +if(dojo.render.html.ie&&!this.object){ +dojo.event.browser.clean(this.editNode); +} +if(this.iframe){ +delete this.iframe; +} +if(this.textarea){ +with(this.textarea.style){ +position=""; +left=top=""; +if(dojo.render.html.ie){ +overflow=this.__overflow; +this.__overflow=null; +} +} +if(save){ +this.textarea.value=this._content; +}else{ +this.textarea.value=this.savedContent; +} +dojo.html.removeNode(this.domNode); +this.domNode=this.textarea; +}else{ +if(save){ +if(dojo.render.html.moz){ +var nc=dojo.doc().createElement("span"); +this.domNode.appendChild(nc); +nc.innerHTML=this.editNode.innerHTML; +}else{ +this.domNode.innerHTML=this._content; +} +}else{ +this.domNode.innerHTML=this.savedContent; +} +} +dojo.html.removeClass(this.domNode,"RichTextEditable"); +this.isClosed=true; +this.isLoaded=false; +delete this.editNode; +if(this.window._frameElement){ +this.window._frameElement=null; +} +this.window=null; +this.document=null; +this.object=null; +this.editingArea=null; +this.editorObject=null; +return _917; +},destroyRendering:function(){ +},destroy:function(){ +this.destroyRendering(); +if(!this.isClosed){ +this.close(false); +} +dojo.widget.RichText.superclass.destroy.call(this); +},connect:function(_919,_91a,_91b){ +dojo.event.connect(_919,_91a,this,_91b); +},disconnect:function(_91c,_91d,_91e){ +dojo.event.disconnect(_91c,_91d,this,_91e); +},disconnectAllWithRoot:function(_91f){ +dojo.deprecated("disconnectAllWithRoot","is deprecated. No need to disconnect manually","0.5"); +},_fixContentForMoz:function(html){ +html=html.replace(/])/gi,"/gi,""); +html=html.replace(/])/gi,"/gi,""); +return html; +}}); +dojo.provide("dojo.lang.type"); +dojo.lang.whatAmI=function(_921){ +dojo.deprecated("dojo.lang.whatAmI","use dojo.lang.getType instead","0.5"); +return dojo.lang.getType(_921); +}; +dojo.lang.whatAmI.custom={}; +dojo.lang.getType=function(_922){ +try{ +if(dojo.lang.isArray(_922)){ +return "array"; +} +if(dojo.lang.isFunction(_922)){ +return "function"; +} +if(dojo.lang.isString(_922)){ +return "string"; +} +if(dojo.lang.isNumber(_922)){ +return "number"; +} +if(dojo.lang.isBoolean(_922)){ +return "boolean"; +} +if(dojo.lang.isAlien(_922)){ +return "alien"; +} +if(dojo.lang.isUndefined(_922)){ +return "undefined"; +} +for(var name in dojo.lang.whatAmI.custom){ +if(dojo.lang.whatAmI.custom[name](_922)){ +return name; +} +} +if(dojo.lang.isObject(_922)){ +return "object"; +} +} +catch(e){ +} +return "unknown"; +}; +dojo.lang.isNumeric=function(_924){ +return (!isNaN(_924)&&isFinite(_924)&&(_924!=null)&&!dojo.lang.isBoolean(_924)&&!dojo.lang.isArray(_924)&&!/^\s*$/.test(_924)); +}; +dojo.lang.isBuiltIn=function(_925){ +return (dojo.lang.isArray(_925)||dojo.lang.isFunction(_925)||dojo.lang.isString(_925)||dojo.lang.isNumber(_925)||dojo.lang.isBoolean(_925)||(_925==null)||(_925 instanceof Error)||(typeof _925=="error")); +}; +dojo.lang.isPureObject=function(_926){ +return ((_926!=null)&&dojo.lang.isObject(_926)&&_926.constructor==Object); +}; +dojo.lang.isOfType=function(_927,type,_929){ +var _92a=false; +if(_929){ +_92a=_929["optional"]; +} +if(_92a&&((_927===null)||dojo.lang.isUndefined(_927))){ +return true; +} +if(dojo.lang.isArray(type)){ +var _92b=type; +for(var i in _92b){ +var _92d=_92b[i]; +if(dojo.lang.isOfType(_927,_92d)){ +return true; +} +} +return false; +}else{ +if(dojo.lang.isString(type)){ +type=type.toLowerCase(); +} +switch(type){ +case Array: +case "array": +return dojo.lang.isArray(_927); +case Function: +case "function": +return dojo.lang.isFunction(_927); +case String: +case "string": +return dojo.lang.isString(_927); +case Number: +case "number": +return dojo.lang.isNumber(_927); +case "numeric": +return dojo.lang.isNumeric(_927); +case Boolean: +case "boolean": +return dojo.lang.isBoolean(_927); +case Object: +case "object": +return dojo.lang.isObject(_927); +case "pureobject": +return dojo.lang.isPureObject(_927); +case "builtin": +return dojo.lang.isBuiltIn(_927); +case "alien": +return dojo.lang.isAlien(_927); +case "undefined": +return dojo.lang.isUndefined(_927); +case null: +case "null": +return (_927===null); +case "optional": +dojo.deprecated("dojo.lang.isOfType(value, [type, \"optional\"])","use dojo.lang.isOfType(value, type, {optional: true} ) instead","0.5"); +return ((_927===null)||dojo.lang.isUndefined(_927)); +default: +if(dojo.lang.isFunction(type)){ +return (_927 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 _92f=str.split("."),i=0,obj=dj_global; +do{ +obj=obj[_92f[i++]]; +}while(i<_92f.length&&obj); +return (obj!=dj_global)?obj:null; +}; +dojo.lang.doesObjectExist=function(str){ +var _933=str.split("."),i=0,obj=dj_global; +do{ +obj=obj[_933[i++]]; +}while(i<_933.length&&obj); +return (obj&&obj!=dj_global); +}; +dojo.provide("dojo.lang.assert"); +dojo.lang.assert=function(_936,_937){ +if(!_936){ +var _938="An assert statement failed.\n"+"The method dojo.lang.assert() was called with a 'false' value.\n"; +if(_937){ +_938+="Here's the assert message:\n"+_937+"\n"; +} +throw new Error(_938); +} +}; +dojo.lang.assertType=function(_939,type,_93b){ +if(dojo.lang.isString(_93b)){ +dojo.deprecated("dojo.lang.assertType(value, type, \"message\")","use dojo.lang.assertType(value, type) instead","0.5"); +} +if(!dojo.lang.isOfType(_939,type,_93b)){ +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(_93c,_93d,_93e){ +var key; +if(!_93e){ +if(!dojo.lang.assertValidKeywords._errorMessage){ +dojo.lang.assertValidKeywords._errorMessage="In dojo.lang.assertValidKeywords(), found invalid keyword:"; +} +_93e=dojo.lang.assertValidKeywords._errorMessage; +} +if(dojo.lang.isArray(_93d)){ +for(key in _93c){ +if(!dojo.lang.inArray(_93d,key)){ +dojo.lang.assert(false,_93e+" "+key); +} +} +}else{ +for(key in _93c){ +if(!(key in _93d)){ +dojo.lang.assert(false,_93e+" "+key); +} +} +} +}; +dojo.provide("dojo.AdapterRegistry"); +dojo.AdapterRegistry=function(_940){ +this.pairs=[]; +this.returnWrappers=_940||false; +}; +dojo.lang.extend(dojo.AdapterRegistry,{register:function(name,_942,wrap,_944,_945){ +var type=(_945)?"unshift":"push"; +this.pairs[type]([name,_942,wrap,_944]); +},match:function(){ +for(var i=0;i"; +this.iframe=dojo.doc().createElement(html); +this.iframe.tabIndex=-1; +if(node){ +node.appendChild(this.iframe); +this.domNode=node; +}else{ +dojo.body().appendChild(this.iframe); +this.iframe.style.display="none"; +} +} +}; +dojo.lang.extend(dojo.html.BackgroundIframe,{iframe:null,onResized:function(){ +if(this.iframe&&this.domNode&&this.domNode.parentNode){ +var _95b=dojo.html.getMarginBox(this.domNode); +if(_95b.width==0||_95b.height==0){ +dojo.lang.setTimeout(this,this.onResized,100); +return; +} +this.iframe.style.width=_95b.width+"px"; +this.iframe.style.height=_95b.height+"px"; +} +},size:function(node){ +if(!this.iframe){ +return; +} +var _95d=dojo.html.toCoordinateObject(node,true,dojo.html.boxSizing.BORDER_BOX); +with(this.iframe.style){ +width=_95d.width+"px"; +height=_95d.height+"px"; +left=_95d.left+"px"; +top=_95d.top+"px"; +} +},setZIndex:function(node){ +if(!this.iframe){ +return; +} +if(dojo.dom.isNode(node)){ +this.iframe.style.zIndex=dojo.html.getStyle(node,"z-index")-1; +}else{ +if(!isNaN(node)){ +this.iframe.style.zIndex=node; +} +} +},show:function(){ +if(this.iframe){ +this.iframe.style.display="block"; +} +},hide:function(){ +if(this.iframe){ +this.iframe.style.display="none"; +} +},remove:function(){ +if(this.iframe){ +dojo.html.removeNode(this.iframe,true); +delete this.iframe; +this.iframe=null; +} +}}); +dojo.provide("dojo.widget.PopupContainer"); +dojo.declare("dojo.widget.PopupContainerBase",null,function(){ +this.queueOnAnimationFinish=[]; +},{isShowingNow:false,currentSubpopup:null,beginZIndex:1000,parentPopup:null,parent:null,popupIndex:0,aroundBox:dojo.html.boxSizing.BORDER_BOX,openedForWindow:null,processKey:function(evt){ +return false; +},applyPopupBasicStyle:function(){ +with(this.domNode.style){ +display="none"; +position="absolute"; +} +},aboutToShow:function(){ +},open:function(x,y,_962,_963,_964,_965){ +if(this.isShowingNow){ +return; +} +if(this.animationInProgress){ +this.queueOnAnimationFinish.push(this.open,arguments); +return; +} +this.aboutToShow(); +var _966=false,node,_968; +if(typeof x=="object"){ +node=x; +_968=_963; +_963=_962; +_962=y; +_966=true; +} +this.parent=_962; +dojo.body().appendChild(this.domNode); +_963=_963||_962["domNode"]||[]; +var _969=null; +this.isTopLevel=true; +while(_962){ +if(_962!==this&&(_962.setOpenedSubpopup!=undefined&&_962.applyPopupBasicStyle!=undefined)){ +_969=_962; +this.isTopLevel=false; +_969.setOpenedSubpopup(this); +break; +} +_962=_962.parent; +} +this.parentPopup=_969; +this.popupIndex=_969?_969.popupIndex+1:1; +if(this.isTopLevel){ +var _96a=dojo.html.isNode(_963)?_963:null; +dojo.widget.PopupManager.opened(this,_96a); +} +if(this.isTopLevel&&!dojo.withGlobal(this.openedForWindow||dojo.global(),dojo.html.selection.isCollapsed)){ +this._bookmark=dojo.withGlobal(this.openedForWindow||dojo.global(),dojo.html.selection.getBookmark); +}else{ +this._bookmark=null; +} +if(_963 instanceof Array){ +_963={left:_963[0],top:_963[1],width:0,height:0}; +} +with(this.domNode.style){ +display=""; +zIndex=this.beginZIndex+this.popupIndex; +} +if(_966){ +this.move(node,_965,_968); +}else{ +this.move(x,y,_965,_964); +} +this.domNode.style.display="none"; +this.explodeSrc=_963; +this.show(); +this.isShowingNow=true; +},move:function(x,y,_96d,_96e){ +var _96f=(typeof x=="object"); +if(_96f){ +var _970=_96d; +var node=x; +_96d=y; +if(!_970){ +_970={"BL":"TL","TL":"BL"}; +} +dojo.html.placeOnScreenAroundElement(this.domNode,node,_96d,this.aroundBox,_970); +}else{ +if(!_96e){ +_96e="TL,TR,BL,BR"; +} +dojo.html.placeOnScreen(this.domNode,x,y,_96d,true,_96e); +} +},close:function(_972){ +if(_972){ +this.domNode.style.display="none"; +} +if(this.animationInProgress){ +this.queueOnAnimationFinish.push(this.close,[]); +return; +} +this.closeSubpopup(_972); +this.hide(); +if(this.bgIframe){ +this.bgIframe.hide(); +this.bgIframe.size({left:0,top:0,width:0,height:0}); +} +if(this.isTopLevel){ +dojo.widget.PopupManager.closed(this); +} +this.isShowingNow=false; +if(this.parent){ +setTimeout(dojo.lang.hitch(this,function(){ +try{ +if(this.parent["focus"]){ +this.parent.focus(); +}else{ +this.parent.domNode.focus(); +} +} +catch(e){ +dojo.debug("No idea how to focus to parent",e); +} +}),10); +} +if(this._bookmark&&dojo.withGlobal(this.openedForWindow||dojo.global(),dojo.html.selection.isCollapsed)){ +if(this.openedForWindow){ +this.openedForWindow.focus(); +} +try{ +dojo.withGlobal(this.openedForWindow||dojo.global(),"moveToBookmark",dojo.html.selection,[this._bookmark]); +} +catch(e){ +} +} +this._bookmark=null; +},closeAll:function(_973){ +if(this.parentPopup){ +this.parentPopup.closeAll(_973); +}else{ +this.close(_973); +} +},setOpenedSubpopup:function(_974){ +this.currentSubpopup=_974; +},closeSubpopup:function(_975){ +if(this.currentSubpopup==null){ +return; +} +this.currentSubpopup.close(_975); +this.currentSubpopup=null; +},onShow:function(){ +dojo.widget.PopupContainer.superclass.onShow.apply(this,arguments); +this.openedSize={w:this.domNode.style.width,h:this.domNode.style.height}; +if(dojo.render.html.ie){ +if(!this.bgIframe){ +this.bgIframe=new dojo.html.BackgroundIframe(); +this.bgIframe.setZIndex(this.domNode); +} +this.bgIframe.size(this.domNode); +this.bgIframe.show(); +} +this.processQueue(); +},processQueue:function(){ +if(!this.queueOnAnimationFinish.length){ +return; +} +var func=this.queueOnAnimationFinish.shift(); +var args=this.queueOnAnimationFinish.shift(); +func.apply(this,args); +},onHide:function(){ +dojo.widget.HtmlWidget.prototype.onHide.call(this); +if(this.openedSize){ +with(this.domNode.style){ +width=this.openedSize.w; +height=this.openedSize.h; +} +} +this.processQueue(); +}}); +dojo.widget.defineWidget("dojo.widget.PopupContainer",[dojo.widget.HtmlWidget,dojo.widget.PopupContainerBase],{isContainer:true,fillInTemplate:function(){ +this.applyPopupBasicStyle(); +dojo.widget.PopupContainer.superclass.fillInTemplate.apply(this,arguments); +}}); +dojo.widget.PopupManager=new function(){ +this.currentMenu=null; +this.currentButton=null; +this.currentFocusMenu=null; +this.focusNode=null; +this.registeredWindows=[]; +this.registerWin=function(win){ +if(!win.__PopupManagerRegistered){ +dojo.event.connect(win.document,"onmousedown",this,"onClick"); +dojo.event.connect(win,"onscroll",this,"onClick"); +dojo.event.connect(win.document,"onkey",this,"onKey"); +win.__PopupManagerRegistered=true; +this.registeredWindows.push(win); +} +}; +this.registerAllWindows=function(_979){ +if(!_979){ +_979=dojo.html.getDocumentWindow(window.top&&window.top.document||window.document); +} +this.registerWin(_979); +for(var i=0;i<_979.frames.length;i++){ +try{ +var win=dojo.html.getDocumentWindow(_979.frames[i].document); +if(win){ +this.registerAllWindows(win); +} +} +catch(e){ +} +} +}; +this.unRegisterWin=function(win){ +if(win.__PopupManagerRegistered){ +dojo.event.disconnect(win.document,"onmousedown",this,"onClick"); +dojo.event.disconnect(win,"onscroll",this,"onClick"); +dojo.event.disconnect(win.document,"onkey",this,"onKey"); +win.__PopupManagerRegistered=false; +} +}; +this.unRegisterAllWindows=function(){ +for(var i=0;i]*>([\s\S]*?)<\/title>/i; +while(_9be=_9c8.exec(s)){ +_9bb.push(_9be[1]); +s=s.substring(0,_9be.index)+s.substr(_9be.index+_9be[0].length); +} +if(this.adjustPaths){ +var _9c9=/<[a-z][a-z0-9]*[^>]*\s(?:(?:src|href|style)=[^>])+[^>]*>/i; +var _9ca=/\s(src|href|style)=(['"]?)([\w()\[\]\/.,\\'"-:;#=&?\s@]+?)\2/i; +var _9cb=/^(?:[#]|(?:(?:https?|ftps?|file|javascript|mailto|news):))/; +while(tag=_9c9.exec(s)){ +str+=s.substring(0,tag.index); +s=s.substring((tag.index+tag[0].length),s.length); +tag=tag[0]; +_9c5=""; +while(attr=_9ca.exec(tag)){ +path=""; +_9c7=attr[3]; +switch(attr[1].toLowerCase()){ +case "src": +case "href": +if(_9cb.exec(_9c7)){ +path=_9c7; +}else{ +path=(new dojo.uri.Uri(url,_9c7).toString()); +} +break; +case "style": +path=dojo.html.fixPathsInCssText(_9c7,url); +break; +default: +path=_9c7; +} +fix=" "+attr[1]+"="+attr[2]+path+attr[2]; +_9c5+=tag.substring(0,attr.index)+fix; +tag=tag.substring((attr.index+attr[0].length),tag.length); +} +str+=_9c5+tag; +} +s=str+s; +} +_9c8=/(?:<(style)[^>]*>([\s\S]*?)<\/style>|]*rel=['"]?stylesheet['"]?[^>]*)>)/i; +while(_9be=_9c8.exec(s)){ +if(_9be[1]&&_9be[1].toLowerCase()=="style"){ +_9c1.push(dojo.html.fixPathsInCssText(_9be[2],url)); +}else{ +if(attr=_9be[3].match(/href=(['"]?)([^'">]*)\1/i)){ +_9c1.push({path:attr[2]}); +} +} +s=s.substring(0,_9be.index)+s.substr(_9be.index+_9be[0].length); +} +var _9c8=/]*)>([\s\S]*?)<\/script>/i; +var _9cc=/src=(['"]?)([^"']*)\1/i; +var _9cd=/.*(\bdojo\b\.js(?:\.uncompressed\.js)?)$/; +var _9ce=/(?:var )?\bdjConfig\b(?:[\s]*=[\s]*\{[^}]+\}|\.[\w]*[\s]*=[\s]*[^;\n]*)?;?|dojo\.hostenv\.writeIncludes\(\s*\);?/g; +var _9cf=/dojo\.(?:(?:require(?:After)?(?:If)?)|(?:widget\.(?:manager\.)?registerWidgetPackage)|(?:(?:hostenv\.)?setModulePrefix|registerModulePath)|defineNamespace)\((['"]).*?\1\)\s*;?/; +while(_9be=_9c8.exec(s)){ +if(this.executeScripts&&_9be[1]){ +if(attr=_9cc.exec(_9be[1])){ +if(_9cd.exec(attr[2])){ +dojo.debug("Security note! inhibit:"+attr[2]+" from being loaded again."); +}else{ +_9bc.push({path:attr[2]}); +} +} +} +if(_9be[2]){ +var sc=_9be[2].replace(_9ce,""); +if(!sc){ +continue; +} +while(tmp=_9cf.exec(sc)){ +_9bf.push(tmp[0]); +sc=sc.substring(0,tmp.index)+sc.substr(tmp.index+tmp[0].length); +} +if(this.executeScripts){ +_9bc.push(sc); +} +} +s=s.substr(0,_9be.index)+s.substr(_9be.index+_9be[0].length); +} +if(this.extractContent){ +_9be=s.match(/]*>\s*([\s\S]+)\s*<\/body>/im); +if(_9be){ +s=_9be[1]; +} +} +if(this.executeScripts&&this.scriptSeparation){ +var _9c8=/(<[a-zA-Z][a-zA-Z0-9]*\s[^>]*?\S=)((['"])[^>]*scriptScope[^>]*>)/; +var _9d1=/([\s'";:\(])scriptScope(.*)/; +str=""; +while(tag=_9c8.exec(s)){ +tmp=((tag[3]=="'")?"\"":"'"); +fix=""; +str+=s.substring(0,tag.index)+tag[1]; +while(attr=_9d1.exec(tag[2])){ +tag[2]=tag[2].substring(0,attr.index)+attr[1]+"dojo.widget.byId("+tmp+this.widgetId+tmp+").scriptScope"+attr[2]; +} +str+=tag[2]; +s=s.substr(tag.index+tag[0].length); +} +s=str+s; +} +} +return {"xml":s,"styles":_9c1,"titles":_9bb,"requires":_9bf,"scripts":_9bc,"url":url}; +},_setContent:function(cont){ +this.destroyChildren(); +for(var i=0;i=0){ +this.dropTargets.splice(_a7a,1); +} +},getDragSource:function(e){ +var tn=e.target; +if(tn===dojo.body()){ +return; +} +var ta=dojo.html.getAttribute(tn,this.dsPrefix); +while((!ta)&&(tn)){ +tn=tn.parentNode; +if((!tn)||(tn===dojo.body())){ +return; +} +ta=dojo.html.getAttribute(tn,this.dsPrefix); +} +return this.dragSources[ta]; +},onKeyDown:function(e){ +},onMouseDown:function(e){ +if(this.disabled){ +return; +} +if(dojo.render.html.ie){ +if(e.button!=1){ +return; +} +}else{ +if(e.which!=1){ +return; +} +} +var _a80=e.target.nodeType==dojo.html.TEXT_NODE?e.target.parentNode:e.target; +if(dojo.html.isTag(_a80,"button","textarea","input","select","option")){ +return; +} +var ds=this.getDragSource(e); +if(!ds){ +return; +} +if(!dojo.lang.inArray(this.selectedSources,ds)){ +this.selectedSources.push(ds); +ds.onSelected(); +} +this.mouseDownX=e.pageX; +this.mouseDownY=e.pageY; +e.preventDefault(); +dojo.event.connect(document,"onmousemove",this,"onMouseMove"); +},onMouseUp:function(e,_a83){ +if(this.selectedSources.length==0){ +return; +} +this.mouseDownX=null; +this.mouseDownY=null; +this._dragTriggered=false; +e.dragSource=this.dragSource; +if((!e.shiftKey)&&(!e.ctrlKey)){ +if(this.currentDropTarget){ +this.currentDropTarget.onDropStart(); +} +dojo.lang.forEach(this.dragObjects,function(_a84){ +var ret=null; +if(!_a84){ +return; +} +if(this.currentDropTarget){ +e.dragObject=_a84; +var ce=this.currentDropTarget.domNode.childNodes; +if(ce.length>0){ +e.dropTarget=ce[0]; +while(e.dropTarget==_a84.domNode){ +e.dropTarget=e.dropTarget.nextSibling; +} +}else{ +e.dropTarget=this.currentDropTarget.domNode; +} +if(this.dropAcceptable){ +ret=this.currentDropTarget.onDrop(e); +}else{ +this.currentDropTarget.onDragOut(e); +} +} +e.dragStatus=this.dropAcceptable&&ret?"dropSuccess":"dropFailure"; +dojo.lang.delayThese([function(){ +try{ +_a84.dragSource.onDragEnd(e); +} +catch(err){ +var _a87={}; +for(var i in e){ +if(i=="type"){ +_a87.type="mouseup"; +continue; +} +_a87[i]=e[i]; +} +_a84.dragSource.onDragEnd(_a87); +} +},function(){ +_a84.onDragEnd(e); +}]); +},this); +this.selectedSources=[]; +this.dragObjects=[]; +this.dragSource=null; +if(this.currentDropTarget){ +this.currentDropTarget.onDropEnd(); +} +}else{ +} +dojo.event.disconnect(document,"onmousemove",this,"onMouseMove"); +this.currentDropTarget=null; +},onScroll:function(){ +for(var i=0;ithis.threshold); +if(!this._dragTriggered){ +return; +} +dx=e.pageX-this.mouseDownX; +dy=e.pageY-this.mouseDownY; +} +this.dragSource=this.selectedSources[0]; +dojo.lang.forEach(this.selectedSources,function(_a97){ +if(!_a97){ +return; +} +var tdo=_a97.onDragStart(e); +if(tdo){ +tdo.onDragStart(e); +tdo.dragOffset.y+=dy; +tdo.dragOffset.x+=dx; +tdo.dragSource=_a97; +this.dragObjects.push(tdo); +} +},this); +this.previousDropTarget=null; +this.cacheTargetLocations(); +} +dojo.lang.forEach(this.dragObjects,function(_a99){ +if(_a99){ +_a99.onDragMove(e); +} +}); +if(this.currentDropTarget){ +var c=dojo.html.toCoordinateObject(this.currentDropTarget.domNode,true); +var dtp=[[c.x,c.y],[c.x+c.width,c.y+c.height]]; +} +if((!this.nestedTargets)&&(dtp)&&(this.isInsideBox(e,dtp))){ +if(this.dropAcceptable){ +this.currentDropTarget.onDragMove(e,this.dragObjects); +} +}else{ +var _a9c=this.findBestTarget(e); +if(_a9c.target===null){ +if(this.currentDropTarget){ +this.currentDropTarget.onDragOut(e); +this.previousDropTarget=this.currentDropTarget; +this.currentDropTarget=null; +} +this.dropAcceptable=false; +return; +} +if(this.currentDropTarget!==_a9c.target){ +if(this.currentDropTarget){ +this.previousDropTarget=this.currentDropTarget; +this.currentDropTarget.onDragOut(e); +} +this.currentDropTarget=_a9c.target; +e.dragObjects=this.dragObjects; +this.dropAcceptable=this.currentDropTarget.onDragOver(e); +}else{ +if(this.dropAcceptable){ +this.currentDropTarget.onDragMove(e,this.dragObjects); +} +} +} +},findBestTarget:function(e){ +var _a9e=this; +var _a9f=new Object(); +_a9f.target=null; +_a9f.points=null; +dojo.lang.every(this.dropTargetDimensions,function(_aa0){ +if(!_a9e.isInsideBox(e,_aa0)){ +return true; +} +_a9f.target=_aa0[2]; +_a9f.points=_aa0; +return Boolean(_a9e.nestedTargets); +}); +return _a9f; +},isInsideBox:function(e,_aa2){ +if((e.pageX>_aa2[0][0])&&(e.pageX<_aa2[1][0])&&(e.pageY>_aa2[0][1])&&(e.pageY<_aa2[1][1])){ +return true; +} +return false; +},onMouseOver:function(e){ +},onMouseOut:function(e){ +}}); +dojo.dnd.dragManager=new dojo.dnd.HtmlDragManager(); +(function(){ +var d=document; +var dm=dojo.dnd.dragManager; +dojo.event.connect(d,"onkeydown",dm,"onKeyDown"); +dojo.event.connect(d,"onmouseover",dm,"onMouseOver"); +dojo.event.connect(d,"onmouseout",dm,"onMouseOut"); +dojo.event.connect(d,"onmousedown",dm,"onMouseDown"); +dojo.event.connect(d,"onmouseup",dm,"onMouseUp"); +dojo.event.connect(window,"onscroll",dm,"onScroll"); +})(); +dojo.provide("dojo.dnd.HtmlDragAndDrop"); +dojo.declare("dojo.dnd.HtmlDragSource",dojo.dnd.DragSource,{dragClass:"",onDragStart:function(){ +var _aa7=new dojo.dnd.HtmlDragObject(this.dragObject,this.type); +if(this.dragClass){ +_aa7.dragClass=this.dragClass; +} +if(this.constrainToContainer){ +_aa7.constrainTo(this.constrainingContainer||this.domNode.parentNode); +} +return _aa7; +},setDragHandle:function(node){ +node=dojo.byId(node); +dojo.dnd.dragManager.unregisterDragSource(this); +this.domNode=node; +dojo.dnd.dragManager.registerDragSource(this); +},setDragTarget:function(node){ +this.dragObject=node; +},constrainTo:function(_aaa){ +this.constrainToContainer=true; +if(_aaa){ +this.constrainingContainer=_aaa; +} +},onSelected:function(){ +for(var i=0;ithis.constraints.maxX){ +x=this.constraints.maxX; +} +if(y>this.constraints.maxY){ +y=this.constraints.maxY; +} +} +this.setAbsolutePosition(x,y); +dojo.event.topic.publish("dragMove",{source:this}); +},setAbsolutePosition:function(x,y){ +if(!this.disableY){ +this.dragClone.style.top=y+"px"; +} +if(!this.disableX){ +this.dragClone.style.left=x+"px"; +} +},onDragEnd:function(e){ +switch(e.dragStatus){ +case "dropSuccess": +dojo.html.removeNode(this.dragClone); +this.dragClone=null; +break; +case "dropFailure": +var _acd=dojo.html.getAbsolutePosition(this.dragClone,true); +var _ace={left:this.dragStartPosition.x+1,top:this.dragStartPosition.y+1}; +var anim=dojo.lfx.slideTo(this.dragClone,_ace,300); +var _ad0=this; +dojo.event.connect(anim,"onEnd",function(e){ +dojo.html.removeNode(_ad0.dragClone); +_ad0.dragClone=null; +}); +anim.play(); +break; +} +dojo.event.topic.publish("dragEnd",{source:this}); +},constrainTo:function(_ad2){ +this.constrainToContainer=true; +if(_ad2){ +this.constrainingContainer=_ad2; +}else{ +this.constrainingContainer=this.domNode.parentNode; +} +}},function(node,type){ +this.domNode=dojo.byId(node); +this.type=type; +this.constrainToContainer=false; +this.dragSource=null; +dojo.dnd.DragObject.prototype.register.call(this); +}); +dojo.declare("dojo.dnd.HtmlDropTarget",dojo.dnd.DropTarget,{vertical:false,onDragOver:function(e){ +if(!this.accepts(e.dragObjects)){ +return false; +} +this.childBoxes=[]; +for(var i=0,_ad7;i=left&&e.pageX<=right&&e.pageY>=top&&e.pageY<=bottom){ +return i; +} +} +} +return -1; +},createDropIndicator:function(){ +this.dropIndicator=document.createElement("div"); +with(this.dropIndicator.style){ +position="absolute"; +zIndex=999; +if(this.vertical){ +borderLeftWidth="1px"; +borderLeftColor="black"; +borderLeftStyle="solid"; +height=dojo.html.getBorderBox(this.domNode).height+"px"; +top=dojo.html.getAbsolutePosition(this.domNode,true).y+"px"; +}else{ +borderTopWidth="1px"; +borderTopColor="black"; +borderTopStyle="solid"; +width=dojo.html.getBorderBox(this.domNode).width+"px"; +left=dojo.html.getAbsolutePosition(this.domNode,true).x+"px"; +} +} +},onDragMove:function(e,_ade){ +var i=this._getNodeUnderMouse(e); +if(!this.dropIndicator){ +this.createDropIndicator(); +} +var _ae0=this.vertical?dojo.html.gravity.WEST:dojo.html.gravity.NORTH; +var hide=false; +if(i<0){ +if(this.childBoxes.length){ +var _ae2=(dojo.html.gravity(this.childBoxes[0].node,e)&_ae0); +if(_ae2){ +hide=true; +} +}else{ +var _ae2=true; +} +}else{ +var _ae3=this.childBoxes[i]; +var _ae2=(dojo.html.gravity(_ae3.node,e)&_ae0); +if(_ae3.node===_ade[0].dragSource.domNode){ +hide=true; +}else{ +var _ae4=_ae2?(i>0?this.childBoxes[i-1]:_ae3):(i=3){ +_b03=new dojo.gfx.color.Color(arguments[0],arguments[1],arguments[2]); +}else{ +_b03=new dojo.gfx.color.Color(_b03); +} +this.bg.style.backgroundColor=_b03.toString(); +return this.bgColor=_b03; +},setBackgroundOpacity:function(op){ +if(arguments.length==0){ +op=this.bgOpacity; +} +dojo.html.setOpacity(this.bg,op); +try{ +this.bgOpacity=dojo.html.getOpacity(this.bg); +} +catch(e){ +this.bgOpacity=op; +} +return this.bgOpacity; +},_sizeBackground:function(){ +if(this.bgOpacity>0){ +var _b05=dojo.html.getViewport(); +var h=_b05.height; +var w=_b05.width; +with(this.bg.style){ +width=w+"px"; +height=h+"px"; +} +var _b08=dojo.html.getScroll().offset; +this.bg.style.top=_b08.y+"px"; +this.bg.style.left=_b08.x+"px"; +var _b05=dojo.html.getViewport(); +if(_b05.width!=w){ +this.bg.style.width=_b05.width+"px"; +} +if(_b05.height!=h){ +this.bg.style.height=_b05.height+"px"; +} +} +this.bgIframe.size(this.bg); +},_showBackground:function(){ +if(this.bgOpacity>0){ +this.bg.style.display="block"; +} +if(this.bgIframe.iframe){ +this.bgIframe.iframe.style.display="block"; +} +},placeModalDialog:function(){ +var _b09=dojo.html.getScroll().offset; +var _b0a=dojo.html.getViewport(); +var mb; +if(this.isShowing()){ +mb=dojo.html.getMarginBox(this.domNode); +}else{ +dojo.html.setVisibility(this.domNode,false); +dojo.html.show(this.domNode); +mb=dojo.html.getMarginBox(this.domNode); +dojo.html.hide(this.domNode); +dojo.html.setVisibility(this.domNode,true); +} +var x=_b09.x+(_b0a.width-mb.width)/2; +var y=_b09.y+(_b0a.height-mb.height)/2; +with(this.domNode.style){ +left=x+"px"; +top=y+"px"; +} +},_onKey:function(evt){ +if(evt.key){ +var node=evt.target; +while(node!=null){ +if(node==this.domNode){ +return; +} +node=node.parentNode; +} +if(evt.key!=evt.KEY_TAB){ +dojo.event.browser.stopEvent(evt); +}else{ +if(!dojo.render.html.opera){ +try{ +this.tabStart.focus(); +} +catch(e){ +} +} +} +} +},showModalDialog:function(){ +if(this.followScroll&&!this._scrollConnected){ +this._scrollConnected=true; +dojo.event.connect(window,"onscroll",this,"_onScroll"); +} +dojo.event.connect(document.documentElement,"onkey",this,"_onKey"); +this.placeModalDialog(); +this.setBackgroundOpacity(); +this._sizeBackground(); +this._showBackground(); +this._fromTrap=true; +setTimeout(dojo.lang.hitch(this,function(){ +try{ +this.tabStart.focus(); +} +catch(e){ +} +}),50); +},hideModalDialog:function(){ +if(this.focusElement){ +dojo.byId(this.focusElement).focus(); +dojo.byId(this.focusElement).blur(); +} +this.bg.style.display="none"; +this.bg.style.width=this.bg.style.height="1px"; +if(this.bgIframe.iframe){ +this.bgIframe.iframe.style.display="none"; +} +dojo.event.disconnect(document.documentElement,"onkey",this,"_onKey"); +if(this._scrollConnected){ +this._scrollConnected=false; +dojo.event.disconnect(window,"onscroll",this,"_onScroll"); +} +},_onScroll:function(){ +var _b10=dojo.html.getScroll().offset; +this.bg.style.top=_b10.y+"px"; +this.bg.style.left=_b10.x+"px"; +this.placeModalDialog(); +},checkSize:function(){ +if(this.isShowing()){ +this._sizeBackground(); +this.placeModalDialog(); +this.onResized(); +} +},onBackgroundClick:function(){ +if(this.lifetime-this.timeRemaining>=this.blockDuration){ +return; +} +this.hide(); +}}); +dojo.widget.defineWidget("dojo.widget.Dialog",[dojo.widget.ContentPane,dojo.widget.ModalDialogBase],{templatePath:dojo.uri.moduleUri("dojo.widget","templates/Dialog.html"),blockDuration:0,lifetime:0,closeNode:"",postMixInProperties:function(){ +dojo.widget.Dialog.superclass.postMixInProperties.apply(this,arguments); +if(this.closeNode){ +this.setCloseControl(this.closeNode); +} +},postCreate:function(){ +dojo.widget.Dialog.superclass.postCreate.apply(this,arguments); +dojo.widget.ModalDialogBase.prototype.postCreate.apply(this,arguments); +},show:function(){ +if(this.lifetime){ +this.timeRemaining=this.lifetime; +if(this.timerNode){ +this.timerNode.innerHTML=Math.ceil(this.timeRemaining/1000); +} +if(this.blockDuration&&this.closeNode){ +if(this.lifetime>this.blockDuration){ +this.closeNode.style.visibility="hidden"; +}else{ +this.closeNode.style.display="none"; +} +} +if(this.timer){ +clearInterval(this.timer); +} +this.timer=setInterval(dojo.lang.hitch(this,"_onTick"),100); +} +this.showModalDialog(); +dojo.widget.Dialog.superclass.show.call(this); +},onLoad:function(){ +this.placeModalDialog(); +dojo.widget.Dialog.superclass.onLoad.call(this); +},fillInTemplate:function(){ +},hide:function(){ +this.hideModalDialog(); +dojo.widget.Dialog.superclass.hide.call(this); +if(this.timer){ +clearInterval(this.timer); +} +},setTimerNode:function(node){ +this.timerNode=node; +},setCloseControl:function(node){ +this.closeNode=dojo.byId(node); +dojo.event.connect(this.closeNode,"onclick",this,"hide"); +},setShowControl:function(node){ +node=dojo.byId(node); +dojo.event.connect(node,"onclick",this,"show"); +},_onTick:function(){ +if(this.timer){ +this.timeRemaining-=100; +if(this.lifetime-this.timeRemaining>=this.blockDuration){ +if(this.closeNode){ +this.closeNode.style.visibility="visible"; +} +} +if(!this.timeRemaining){ +clearInterval(this.timer); +this.hide(); +}else{ +if(this.timerNode){ +this.timerNode.innerHTML=Math.ceil(this.timeRemaining/1000); +} +} +} +}}); +dojo.provide("dojo.widget.ResizeHandle"); +dojo.widget.defineWidget("dojo.widget.ResizeHandle",dojo.widget.HtmlWidget,{targetElmId:"",templateCssPath:dojo.uri.moduleUri("dojo.widget","templates/ResizeHandle.css"),templateString:"
    ",postCreate:function(){ +dojo.event.connect(this.domNode,"onmousedown",this,"_beginSizing"); +},_beginSizing:function(e){ +if(this._isSizing){ +return false; +} +this.targetWidget=dojo.widget.byId(this.targetElmId); +this.targetDomNode=this.targetWidget?this.targetWidget.domNode:dojo.byId(this.targetElmId); +if(!this.targetDomNode){ +return; +} +this._isSizing=true; +this.startPoint={"x":e.clientX,"y":e.clientY}; +var mb=dojo.html.getMarginBox(this.targetDomNode); +this.startSize={"w":mb.width,"h":mb.height}; +dojo.event.kwConnect({srcObj:dojo.body(),srcFunc:"onmousemove",targetObj:this,targetFunc:"_changeSizing",rate:25}); +dojo.event.connect(dojo.body(),"onmouseup",this,"_endSizing"); +e.preventDefault(); +},_changeSizing:function(e){ +try{ +if(!e.clientX||!e.clientY){ +return; +} +} +catch(e){ +return; +} +var dx=this.startPoint.x-e.clientX; +var dy=this.startPoint.y-e.clientY; +var newW=this.startSize.w-dx; +var newH=this.startSize.h-dy; +if(this.minSize){ +var mb=dojo.html.getMarginBox(this.targetDomNode); +if(newWthis._scrollThreshold){ +if(!this._fixEnabled){ +var _b44=dojo.html.getMarginBox(tdn); +this.editor.editorObject.style.marginTop=_b44.height+"px"; +if(isIE){ +tdn.style.left=dojo.html.abs(tdn,dojo.html.boxSizing.MARGIN_BOX).x; +if(tdn.previousSibling){ +this._IEOriginalPos=["after",tdn.previousSibling]; +}else{ +if(tdn.nextSibling){ +this._IEOriginalPos=["before",tdn.nextSibling]; +}else{ +this._IEOriginalPos=["",tdn.parentNode]; +} +} +dojo.body().appendChild(tdn); +dojo.html.addClass(tdn,"IEFixedToolbar"); +}else{ +with(tdn.style){ +position="fixed"; +top="0px"; +} +} +tdn.style.width=_b44.width+"px"; +tdn.style.zIndex=1000; +this._fixEnabled=true; +} +if(!dojo.render.html.safari){ +var _b45=(this.height)?parseInt(this.editor.height):this.editor._lastHeight; +if(_b43>(this._scrollThreshold+_b45)){ +tdn.style.display="none"; +}else{ +tdn.style.display=""; +} +} +}else{ +if(this._fixEnabled){ +(this.editor.object||this.editor.iframe).style.marginTop=null; +with(tdn.style){ +position=""; +top=""; +zIndex=""; +display=""; +} +if(isIE){ +tdn.style.left=""; +dojo.html.removeClass(tdn,"IEFixedToolbar"); +if(this._IEOriginalPos){ +dojo.html.insertAtPosition(tdn,this._IEOriginalPos[1],this._IEOriginalPos[0]); +this._IEOriginalPos=null; +}else{ +dojo.html.insertBefore(tdn,this.editor.object||this.editor.iframe); +} +} +tdn.style.width=""; +this._fixEnabled=false; +} +} +},destroy:function(){ +this._IEOriginalPos=null; +this._handleScroll=false; +clearInterval(this.scrollInterval); +this.editor.unregisterLoadedPlugin(this); +if(dojo.render.html.ie){ +dojo.html.removeClass(this.editor.toolbarWidget.domNode,"IEFixedToolbar"); +} +}}); +dojo.provide("dojo.widget.Editor2"); +dojo.widget.Editor2Manager=new dojo.widget.HandlerManager; +dojo.lang.mixin(dojo.widget.Editor2Manager,{_currentInstance:null,commandState:{Disabled:0,Latched:1,Enabled:2},getCurrentInstance:function(){ +return this._currentInstance; +},setCurrentInstance:function(inst){ +this._currentInstance=inst; +},getCommand:function(_b47,name){ +var _b49; +name=name.toLowerCase(); +for(var i=0;ithis._updateTime||this._state==undefined){ +this._updateTime=this._editor._lastStateTimestamp; +try{ +if(this._editor.queryCommandEnabled(this._name)){ +if(this._editor.queryCommandState(this._name)){ +this._state=dojo.widget.Editor2Manager.commandState.Latched; +}else{ +this._state=dojo.widget.Editor2Manager.commandState.Enabled; +} +}else{ +this._state=dojo.widget.Editor2Manager.commandState.Disabled; +} +} +catch(e){ +this._state=dojo.widget.Editor2Manager.commandState.Enabled; +} +} +return this._state; +},getValue:function(){ +try{ +return this._editor.queryCommandValue(this._name); +} +catch(e){ +} +}}); +dojo.lang.declare("dojo.widget.Editor2FormatBlockCommand",dojo.widget.Editor2BrowserCommand,{}); +dojo.widget.defineWidget("dojo.widget.Editor2Dialog",[dojo.widget.HtmlWidget,dojo.widget.FloatingPaneBase,dojo.widget.ModalDialogBase],{templatePath:dojo.uri.moduleUri("dojo.widget","templates/Editor2/EditorDialog.html"),modal:true,width:"",height:"",windowState:"minimized",displayCloseAction:true,contentFile:"",contentClass:"",fillInTemplate:function(args,frag){ +this.fillInFloatingPaneTemplate(args,frag); +dojo.widget.Editor2Dialog.superclass.fillInTemplate.call(this,args,frag); +},postCreate:function(){ +if(this.contentFile){ +dojo.require(this.contentFile); +} +if(this.modal){ +dojo.widget.ModalDialogBase.prototype.postCreate.call(this); +}else{ +with(this.domNode.style){ +zIndex=999; +display="none"; +} +} +dojo.widget.FloatingPaneBase.prototype.postCreate.apply(this,arguments); +dojo.widget.Editor2Dialog.superclass.postCreate.call(this); +if(this.width&&this.height){ +with(this.domNode.style){ +width=this.width; +height=this.height; +} +} +},createContent:function(){ +if(!this.contentWidget&&this.contentClass){ +this.contentWidget=dojo.widget.createWidget(this.contentClass); +this.addChild(this.contentWidget); +} +},show:function(){ +if(!this.contentWidget){ +dojo.widget.Editor2Dialog.superclass.show.apply(this,arguments); +this.createContent(); +dojo.widget.Editor2Dialog.superclass.hide.call(this); +} +if(!this.contentWidget||!this.contentWidget.loadContent()){ +return; +} +this.showFloatingPane(); +dojo.widget.Editor2Dialog.superclass.show.apply(this,arguments); +if(this.modal){ +this.showModalDialog(); +} +if(this.modal){ +this.bg.style.zIndex=this.domNode.style.zIndex-1; +} +},onShow:function(){ +dojo.widget.Editor2Dialog.superclass.onShow.call(this); +this.onFloatingPaneShow(); +},closeWindow:function(){ +this.hide(); +dojo.widget.Editor2Dialog.superclass.closeWindow.apply(this,arguments); +},hide:function(){ +if(this.modal){ +this.hideModalDialog(); +} +dojo.widget.Editor2Dialog.superclass.hide.call(this); +},checkSize:function(){ +if(this.isShowing()){ +if(this.modal){ +this._sizeBackground(); +} +this.placeModalDialog(); +this.onResized(); +} +}}); +dojo.widget.defineWidget("dojo.widget.Editor2DialogContent",dojo.widget.HtmlWidget,{widgetsInTemplate:true,loadContent:function(){ +return true; +},cancel:function(){ +this.parent.hide(); +}}); +dojo.lang.declare("dojo.widget.Editor2DialogCommand",dojo.widget.Editor2BrowserCommand,function(_b55,name,_b57){ +this.dialogParas=_b57; +},{execute:function(){ +if(!this.dialog){ +if(!this.dialogParas.contentFile||!this.dialogParas.contentClass){ +alert("contentFile and contentClass should be set for dojo.widget.Editor2DialogCommand.dialogParas!"); +return; +} +this.dialog=dojo.widget.createWidget("Editor2Dialog",this.dialogParas); +dojo.body().appendChild(this.dialog.domNode); +dojo.event.connect(this,"destroy",this.dialog,"destroy"); +} +this.dialog.show(); +},getText:function(){ +return this.dialogParas.title||dojo.widget.Editor2DialogCommand.superclass.getText.call(this); +}}); +dojo.widget.Editor2ToolbarGroups={}; +dojo.widget.defineWidget("dojo.widget.Editor2",dojo.widget.RichText,function(){ +this._loadedCommands={}; +},{toolbarAlwaysVisible:false,toolbarWidget:null,scrollInterval:null,toolbarTemplatePath:dojo.uri.cache.allow(dojo.uri.moduleUri("dojo.widget","templates/EditorToolbarOneline.html")),toolbarTemplateCssPath:null,toolbarPlaceHolder:"",_inSourceMode:false,_htmlEditNode:null,toolbarGroup:"",shareToolbar:false,contextMenuGroupSet:"",editorOnLoad:function(){ +dojo.event.topic.publish("dojo.widget.Editor2::preLoadingToolbar",this); +if(this.toolbarAlwaysVisible){ +} +if(this.toolbarWidget){ +this.toolbarWidget.show(); +dojo.html.insertBefore(this.toolbarWidget.domNode,this.domNode.firstChild); +}else{ +if(this.shareToolbar){ +dojo.deprecated("Editor2:shareToolbar is deprecated in favor of toolbarGroup","0.5"); +this.toolbarGroup="defaultDojoToolbarGroup"; +} +if(this.toolbarGroup){ +if(dojo.widget.Editor2ToolbarGroups[this.toolbarGroup]){ +this.toolbarWidget=dojo.widget.Editor2ToolbarGroups[this.toolbarGroup]; +} +} +if(!this.toolbarWidget){ +var _b58={shareGroup:this.toolbarGroup,parent:this}; +_b58.templateString=dojo.uri.cache.get(this.toolbarTemplatePath); +if(this.toolbarTemplateCssPath){ +_b58.templateCssPath=this.toolbarTemplateCssPath; +_b58.templateCssString=dojo.uri.cache.get(this.toolbarTemplateCssPath); +} +if(this.toolbarPlaceHolder){ +this.toolbarWidget=dojo.widget.createWidget("Editor2Toolbar",_b58,dojo.byId(this.toolbarPlaceHolder),"after"); +}else{ +this.toolbarWidget=dojo.widget.createWidget("Editor2Toolbar",_b58,this.domNode.firstChild,"before"); +} +if(this.toolbarGroup){ +dojo.widget.Editor2ToolbarGroups[this.toolbarGroup]=this.toolbarWidget; +} +dojo.event.connect(this,"close",this.toolbarWidget,"hide"); +this.toolbarLoaded(); +} +} +dojo.event.topic.registerPublisher("Editor2.clobberFocus",this,"clobberFocus"); +dojo.event.topic.subscribe("Editor2.clobberFocus",this,"setBlur"); +dojo.event.topic.publish("dojo.widget.Editor2::onLoad",this); +},toolbarLoaded:function(){ +},registerLoadedPlugin:function(obj){ +if(!this.loadedPlugins){ +this.loadedPlugins=[]; +} +this.loadedPlugins.push(obj); +},unregisterLoadedPlugin:function(obj){ +for(var i in this.loadedPlugins){ +if(this.loadedPlugins[i]===obj){ +delete this.loadedPlugins[i]; +return; +} +} +dojo.debug("dojo.widget.Editor2.unregisterLoadedPlugin: unknow plugin object: "+obj); +},execCommand:function(_b5c,_b5d){ +switch(_b5c.toLowerCase()){ +case "htmltoggle": +this.toggleHtmlEditing(); +break; +default: +dojo.widget.Editor2.superclass.execCommand.apply(this,arguments); +} +},queryCommandEnabled:function(_b5e,_b5f){ +switch(_b5e.toLowerCase()){ +case "htmltoggle": +return true; +default: +if(this._inSourceMode){ +return false; +} +return dojo.widget.Editor2.superclass.queryCommandEnabled.apply(this,arguments); +} +},queryCommandState:function(_b60,_b61){ +switch(_b60.toLowerCase()){ +case "htmltoggle": +return this._inSourceMode; +default: +return dojo.widget.Editor2.superclass.queryCommandState.apply(this,arguments); +} +},onClick:function(e){ +dojo.widget.Editor2.superclass.onClick.call(this,e); +if(dojo.widget.PopupManager){ +if(!e){ +e=this.window.event; +} +dojo.widget.PopupManager.onClick(e); +} +},clobberFocus:function(){ +},toggleHtmlEditing:function(){ +if(this===dojo.widget.Editor2Manager.getCurrentInstance()){ +if(!this._inSourceMode){ +var html=this.getEditorContent(); +this._inSourceMode=true; +if(!this._htmlEditNode){ +this._htmlEditNode=dojo.doc().createElement("textarea"); +dojo.html.insertAfter(this._htmlEditNode,this.editorObject); +} +this._htmlEditNode.style.display=""; +this._htmlEditNode.style.width="100%"; +this._htmlEditNode.style.height=dojo.html.getBorderBox(this.editNode).height+"px"; +this._htmlEditNode.value=html; +with(this.editorObject.style){ +position="absolute"; +left="-2000px"; +top="-2000px"; +} +}else{ +this._inSourceMode=false; +this._htmlEditNode.blur(); +with(this.editorObject.style){ +position=""; +left=""; +top=""; +} +var html=this._htmlEditNode.value; +dojo.lang.setTimeout(this,"replaceEditorContent",1,html); +this._htmlEditNode.style.display="none"; +this.focus(); +} +this.onDisplayChanged(null,true); +} +},setFocus:function(){ +if(dojo.widget.Editor2Manager.getCurrentInstance()===this){ +return; +} +this.clobberFocus(); +dojo.widget.Editor2Manager.setCurrentInstance(this); +},setBlur:function(){ +},saveSelection:function(){ +this._bookmark=null; +this._bookmark=dojo.withGlobal(this.window,dojo.html.selection.getBookmark); +},restoreSelection:function(){ +if(this._bookmark){ +this.focus(); +dojo.withGlobal(this.window,"moveToBookmark",dojo.html.selection,[this._bookmark]); +this._bookmark=null; +}else{ +dojo.debug("restoreSelection: no saved selection is found!"); +} +},_updateToolbarLastRan:null,_updateToolbarTimer:null,_updateToolbarFrequency:500,updateToolbar:function(_b64){ +if((!this.isLoaded)||(!this.toolbarWidget)){ +return; +} +var diff=new Date()-this._updateToolbarLastRan; +if((!_b64)&&(this._updateToolbarLastRan)&&((diff0){ +var _b81=""; +for(var i=0;i<_b80.scripts.length;i++){ +_b81+=_b80.scripts[i]; +} +(new Function("_container_",_b81+"; return this;"))(this); +} +this.setContent(_b80.text); +}else{ +this.setContent(data); +} +}else{ +if(this.showError){ +var _b83=dojo.string.isBlank(this.errorText)?e.message:this.errorText; +this.setContent(_b83); +} +} +},notify:function(data,type,e){ +var self=this; +if(this.notifyTopicsArray){ +dojo.lang.forEach(this.notifyTopicsArray,function(_b88){ +try{ +dojo.event.topic.publish(_b88,data,type,e); +} +catch(ex){ +self.log(ex); +} +}); +} +var _b89=null; +switch(type){ +case "before": +_b89=this.beforeNotifyTopicsArray; +break; +case "load": +_b89=this.afterNotifyTopicsArray; +break; +case "error": +_b89=this.errorNotifyTopicsArray; +break; +} +this.notifyTo(_b89,data,type,e); +},notifyTo:function(_b8a,data,type,e){ +var self=this; +if(_b8a){ +dojo.lang.forEach(_b8a,function(_b8f){ +try{ +dojo.event.topic.publish(_b8f,data,type,e); +} +catch(ex){ +self.log(ex); +} +}); +} +},onDownloadStart:function(_b90){ +if(this.showLoading&&!dojo.string.isBlank(this.loadingText)){ +_b90.text=this.loadingText; +} +},reloadContents:function(evt){ +if(!dojo.string.isBlank(this.handler)){ +this.log("Invoking handler: "+this.handler); +window[this.handler](this,this.domNode); +}else{ +try{ +var self=this; +var _b93={cancel:false}; +this.notify(this.widgetId,"before",_b93); +if(_b93.cancel){ +this.log("Request canceled"); +return; +} +if(dojo.string.isBlank(this.href)){ +return; +} +if(this.formNode&&this.formNode.onsubmit!=null){ +var _b94=this.formNode.onsubmit.call(evt); +if(_b94!=null&&!_b94){ +this.log("Request canceled by 'onsubmit' of the form"); +return; +} +} +dojo.html.show(this.indicator); +if(this.showLoading){ +this.setContent(this.loadingText); +} +dojo.io.bind({url:this.href,useCache:false,preventCache:true,formNode:self.formNode,formFilter:window[self.formFilter],handler:function(type,data,e){ +dojo.lang.hitch(self,"bindHandler")(type,data,e); +},mimetype:"text/html"}); +} +catch(ex){ +if(this.showError){ +var _b98=dojo.string.isBlank(this.errorText)?ex:this.errorText; +this.setContent(_b98); +} +} +} +},parse:function(s){ +this.log("Parsing: "+s); +var _b9a=[]; +var tmp=[]; +var _b9c=[]; +while(_b9a){ +_b9a=s.match(/]*)>([\s\S]*?)<\/script>/i); +if(!_b9a){ +break; +} +if(_b9a[1]){ +attr=_b9a[1].match(/src=(['"]?)([^"']*)\1/i); +if(attr){ +var tmp2=attr[2].search(/.*(\bdojo\b(?:\.uncompressed)?\.js)$/); +if(tmp2>-1){ +this.log("Security note! inhibit:"+attr[2]+" from beeing loaded again."); +} +} +} +if(_b9a[2]){ +var sc=_b9a[2].replace(/(?:var )?\bdjConfig\b(?:[\s]*=[\s]*\{[^}]+\}|\.[\w]*[\s]*=[\s]*[^;\n]*)?;?|dojo\.hostenv\.writeIncludes\(\s*\);?/g,""); +if(!sc){ +continue; +} +tmp=[]; +while(tmp){ +tmp=sc.match(/dojo\.(?:(?:require(?:After)?(?:If)?)|(?:widget\.(?:manager\.)?registerWidgetPackage)|(?:(?:hostenv\.)?setModulePrefix))\((['"]).*?\1\)\s*;?/); +if(!tmp){ +break; +} +sc=sc.replace(tmp[0],""); +} +_b9c.push(sc); +} +s=s.replace(/]*>[\s\S]*?<\/script>/i,""); +} +return {text:s,scripts:_b9c}; +}}); +dojo.provide("dojo.lang.timing.Timer"); +dojo.lang.timing.Timer=function(_b9f){ +this.timer=null; +this.isRunning=false; +this.interval=_b9f; +this.onStart=null; +this.onStop=null; +}; +dojo.extend(dojo.lang.timing.Timer,{onTick:function(){ +},setInterval:function(_ba0){ +if(this.isRunning){ +dj_global.clearInterval(this.timer); +} +this.interval=_ba0; +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); +}}); +dojo.provide("struts.widget.BindDiv"); +dojo.widget.defineWidget("struts.widget.BindDiv",dojo.widget.ContentPane,{widgetType:"BindDiv",href:"",extractContent:false,parseContent:false,cacheContent:false,refreshOnShow:false,executeScripts:false,updateFreq:0,delay:0,autoStart:true,timer:null,loadingText:"Loading...",showLoading:true,errorText:"",showError:true,listenTopics:"",notifyTopics:"",notifyTopicsArray:null,stopTimerListenTopics:"",startTimerListenTopics:"",beforeNotifyTopics:"",beforeNotifyTopicsArray:null,afterNotifyTopics:"",afterNotifyTopicsArray:null,errorNotifyTopics:"",errorNotifyTopicsArray:null,beforeLoading:"",afterLoading:"",formId:"",formFilter:"",firstTime:true,indicator:"",parseContent:true,onDownloadStart:function(_ba1){ +if(!this.showLoading){ +_ba1.returnValue=false; +return; +} +if(this.showLoading&&!dojo.string.isBlank(this.loadingText)){ +_ba1.text=this.loadingText; +} +},onDownloadError:function(_ba2){ +this.onError(_ba2); +},onContentError:function(_ba3){ +this.onError(_ba3); +},onExecError:function(_ba4){ +this.onError(_ba4); +},onError:function(_ba5){ +if(this.showError){ +if(!dojo.string.isBlank(this.errorText)){ +_ba5.text=this.errorText; +} +}else{ +_ba5.text=""; +} +},notify:function(data,type,e){ +if(this.notifyTopicsArray){ +var self=this; +dojo.lang.forEach(this.notifyTopicsArray,function(_baa){ +try{ +dojo.event.topic.publish(_baa,data,type,e); +} +catch(ex){ +self.log(ex); +} +}); +} +var _bab=null; +switch(type){ +case "before": +_bab=this.beforeNotifyTopicsArray; +break; +case "load": +_bab=this.afterNotifyTopicsArray; +break; +case "error": +_bab=this.errorNotifyTopicsArray; +break; +} +this.notifyTo(_bab,data,type,e); +},notifyTo:function(_bac,data,type,e){ +var self=this; +if(_bac){ +dojo.lang.forEach(_bac,function(_bb1){ +try{ +dojo.event.topic.publish(_bb1,data,type,e); +} +catch(ex){ +self.log(ex); +} +}); +} +},postCreate:function(args,frag){ +struts.widget.BindDiv.superclass.postCreate.apply(this); +var self=this; +var _bb5=function(){ +dojo.lang.hitch(self,"refresh")(); +}; +var _bb6=function(){ +dojo.lang.hitch(self,"startTimer")(); +}; +if(this.updateFreq>0){ +this.timer=new dojo.lang.timing.Timer(this.updateFreq); +this.timer.onTick=_bb5; +if(this.autoStart){ +if(this.delay>0){ +dojo.lang.setTimeout(this.delay,_bb6); +}else{ +this.startTimer(); +} +} +}else{ +if(this.delay>0){ +dojo.lang.setTimeout(this.delay,_bb5); +} +} +if(this.autoStart){ +if(this.delay>0){ +if(this.updateFreq>0){ +dojo.lang.setTimeout(this.delay,_bb6); +}else{ +dojo.lang.setTimeout(this.delay,_bb5); +} +} +} +if(!dojo.string.isBlank(this.listenTopics)){ +this.log("Listening to "+this.listenTopics+" to refresh"); +var _bb7=this.listenTopics.split(","); +if(_bb7){ +dojo.lang.forEach(_bb7,function(_bb8){ +dojo.event.topic.subscribe(_bb8,self,"refresh"); +}); +} +} +if(!dojo.string.isBlank(this.stopTimerListenTopics)){ +this.log("Listening to "+this.stopTimerListenTopics+" to stop timer"); +var _bb9=this.stopTimerListenTopics.split(","); +if(_bb9){ +dojo.lang.forEach(_bb9,function(_bba){ +dojo.event.topic.subscribe(_bba,self,"stopTimer"); +}); +} +} +if(!dojo.string.isBlank(this.startTimerListenTopics)){ +this.log("Listening to "+this.stopTimerListenTopics+" to start timer"); +var _bbb=this.startTimerListenTopics.split(","); +if(_bbb){ +dojo.lang.forEach(_bbb,function(_bbc){ +dojo.event.topic.subscribe(_bbc,self,"startTimer"); +}); +} +} +if(!dojo.string.isBlank(this.notifyTopics)){ +this.notifyTopicsArray=this.notifyTopics.split(","); +} +if(!dojo.string.isBlank(this.beforeNotifyTopics)){ +this.beforeNotifyTopicsArray=this.beforeNotifyTopics.split(","); +} +if(!dojo.string.isBlank(this.afterNotifyTopics)){ +this.afterNotifyTopicsArray=this.afterNotifyTopics.split(","); +} +if(!dojo.string.isBlank(this.errorNotifyTopics)){ +this.errorNotifyTopicsArray=this.errorNotifyTopics.split(","); +} +},_downloadExternalContent:function(url,_bbe){ +if(this.firstTime){ +this.firstTime=false; +if(this.delay>0){ +return; +} +} +var _bbf={cancel:false}; +this.notify(this.widgetId,"before",_bbf); +if(_bbf.cancel){ +return; +} +dojo.html.show(this.indicator); +this._handleDefaults("Loading...","onDownloadStart"); +var self=this; +dojo.io.bind({url:url,useCache:_bbe,preventCache:!_bbe,mimetype:"text/html",formNode:dojo.byId(self.formId),formFilter:window[self.formFilter],handler:function(type,data,e){ +dojo.html.hide(self.indicator); +self.notify(data,type,e); +if(type=="load"){ +self.onDownloadEnd.call(self,url,data); +}else{ +self._handleDefaults.call(self,"Error loading '"+url+"' ("+e.status+" "+e.statusText+")","onDownloadError"); +self.onLoad(); +} +}}); +},log:function(text){ +dojo.debug("["+this.widgetId+"] "+text); +},stopTimer:function(){ +if(this.timer&&this.timer.isRunning){ +this.log("stopping timer"); +this.timer.stop(); +} +},startTimer:function(){ +if(this.timer&&!this.timer.isRunning){ +this.log("starting timer with update interval "+this.updateFreq); +this.timer.start(); +} +}}); +dojo.provide("struts.widget.BindAnchor"); +dojo.widget.defineWidget("struts.widget.BindAnchor",struts.widget.Bind,{widgetType:"BindAnchor",event:"onclick",postCreate:function(){ +struts.widget.BindAnchor.superclass.postCreate.apply(this); +this.domNode.href="#"; +}}); +dojo.provide("dojo.widget.html.stabile"); +dojo.widget.html.stabile={_sqQuotables:new RegExp("([\\\\'])","g"),_depth:0,_recur:false,depthLimit:2}; +dojo.widget.html.stabile.getState=function(id){ +dojo.widget.html.stabile.setup(); +return dojo.widget.html.stabile.widgetState[id]; +}; +dojo.widget.html.stabile.setState=function(id,_bc7,_bc8){ +dojo.widget.html.stabile.setup(); +dojo.widget.html.stabile.widgetState[id]=_bc7; +if(_bc8){ +dojo.widget.html.stabile.commit(dojo.widget.html.stabile.widgetState); +} +}; +dojo.widget.html.stabile.setup=function(){ +if(!dojo.widget.html.stabile.widgetState){ +var text=dojo.widget.html.stabile._getStorage().value; +dojo.widget.html.stabile.widgetState=text?dj_eval("("+text+")"):{}; +} +}; +dojo.widget.html.stabile.commit=function(_bca){ +dojo.widget.html.stabile._getStorage().value=dojo.widget.html.stabile.description(_bca); +}; +dojo.widget.html.stabile.description=function(v,_bcc){ +var _bcd=dojo.widget.html.stabile._depth; +var _bce=function(){ +return this.description(this,true); +}; +try{ +if(v===void (0)){ +return "undefined"; +} +if(v===null){ +return "null"; +} +if(typeof (v)=="boolean"||typeof (v)=="number"||v instanceof Boolean||v instanceof Number){ +return v.toString(); +} +if(typeof (v)=="string"||v instanceof String){ +var v1=v.replace(dojo.widget.html.stabile._sqQuotables,"\\$1"); +v1=v1.replace(/\n/g,"\\n"); +v1=v1.replace(/\r/g,"\\r"); +return "'"+v1+"'"; +} +if(v instanceof Date){ +return "new Date("+d.getFullYear+","+d.getMonth()+","+d.getDate()+")"; +} +var d; +if(v instanceof Array||v.push){ +if(_bcd>=dojo.widget.html.stabile.depthLimit){ +return "[ ... ]"; +} +d="["; +var _bd1=true; +dojo.widget.html.stabile._depth++; +for(var i=0;i=dojo.widget.html.stabile.depthLimit){ +return "{ ... }"; +} +if(typeof (v.hasOwnProperty)!="function"&&v.prototype){ +throw new Error("description: "+v+" not supported by script engine"); +} +var _bd1=true; +d="{"; +dojo.widget.html.stabile._depth++; +for(var key in v){ +if(v[key]==void (0)||typeof (v[key])=="function"){ +continue; +} +if(_bd1){ +_bd1=false; +}else{ +d+=", "; +} +var kd=key; +if(!kd.match(/^[a-zA-Z_][a-zA-Z0-9_]*$/)){ +kd=arguments.callee(key,_bcc); +} +d+=kd+": "+arguments.callee(v[key],_bcc); +} +return d+"}"; +} +if(_bcc){ +if(dojo.widget.html.stabile._recur){ +var _bd5=Object.prototype.toString; +return _bd5.apply(v,[]); +}else{ +dojo.widget.html.stabile._recur=true; +return v.toString(); +} +}else{ +throw new Error("Unknown type: "+v); +return "'unknown'"; +} +} +finally{ +dojo.widget.html.stabile._depth=_bcd; +} +}; +dojo.widget.html.stabile._getStorage=function(){ +if(dojo.widget.html.stabile.dataField){ +return dojo.widget.html.stabile.dataField; +} +var form=document.forms._dojo_form; +return dojo.widget.html.stabile.dataField=form?form.stabile:{value:""}; +}; +dojo.provide("dojo.widget.ComboBox"); +dojo.declare("dojo.widget.incrementalComboBoxDataProvider",null,function(_bd7){ +this.searchUrl=_bd7.dataUrl; +this._cache={}; +this._inFlight=false; +this._lastRequest=null; +this.allowCache=false; +},{_addToCache:function(_bd8,data){ +if(this.allowCache){ +this._cache[_bd8]=data; +} +},startSearch:function(_bda,_bdb){ +if(this._inFlight){ +} +var tss=encodeURIComponent(_bda); +var _bdd=dojo.string.substituteParams(this.searchUrl,{"searchString":tss}); +var _bde=this; +var _bdf=this._lastRequest=dojo.io.bind({url:_bdd,method:"get",mimetype:"text/json",load:function(type,data,evt){ +_bde._inFlight=false; +if(!dojo.lang.isArray(data)){ +var _be3=[]; +for(var key in data){ +_be3.push([data[key],key]); +} +data=_be3; +} +_bde._addToCache(_bda,data); +if(_bdf==_bde._lastRequest){ +_bdb(data); +} +}}); +this._inFlight=true; +}}); +dojo.declare("dojo.widget.basicComboBoxDataProvider",null,function(_be5,node){ +this._data=[]; +this.searchLimit=30; +this.searchType="STARTSTRING"; +this.caseSensitive=false; +if(!dj_undef("dataUrl",_be5)&&!dojo.string.isBlank(_be5.dataUrl)){ +this._getData(_be5.dataUrl); +}else{ +if((node)&&(node.nodeName.toLowerCase()=="select")){ +var opts=node.getElementsByTagName("option"); +var ol=opts.length; +var data=[]; +for(var x=0;x0)&&(ret.length>=this.searchLimit)){ +break; +} +var _bfa=new String((!this.caseSensitive)?this._data[x][0].toLowerCase():this._data[x][0]); +if(_bfa.length<_bf5.length){ +continue; +} +if(st=="STARTSTRING"){ +if(_bf5==_bfa.substr(0,_bf5.length)){ +ret.push(this._data[x]); +} +}else{ +if(st=="SUBSTRING"){ +if(_bfa.indexOf(_bf5)>=0){ +ret.push(this._data[x]); +} +}else{ +if(st=="STARTWORD"){ +var idx=_bfa.indexOf(_bf5); +if(idx==0){ +ret.push(this._data[x]); +} +if(idx<=0){ +continue; +} +var _bfc=false; +while(idx!=-1){ +if(" ,/(".indexOf(_bfa.charAt(idx-1))!=-1){ +_bfc=true; +break; +} +idx=_bfa.indexOf(_bf5,idx+1); +} +if(!_bfc){ +continue; +}else{ +ret.push(this._data[x]); +} +} +} +} +} +_bf6(ret); +},setData:function(_bfd){ +this._data=_bfd; +}}); +dojo.widget.defineWidget("dojo.widget.ComboBox",dojo.widget.HtmlWidget,{forceValidOption:false,searchType:"stringstart",dataProvider:null,autoComplete:true,searchDelay:100,dataUrl:"",fadeTime:200,maxListLength:8,mode:"local",selectedResult:null,dataProviderClass:"",buttonSrc:dojo.uri.moduleUri("dojo.widget","templates/images/combo_box_arrow.png"),dropdownToggle:"fade",templatePath:dojo.uri.moduleUri("dojo.widget","templates/ComboBox.html"),templateCssPath:dojo.uri.moduleUri("dojo.widget","templates/ComboBox.css"),setValue:function(_bfe){ +this.comboBoxValue.value=_bfe; +if(this.textInputNode.value!=_bfe){ +this.textInputNode.value=_bfe; +dojo.widget.html.stabile.setState(this.widgetId,this.getState(),true); +this.onValueChanged(_bfe); +} +},onValueChanged:function(_bff){ +},getValue:function(){ +return this.comboBoxValue.value; +},getState:function(){ +return {value:this.getValue()}; +},setState:function(_c00){ +this.setValue(_c00.value); +},enable:function(){ +this.disabled=false; +this.textInputNode.removeAttribute("disabled"); +},disable:function(){ +this.disabled=true; +this.textInputNode.setAttribute("disabled",true); +},_getCaretPos:function(_c01){ +if(dojo.lang.isNumber(_c01.selectionStart)){ +return _c01.selectionStart; +}else{ +if(dojo.render.html.ie){ +var tr=document.selection.createRange().duplicate(); +var ntr=_c01.createTextRange(); +tr.move("character",0); +ntr.move("character",0); +try{ +ntr.setEndPoint("EndToEnd",tr); +return String(ntr.text).replace(/\r/g,"").length; +} +catch(e){ +return 0; +} +} +} +},_setCaretPos:function(_c04,_c05){ +_c05=parseInt(_c05); +this._setSelectedRange(_c04,_c05,_c05); +},_setSelectedRange:function(_c06,_c07,end){ +if(!end){ +end=_c06.value.length; +} +if(_c06.setSelectionRange){ +_c06.focus(); +_c06.setSelectionRange(_c07,end); +}else{ +if(_c06.createTextRange){ +var _c09=_c06.createTextRange(); +with(_c09){ +collapse(true); +moveEnd("character",end); +moveStart("character",_c07); +select(); +} +}else{ +_c06.value=_c06.value; +_c06.blur(); +_c06.focus(); +var dist=parseInt(_c06.value.length)-end; +var _c0b=String.fromCharCode(37); +var tcc=_c0b.charCodeAt(0); +for(var x=0;x0)){ +var cpos=this._getCaretPos(this.textInputNode); +if((cpos+1)>this.textInputNode.value.length){ +this.textInputNode.value+=_c20[0][0].substr(cpos); +this._setSelectedRange(this.textInputNode,cpos,this.textInputNode.value.length); +} +} +var even=true; +while(_c20.length){ +var tr=_c20.shift(); +if(tr){ +var td=document.createElement("div"); +td.appendChild(document.createTextNode(tr[0])); +td.setAttribute("resultName",tr[0]); +td.setAttribute("resultValue",tr[1]); +td.className="dojoComboBoxItem "+((even)?"dojoComboBoxItemEven":"dojoComboBoxItemOdd"); +even=(!even); +this.optionsListNode.appendChild(td); +} +} +this._showResultList(); +},_onFocusInput:function(){ +this._hasFocus=true; +},_onBlurInput:function(){ +this._hasFocus=false; +this._handleBlurTimer(true,500); +},_handleBlurTimer:function(_c25,_c26){ +if(this.blurTimer&&(_c25||_c26)){ +clearTimeout(this.blurTimer); +} +if(_c26){ +this.blurTimer=dojo.lang.setTimeout(this,"_checkBlurred",_c26); +} +},_onMouseOver:function(evt){ +if(!this._mouseover_list){ +this._handleBlurTimer(true,0); +this._mouseover_list=true; +} +},_onMouseOut:function(evt){ +var _c29=evt.relatedTarget; +try{ +if(!_c29||_c29.parentNode!=this.optionsListNode){ +this._mouseover_list=false; +this._handleBlurTimer(true,100); +this._tryFocus(); +} +} +catch(e){ +} +},_isInputEqualToResult:function(_c2a){ +var _c2b=this.textInputNode.value; +if(!this.dataProvider.caseSensitive){ +_c2b=_c2b.toLowerCase(); +_c2a=_c2a.toLowerCase(); +} +return (_c2b==_c2a); +},_isValidOption:function(){ +var tgt=dojo.html.firstElement(this.optionsListNode); +var _c2d=false; +while(!_c2d&&tgt){ +if(this._isInputEqualToResult(tgt.getAttribute("resultName"))){ +_c2d=true; +}else{ +tgt=dojo.html.nextElement(tgt); +} +} +return _c2d; +},_checkBlurred:function(){ +if(!this._hasFocus&&!this._mouseover_list){ +this._hideResultList(); +if(!this.textInputNode.value.length){ +this.setAllValues("",""); +return; +} +var _c2e=this._isValidOption(); +if(this.forceValidOption&&!_c2e){ +this.setAllValues("",""); +return; +} +if(!_c2e){ +this.setSelectedValue(""); +} +} +},_selectOption:function(evt){ +var tgt=null; +if(!evt){ +evt={target:this._highlighted_option}; +} +if(!dojo.html.isDescendantOf(evt.target,this.optionsListNode)){ +if(!this.textInputNode.value.length){ +return; +} +tgt=dojo.html.firstElement(this.optionsListNode); +if(!tgt||!this._isInputEqualToResult(tgt.getAttribute("resultName"))){ +return; +} +}else{ +tgt=evt.target; +} +while((tgt.nodeType!=1)||(!tgt.getAttribute("resultName"))){ +tgt=tgt.parentNode; +if(tgt===dojo.body()){ +return false; +} +} +this.selectedResult=[tgt.getAttribute("resultName"),tgt.getAttribute("resultValue")]; +this.setAllValues(tgt.getAttribute("resultName"),tgt.getAttribute("resultValue")); +if(!evt.noHide){ +this._hideResultList(); +this._setSelectedRange(this.textInputNode,0,null); +} +this._tryFocus(); +},_clearResultList:function(){ +if(this.optionsListNode.innerHTML){ +this.optionsListNode.innerHTML=""; +} +},_hideResultList:function(){ +this.popupWidget.close(); +},_showResultList:function(){ +var _c31=this.optionsListNode.childNodes; +if(_c31.length){ +var _c32=Math.min(_c31.length,this.maxListLength); +with(this.optionsListNode.style){ +display=""; +if(_c32==_c31.length){ +height=""; +}else{ +height=_c32*dojo.html.getMarginBox(_c31[0]).height+"px"; +} +width=(dojo.html.getMarginBox(this.domNode).width-2)+"px"; +} +this.popupWidget.open(this.domNode,this,this.downArrowNode); +}else{ +this._hideResultList(); +} +},handleArrowClick:function(){ +this._handleBlurTimer(true,0); +this._tryFocus(); +if(this.popupWidget.isShowingNow){ +this._hideResultList(); +}else{ +this._startSearch(""); +} +},_tryFocus:function(){ +try{ +this.textInputNode.focus(); +} +catch(e){ +} +},_startSearchFromInput:function(){ +this._startSearch(this.textInputNode.value); +},_startSearch:function(key){ +this.dataProvider.startSearch(key,dojo.lang.hitch(this,"_openResultList")); +},postCreate:function(){ +this.onResize(); +dojo.event.connect(this.textInputNode,"onblur",this,"_onBlurInput"); +dojo.event.connect(this.textInputNode,"onfocus",this,"_onFocusInput"); +if(this.disabled){ +this.disable(); +} +var s=dojo.widget.html.stabile.getState(this.widgetId); +if(s){ +this.setState(s); +} +}}); +dojo.provide("struts.widget.ComboBox"); +struts.widget.ComboBoxDataProvider=function(_c35,node){ +this.data=[]; +this.searchLimit=30; +this.searchType="STARTSTRING"; +this.caseSensitive=false; +this._lastSearch=""; +this._lastSearchResults=null; +this.firstRequest=true; +this.cbox=_c35; +this.formId=this.cbox.formId; +this.formFilter=this.cbox.formFilter; +this.getData=function(url){ +dojo.html.show(this.cbox.indicator); +dojo.io.bind({url:url,formNode:dojo.byId(this.formId),formFilter:window[this.formFilter],handler:dojo.lang.hitch(this,function(type,data,evt){ +this.firstRequest=false; +dojo.html.hide(this.cbox.indicator); +if(!this.firstRequest){ +this.cbox.notify.apply(this.cbox,[data,type,evt]); +} +if(!dojo.lang.isArray(data)){ +if(!dojo.string.isBlank(this.cbox.dataFieldName)&&data[this.cbox.dataFieldName]!=null){ +_c3b=data[this.cbox.dataFieldName]; +}else{ +var _c3b=null; +for(var key in data){ +if(key==this.cbox.name){ +_c3b=data[key]; +break; +} +if(!_c3b&&dojo.lang.isArray(data[key])){ +_c3b=data=data[key]; +} +} +} +data=_c3b; +} +this.setData(data); +}),mimetype:"text/json"}); +}; +this.startSearch=function(_c3d,_c3e){ +this._preformSearch(_c3d,_c3e); +}; +this._preformSearch=function(_c3f,_c40){ +var st=this.searchType; +var ret=[]; +if(!this.caseSensitive){ +_c3f=_c3f.toLowerCase(); +} +for(var x=0;x0)&&(ret.length>=this.searchLimit)){ +break; +} +var _c44=new String((!this.caseSensitive)?this.data[x][0].toLowerCase():this.data[x][0]); +if(_c44.length<_c3f.length){ +continue; +} +if(st=="STARTSTRING"){ +if(_c3f==_c44.substr(0,_c3f.length)){ +ret.push(this.data[x]); +} +}else{ +if(st=="SUBSTRING"){ +if(_c44.indexOf(_c3f)>=0){ +ret.push(this.data[x]); +} +}else{ +if(st=="STARTWORD"){ +var idx=_c44.indexOf(_c3f); +if(idx==0){ +ret.push(this.data[x]); +} +if(idx<=0){ +continue; +} +var _c46=false; +while(idx!=-1){ +if(" ,/(".indexOf(_c44.charAt(idx-1))!=-1){ +_c46=true; +break; +} +idx=_c44.indexOf(_c3f,idx+1); +} +if(!_c46){ +continue; +}else{ +ret.push(this.data[x]); +} +} +} +} +} +_c40(ret); +}; +this.addData=function(_c47){ +this.data=this.data.concat(_c47); +}; +this.setData=function(_c48){ +this.data=_c48; +for(var i=0;i0)){ +var cpos=this._getCaretPos(this.textInputNode); +if((cpos+1)>this.textInputNode.value.length){ +this.textInputNode.value+=_c53[0][0].substr(cpos); +this._setSelectedRange(this.textInputNode,cpos,this.textInputNode.value.length); +} +} +var _c55=this.textInputNode.value; +var even=true; +while(_c53.length){ +var tr=_c53.shift(); +if(tr){ +var td=document.createElement("div"); +var text=tr[0]; +var i=text.toLowerCase().indexOf(_c55.toLowerCase()); +if(i>=0){ +var pre=text.substring(0,i); +var _c5c=text.substring(i,i+_c55.length); +var post=text.substring(i+_c55.length); +if(!dojo.string.isBlank(pre)){ +td.appendChild(document.createTextNode(pre)); +} +var _c5e=document.createElement("b"); +td.appendChild(_c5e); +_c5e.appendChild(document.createTextNode(_c5c)); +td.appendChild(document.createTextNode(post)); +}else{ +td.appendChild(document.createTextNode(tr[0])); +} +td.setAttribute("resultName",tr[0]); +td.setAttribute("resultValue",tr[1]); +td.className="dojoComboBoxItem "+((even)?"dojoComboBoxItemEven":"dojoComboBoxItemOdd"); +even=(!even); +this.optionsListNode.appendChild(td); +} +} +this.showResultList(); +},postCreate:function(){ +struts.widget.ComboBox.superclass.postCreate.apply(this); +var self=this; +if(!dojo.string.isBlank(this.listenTopics)){ +var _c60=this.listenTopics.split(","); +for(var i=0;i<_c60.length;i++){ +dojo.event.topic.subscribe(_c60[i],function(){ +var _c62={cancel:false}; +self.notify(this.widgetId,"before",_c62); +if(_c62.cancel){ +return; +} +self.clearValues(); +self.dataProvider.getData(self.dataUrl); +}); +} +} +if(!dojo.string.isBlank(this.notifyTopics)){ +this.notifyTopicsArray=this.notifyTopics.split(","); +} +if(!dojo.string.isBlank(this.beforeNotifyTopics)){ +this.beforeNotifyTopicsArray=this.beforeNotifyTopics.split(","); +} +if(!dojo.string.isBlank(this.afterNotifyTopics)){ +this.afterNotifyTopicsArray=this.afterNotifyTopics.split(","); +} +if(!dojo.string.isBlank(this.errorNotifyTopics)){ +this.errorNotifyTopicsArray=this.errorNotifyTopics.split(","); +} +if(!dojo.string.isBlank(this.valueNotifyTopics)){ +this.valueNotifyTopicsArray=this.valueNotifyTopics.split(","); +} +this.comboBoxSelectionValue.name=dojo.string.isBlank(this.keyName)?this.name+"Key":this.keyName; +this.comboBoxValue.value=this.initialValue; +this.comboBoxSelectionValue.value=this.initialKey; +this.textInputNode.value=this.initialValue; +if(!this.visibleDownArrow){ +dojo.html.hide(this.downArrowNode); +} +if(!dojo.string.isBlank(this.searchType)){ +this.dataProvider.searchType=this.searchType.toUpperCase(); +} +},clearValues:function(){ +this.comboBoxValue.value=""; +this.comboBoxSelectionValue.value=""; +this.textInputNode.value=""; +},onValueChanged:function(data){ +this.notify(data,"valuechanged",null); +},notify:function(data,type,e){ +if(this.notifyTopicsArray){ +var self=this; +dojo.lang.forEach(this.notifyTopicsArray,function(_c68){ +try{ +dojo.event.topic.publish(_c68,data,type,e); +} +catch(ex){ +self.log(ex); +} +}); +} +var _c69=null; +switch(type){ +case "before": +_c69=this.beforeNotifyTopicsArray; +break; +case "load": +_c69=this.afterNotifyTopicsArray; +break; +case "error": +_c69=this.errorNotifyTopicsArray; +break; +case "valuechanged": +_c69=this.valueNotifyTopicsArray; +break; +} +this.notifyTo(_c69,data,type,e); +},notifyTo:function(_c6a,data,type,e){ +var self=this; +if(_c6a){ +dojo.lang.forEach(_c6a,function(_c6f){ +try{ +dojo.event.topic.publish(_c6f,data,type,e); +} +catch(ex){ +self.log(ex); +} +}); +} +},log:function(text){ +dojo.debug("["+(this.widgetId?this.widgetId:"unknown")+"] "+text); +},startSearchFromInput:function(){ +var _c71=this.textInputNode.value; +if(this.loadOnType){ +if(_c71.length>=this.loadMinimum){ +var _c72=this.dataUrl+(this.dataUrl.indexOf("?")>-1?"&":"?"); +_c72+=this.name+"="+_c71; +this.dataProvider.getData(_c72); +this.startSearch(_c71); +}else{ +this._hideResultList(); +} +}else{ +this.startSearch(_c71); +} +}}); +dojo.provide("dojo.widget.DropdownContainer"); +dojo.widget.defineWidget("dojo.widget.DropdownContainer",dojo.widget.HtmlWidget,{inputWidth:"7em",id:"",inputId:"",inputName:"",iconURL:dojo.uri.moduleUri("dojo.widget","templates/images/combo_box_arrow.png"),copyClasses:false,iconAlt:"",containerToggle:"plain",containerToggleDuration:150,templateString:" \"${this.iconAlt}\"",templateCssPath:"",isContainer:true,attachTemplateNodes:function(){ +dojo.widget.DropdownContainer.superclass.attachTemplateNodes.apply(this,arguments); +this.popup=dojo.widget.createWidget("PopupContainer",{toggle:this.containerToggle,toggleDuration:this.containerToggleDuration}); +this.containerNode=this.popup.domNode; +},fillInTemplate:function(args,frag){ +this.domNode.appendChild(this.popup.domNode); +if(this.id){ +this.domNode.id=this.id; +} +if(this.inputId){ +this.inputNode.id=this.inputId; +} +if(this.inputName){ +this.inputNode.name=this.inputName; +} +this.inputNode.style.width=this.inputWidth; +this.inputNode.disabled=this.disabled; +if(this.copyClasses){ +this.inputNode.style=""; +this.inputNode.className=this.getFragNodeRef(frag).className; +} +dojo.event.connect(this.inputNode,"onchange",this,"onInputChange"); +},onIconClick:function(evt){ +if(this.disabled){ +return; +} +if(!this.popup.isShowingNow){ +this.popup.open(this.inputNode,this,this.buttonNode); +}else{ +this.popup.close(); +} +},hideContainer:function(){ +if(this.popup.isShowingNow){ +this.popup.close(); +} +},onInputChange:function(){ +},enable:function(){ +this.inputNode.disabled=false; +dojo.widget.DropdownContainer.superclass.enable.apply(this,arguments); +},disable:function(){ +this.inputNode.disabled=true; +dojo.widget.DropdownContainer.superclass.disable.apply(this,arguments); +}}); +dojo.provide("dojo.date.serialize"); +dojo.date.setIso8601=function(_c76,_c77){ +var _c78=(_c77.indexOf("T")==-1)?_c77.split(" "):_c77.split("T"); +_c76=dojo.date.setIso8601Date(_c76,_c78[0]); +if(_c78.length==2){ +_c76=dojo.date.setIso8601Time(_c76,_c78[1]); +} +return _c76; +}; +dojo.date.fromIso8601=function(_c79){ +return dojo.date.setIso8601(new Date(0,0),_c79); +}; +dojo.date.setIso8601Date=function(_c7a,_c7b){ +var _c7c="^([0-9]{4})((-?([0-9]{2})(-?([0-9]{2}))?)|"+"(-?([0-9]{3}))|(-?W([0-9]{2})(-?([1-7]))?))?$"; +var d=_c7b.match(new RegExp(_c7c)); +if(!d){ +dojo.debug("invalid date string: "+_c7b); +return null; +} +var year=d[1]; +var _c7f=d[4]; +var date=d[6]; +var _c81=d[8]; +var week=d[10]; +var _c83=d[12]?d[12]:1; +_c7a.setFullYear(year); +if(_c81){ +_c7a.setMonth(0); +_c7a.setDate(Number(_c81)); +}else{ +if(week){ +_c7a.setMonth(0); +_c7a.setDate(1); +var gd=_c7a.getDay(); +var day=gd?gd:7; +var _c86=Number(_c83)+(7*Number(week)); +if(day<=4){ +_c7a.setDate(_c86+1-day); +}else{ +_c7a.setDate(_c86+8-day); +} +}else{ +if(_c7f){ +_c7a.setDate(1); +_c7a.setMonth(_c7f-1); +} +if(date){ +_c7a.setDate(date); +} +} +} +return _c7a; +}; +dojo.date.fromIso8601Date=function(_c87){ +return dojo.date.setIso8601Date(new Date(0,0),_c87); +}; +dojo.date.setIso8601Time=function(_c88,_c89){ +var _c8a="Z|(([-+])([0-9]{2})(:?([0-9]{2}))?)$"; +var d=_c89.match(new RegExp(_c8a)); +var _c8c=0; +if(d){ +if(d[0]!="Z"){ +_c8c=(Number(d[3])*60)+Number(d[5]); +_c8c*=((d[2]=="-")?1:-1); +} +_c8c-=_c88.getTimezoneOffset(); +_c89=_c89.substr(0,_c89.length-d[0].length); +} +var _c8d="^([0-9]{2})(:?([0-9]{2})(:?([0-9]{2})(.([0-9]+))?)?)?$"; +d=_c89.match(new RegExp(_c8d)); +if(!d){ +dojo.debug("invalid time string: "+_c89); +return null; +} +var _c8e=d[1]; +var mins=Number((d[3])?d[3]:0); +var secs=(d[5])?d[5]:0; +var ms=d[7]?(Number("0."+d[7])*1000):0; +_c88.setHours(_c8e); +_c88.setMinutes(mins); +_c88.setSeconds(secs); +_c88.setMilliseconds(ms); +if(_c8c!==0){ +_c88.setTime(_c88.getTime()+_c8c*60000); +} +return _c88; +}; +dojo.date.fromIso8601Time=function(_c92){ +return dojo.date.setIso8601Time(new Date(0,0),_c92); +}; +dojo.date.toRfc3339=function(_c93,_c94){ +if(!_c93){ +_c93=new Date(); +} +var _=dojo.string.pad; +var _c96=[]; +if(_c94!="timeOnly"){ +var date=[_(_c93.getFullYear(),4),_(_c93.getMonth()+1,2),_(_c93.getDate(),2)].join("-"); +_c96.push(date); +} +if(_c94!="dateOnly"){ +var time=[_(_c93.getHours(),2),_(_c93.getMinutes(),2),_(_c93.getSeconds(),2)].join(":"); +var _c99=_c93.getTimezoneOffset(); +time+=(_c99>0?"-":"+")+_(Math.floor(Math.abs(_c99)/60),2)+":"+_(Math.abs(_c99)%60,2); +_c96.push(time); +} +return _c96.join("T"); +}; +dojo.date.fromRfc3339=function(_c9a){ +if(_c9a.indexOf("Tany")!=-1){ +_c9a=_c9a.replace("Tany",""); +} +var _c9b=new Date(); +return dojo.date.setIso8601(_c9b,_c9a); +}; +dojo.provide("dojo.date.common"); +dojo.date.setDayOfYear=function(_c9c,_c9d){ +_c9c.setMonth(0); +_c9c.setDate(_c9d); +return _c9c; +}; +dojo.date.getDayOfYear=function(_c9e){ +var _c9f=_c9e.getFullYear(); +var _ca0=new Date(_c9f-1,11,31); +return Math.floor((_c9e.getTime()-_ca0.getTime())/86400000); +}; +dojo.date.setWeekOfYear=function(_ca1,week,_ca3){ +if(arguments.length==1){ +_ca3=0; +} +dojo.unimplemented("dojo.date.setWeekOfYear"); +}; +dojo.date.getWeekOfYear=function(_ca4,_ca5){ +if(arguments.length==1){ +_ca5=0; +} +var _ca6=new Date(_ca4.getFullYear(),0,1); +var day=_ca6.getDay(); +_ca6.setDate(_ca6.getDate()-day+_ca5-(day>_ca5?7:0)); +return Math.floor((_ca4.getTime()-_ca6.getTime())/604800000); +}; +dojo.date.setIsoWeekOfYear=function(_ca8,week,_caa){ +if(arguments.length==1){ +_caa=1; +} +dojo.unimplemented("dojo.date.setIsoWeekOfYear"); +}; +dojo.date.getIsoWeekOfYear=function(_cab,_cac){ +if(arguments.length==1){ +_cac=1; +} +dojo.unimplemented("dojo.date.getIsoWeekOfYear"); +}; +dojo.date.shortTimezones=["IDLW","BET","HST","MART","AKST","PST","MST","CST","EST","AST","NFT","BST","FST","AT","GMT","CET","EET","MSK","IRT","GST","AFT","AGTT","IST","NPT","ALMT","MMT","JT","AWST","JST","ACST","AEST","LHST","VUT","NFT","NZT","CHAST","PHOT","LINT"]; +dojo.date.timezoneOffsets=[-720,-660,-600,-570,-540,-480,-420,-360,-300,-240,-210,-180,-120,-60,0,60,120,180,210,240,270,300,330,345,360,390,420,480,540,570,600,630,660,690,720,765,780,840]; +dojo.date.getDaysInMonth=function(_cad){ +var _cae=_cad.getMonth(); +var days=[31,28,31,30,31,30,31,31,30,31,30,31]; +if(_cae==1&&dojo.date.isLeapYear(_cad)){ +return 29; +}else{ +return days[_cae]; +} +}; +dojo.date.isLeapYear=function(_cb0){ +var year=_cb0.getFullYear(); +return (year%400==0)?true:(year%100==0)?false:(year%4==0)?true:false; +}; +dojo.date.getTimezoneName=function(_cb2){ +var str=_cb2.toString(); +var tz=""; +var _cb5; +var pos=str.indexOf("("); +if(pos>-1){ +pos++; +tz=str.substring(pos,str.indexOf(")")); +}else{ +var pat=/([A-Z\/]+) \d{4}$/; +if((_cb5=str.match(pat))){ +tz=_cb5[1]; +}else{ +str=_cb2.toLocaleString(); +pat=/ ([A-Z\/]+)$/; +if((_cb5=str.match(pat))){ +tz=_cb5[1]; +} +} +} +return tz=="AM"||tz=="PM"?"":tz; +}; +dojo.date.getOrdinal=function(_cb8){ +var date=_cb8.getDate(); +if(date%100!=11&&date%10==1){ +return "st"; +}else{ +if(date%100!=12&&date%10==2){ +return "nd"; +}else{ +if(date%100!=13&&date%10==3){ +return "rd"; +}else{ +return "th"; +} +} +} +}; +dojo.date.compareTypes={DATE:1,TIME:2}; +dojo.date.compare=function(_cba,_cbb,_cbc){ +var dA=_cba; +var dB=_cbb||new Date(); +var now=new Date(); +with(dojo.date.compareTypes){ +var opt=_cbc||(DATE|TIME); +var d1=new Date((opt&DATE)?dA.getFullYear():now.getFullYear(),(opt&DATE)?dA.getMonth():now.getMonth(),(opt&DATE)?dA.getDate():now.getDate(),(opt&TIME)?dA.getHours():0,(opt&TIME)?dA.getMinutes():0,(opt&TIME)?dA.getSeconds():0); +var d2=new Date((opt&DATE)?dB.getFullYear():now.getFullYear(),(opt&DATE)?dB.getMonth():now.getMonth(),(opt&DATE)?dB.getDate():now.getDate(),(opt&TIME)?dB.getHours():0,(opt&TIME)?dB.getMinutes():0,(opt&TIME)?dB.getSeconds():0); +} +if(d1.valueOf()>d2.valueOf()){ +return 1; +} +if(d1.valueOf()0)?5:-5; +_cc8=(incr>0)?((incr-5)/5):((incr+5)/5); +}else{ +days=mod; +_cc8=parseInt(incr/5); +} +strt=dt.getDay(); +if(strt==6&&incr>0){ +adj=1; +}else{ +if(strt==0&&incr<0){ +adj=-1; +} +} +trgt=(strt+days); +if(trgt==0||trgt==6){ +adj=(incr>0)?2:-2; +} +sum.setDate(dat+(7*_cc8)+days+adj); +break; +case HOUR: +sum.setHours(sum.getHours()+incr); +break; +case MINUTE: +sum.setMinutes(sum.getMinutes()+incr); +break; +case SECOND: +sum.setSeconds(sum.getSeconds()+incr); +break; +case MILLISECOND: +sum.setMilliseconds(sum.getMilliseconds()+incr); +break; +default: +break; +} +} +return sum; +}; +dojo.date.diff=function(dtA,dtB,_cd0){ +if(typeof dtA=="number"){ +dtA=new Date(dtA); +} +if(typeof dtB=="number"){ +dtB=new Date(dtB); +} +var _cd1=dtB.getFullYear()-dtA.getFullYear(); +var _cd2=(dtB.getMonth()-dtA.getMonth())+(_cd1*12); +var _cd3=dtB.getTime()-dtA.getTime(); +var _cd4=_cd3/1000; +var _cd5=_cd4/60; +var _cd6=_cd5/60; +var _cd7=_cd6/24; +var _cd8=_cd7/7; +var _cd9=0; +with(dojo.date.dateParts){ +switch(_cd0){ +case YEAR: +_cd9=_cd1; +break; +case QUARTER: +var mA=dtA.getMonth(); +var mB=dtB.getMonth(); +var qA=Math.floor(mA/3)+1; +var qB=Math.floor(mB/3)+1; +qB+=(_cd1*4); +_cd9=qB-qA; +break; +case MONTH: +_cd9=_cd2; +break; +case WEEK: +_cd9=parseInt(_cd8); +break; +case DAY: +_cd9=_cd7; +break; +case WEEKDAY: +var days=Math.round(_cd7); +var _cdf=parseInt(days/7); +var mod=days%7; +if(mod==0){ +days=_cdf*5; +}else{ +var adj=0; +var aDay=dtA.getDay(); +var bDay=dtB.getDay(); +_cdf=parseInt(days/7); +mod=days%7; +var _ce4=new Date(dtA); +_ce4.setDate(_ce4.getDate()+(_cdf*7)); +var _ce5=_ce4.getDay(); +if(_cd7>0){ +switch(true){ +case aDay==6: +adj=-1; +break; +case aDay==0: +adj=0; +break; +case bDay==6: +adj=-1; +break; +case bDay==0: +adj=-2; +break; +case (_ce5+mod)>5: +adj=-2; +break; +default: +break; +} +}else{ +if(_cd7<0){ +switch(true){ +case aDay==6: +adj=0; +break; +case aDay==0: +adj=1; +break; +case bDay==6: +adj=2; +break; +case bDay==0: +adj=1; +break; +case (_ce5+mod)<0: +adj=2; +break; +default: +break; +} +} +} +days+=adj; +days-=(_cdf*2); +} +_cd9=days; +break; +case HOUR: +_cd9=_cd6; +break; +case MINUTE: +_cd9=_cd5; +break; +case SECOND: +_cd9=_cd4; +break; +case MILLISECOND: +_cd9=_cd3; +break; +default: +break; +} +} +return Math.round(_cd9); +}; +dojo.provide("dojo.date.supplemental"); +dojo.date.getFirstDayOfWeek=function(_ce6){ +var _ce7={mv:5,ae:6,af:6,bh:6,dj:6,dz:6,eg:6,er:6,et:6,iq:6,ir:6,jo:6,ke:6,kw:6,lb:6,ly:6,ma:6,om:6,qa:6,sa:6,sd:6,so:6,tn:6,ye:6,as:0,au:0,az:0,bw:0,ca:0,cn:0,fo:0,ge:0,gl:0,gu:0,hk:0,ie:0,il:0,is:0,jm:0,jp:0,kg:0,kr:0,la:0,mh:0,mo:0,mp:0,mt:0,nz:0,ph:0,pk:0,sg:0,th:0,tt:0,tw:0,um:0,us:0,uz:0,vi:0,za:0,zw:0,et:0,mw:0,ng:0,tj:0,gb:0,sy:4}; +_ce6=dojo.hostenv.normalizeLocale(_ce6); +var _ce8=_ce6.split("-")[1]; +var dow=_ce7[_ce8]; +return (typeof dow=="undefined")?1:dow; +}; +dojo.date.getWeekend=function(_cea){ +var _ceb={eg:5,il:5,sy:5,"in":0,ae:4,bh:4,dz:4,iq:4,jo:4,kw:4,lb:4,ly:4,ma:4,om:4,qa:4,sa:4,sd:4,tn:4,ye:4}; +var _cec={ae:5,bh:5,dz:5,iq:5,jo:5,kw:5,lb:5,ly:5,ma:5,om:5,qa:5,sa:5,sd:5,tn:5,ye:5,af:5,ir:5,eg:6,il:6,sy:6}; +_cea=dojo.hostenv.normalizeLocale(_cea); +var _ced=_cea.split("-")[1]; +var _cee=_ceb[_ced]; +var end=_cec[_ced]; +if(typeof _cee=="undefined"){ +_cee=6; +} +if(typeof end=="undefined"){ +end=0; +} +return {start:_cee,end:end}; +}; +dojo.date.isWeekend=function(_cf0,_cf1){ +var _cf2=dojo.date.getWeekend(_cf1); +var day=(_cf0||new Date()).getDay(); +if(_cf2.end<_cf2.start){ +_cf2.end+=7; +if(day<_cf2.start){ +day+=7; +} +} +return day>=_cf2.start&&day<=_cf2.end; +}; +dojo.provide("dojo.i18n.common"); +dojo.i18n.getLocalization=function(_cf4,_cf5,_cf6){ +dojo.hostenv.preloadLocalizations(); +_cf6=dojo.hostenv.normalizeLocale(_cf6); +var _cf7=_cf6.split("-"); +var _cf8=[_cf4,"nls",_cf5].join("."); +var _cf9=dojo.hostenv.findModule(_cf8,true); +var _cfa; +for(var i=_cf7.length;i>0;i--){ +var loc=_cf7.slice(0,i).join("_"); +if(_cf9[loc]){ +_cfa=_cf9[loc]; +break; +} +} +if(!_cfa){ +_cfa=_cf9.ROOT; +} +if(_cfa){ +var _cfd=function(){ +}; +_cfd.prototype=_cfa; +return new _cfd(); +} +dojo.raise("Bundle not found: "+_cf5+" in "+_cf4+" , locale="+_cf6); +}; +dojo.i18n.isLTR=function(_cfe){ +var lang=dojo.hostenv.normalizeLocale(_cfe).split("-")[0]; +var RTL={ar:true,fa:true,he:true,ur:true,yi:true}; +return !RTL[lang]; +}; +dojo.provide("dojo.date.format"); +(function(){ +dojo.date.format=function(_d01,_d02){ +if(typeof _d02=="string"){ +dojo.deprecated("dojo.date.format","To format dates with POSIX-style strings, please use dojo.date.strftime instead","0.5"); +return dojo.date.strftime(_d01,_d02); +} +function formatPattern(_d03,_d04){ +return _d04.replace(/([a-z])\1*/ig,function(_d05){ +var s; +var c=_d05.charAt(0); +var l=_d05.length; +var pad; +var _d0a=["abbr","wide","narrow"]; +switch(c){ +case "G": +if(l>3){ +dojo.unimplemented("Era format not implemented"); +} +s=info.eras[_d03.getFullYear()<0?1:0]; +break; +case "y": +s=_d03.getFullYear(); +switch(l){ +case 1: +break; +case 2: +s=String(s).substr(-2); +break; +default: +pad=true; +} +break; +case "Q": +case "q": +s=Math.ceil((_d03.getMonth()+1)/3); +switch(l){ +case 1: +case 2: +pad=true; +break; +case 3: +case 4: +dojo.unimplemented("Quarter format not implemented"); +} +break; +case "M": +case "L": +var m=_d03.getMonth(); +var _d0d; +switch(l){ +case 1: +case 2: +s=m+1; +pad=true; +break; +case 3: +case 4: +case 5: +_d0d=_d0a[l-3]; +break; +} +if(_d0d){ +var type=(c=="L")?"standalone":"format"; +var prop=["months",type,_d0d].join("-"); +s=info[prop][m]; +} +break; +case "w": +var _d10=0; +s=dojo.date.getWeekOfYear(_d03,_d10); +pad=true; +break; +case "d": +s=_d03.getDate(); +pad=true; +break; +case "D": +s=dojo.date.getDayOfYear(_d03); +pad=true; +break; +case "E": +case "e": +case "c": +var d=_d03.getDay(); +var _d0d; +switch(l){ +case 1: +case 2: +if(c=="e"){ +var _d12=dojo.date.getFirstDayOfWeek(_d02.locale); +d=(d-_d12+7)%7; +} +if(c!="c"){ +s=d+1; +pad=true; +break; +} +case 3: +case 4: +case 5: +_d0d=_d0a[l-3]; +break; +} +if(_d0d){ +var type=(c=="c")?"standalone":"format"; +var prop=["days",type,_d0d].join("-"); +s=info[prop][d]; +} +break; +case "a": +var _d13=(_d03.getHours()<12)?"am":"pm"; +s=info[_d13]; +break; +case "h": +case "H": +case "K": +case "k": +var h=_d03.getHours(); +switch(c){ +case "h": +s=(h%12)||12; +break; +case "H": +s=h; +break; +case "K": +s=(h%12); +break; +case "k": +s=h||24; +break; +} +pad=true; +break; +case "m": +s=_d03.getMinutes(); +pad=true; +break; +case "s": +s=_d03.getSeconds(); +pad=true; +break; +case "S": +s=Math.round(_d03.getMilliseconds()*Math.pow(10,l-3)); +break; +case "v": +case "z": +s=dojo.date.getTimezoneName(_d03); +if(s){ +break; +} +l=4; +case "Z": +var _d15=_d03.getTimezoneOffset(); +var tz=[(_d15<=0?"+":"-"),dojo.string.pad(Math.floor(Math.abs(_d15)/60),2),dojo.string.pad(Math.abs(_d15)%60,2)]; +if(l==4){ +tz.splice(0,0,"GMT"); +tz.splice(3,0,":"); +} +s=tz.join(""); +break; +case "Y": +case "u": +case "W": +case "F": +case "g": +case "A": +dojo.debug(_d05+" modifier not yet implemented"); +s="?"; +break; +default: +dojo.raise("dojo.date.format: invalid pattern char: "+_d04); +} +if(pad){ +s=dojo.string.pad(s,l); +} +return s; +}); +} +_d02=_d02||{}; +var _d17=dojo.hostenv.normalizeLocale(_d02.locale); +var _d18=_d02.formatLength||"full"; +var info=dojo.date._getGregorianBundle(_d17); +var str=[]; +var _d1a=dojo.lang.curry(this,formatPattern,_d01); +if(_d02.selector!="timeOnly"){ +var _d1b=_d02.datePattern||info["dateFormat-"+_d18]; +if(_d1b){ +str.push(_processPattern(_d1b,_d1a)); +} +} +if(_d02.selector!="dateOnly"){ +var _d1c=_d02.timePattern||info["timeFormat-"+_d18]; +if(_d1c){ +str.push(_processPattern(_d1c,_d1a)); +} +} +var _d1d=str.join(" "); +return _d1d; +}; +dojo.date.parse=function(_d1e,_d1f){ +_d1f=_d1f||{}; +var _d20=dojo.hostenv.normalizeLocale(_d1f.locale); +var info=dojo.date._getGregorianBundle(_d20); +var _d22=_d1f.formatLength||"full"; +if(!_d1f.selector){ +_d1f.selector="dateOnly"; +} +var _d23=_d1f.datePattern||info["dateFormat-"+_d22]; +var _d24=_d1f.timePattern||info["timeFormat-"+_d22]; +var _d25; +if(_d1f.selector=="dateOnly"){ +_d25=_d23; +}else{ +if(_d1f.selector=="timeOnly"){ +_d25=_d24; +}else{ +if(_d1f.selector=="dateTime"){ +_d25=_d23+" "+_d24; +}else{ +var msg="dojo.date.parse: Unknown selector param passed: '"+_d1f.selector+"'."; +msg+=" Defaulting to date pattern."; +dojo.debug(msg); +_d25=_d23; +} +} +} +var _d27=[]; +var _d28=_processPattern(_d25,dojo.lang.curry(this,_buildDateTimeRE,_d27,info,_d1f)); +var _d29=new RegExp("^"+_d28+"$"); +var _d2a=_d29.exec(_d1e); +if(!_d2a){ +return null; +} +var _d2b=["abbr","wide","narrow"]; +var _d2c=new Date(1972,0); +var _d2d={}; +for(var i=1;i<_d2a.length;i++){ +var grp=_d27[i-1]; +var l=grp.length; +var v=_d2a[i]; +switch(grp.charAt(0)){ +case "y": +if(l!=2){ +_d2c.setFullYear(v); +_d2d.year=v; +}else{ +if(v<100){ +v=Number(v); +var year=""+new Date().getFullYear(); +var _d33=year.substring(0,2)*100; +var _d34=Number(year.substring(2,4)); +var _d35=Math.min(_d34+20,99); +var num=(v<_d35)?_d33+v:_d33-100+v; +_d2c.setFullYear(num); +_d2d.year=num; +}else{ +if(_d1f.strict){ +return null; +} +_d2c.setFullYear(v); +_d2d.year=v; +} +} +break; +case "M": +if(l>2){ +if(!_d1f.strict){ +v=v.replace(/\./g,""); +v=v.toLowerCase(); +} +var _d37=info["months-format-"+_d2b[l-3]].concat(); +for(var j=0;j<_d37.length;j++){ +if(!_d1f.strict){ +_d37[j]=_d37[j].toLowerCase(); +} +if(v==_d37[j]){ +_d2c.setMonth(j); +_d2d.month=j; +break; +} +} +if(j==_d37.length){ +dojo.debug("dojo.date.parse: Could not parse month name: '"+v+"'."); +return null; +} +}else{ +_d2c.setMonth(v-1); +_d2d.month=v-1; +} +break; +case "E": +case "e": +if(!_d1f.strict){ +v=v.toLowerCase(); +} +var days=info["days-format-"+_d2b[l-3]].concat(); +for(var j=0;j23){ +dojo.debug("dojo.date.parse: Illegal hours value"); +return null; +} +_d2c.setHours(v); +break; +case "m": +_d2c.setMinutes(v); +break; +case "s": +_d2c.setSeconds(v); +break; +case "S": +_d2c.setMilliseconds(v); +break; +default: +dojo.unimplemented("dojo.date.parse: unsupported pattern char="+grp.charAt(0)); +} +} +if(_d2d.year&&_d2c.getFullYear()!=_d2d.year){ +dojo.debug("Parsed year: '"+_d2c.getFullYear()+"' did not match input year: '"+_d2d.year+"'."); +return null; +} +if(_d2d.month&&_d2c.getMonth()!=_d2d.month){ +dojo.debug("Parsed month: '"+_d2c.getMonth()+"' did not match input month: '"+_d2d.month+"'."); +return null; +} +if(_d2d.date&&_d2c.getDate()!=_d2d.date){ +dojo.debug("Parsed day of month: '"+_d2c.getDate()+"' did not match input day of month: '"+_d2d.date+"'."); +return null; +} +return _d2c; +}; +function _processPattern(_d3d,_d3e,_d3f,_d40){ +var _d41=function(x){ +return x; +}; +_d3e=_d3e||_d41; +_d3f=_d3f||_d41; +_d40=_d40||_d41; +var _d43=_d3d.match(/(''|[^'])+/g); +var _d44=false; +for(var i=0;i<_d43.length;i++){ +if(!_d43[i]){ +_d43[i]=""; +}else{ +_d43[i]=(_d44?_d3f:_d3e)(_d43[i]); +_d44=!_d44; +} +} +return _d40(_d43.join("")); +} +function _buildDateTimeRE(_d46,info,_d48,_d49){ +return _d49.replace(/([a-z])\1*/ig,function(_d4a){ +var s; +var c=_d4a.charAt(0); +var l=_d4a.length; +switch(c){ +case "y": +s="\\d"+((l==2)?"{2,4}":"+"); +break; +case "M": +s=(l>2)?"\\S+":"\\d{1,2}"; +break; +case "d": +s="\\d{1,2}"; +break; +case "E": +s="\\S+"; +break; +case "h": +case "H": +case "K": +case "k": +s="\\d{1,2}"; +break; +case "m": +case "s": +s="[0-5]\\d"; +break; +case "S": +s="\\d{1,3}"; +break; +case "a": +var am=_d48.am||info.am||"AM"; +var pm=_d48.pm||info.pm||"PM"; +if(_d48.strict){ +s=am+"|"+pm; +}else{ +s=am; +s+=(am!=am.toLowerCase())?"|"+am.toLowerCase():""; +s+="|"; +s+=(pm!=pm.toLowerCase())?pm+"|"+pm.toLowerCase():pm; +} +break; +default: +dojo.unimplemented("parse of date format, pattern="+_d49); +} +if(_d46){ +_d46.push(_d4a); +} +return "\\s*("+s+")\\s*"; +}); +} +})(); +dojo.date.strftime=function(_d50,_d51,_d52){ +var _d53=null; +function _(s,n){ +return dojo.string.pad(s,n||2,_d53||"0"); +} +var info=dojo.date._getGregorianBundle(_d52); +function $(_d57){ +switch(_d57){ +case "a": +return dojo.date.getDayShortName(_d50,_d52); +case "A": +return dojo.date.getDayName(_d50,_d52); +case "b": +case "h": +return dojo.date.getMonthShortName(_d50,_d52); +case "B": +return dojo.date.getMonthName(_d50,_d52); +case "c": +return dojo.date.format(_d50,{locale:_d52}); +case "C": +return _(Math.floor(_d50.getFullYear()/100)); +case "d": +return _(_d50.getDate()); +case "D": +return $("m")+"/"+$("d")+"/"+$("y"); +case "e": +if(_d53==null){ +_d53=" "; +} +return _(_d50.getDate()); +case "f": +if(_d53==null){ +_d53=" "; +} +return _(_d50.getMonth()+1); +case "g": +break; +case "G": +dojo.unimplemented("unimplemented modifier 'G'"); +break; +case "F": +return $("Y")+"-"+$("m")+"-"+$("d"); +case "H": +return _(_d50.getHours()); +case "I": +return _(_d50.getHours()%12||12); +case "j": +return _(dojo.date.getDayOfYear(_d50),3); +case "k": +if(_d53==null){ +_d53=" "; +} +return _(_d50.getHours()); +case "l": +if(_d53==null){ +_d53=" "; +} +return _(_d50.getHours()%12||12); +case "m": +return _(_d50.getMonth()+1); +case "M": +return _(_d50.getMinutes()); +case "n": +return "\n"; +case "p": +return info[_d50.getHours()<12?"am":"pm"]; +case "r": +return $("I")+":"+$("M")+":"+$("S")+" "+$("p"); +case "R": +return $("H")+":"+$("M"); +case "S": +return _(_d50.getSeconds()); +case "t": +return "\t"; +case "T": +return $("H")+":"+$("M")+":"+$("S"); +case "u": +return String(_d50.getDay()||7); +case "U": +return _(dojo.date.getWeekOfYear(_d50)); +case "V": +return _(dojo.date.getIsoWeekOfYear(_d50)); +case "W": +return _(dojo.date.getWeekOfYear(_d50,1)); +case "w": +return String(_d50.getDay()); +case "x": +return dojo.date.format(_d50,{selector:"dateOnly",locale:_d52}); +case "X": +return dojo.date.format(_d50,{selector:"timeOnly",locale:_d52}); +case "y": +return _(_d50.getFullYear()%100); +case "Y": +return String(_d50.getFullYear()); +case "z": +var _d58=_d50.getTimezoneOffset(); +return (_d58>0?"-":"+")+_(Math.floor(Math.abs(_d58)/60))+":"+_(Math.abs(_d58)%60); +case "Z": +return dojo.date.getTimezoneName(_d50); +case "%": +return "%"; +} +} +var _d59=""; +var i=0; +var _d5b=0; +var _d5c=null; +while((_d5b=_d51.indexOf("%",i))!=-1){ +_d59+=_d51.substring(i,_d5b++); +switch(_d51.charAt(_d5b++)){ +case "_": +_d53=" "; +break; +case "-": +_d53=""; +break; +case "0": +_d53="0"; +break; +case "^": +_d5c="upper"; +break; +case "*": +_d5c="lower"; +break; +case "#": +_d5c="swap"; +break; +default: +_d53=null; +_d5b--; +break; +} +var _d5d=$(_d51.charAt(_d5b++)); +switch(_d5c){ +case "upper": +_d5d=_d5d.toUpperCase(); +break; +case "lower": +_d5d=_d5d.toLowerCase(); +break; +case "swap": +var _d5e=_d5d.toLowerCase(); +var _d5f=""; +var j=0; +var ch=""; +while(j<_d5d.length){ +ch=_d5d.charAt(j); +_d5f+=(ch==_d5e.charAt(j))?ch.toUpperCase():ch.toLowerCase(); +j++; +} +_d5d=_d5f; +break; +default: +break; +} +_d5c=null; +_d59+=_d5d; +i=_d5b; +} +_d59+=_d51.substring(i); +return _d59; +}; +(function(){ +var _d62=[]; +dojo.date.addCustomFormats=function(_d63,_d64){ +_d62.push({pkg:_d63,name:_d64}); +}; +dojo.date._getGregorianBundle=function(_d65){ +var _d66={}; +dojo.lang.forEach(_d62,function(desc){ +var _d68=dojo.i18n.getLocalization(desc.pkg,desc.name,_d65); +_d66=dojo.lang.mixin(_d66,_d68); +},this); +return _d66; +}; +})(); +dojo.date.addCustomFormats("dojo.i18n.calendar","gregorian"); +dojo.date.addCustomFormats("dojo.i18n.calendar","gregorianExtras"); +dojo.date.getNames=function(item,type,use,_d6c){ +var _d6d; +var _d6e=dojo.date._getGregorianBundle(_d6c); +var _d6f=[item,use,type]; +if(use=="standAlone"){ +_d6d=_d6e[_d6f.join("-")]; +} +_d6f[1]="format"; +return (_d6d||_d6e[_d6f.join("-")]).concat(); +}; +dojo.date.getDayName=function(_d70,_d71){ +return dojo.date.getNames("days","wide","format",_d71)[_d70.getDay()]; +}; +dojo.date.getDayShortName=function(_d72,_d73){ +return dojo.date.getNames("days","abbr","format",_d73)[_d72.getDay()]; +}; +dojo.date.getMonthName=function(_d74,_d75){ +return dojo.date.getNames("months","wide","format",_d75)[_d74.getMonth()]; +}; +dojo.date.getMonthShortName=function(_d76,_d77){ +return dojo.date.getNames("months","abbr","format",_d77)[_d76.getMonth()]; +}; +dojo.date.toRelativeString=function(_d78){ +var now=new Date(); +var diff=(now-_d78)/1000; +var end=" ago"; +var _d7c=false; +if(diff<0){ +_d7c=true; +end=" from now"; +diff=-diff; +} +if(diff<60){ +diff=Math.round(diff); +return diff+" second"+(diff==1?"":"s")+end; +} +if(diff<60*60){ +diff=Math.round(diff/60); +return diff+" minute"+(diff==1?"":"s")+end; +} +if(diff<60*60*24){ +diff=Math.round(diff/3600); +return diff+" hour"+(diff==1?"":"s")+end; +} +if(diff<60*60*24*7){ +diff=Math.round(diff/(3600*24)); +if(diff==1){ +return _d7c?"Tomorrow":"Yesterday"; +}else{ +return diff+" days"+end; +} +} +return dojo.date.format(_d78); +}; +dojo.date.toSql=function(_d7d,_d7e){ +return dojo.date.strftime(_d7d,"%F"+!_d7e?" %T":""); +}; +dojo.date.fromSql=function(_d7f){ +var _d80=_d7f.split(/[\- :]/g); +while(_d80.length<6){ +_d80.push(0); +} +return new Date(_d80[0],(parseInt(_d80[1],10)-1),_d80[2],_d80[3],_d80[4],_d80[5]); +}; +dojo.provide("dojo.widget.TimePicker"); +dojo.widget.defineWidget("dojo.widget.TimePicker",dojo.widget.HtmlWidget,function(){ +this.time=""; +this.useDefaultTime=false; +this.useDefaultMinutes=false; +this.storedTime=""; +this.currentTime={}; +this.classNames={selectedTime:"selectedItem"}; +this.any="any"; +this.selectedTime={hour:"",minute:"",amPm:"",anyTime:false}; +this.hourIndexMap=["",2,4,6,8,10,1,3,5,7,9,11,0]; +this.minuteIndexMap=[0,2,4,6,8,10,1,3,5,7,9,11]; +},{isContainer:false,templatePath:dojo.uri.moduleUri("dojo.widget","templates/TimePicker.html"),templateCssPath:dojo.uri.moduleUri("dojo.widget","templates/TimePicker.css"),postMixInProperties:function(_d81,frag){ +dojo.widget.TimePicker.superclass.postMixInProperties.apply(this,arguments); +this.calendar=dojo.i18n.getLocalization("dojo.i18n.calendar","gregorian",this.lang); +this.widgetStrings=dojo.i18n.getLocalization("dojo.widget","TimePicker",this.lang); +},fillInTemplate:function(args,frag){ +var _d85=this.getFragNodeRef(frag); +dojo.html.copyStyle(this.domNode,_d85); +if(args.value){ +if(args.value instanceof Date){ +this.storedTime=dojo.date.toRfc3339(args.value); +}else{ +this.storedTime=args.value; +} +} +this.initData(); +this.initUI(); +},initData:function(){ +if(this.storedTime.indexOf("T")!=-1&&this.storedTime.split("T")[1]&&this.storedTime!=" "&&this.storedTime.split("T")[1]!="any"){ +this.time=dojo.widget.TimePicker.util.fromRfcDateTime(this.storedTime,this.useDefaultMinutes,this.selectedTime.anyTime); +}else{ +if(this.useDefaultTime){ +this.time=dojo.widget.TimePicker.util.fromRfcDateTime("",this.useDefaultMinutes,this.selectedTime.anyTime); +}else{ +this.selectedTime.anyTime=true; +this.time=dojo.widget.TimePicker.util.fromRfcDateTime("",0,1); +} +} +},initUI:function(){ +if(!this.selectedTime.anyTime&&this.time){ +var _d86=dojo.widget.TimePicker.util.toAmPmHour(this.time.getHours()); +var hour=_d86[0]; +var isAm=_d86[1]; +var _d89=this.time.getMinutes(); +var _d8a=parseInt(_d89/5); +this.onSetSelectedHour(this.hourIndexMap[hour]); +this.onSetSelectedMinute(this.minuteIndexMap[_d8a]); +this.onSetSelectedAmPm(isAm); +}else{ +this.onSetSelectedAnyTime(); +} +},setTime:function(date){ +if(date){ +this.selectedTime.anyTime=false; +this.setDateTime(dojo.date.toRfc3339(date)); +}else{ +this.selectedTime.anyTime=true; +} +this.initData(); +this.initUI(); +},setDateTime:function(_d8c){ +this.storedTime=_d8c; +},onClearSelectedHour:function(evt){ +this.clearSelectedHour(); +},onClearSelectedMinute:function(evt){ +this.clearSelectedMinute(); +},onClearSelectedAmPm:function(evt){ +this.clearSelectedAmPm(); +},onClearSelectedAnyTime:function(evt){ +this.clearSelectedAnyTime(); +if(this.selectedTime.anyTime){ +this.selectedTime.anyTime=false; +this.time=dojo.widget.TimePicker.util.fromRfcDateTime("",this.useDefaultMinutes); +this.initUI(); +} +},clearSelectedHour:function(){ +var _d91=this.hourContainerNode.getElementsByTagName("td"); +for(var i=0;i<_d91.length;i++){ +dojo.html.setClass(_d91.item(i),""); +} +},clearSelectedMinute:function(){ +var _d93=this.minuteContainerNode.getElementsByTagName("td"); +for(var i=0;i<_d93.length;i++){ +dojo.html.setClass(_d93.item(i),""); +} +},clearSelectedAmPm:function(){ +var _d95=this.amPmContainerNode.getElementsByTagName("td"); +for(var i=0;i<_d95.length;i++){ +dojo.html.setClass(_d95.item(i),""); +} +},clearSelectedAnyTime:function(){ +dojo.html.setClass(this.anyTimeContainerNode,"anyTimeContainer"); +},onSetSelectedHour:function(evt){ +this.onClearSelectedAnyTime(); +this.onClearSelectedHour(); +this.setSelectedHour(evt); +this.onSetTime(); +},setSelectedHour:function(evt){ +if(evt&&evt.target){ +if(evt.target.nodeType==dojo.dom.ELEMENT_NODE){ +var _d99=evt.target; +}else{ +var _d99=evt.target.parentNode; +} +dojo.event.browser.stopEvent(evt); +dojo.html.setClass(_d99,this.classNames.selectedTime); +this.selectedTime["hour"]=_d99.innerHTML; +}else{ +if(!isNaN(evt)){ +var _d9a=this.hourContainerNode.getElementsByTagName("td"); +if(_d9a.item(evt)){ +dojo.html.setClass(_d9a.item(evt),this.classNames.selectedTime); +this.selectedTime["hour"]=_d9a.item(evt).innerHTML; +} +} +} +this.selectedTime.anyTime=false; +},onSetSelectedMinute:function(evt){ +this.onClearSelectedAnyTime(); +this.onClearSelectedMinute(); +this.setSelectedMinute(evt); +this.selectedTime.anyTime=false; +this.onSetTime(); +},setSelectedMinute:function(evt){ +if(evt&&evt.target){ +if(evt.target.nodeType==dojo.dom.ELEMENT_NODE){ +var _d9d=evt.target; +}else{ +var _d9d=evt.target.parentNode; +} +dojo.event.browser.stopEvent(evt); +dojo.html.setClass(_d9d,this.classNames.selectedTime); +this.selectedTime["minute"]=_d9d.innerHTML; +}else{ +if(!isNaN(evt)){ +var _d9e=this.minuteContainerNode.getElementsByTagName("td"); +if(_d9e.item(evt)){ +dojo.html.setClass(_d9e.item(evt),this.classNames.selectedTime); +this.selectedTime["minute"]=_d9e.item(evt).innerHTML; +} +} +} +},onSetSelectedAmPm:function(evt){ +this.onClearSelectedAnyTime(); +this.onClearSelectedAmPm(); +this.setSelectedAmPm(evt); +this.selectedTime.anyTime=false; +this.onSetTime(); +},setSelectedAmPm:function(evt){ +var _da1=evt.target; +if(evt&&_da1){ +if(_da1.nodeType!=dojo.dom.ELEMENT_NODE){ +_da1=_da1.parentNode; +} +dojo.event.browser.stopEvent(evt); +this.selectedTime.amPm=_da1.id; +dojo.html.setClass(_da1,this.classNames.selectedTime); +}else{ +evt=evt?0:1; +var _da2=this.amPmContainerNode.getElementsByTagName("td"); +if(_da2.item(evt)){ +this.selectedTime.amPm=_da2.item(evt).id; +dojo.html.setClass(_da2.item(evt),this.classNames.selectedTime); +} +} +},onSetSelectedAnyTime:function(evt){ +this.onClearSelectedHour(); +this.onClearSelectedMinute(); +this.onClearSelectedAmPm(); +this.setSelectedAnyTime(); +this.onSetTime(); +},setSelectedAnyTime:function(evt){ +this.selectedTime.anyTime=true; +dojo.html.setClass(this.anyTimeContainerNode,this.classNames.selectedTime+" "+"anyTimeContainer"); +},onClick:function(evt){ +dojo.event.browser.stopEvent(evt); +},onSetTime:function(){ +if(this.selectedTime.anyTime){ +this.time=new Date(); +var _da6=dojo.widget.TimePicker.util.toRfcDateTime(this.time); +this.setDateTime(_da6.split("T")[0]); +}else{ +var hour=12; +var _da8=0; +var isAm=false; +if(this.selectedTime["hour"]){ +hour=parseInt(this.selectedTime["hour"],10); +} +if(this.selectedTime["minute"]){ +_da8=parseInt(this.selectedTime["minute"],10); +} +if(this.selectedTime["amPm"]){ +isAm=(this.selectedTime["amPm"].toLowerCase()=="am"); +} +this.time=new Date(); +this.time.setHours(dojo.widget.TimePicker.util.fromAmPmHour(hour,isAm)); +this.time.setMinutes(_da8); +this.setDateTime(dojo.widget.TimePicker.util.toRfcDateTime(this.time)); +} +this.onValueChanged(this.time); +},onValueChanged:function(date){ +}}); +dojo.widget.TimePicker.util=new function(){ +this.toRfcDateTime=function(_dab){ +if(!_dab){ +_dab=new Date(); +} +_dab.setSeconds(0); +return dojo.date.strftime(_dab,"%Y-%m-%dT%H:%M:00%z"); +}; +this.fromRfcDateTime=function(_dac,_dad,_dae){ +var _daf=new Date(); +if(!_dac||_dac.indexOf("T")==-1){ +if(_dad){ +_daf.setMinutes(Math.floor(_daf.getMinutes()/5)*5); +}else{ +_daf.setMinutes(0); +} +}else{ +var _db0=_dac.split("T")[1].split(":"); +var _daf=new Date(); +_daf.setHours(_db0[0]); +_daf.setMinutes(_db0[1]); +} +return _daf; +}; +this.toAmPmHour=function(hour){ +var _db2=hour; +var isAm=true; +if(_db2==0){ +_db2=12; +}else{ +if(_db2>12){ +_db2=_db2-12; +isAm=false; +}else{ +if(_db2==12){ +isAm=false; +} +} +} +return [_db2,isAm]; +}; +this.fromAmPmHour=function(_db4,isAm){ +var hour=parseInt(_db4,10); +if(isAm&&hour==12){ +hour=0; +}else{ +if(!isAm&&hour<12){ +hour=hour+12; +} +} +return hour; +}; +}; +dojo.provide("dojo.widget.DropdownTimePicker"); +dojo.widget.defineWidget("dojo.widget.DropdownTimePicker",dojo.widget.DropdownContainer,{iconURL:dojo.uri.moduleUri("dojo.widget","templates/images/timeIcon.gif"),formatLength:"short",displayFormat:"",timeFormat:"",saveFormat:"",value:"",name:"",postMixInProperties:function(){ +dojo.widget.DropdownTimePicker.superclass.postMixInProperties.apply(this,arguments); +var _db7=dojo.i18n.getLocalization("dojo.widget","DropdownTimePicker",this.lang); +this.iconAlt=_db7.selectTime; +if(typeof (this.value)=="string"&&this.value.toLowerCase()=="today"){ +this.value=new Date(); +} +if(this.value&&isNaN(this.value)){ +var orig=this.value; +this.value=dojo.date.fromRfc3339(this.value); +if(!this.value){ +var d=dojo.date.format(new Date(),{selector:"dateOnly",datePattern:"yyyy-MM-dd"}); +var c=orig.split(":"); +for(var i=0;i2)){ +this.value=dojo.date.fromRfc3339(this.value); +this.value.setHours(0,0,0,0); +} +} +},fillInTemplate:function(args,frag){ +dojo.widget.DatePicker.superclass.fillInTemplate.apply(this,arguments); +var _dd1=this.getFragNodeRef(frag); +dojo.html.copyStyle(this.domNode,_dd1); +this.weekTemplate=dojo.dom.removeNode(this.calendarWeekTemplate); +this._preInitUI(this.value?this.value:this.today,false,true); +var _dd2=dojo.lang.unnest(dojo.date.getNames("days",this.dayWidth,"standAlone",this.lang)); +if(this.weekStartsOn>0){ +for(var i=0;ithis.endDate){ +_dd7=new Date((_dd7days){ +this._preInitUI(this.startDate,true,false); +_dda=new Date(this.firstDay); +} +this.curMonth=new Date(_dda); +this.curMonth.setDate(_dda.getDate()+6); +this.curMonth.setDate(1); +var _ddd=(_dda.getMonth()==this.curMonth.getMonth())?"current":"previous"; +} +if(_dd9){ +this._initUI(days); +} +},_initUI:function(days){ +dojo.dom.removeChildren(this.calendarDatesContainerNode); +for(var i=0;ithis.endDate){ +_dea=_dec=_dee=false; +} +if(_deb&&add(d,DAY,-1)this.endDate){ +_dec=_dee=false; +} +if(_ded&&add(d2,YEAR,-1)this.endDate){ +_dee=false; +} +} +function enableControl(node,_df1){ +dojo.html.setVisibility(node,_df1?"":"hidden"); +} +enableControl(this.decreaseWeekNode,_de9); +enableControl(this.increaseWeekNode,_dea); +enableControl(this.decreaseMonthNode,_deb); +enableControl(this.increaseMonthNode,_dec); +enableControl(this.previousYearLabelNode,_ded); +enableControl(this.nextYearLabelNode,_dee); +},_incrementWeek:function(evt){ +var d=new Date(this.firstDay); +switch(evt.target){ +case this.increaseWeekNode.getElementsByTagName("img").item(0): +case this.increaseWeekNode: +var _df4=dojo.date.add(d,dojo.date.dateParts.WEEK,1); +if(_df4=this.startDate){ +d=dojo.date.add(d,dojo.date.dateParts.WEEK,-1); +} +break; +} +this._preInitUI(d,true,true); +},_incrementMonth:function(evt){ +var d=new Date(this.curMonth); +var _df7=new Date(this.firstDay); +switch(evt.currentTarget){ +case this.increaseMonthNode.getElementsByTagName("img").item(0): +case this.increaseMonthNode: +_df7=dojo.date.add(_df7,dojo.date.dateParts.DAY,this.displayWeeks*7); +if(_df7this.startDate){ +d=dojo.date.add(d,dojo.date.dateParts.MONTH,-1); +}else{ +var _df9=true; +} +break; +} +if(_df9){ +d=new Date(this.startDate); +}else{ +if(_df8){ +d=new Date(this.endDate); +} +} +this._preInitUI(d,false,true); +},_incrementYear:function(evt){ +var year=this.curMonth.getFullYear(); +var _dfc=new Date(this.firstDay); +switch(evt.target){ +case this.nextYearLabelNode: +_dfc=dojo.date.add(_dfc,dojo.date.dateParts.YEAR,1); +if(_dfcthis.startDate){ +year--; +}else{ +var _dfe=true; +} +break; +} +var d; +if(_dfe){ +d=new Date(this.startDate); +}else{ +if(_dfd){ +d=new Date(this.endDate); +}else{ +d=new Date(year,this.curMonth.getMonth(),1); +} +} +this._preInitUI(d,false,true); +},onIncrementWeek:function(evt){ +evt.stopPropagation(); +if(!this.staticDisplay){ +this._incrementWeek(evt); +} +},onIncrementMonth:function(evt){ +evt.stopPropagation(); +if(!this.staticDisplay){ +this._incrementMonth(evt); +} +},onIncrementYear:function(evt){ +evt.stopPropagation(); +if(!this.staticDisplay){ +this._incrementYear(evt); +} +},_setMonthLabel:function(_e03){ +this.monthLabelNode.innerHTML=dojo.date.getNames("months","wide","standAlone",this.lang)[_e03]; +},_setYearLabels:function(year){ +var y=year-1; +var that=this; +function f(n){ +that[n+"YearLabelNode"].innerHTML=dojo.date.format(new Date(y++,0),{formatLength:"yearOnly",locale:that.lang}); +} +f("previous"); +f("current"); +f("next"); +},_getDateClassName:function(date,_e09){ +var _e0a=this.classNames[_e09]; +if((!this.selectedIsUsed&&this.value)&&(Number(date)==Number(this.value))){ +_e0a=this.classNames.selectedDate+" "+_e0a; +this.selectedIsUsed=true; +} +if((!this.currentIsUsed)&&(Number(date)==Number(this.today))){ +_e0a=_e0a+" "+this.classNames.currentDate; +this.currentIsUsed=true; +} +return _e0a; +},onClick:function(evt){ +dojo.event.browser.stopEvent(evt); +},_handleUiClick:function(evt){ +var _e0d=evt.target; +if(_e0d.nodeType!=dojo.dom.ELEMENT_NODE){ +_e0d=_e0d.parentNode; +} +dojo.event.browser.stopEvent(evt); +this.selectedIsUsed=this.todayIsUsed=false; +if(dojo.html.hasClass(_e0d,this.classNames["disabledPrevious"])||dojo.html.hasClass(_e0d,this.classNames["disabledCurrent"])||dojo.html.hasClass(_e0d,this.classNames["disabledNext"])){ +return; +} +this.clickedNode=_e0d; +this.setDate(new Date(Number(dojo.html.getAttribute(_e0d,"djDateValue")))); +},onValueChanged:function(date){ +},_isDisabledDate:function(_e0f){ +if(_e0fthis.endDate){ +return true; +} +return this.isDisabledDate(_e0f,this.lang); +},isDisabledDate:function(_e10,_e11){ +return false; +},_initFirstDay:function(_e12,adj){ +var d=new Date(_e12); +if(!adj){ +d.setDate(1); +} +d.setDate(d.getDate()-this._getAdjustedDay(d,this.weekStartsOn)); +d.setHours(0,0,0,0); +return d; +},_getAdjustedDay:function(_e15){ +var days=[0,1,2,3,4,5,6]; +if(this.weekStartsOn>0){ +for(var i=0;ithis.datePicker.endDate){ +this.inputNode.value=""; +} +this._syncValueNode(); +this.onValueChanged(this.getDate()); +this.hideContainer(); +},onValueChanged:function(_e21){ +},onInputChange:function(){ +var _e22=dojo.string.trim(this.inputNode.value); +if(_e22){ +var _e23=dojo.date.parse(_e22,{formatLength:this.formatLength,datePattern:this.displayFormat,selector:"dateOnly",locale:this.lang}); +if(!this.datePicker._isDisabledDate(_e23)){ +this.setDate(_e23); +} +}else{ +if(_e22==""){ +this.datePicker.setDate(""); +} +this.valueNode.value=_e22; +} +if(_e22){ +this._updateText(); +} +},_syncValueNode:function(){ +var date=this.datePicker.value; +var _e25=""; +switch(this.saveFormat.toLowerCase()){ +case "rfc": +case "iso": +case "": +_e25=dojo.date.toRfc3339(date,"dateOnly"); +break; +case "posix": +case "unix": +_e25=Number(date); +break; +default: +if(date){ +_e25=dojo.date.format(date,{datePattern:this.saveFormat,selector:"dateOnly",locale:this.lang}); +} +} +this.valueNode.value=_e25; +},destroy:function(_e26){ +this.datePicker.destroy(_e26); +dojo.widget.DropdownDatePicker.superclass.destroy.apply(this,arguments); +}}); +dojo.provide("struts.widget.StrutsDatePicker"); +dojo.widget.defineWidget("struts.widget.StrutsDatePicker",dojo.widget.DropdownDatePicker,{widgetType:"StrutsDatePicker",postCreate:function(){ +struts.widget.StrutsDatePicker.superclass.postCreate.apply(this,arguments); +if(this.extraArgs["class"]){ +dojo.html.setClass(this.inputNode,this.extraArgs["class"]); +} +if(this.extraArgs.style){ +dojo.html.setStyleText(this.inputNode,this.extraArgs.style); +} +},}); +dojo.kwCompoundRequire({common:["struts.widget.Bind","struts.widget.BindDiv","struts.widget.BindAnchor","struts.widget.ComboBox","struts.widget.StrutsTimePicker","struts.widget.StrutsDatePicker"]}); +dojo.provide("struts.widget.*"); + diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/struts_dojo.js.uncompressed.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/struts_dojo.js.uncompressed.js new file mode 100644 index 000000000..0c4437a7b --- /dev/null +++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/struts_dojo.js.uncompressed.js @@ -0,0 +1,27562 @@ +/* + 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 +*/ + +if(typeof dojo == "undefined"){ + +// TODOC: HOW TO DOC THE BELOW? +// @global: djConfig +// summary: +// Application code can set the global 'djConfig' prior to loading +// the library to override certain global settings for how dojo works. +// description: The variables that can be set are as follows: +// - isDebug: false +// - allowQueryConfig: false +// - baseScriptUri: "" +// - baseRelativePath: "" +// - libraryScriptUri: "" +// - iePreventClobber: false +// - ieClobberMinimal: true +// - locale: undefined +// - extraLocale: undefined +// - preventBackButtonFix: true +// - searchIds: [] +// - parseWidgets: true +// TODOC: HOW TO DOC THESE VARIABLES? +// TODOC: IS THIS A COMPLETE LIST? +// note: +// 'djConfig' does not exist under 'dojo.*' so that it can be set before the +// 'dojo' variable exists. +// note: +// Setting any of these variables *after* the library has loaded does nothing at all. +// TODOC: is this still true? Release notes for 0.3 indicated they could be set after load. +// + + +//TODOC: HOW TO DOC THIS? +// @global: dj_global +// summary: +// an alias for the top-level global object in the host environment +// (e.g., the window object in a browser). +// description: +// Refer to 'dj_global' rather than referring to window to ensure your +// code runs correctly in contexts other than web browsers (eg: Rhino on a server). +var dj_global = this; + +//TODOC: HOW TO DOC THIS? +// @global: dj_currentContext +// summary: +// Private global context object. Where 'dj_global' always refers to the boot-time +// global context, 'dj_currentContext' can be modified for temporary context shifting. +// dojo.global() returns dj_currentContext. +// description: +// Refer to dojo.global() rather than referring to dj_global to ensure your +// code runs correctly in managed contexts. +var dj_currentContext = this; + + +// **************************************************************** +// global public utils +// TODOC: DO WE WANT TO NOTE THAT THESE ARE GLOBAL PUBLIC UTILS? +// **************************************************************** + +function dj_undef(/*String*/ name, /*Object?*/ object){ + //summary: Returns true if 'name' is defined on 'object' (or globally if 'object' is null). + //description: Note that 'defined' and 'exists' are not the same concept. + return (typeof (object || dj_currentContext)[name] == "undefined"); // Boolean +} + +// make sure djConfig is defined +if(dj_undef("djConfig", this)){ + var djConfig = {}; +} + +//TODOC: HOW TO DOC THIS? +// dojo is the root variable of (almost all) our public symbols -- make sure it is defined. +if(dj_undef("dojo", this)){ + var dojo = {}; +} + +dojo.global = function(){ + // summary: + // return the current global context object + // (e.g., the window object in a browser). + // description: + // Refer to 'dojo.global()' rather than referring to window to ensure your + // code runs correctly in contexts other than web browsers (eg: Rhino on a server). + return dj_currentContext; +} + +// Override locale setting, if specified +dojo.locale = djConfig.locale; + +//TODOC: HOW TO DOC THIS? +dojo.version = { + // summary: version number of this instance of dojo. + 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 + ")"; // String + } + } +} + +dojo.evalProp = function(/*String*/ name, /*Object*/ object, /*Boolean?*/ create){ + // summary: Returns 'object[name]'. If not defined and 'create' is true, will return a new Object. + // description: + // Returns null if 'object[name]' is not defined and 'create' is not true. + // Note: 'defined' and 'exists' are not the same concept. + if((!object)||(!name)) return undefined; // undefined + if(!dj_undef(name, object)) return object[name]; // mixed + return (create ? (object[name]={}) : undefined); // mixed +} + +dojo.parseObjPath = function(/*String*/ path, /*Object?*/ context, /*Boolean?*/ create){ + // summary: Parse string path to an object, and return corresponding object reference and property name. + // description: + // Returns an object with two properties, 'obj' and 'prop'. + // 'obj[prop]' is the reference indicated by 'path'. + // path: Path to an object, in the form "A.B.C". + // context: Object to use as root of path. Defaults to 'dojo.global()'. + // create: If true, Objects will be created at any point along the 'path' that is undefined. + var object = (context || dojo.global()); + var names = path.split('.'); + var prop = names.pop(); + for (var i=0,l=names.length;i 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){ + 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") + var dh = dojo.hostenv; + if(arguments.length == 1){ + dh.unloadListeners.push(obj); + } 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.debug("files still in flight!"); + return; + } + dojo.hostenv.callLoaded(); + } +} + +dojo.hostenv.callLoaded = function(){ + //The "object" check is for IE, and the other opera check fixes an issue + //in Opera where it could not find the body element in some widget test cases. + //For 0.9, maybe route all browsers through the setTimeout (need protection + //still for non-browser environments though). This might also help the issue with + //FF 2.0 and freezing issues where we try to do sync xhr while background css images + //are being loaded (trac #2572)? Consider for 0.9. + if(typeof setTimeout == "object" || (djConfig["useXDomain"] && dojo.render.html.opera)){ + setTimeout("dojo.hostenv.loaded();", 0); + }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 + var syms = modulename.split("."); + 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) for top-level modules + syms[0] = "../" + syms[0]; + }else{ + var parentModulePath = this.getModulePrefix(parentModule); + if(parentModulePath != parentModule){ + syms.splice(0, i, parentModulePath); + break; + } + } + } + return syms; // Array +} + +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; } + omitModuleCheck = this._global_omit_module_check || omitModuleCheck; + var module = this.findModule(moduleName, false); + if(module){ + return module; + } + + // protect against infinite recursion from mutual dependencies + 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 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 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){ + syms.pop(); + syms.push(this.pkgFileName); + relpath = syms.join("/") + '.js'; + if(startedRelative && relpath.charAt(0)=="/"){ + relpath = relpath.slice(1); + } + ok = this.loadPath(relpath, !omitModuleCheck ? moduleName : null); + if(ok){ break; } + syms.pop(); + } + }else{ + relpath = syms.join("/") + '.js'; + moduleName = nsyms.join('.'); + var modArg = !omitModuleCheck ? moduleName : null; + ok = this.loadPath(relpath, modArg); + if(!ok && !exactOnly){ + syms.pop(); + while(syms.length){ + relpath = syms.join('/') + '.js'; + ok = this.loadPath(relpath, modArg); + if(ok){ break; } + syms.pop(); + 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 && !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 + module = this.findModule(moduleName, false); + 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. + var fullPkgName = String(packageName); + var strippedPkgName = fullPkgName; + + var syms = packageName.split(/\./); + 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. + + var lmn = String(moduleName); + + if(this.loaded_modules_[lmn]){ + return this.loaded_modules_[lmn]; // Object + } + + 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. + 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"); + 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 + var p = name.split("."); + for(var i = 0; i < p.length; i++){ + if(!obj[p[i]]){ return false; } // Boolean + 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. + + var result = locale ? locale.toLowerCase() : dojo.locale; + if(result == "root"){ + result = "ROOT"; + } + return result;// String +}; + +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". + + locale = dojo.hostenv.normalizeLocale(locale); + + var elements = locale.split('-'); + var searchlist = []; + 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--){ + var loc = searchlist[j] || "ROOT"; + var stop = searchFunc(loc); + if(stop){ break; } + } +} + +//These two functions are placed outside of preloadLocalizations +//So that the xd loading can use/override them. +dojo.hostenv.localesGenerated =["ROOT","es-es","es","it-it","pt-br","de","fr-fr","zh-cn","pt","en-us","zh","fr","zh-tw","it","en-gb","xx","de-de","ko-kr","ja-jp","ko","en","ja"]; // 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.registerNlsPrefix(); + + 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"; + } + } + + //See if the desired locale is already loaded. + 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)){ + // Mark loaded whether it's found or not, so that further load attempts will not be made + 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){ + // Use singleton with prototype to point to parent bundle, then mix-in result from loadPath + 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){ + //Stop the locale path searching if we know the availableFlatLocales, since + //the first call to this function will load the only bundle that is needed. + return true; + } + }); + } + + //Save the best locale bundle as the target locale bundle when we know the + //the available bundles. + if(availableFlatLocales && targetLocale != bestLocale){ + bundle[targetLocale.replace('-', '_')] = bundle[bestLocale.replace('-', '_')]; + } +}; + +(function(){ + // If other locales are used, dojo.requireLocalization should load them as well, by default. + // Override dojo.requireLocalization to do load the default bundle, then iterate through the + // extraLocale list and load those translations as well, unless a particular locale was requested. + + var extra = djConfig.extraLocale; + if(extra){ + if(!extra instanceof Array){ + extra = [extra]; + } + + var req = dojo.requireLocalization; + dojo.requireLocalization = function(m, b, locale, availableFlatLocales){ + req(m,b,locale, availableFlatLocales); + if(locale){return;} + for(var i=0; i 1){ + var paramStr = params[1]; + var pairs = paramStr.split("&"); + for(var x in pairs){ + var sp = pairs[x].split("="); + // FIXME: is this eval dangerous? + if((sp[0].length > 9)&&(sp[0].substr(0, 9) == "djConfig.")){ + var opt = sp[0].substr(9); + try{ + djConfig[opt]=eval(sp[1]); + }catch(e){ + djConfig[opt]=sp[1]; + } + } + } + } + } + + if( + ((djConfig["baseScriptUri"] == "")||(djConfig["baseRelativePath"] == "")) && + (document && document.getElementsByTagName) + ){ + var scripts = document.getElementsByTagName("script"); + var rePkg = /(__package__|dojo|bootstrap1)\.js([\?\.]|$)/i; + for(var i = 0; i < scripts.length; i++) { + var src = scripts[i].getAttribute("src"); + if(!src) { continue; } + var m = src.match(rePkg); + if(m) { + var root = src.substring(0, m.index); + if(src.indexOf("bootstrap1") > -1) { root += "../"; } + if(!this["djConfig"]) { djConfig = {}; } + if(djConfig["baseScriptUri"] == "") { djConfig["baseScriptUri"] = root; } + if(djConfig["baseRelativePath"] == "") { djConfig["baseRelativePath"] = root; } + break; + } + } + } + + // fill in the rendering support information in dojo.render.* + var dr = dojo.render; + var drh = dojo.render.html; + var drs = dojo.render.svg; + var dua = (drh.UA = navigator.userAgent); + var dav = (drh.AV = navigator.appVersion); + var t = true; + var f = false; + drh.capable = t; + drh.support.builtin = t; + + dr.ver = parseFloat(drh.AV); + dr.os.mac = dav.indexOf("Macintosh") >= 0; + dr.os.win = dav.indexOf("Windows") >= 0; + // could also be Solaris or something, but it's the same browser + 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 geckoPos = dua.indexOf("Gecko"); + drh.mozilla = drh.moz = (geckoPos >= 0)&&(!drh.khtml); + if (drh.mozilla) { + // gecko version is YYYYMMDD + drh.geckoVersion = dua.substring(geckoPos + 6, geckoPos + 14); + } + drh.ie = (document.all)&&(!drh.opera); + drh.ie50 = drh.ie && dav.indexOf("MSIE 5.0")>=0; + drh.ie55 = drh.ie && dav.indexOf("MSIE 5.5")>=0; + drh.ie60 = drh.ie && dav.indexOf("MSIE 6.0")>=0; + drh.ie70 = drh.ie && dav.indexOf("MSIE 7.0")>=0; + + var cm = document["compatMode"]; + drh.quirks = (cm == "BackCompat")||(cm == "QuirksMode")||drh.ie55||drh.ie50; + + // TODO: is the HTML LANG attribute relevant? + dojo.locale = dojo.locale || (drh.ie ? navigator.userLanguage : navigator.language).toLowerCase(); + + dr.vml.capable=drh.ie; + drs.capable = f; + drs.support.plugin = f; + drs.support.builtin = f; + var tdoc = window["document"]; + var tdi = tdoc["implementation"]; + + if((tdi)&&(tdi["hasFeature"])&&(tdi.hasFeature("org.w3c.dom.svg", "1.0"))){ + drs.capable = t; + drs.support.builtin = t; + drs.support.plugin = f; + } + // webkits after 420 support SVG natively. The test string is "AppleWebKit/420+" + if(drh.safari){ + var tmp = dua.split("AppleWebKit/")[1]; + var ver = parseFloat(tmp.split(" ")[0]); + if(ver >= 420){ + drs.capable = t; + drs.support.builtin = t; + drs.support.plugin = f; + } + }else{ + } + })(); + + dojo.hostenv.startPackage("dojo.hostenv"); + + dojo.render.name = dojo.hostenv.name_ = 'browser'; + dojo.hostenv.searchIds = []; + + // These are in order of decreasing likelihood; this will change in time. + dojo.hostenv._XMLHTTP_PROGIDS = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0']; + + dojo.hostenv.getXmlhttpObject = function(){ + // summary: does the work of portably generating a new XMLHTTPRequest object. + var http = null; + var last_e = null; + try{ http = new XMLHttpRequest(); }catch(e){} + if(!http){ + for(var i=0; i<3; ++i){ + var progid = dojo.hostenv._XMLHTTP_PROGIDS[i]; + try{ + http = new ActiveXObject(progid); + }catch(e){ + last_e = e; + } + + if(http){ + dojo.hostenv._XMLHTTP_PROGIDS = [progid]; // so faster next time + break; + } + } + + /*if(http && !http.toString) { + http.toString = function() { "[object XMLHttpRequest]"; } + }*/ + } + + if(!http){ + return dojo.raise("XMLHTTP not available", last_e); + } + + return http; // XMLHTTPRequest instance + } + + dojo.hostenv._blockAsync = false; + dojo.hostenv.getText = function(uri, async_cb, fail_ok){ + // summary: Read the contents of the specified uri and return those contents. + // uri: + // A relative or absolute uri. If absolute, it still must be in + // the same "domain" as we are. + // async_cb: + // If not specified, load synchronously. If specified, load + // asynchronously, and use async_cb as the progress handler which + // takes the xmlhttp object as its argument. If async_cb, this + // function returns null. + // fail_ok: + // Default false. If fail_ok and !async_cb and loading fails, + // return null instead of throwing. + + // need to block async callbacks from snatching this thread as the result + // of an async callback might call another sync XHR, this hangs khtml forever + // hostenv._blockAsync must also be checked in BrowserIO's watchInFlight() + // NOTE: must be declared before scope switches ie. this.getXmlhttpObject() + if(!async_cb){ this._blockAsync = true; } + + var http = this.getXmlhttpObject(); + + function isDocumentOk(http){ + var stat = http["status"]; + // allow a 304 use cache, needed in konq (is this compliant with the http spec?) + return Boolean((!stat)||((200 <= stat)&&(300 > stat))||(stat==304)); + } + + if(async_cb){ + var _this = this, timer = null, gbl = dojo.global(); + var xhr = dojo.evalObjPath("dojo.io.XMLHTTPTransport"); + http.onreadystatechange = function(){ + if(timer){ gbl.clearTimeout(timer); timer = null; } + if(_this._blockAsync || (xhr && xhr._blockAsync)){ + timer = gbl.setTimeout(function () { http.onreadystatechange.apply(this); }, 10); + }else{ + if(4==http.readyState){ + if(isDocumentOk(http)){ + // dojo.debug("LOADED URI: "+uri); + async_cb(http.responseText); + } + } + } + } + } + + http.open('GET', uri, async_cb ? true : false); + try{ + http.send(null); + if(async_cb){ + return null; + } + if(!isDocumentOk(http)){ + var err = Error("Unable to load "+uri+" status:"+ http.status); + err.status = http.status; + err.responseText = http.responseText; + throw err; + } + }catch(e){ + this._blockAsync = false; + if((fail_ok)&&(!async_cb)){ + return null; + }else{ + throw e; + } + } + + this._blockAsync = false; + return http.responseText; // String + } + + dojo.hostenv.defaultDebugContainerId = 'dojoDebug'; + dojo.hostenv._println_buffer = []; + dojo.hostenv._println_safe = false; + dojo.hostenv.println = function(/*String*/line){ + // summary: + // prints the provided line to whatever logging container is + // available. If the page isn't loaded yet, the line may be added + // to a buffer for printing later. + if(!dojo.hostenv._println_safe){ + dojo.hostenv._println_buffer.push(line); + }else{ + try { + var console = document.getElementById(djConfig.debugContainerId ? + djConfig.debugContainerId : dojo.hostenv.defaultDebugContainerId); + if(!console) { console = dojo.body(); } + + var div = document.createElement("div"); + div.appendChild(document.createTextNode(line)); + console.appendChild(div); + } catch (e) { + try{ + // safari needs the output wrapped in an element for some reason + document.write("
    " + line + "
    "); + }catch(e2){ + window.status = line; + } + } + } + } + + dojo.addOnLoad(function(){ + dojo.hostenv._println_safe = true; + while(dojo.hostenv._println_buffer.length > 0){ + dojo.hostenv.println(dojo.hostenv._println_buffer.shift()); + } + }); + + function dj_addNodeEvtHdlr(/*DomNode*/node, /*String*/evtName, /*Function*/fp){ + // summary: + // non-destructively adds the specified function to the node's + // evtName handler. + // node: the DomNode to add the handler to + // evtName: should be in the form "click" for "onclick" handlers + var oldHandler = node["on"+evtName] || function(){}; + node["on"+evtName] = function(){ + fp.apply(node, arguments); + oldHandler.apply(node, arguments); + } + return true; + } + + // BEGIN DOMContentLoaded, from Dean Edwards (http://dean.edwards.name/weblog/2006/06/again/) + function dj_load_init(e){ + // allow multiple calls, only first one will take effect + // A bug in khtml calls events callbacks for document for event which isnt supported + // for example a created contextmenu event calls DOMContentLoaded, workaround + var type = (e && e.type) ? e.type.toLowerCase() : "load"; + if(arguments.callee.initialized || (type!="domcontentloaded" && type!="load")){ return; } + arguments.callee.initialized = true; + if(typeof(_timer) != 'undefined'){ + clearInterval(_timer); + delete _timer; + } + + var initFunc = function(){ + //perform initialization + if(dojo.render.html.ie){ + dojo.hostenv.makeWidgets(); + } + }; + + if(dojo.hostenv.inFlightCount == 0){ + initFunc(); + dojo.hostenv.modulesLoaded(); + }else{ + //This else case should be xdomain loading. + //Make sure this is the first thing in the load listener array. + //Part of the dojo.addOnLoad guarantee is that when the listeners are notified, + //It means the DOM (or page) has loaded and that widgets have been parsed. + dojo.hostenv.modulesLoadedListeners.unshift(initFunc); + } + } + + // START DOMContentLoaded + // Mozilla and Opera 9 expose the event we could use + if(document.addEventListener){ + // NOTE: + // due to a threading issue in Firefox 2.0, we can't enable + // DOMContentLoaded on that platform. For more information, see: + // http://trac.dojotoolkit.org/ticket/1704 + if(dojo.render.html.opera || (dojo.render.html.moz && (djConfig["enableMozDomContentLoaded"] === true))){ + document.addEventListener("DOMContentLoaded", dj_load_init, null); + } + + // mainly for Opera 8.5, won't be fired if DOMContentLoaded fired already. + // also used for Mozilla because of trac #1640 + window.addEventListener("load", dj_load_init, null); + } + + // for Internet Explorer. readyState will not be achieved on init call, but dojo doesn't need it + // however, we'll include it because we don't know if there are other functions added that might. + // Note that this has changed because the build process strips all comments--including conditional + // ones. + if(dojo.render.html.ie && dojo.render.os.win){ + document.attachEvent("onreadystatechange", function(e){ + if(document.readyState == "complete"){ + dj_load_init(); + } + }); + } + + if (/(WebKit|khtml)/i.test(navigator.userAgent)) { // sniff + var _timer = setInterval(function() { + if (/loaded|complete/.test(document.readyState)) { + dj_load_init(); // call the onload handler + } + }, 10); + } + // END DOMContentLoaded + + // IE WebControl hosted in an application can fire "beforeunload" and "unload" + // events when control visibility changes, causing Dojo to unload too soon. The + // following code fixes the problem + // Reference: http://support.microsoft.com/default.aspx?scid=kb;en-us;199155 + if(dojo.render.html.ie){ + dj_addNodeEvtHdlr(window, "beforeunload", function(){ + dojo.hostenv._unloading = true; + window.setTimeout(function() { + dojo.hostenv._unloading = false; + }, 0); + }); + } + + dj_addNodeEvtHdlr(window, "unload", function(){ + dojo.hostenv.unloaded(); + if((!dojo.render.html.ie)||(dojo.render.html.ie && dojo.hostenv._unloading)){ + dojo.hostenv.unloaded(); + } + }); + + dojo.hostenv.makeWidgets = function(){ + // you can put searchIds in djConfig and dojo.hostenv at the moment + // we should probably eventually move to one or the other + var sids = []; + if(djConfig.searchIds && djConfig.searchIds.length > 0) { + sids = sids.concat(djConfig.searchIds); + } + if(dojo.hostenv.searchIds && dojo.hostenv.searchIds.length > 0) { + sids = sids.concat(dojo.hostenv.searchIds); + } + + if((djConfig.parseWidgets)||(sids.length > 0)){ + if(dojo.evalObjPath("dojo.widget.Parse")){ + // we must do this on a delay to avoid: + // http://www.shaftek.org/blog/archives/000212.html + // (IE bug) + var parser = new dojo.xml.Parse(); + if(sids.length > 0){ + for(var x=0; x 0, trim from start, if wh < 0, trim from end, else both + 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 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 + var out = ""; + for(var i = 0; i < count; i++) { + out += str; + 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 + var out = String(str); + if(!c) { + c = '0'; + } + if(!dir) { + dir = 1; + } + while(out.length < len) { + if(dir > 0) { + out = c + out; + } else { + out += c; + } + } + return out; // string +} + +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 +} + +dojo.provide("dojo.string"); + + +dojo.provide("dojo.lang.common"); + +dojo.lang.inherits = function(/*Function*/subclass, /*Function*/superclass){ + // summary: Set up inheritance between two classes. + 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. This addition is + // "prototype extension safe", so that instances of objects will not + // pass along prototype defaults. + 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])){ + 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"])) + { + 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. + return (it instanceof Function || typeof it == "function"); // Boolean +}; + +(function(){ + // webkit treats NodeList as a function, which is bad + if((dojo.render.html.capable)&&(dojo.render.html["safari"])){ + dojo.lang.isFunction = function(/*anything*/ it){ + 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. + return (typeof it == "string" || it instanceof String); +} + +dojo.lang.isAlien = function(/*anything*/ it){ + // summary: Return true if it is not a built-in function. False if not. + if(!it){ return false; } + return !dojo.lang.isFunction(it) && /\{\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 + +dojo.provide("dojo.lang.extras"); + + + +dojo.lang.setTimeout = function(/*Function*/func, /*int*/delay /*, ...*/){ + // summary: + // Sets a timeout in milliseconds to execute a function in a given + // context with optional arguments. + // usage: + // dojo.lang.setTimeout(Object context, function func, number delay[, arg1[, ...]]); + // dojo.lang.setTimeout(function func, number delay[, arg1[, ...]]); + + var context = window, argsStart = 2; + if(!dojo.lang.isFunction(func)){ + context = func; + func = delay; + delay = arguments[2]; + argsStart++; + } + + if(dojo.lang.isString(func)){ + func = context[func]; + } + + var args = []; + for (var i = argsStart; i < arguments.length; i++){ + args.push(arguments[i]); + } + return dojo.global().setTimeout(function(){ func.apply(context, args); }, delay); // int +} + +dojo.lang.clearTimeout = function(/*int*/timer){ + // summary: clears timer by number from the execution queue + + // FIXME: + // why do we have this function? It's not portable outside of browser + // environments and it's a stupid wrapper on something that browsers + // provide anyway. + dojo.global().clearTimeout(timer); +} + +dojo.lang.getNameInObj = function(/*Object*/ns, /*unknown*/item){ + // summary: + // looks for a value in the object ns with a value matching item and + // returns the property name + // ns: if null, dj_global is used + // item: value to return a name for + if(!ns){ ns = dj_global; } + + for(var x in ns){ + if(ns[x] === item){ + return new String(x); // String + } + } + return null; // null +} + +dojo.lang.shallowCopy = function(/*Object*/obj, /*Boolean?*/deep){ + // summary: + // copies object obj one level deep, or full depth if deep is true + var i, ret; + + if(obj === null){ /*obj: null*/ return null; } // null + + if(dojo.lang.isObject(obj)){ + // obj: Object + ret = new obj.constructor(); + for(i in obj){ + if(dojo.lang.isUndefined(ret[i])){ + ret[i] = deep ? dojo.lang.shallowCopy(obj[i], deep) : obj[i]; + } + } + }else if(dojo.lang.isArray(obj)){ + // obj: Array + ret = []; + for(i=0; i hacks: + * iframe document hacks allow browsers to communicate asynchronously + * with a server via HTTP POST and GET operations. With significant + * effort and server cooperation, low-latency data transit between + * client and server can be acheived via iframe mechanisms (repubsub). + * + * SVG: + * Adobe's SVG viewer implements helpful primitives for XML-based + * requests, but receipt of arbitrary text data seems unlikely w/o + * sections. + * + * + * A discussion between Dylan, Mark, Tom, and Alex helped to lay down a lot + * the IO API interface. A transcript of it can be found at: + * http://dojotoolkit.org/viewcvs/viewcvs.py/documents/irc/irc_io_api_log.txt?rev=307&view=auto + * + * Also referenced in the design of the API was the DOM 3 L&S spec: + * http://www.w3.org/TR/2004/REC-DOM-Level-3-LS-20040407/load-save.html + ******************************************************************************/ + +// a map of the available transport options. Transports should add themselves +// by calling add(name) +dojo.io.transports = []; +dojo.io.hdlrFuncNames = [ "load", "error", "timeout" ]; // we're omitting a progress() event for now + +dojo.io.Request = function(/*String*/ url, /*String*/ mimetype, /*String*/ transport, /*String or Boolean*/ changeUrl){ +// summary: +// Constructs a Request object that is used by dojo.io.bind(). +// description: +// dojo.io.bind() will create one of these for you if +// you call dojo.io.bind() with an plain object containing the bind parameters. +// This method can either take the arguments specified, or an Object containing all of the parameters that you +// want to use to create the dojo.io.Request (similar to how dojo.io.bind() is called. +// The named parameters to this constructor represent the minimum set of parameters need + if((arguments.length == 1)&&(arguments[0].constructor == Object)){ + this.fromKwArgs(arguments[0]); + }else{ + this.url = url; + if(mimetype){ this.mimetype = mimetype; } + if(transport){ this.transport = transport; } + if(arguments.length >= 4){ this.changeUrl = changeUrl; } + } +} + +dojo.lang.extend(dojo.io.Request, { + + /** The URL to hit */ + url: "", + + /** The mime type used to interrpret the response body */ + mimetype: "text/plain", + + /** The HTTP method to use */ + method: "GET", + + /** An Object containing key-value pairs to be included with the request */ + content: undefined, // Object + + /** The transport medium to use */ + transport: undefined, // String + + /** If defined the URL of the page is physically changed */ + changeUrl: undefined, // String + + /** A form node to use in the request */ + formNode: undefined, // HTMLFormElement + + /** Whether the request should be made synchronously */ + sync: false, + + bindSuccess: false, + + /** Cache/look for the request in the cache before attempting to request? + * NOTE: this isn't a browser cache, this is internal and would only cache in-page + */ + useCache: false, + + /** Prevent the browser from caching this by adding a query string argument to the URL */ + preventCache: false, + + // events stuff + load: function(/*String*/type, /*Object*/data, /*Object*/transportImplementation, /*Object*/kwArgs){ + // summary: + // Called on successful completion of a bind. + // type: String + // A string with value "load" + // data: Object + // The object representing the result of the bind. The actual structure + // of the data object will depend on the mimetype that was given to bind + // in the bind arguments. + // transportImplementation: Object + // The object that implements a particular transport. Structure is depedent + // on the transport. For XMLHTTPTransport (dojo.io.BrowserIO), it will be the + // XMLHttpRequest object from the browser. + // kwArgs: Object + // Object that contains the request parameters that were given to the + // bind call. Useful for storing and retrieving state from when bind + // was called. + }, + error: function(/*String*/type, /*Object*/error, /*Object*/transportImplementation, /*Object*/kwArgs){ + // summary: + // Called when there is an error with a bind. + // type: String + // A string with value "error" + // error: Object + // The error object. Should be a dojo.io.Error object, but not guaranteed. + // transportImplementation: Object + // The object that implements a particular transport. Structure is depedent + // on the transport. For XMLHTTPTransport (dojo.io.BrowserIO), it will be the + // XMLHttpRequest object from the browser. + // kwArgs: Object + // Object that contains the request parameters that were given to the + // bind call. Useful for storing and retrieving state from when bind + // was called. + }, + timeout: function(/*String*/type, /*Object*/empty, /*Object*/transportImplementation, /*Object*/kwArgs){ + // summary: + // Called when there is an error with a bind. Only implemented in certain transports at this time. + // type: String + // A string with value "timeout" + // empty: Object + // Should be null. Just a spacer argument so that load, error, timeout and handle have the + // same signatures. + // transportImplementation: Object + // The object that implements a particular transport. Structure is depedent + // on the transport. For XMLHTTPTransport (dojo.io.BrowserIO), it will be the + // XMLHttpRequest object from the browser. May be null for the timeout case for + // some transports. + // kwArgs: Object + // Object that contains the request parameters that were given to the + // bind call. Useful for storing and retrieving state from when bind + // was called. + }, + handle: function(/*String*/type, /*Object*/data, /*Object*/transportImplementation, /*Object*/kwArgs){ + // summary: + // The handle method can be defined instead of defining separate load, error and timeout + // callbacks. + // type: String + // A string with the type of callback: "load", "error", or "timeout". + // data: Object + // See the above callbacks for what this parameter could be. + // transportImplementation: Object + // The object that implements a particular transport. Structure is depedent + // on the transport. For XMLHTTPTransport (dojo.io.BrowserIO), it will be the + // XMLHttpRequest object from the browser. + // kwArgs: Object + // Object that contains the request parameters that were given to the + // bind call. Useful for storing and retrieving state from when bind + // was called. + }, + + //FIXME: change IframeIO.js to use timeouts? + // The number of seconds to wait until firing a timeout callback. + // If it is zero, that means, don't do a timeout check. + timeoutSeconds: 0, + + // the abort method needs to be filled in by the transport that accepts the + // bind() request + abort: function(){ }, + + // backButton: function(){ }, + // forwardButton: function(){ }, + + fromKwArgs: function(/*Object*/ kwArgs){ + // summary: + // Creates a dojo.io.Request from a simple object (kwArgs object). + + // normalize args + if(kwArgs["url"]){ kwArgs.url = kwArgs.url.toString(); } + if(kwArgs["formNode"]) { kwArgs.formNode = dojo.byId(kwArgs.formNode); } + if(!kwArgs["method"] && kwArgs["formNode"] && kwArgs["formNode"].method) { + kwArgs.method = kwArgs["formNode"].method; + } + + // backwards compatibility + if(!kwArgs["handle"] && kwArgs["handler"]){ kwArgs.handle = kwArgs.handler; } + if(!kwArgs["load"] && kwArgs["loaded"]){ kwArgs.load = kwArgs.loaded; } + if(!kwArgs["changeUrl"] && kwArgs["changeURL"]) { kwArgs.changeUrl = kwArgs.changeURL; } + + // encoding fun! + kwArgs.encoding = dojo.lang.firstValued(kwArgs["encoding"], djConfig["bindEncoding"], ""); + + kwArgs.sendTransport = dojo.lang.firstValued(kwArgs["sendTransport"], djConfig["ioSendTransport"], false); + + var isFunction = dojo.lang.isFunction; + for(var x=0; x 0){ + dojo.io.bind(dojo.io._bindQueue.shift()); + }else{ + dojo.io._queueBindInFlight = false; + } + } +} +dojo.io._bindQueue = []; +dojo.io._queueBindInFlight = false; + +dojo.io.argsFromMap = function(/*Object*/map, /*String?*/encoding, /*String?*/last){ + // summary: + // Converts name/values pairs in the map object to an URL-encoded string + // with format of name1=value1&name2=value2... + // map: Object + // Object that has the contains the names and values. + // encoding: String? + // String to specify how to encode the name and value. If the encoding string + // contains "utf" (case-insensitive), then encodeURIComponent is used. Otherwise + // dojo.string.encodeAscii is used. + // last: String? + // The last parameter in the list. Helps with final string formatting? + var enc = /utf/i.test(encoding||"") ? encodeURIComponent : dojo.string.encodeAscii; + var mapped = []; + var control = new Object(); + for(var name in map){ + var domap = function(elt){ + var val = enc(name)+"="+enc(elt); + mapped[(last == name) ? "push" : "unshift"](val); + } + if(!control[name]){ + var value = map[name]; + // FIXME: should be isArrayLike? + if (dojo.lang.isArray(value)){ + dojo.lang.forEach(value, domap); + }else{ + domap(value); + } + } + } + return mapped.join("&"); //String +} + +dojo.io.setIFrameSrc = function(/*DOMNode*/ iframe, /*String*/ src, /*Boolean*/ replace){ + //summary: + // Sets the URL that is loaded in an IFrame. The replace parameter indicates whether + // location.replace() should be used when changing the location of the iframe. + try{ + var r = dojo.render.html; + // dojo.debug(iframe); + if(!replace){ + if(r.safari){ + iframe.location = src; + }else{ + frames[iframe.name].location = src; + } + }else{ + // Fun with DOM 0 incompatibilities! + var idoc; + if(r.ie){ + idoc = iframe.contentWindow.document; + }else if(r.safari){ + idoc = iframe.document; + }else{ // if(r.moz){ + idoc = iframe.contentWindow; + } + + //For Safari (at least 2.0.3) and Opera, if the iframe + //has just been created but it doesn't have content + //yet, then iframe.document may be null. In that case, + //use iframe.location and return. + if(!idoc){ + iframe.location = src; + return; + }else{ + idoc.location.replace(src); + } + } + }catch(e){ + dojo.debug(e); + dojo.debug("setIFrameSrc: "+e); + } +} + +/* +dojo.io.sampleTranport = new function(){ + this.canHandle = function(kwArgs){ + // canHandle just tells dojo.io.bind() if this is a good transport to + // use for the particular type of request. + if( + ( + (kwArgs["mimetype"] == "text/plain") || + (kwArgs["mimetype"] == "text/html") || + (kwArgs["mimetype"] == "text/javascript") + )&&( + (kwArgs["method"] == "get") || + ( (kwArgs["method"] == "post") && (!kwArgs["formNode"]) ) + ) + ){ + return true; + } + + return false; + } + + this.bind = function(kwArgs){ + var hdlrObj = {}; + + // set up a handler object + for(var x=0; x1; }); + // // returns false + // dojo.lang.every([1, 2, 3, 4], function(item){ return item>0; }); + // // returns true + return this._everyOrSome(true, arr, callback, thisObject); // Boolean + }, + + some: function(/*Array*/arr, /*Function*/callback, /*Object?*/thisObject){ + // summary: + // determines whether or not any item in the array satisfies the + // condition implemented by callback. thisObject may be used to + // scope the call to callback. The function signature is derived + // from the JavaScript 1.6 Array.some() function. More + // information on this can be found here: + // http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:some + // examples: + // dojo.lang.some([1, 2, 3, 4], function(item){ return item>1; }); + // // returns true + // dojo.lang.some([1, 2, 3, 4], function(item){ return item<1; }); + // // returns false + return this._everyOrSome(false, arr, callback, thisObject); // Boolean + }, + + filter: function(/*Array*/arr, /*Function*/callback, /*Object?*/thisObject){ + // summary: + // returns a new Array with those items from arr that match the + // condition implemented by callback.thisObject may be used to + // scope the call to callback. The function signature is derived + // from the JavaScript 1.6 Array.filter() function, although + // special accomidation is made in our implementation for strings. + // More information on the JS 1.6 API can be found here: + // http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:filter + // examples: + // dojo.lang.some([1, 2, 3, 4], function(item){ return item>1; }); + // // returns [2, 3, 4] + var isString = dojo.lang.isString(arr); + if(isString){ /*arr: String*/arr = arr.split(""); } + var outArr; + if(Array.filter){ + outArr = Array.filter(arr, callback, thisObject); + }else{ + 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)){ + outArr.push(arr[i]); + } + } + } + if(isString){ + return outArr.join(""); // String + } else { + return outArr; // Array + } + }, + + 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] + + var out = []; + 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{ + out.push(arguments[i]); + } + } + return out; // Array + }, + + toArray: function(/*Object*/arrayLike, /*Number*/startOffset){ + // summary: + // Converts an array-like object (i.e. arguments, DOMCollection) + // to an array. Returns a new Array object. + var array = []; + for(var i = startOffset||0; i < arrayLike.length; i++){ + array.push(arrayLike[i]); + } + return array; // Array + } +}); + +dojo.provide("dojo.lang.func"); + + +dojo.lang.hitch = function(/*Object*/thisObject, /*Function|String*/method){ + // summary: + // Returns a function that will only ever execute in the a given scope + // (thisObject). This allows for easy use of object member functions + // in callbacks and other places in which the "this" keyword may + // otherwise not reference the expected scope. Note that the order of + // arguments may be reversed in a future version. + // thisObject: the scope to run the method in + // method: + // a function to be "bound" to thisObject or the name of the method in + // thisObject to be used as the basis for the binding + // usage: + // dojo.lang.hitch(foo, "bar")(); // runs foo.bar() in the scope of foo + // dojo.lang.hitch(foo, myFunction); // returns a function that runs myFunction in the scope of foo + + // FIXME: + // should this be extended to "fixate" arguments in a manner similar + // to dojo.lang.curry, but without the default execution of curry()? + var fcn = (dojo.lang.isString(method) ? thisObject[method] : method) || function(){}; + return function(){ + return fcn.apply(thisObject, arguments); // Function + }; +} + +dojo.lang.anonCtr = 0; +dojo.lang.anon = {}; + +dojo.lang.nameAnonFunc = function(/*Function*/anonFuncPtr, /*Object*/thisObj, /*Boolean*/searchForNames){ + // summary: + // Creates a reference to anonFuncPtr in thisObj with a completely + // unique name. The new name is returned as a String. If + // searchForNames is true, an effort will be made to locate an + // existing reference to anonFuncPtr in thisObj, and if one is found, + // the existing name will be returned instead. The default is for + // searchForNames to be false. + var nso = (thisObj|| dojo.lang.anon); + if( (searchForNames) || + ((dj_global["djConfig"])&&(djConfig["slowAnonFuncLookups"] == true)) ){ + for(var x in nso){ + try{ + if(nso[x] === anonFuncPtr){ + return x; + } + }catch(e){} // window.external fails in IE embedded in Eclipse (Eclipse bug #151165) + } + } + var ret = "__"+dojo.lang.anonCtr++; + while(typeof nso[ret] != "undefined"){ + ret = "__"+dojo.lang.anonCtr++; + } + nso[ret] = anonFuncPtr; + return ret; // String +} + +dojo.lang.forward = function(funcName){ + // summary: + // Returns a function that forwards a method call to + // this.funcName(...). Unlike dojo.lang.hitch(), the "this" scope is + // not fixed on a single object. Ported from MochiKit. + return function(){ + return this[funcName].apply(this, arguments); + }; // Function +} + +dojo.lang.curry = function(thisObj, func /* args ... */){ + // summary: + // similar to the curry() method found in many functional programming + // environments, this function returns an "argument accumulator" + // function, bound to a particular scope, and "primed" with a variable + // number of arguments. The curry method is unique in that it returns + // a function that may return other "partial" function which can be + // called repeatedly. New functions are returned until the arity of + // the original function is reached, at which point the underlying + // function (func) is called in the scope thisObj with all of the + // accumulated arguments (plus any extras) in positional order. + // examples: + // assuming a function defined like this: + // var foo = { + // bar: function(arg1, arg2, arg3){ + // dojo.debug.apply(dojo, arguments); + // } + // }; + // + // dojo.lang.curry() can be used most simply in this way: + // + // tmp = dojo.lang.curry(foo, foo.bar, "arg one", "thinger"); + // tmp("blah", "this is superfluous"); + // // debugs: "arg one thinger blah this is superfluous" + // tmp("blah"); + // // debugs: "arg one thinger blah" + // tmp(); + // // returns a function exactly like tmp that expects one argument + // + // other intermittent functions could be created until the 3 + // positional arguments are filled: + // + // tmp = dojo.lang.curry(foo, foo.bar, "arg one"); + // tmp2 = tmp("arg two"); + // tmp2("blah blah"); + // // debugs: "arg one arg two blah blah" + // tmp2("oy"); + // // debugs: "arg one arg two oy" + // + // curry() can also be used to call the function if enough arguments + // are passed in the initial invocation: + // + // dojo.lang.curry(foo, foo.bar, "one", "two", "three", "four"); + // // debugs: "one two three four" + // dojo.lang.curry(foo, foo.bar, "one", "two", "three"); + // // debugs: "one two three" + + + // FIXME: the order of func and thisObj should be changed!!! + var outerArgs = []; + thisObj = thisObj||dj_global; + if(dojo.lang.isString(func)){ + func = thisObj[func]; + } + for(var x=2; x"' +// 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 + } + + 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){ + str = str.toLowerCase(); + end = end.toLowerCase(); + } + if((str.length - end.length) < 0){ + return false; // boolean + } + 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 false; // boolean +} + +dojo.string.startsWith = function(/*string*/str, /*string*/start, /*boolean*/ignoreCase){ +// summary: +// Returns true if 'str' starts with 'start' + + 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 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; // 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"){ + 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"); + } + 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 + + var components = []; + 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 +} + +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"; + +/** + * comprehensive list of XML namespaces +**/ +dojo.dom.xmlns = { + // summary + // aliases for various common XML namespaces + 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(/* object */wh){ + // summary: + // checks to see if wh is actually a node. + if(typeof Element == "function") { + try { + return wh instanceof Element; // boolean + } catch(e) {} + } else { + // best-guess + return wh && !isNaN(wh.nodeType); // boolean + } +} + +dojo.dom.getUniqueId = function(){ + // summary: + // returns a unique string for use with any DOM element + var _document = dojo.doc(); + do { + var id = "dj_unique_" + (++arguments.callee._idIncrement); + }while(_document.getElementById(id)); + return id; // string +} +dojo.dom.getUniqueId._idIncrement = 0; + +dojo.dom.firstElement = dojo.dom.getFirstChildElement = function(/* Element */parentNode, /* string? */tagName){ + // summary: + // returns the first child element matching tagName + var node = parentNode.firstChild; + while(node && node.nodeType != dojo.dom.ELEMENT_NODE){ + node = node.nextSibling; + } + if(tagName && node && node.tagName && node.tagName.toLowerCase() != tagName.toLowerCase()) { + node = dojo.dom.nextElement(node, tagName); + } + return node; // Element +} + +dojo.dom.lastElement = dojo.dom.getLastChildElement = function(/* Element */parentNode, /* string? */tagName){ + // summary: + // returns the last child element matching tagName + var node = parentNode.lastChild; + while(node && node.nodeType != dojo.dom.ELEMENT_NODE) { + node = node.previousSibling; + } + if(tagName && node && node.tagName && node.tagName.toLowerCase() != tagName.toLowerCase()) { + node = dojo.dom.prevElement(node, tagName); + } + return node; // Element +} + +dojo.dom.nextElement = dojo.dom.getNextSiblingElement = function(/* Node */node, /* string? */tagName){ + // summary: + // returns the next sibling element matching tagName + if(!node) { return null; } + do { + node = node.nextSibling; + } while(node && node.nodeType != dojo.dom.ELEMENT_NODE); + + if(node && tagName && tagName.toLowerCase() != node.tagName.toLowerCase()) { + return dojo.dom.nextElement(node, tagName); + } + return node; // Element +} + +dojo.dom.prevElement = dojo.dom.getPreviousSiblingElement = function(/* Node */node, /* string? */tagName){ + // summary: + // returns the previous sibling element matching tagName + if(!node) { return null; } + if(tagName) { tagName = tagName.toLowerCase(); } + do { + node = node.previousSibling; + } while(node && node.nodeType != dojo.dom.ELEMENT_NODE); + + if(node && tagName && tagName.toLowerCase() != node.tagName.toLowerCase()) { + return dojo.dom.prevElement(node, tagName); + } + return node; // Element +} + +// TODO: hmph +/*this.forEachChildTag = function(node, unaryFunc) { + var child = this.getFirstChildTag(node); + while(child) { + if(unaryFunc(child) == "break") { break; } + child = this.getNextSiblingTag(child); + } +}*/ + +dojo.dom.moveChildren = function(/*Element*/srcNode, /*Element*/destNode, /*boolean?*/trim){ + // summary: + // Moves children from srcNode to destNode and returns the count of + // children moved; will trim off text nodes if trim == true + var count = 0; + if(trim) { + while(srcNode.hasChildNodes() && + srcNode.firstChild.nodeType == dojo.dom.TEXT_NODE) { + srcNode.removeChild(srcNode.firstChild); + } + while(srcNode.hasChildNodes() && + srcNode.lastChild.nodeType == dojo.dom.TEXT_NODE) { + srcNode.removeChild(srcNode.lastChild); + } + } + while(srcNode.hasChildNodes()){ + destNode.appendChild(srcNode.firstChild); + count++; + } + return count; // number +} + +dojo.dom.copyChildren = function(/*Element*/srcNode, /*Element*/destNode, /*boolean?*/trim){ + // summary: + // Copies children from srcNde to destNode and returns the count of + // children copied; will trim off text nodes if trim == true + var clonedNode = srcNode.cloneNode(true); + return this.moveChildren(clonedNode, destNode, trim); // number +} + +dojo.dom.replaceChildren = function(/*Element*/node, /*Node*/newChild){ + // summary: + // Removes all children of node and appends newChild. All the existing + // children will be destroyed. + // FIXME: what if newChild is an array-like object? + var nodes = []; + if(dojo.render.html.ie){ + for(var i=0;i 0){ + return ancestors[0]; // Node + } + + node = node.parentNode; + } + if(returnFirstHit){ return null; } + return ancestors; // array +} + +dojo.dom.getAncestorsByTag = function(/*Node*/node, /*String*/tag, /*boolean?*/returnFirstHit){ + // summary: + // returns all ancestors matching tag (as tagName), will only return + // first one if returnFirstHit + tag = tag.toLowerCase(); + return dojo.dom.getAncestors(node, function(el){ + return ((el.tagName)&&(el.tagName.toLowerCase() == tag)); + }, returnFirstHit); // Node || array +} + +dojo.dom.getFirstAncestorByTag = function(/*Node*/node, /*string*/tag){ + // summary: + // Returns first ancestor of node with tag tagName + return dojo.dom.getAncestorsByTag(node, tag, true); // Node +} + +dojo.dom.isDescendantOf = function(/* Node */node, /* Node */ancestor, /* boolean? */guaranteeDescendant){ + // summary + // Returns boolean if node is a descendant of ancestor + // guaranteeDescendant allows us to be a "true" isDescendantOf function + if(guaranteeDescendant && node) { node = node.parentNode; } + while(node) { + if(node == ancestor){ + return true; // boolean + } + node = node.parentNode; + } + return false; // boolean +} + +dojo.dom.innerXML = function(/*Node*/node){ + // summary: + // Implementation of MS's innerXML function. + if(node.innerXML){ + return node.innerXML; // string + }else if (node.xml){ + return node.xml; // string + }else if(typeof XMLSerializer != "undefined"){ + return (new XMLSerializer()).serializeToString(node); // string + } +} + +dojo.dom.createDocument = function(){ + // summary: + // cross-browser implementation of creating an XML document object. + var doc = null; + var _document = dojo.doc(); + + if(!dj_undef("ActiveXObject")){ + var prefixes = [ "MSXML2", "Microsoft", "MSXML", "MSXML3" ]; + for(var i = 0; i1) { + var _document = dojo.doc(); + dojo.dom.replaceChildren(node, _document.createTextNode(text)); + return text; // string + } else { + if(node.textContent != undefined){ //FF 1.5 + return node.textContent; // string + } + var _result = ""; + if (node == null) { return _result; } + for (var i = 0; i < node.childNodes.length; i++) { + switch (node.childNodes[i].nodeType) { + case 1: // ELEMENT_NODE + case 5: // ENTITY_REFERENCE_NODE + _result += dojo.dom.textContent(node.childNodes[i]); + break; + case 3: // TEXT_NODE + case 2: // ATTRIBUTE_NODE + case 4: // CDATA_SECTION_NODE + _result += node.childNodes[i].nodeValue; + break; + default: + break; + } + } + return _result; // string + } +} + +dojo.dom.hasParent = function(/*Node*/node){ + // summary: + // returns whether or not node is a child of another node. + return Boolean(node && node.parentNode && dojo.dom.isNode(node.parentNode)); // boolean +} + +/** + * Examples: + * + * myFooNode = + * isTag(myFooNode, "foo"); // returns "foo" + * isTag(myFooNode, "bar"); // returns "" + * isTag(myFooNode, "FOO"); // returns "" + * isTag(myFooNode, "hey", "foo", "bar"); // returns "foo" +**/ +dojo.dom.isTag = function(/* Node */node /* ... */){ + // summary: + // determines if node has any of the provided tag names and returns + // the tag name that matches, empty string otherwise. + if(node && node.tagName) { + for(var i=1; i"); + } +}catch(e){/* squelch */} + +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: (!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(/*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: 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. + 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){ + 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.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]); + } + + //Set interceptor function in the right place. + 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]); + } + } + + //Set interceptor function in the right place. + if(args["forward"]){ + args.forward = tfw; + }else if(args["forwardButton"]){ + args.forwardButton = tfw; + }else if(args["handle"]){ + args.handle = tfw; + } + + }else if(dojo.render.html.moz){ + // start the timer + 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(){ + //summary: private method. Do not call this directly. + 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); + 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){ + //summary: private method. Do not call this directly. + 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)){ + this.handleBackButton(); + } + else if(this.forwardStack.length > 0 && query == this._getUrlQuery(this.forwardStack[this.forwardStack.length-1].url)){ + this.handleForwardButton(); + } + } + }, + + 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; } + 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"); + } + } + this.forwardStack.push(current); + }, + + handleForwardButton: function(){ + //summary: private method. Do not call this directly. + + 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){ + //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; //null + } + else{ + return segments[1]; //String + } + }, + + _loadIframeHistory: function(){ + //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; //String + } +} + +dojo.provide("dojo.io.BrowserIO"); + + + + + + + + +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){ + if(hasFile){ return; } + if(input.getAttribute("type")=="file"){ + hasFile = true; + } + }); + return hasFile; //boolean +} + +dojo.io.formHasFile = function(/*DOMNode*/formNode){ + //summary: Just calls dojo.io.checkChildrenForFile(). + return dojo.io.checkChildrenForFile(formNode); //boolean +} + +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)){ + args = { url: urlOrArgs }; + } + args.mimetype = "text/html"; + args.load = function(t, d, e){ + while(node.firstChild){ + dojo.dom.destroyNode(node.firstChild); + } + node.innerHTML = d; + }; + dojo.io.bind(args); +} + +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); //boolean +} + +// TODO: Move to htmlUtils +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."); + } + if(!formFilter) { formFilter = dojo.io.formFilter; } + var enc = /utf/i.test(encoding||"") ? encodeURIComponent : dojo.string.encodeAscii; + var values = []; + + for(var i = 0; i < formNode.elements.length; i++){ + var elm = formNode.elements[i]; + if(!elm || elm.tagName.toLowerCase() == "fieldset" || !formFilter(elm)) { continue; } + var name = enc(elm.name); + var type = elm.type.toLowerCase(); + + if(type == "select-multiple"){ + for(var j = 0; j < elm.options.length; j++){ + if(elm.options[j].selected) { + values.push(name + "=" + enc(elm.options[j].value)); + } + } + }else if(dojo.lang.inArray(["radio", "checkbox"], type)){ + if(elm.checked){ + values.push(name + "=" + enc(elm.value)); + } + }else{ + values.push(name + "=" + enc(elm.value)); + } + } + + // now collect input type="image", which doesn't show up in the elements array + var inputs = formNode.getElementsByTagName("input"); + for(var i = 0; i < inputs.length; i++) { + var input = inputs[i]; + if(input.type.toLowerCase() == "image" && input.form == formNode + && formFilter(input)) { + var name = enc(input.name); + values.push(name + "=" + enc(input.value)); + values.push(name + ".x=0"); + values.push(name + ".y=0"); + } + } + return values.join("&") + "&"; //String +} + +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) { + this.init(args); + } else if(args) { + this.init({formNode: args}); + } +} +dojo.lang.extend(dojo.io.FormBind, { + form: null, + + bindArgs: null, + + clickedButton: null, + + 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") { + throw new Error("FormBind: Couldn't apply, invalid form"); + } else if(this.form == form) { + return; + } else if(this.form) { + throw new Error("FormBind: Already applied to a form"); + } + + dojo.lang.mixin(this.bindArgs, args); + this.form = form; + + this.connect(form, "onsubmit", "submit"); + + for(var i = 0; i < form.elements.length; i++) { + var node = form.elements[i]; + if(node && node.type && dojo.lang.inArray(["submit", "button"], node.type.toLowerCase())) { + this.connect(node, "onclick", "click"); + } + } + + var inputs = form.getElementsByTagName("input"); + for(var i = 0; i < inputs.length; i++) { + var input = inputs[i]; + if(input.type.toLowerCase() == "image" && input.form == form) { + this.connect(input, "onclick", "click"); + } + } + }, + + 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(/*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, { + formFilter: dojo.lang.hitch(this, "formFilter") + })); + } + }, + + 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(/*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) { + accept = false; + } else if(dojo.lang.inArray(["submit", "button", "image"], type)) { + if(!this.clickedButton) { this.clickedButton = node; } + accept = node == this.clickedButton; + } else { + accept = !dojo.lang.inArray(["file", "submit", "reset", "button"], type); + } + return accept; //boolean + }, + + // in case you don't have dojo.event.* pulled in + 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 { + var fcn = dojo.lang.hitch(this, targetFcn); + srcObj[srcFcn] = function(e) { + if(!e) { e = window.event; } + if(!e.currentTarget) { e.currentTarget = e.srcElement; } + if(!e.preventDefault) { e.preventDefault = function() { window.event.returnValue = false; } } + fcn(e); + } + } + } +}); + +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? + this.useCache = false; // if this is true, we'll cache unless kwArgs.useCache = false + this.preventCache = false; // if this is true, we'll always force GET requests to cache + + // FIXME: Should this even be a function? or do we just hard code it in the next 2 functions? + function getCacheKey(url, query, method) { + return url + "|" + query + "|" + method.toLowerCase(); + } + + function addToCache(url, query, method, http) { + _cache[getCacheKey(url, query, method)] = http; + } + + function getFromCache(url, query, method) { + return _cache[getCacheKey(url, query, method)]; + } + + this.clearCache = function() { + _cache = {}; + } + + // moved successful load stuff here + function doLoad(kwArgs, http, url, query, useCache) { + if( ((http.status>=200)&&(http.status<300))|| // allow any 2XX response code + (http.status==304)|| // get it out of the cache + (location.protocol=="file:" && (http.status==0 || http.status==undefined))|| + (location.protocol=="chrome:" && (http.status==0 || http.status==undefined)) + ){ + var ret; + if(kwArgs.method.toLowerCase() == "head"){ + var headers = http.getAllResponseHeaders(); + ret = {}; + ret.toString = function(){ return headers; } + var values = headers.split(/[\r\n]+/g); + for(var i = 0; i < values.length; i++) { + var pair = values[i].match(/^([^:]+)\s*:\s*(.+)$/i); + if(pair) { + ret[pair[1]] = pair[2]; + } + } + }else if(kwArgs.mimetype == "text/javascript"){ + try{ + ret = dj_eval(http.responseText); + }catch(e){ + dojo.debug(e); + dojo.debug(http.responseText); + ret = null; + } + }else if(kwArgs.mimetype == "text/json" || kwArgs.mimetype == "application/json"){ + try{ + ret = dj_eval("("+http.responseText+")"); + }catch(e){ + dojo.debug(e); + dojo.debug(http.responseText); + ret = false; + } + }else if((kwArgs.mimetype == "application/xml")|| + (kwArgs.mimetype == "text/xml")){ + ret = http.responseXML; + if(!ret || typeof ret == "string" || !http.getResponseHeader("Content-Type")) { + ret = dojo.dom.createDocumentFromText(http.responseText); + } + }else{ + ret = http.responseText; + } + + if(useCache){ // only cache successful responses + addToCache(url, query, kwArgs.method, http); + } + kwArgs[(typeof kwArgs.load == "function") ? "load" : "handle"]("load", ret, http, kwArgs); + }else{ + var errObj = new dojo.io.Error("XMLHttpTransport Error: "+http.status+" "+http.statusText); + kwArgs[(typeof kwArgs.error == "function") ? "error" : "handle"]("error", errObj, http, kwArgs); + } + } + + // set headers (note: Content-Type will get overriden if kwArgs.contentType is set) + function setHeaders(http, kwArgs){ + if(kwArgs["headers"]) { + for(var header in kwArgs["headers"]) { + if(header.toLowerCase() == "content-type" && !kwArgs["contentType"]) { + kwArgs["contentType"] = kwArgs["headers"][header]; + } else { + http.setRequestHeader(header, kwArgs["headers"][header]); + } + } + } + } + + this.inFlight = []; + 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 + // using setTimeout instead + this.inFlightTimer = setTimeout("dojo.io.XMLHTTPTransport.watchInFlight();", 10); + } + } + + 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 + if(!dojo.hostenv._blockAsync && !_this._blockAsync){ + for(var x=this.inFlight.length-1; x>=0; x--){ + try{ + var tif = this.inFlight[x]; + if(!tif || tif.http._aborted || !tif.http.readyState){ + this.inFlight.splice(x, 1); continue; + } + if(4==tif.http.readyState){ + // remove it so we can clean refs + this.inFlight.splice(x, 1); + doLoad(tif.req, tif.http, tif.url, tif.query, tif.useCache); + }else if (tif.startTime){ + //See if this is a timeout case. + if(!now){ + now = (new Date()).getTime(); + } + if(tif.startTime + (tif.req.timeoutSeconds * 1000) < now){ + //Stop the request. + if(typeof tif.http.abort == "function"){ + tif.http.abort(); + } + + // remove it so we can clean refs + this.inFlight.splice(x, 1); + tif.req[(typeof tif.req.timeout == "function") ? "timeout" : "handle"]("timeout", null, tif.http, tif.req); + } + } + }catch(e){ + try{ + var errObj = new dojo.io.Error("XMLHttpTransport.watchInFlight Error: " + e); + tif.req[(typeof tif.req.error == "function") ? "error" : "handle"]("error", errObj, tif.http, tif.req); + }catch(e2){ + dojo.debug("XMLHttpTransport error callback failed: " + e2); + } + } + } + } + + clearTimeout(this.inFlightTimer); + if(this.inFlight.length == 0){ + this.inFlightTimer = null; + return; + } + this.inFlightTimer = setTimeout("dojo.io.XMLHTTPTransport.watchInFlight();", 10); + } + + var hasXmlHttp = dojo.hostenv.getXmlhttpObject() ? true : false; + 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"]) ); //boolean + } + + this.multipartBoundary = "45309FFF-BD65-4d50-99C9-36986896A96F"; // unique guid as a boundary value for multipart posts + + 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"] + && (kwArgs["backButton"] || kwArgs["back"] || kwArgs["changeUrl"] || kwArgs["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(kwArgs); + return true; + } + } + + // build this first for cache purposes + var url = kwArgs.url; + var query = ""; + if(kwArgs["formNode"]){ + var ta = kwArgs.formNode.getAttribute("action"); + if((ta)&&(!kwArgs["url"])){ url = ta; } + var tp = kwArgs.formNode.getAttribute("method"); + if((tp)&&(!kwArgs["method"])){ kwArgs.method = tp; } + query += dojo.io.encodeForm(kwArgs.formNode, kwArgs.encoding, kwArgs["formFilter"]); + } + + if(url.indexOf("#") > -1) { + dojo.debug("Warning: dojo.io.bind: stripping hash values from url:", url); + url = url.split("#")[0]; + } + + if(kwArgs["file"]){ + // force post for file transfer + kwArgs.method = "post"; + } + + if(!kwArgs["method"]){ + kwArgs.method = "get"; + } + + // guess the multipart value + if(kwArgs.method.toLowerCase() == "get"){ + // GET cannot use multipart + kwArgs.multipart = false; + }else{ + if(kwArgs["file"]){ + // enforce multipart when sending files + kwArgs.multipart = true; + }else if(!kwArgs["multipart"]){ + // default + kwArgs.multipart = false; + } + } + + if(kwArgs["backButton"] || kwArgs["back"] || kwArgs["changeUrl"]){ + dojo.undo.browser.addToHistory(kwArgs); + } + + var content = kwArgs["content"] || {}; + + if(kwArgs.sendTransport) { + content["dojo.transport"] = "xmlhttp"; + } + + do { // break-block + if(kwArgs.postContent){ + query = kwArgs.postContent; + break; + } + + if(content) { + query += dojo.io.argsFromMap(content, kwArgs.encoding); + } + + if(kwArgs.method.toLowerCase() == "get" || !kwArgs.multipart){ + break; + } + + var t = []; + if(query.length){ + var q = query.split("&"); + for(var i = 0; i < q.length; ++i){ + if(q[i].length){ + var p = q[i].split("="); + t.push( "--" + this.multipartBoundary, + "Content-Disposition: form-data; name=\"" + p[0] + "\"", + "", + p[1]); + } + } + } + + if(kwArgs.file){ + if(dojo.lang.isArray(kwArgs.file)){ + for(var i = 0; i < kwArgs.file.length; ++i){ + var o = kwArgs.file[i]; + t.push( "--" + this.multipartBoundary, + "Content-Disposition: form-data; name=\"" + o.name + "\"; filename=\"" + ("fileName" in o ? o.fileName : o.name) + "\"", + "Content-Type: " + ("contentType" in o ? o.contentType : "application/octet-stream"), + "", + o.content); + } + }else{ + var o = kwArgs.file; + t.push( "--" + this.multipartBoundary, + "Content-Disposition: form-data; name=\"" + o.name + "\"; filename=\"" + ("fileName" in o ? o.fileName : o.name) + "\"", + "Content-Type: " + ("contentType" in o ? o.contentType : "application/octet-stream"), + "", + o.content); + } + } + + if(t.length){ + t.push("--"+this.multipartBoundary+"--", ""); + query = t.join("\r\n"); + } + }while(false); + + // kwArgs.Connection = "close"; + + var async = kwArgs["sync"] ? false : true; + + var preventCache = kwArgs["preventCache"] || + (this.preventCache == true && kwArgs["preventCache"] != false); + var useCache = kwArgs["useCache"] == true || + (this.useCache == true && kwArgs["useCache"] != false ); + + // preventCache is browser-level (add query string junk), useCache + // is for the local cache. If we say preventCache, then don't attempt + // to look in the cache, but if useCache is true, we still want to cache + // the response + if(!preventCache && useCache){ + var cachedHttp = getFromCache(url, query, kwArgs.method); + if(cachedHttp){ + doLoad(kwArgs, cachedHttp, url, query, false); + return; + } + } + + // much of this is from getText, but reproduced here because we need + // more flexibility + var http = dojo.hostenv.getXmlhttpObject(kwArgs); + var received = false; + + // build a handler function that calls back to the handler obj + if(async){ + var startTime = + // FIXME: setting up this callback handler leaks on IE!!! + this.inFlight.push({ + "req": kwArgs, + "http": http, + "url": url, + "query": query, + "useCache": useCache, + "startTime": kwArgs.timeoutSeconds ? (new Date()).getTime() : 0 + }); + this.startWatchingInFlight(); + }else{ + // block async callbacks until sync is in, needed in khtml, others? + _this._blockAsync = true; + } + + if(kwArgs.method.toLowerCase() == "post"){ + // FIXME: need to hack in more flexible Content-Type setting here! + if (!kwArgs.user) { + http.open("POST", url, async); + }else{ + http.open("POST", url, async, kwArgs.user, kwArgs.password); + } + setHeaders(http, kwArgs); + http.setRequestHeader("Content-Type", kwArgs.multipart ? ("multipart/form-data; boundary=" + this.multipartBoundary) : + (kwArgs.contentType || "application/x-www-form-urlencoded")); + try{ + http.send(query); + }catch(e){ + if(typeof http.abort == "function"){ + http.abort(); + } + doLoad(kwArgs, {status: 404}, url, query, useCache); + } + }else{ + var tmpUrl = url; + if(query != "") { + tmpUrl += (tmpUrl.indexOf("?") > -1 ? "&" : "?") + query; + } + if(preventCache) { + tmpUrl += (dojo.string.endsWithAny(tmpUrl, "?", "&") + ? "" : (tmpUrl.indexOf("?") > -1 ? "&" : "?")) + "dojo.preventCache=" + new Date().valueOf(); + } + if (!kwArgs.user) { + http.open(kwArgs.method.toUpperCase(), tmpUrl, async); + }else{ + http.open(kwArgs.method.toUpperCase(), tmpUrl, async, kwArgs.user, kwArgs.password); + } + setHeaders(http, kwArgs); + try { + http.send(null); + }catch(e) { + if(typeof http.abort == "function"){ + http.abort(); + } + doLoad(kwArgs, {status: 404}, url, query, useCache); + } + } + + if( !async ) { + doLoad(kwArgs, http, url, query, useCache); + _this._blockAsync = false; + } + + kwArgs.abort = function(){ + try{// khtml doesent reset readyState on abort, need this workaround + http._aborted = true; + }catch(e){/*squelsh*/} + return http.abort(); + } + + return; + } + dojo.io.transports.addTransport("XMLHTTPTransport"); +} + +} + +dojo.provide("dojo.io.cookie"); + +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)){ + var d = new Date(); + d.setTime(d.getTime()+(days*24*60*60*1000)); + expires = d.toGMTString(); + } + value = escape(value); + document.cookie = name + "=" + value + ";" + + (expires != -1 ? " expires=" + expires + ";" : "") + + (path ? "path=" + path : "") + + (domain ? "; domain=" + domain : "") + + (secure ? "; secure" : ""); +} + +dojo.io.cookie.set = dojo.io.cookie.setCookie; + +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. + // I think taking the last one in the list takes the one from the + // deepest subdomain, which is what we're doing here. + var idx = document.cookie.lastIndexOf(name+'='); + if(idx == -1) { return null; } + var value = document.cookie.substring(idx+name.length+1); + var end = value.indexOf(';'); + if(end == -1) { end = value.length; } + value = value.substring(0, end); + value = unescape(value); + return value; //String +} + +dojo.io.cookie.get = dojo.io.cookie.getCookie; + +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( /*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(obj[prop] == null){ + delete cookie[prop]; + }else if((typeof obj[prop] == "string")||(typeof obj[prop] == "number")){ + cookie[prop] = obj[prop]; + } + } + prop = null; + for(var prop in cookie){ + pairs.push(escape(prop) + "=" + escape(cookie[prop])); + } + value = pairs.join("&"); + } + dojo.io.cookie.setCookie(name, value, days, path, domain, secure); +} + +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){ + values = {}; + var pairs = cookie.split("&"); + for(var i = 0; i < pairs.length; i++){ + var pair = pairs[i].split("="); + var value = pair[1]; + if( isNaN(value) ){ value = unescape(pair[1]); } + values[ unescape(pair[0]) ] = value; + } + } + return values; +} + +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){ + // FIXME: should we leave this around? + this.deleteCookie("__TestingYourBrowserForCookieSupport__"); + } + } + 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; } + +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.event.common"); + + + + + +// TODO: connection filter functions +// these are functions that accept a method invocation (like around +// advice) and return a boolean based on it. That value determines +// whether or not the connection proceeds. It could "feel" like around +// advice for those who know what it is (calling proceed() or not), +// but I think presenting it as a "filter" and/or calling it with the +// function args and not the MethodInvocation might make it more +// palletable to "normal" users than around-advice currently is +// TODO: execution scope mangling +// YUI's event facility by default executes listeners in the context +// of the source object. This is very odd, but should probably be +// supported as an option (both for the source and for the dest). It +// can be thought of as a connection-specific hitch(). +// TODO: more resiliency for 4+ arguments to connect() + +dojo.event = new function(){ + this._canTimeout = dojo.lang.isFunction(dj_global["setTimeout"])||dojo.lang.isAlien(dj_global["setTimeout"]); + + // FIXME: where should we put this method (not here!)? + function interpolateArgs(args, searchForNames){ + var dl = dojo.lang; + 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; + case 1: return; + case 2: + ao.srcFunc = args[0]; + ao.adviceFunc = args[1]; + break; + case 3: + if((dl.isObject(args[0]))&&(dl.isString(args[1]))&&(dl.isString(args[2]))){ + ao.adviceType = "after"; + ao.srcObj = args[0]; + ao.srcFunc = args[1]; + ao.adviceFunc = args[2]; + }else if((dl.isString(args[1]))&&(dl.isString(args[2]))){ + ao.srcFunc = args[1]; + ao.adviceFunc = args[2]; + }else 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 tmpName = dl.nameAnonFunc(args[2], ao.adviceObj, searchForNames); + ao.adviceFunc = tmpName; + }else if((dl.isFunction(args[0]))&&(dl.isObject(args[1]))&&(dl.isString(args[2]))){ + ao.adviceType = "after"; + ao.srcObj = dj_global; + var tmpName = dl.nameAnonFunc(args[0], ao.srcObj, searchForNames); + ao.srcFunc = tmpName; + ao.adviceObj = args[1]; + ao.adviceFunc = args[2]; + } + break; + case 4: + if((dl.isObject(args[0]))&&(dl.isObject(args[2]))){ + // we can assume that we've got an old-style "connect" from + // the sigslot school of event attachment. We therefore + // assume after-advice. + ao.adviceType = "after"; + ao.srcObj = args[0]; + ao.srcFunc = args[1]; + ao.adviceObj = args[2]; + ao.adviceFunc = args[3]; + }else if((dl.isString(args[0]))&&(dl.isString(args[1]))&&(dl.isObject(args[2]))){ + ao.adviceType = args[0]; + ao.srcObj = dj_global; + ao.srcFunc = args[1]; + ao.adviceObj = args[2]; + ao.adviceFunc = args[3]; + }else if((dl.isString(args[0]))&&(dl.isFunction(args[1]))&&(dl.isObject(args[2]))){ + ao.adviceType = args[0]; + ao.srcObj = dj_global; + var tmpName = dl.nameAnonFunc(args[1], dj_global, searchForNames); + ao.srcFunc = tmpName; + 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 tmpName = dl.nameAnonFunc(args[3], dj_global, searchForNames); + ao.adviceObj = dj_global; + ao.adviceFunc = tmpName; + }else if(dl.isObject(args[1])){ + ao.srcObj = args[1]; + ao.srcFunc = args[2]; + ao.adviceObj = dj_global; + ao.adviceFunc = args[3]; + }else if(dl.isObject(args[2])){ + ao.srcObj = dj_global; + ao.srcFunc = args[1]; + ao.adviceObj = args[2]; + ao.adviceFunc = args[3]; + }else{ + ao.srcObj = ao.adviceObj = ao.aroundObj = dj_global; + ao.srcFunc = args[1]; + ao.adviceFunc = args[2]; + ao.aroundFunc = args[3]; + } + break; + case 6: + ao.srcObj = args[1]; + ao.srcFunc = args[2]; + ao.adviceObj = args[3] + ao.adviceFunc = args[4]; + ao.aroundFunc = args[5]; + ao.aroundObj = dj_global; + break; + default: + ao.srcObj = args[1]; + ao.srcFunc = args[2]; + ao.adviceObj = args[3] + ao.adviceFunc = args[4]; + ao.aroundObj = args[5]; + ao.aroundFunc = args[6]; + 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 tmpName = dl.nameAnonFunc(ao.aroundFunc, ao.aroundObj, searchForNames); + ao.aroundFunc = tmpName; + } + + if(dl.isFunction(ao.srcFunc)){ + ao.srcFunc = dl.getNameInObj(ao.srcObj, ao.srcFunc); + } + + if(dl.isFunction(ao.adviceFunc)){ + ao.adviceFunc = dl.getNameInObj(ao.adviceObj, ao.adviceFunc); + } + + if((ao.aroundObj)&&(dl.isFunction(ao.aroundFunc))){ + ao.aroundFunc = dl.getNameInObj(ao.aroundObj, ao.aroundFunc); + } + + if(!ao.srcObj){ + dojo.raise("bad srcObj for srcFunc: "+ao.srcFunc); + } + if(!ao.adviceObj){ + dojo.raise("bad adviceObj for adviceFunc: "+ao.adviceFunc); + } + + if(!ao.adviceFunc){ + dojo.debug("bad adviceFunc for srcFunc: "+ao.srcFunc); + dojo.debugShallow(ao); + } + + return ao; + } + + this.connect = function(/*...*/){ + // summary: + // dojo.event.connect is the glue that holds most Dojo-based + // applications together. Most combinations of arguments are + // supported, with the connect() method attempting to disambiguate + // the implied types of positional parameters. The following will + // all work: + // dojo.event.connect("globalFunctionName1", "globalFunctionName2"); + // dojo.event.connect(functionReference1, functionReference2); + // dojo.event.connect("globalFunctionName1", functionReference2); + // dojo.event.connect(functionReference1, "globalFunctionName2"); + // dojo.event.connect(scope1, "functionName1", "globalFunctionName2"); + // dojo.event.connect("globalFunctionName1", scope2, "functionName2"); + // dojo.event.connect(scope1, "functionName1", scope2, "functionName2"); + // dojo.event.connect("after", scope1, "functionName1", scope2, "functionName2"); + // dojo.event.connect("before", scope1, "functionName1", scope2, "functionName2"); + // dojo.event.connect("around", scope1, "functionName1", + // scope2, "functionName2", + // aroundFunctionReference); + // dojo.event.connect("around", scope1, "functionName1", + // scope2, "functionName2", + // scope3, "aroundFunctionName"); + // dojo.event.connect("before-around", scope1, "functionName1", + // scope2, "functionName2", + // aroundFunctionReference); + // dojo.event.connect("after-around", scope1, "functionName1", + // scope2, "functionName2", + // aroundFunctionReference); + // dojo.event.connect("after-around", scope1, "functionName1", + // scope2, "functionName2", + // scope3, "aroundFunctionName"); + // dojo.event.connect("around", scope1, "functionName1", + // scope2, "functionName2", + // scope3, "aroundFunctionName", true, 30); + // dojo.event.connect("around", scope1, "functionName1", + // scope2, "functionName2", + // scope3, "aroundFunctionName", null, null, 10); + // adviceType: + // Optional. String. One of "before", "after", "around", + // "before-around", or "after-around". FIXME + // srcObj: + // the scope in which to locate/execute the named srcFunc. Along + // with srcFunc, this creates a way to dereference the function to + // call. So if the function in question is "foo.bar", the + // srcObj/srcFunc pair would be foo and "bar", where "bar" is a + // string and foo is an object reference. + // srcFunc: + // the name of the function to connect to. When it is executed, + // the listener being registered with this call will be called. + // The adviceType defines the call order between the source and + // the target functions. + // adviceObj: + // the scope in which to locate/execute the named adviceFunc. + // adviceFunc: + // the name of the function being conected to srcObj.srcFunc + // aroundObj: + // the scope in which to locate/execute the named aroundFunc. + // aroundFunc: + // the name of, or a reference to, the function that will be used + // to mediate the advice call. Around advice requires a special + // unary function that will be passed a "MethodInvocation" object. + // These objects have several important properties, namely: + // - args + // a mutable array of arguments to be passed into the + // wrapped function + // - proceed + // a function that "continues" the invocation. The result + // of this function is the return of the wrapped function. + // You can then manipulate this return before passing it + // back out (or take further action based on it). + // once: + // boolean that determines whether or not this connect() will + // create a new connection if an identical connect() has already + // been made. Defaults to "false". + // delay: + // an optional delay (in ms), as an integer, for dispatch of a + // listener after the source has been fired. + // rate: + // an optional rate throttling parameter (integer, in ms). When + // specified, this particular connection will not fire more than + // once in the interval specified by the rate + // adviceMsg: + // boolean. Should the listener have all the parameters passed in + // as a single argument? + + /* + ao.adviceType = args[0]; + ao.srcObj = args[1]; + ao.srcFunc = args[2]; + ao.adviceObj = args[3] + ao.adviceFunc = args[4]; + ao.aroundObj = args[5]; + ao.aroundFunc = args[6]; + ao.once = args[7]; + ao.delay = args[8]; + ao.rate = args[9]; + ao.adviceMsg = args[10]; + ao.maxCalls = args[11]; + */ + if(arguments.length == 1){ + 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 tmpAO = {}; + for(var x in ao){ + tmpAO[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); + // dojo.debug(src); + } + tmpAO.srcObj = src; + // dojo.debug(tmpAO.srcObj, tmpAO.srcFunc); + // dojo.debug(tmpAO.adviceObj, tmpAO.adviceFunc); + mjps.push(dojo.event.connect.call(dojo.event, tmpAO)); + }); + return mjps; + } + + // FIXME: just doing a "getForMethod()" seems to be enough to put this into infinite recursion!! + var mjp = dojo.event.MethodJoinPoint.getForMethod(ao.srcObj, ao.srcFunc); + if(ao.adviceFunc){ + var mjp2 = dojo.event.MethodJoinPoint.getForMethod(ao.adviceObj, ao.adviceFunc); + } + + mjp.kwAddAdvice(ao); + + // advanced users might want to fsck w/ the join point manually + return mjp; // a MethodJoinPoint object + } + + this.log = function(/*object or funcName*/ a1, /*funcName*/ a2){ + // summary: + // a function that will wrap and log all calls to the specified + // a1.a2() function. If only a1 is passed, it'll be used as a + // function or function name on the global context. Logging will + // be sent to dojo.debug + // a1: + // if a2 is passed, this should be an object. If not, it can be a + // function or function name. + // a2: + // a function name + var kwArgs; + if((arguments.length == 1)&&(typeof a1 == "object")){ + kwArgs = a1; + }else{ + kwArgs = { + srcObj: a1, + srcFunc: a2 + }; + } + kwArgs.adviceFunc = function(){ + var argsStr = []; + for(var x=0; x= this.jp_.around.length){ + return this.jp_.object[this.jp_.methodname].apply(this.jp_.object, this.args); + // return this.jp_.run_before_after(this.object, this.args); + }else{ + var ti = this.jp_.around[this.around_index]; + var mobj = ti[0]||dj_global; + var meth = ti[1]; + return mobj[meth].call(mobj, this); + } +} + + +dojo.event.MethodJoinPoint = function(/*Object*/obj, /*String*/funcName){ + this.object = obj||dj_global; + this.methodname = funcName; + this.methodfunc = this.object[funcName]; + this.squelch = false; + // this.before = []; + // this.after = []; + // this.around = []; +} + +dojo.event.MethodJoinPoint.getForMethod = function(/*Object*/obj, /*String*/funcName){ + // summary: + // "static" class function for returning a MethodJoinPoint from a + // scoped function. If one doesn't exist, one is created. + // obj: + // the scope to search for the function in + // funcName: + // the name of the function to return a MethodJoinPoint for + if(!obj){ obj = dj_global; } + var ofn = obj[funcName]; + if(!ofn){ + // supply a do-nothing method implementation + ofn = obj[funcName] = function(){}; + if(!obj[funcName]){ + // e.g. cannot add to inbuilt objects in IE6 + dojo.raise("Cannot set do-nothing method on that object "+funcName); + } + }else if((typeof ofn != "function")&&(!dojo.lang.isFunction(ofn))&&(!dojo.lang.isAlien(ofn))){ + // FIXME: should we throw an exception here instead? + return null; + } + // we hide our joinpoint instance in obj[funcName + '$joinpoint'] + var jpname = funcName + "$joinpoint"; + var jpfuncname = funcName + "$joinpoint$method"; + var joinpoint = obj[jpname]; + if(!joinpoint){ + var isNode = false; + if(dojo.event["browser"]){ + if( (obj["attachEvent"])|| + (obj["nodeType"])|| + (obj["addEventListener"]) ){ + isNode = true; + dojo.event.browser.addClobberNodeAttrs(obj, [jpname, jpfuncname, funcName]); + } + } + var origArity = ofn.length; + obj[jpfuncname] = ofn; + // joinpoint = obj[jpname] = new dojo.event.MethodJoinPoint(obj, funcName); + joinpoint = obj[jpname] = new dojo.event.MethodJoinPoint(obj, jpfuncname); + + if(!isNode){ + obj[funcName] = function(){ + // var args = []; + // for(var x=0; x -1){ + if(maxCount == 0){ + return; + } + marr[7]--; + } + var undef; + + var to = { + args: [], + jp_: this, + object: obj, + proceed: function(){ + return callObj[callFunc].apply(callObj, to.args); + } + }; + to.args = aargs; + + var delay = parseInt(marr[4]); + var hasDelay = ((!isNaN(delay))&&(marr[4]!==null)&&(typeof marr[4] != "undefined")); + if(marr[5]){ + var rate = parseInt(marr[5]); + var cur = new Date(); + var timerSet = false; + if((marr["last"])&&((cur-marr.last)<=rate)){ + if(dojo.event._canTimeout){ + if(marr["delayTimer"]){ + clearTimeout(marr.delayTimer); + } + var tod = parseInt(rate*2); // is rate*2 naive? + var mcpy = dojo.lang.shallowCopy(marr); + marr.delayTimer = setTimeout(function(){ + // FIXME: on IE at least, event objects from the + // browser can go out of scope. How (or should?) we + // deal with it? + mcpy[5] = 0; + unrollAdvice(mcpy); + }, tod); + } + return; + }else{ + marr.last = cur; + } + } + + // FIXME: need to enforce rates for a connection here! + + if(aroundFunc){ + // NOTE: around advice can't delay since we might otherwise depend + // on execution order! + aroundObj[aroundFunc].call(aroundObj, to); + }else{ + // var tmjp = dojo.event.MethodJoinPoint.getForMethod(obj, methname); + if((hasDelay)&&((dojo.render.html)||(dojo.render.svg))){ // FIXME: the render checks are grotty! + dj_global["setTimeout"](function(){ + if(msg){ + callObj[callFunc].call(callObj, to); + }else{ + callObj[callFunc].apply(callObj, args); + } + }, delay); + }else{ // many environments can't support delay! + if(msg){ + callObj[callFunc].call(callObj, to); + }else{ + callObj[callFunc].apply(callObj, args); + } + } + } + }; + + var unRollSquelch = function(){ + if(this.squelch){ + try{ + return unrollAdvice.apply(this, arguments); + }catch(e){ + dojo.debug(e); + } + }else{ + return unrollAdvice.apply(this, arguments); + } + }; + + if((this["before"])&&(this.before.length>0)){ + // pass a cloned array, if this event disconnects this event forEach on this.before wont work + dojo.lang.forEach(this.before.concat(new Array()), unRollSquelch); + } + + var result; + try{ + if((this["around"])&&(this.around.length>0)){ + var mi = new dojo.event.MethodInvocation(this, obj, args); + result = mi.proceed(); + }else if(this.methodfunc){ + result = 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)){ + // see comment on this.before above + dojo.lang.forEach(this.after.concat(new Array()), unRollSquelch); + } + + return (this.methodfunc) ? result : null; + }, + + getArr: function(/*String*/kind){ + // summary: return a list of listeners of the past "kind" + // kind: + // can be one of: "before", "after", "around", "before-around", or + // "after-around" + var type = "after"; + // FIXME: we should be able to do this through props or Array.in() + if((typeof kind == "string")&&(kind.indexOf("before")!=-1)){ + type = "before"; + }else if(kind=="around"){ + type = "around"; + } + if(!this[type]){ this[type] = []; } + return this[type]; // Array + }, + + kwAddAdvice: function(/*Object*/args){ + // summary: + // adds advice to the joinpoint with arguments in a map + // args: + // An object that can have the following properties: + // - adviceType + // - adviceObj + // - adviceFunc + // - aroundObj + // - aroundFunc + // - once + // - delay + // - rate + // - adviceMsg + // - maxCalls + 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( thisAdviceObj, thisAdvice, + thisAroundObj, thisAround, + adviceType, precedence, + once, delay, rate, asMessage, + maxCalls){ + // summary: + // add advice to this joinpoint using positional parameters + // thisAdviceObj: + // the scope in which to locate/execute the named adviceFunc. + // thisAdviceFunc: + // the name of the function being conected + // thisAroundObj: + // the scope in which to locate/execute the named aroundFunc. + // thisAroundFunc: + // the name of the function that will be used to mediate the + // advice call. + // adviceType: + // Optional. String. One of "before", "after", "around", + // "before-around", or "after-around". FIXME + // once: + // boolean that determines whether or not this advice will create + // a new connection if an identical advice set has already been + // provided. Defaults to "false". + // delay: + // an optional delay (in ms), as an integer, for dispatch of a + // listener after the source has been fired. + // rate: + // an optional rate throttling parameter (integer, in ms). When + // specified, this particular connection will not fire more than + // once in the interval specified by the rate + // adviceMsg: + // boolean. Should the listener have all the parameters passed in + // as a single argument? + // maxCalls: + // Integer. The maximum number of times this connection can be + // used before being auto-disconnected. -1 signals that the + // connection should never be disconnected. + var arr = this.getArr(adviceType); + if(!arr){ + dojo.raise("bad this: " + this); + } + + var ao = [thisAdviceObj, thisAdvice, thisAroundObj, thisAround, delay, rate, asMessage, maxCalls]; + + if(once){ + if(this.hasAdvice(thisAdviceObj, thisAdvice, adviceType, arr) >= 0){ + return; + } + } + + if(precedence == "first"){ + arr.unshift(ao); + }else{ + arr.push(ao); + } + }, + + hasAdvice: function(thisAdviceObj, thisAdvice, adviceType, arr){ + // summary: + // returns the array index of the first existing connection + // betweened the passed advice and this joinpoint. Will be -1 if + // none exists. + // thisAdviceObj: + // the scope in which to locate/execute the named adviceFunc. + // thisAdviceFunc: + // the name of the function being conected + // adviceType: + // Optional. String. One of "before", "after", "around", + // "before-around", or "after-around". FIXME + // arr: + // Optional. The list of advices to search. Will be found via + // adviceType if not passed + if(!arr){ arr = this.getArr(adviceType); } + var ind = -1; + for(var x=0; x=0; i=i-1){ + var el = na[i]; + try{ + if(el && el["__clobberAttrs__"]){ + for(var j=0; j= 65 && unifiedCharCode <= 90 && evt.shiftKey == false){ + unifiedCharCode += 32; + } + if(unifiedCharCode >= 1 && unifiedCharCode <= 26 && evt.ctrlKey){ + unifiedCharCode += 96; // 001-032 = ctrl+[a-z] + } + evt.key = String.fromCharCode(unifiedCharCode); + } + } + } else if(evt["type"] == "keypress"){ + if(dojo.render.html.opera){ + if(evt.which == 0){ + evt.key = evt.keyCode; + }else if(evt.which > 0){ + switch(evt.which){ + case evt.KEY_SHIFT: + case evt.KEY_CTRL: + case evt.KEY_ALT: + case evt.KEY_CAPS_LOCK: + case evt.KEY_NUM_LOCK: + case evt.KEY_SCROLL_LOCK: + break; + case evt.KEY_PAUSE: + case evt.KEY_TAB: + case evt.KEY_BACKSPACE: + case evt.KEY_ENTER: + case evt.KEY_ESCAPE: + evt.key = evt.which; + break; + default: + var unifiedCharCode = evt.which; + if((evt.ctrlKey || evt.altKey || evt.metaKey) && (evt.which >= 65 && evt.which <= 90 && evt.shiftKey == false)){ + unifiedCharCode += 32; + } + evt.key = String.fromCharCode(unifiedCharCode); + } + } + }else if(dojo.render.html.ie){ // catch some IE keys that are hard to get in keyDown + // key combinations were handled in onKeyDown + if(!evt.ctrlKey && !evt.altKey && evt.keyCode >= evt.KEY_SPACE){ + 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; + case 63233: evt.key = evt.KEY_DOWN_ARROW; break; + case 63234: evt.key = evt.KEY_LEFT_ARROW; 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://prtscr + case 63249://scrolllock + case 63289://numlock + break; + default: + 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; + } + } + } + if(dojo.render.html.ie){ + if(!evt.target){ evt.target = evt.srcElement; } + if(!evt.currentTarget){ evt.currentTarget = (sender ? sender : evt.srcElement); } + if(!evt.layerX){ evt.layerX = evt.offsetX; } + if(!evt.layerY){ evt.layerY = evt.offsetY; } + // FIXME: scroll position query is duped from dojo.html to avoid dependency on that entire module + // DONOT replace the following to use dojo.body(), in IE, document.documentElement should be used + // here rather than document.body + var doc = (evt.srcElement && evt.srcElement.ownerDocument) ? evt.srcElement.ownerDocument : document; + var docBody = ((dojo.render.html.ie55)||(doc["compatMode"] == "BackCompat")) ? doc.body : doc.documentElement; + if(!evt.pageX){ evt.pageX = evt.clientX + (docBody.scrollLeft || 0) } + if(!evt.pageY){ evt.pageY = evt.clientY + (docBody.scrollTop || 0) } + // mouseover + if(evt.type == "mouseover"){ evt.relatedTarget = evt.fromElement; } + // mouseout + if(evt.type == "mouseout"){ evt.relatedTarget = evt.toElement; } + this.currentEvent = evt; + evt.callListener = this.callListener; + evt.stopPropagation = this._stopPropagation; + evt.preventDefault = this._preventDefault; + } + return evt; // Event + } + + this.stopEvent = function(/*Event*/evt){ + // summary: + // prevents propigation and clobbers the default action of the + // passed event + // evt: Optional for IE. The native event object. + if(window.event){ + 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.gfx.color"); + + + +// TODO: rewrite the "x2y" methods to take advantage of the parsing +// abilities of the Color object. Also, beef up the Color +// object (as possible) to parse most common formats + +// takes an r, g, b, a(lpha) value, [r, g, b, a] array, "rgb(...)" string, hex string (#aaa, #aaaaaa, aaaaaaa) +dojo.gfx.color.Color = function(r, g, b, a) { + // dojo.debug("r:", r[0], "g:", r[1], "b:", r[2]); + if(dojo.lang.isArray(r)){ + this.r = r[0]; + this.g = r[1]; + this.b = r[2]; + this.a = r[3]||1.0; + }else if(dojo.lang.isString(r)){ + var rgb = dojo.gfx.color.extractRGB(r); + this.r = rgb[0]; + this.g = rgb[1]; + this.b = rgb[2]; + this.a = g||1.0; + }else if(r instanceof dojo.gfx.color.Color){ + // why does this create a new instance if we were passed one? + this.r = r.r; + this.b = r.b; + this.g = r.g; + this.a = r.a; + }else{ + this.r = r; + this.g = g; + this.b = b; + this.a = a; + } +} + +dojo.gfx.color.Color.fromArray = function(arr) { + return new dojo.gfx.color.Color(arr[0], arr[1], arr[2], arr[3]); +} + +dojo.extend(dojo.gfx.color.Color, { + toRgb: function(includeAlpha) { + if(includeAlpha) { + return this.toRgba(); + } else { + return [this.r, this.g, this.b]; + } + }, + toRgba: function() { + return [this.r, this.g, this.b, this.a]; + }, + toHex: function() { + return dojo.gfx.color.rgb2hex(this.toRgb()); + }, + toCss: function() { + return "rgb(" + this.toRgb().join() + ")"; + }, + toString: function() { + return this.toHex(); // decent default? + }, + blend: function(color, weight){ + var rgb = null; + if(dojo.lang.isArray(color)){ + rgb = color; + }else if(color instanceof dojo.gfx.color.Color){ + rgb = color.toRgb(); + }else{ + rgb = new dojo.gfx.color.Color(color).toRgb(); + } + return dojo.gfx.color.blend(this.toRgb(), rgb, weight); + } +}); + +dojo.gfx.color.named = { + white: [255,255,255], + black: [0,0,0], + red: [255,0,0], + green: [0,255,0], + lime: [0,255,0], + blue: [0,0,255], + navy: [0,0,128], + gray: [128,128,128], + silver: [192,192,192] +}; + +dojo.gfx.color.blend = function(a, b, weight){ + // summary: + // blend colors a and b (both as RGB array or hex strings) with weight + // from -1 to +1, 0 being a 50/50 blend + if(typeof a == "string"){ + return dojo.gfx.color.blendHex(a, b, weight); + } + if(!weight){ + weight = 0; + } + weight = Math.min(Math.max(-1, weight), 1); + + // alex: this interface blows. + // map -1 to 1 to the range 0 to 1 + weight = ((weight + 1)/2); + + var c = []; + + // var stop = (1000*weight); + for(var x = 0; x < 3; x++){ + c[x] = parseInt( b[x] + ( (a[x] - b[x]) * weight) ); + } + return c; +} + +// very convenient blend that takes and returns hex values +// (will get called automatically by blend when blend gets strings) +dojo.gfx.color.blendHex = function(a, b, weight) { + return dojo.gfx.color.rgb2hex(dojo.gfx.color.blend(dojo.gfx.color.hex2rgb(a), dojo.gfx.color.hex2rgb(b), weight)); +} + +// get RGB array from css-style color declarations +dojo.gfx.color.extractRGB = function(color) { + var hex = "0123456789abcdef"; + color = color.toLowerCase(); + if( color.indexOf("rgb") == 0 ) { + var matches = color.match(/rgba*\((\d+), *(\d+), *(\d+)/i); + var ret = matches.splice(1, 3); + return ret; + } else { + var colors = dojo.gfx.color.hex2rgb(color); + if(colors) { + return colors; + } else { + // named color (how many do we support?) + return dojo.gfx.color.named[color] || [255, 255, 255]; + } + } +} + +dojo.gfx.color.hex2rgb = function(hex) { + var hexNum = "0123456789ABCDEF"; + var rgb = new Array(3); + if( hex.indexOf("#") == 0 ) { hex = hex.substring(1); } + hex = hex.toUpperCase(); + if(hex.replace(new RegExp("["+hexNum+"]", "g"), "") != "") { + return null; + } + if( hex.length == 3 ) { + rgb[0] = hex.charAt(0) + hex.charAt(0) + rgb[1] = hex.charAt(1) + hex.charAt(1) + rgb[2] = hex.charAt(2) + hex.charAt(2); + } else { + rgb[0] = hex.substring(0, 2); + rgb[1] = hex.substring(2, 4); + rgb[2] = hex.substring(4); + } + for(var i = 0; i < rgb.length; i++) { + rgb[i] = hexNum.indexOf(rgb[i].charAt(0)) * 16 + hexNum.indexOf(rgb[i].charAt(1)); + } + return rgb; +} + +dojo.gfx.color.rgb2hex = function(r, g, b) { + if(dojo.lang.isArray(r)) { + g = r[1] || 0; + b = r[2] || 0; + r = r[0] || 0; + } + var ret = dojo.lang.map([r, g, b], function(x) { + x = new Number(x); + var s = x.toString(16); + while(s.length < 2) { s = "0" + s; } + return s; + }); + ret.unshift("#"); + return ret.join(""); +} + +dojo.provide("dojo.lfx.Animation"); + + + +/* + Animation package based on Dan Pupius' work: http://pupius.co.uk/js/Toolkit.Drawing.js +*/ +dojo.lfx.Line = function(/*int*/ start, /*int*/ end){ + // summary: dojo.lfx.Line is the object used to generate values + // from a start value to an end value + this.start = start; + this.end = end; + if(dojo.lang.isArray(start)){ + /* start: Array + end: Array + pId: a */ + var diff = []; + dojo.lang.forEach(this.start, function(s,i){ + diff[i] = this.end[i] - s; + }, this); + + this.getValue = function(/*float*/ n){ + var res = []; + dojo.lang.forEach(this.start, function(s, i){ + res[i] = (diff[i] * n) + s; + }, this); + return res; // Array + } + }else{ + var diff = end - start; + + this.getValue = function(/*float*/ n){ + // summary: returns the point on the line + // n: a floating point number greater than 0 and less than 1 + return (diff * n) + this.start; // Decimal + } + } +} + +if((dojo.render.html.khtml)&&(!dojo.render.html.safari)){ + // the cool kids are obviously not using konqueror... + // found a very wierd bug in floats constants, 1.5 evals as 1 + // seems somebody mixed up ints and floats in 3.5.4 ?? + // FIXME: investigate more and post a KDE bug (Fredrik) + dojo.lfx.easeDefault = function(/*Decimal?*/ n){ + // summary: Returns the point for point n on a sin wave. + return (parseFloat("0.5")+((Math.sin( (n+parseFloat("1.5")) * Math.PI))/2)); + } +}else{ + dojo.lfx.easeDefault = function(/*Decimal?*/ n){ + return (0.5+((Math.sin( (n+1.5) * Math.PI))/2)); + } +} + +dojo.lfx.easeIn = function(/*Decimal?*/ n){ + // summary: returns the point on an easing curve + // n: a floating point number greater than 0 and less than 1 + return Math.pow(n, 3); +} + +dojo.lfx.easeOut = function(/*Decimal?*/ n){ + // summary: returns the point on the line + // n: a floating point number greater than 0 and less than 1 + return ( 1 - Math.pow(1 - n, 3) ); +} + +dojo.lfx.easeInOut = function(/*Decimal?*/ n){ + // summary: returns the point on the line + // n: a floating point number greater than 0 and less than 1 + return ( (3 * Math.pow(n, 2)) - (2 * Math.pow(n, 3)) ); +} + +dojo.lfx.IAnimation = function(){ + // summary: dojo.lfx.IAnimation is an interface that implements + // commonly used functions of animation objects +} +dojo.lang.extend(dojo.lfx.IAnimation, { + // public properties + curve: null, + duration: 1000, + easing: null, + repeatCount: 0, + rate: 10, + + // events + handler: null, + beforeBegin: null, + onBegin: null, + onAnimate: null, + onEnd: null, + onPlay: null, + onPause: null, + onStop: null, + + // public methods + play: null, + pause: null, + stop: null, + + connect: function(/*Event*/ evt, /*Object*/ scope, /*Function*/ newFunc){ + // summary: Convenience function. Quickly connect to an event + // of this object and save the old functions connected to it. + // evt: The name of the event to connect to. + // scope: the scope in which to run newFunc. + // newFunc: the function to run when evt is fired. + if(!newFunc){ + /* scope: Function + newFunc: null + pId: f */ + newFunc = scope; + scope = this; + } + newFunc = dojo.lang.hitch(scope, newFunc); + var oldFunc = this[evt]||function(){}; + this[evt] = function(){ + var ret = oldFunc.apply(this, arguments); + newFunc.apply(this, arguments); + return ret; + } + return this; // dojo.lfx.IAnimation + }, + + fire: function(/*Event*/ evt, /*Array*/ args){ + // summary: Convenience function. Fire event "evt" and pass it + // the arguments specified in "args". + // evt: The event to fire. + // args: The arguments to pass to the event. + if(this[evt]){ + this[evt].apply(this, (args||[])); + } + return this; // dojo.lfx.IAnimation + }, + + repeat: function(/*int*/ count){ + // summary: Set the repeat count of this object. + // count: How many times to repeat the animation. + this.repeatCount = count; + return this; // dojo.lfx.IAnimation + }, + + // private properties + _active: false, + _paused: false +}); + +dojo.lfx.Animation = function( /*Object*/ handlers, + /*int*/ duration, + /*dojo.lfx.Line*/ curve, + /*function*/ easing, + /*int*/ repeatCount, + /*int*/ rate){ + // summary + // a generic animation object that fires callbacks into it's handlers + // object at various states + // handlers: { handler: Function?, onstart: Function?, onstop: Function?, onanimate: Function? } + dojo.lfx.IAnimation.call(this); + if(dojo.lang.isNumber(handlers)||(!handlers && duration.getValue)){ + // no handlers argument: + rate = repeatCount; + repeatCount = easing; + easing = curve; + curve = duration; + duration = handlers; + handlers = null; + }else if(handlers.getValue||dojo.lang.isArray(handlers)){ + // no handlers or duration: + rate = easing; + repeatCount = curve; + easing = duration; + curve = handlers; + duration = null; + handlers = null; + } + if(dojo.lang.isArray(curve)){ + /* curve: Array + pId: a */ + this.curve = new dojo.lfx.Line(curve[0], curve[1]); + }else{ + this.curve = curve; + } + if(duration != null && duration > 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(easing && dojo.lang.isFunction(easing)){ + this.easing=easing; + } +} +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; + } + 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. + 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 + } + 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.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.Animation + } +}); + +dojo.lfx.Combine = function(/*dojo.lfx.IAnimation...*/ animations){ + // summary: An animation object to play animations passed to it at the same time. + 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 */ + anims = anims[0]; + } + + 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.lfx.Chain = function(/*dojo.lfx.IAnimation...*/ animations) { + // summary: An animation object to play animations passed to it + // one after another. + 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 */ + anims = anims[0]; + } + + var _this = this; + 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"); }) ); + } + }, 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.lfx.combine = function(/*dojo.lfx.IAnimation...*/ animations){ + // summary: Convenience function. Returns a dojo.lfx.Combine created + // using the animations passed in. + var anims = arguments; + if(dojo.lang.isArray(arguments[0])){ + /* animations: dojo.lfx.IAnimation[] + pId: a */ + 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. + var anims = arguments; + if(dojo.lang.isArray(arguments[0])){ + /* animations: dojo.lfx.IAnimation[] + pId: a */ + anims = arguments[0]; + } + if(anims.length == 1){ return anims[0]; } + return new dojo.lfx.Chain(anims); // dojo.lfx.Combine +} + +dojo.provide("dojo.html.common"); + + + +dojo.lang.mixin(dojo.html, dojo.dom); + +dojo.html.body = function(){ + dojo.deprecated("dojo.html.body() moved to dojo.body()", "0.5"); + return dojo.body(); +} + +// FIXME: we are going to assume that we can throw any and every rendering +// engine into the IE 5.x box model. In Mozilla, we do this w/ CSS. +// Need to investigate for KHTML and Opera + +dojo.html.getEventTarget = function(/* DOMEvent */evt){ + // summary + // Returns the target of an event + if(!evt) { evt = dojo.global().event || {} }; + var t = (evt.srcElement ? evt.srcElement : (evt.target ? evt.target : null)); + while((t)&&(t.nodeType!=1)){ t = t.parentNode; } + return t; // HTMLElement +} + +dojo.html.getViewport = function(){ + // summary + // Returns the dimensions of the viewable area of a browser window + var _window = dojo.global(); + var _document = dojo.doc(); + var w = 0; + var h = 0; + + if(dojo.render.html.mozilla){ + // mozilla + w = _document.documentElement.clientWidth; + h = _window.innerHeight; + }else if(!dojo.render.html.opera && _window.innerWidth){ + //in opera9, dojo.body().clientWidth should be used, instead + //of window.innerWidth/document.documentElement.clientWidth + //so we have to check whether it is opera + w = _window.innerWidth; + h = _window.innerHeight; + } else if (!dojo.render.html.opera && dojo.exists(_document, "documentElement.clientWidth")){ + // IE6 Strict + var w2 = _document.documentElement.clientWidth; + // this lets us account for scrollbars + if(!w || w2 && w2 < w) { + w = w2; + } + h = _document.documentElement.clientHeight; + } else if (dojo.body().clientWidth){ + // IE, Opera + w = dojo.body().clientWidth; + h = dojo.body().clientHeight; + } + return { width: w, height: h }; // object +} + +dojo.html.getScroll = function(){ + // summary + // Returns the scroll position of the document + var _window = dojo.global(); + var _document = dojo.doc(); + var top = _window.pageYOffset || _document.documentElement.scrollTop || dojo.body().scrollTop || 0; + var left = _window.pageXOffset || _document.documentElement.scrollLeft || dojo.body().scrollLeft || 0; + return { + top: top, + left: left, + offset:{ x: left, y: top } // note the change, NOT an Array with added properties. + }; // object +} + +dojo.html.getParentByType = function(/* HTMLElement */node, /* string */type) { + // summary + // Returns the first ancestor of node with tagName type. + var _document = dojo.doc(); + var parent = dojo.byId(node); + type = type.toLowerCase(); + while((parent)&&(parent.nodeName.toLowerCase()!=type)){ + if(parent==(_document["body"]||_document["documentElement"])){ + return null; + } + parent = parent.parentNode; + } + return parent; // HTMLElement +} + +dojo.html.getAttribute = function(/* HTMLElement */node, /* string */attr){ + // summary + // Returns the value of attribute attr from node. + node = dojo.byId(node); + // FIXME: need to add support for attr-specific accessors + if((!node)||(!node.getAttribute)){ + // if(attr !== 'nwType'){ + // alert("getAttr of '" + attr + "' with bad node"); + // } + return null; + } + var ta = typeof attr == 'string' ? attr : new String(attr); + + // first try the approach most likely to succeed + var v = node.getAttribute(ta.toUpperCase()); + if((v)&&(typeof v == 'string')&&(v!="")){ + return v; // string + } + + // try returning the attributes value, if we couldn't get it as a string + if(v && v.value){ + return v.value; // string + } + + // this should work on Opera 7, but it's a little on the crashy side + if((node.getAttributeNode)&&(node.getAttributeNode(ta))){ + return (node.getAttributeNode(ta)).value; // string + }else if(node.getAttribute(ta)){ + return node.getAttribute(ta); // string + }else if(node.getAttribute(ta.toLowerCase())){ + return node.getAttribute(ta.toLowerCase()); // string + } + return null; // string +} + +dojo.html.hasAttribute = function(/* HTMLElement */node, /* string */attr){ + // summary + // Determines whether or not the specified node carries a value for the attribute in question. + return dojo.html.getAttribute(dojo.byId(node), attr) ? true : false; // boolean +} + +dojo.html.getCursorPosition = function(/* DOMEvent */e){ + // summary + // Returns the mouse position relative to the document (not the viewport). + // For example, if you have a document that is 10000px tall, + // but your browser window is only 100px tall, + // if you scroll to the bottom of the document and call this function it + // will return {x: 0, y: 10000} + // NOTE: for events delivered via dojo.event.connect() and/or dojoAttachEvent (for widgets), + // you can just access evt.pageX and evt.pageY, rather than calling this function. + e = e || dojo.global().event; + var cursor = {x:0, y:0}; + if(e.pageX || e.pageY){ + cursor.x = e.pageX; + cursor.y = e.pageY; + }else{ + var de = dojo.doc().documentElement; + var db = dojo.body(); + cursor.x = e.clientX + ((de||db)["scrollLeft"]) - ((de||db)["clientLeft"]); + cursor.y = e.clientY + ((de||db)["scrollTop"]) - ((de||db)["clientTop"]); + } + return cursor; // object +} + +dojo.html.isTag = function(/* HTMLElement */node) { + // summary + // Like dojo.dom.isTag, except case-insensitive + node = dojo.byId(node); + if(node && node.tagName) { + for (var i=1; i, + //which will be treated as an external javascript file in IE + var xscript = dojo.doc().createElement('script'); + xscript.src = "javascript:'dojo.html.createExternalElement=function(doc, tag){ return doc.createElement(tag); }'"; + dojo.doc().getElementsByTagName("head")[0].appendChild(xscript); + })(); + } +}else{ + //for other browsers, simply use document.createElement + //is enough + dojo.html.createExternalElement = function(/* HTMLDocument */doc, /* string */tag){ + // summary + // Creates an element in the HTML document, here for ActiveX activation workaround. + return doc.createElement(tag); // HTMLElement + } +} + +dojo.html._callDeprecated = function(inFunc, replFunc, args, argName, retValue){ + dojo.deprecated("dojo.html." + inFunc, + "replaced by dojo.html." + replFunc + "(" + (argName ? "node, {"+ argName + ": " + argName + "}" : "" ) + ")" + (retValue ? "." + retValue : ""), "0.5"); + var newArgs = []; + if(argName){ var argsIn = {}; argsIn[argName] = args[1]; newArgs.push(args[0]); newArgs.push(argsIn); } + else { newArgs = args } + var ret = dojo.html[replFunc].apply(dojo.html, args); + if(retValue){ return ret[retValue]; } + else { return ret; } +} + +dojo.html.getViewportWidth = function(){ + return dojo.html._callDeprecated("getViewportWidth", "getViewport", arguments, null, "width"); +} +dojo.html.getViewportHeight = function(){ + return dojo.html._callDeprecated("getViewportHeight", "getViewport", arguments, null, "height"); +} +dojo.html.getViewportSize = function(){ + return dojo.html._callDeprecated("getViewportSize", "getViewport", arguments); +} +dojo.html.getScrollTop = function(){ + return dojo.html._callDeprecated("getScrollTop", "getScroll", arguments, null, "top"); +} +dojo.html.getScrollLeft = function(){ + return dojo.html._callDeprecated("getScrollLeft", "getScroll", arguments, null, "left"); +} +dojo.html.getScrollOffset = function(){ + return dojo.html._callDeprecated("getScrollOffset", "getScroll", arguments, null, "offset"); +} + +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 + 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 module + // description: Examples: dojo.uri.moduleUri("dojo.widget","templates/template.html"), or dojo.uri.moduleUri("acme","images/small.png") + var loc = dojo.hostenv.getModuleSymbols(module).join('/'); + if(!loc){ + return null; + } + if(loc.lastIndexOf("/") != loc.length-1){ + loc += "/"; + } + + //If the path is an absolute path (starts with a / or is on another domain/xdomain) + //then don't add the baseScriptUri. + 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 (/*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 + 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 + 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; } + 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; } + } + } + relobj.path = segs.join("/"); + } + } + } + + uri = ""; + 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; } + } + + this.uri = uri.toString(); + + // break the uri into its main components + var 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.query = r[7] || (r[6] ? "" : 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; } + } +}; + +dojo.provide("dojo.html.style"); + + + +dojo.html.getClass = function(/* HTMLElement */node){ + // summary + // Returns the string value of the list of CSS classes currently assigned directly + // to the node in question. Returns an empty string if no class attribute is found; + 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, ""); // string +} + +dojo.html.getClasses = function(/* HTMLElement */node) { + // summary + // Returns an array of CSS classes currently assigned directly to the node in question. + // Returns an empty array if no classes are found; + var c = dojo.html.getClass(node); + return (c == "") ? [] : c.split(/\s+/g); // array +} + +dojo.html.hasClass = function(/* HTMLElement */node, /* string */classname){ + // summary + // Returns whether or not the specified classname is a portion of the + // class list currently applied to the node. Does not cover cascaded + // styles, only classes directly applied to the node. + return (new RegExp('(^|\\s+)'+classname+'(\\s+|$)')).test(dojo.html.getClass(node)) // boolean +} + +dojo.html.prependClass = function(/* HTMLElement */node, /* string */classStr){ + // summary + // Adds the specified class to the beginning of the class list on the + // passed node. This gives the specified class the highest precidence + // when style cascading is calculated for the node. Returns true or + // false; indicating success or failure of the operation, respectively. + classStr += " " + dojo.html.getClass(node); + return dojo.html.setClass(node, classStr); // boolean +} + +dojo.html.addClass = function(/* HTMLElement */node, /* string */classStr){ + // summary + // Adds the specified class to the end of the class list on the + // passed &node;. Returns &true; or &false; indicating success or failure. + if (dojo.html.hasClass(node, classStr)) { + return false; + } + classStr = (dojo.html.getClass(node) + " " + classStr).replace(/^\s+|\s+$/g,""); + return dojo.html.setClass(node, classStr); // boolean +} + +dojo.html.setClass = function(/* HTMLElement */node, /* string */classStr){ + // summary + // Clobbers the existing list of classes for the node, replacing it with + // the list given in the 2nd argument. Returns true or false + // indicating success or failure. + node = dojo.byId(node); + var cs = new String(classStr); + try{ + if(typeof node.className == "string"){ + node.className = cs; + }else if(node.setAttribute){ + node.setAttribute("class", classStr); + node.className = cs; + }else{ + return false; + } + }catch(e){ + dojo.debug("dojo.html.setClass() failed", e); + } + return true; +} + +dojo.html.removeClass = function(/* HTMLElement */node, /* string */classStr, /* boolean? */allowPartialMatches){ + // summary + // Removes the className from the node;. Returns true or false indicating success or failure. + try{ + if (!allowPartialMatches) { + var newcs = dojo.html.getClass(node).replace(new RegExp('(^|\\s+)'+classStr+'(\\s+|$)'), "$1$2"); + } else { + var newcs = dojo.html.getClass(node).replace(classStr,''); + } + dojo.html.setClass(node, newcs); + }catch(e){ + dojo.debug("dojo.html.removeClass() failed", e); + } + return true; // boolean +} + +dojo.html.replaceClass = function(/* HTMLElement */node, /* string */newClass, /* string */oldClass) { + // summary + // Replaces 'oldClass' and adds 'newClass' to node + dojo.html.removeClass(node, oldClass); + dojo.html.addClass(node, newClass); +} + +// Enum type for getElementsByClass classMatchType arg: +dojo.html.classMatchType = { + ContainsAll : 0, // all of the classes are part of the node's class (default) + ContainsAny : 1, // any of the classes are part of the node's class + IsOnly : 2 // only all of the classes are part of the node's class +} + + +dojo.html.getElementsByClass = function( + /* string */classStr, + /* HTMLElement? */parent, + /* string? */nodeType, + /* integer? */classMatchType, + /* boolean? */useNonXpath +){ + // summary + // Returns an array of nodes for the given classStr, children of a + // parent, and optionally of a certain nodeType + // FIXME: temporarily set to false because of several dojo tickets related + // to the xpath version not working consistently in firefox. + useNonXpath = false; + var _document = dojo.doc(); + parent = dojo.byId(parent) || _document; + var classes = classStr.split(/\s+/g); + var nodes = []; + if( classMatchType != 1 && classMatchType != 2 ) classMatchType = 0; // make it enum + var reClass = new RegExp("(\\s|^)((" + classes.join(")|(") + "))(\\s|$)"); + var srtLength = classes.join(" ").length; + var candidateNodes = []; + + if(!useNonXpath && _document.evaluate) { // supports dom 3 xpath + var xpath = ".//" + (nodeType || "*") + "[contains("; + if(classMatchType != dojo.html.classMatchType.ContainsAny){ + xpath += "concat(' ',@class,' '), ' " + + classes.join(" ') and contains(concat(' ',@class,' '), ' ") + + " ')"; + if (classMatchType == 2) { + xpath += " and string-length(@class)="+srtLength+"]"; + }else{ + xpath += "]"; + } + }else{ + xpath += "concat(' ',@class,' '), ' " + + classes.join(" ') or contains(concat(' ',@class,' '), ' ") + + " ')]"; + } + var xpathResult = _document.evaluate(xpath, parent, null, XPathResult.ANY_TYPE, null); + var result = xpathResult.iterateNext(); + while(result){ + try{ + candidateNodes.push(result); + result = xpathResult.iterateNext(); + }catch(e){ break; } + } + return candidateNodes; // NodeList + }else{ + if(!nodeType){ + nodeType = "*"; + } + candidateNodes = parent.getElementsByTagName(nodeType); + + var node, i = 0; + outer: + while(node = candidateNodes[i++]){ + var nodeClasses = dojo.html.getClasses(node); + if(nodeClasses.length == 0){ continue outer; } + var matches = 0; + + for(var j = 0; j < nodeClasses.length; j++){ + if(reClass.test(nodeClasses[j])){ + if(classMatchType == dojo.html.classMatchType.ContainsAny){ + nodes.push(node); + continue outer; + }else{ + matches++; + } + }else{ + if(classMatchType == dojo.html.classMatchType.IsOnly){ + continue outer; + } + } + } + + if(matches == classes.length){ + if( (classMatchType == dojo.html.classMatchType.IsOnly)&& + (matches == nodeClasses.length)){ + nodes.push(node); + }else if(classMatchType == dojo.html.classMatchType.ContainsAll){ + nodes.push(node); + } + } + } + return nodes; // NodeList + } +} +dojo.html.getElementsByClassName = dojo.html.getElementsByClass; + +dojo.html.toCamelCase = function(/* string */selector){ + // summary + // Translates a CSS selector string to a camel-cased one. + 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 +} + +dojo.html.toSelectorCase = function(/* string */selector){ + // summary + // Translates a camel cased string to a selector cased one. + return selector.replace(/([A-Z])/g, "-$1" ).toLowerCase(); // string +} + +if (dojo.render.html.ie) { + // IE branch + dojo.html.getComputedStyle = function(/*HTMLElement|String*/node, /*String*/property, /*String*/value) { + // summary + // Get the computed style value for style "property" on "node" (IE). + node = dojo.byId(node); // FIXME: remove ability to access nodes by id for this time-critical function + if(!node || !node.style){return value;} + // FIXME: standardize on camel-case input to improve speed + return node.currentStyle[dojo.html.toCamelCase(property)]; // String + } + // SJM: getComputedStyle should be abandoned and replaced with the below function. + // All our supported browsers can return CSS2 compliant CssStyleDeclaration objects + // which can be queried directly for multiple styles. + dojo.html.getComputedStyles = function(/*HTMLElement*/node) { + // summary + // Get a style object containing computed styles for HTML Element node (IE). + return node.currentStyle; // CSSStyleDeclaration + } +} else { + // non-IE branch + dojo.html.getComputedStyle = function(/*HTMLElement|String*/node, /*String*/property, /*Any*/value) { + // summary + // Get the computed style value for style "property" on "node" (non-IE). + node = dojo.byId(node); + if(!node || !node.style){return value;} + var s = document.defaultView.getComputedStyle(node, null); + // s may be null on Safari + return (s&&s[dojo.html.toCamelCase(property)])||''; // String + } + // SJM: getComputedStyle should be abandoned and replaced with the below function. + // All our supported browsers can return CSS2 compliant CssStyleDeclaration objects + // which can be queried directly for multiple styles. + dojo.html.getComputedStyles = function(node) { + // summary + // Get a style object containing computed styles for HTML Element node (non-IE). + return document.defaultView.getComputedStyle(node, null); // CSSStyleDeclaration + } +} + +dojo.html.getStyleProperty = function(/* HTMLElement */node, /* string */cssSelector){ + // summary + // Returns the value of the passed style + node = dojo.byId(node); + return (node && node.style ? node.style[dojo.html.toCamelCase(cssSelector)] : undefined); // string +} + +dojo.html.getStyle = function(/* HTMLElement */node, /* string */cssSelector){ + // summary + // Returns the computed value of the passed style + var value = dojo.html.getStyleProperty(node, cssSelector); + return (value ? value : dojo.html.getComputedStyle(node, cssSelector)); // string || integer +} + +dojo.html.setStyle = function(/* HTMLElement */node, /* string */cssSelector, /* string */value){ + // summary + // Set the value of passed style on node + node = dojo.byId(node); + if(node && node.style){ + var camelCased = dojo.html.toCamelCase(cssSelector); + node.style[camelCased] = value; + } +} + +dojo.html.setStyleText = function (/* HTMLElement */target, /* string */text) { + // summary + // Try to set the entire cssText property of the passed target; equiv of setting style attribute. + try { + target.style.cssText = text; + } catch (e) { + target.setAttribute("style", text); + } +} + +dojo.html.copyStyle = function(/* HTMLElement */target, /* HTMLElement */source){ + // summary + // work around for opera which doesn't have cssText, and for IE which fails on setAttribute + if(!source.style.cssText){ + target.setAttribute("style", source.getAttribute("style")); + }else{ + target.style.cssText = source.style.cssText; + } + dojo.html.addClass(target, dojo.html.getClass(source)); +} + +dojo.html.getUnitValue = function(/* HTMLElement */node, /* string */cssSelector, /* boolean? */autoIsZero){ + // summary + // Get the value of passed selector, with the specific units used + var s = dojo.html.getComputedStyle(node, cssSelector); + if((!s)||((s == 'auto')&&(autoIsZero))){ + return { value: 0, units: 'px' }; // object + } + // FIXME: is regex inefficient vs. parseInt or some manual test? + var match = s.match(/(\-?[\d.]+)([a-z%]*)/i); + if (!match){return dojo.html.getUnitValue.bad;} + return { value: Number(match[1]), units: match[2].toLowerCase() }; // object +} +dojo.html.getUnitValue.bad = { value: NaN, units: '' }; + +if (dojo.render.html.ie) { + // IE branch + dojo.html.toPixelValue = function(/* HTMLElement */element, /* String */styleValue){ + // summary + // Extract value in pixels from styleValue (IE version). + // If a value cannot be extracted, zero is returned. + if(!styleValue){return 0;} + if(styleValue.slice(-2) == 'px'){return parseFloat(styleValue);} + var pixelValue = 0; + with(element){ + var sLeft = style.left; + var rsLeft = runtimeStyle.left; + runtimeStyle.left = currentStyle.left; + try { + style.left = styleValue || 0; + pixelValue = style.pixelLeft; + style.left = sLeft; + runtimeStyle.left = rsLeft; + }catch(e){ + // FIXME: it's possible for styleValue to be incompatible with + // style.left. In particular, border width values of + // "thick", "medium", or "thin" will provoke an exception. + } + } + return pixelValue; // Number + } +} else { + // non-IE branch + dojo.html.toPixelValue = function(/* HTMLElement */element, /* String */styleValue){ + // summary + // Extract value in pixels from styleValue (non-IE version). + // If a value cannot be extracted, zero is returned. + return (styleValue && (styleValue.slice(-2)=='px') ? parseFloat(styleValue) : 0); // Number + } +} + +dojo.html.getPixelValue = function(/* HTMLElement */node, /* string */styleProperty, /* boolean? */autoIsZero){ + // summary + // Get a computed style value, in pixels. + // node: HTMLElement + // Node to interrogate + // styleProperty: String + // Style property to query, in either css-selector or camelCase (property) format. + // autoIsZero: Boolean + // Deprecated. Any value that cannot be converted to pixels is returned as zero. + // + // summary + // Get the value of passed selector in pixels. + // + return dojo.html.toPixelValue(node, dojo.html.getComputedStyle(node, styleProperty)); +} + +dojo.html.setPositivePixelValue = function(/* HTMLElement */node, /* string */selector, /* integer */value){ + // summary + // Attempt to set the value of selector on node as a positive pixel value. + if(isNaN(value)){return false;} + node.style[selector] = Math.max(0, value) + 'px'; + return true; // boolean +} + +dojo.html.styleSheet = null; + +// FIXME: this is a really basic stub for adding and removing cssRules, but +// it assumes that you know the index of the cssRule that you want to add +// or remove, making it less than useful. So we need something that can +// search for the selector that you you want to remove. +dojo.html.insertCssRule = function(/* string */selector, /* string */declaration, /* integer? */index) { + // summary + // Attempt to insert declaration as selector on the internal stylesheet; if index try to set it there. + if (!dojo.html.styleSheet) { + if (document.createStyleSheet) { // IE + dojo.html.styleSheet = document.createStyleSheet(); + } else if (document.styleSheets[0]) { // rest + // FIXME: should create a new style sheet here + // fall back on an exsiting style sheet + dojo.html.styleSheet = document.styleSheets[0]; + } else { + return null; // integer + } // fail + } + + if (arguments.length < 3) { // index may == 0 + if (dojo.html.styleSheet.cssRules) { // W3 + index = dojo.html.styleSheet.cssRules.length; + } else if (dojo.html.styleSheet.rules) { // IE + index = dojo.html.styleSheet.rules.length; + } else { + return null; // integer + } // fail + } + + if (dojo.html.styleSheet.insertRule) { // W3 + var rule = selector + " { " + declaration + " }"; + return dojo.html.styleSheet.insertRule(rule, index); // integer + } else if (dojo.html.styleSheet.addRule) { // IE + return dojo.html.styleSheet.addRule(selector, declaration, index); // integer + } else { + return null; // integer + } // fail +} + +dojo.html.removeCssRule = function(/* integer? */index){ + // summary + // Attempt to remove the rule at index. + if(!dojo.html.styleSheet){ + dojo.debug("no stylesheet defined for removing rules"); + return false; + } + if(dojo.render.html.ie){ + if(!index){ + index = dojo.html.styleSheet.rules.length; + dojo.html.styleSheet.removeRule(index); + } + }else if(document.styleSheets[0]){ + if(!index){ + index = dojo.html.styleSheet.cssRules.length; + } + dojo.html.styleSheet.deleteRule(index); + } + return true; // boolean +} + +dojo.html._insertedCssFiles = []; // cache container needed because IE reformats cssText when added to DOM +dojo.html.insertCssFile = function(/* string */URI, /* HTMLDocument? */doc, /* boolean? */checkDuplicates, /* boolean */fail_ok){ + // summary + // calls css by XmlHTTP and inserts it into DOM as + if(!URI){ return; } + if(!doc){ doc = document; } + var cssStr = dojo.hostenv.getText(URI, false, fail_ok); + if(cssStr===null){ return; } + cssStr = dojo.html.fixPathsInCssText(cssStr, URI); + + if(checkDuplicates){ + var idx = -1, node, ent = dojo.html._insertedCssFiles; + for(var i = 0; i < ent.length; i++){ + if((ent[i].doc == doc) && (ent[i].cssText == cssStr)){ + idx = i; node = ent[i].nodeRef; + break; + } + } + // make sure we havent deleted our node + if(node){ + var styles = doc.getElementsByTagName("style"); + for(var i = 0; i < styles.length; i++){ + if(styles[i] == node){ + return; + } + } + // delete this entry + dojo.html._insertedCssFiles.shift(idx, 1); + } + } + + var style = dojo.html.insertCssText(cssStr, doc); + dojo.html._insertedCssFiles.push({'doc': doc, 'cssText': cssStr, 'nodeRef': style}); + + // insert custom attribute ex dbgHref="../foo.css" usefull when debugging in DOM inspectors, no? + if(style && djConfig.isDebug){ + style.setAttribute("dbgHref", URI); + } + return style; // HTMLStyleElement +} + +dojo.html.insertCssText = function(/* string */cssStr, /* HTMLDocument? */doc, /* string? */URI){ + // summary + // Attempt to insert CSS rules into the document through inserting a style element + // DomNode Style = insertCssText(String ".dojoMenu {color: green;}"[, DomDoc document, dojo.uri.Uri Url ]) + if(!cssStr){ + return; // HTMLStyleElement + } + if(!doc){ doc = document; } + if(URI){// fix paths in cssStr + cssStr = dojo.html.fixPathsInCssText(cssStr, URI); + } + var style = doc.createElement("style"); + style.setAttribute("type", "text/css"); + // IE is b0rken enough to require that we add the element to the doc + // before changing it's properties + var head = doc.getElementsByTagName("head")[0]; + if(!head){ // must have a head tag + dojo.debug("No head tag in document, aborting styles"); + return; // HTMLStyleElement + }else{ + head.appendChild(style); + } + if(style.styleSheet){// IE + var setFunc = function(){ + try{ + style.styleSheet.cssText = cssStr; + }catch(e){ dojo.debug(e); } + }; + if(style.styleSheet.disabled){ + setTimeout(setFunc, 10); + }else{ + setFunc(); + } + }else{ // w3c + var cssText = doc.createTextNode(cssStr); + style.appendChild(cssText); + } + return style; // HTMLStyleElement +} + +dojo.html.fixPathsInCssText = function(/* string */cssStr, /* string */URI){ + // summary + // usage: cssText comes from dojoroot/src/widget/templates/Foobar.css + // it has .dojoFoo { background-image: url(images/bar.png);} then uri should point to dojoroot/src/widget/templates/ + if(!cssStr || !URI){ return; } + var match, str = "", url = "", urlChrs = "[\\t\\s\\w\\(\\)\\/\\.\\\\'\"-:#=&?~]+"; + var regex = new RegExp('url\\(\\s*('+urlChrs+')\\s*\\)'); + var regexProtocol = /(file|https?|ftps?):\/\//; + regexTrim = new RegExp("^[\\s]*(['\"]?)("+urlChrs+")\\1[\\s]*?$"); + if(dojo.render.html.ie55 || dojo.render.html.ie60){ + var regexIe = new RegExp("AlphaImageLoader\\((.*)src\=['\"]("+urlChrs+")['\"]"); + // TODO: need to decide how to handle relative paths and AlphaImageLoader see #1441 + // current implementation breaks on build with intern_strings + while(match = regexIe.exec(cssStr)){ + url = match[2].replace(regexTrim, "$2"); + if(!regexProtocol.exec(url)){ + url = (new dojo.uri.Uri(URI, url).toString()); + } + str += cssStr.substring(0, match.index) + "AlphaImageLoader(" + match[1] + "src='" + url + "'"; + cssStr = cssStr.substr(match.index + match[0].length); + } + cssStr = str + cssStr; + str = ""; + } + + while(match = regex.exec(cssStr)){ + url = match[1].replace(regexTrim, "$2"); + if(!regexProtocol.exec(url)){ + url = (new dojo.uri.Uri(URI, url).toString()); + } + str += cssStr.substring(0, match.index) + "url(" + url + ")"; + cssStr = cssStr.substr(match.index + match[0].length); + } + return str + cssStr; // string +} + +dojo.html.setActiveStyleSheet = function(/* string */title){ + // summary + // Activate style sheet with specified title. + var i = 0, a, els = dojo.doc().getElementsByTagName("link"); + while (a = els[i++]) { + if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")){ + a.disabled = true; + if (a.getAttribute("title") == title) { a.disabled = false; } + } + } +} + +dojo.html.getActiveStyleSheet = function(){ + // summary + // return the title of the currently active stylesheet + var i = 0, a, els = dojo.doc().getElementsByTagName("link"); + while (a = els[i++]) { + if (a.getAttribute("rel").indexOf("style") != -1 + && a.getAttribute("title") + && !a.disabled + ){ + return a.getAttribute("title"); // string + } + } + return null; // string +} + +dojo.html.getPreferredStyleSheet = function(){ + // summary + // Return the preferred stylesheet title (i.e. link without alt attribute) + var i = 0, a, els = dojo.doc().getElementsByTagName("link"); + while (a = els[i++]) { + if(a.getAttribute("rel").indexOf("style") != -1 + && a.getAttribute("rel").indexOf("alt") == -1 + && a.getAttribute("title") + ){ + return a.getAttribute("title"); // string + } + } + return null; // string +} + +dojo.html.applyBrowserClass = function(/* HTMLElement */node){ + // summary + // Applies pre-set class names based on browser & version to the passed node. + // Modified version of Morris' CSS hack. + var drh=dojo.render.html; + var classes = { + dj_ie: drh.ie, + dj_ie55: drh.ie55, + dj_ie6: drh.ie60, + dj_ie7: drh.ie70, + dj_iequirks: drh.ie && drh.quirks, + dj_opera: drh.opera, + dj_opera8: drh.opera && (Math.floor(dojo.render.version)==8), + dj_opera9: drh.opera && (Math.floor(dojo.render.version)==9), + dj_khtml: drh.khtml, + dj_safari: drh.safari, + dj_gecko: drh.mozilla + }; // no dojo unsupported browsers + for(var p in classes){ + if(classes[p]){ + dojo.html.addClass(node, p); + } + } +}; + +dojo.provide("dojo.html.display"); + + +dojo.html._toggle = function(node, tester, setter){ + node = dojo.byId(node); + setter(node, !tester(node)); + return tester(node); +} + +dojo.html.show = function(/* HTMLElement */node){ + // summary + // Show the passed element by reverting display property set by dojo.html.hide + node = dojo.byId(node); + if(dojo.html.getStyleProperty(node, 'display')=='none'){ + dojo.html.setStyle(node, 'display', (node.dojoDisplayCache||'')); + node.dojoDisplayCache = undefined; // cannot use delete on a node in IE6 + } +} + +dojo.html.hide = function(/* HTMLElement */node){ + // summary + // Hide the passed element by setting display:none + node = dojo.byId(node); + if(typeof node["dojoDisplayCache"] == "undefined"){ // it could == '', so we cannot say !node.dojoDisplayCount + var d = dojo.html.getStyleProperty(node, 'display') + if(d!='none'){ + node.dojoDisplayCache = d; + } + } + dojo.html.setStyle(node, 'display', 'none'); +} + +dojo.html.setShowing = function(/* HTMLElement */node, /* boolean? */showing){ + // summary + // Calls show() if showing is true, hide() otherwise + dojo.html[(showing ? 'show' : 'hide')](node); +} + +dojo.html.isShowing = function(/* HTMLElement */node){ + // summary + // Returns whether the element is displayed or not. + // FIXME: returns true if node is bad, isHidden would be easier to make correct + return (dojo.html.getStyleProperty(node, 'display') != 'none'); // boolean +} + +dojo.html.toggleShowing = function(/* HTMLElement */node){ + // summary + // Call setShowing() on node with the complement of isShowing(), then return the new value of isShowing() + return dojo.html._toggle(node, dojo.html.isShowing, dojo.html.setShowing); // boolean +} + +// Simple mapping of tag names to display values +// FIXME: simplistic +dojo.html.displayMap = { tr: '', td: '', th: '', img: 'inline', span: 'inline', input: 'inline', button: 'inline' }; + +dojo.html.suggestDisplayByTagName = function(/* HTMLElement */node){ + // summary + // Suggest a value for the display property that will show 'node' based on it's tag + node = dojo.byId(node); + if(node && node.tagName){ + var tag = node.tagName.toLowerCase(); + return (tag in dojo.html.displayMap ? dojo.html.displayMap[tag] : 'block'); // string + } +} + +dojo.html.setDisplay = function(/* HTMLElement */node, /* string */display){ + // summary + // Sets the value of style.display to value of 'display' parameter if it is a string. + // Otherwise, if 'display' is false, set style.display to 'none'. + // Finally, set 'display' to a suggested display value based on the node's tag + dojo.html.setStyle(node, 'display', ((display instanceof String || typeof display == "string") ? display : (display ? dojo.html.suggestDisplayByTagName(node) : 'none'))); +} + +dojo.html.isDisplayed = function(/* HTMLElement */node){ + // summary + // Is true if the the computed display style for node is not 'none' + // FIXME: returns true if node is bad, isNotDisplayed would be easier to make correct + return (dojo.html.getComputedStyle(node, 'display') != 'none'); // boolean +} + +dojo.html.toggleDisplay = function(/* HTMLElement */node){ + // summary + // Call setDisplay() on node with the complement of isDisplayed(), then + // return the new value of isDisplayed() + return dojo.html._toggle(node, dojo.html.isDisplayed, dojo.html.setDisplay); // boolean +} + +dojo.html.setVisibility = function(/* HTMLElement */node, /* string */visibility){ + // summary + // Sets the value of style.visibility to value of 'visibility' parameter if it is a string. + // Otherwise, if 'visibility' is false, set style.visibility to 'hidden'. Finally, set style.visibility to 'visible'. + dojo.html.setStyle(node, 'visibility', ((visibility instanceof String || typeof visibility == "string") ? visibility : (visibility ? 'visible' : 'hidden'))); +} + +dojo.html.isVisible = function(/* HTMLElement */node){ + // summary + // Returns true if the the computed visibility style for node is not 'hidden' + // FIXME: returns true if node is bad, isInvisible would be easier to make correct + return (dojo.html.getComputedStyle(node, 'visibility') != 'hidden'); // boolean +} + +dojo.html.toggleVisibility = function(node){ + // summary + // Call setVisibility() on node with the complement of isVisible(), then return the new value of isVisible() + return dojo.html._toggle(node, dojo.html.isVisible, dojo.html.setVisibility); // boolean +} + +dojo.html.setOpacity = function(/* HTMLElement */node, /* float */opacity, /* boolean? */dontFixOpacity){ + // summary + // Sets the opacity of node in a cross-browser way. + // float between 0.0 (transparent) and 1.0 (opaque) + node = dojo.byId(node); + var h = dojo.render.html; + if(!dontFixOpacity){ + if( opacity >= 1.0){ + if(h.ie){ + dojo.html.clearOpacity(node); + return; + }else{ + opacity = 0.999999; + } + }else if( opacity < 0.0){ opacity = 0; } + } + if(h.ie){ + if(node.nodeName.toLowerCase() == "tr"){ + // FIXME: is this too naive? will we get more than we want? + var tds = node.getElementsByTagName("td"); + for(var x=0; x= 0.999999 ? 1.0 : Number(opac); // float +} + + +dojo.provide("dojo.html.color"); + + + + +dojo.html.getBackgroundColor = function(/* HTMLElement */node){ + // summary + // returns the background color of the passed node as a 32-bit color (RGBA) + node = dojo.byId(node); + var color; + do{ + color = dojo.html.getStyle(node, "background-color"); + // Safari doesn't say "transparent" + if(color.toLowerCase() == "rgba(0, 0, 0, 0)") { color = "transparent"; } + if(node == document.getElementsByTagName("body")[0]) { node = null; break; } + node = node.parentNode; + }while(node && dojo.lang.inArray(["transparent", ""], color)); + if(color == "transparent"){ + color = [255, 255, 255, 0]; + }else{ + color = dojo.gfx.color.extractRGB(color); + } + return color; // array +} + +dojo.provide("dojo.html.layout"); + + + + + +dojo.html.sumAncestorProperties = function(/* HTMLElement */node, /* string */prop){ + // summary + // Returns the sum of the passed property on all ancestors of node. + node = dojo.byId(node); + if(!node){ return 0; } // FIXME: throw an error? + + var retVal = 0; + while(node){ + if(dojo.html.getComputedStyle(node, 'position') == 'fixed'){ + return 0; + } + var val = node[prop]; + if(val){ + retVal += val - 0; + if(node==dojo.body()){ break; }// opera and khtml #body & #html has the same values, we only need one value + } + node = node.parentNode; + } + return retVal; // integer +} + +dojo.html.setStyleAttributes = function(/* HTMLElement */node, /* string */attributes) { + // summary + // allows a dev to pass a string similar to what you'd pass in style="", and apply it to a node. + node = dojo.byId(node); + var splittedAttribs=attributes.replace(/(;)?\s*$/, "").split(";"); + for(var i=0; i0){ + ret.x += isNaN(n) ? 0 : n; + } + var m = curnode["offsetTop"]; + ret.y += isNaN(m) ? 0 : m; + curnode = curnode.offsetParent; + }while((curnode != endNode)&&(curnode != null)); + }else if(node["x"]&&node["y"]){ + ret.x += isNaN(node.x) ? 0 : node.x; + ret.y += isNaN(node.y) ? 0 : node.y; + } + } + + // account for document scrolling! + if(includeScroll){ + var scroll = dojo.html.getScroll(); + ret.y += scroll.top; + ret.x += scroll.left; + } + + var extentFuncArray=[dojo.html.getPaddingExtent, dojo.html.getBorderExtent, dojo.html.getMarginExtent]; + if(nativeBoxType > targetBoxType){ + for(var i=targetBoxType;inativeBoxType;--i){ + ret.y -= extentFuncArray[i-1](node, 'top'); + ret.x -= extentFuncArray[i-1](node, 'left'); + } + } + ret.top = ret.y; + ret.left = ret.x; + return ret; // object +} + +dojo.html.isPositionAbsolute = function(/* HTMLElement */node){ + // summary + // Returns true if the element is absolutely positioned. + return (dojo.html.getComputedStyle(node, 'position') == 'absolute'); // boolean +} + +dojo.html._sumPixelValues = function(/* HTMLElement */node, selectors, autoIsZero){ + var total = 0; + for(var x=0; x 4 ) { coords.pop(); } + var ret = { + left: coords[0], + top: coords[1], + width: coords[2], + height: coords[3] + }; + }else if(!coords.nodeType && !(coords instanceof String || typeof coords == "string") && + ('width' in coords || 'height' in coords || 'left' in coords || + 'x' in coords || 'top' in coords || 'y' in coords)){ + // coords is a coordinate object or at least part of one + var ret = { + left: coords.left||coords.x||0, + top: coords.top||coords.y||0, + width: coords.width||0, + height: coords.height||0 + }; + }else{ + // coords is an dom object (or dom object id); return it's coordinates + var node = dojo.byId(coords); + var pos = dojo.html.abs(node, includeScroll, boxtype); + var marginbox = dojo.html.getMarginBox(node); + var ret = { + left: pos.left, + top: pos.top, + width: marginbox.width, + height: marginbox.height + }; + } + ret.x = ret.left; + ret.y = ret.top; + return ret; // object +} + +dojo.html.setMarginBoxWidth = dojo.html.setOuterWidth = function(node, width){ + 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, includeScroll){ + return dojo.html._callDeprecated("getTotalOffset", "getAbsolutePosition", arguments, null, type); +} +dojo.html.getAbsoluteX = function(node, includeScroll){ + return dojo.html._callDeprecated("getAbsoluteX", "getAbsolutePosition", arguments, null, "x"); +} +dojo.html.getAbsoluteY = function(node, includeScroll){ + return dojo.html._callDeprecated("getAbsoluteY", "getAbsolutePosition", arguments, null, "y"); +} +dojo.html.totalOffsetLeft = function(node, includeScroll){ + return dojo.html._callDeprecated("totalOffsetLeft", "getAbsolutePosition", arguments, null, "left"); +} +dojo.html.totalOffsetTop = function(node, includeScroll){ + 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, width){ + return dojo.html._callDeprecated("setContentBoxWidth", "setContentBox", arguments, "width"); +} +dojo.html.setContentBoxHeight = dojo.html.setContentHeight = function(node, height){ + return dojo.html._callDeprecated("setContentBoxHeight", "setContentBox", arguments, "height"); +} + +dojo.provide("dojo.lfx.html"); + + + + + + + + +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){ + n.push(dojo.byId(node)); + }); + n.alreadyChecked = true; + return n; + }else{ + return nodes; + } + }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? } + 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 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 + var parr = []; + 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"){ + prop.start = parseInt(dojo.html.getComputedStyle(args.nodes[0], prop.property)); + }else{ + prop.start = dojo.html.getOpacity(args.nodes[0]); + } + } + }); + } + } + + var coordsAsInts = function(coords){ + var cints = []; + dojo.lang.forEach(coords, function(c){ + cints.push(Math.round(c)); + }); + return cints; + } + + var setStyle = function(n, style){ + n = dojo.byId(n); + 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){ + 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)){ + prop.start = prop.start(prop, i); + } + if(dojo.lang.isFunction(prop.end)){ + prop.end = prop.end(prop, i); + } + if(dojo.lang.isArray(prop.start)){ + // don't loop through the arrays + 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; + } + }, this); + + this.getValue = function(n){ + var ret = {}; + 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 ? "," : ""); + } + 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])){ + 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 + 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") ){ + node.style.width = "auto"; + } + } + } + if(dojo.lang.isArrayLike(nodes)){ + dojo.lang.forEach(nodes, makeFade); + }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. + nodes = dojo.lfx.html._byId(nodes); + var props = { property: "opacity" }; + if(!dj_undef("start", values)){ + props.start = values.start; + }else{ + props.start = function(){ return dojo.html.getOpacity(nodes[0]); }; + } + + if(!dj_undef("end", values)){ + props.end = values.end; + }else{ + dojo.raise("dojo.lfx.html.fade needs an end value"); + } + + 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); }); + } + + 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); + }); + + var anim = dojo.lfx.html.fadeIn(nodes, duration, easing, callback); + anim.connect("beforeBegin", function(){ + if(dojo.lang.isArrayLike(nodes)){ + dojo.lang.forEach(nodes, dojo.html.show); + }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)){ + dojo.lang.forEach(nodes, dojo.html.hide); + }else{ + dojo.html.hide(nodes); + } + 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. + 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) + // TODO: should this offscreen code be part of dojo.html, so that getBorderBox() works on hidden nodes? + 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, // 0 causes IE to display the whole panel + end: function(){ return nodeHeight; } + } + }, + duration, + easing); + + anim.connect("beforeBegin", function(){ + oprop.overflow = node.style.overflow; + oprop.height = node.style.height; + with(node.style){ + overflow = "hidden"; + height = "1px"; // 0 causes IE to display the whole panel + } + dojo.html.show(node); + }); + + anim.connect("onEnd", function(){ + 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.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. + 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); } + } + } + ); + 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. + 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] }; + } + dojo.lang.forEach(nodes, function(node){ + var top = null; + var left = null; + + 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)) { + var ret = dojo.html.abs(innerNode, true); + 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); }); + } + + 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. + 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] }; + } + + dojo.lang.forEach(nodes, function(node){ + var top = null; + var left = null; + + 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)) { + var ret = dojo.html.abs(innerNode, true); + 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); }); + } + + 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. + 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){ + 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){ + visibility = "hidden"; + display = "block"; + } + var endCoords = h.toCoordinateObject(endNode, true); + 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 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. + 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; } + dojo.html.setOpacity(outline, 0.3); + 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 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. + nodes = dojo.lfx.html._byId(nodes); + var anims = []; + + 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(); } + + 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); + } + } + } + ); + + 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. + nodes = dojo.lfx.html._byId(nodes); + var anims = []; + + 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); + } + } + } + ); + anims.push(anim); + }); + return dojo.lfx.combine(anims); // dojo.lfx.Combine +} + +dojo.lang.mixin(dojo.lfx, dojo.lfx.html); + +dojo.kwCompoundRequire({ + browser: ["dojo.lfx.html"], + dashboard: ["dojo.lfx.html"] +}); +dojo.provide("dojo.lfx.*"); + +if(!this["dojo"]){ + alert("\"dojo/__package__.js\" is now located at \"dojo/dojo.js\". Please update your includes accordingly"); +} + +dojo.provide("dojo.xml.Parse"); + + +//TODO: determine dependencies +// currently has dependency on dojo.xml.DomUtil nodeTypes constants... + +// using documentFragment nomenclature to generalize in case we don't want to require passing a collection of nodes with a single parent + +dojo.xml.Parse = function(){ + // summary: + // generic class for taking a DOM node and parsing it into an object + // based on the "dojo tag name" of that node. + // + // supported dojoTagName's: + // => prefix:tag + // => dojo:tag + // => dojo:tag + // => dojo:type + // => prefix:type + // => dojo:type + // => dojo:type + + var isIE = ((dojo.render.html.capable)&&(dojo.render.html.ie)); + + // get normalized (lowercase) tagName + // some browsers report tagNames in lowercase no matter what + function getTagName(node){ + /* + return ((node)&&(node["tagName"]) ? node.tagName.toLowerCase() : ''); + */ + try{ + return node.tagName.toLowerCase(); + }catch(e){ + return ""; + } + } + + // locate dojo qualified tag name + function getDojoTagName(node){ + var tagName = getTagName(node); + if (!tagName){ + return ''; + } + // any registered tag + if((dojo.widget)&&(dojo.widget.tags[tagName])){ + return tagName; + } + // => prefix:tag + var p = tagName.indexOf(":"); + if(p>=0){ + return tagName; + } + // => dojo:tag + if(tagName.substr(0,5) == "dojo:"){ + return tagName; + } + if(dojo.render.html.capable && dojo.render.html.ie && node.scopeName != 'HTML'){ + return node.scopeName.toLowerCase() + ':' + tagName; + } + // => dojo:tag + if(tagName.substr(0,4) == "dojo"){ + // FIXME: this assumes tag names are always lower case + return "dojo:" + tagName.substring(4); + } + // => prefix:type + // => dojo:type + var djt = node.getAttribute("dojoType") || node.getAttribute("dojotype"); + if(djt){ + if (djt.indexOf(":")<0){ + djt = "dojo:"+djt; + } + return djt.toLowerCase(); + } + // => dojo:type + djt = node.getAttributeNS && node.getAttributeNS(dojo.dom.dojoml,"type"); + if(djt){ + return "dojo:" + djt.toLowerCase(); + } + // => dojo:type + try{ + // FIXME: IE really really doesn't like this, so we squelch errors for it + djt = node.getAttribute("dojo:type"); + }catch(e){ + // FIXME: log? + } + if(djt){ return "dojo:"+djt.toLowerCase(); } + // => dojo:type + if((dj_global["djConfig"])&&(!djConfig["ignoreClassNames"])){ + // FIXME: should we make this optionally enabled via djConfig? + var classes = node.className||node.getAttribute("class"); + // FIXME: following line, without check for existence of classes.indexOf + // breaks firefox 1.5's svg widgets + if((classes )&&(classes.indexOf)&&(classes.indexOf("dojo-")!=-1)){ + var aclasses = classes.split(" "); + for(var x=0, c=aclasses.length; x as nodes that should be parsed. Ignore these + if(isIE && tagName.indexOf("/")==0){ return null; } + + try{ + var attr = node.getAttribute("parseWidgets"); + if(attr && attr.toLowerCase() == "false"){ + return {}; + } + }catch(e){/*continue*/} + + + // look for a dojoml qualified name + // process dojoml only when optimizeForDojoML is true + var process = true; + if(optimizeForDojoML){ + var dojoTagName = getDojoTagName(node); + tagName = dojoTagName || tagName; + process = Boolean(dojoTagName); + } + + var parsedNodeSet = {}; + parsedNodeSet[tagName] = []; + var pos = tagName.indexOf(":"); + if(pos>0){ + var ns = tagName.substring(0,pos); + parsedNodeSet["ns"] = ns; + // honor user namespace filters + if((dojo.ns)&&(!dojo.ns.allow(ns))){process=false;} + } + + if(process){ + var attributeSet = this.parseAttributes(node); + for(var attr in attributeSet){ + if((!parsedNodeSet[tagName][attr])||(typeof parsedNodeSet[tagName][attr] != "array")){ + parsedNodeSet[tagName][attr] = []; + } + parsedNodeSet[tagName][attr].push(attributeSet[attr]); + } + // FIXME: we might want to make this optional or provide cloning instead of + // referencing, but for now, we include a node reference to allow + // instantiated components to figure out their "roots" + parsedNodeSet[tagName].nodeRef = node; + parsedNodeSet.tagName = tagName; + parsedNodeSet.index = thisIdx||0; + } + + var count = 0; + for(var i = 0; i < node.childNodes.length; i++){ + var tcn = node.childNodes.item(i); + switch(tcn.nodeType){ + case dojo.dom.ELEMENT_NODE: // element nodes, call this function recursively + var ctn = getDojoTagName(tcn) || getTagName(tcn); + if(!parsedNodeSet[ctn]){ + parsedNodeSet[ctn] = []; + } + parsedNodeSet[ctn].push(this.parseElement(tcn, true, optimizeForDojoML, count)); + if( (tcn.childNodes.length == 1)&& + (tcn.childNodes.item(0).nodeType == dojo.dom.TEXT_NODE)){ + parsedNodeSet[ctn][parsedNodeSet[ctn].length-1].value = tcn.childNodes.item(0).nodeValue; + } + count++; + break; + case dojo.dom.TEXT_NODE: // if a single text node is the child, treat it as an attribute + if(node.childNodes.length == 1){ + parsedNodeSet[tagName].push({ value: node.childNodes.item(0).nodeValue }); + } + break; + default: break; + /* + case dojo.dom.ATTRIBUTE_NODE: // attribute node... not meaningful here + break; + case dojo.dom.CDATA_SECTION_NODE: // cdata section... not sure if this would ever be meaningful... might be... + break; + case dojo.dom.ENTITY_REFERENCE_NODE: // entity reference node... not meaningful here + break; + case dojo.dom.ENTITY_NODE: // entity node... not sure if this would ever be meaningful + break; + case dojo.dom.PROCESSING_INSTRUCTION_NODE: // processing instruction node... not meaningful here + break; + case dojo.dom.COMMENT_NODE: // comment node... not not sure if this would ever be meaningful + break; + case dojo.dom.DOCUMENT_NODE: // document node... not sure if this would ever be meaningful + break; + case dojo.dom.DOCUMENT_TYPE_NODE: // document type node... not meaningful here + break; + case dojo.dom.DOCUMENT_FRAGMENT_NODE: // document fragment node... not meaningful here + break; + case dojo.dom.NOTATION_NODE:// notation node... not meaningful here + break; + */ + } + } + //return (hasParentNodeSet) ? parsedNodeSet[node.tagName] : parsedNodeSet; + //if(parsedNodeSet.tagName)dojo.debug("parseElement: RETURNING NODE WITH TAGNAME "+parsedNodeSet.tagName); + return parsedNodeSet; + }; + + + /* parses a set of attributes on a node into an object tree */ + this.parseAttributes = function(/*DomNode*/node){ + // summary: + // creates an attribute object that maps attribute values for the + // passed node. Note that this is similar to creating a JSON + // representation of a DOM node. + // usage: + // a node with the following serialization: + //
    ...
    + // would yeild the following return structure when passed into this + // function: + // { + // "foo": { + // "value": "bar" + // }, + // "baz": { + // "value": "thud" + // } + // } + // + var parsedAttributeSet = {}; + var atts = node.attributes; + // TODO: should we allow for duplicate attributes at this point... + // would any of the relevant dom implementations even allow this? + var attnode, i=0; + while((attnode=atts[i++])){ + if(isIE){ + if(!attnode){ continue; } + if((typeof attnode == "object")&& + (typeof attnode.nodeValue == 'undefined')|| + (attnode.nodeValue == null)|| + (attnode.nodeValue == '')){ + continue; + } + } + + var nn = attnode.nodeName.split(":"); + nn = (nn.length == 2) ? nn[1] : attnode.nodeName; + + parsedAttributeSet[nn] = { + value: attnode.nodeValue + }; + } + return parsedAttributeSet; + }; +}; + +dojo.provide("dojo.lang.declare"); + + + + +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(); + * }, + * { // properties to be added to the class prototype + * 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) + var temp = props; + props = init; + init = temp; + } + var mixins = [ ]; + if(dojo.lang.isArray(superclass)){ + mixins = superclass; + superclass = mixins.shift(); + } + if(!init){ + init = dojo.evalObjPath(className, false); + if((init)&&(!dojo.lang.isFunction(init))){ init = null }; + } + var ctor = dojo.lang.declare._makeConstructor(); + var scp = (superclass ? superclass.prototype : null); + if(scp){ + scp.prototyping = true; + ctor.prototype = new superclass(); + scp.prototyping = false; + } + ctor.superclass = scp; + ctor.mixins = mixins; + for(var i=0,l=mixins.length; i 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.widget.Manager"); + + + + +// summary +// Manager class for the widgets. +// This is an internal class used by dojo; users shouldn't call this class directly. +dojo.widget.manager = new function(){ + this.widgets = []; + this.widgetIds = []; + + // map of widgetId-->widget for widgets without parents (top level widgets) + this.topWidgets = {}; + + var widgetTypeCtr = {}; + var renderPrefixCache = []; + + this.getUniqueId = function (widgetType) { + var widgetId; + do{ + widgetId = widgetType + "_" + (widgetTypeCtr[widgetType] != undefined ? + ++widgetTypeCtr[widgetType] : widgetTypeCtr[widgetType] = 0); + }while(this.getWidgetById(widgetId)); + return widgetId; + } + + this.add = function(widget){ + //dojo.profile.start("dojo.widget.manager.add"); + this.widgets.push(widget); + // Opera9 uses ID (caps) + if(!widget.extraArgs["id"]){ + widget.extraArgs["id"] = widget.extraArgs["ID"]; + } + // FIXME: the rest of this method is very slow! + if(widget.widgetId == ""){ + if(widget["id"]){ + widget.widgetId = widget["id"]; + }else if(widget.extraArgs["id"]){ + widget.widgetId = widget.extraArgs["id"]; + }else{ + widget.widgetId = this.getUniqueId(widget.ns+'_'+widget.widgetType); + } + } + if(this.widgetIds[widget.widgetId]){ + dojo.debug("widget ID collision on ID: "+widget.widgetId); + } + this.widgetIds[widget.widgetId] = widget; + // Widget.destroy already calls removeById(), so we don't need to + // connect() it here + //dojo.profile.end("dojo.widget.manager.add"); + } + + this.destroyAll = function(){ + for(var x=this.widgets.length-1; x>=0; x--){ + try{ + // this.widgets[x].destroyChildren(); + this.widgets[x].destroy(true); + delete this.widgets[x]; + }catch(e){ } + } + } + + // FIXME: we should never allow removal of the root widget until all others + // are removed! + this.remove = function(widgetIndex){ + if(dojo.lang.isNumber(widgetIndex)){ + var tw = this.widgets[widgetIndex].widgetId; + delete this.topWidgets[tw]; + delete this.widgetIds[tw]; + this.widgets.splice(widgetIndex, 1); + }else{ + this.removeById(widgetIndex); + } + } + + // FIXME: suboptimal performance + this.removeById = function(id) { + if(!dojo.lang.isString(id)){ + id = id["widgetId"]; + if(!id){ dojo.debug("invalid widget or id passed to removeById"); return; } + } + for (var i=0; i.widget by convention + dojo.ns.register(ns, ns + '.widget'); + nsObj = dojo.ns.get(ns); + } + + // allow the namespace to resolve the widget module + if(nsObj){nsObj.resolve(widgetName);} + + // locate a widget implementation in the registered module for our current rendering environment + impl = findImplementation(lowerCaseWidgetName, nsObj.module); + if(impl){return(imps[lowerCaseWidgetName] = impl)}; + + // try to load a manifest to resolve this implemenation + nsObj = dojo.ns.require(ns); + if((nsObj)&&(nsObj.resolver)){ + nsObj.resolve(widgetName); + impl = findImplementation(lowerCaseWidgetName, nsObj.module); + if(impl){return(imps[lowerCaseWidgetName] = impl)}; + } + + // this is an error condition under new rules + dojo.deprecated('dojo.widget.Manager.getImplementationName', + 'Could not locate widget implementation for "' + widgetName + '" in "' + nsObj.module + '" registered to namespace "' + nsObj.name + '". ' + + "Developers must specify correct namespaces for all non-Dojo widgets", "0.5"); + + // backward compat: if the user has not specified any namespace and their widget is not in dojo.widget.* + // search registered widget packages [sic] + // note: registerWidgetPackage itself is now deprecated + for(var i=0; i 0) { + return widgets[n]; + } + return widgets; + } + g("registerWidgetPackage"); + g("getImplementation", "getWidgetImplementation"); + g("getImplementationName", "getWidgetImplementationName"); + + dw.widgets = dwm.widgets; + dw.widgetIds = dwm.widgetIds; + dw.root = dwm.root; +})(); + +dojo.kwCompoundRequire({ + common: [["dojo.uri.Uri", false, false]] +}); +dojo.provide("dojo.uri.*"); + +dojo.provide("dojo.a11y"); + + + + +dojo.a11y = { + // imgPath: String path to the test image for determining if images are displayed or not + // doAccessibleCheck: Boolean if true will perform check for need to create accessible widgets + // accessible: Boolean uninitialized when null (accessible check has not been performed) + // if true generate accessible widgets + imgPath:dojo.uri.moduleUri("dojo.widget", "templates/images"), + doAccessibleCheck: true, + accessible: null, + + checkAccessible: function(){ + // summary: + // perform check for accessibility if accessibility checking is turned + // on and the accessibility test has not been performed yet + if(this.accessible === null){ + this.accessible = false; //default + if(this.doAccessibleCheck == true){ + this.accessible = this.testAccessible(); + } + } + return this.accessible; /* Boolean */ + }, + + testAccessible: function(){ + // summary: + // Always perform the accessibility check to determine if high + // contrast mode is on or display of images are turned off. Currently only checks + // in IE and Mozilla. + this.accessible = false; //default + if (dojo.render.html.ie || dojo.render.html.mozilla){ + var div = document.createElement("div"); + //div.style.color="rgb(153,204,204)"; + div.style.backgroundImage = "url(\"" + this.imgPath + "/tab_close.gif\")"; + // must add to hierarchy before can view currentStyle below + dojo.body().appendChild(div); + // in FF and IE the value for the current background style of the added div + // will be "none" in high contrast mode + // in FF the return value will be url(invalid-url:) when running over http + var bkImg = null; + if (window.getComputedStyle ) { + var cStyle = getComputedStyle(div, ""); + bkImg = cStyle.getPropertyValue("background-image"); + }else{ + bkImg = div.currentStyle.backgroundImage; + } + var bUseImgElem = false; + if (bkImg != null && (bkImg == "none" || bkImg == "url(invalid-url:)" )) { + this.accessible = true; + } + /* + if(this.accessible == false && document.images){ + // test if images are off in IE + var testImg = new Image(); + if(testImg.fileSize) { + testImg.src = this.imgPath + "/tab_close.gif"; + if(testImg.fileSize < 0){ + this.accessible = true; + } + } + }*/ + dojo.body().removeChild(div); + } + return this.accessible; /* Boolean */ + }, + + setCheckAccessible: function(/* Boolean */ bTest){ + // summary: + // Set whether or not to check for accessibility mode. Default value + // of module is true - perform check for accessibility modes. + // bTest: Boolean - true to check; false to turn off checking + this.doAccessibleCheck = bTest; + }, + + setAccessibleMode: function(){ + // summary: + // perform the accessibility check and sets the correct mode to load + // a11y widgets. Only runs if test for accessiiblity has not been performed yet. + // Call testAccessible() to force the test. + if (this.accessible === null){ + if (this.checkAccessible()){ + dojo.render.html.prefixes.unshift("a11y"); + } + } + return this.accessible; /* Boolean */ + } +}; + +//dojo.hostenv.modulesLoadedListeners.unshift(function() { dojo.a11y.setAccessibleMode(); }); +//dojo.event.connect("before", dojo.hostenv, "makeWidgets", dojo.a11y, "setAccessibleMode"); + +dojo.provide("dojo.widget.Widget"); + + + + + + + + + + +dojo.declare("dojo.widget.Widget", null, + function(){ + // these properties aren't primitives and need to be created on a per-item + // basis. + + // children: Array + // a list of all of the widgets that have been added as children of + // this component. Should only have values if isContainer is true. + this.children = []; + + // extraArgs: Object + // a map of properties which the widget system tried to assign from + // user input but did not correspond to any of the properties set on + // the class prototype. These names will also be available in all + // lower-case form in this map + this.extraArgs = {}; + }, +{ + // parent: Widget + // the parent of this widget + parent: null, + + // isTopLevel: Boolean + // should this widget eat all events that bubble up to it? + // obviously, top-level and modal widgets should set these appropriately + isTopLevel: false, + + // disabled: Boolean + // should this widget respond to user input? + // in markup, this is specified as "disabled='disabled'", or just "disabled" + disabled: false, + + // isContainer: Boolean + // can this widget contain other widgets? + isContainer: false, + + // widgetId: String + // a unique, opaque ID string that can be assigned by users or by the + // system. If the developer passes an ID which is known not to be + // unique, the specified ID is ignored and the system-generated ID is + // used instead. + widgetId: "", + + // widgetType: String + // used for building generic widgets + widgetType: "Widget", + + // ns: String + // defaults to 'dojo'. "namespace" is a reserved word in JavaScript, so we abbreviate + ns: "dojo", + + getNamespacedType: function(){ + // summary: + // get the "full" name of the widget. If the widget comes from the + // "dojo" namespace and is a Button, calling this method will + // return "dojo:button", all lower-case + return (this.ns ? this.ns + ":" + this.widgetType : this.widgetType).toLowerCase(); // String + }, + + toString: function(){ + // summary: + // returns a string that represents the widget. When a widget is + // cast to a string, this method will be used to generate the + // output. Currently, it does not implement any sort of reversable + // serialization. + return '[Widget ' + this.getNamespacedType() + ', ' + (this.widgetId || 'NO ID') + ']'; // String + }, + + repr: function(){ + // summary: returns the string representation of the widget. + return this.toString(); // String + }, + + enable: function(){ + // summary: + // enables the widget, usually involving unmasking inputs and + // turning on event handlers. Not implemented here. + this.disabled = false; + }, + + disable: function(){ + // summary: + // disables the widget, usually involves masking inputs and + // unsetting event handlers. Not implemented here. + this.disabled = true; + }, + + // TODO: + // 1) this would be better in HtmlWidget rather than here? + // 2) since many widgets don't care if they've been resized, maybe this should be a mixin? + onResized: function(){ + // summary: + // A signal that widgets will call when they have been resized. + // Can be connected to for determining if a layout needs to be + // reflowed. Clients should override this function to do special + // processing, then call this.notifyChildrenOfResize() to notify + // children of resize. + this.notifyChildrenOfResize(); + }, + + notifyChildrenOfResize: function(){ + // summary: dispatches resized events to all children of this widget + for(var i=0; i mixInProperties"); + //dojo.profile.start(this.widgetType + " mixInProperties"); + this.mixInProperties(args, fragment, parent); + //dojo.profile.end(this.widgetType + " mixInProperties"); + // dojo.debug(this.widgetType, "-> postMixInProperties"); + //dojo.profile.start(this.widgetType + " postMixInProperties"); + this.postMixInProperties(args, fragment, parent); + //dojo.profile.end(this.widgetType + " postMixInProperties"); + // dojo.debug(this.widgetType, "-> dojo.widget.manager.add"); + dojo.widget.manager.add(this); + // dojo.debug(this.widgetType, "-> buildRendering"); + //dojo.profile.start(this.widgetType + " buildRendering"); + this.buildRendering(args, fragment, parent); + //dojo.profile.end(this.widgetType + " buildRendering"); + // dojo.debug(this.widgetType, "-> initialize"); + //dojo.profile.start(this.widgetType + " initialize"); + this.initialize(args, fragment, parent); + //dojo.profile.end(this.widgetType + " initialize"); + // dojo.debug(this.widgetType, "-> postInitialize"); + // postinitialize includes subcomponent creation + // profile is put directly to function + this.postInitialize(args, fragment, parent); + // dojo.debug(this.widgetType, "-> postCreate"); + //dojo.profile.start(this.widgetType + " postCreate"); + this.postCreate(args, fragment, parent); + //dojo.profile.end(this.widgetType + " postCreate"); + // dojo.debug(this.widgetType, "done!"); + + //dojo.profile.end(this.widgetType + " create"); + + return this; + }, + + destroy: function(finalize){ + // summary: + // Destroy this widget and it's descendants. This is the generic + // "destructor" function that all widget users should call to + // clealy discard with a widget. Once a widget is destroyed, it's + // removed from the manager object. + // finalize: Boolean + // is this function being called part of global environment + // tear-down? + + // FIXME: this is woefully incomplete + if(this.parent){ + this.parent.removeChild(this); + } + this.destroyChildren(); + this.uninitialize(); + this.destroyRendering(finalize); + dojo.widget.manager.removeById(this.widgetId); + }, + + destroyChildren: function(){ + // summary: + // Recursively destroy the children of this widget and their + // descendents. + var widget; + var i=0; + while(this.children.length > i){ + widget = this.children[i]; + if (widget instanceof dojo.widget.Widget) { // find first widget + this.removeChild(widget); + widget.destroy(); + continue; + } + + i++; // skip data object + } + + }, + + getChildrenOfType: function(/*String*/type, recurse){ + // summary: + // return an array of descendant widgets who match the passed type + // recurse: Boolean + // should we try to get all descendants that match? Defaults to + // false. + var ret = []; + var isFunc = dojo.lang.isFunction(type); + if(!isFunc){ + type = type.toLowerCase(); + } + for(var x=0; xsi)){ + this[x][pairs[y].substr(0, si).replace(/^\s+|\s+$/g, "")] = pairs[y].substr(si+1); + } + } + } + }else{ + // the default is straight-up string assignment. When would + // we ever hit this? + this[x] = args[x]; + } + } + }else{ + // collect any extra 'non mixed in' args + this.extraArgs[x.toLowerCase()] = args[x]; + } + } + // dojo.profile.end("mixInProperties"); + }, + + postMixInProperties: function(/*Object*/args, /*Object*/frag, /*Widget*/parent){ + // summary + // Called after the parameters to the widget have been read-in, + // but before the widget template is instantiated. + // Especially useful to set properties that are referenced in the widget template. + }, + + initialize: function(/*Object*/args, /*Object*/frag, /*Widget*/parent){ + // summary: stub function. + return false; + // dojo.unimplemented("dojo.widget.Widget.initialize"); + }, + + postInitialize: function(/*Object*/args, /*Object*/frag, /*Widget*/parent){ + // summary: stub function. + return false; + }, + + postCreate: function(/*Object*/args, /*Object*/frag, /*Widget*/parent){ + // summary: stub function. + return false; + }, + + uninitialize: function(){ + // summary: + // stub function. Over-ride to implement custom widget tear-down + // behavior. + return false; + }, + + buildRendering: function(/*Object*/args, /*Object*/frag, /*Widget*/parent){ + // summary: stub function. SUBCLASSES MUST IMPLEMENT + dojo.unimplemented("dojo.widget.Widget.buildRendering, on "+this.toString()+", "); + return false; + }, + + destroyRendering: function(){ + // summary: stub function. SUBCLASSES MUST IMPLEMENT + dojo.unimplemented("dojo.widget.Widget.destroyRendering"); + return false; + }, + + addedTo: function(parent){ + // summary: + // stub function this is just a signal that can be caught + // parent: Widget + // instance of dojo.widget.Widget that we were added to + }, + + addChild: function(child){ + // summary: stub function. SUBCLASSES MUST IMPLEMENT + dojo.unimplemented("dojo.widget.Widget.addChild"); + return false; + }, + + // Detach the given child widget from me, but don't destroy it + removeChild: function(/*Widget*/widget){ + // summary: + // removes the passed widget instance from this widget but does + // not destroy it + for(var x=0; x +dojo.widget.tags["dojo:connect"] = function(fragment, widgetParser, parentComp){ + var properties = widgetParser.parseProperties(fragment["dojo:connect"]); +} + +// FIXME: if we know the insertion point (to a reasonable location), why then do we: +// - create a template node +// - clone the template node +// - render the clone and set properties +// - remove the clone from the render tree +// - place the clone +// this is quite dumb +dojo.widget.buildWidgetFromParseTree = function(/*String*/ type, + /*Object*/ frag, + /*dojo.widget.Parse*/ parser, + /*Widget, optional*/ parentComp, + /*int, optional*/ insertionIndex, + /*Object*/ localProps){ + + // summary: creates a tree of widgets from the data structure produced by the first-pass parser (frag) + + // test for accessibility mode + dojo.a11y.setAccessibleMode(); + //dojo.profile.start("buildWidgetFromParseTree"); + // FIXME: for codepath from createComponentFromScript, we are now splitting a path + // that we already split and then joined + var stype = type.split(":"); + stype = (stype.length == 2) ? stype[1] : type; + + // FIXME: we don't seem to be doing anything with this! + // var propertySets = parser.getPropertySets(frag); + var localProperties = localProps || parser.parseProperties(frag[frag["ns"]+":"+stype]); + var twidget = dojo.widget.manager.getImplementation(stype,null,null,frag["ns"]); + if(!twidget){ + throw new Error('cannot find "' + type + '" widget'); + }else if (!twidget.create){ + throw new Error('"' + type + '" widget object has no "create" method and does not appear to implement *Widget'); + } + localProperties["dojoinsertionindex"] = insertionIndex; + // FIXME: we lose no less than 5ms in construction! + var ret = twidget.create(localProperties, frag, parentComp, frag["ns"]); + // dojo.profile.end("buildWidgetFromParseTree"); + return ret; +} + +dojo.widget.defineWidget = function(widgetClass, renderer, superclasses, init, props){ + // summary: Create a widget constructor function (aka widgetClass) + // widgetClass: String + // the location in the object hierarchy to place the new widget class constructor + // renderer: String + // usually "html", determines when this delcaration will be used + // superclasses: Function||Function[] + // can be either a single function or an array of functions to be + // mixed in as superclasses. If an array, only the first will be used + // to set prototype inheritance. + // init: Function + // an optional constructor function. Will be called after superclasses are mixed in. + // props: Object + // a map of properties and functions to extend the class prototype with + + // This meta-function does parameter juggling for backward compat and overloading + // if 4th argument is a string, we are using the old syntax + // old sig: widgetClass, superclasses, props (object), renderer (string), init (function) + if(dojo.lang.isString(arguments[3])){ + dojo.widget._defineWidget(arguments[0], arguments[3], arguments[1], arguments[4], arguments[2]); + }else{ + // widgetClass + var args = [ arguments[0] ], p = 3; + if(dojo.lang.isString(arguments[1])){ + // renderer, superclass + args.push(arguments[1], arguments[2]); + }else{ + // superclass + args.push('', arguments[1]); + p = 2; + } + if(dojo.lang.isFunction(arguments[p])){ + // init (function), props (object) + args.push(arguments[p], arguments[p+1]); + }else{ + // props (object) + args.push(null, arguments[p]); + } + dojo.widget._defineWidget.apply(this, args); + } +} + +dojo.widget.defineWidget.renderers = "html|svg|vml"; + +dojo.widget._defineWidget = function(widgetClass /*string*/, renderer /*string*/, superclasses /*function||array*/, init /*function*/, props /*object*/){ + // FIXME: uncomment next line to test parameter juggling ... remove when confidence improves + // dojo.debug('(c:)' + widgetClass + '\n\n(r:)' + renderer + '\n\n(i:)' + init + '\n\n(p:)' + props); + // widgetClass takes the form foo.bar.baz<.renderer>.WidgetName (e.g. foo.bar.baz.WidgetName or foo.bar.baz.html.WidgetName) + var module = widgetClass.split("."); + var type = module.pop(); // type <= WidgetName, module <= foo.bar.baz<.renderer> + var regx = "\\.(" + (renderer ? renderer + '|' : '') + dojo.widget.defineWidget.renderers + ")\\."; + var r = widgetClass.search(new RegExp(regx)); + module = (r < 0 ? module.join(".") : widgetClass.substr(0, r)); + + // deprecated in favor of namespace system, remove for 0.5 + dojo.widget.manager.registerWidgetPackage(module); + + var pos = module.indexOf("."); + var nsName = (pos > -1) ? module.substring(0,pos) : module; + + // FIXME: hrm, this might make things simpler + //dojo.widget.tags.addParseTreeHandler(nsName+":"+type.toLowerCase()); + + props=(props)||{}; + props.widgetType = type; + if((!init)&&(props["classConstructor"])){ + init = props.classConstructor; + delete props.classConstructor; + } + dojo.declare(widgetClass, superclasses, init, props); +} + +dojo.provide("dojo.widget.Parse"); + + + +// +// dojoML parser should be moved out of 'widget', codifying the difference between a 'component' +// and a 'widget'. A 'component' being anything that can be generated from a tag. +// +// a particular dojoML tag would be handled by a registered tagHandler with a hook for a default handler +// if the widget system is loaded, a widget builder would be attach itself as the default handler +// +// widget tags are no longer registered themselves: +// they are now arbitrarily namespaced, so we cannot register them all, and the non-prefixed portions +// are no longer guaranteed unique +// +// therefore dojo.widget.tags should go with this parser code out of the widget module +// + +dojo.widget.Parse = function(/*Object*/fragment){ + this.propertySetsList = []; + this.fragment = fragment; + + this.createComponents = function(/*Object*/frag, /*Object*/parentComp){ + var comps = []; + var built = false; + // if we have items to parse/create at this level, do it! + try{ + if(frag && frag.tagName && (frag != frag.nodeRef)){ + + // these are in fact, not ever for widgets per-se anymore, + // but for other markup elements (aka components) + var djTags = dojo.widget.tags; + + // we split so that you can declare multiple + // non-destructive components from the same ctor node + var tna = String(frag.tagName).split(";"); + for(var x=0; x -1) ? name.substring(0,pos) : "dojo"; + if(pos > -1){ name = name.substring(pos+1); } + var lowerCaseName = name.toLowerCase(); + var namespacedName = ns + ":" + lowerCaseName; + isNode = (dojo.byId(name) && !dojo.widget.tags[namespacedName]); + } + + if((arguments.length == 1) && (isNode || !isNameStr)){ + // we got a DOM node + var xp = new dojo.xml.Parse(); + // FIXME: we should try to find the parent! + var tn = isNode ? dojo.byId(name) : name; + return dojo.widget.getParser().createComponents(xp.parseElement(tn, null, true))[0]; + } + + function fromScript(placeKeeperNode, name, props, ns){ + props[namespacedName] = { + dojotype: [{value: lowerCaseName}], + nodeRef: placeKeeperNode, + fastMixIn: true + }; + props.ns = ns; + return dojo.widget.getParser().createComponentFromScript(placeKeeperNode, name, props, ns); + } + + props = props||{}; + var notRef = false; + var tn = null; + var h = dojo.render.html.capable; + if(h){ + tn = document.createElement("span"); + } + if(!refNode){ + notRef = true; + refNode = tn; + if(h){ + dojo.body().appendChild(refNode); + } + }else if(position){ + dojo.dom.insertAtPosition(tn, refNode, position); + }else{ // otherwise don't replace, but build in-place + tn = refNode; + } + var widgetArray = fromScript(tn, name.toLowerCase(), props, ns); + if( (!widgetArray)||(!widgetArray[0])|| + (typeof widgetArray[0].widgetType == "undefined") ){ + throw new Error("createWidget: Creation of \"" + name + "\" widget failed."); + } + try{ + if(notRef && widgetArray[0].domNode.parentNode){ + widgetArray[0].domNode.parentNode.removeChild(widgetArray[0].domNode); + } + }catch(e){ + /* squelch for Safari */ + dojo.debug(e); + } + return widgetArray[0]; // Widget +} + +dojo.provide("dojo.widget.DomWidget"); + + + + + + + + + + +dojo.widget._cssFiles = {}; +dojo.widget._cssStrings = {}; +dojo.widget._templateCache = {}; + +dojo.widget.defaultStrings = { + // summary: a mapping of strings that are used in template variable replacement + dojoRoot: dojo.hostenv.getBaseScriptUri(), + dojoWidgetModuleUri: dojo.uri.moduleUri("dojo.widget"), + baseScriptUri: dojo.hostenv.getBaseScriptUri() +}; + +dojo.widget.fillFromTemplateCache = function(obj, templatePath, templateString, avoidCache){ + // summary: + // static method to build from a template w/ or w/o a real widget in + // place + // obj: DomWidget + // an instance of dojo.widget.DomWidget to initialize the template for + // templatePath: String + // the URL to get the template from. dojo.uri.Uri is often passed as well. + // templateString: String? + // a string to use in lieu of fetching the template from a URL + // avoidCache: Boolean? + // should the template system not use whatever is in the cache and + // always use the passed templatePath or templateString? + + // dojo.debug("avoidCache:", avoidCache); + var tpath = templatePath || obj.templatePath; + + var tmplts = dojo.widget._templateCache; + if(!tpath && !obj["widgetType"]) { // don't have a real template here + do { + var dummyName = "__dummyTemplate__" + dojo.widget._templateCache.dummyCount++; + } while(tmplts[dummyName]); + obj.widgetType = dummyName; + } + var wt = tpath?tpath.toString():obj.widgetType; + + var ts = tmplts[wt]; + if(!ts){ + tmplts[wt] = {"string": null, "node": null}; + if(avoidCache){ + ts = {}; + }else{ + ts = tmplts[wt]; + } + } + + if((!obj.templateString)&&(!avoidCache)){ + obj.templateString = templateString || ts["string"]; + } + if(obj.templateString){ + obj.templateString = this._sanitizeTemplateString(obj.templateString); + } + + if((!obj.templateNode)&&(!avoidCache)){ + obj.templateNode = ts["node"]; + } + if((!obj.templateNode)&&(!obj.templateString)&&(tpath)){ + // fetch a text fragment and assign it to templateString + // NOTE: we rely on blocking IO here! + var tstring = this._sanitizeTemplateString(dojo.hostenv.getText(tpath)); + + obj.templateString = tstring; + if(!avoidCache){ + tmplts[wt]["string"] = tstring; + } + } + if((!ts["string"])&&(!avoidCache)){ + ts.string = obj.templateString; + } +} + +dojo.widget._sanitizeTemplateString = function(/*String*/tString){ + //summary: Strips declarations so that external SVG and XML + //documents can be added to a document without worry. Also, if the string + //is an HTML document, only the part inside the body tag is returned. + if(tString){ + tString = tString.replace(/^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im, ""); + var matches = tString.match(/]*>\s*([\s\S]+)\s*<\/body>/im); + if(matches){ + tString = matches[1]; + } + }else{ + tString = ""; + } + return tString; //String +} + +dojo.widget._templateCache.dummyCount = 0; + +// Array: list of properties to search for node-to-property mappings +dojo.widget.attachProperties = ["dojoAttachPoint", "id"]; + +// String: name of the property to use for mapping DOM events to widget functions +dojo.widget.eventAttachProperty = "dojoAttachEvent"; + +// String: property name of code to evaluate when the widget is constructed +dojo.widget.onBuildProperty = "dojoOnBuild"; + +// Array: possible accessibility values to set on widget elements - role or state +dojo.widget.waiNames = ["waiRole", "waiState"]; + +dojo.widget.wai = { + // summary: Contains functions to set accessibility roles and states + // onto widget elements + waiRole: { + // name: String: + // information for mapping accessibility role + name: "waiRole", + // namespace: String: + // URI of the namespace for the set of roles + "namespace": "http://www.w3.org/TR/xhtml2", + // alias: String: + // The alias to assign the namespace + alias: "x2", + // prefix: String: + // The prefix to assign to the role value + prefix: "wairole:" + }, + waiState: { + // name: String: + // information for mapping accessibility state + name: "waiState", + // namespace: String: + // URI of the namespace for the set of states + "namespace": "http://www.w3.org/2005/07/aaa", + // alias: String: + // The alias to assign the namespace + alias: "aaa", + // prefix: String: + // empty string - state value does not require prefix + prefix: "" + }, + setAttr: function(/*DomNode*/node, /*String*/ ns, /*String*/ attr, /*String|Boolean*/value){ + // summary: Use appropriate API to set the role or state attribute onto the element. + // description: In IE use the generic setAttribute() api. Append a namespace + // alias to the attribute name and appropriate prefix to the value. + // Otherwise, use the setAttribueNS api to set the namespaced attribute. Also + // add the appropriate prefix to the attribute value. + if(dojo.render.html.ie){ + node.setAttribute(this[ns].alias+":"+ attr, this[ns].prefix+value); + }else{ + node.setAttributeNS(this[ns]["namespace"], attr, this[ns].prefix+value); + } + }, + + getAttr: function(/*DomNode*/ node, /*String*/ ns, /*String|Boolena*/ attr){ + // Summary: Use the appropriate API to retrieve the role or state value + // Description: In IE use the generic getAttribute() api. An alias value + // was added to the attribute name to simulate a namespace when the attribute + // was set. Otherwise use the getAttributeNS() api to retrieve the state value + if(dojo.render.html.ie){ + return node.getAttribute(this[ns].alias+":"+attr); + }else{ + return node.getAttributeNS(this[ns]["namespace"], attr); + } + }, + removeAttr: function(/*DomNode*/ node, /*String*/ ns, /*String|Boolena*/ attr){ + // summary: Use the appropriate API to remove the role or state value + // description: In IE use the generic removeAttribute() api. An alias value + // was added to the attribute name to simulate a namespace when the attribute + // was set. Otherwise use the removeAttributeNS() api to remove the state value + var success = true; //only IE returns a value + if(dojo.render.html.ie){ + success = node.removeAttribute(this[ns].alias+":"+attr); + }else{ + node.removeAttributeNS(this[ns]["namespace"], attr); + } + return success; + } +}; + +dojo.widget.attachTemplateNodes = function(rootNode, /*Widget*/ targetObj, events ){ + // summary: + // map widget properties and functions to the handlers specified in + // the dom node and it's descendants. This function iterates over all + // nodes and looks for these properties: + // * dojoAttachPoint + // * dojoAttachEvent + // * waiRole + // * waiState + // * any "dojoOn*" proprties passed in the events array + // rootNode: DomNode + // the node to search for properties. All children will be searched. + // events: Array + // a list of properties generated from getDojoEventsFromStr. + + // FIXME: this method is still taking WAAAY too long. We need ways of optimizing: + // a.) what we are looking for on each node + // b.) the nodes that are subject to interrogation (use xpath instead?) + // c.) how expensive event assignment is (less eval(), more connect()) + // var start = new Date(); + var elementNodeType = dojo.dom.ELEMENT_NODE; + + function trim(str){ + return str.replace(/^\s+|\s+$/g, ""); + } + + if(!rootNode){ + rootNode = targetObj.domNode; + } + + if(rootNode.nodeType != elementNodeType){ + return; + } + // alert(events.length); + + var nodes = rootNode.all || rootNode.getElementsByTagName("*"); + var _this = targetObj; + for(var x=-1; x= 0){ + // oh, if only JS had tuple assignment + var funcNameArr = tevt.split(":"); + tevt = trim(funcNameArr[0]); + thisFunc = trim(funcNameArr[1]); + } + if(!thisFunc){ + thisFunc = tevt; + } + + var tf = function(){ + var ntf = new String(thisFunc); + return function(evt){ + if(_this[ntf]){ + _this[ntf](dojo.event.browser.fixEvent(evt, this)); + } + }; + }(); + dojo.event.browser.addListener(baseNode, tevt, tf, false, true); + // dojo.event.browser.addListener(baseNode, tevt, dojo.lang.hitch(_this, thisFunc)); + } + } + + for(var y=0; y=0){ + funcs = dojo.lang.map(thisFunc.split(";"), trim); + } + for(var z=0; z0)&&(typeof arguments[0] == "object")){ + this.create(arguments[0]); + } + }, + { + // templateNode: DomNode + // a node that represents the widget template. Pre-empts both templateString and templatePath. + templateNode: null, + + // templateString String: + // a string that represents the widget template. Pre-empts the + // templatePath. In builds that have their strings "interned", the + // templatePath is converted to an inline templateString, thereby + // preventing a synchronous network call. + templateString: null, + + // templateCssString String: + // a string that represents the CSS for the widgettemplate. + // Pre-empts the templateCssPath. In builds that have their + // strings "interned", the templateCssPath is converted to an + // inline templateCssString, thereby preventing a synchronous + // network call. + templateCssString: null, + + // preventClobber Boolean: + // should the widget not replace the node from which it was + // constructed? Widgets that apply behaviors to pre-existing parts + // of a page can be implemented easily by setting this to "true". + // In these cases, the domNode property will point to the node + // which the widget was created from. + preventClobber: false, + + // domNode DomNode: + // this is our visible representation of the widget! Other DOM + // Nodes may by assigned to other properties, usually through the + // template system's dojoAttachPonit syntax, but the domNode + // property is the canonical "top level" node in widget UI. + domNode: null, + + // containerNode DomNode: + // holds child elements. "containerNode" is generally set via a + // dojoAttachPoint assignment and it designates where widgets that + // are defined as "children" of the parent will be placed + // visually. + containerNode: null, + + // widgetsInTemplate Boolean: + // should we parse the template to find widgets that might be + // declared in markup inside it? false by default. + widgetsInTemplate: false, + + addChild: function(/*Widget*/ widget, overrideContainerNode, pos, ref, insertIndex){ + // summary: + // Process the given child widget, inserting it's dom node as + // a child of our dom node + // overrideContainerNode: DomNode? + // a non-default container node for the widget + // pos: String? + // can be one of "before", "after", "first", or "last". This + // has the same meaning as in dojo.dom.insertAtPosition() + // ref: DomNode? + // a node to place the widget relative to + // insertIndex: int? + // DOM index, same meaning as in dojo.dom.insertAtIndex() + // returns: the widget that was inserted + + // FIXME: should we support addition at an index in the children arr and + // order the display accordingly? Right now we always append. + if(!this.isContainer){ // we aren't allowed to contain other widgets, it seems + dojo.debug("dojo.widget.DomWidget.addChild() attempted on non-container widget"); + return null; + }else{ + if(insertIndex == undefined){ + insertIndex = this.children.length; + } + this.addWidgetAsDirectChild(widget, overrideContainerNode, pos, ref, insertIndex); + this.registerChild(widget, insertIndex); + } + return widget; // Widget + }, + + addWidgetAsDirectChild: function(/*Widget*/ widget, overrideContainerNode, pos, ref, insertIndex){ + // summary: + // Process the given child widget, inserting it's dom node as + // a child of our dom node + // overrideContainerNode: DomNode + // a non-default container node for the widget + // pos: String? + // can be one of "before", "after", "first", or "last". This + // has the same meaning as in dojo.dom.insertAtPosition() + // ref: DomNode? + // a node to place the widget relative to + // insertIndex: int? + // DOM index, same meaning as in dojo.dom.insertAtIndex() + if((!this.containerNode)&&(!overrideContainerNode)){ + this.containerNode = this.domNode; + } + var cn = (overrideContainerNode) ? overrideContainerNode : this.containerNode; + if(!pos){ pos = "after"; } + if(!ref){ + if(!cn){ cn = dojo.body(); } + ref = cn.lastChild; + } + if(!insertIndex) { insertIndex = 0; } + widget.domNode.setAttribute("dojoinsertionindex", insertIndex); + + // insert the child widget domNode directly underneath my domNode, in the + // specified position (by default, append to end) + if(!ref){ + cn.appendChild(widget.domNode); + }else{ + // FIXME: was this meant to be the (ugly hack) way to support insert @ index? + //dojo.dom[pos](widget.domNode, ref, insertIndex); + + // CAL: this appears to be the intended way to insert a node at a given position... + if (pos == 'insertAtIndex'){ + // dojo.debug("idx:", insertIndex, "isLast:", ref === cn.lastChild); + dojo.dom.insertAtIndex(widget.domNode, ref.parentNode, insertIndex); + }else{ + // dojo.debug("pos:", pos, "isLast:", ref === cn.lastChild); + if((pos == "after")&&(ref === cn.lastChild)){ + cn.appendChild(widget.domNode); + }else{ + dojo.dom.insertAtPosition(widget.domNode, cn, pos); + } + } + } + }, + + registerChild: function(widget, insertionIndex){ + // summary: record that given widget descends from me + // widget: Widget + // the widget that is now a child + // insertionIndex: int + // where in the children[] array to place it + + // we need to insert the child at the right point in the parent's + // 'children' array, based on the insertionIndex + + widget.dojoInsertionIndex = insertionIndex; + + var idx = -1; + for(var i=0; i node that can't be inserted back into the original DOM tree + parentComp.addWidgetAsDirectChild(this, "", "insertAtIndex", "", args["dojoinsertionindex"], sourceNodeRef); + } else if (sourceNodeRef){ + // Do in-place replacement of the my source node with my generated dom + if(this.domNode && (this.domNode !== sourceNodeRef)){ + this._sourceNodeRef = dojo.dom.replaceNode(sourceNodeRef, this.domNode); + } + } + + // Register myself with my parent, or with the widget manager if + // I have no parent + // TODO: the code below erroneously adds all programatically generated widgets + // to topWidgets (since we don't know who the parent is until after creation finishes) + if ( parentComp ) { + parentComp.registerChild(this, args.dojoinsertionindex); + } else { + dojo.widget.manager.topWidgets[this.widgetId]=this; + } + + if(this.widgetsInTemplate){ + var parser = new dojo.xml.Parse(); + + var subContainerNode; + //TODO: use xpath here? + var subnodes = this.domNode.getElementsByTagName("*"); + for(var i=0;i= 0){ + // oh, if only JS had tuple assignment + var funcNameArr = tevt.split(":"); + tevt = dojo.string.trim(funcNameArr[0]); + thisFunc = dojo.string.trim(funcNameArr[1]); + } + if(!thisFunc){ + thisFunc = tevt; + } + if(dojo.lang.isFunction(widget[tevt])){ + dojo.event.kwConnect({ + srcObj: widget, + srcFunc: tevt, + targetObj: this, + targetFunc: thisFunc + }); + }else{ + alert(tevt+" is not a function in widget "+widget); + } + } + } + + if(widget.extraArgs['dojoattachpoint']){ + //don't attach widget.domNode here, as we do not know which + //dom node we should connect to (in checkbox widget case, + //it is inputNode). So we make the widget itself available + this[widget.extraArgs['dojoattachpoint']] = widget; + } + } + } + + //dojo.profile.end(this.widgetType + " postInitialize"); + + // Expand my children widgets + /* dojoDontFollow is important for a very special case + * basically if you have a widget that you instantiate from script + * and that widget is a container, and it contains a reference to a parent + * instance, the parser will start recursively parsing until the browser + * complains. So the solution is to set an initialization property of + * dojoDontFollow: true and then it won't recurse where it shouldn't + */ + if(this.isContainer && !frag["dojoDontFollow"]){ + //alert("recurse from " + this.widgetId); + // build any sub-components with us as the parent + dojo.widget.getParser().createSubComponents(frag, this); + } + }, + + // method over-ride + buildRendering: function(/*Object*/ args, /*Object*/ frag){ + // summary: + // Construct the UI for this widget, generally from a + // template. This can be over-ridden for custom UI creation to + // to side-step the template system. This is an + // implementation of the stub function defined in + // dojo.widget.Widget. + + // DOM widgets construct themselves from a template + var ts = dojo.widget._templateCache[this.widgetType]; + + // Handle style for this widget here, as even if templatePath + // is not set, style specified by templateCssString or templateCssPath + // should be applied. templateCssString has higher priority + // than templateCssPath + if(args["templatecsspath"]){ + args["templateCssPath"] = args["templatecsspath"]; + } + var cpath = args["templateCssPath"] || this.templateCssPath; + if(cpath && !dojo.widget._cssFiles[cpath.toString()]){ + if((!this.templateCssString)&&(cpath)){ + this.templateCssString = dojo.hostenv.getText(cpath); + this.templateCssPath = null; + } + dojo.widget._cssFiles[cpath.toString()] = true; + } + + if((this["templateCssString"])&&(!dojo.widget._cssStrings[this.templateCssString])){ + dojo.html.insertCssText(this.templateCssString, null, cpath); + dojo.widget._cssStrings[this.templateCssString] = true; + } + if( + (!this.preventClobber)&&( + (this.templatePath)|| + (this.templateNode)|| + ( + (this["templateString"])&&(this.templateString.length) + )|| + ( + (typeof ts != "undefined")&&( (ts["string"])||(ts["node"]) ) + ) + ) + ){ + // if it looks like we can build the thing from a template, do it! + this.buildFromTemplate(args, frag); + }else{ + // otherwise, assign the DOM node that was the source of the widget + // parsing to be the root node + this.domNode = this.getFragNodeRef(frag); + } + this.fillInTemplate(args, frag); // this is where individual widgets + // will handle population of data + // from properties, remote data + // sets, etc. + }, + + buildFromTemplate: function(/*Object*/ args, /*Object*/ frag){ + // summary: + // Called by buildRendering, creates the actual UI in a DomWidget. + + // var start = new Date(); + // copy template properties if they're already set in the templates object + // dojo.debug("buildFromTemplate:", this); + var avoidCache = false; + if(args["templatepath"]){ +// avoidCache = true; + args["templatePath"] = args["templatepath"]; + } + dojo.widget.fillFromTemplateCache( this, + args["templatePath"], + null, + avoidCache); + var ts = dojo.widget._templateCache[this.templatePath?this.templatePath.toString():this.widgetType]; + if((ts)&&(!avoidCache)){ + if(!this.templateString.length){ + this.templateString = ts["string"]; + } + if(!this.templateNode){ + this.templateNode = ts["node"]; + } + } + var matches = false; + var node = null; + // var tstr = new String(this.templateString); + var tstr = this.templateString; + // attempt to clone a template node, if there is one + if((!this.templateNode)&&(this.templateString)){ + matches = this.templateString.match(/\$\{([^\}]+)\}/g); + if(matches) { + // if we do property replacement, don't create a templateNode + // to clone from. + var hash = this.strings || {}; + // FIXME: should this hash of default replacements be cached in + // templateString? + for(var key in dojo.widget.defaultStrings) { + if(dojo.lang.isUndefined(hash[key])) { + hash[key] = dojo.widget.defaultStrings[key]; + } + } + // FIXME: this is a lot of string munging. Can we make it faster? + for(var i = 0; i < matches.length; i++) { + var key = matches[i]; + key = key.substring(2, key.length-1); + var kval = (key.substring(0, 5) == "this.") ? dojo.lang.getObjPathValue(key.substring(5), this) : hash[key]; + var value; + if((kval)||(dojo.lang.isString(kval))){ + value = new String((dojo.lang.isFunction(kval)) ? kval.call(this, key, this.templateString) : kval); + // Safer substitution, see heading "Attribute values" in + // http://www.w3.org/TR/REC-html40/appendix/notes.html#h-B.3.2 + while (value.indexOf("\"") > -1) { + value=value.replace("\"","""); + } + tstr = tstr.replace(matches[i], value); + } + } + }else{ + // otherwise, we are required to instantiate a copy of the template + // string if one is provided. + + // FIXME: need to be able to distinguish here what should be done + // or provide a generic interface across all DOM implementations + // FIMXE: this breaks if the template has whitespace as its first + // characters + // node = this.createNodesFromText(this.templateString, true); + // this.templateNode = node[0].cloneNode(true); // we're optimistic here + this.templateNode = this.createNodesFromText(this.templateString, true)[0]; + if(!avoidCache){ + ts.node = this.templateNode; + } + } + } + if((!this.templateNode)&&(!matches)){ + dojo.debug("DomWidget.buildFromTemplate: could not create template"); + return false; + }else if(!matches){ + node = this.templateNode.cloneNode(true); + if(!node){ return false; } + }else{ + node = this.createNodesFromText(tstr, true)[0]; + } + + // recurse through the node, looking for, and attaching to, our + // attachment points which should be defined on the template node. + + this.domNode = node; + // dojo.profile.start("attachTemplateNodes"); + this.attachTemplateNodes(); + // dojo.profile.end("attachTemplateNodes"); + + // relocate source contents to templated container node + // this.containerNode must be able to receive children, or exceptions will be thrown + if (this.isContainer && this.containerNode){ + var src = this.getFragNodeRef(frag); + if (src){ + dojo.dom.moveChildren(src, this.containerNode); + } + } + }, + + attachTemplateNodes: function(baseNode, targetObj){ + // summary: + // hooks up event handlers and property/node linkages. Calls + // dojo.widget.attachTemplateNodes to do all the hard work. + // baseNode: DomNode + // defaults to "this.domNode" + // targetObj: Widget + // defaults to "this" + if(!baseNode){ baseNode = this.domNode; } + if(!targetObj){ targetObj = this; } + return dojo.widget.attachTemplateNodes(baseNode, targetObj, + dojo.widget.getDojoEventsFromStr(this.templateString)); + }, + + fillInTemplate: function(){ + // summary: + // stub function! sub-classes may use as a default UI + // initializer function. The UI rendering will be available by + // the time this is called from buildRendering. If + // buildRendering is over-ridden, this function may not be + // fired! + + // dojo.unimplemented("dojo.widget.DomWidget.fillInTemplate"); + }, + + // method over-ride + destroyRendering: function(){ + // summary: UI destructor. Destroy the dom nodes associated w/this widget. + try{ + dojo.dom.destroyNode(this.domNode); + delete this.domNode; + }catch(e){ /* squelch! */ } + if(this._sourceNodeRef){ + try{ + dojo.dom.destroyNode(this._sourceNodeRef); + }catch(e){ /* squelch! */ } + } + }, + + createNodesFromText: function(){ + // summary + // Attempts to create a set of nodes based on the structure of the passed text. + // Implemented in HtmlWidget and SvgWidget. + dojo.unimplemented("dojo.widget.DomWidget.createNodesFromText"); + } + } +); + +dojo.provide("dojo.html.util"); + + +dojo.html.getElementWindow = function(/* HTMLElement */element){ + // summary + // Get the window object where the element is placed in. + return dojo.html.getDocumentWindow( element.ownerDocument ); // Window +} + +dojo.html.getDocumentWindow = function(doc){ + // summary + // Get window object associated with document doc + + // With Safari, there is not wa to retrieve the window from the document, so we must fix it. + if(dojo.render.html.safari && !doc._parentWindow){ + /* + This is a Safari specific function that fix the reference to the parent + window from the document object. + */ + + var fix=function(win){ + win.document._parentWindow=win; + for(var i=0; i + // If you wanted to insert a node into a DOM tree based on the mouse + // position you might use the following code: + //
    +	//	if (gravity(node, e) & gravity.NORTH) { [insert before]; }
    +	//	else { [insert after]; }
    +	//	
    + // + // @param node The node + // @param e The event containing the mouse coordinates + // @return The directions, NORTH or SOUTH and EAST or WEST. These + // are properties of the function. + node = dojo.byId(node); + var mouse = dojo.html.getCursorPosition(e); + + with (dojo.html) { + var absolute = getAbsolutePosition(node, true); + var bb = getBorderBox(node); + var nodecenterx = absolute.x + (bb.width / 2); + var nodecentery = absolute.y + (bb.height / 2); + } + + with (dojo.html.gravity) { + return ((mouse.x < nodecenterx ? WEST : EAST) | (mouse.y < nodecentery ? NORTH : SOUTH)); // integer + } +} + +dojo.html.gravity.NORTH = 1; +dojo.html.gravity.SOUTH = 1 << 1; +dojo.html.gravity.EAST = 1 << 2; +dojo.html.gravity.WEST = 1 << 3; + +dojo.html.overElement = function(/* HTMLElement */element, /* DOMEvent */e){ + // summary + // Returns whether the mouse is over the passed element. + // Element must be display:block (ie, not a ) + element = dojo.byId(element); + var mouse = dojo.html.getCursorPosition(e); + var bb = dojo.html.getBorderBox(element); + var absolute = dojo.html.getAbsolutePosition(element, true, dojo.html.boxSizing.BORDER_BOX); + var top = absolute.y; + var bottom = top + bb.height; + var left = absolute.x; + var right = left + bb.width; + + return (mouse.x >= left + && mouse.x <= right + && mouse.y >= top + && mouse.y <= bottom + ); // boolean +} + +dojo.html.renderedTextContent = function(/* HTMLElement */node){ + // summary + // Attempts to return the text as it would be rendered, with the line breaks + // sorted out nicely. Unfinished. + node = dojo.byId(node); + var result = ""; + if (node == null) { return result; } + for (var i = 0; i < node.childNodes.length; i++) { + switch (node.childNodes[i].nodeType) { + case 1: // ELEMENT_NODE + case 5: // ENTITY_REFERENCE_NODE + var display = "unknown"; + try { + display = dojo.html.getStyle(node.childNodes[i], "display"); + } catch(E) {} + switch (display) { + case "block": case "list-item": case "run-in": + case "table": case "table-row-group": case "table-header-group": + case "table-footer-group": case "table-row": case "table-column-group": + case "table-column": case "table-cell": case "table-caption": + // TODO: this shouldn't insert double spaces on aligning blocks + result += "\n"; + result += dojo.html.renderedTextContent(node.childNodes[i]); + result += "\n"; + break; + + case "none": break; + + default: + if(node.childNodes[i].tagName && node.childNodes[i].tagName.toLowerCase() == "br") { + result += "\n"; + } else { + result += dojo.html.renderedTextContent(node.childNodes[i]); + } + break; + } + break; + case 3: // TEXT_NODE + case 2: // ATTRIBUTE_NODE + case 4: // CDATA_SECTION_NODE + var text = node.childNodes[i].nodeValue; + var textTransform = "unknown"; + try { + textTransform = dojo.html.getStyle(node, "text-transform"); + } catch(E) {} + switch (textTransform){ + case "capitalize": + var words = text.split(' '); + for(var i=0; i]/i).test(txt.replace(/^\s+/))) { + txt = "" + txt + "
    "; + tableType = "cell"; + } else if((/^]/i).test(txt.replace(/^\s+/))) { + txt = "" + txt + "
    "; + tableType = "row"; + } else if((/^<(thead|tbody|tfoot)[\s\r\n>]/i).test(txt.replace(/^\s+/))) { + txt = "" + txt + "
    "; + tableType = "section"; + } + tn.innerHTML = txt; + if(tn["normalize"]){ + tn.normalize(); + } + + var parent = null; + switch(tableType) { + case "cell": + parent = tn.getElementsByTagName("tr")[0]; + break; + case "row": + parent = tn.getElementsByTagName("tbody")[0]; + break; + case "section": + parent = tn.getElementsByTagName("table")[0]; + break; + default: + parent = tn; + break; + } + + /* this doesn't make much sense, I'm assuming it just meant trim() so wrap was replaced with trim + if(wrap){ + var ret = []; + // start hack + var fc = tn.firstChild; + ret[0] = ((fc.nodeValue == " ")||(fc.nodeValue == "\t")) ? fc.nextSibling : fc; + // end hack + // tn.style.display = "none"; + dojo.body().removeChild(tn); + return ret; + } + */ + var nodes = []; + for(var x=0; x view.width) { + x = view.width - w; + match = false; + } else { + x = tryX; + } + x = Math.max(padding[0], x) + scroll.x; + + var y = tryY + h; + if(y > view.height) { + y = view.height - h; + match = false; + } else { + y = tryY; + } + y = Math.max(padding[1], y) + scroll.y; + + if(match){ //perfect match, return now + bestx = x; + besty = y; + bestDistance = 0; + bestCorner = corner; + break; + }else{ + //not perfect, find out whether it is better than the saved one + var dist = Math.pow(x-tryX-scroll.x,2)+Math.pow(y-tryY-scroll.y,2); + if(bestDistance > dist){ + bestDistance = dist; + bestx = x; + besty = y; + bestCorner = corner; + } + } + } + + if(!tryOnly){ + node.style.left = bestx + "px"; + node.style.top = besty + "px"; + } + + return { left: bestx, top: besty, x: bestx, y: besty, dist: bestDistance, corner: bestCorner}; // object +} + +dojo.html.placeOnScreenPoint = function(node, desiredX, desiredY, padding, hasScroll) { + dojo.deprecated("dojo.html.placeOnScreenPoint", "use dojo.html.placeOnScreen() instead", "0.5"); + return dojo.html.placeOnScreen(node, desiredX, desiredY, padding, hasScroll, ['TL', 'TR', 'BL', 'BR']); +} + +dojo.html.placeOnScreenAroundElement = function( + /* HTMLElement */node, + /* HTMLElement */aroundNode, + /* integer */padding, + /* string? */aroundType, + /* string? */aroundCorners, + /* boolean? */tryOnly +){ + // summary + // Like placeOnScreen, except it accepts aroundNode instead of x,y + // and attempts to place node around it. aroundType (see + // dojo.html.boxSizing in html/layout.js) determines which box of the + // aroundNode should be used to calculate the outer box. + // aroundCorners specify Which corner of aroundNode should be + // used to place the node => which corner(s) of node to use (see the + // corners parameter in dojo.html.placeOnScreen) + // aroundCorners: {'TL': 'BL', 'BL': 'TL'} + + var best, bestDistance=Infinity; + aroundNode = dojo.byId(aroundNode); + var oldDisplay = aroundNode.style.display; + aroundNode.style.display=""; + var mb = dojo.html.getElementBox(aroundNode, aroundType); + var aroundNodeW = mb.width; + var aroundNodeH = mb.height; + var aroundNodePos = dojo.html.getAbsolutePosition(aroundNode, true, aroundType); + aroundNode.style.display=oldDisplay; + + for(var nodeCorner in aroundCorners){ + var pos, desiredX, desiredY; + var corners = aroundCorners[nodeCorner]; + + desiredX = aroundNodePos.x + (nodeCorner.charAt(1)=='L' ? 0 : aroundNodeW); + desiredY = aroundNodePos.y + (nodeCorner.charAt(0)=='T' ? 0 : aroundNodeH); + + pos = dojo.html.placeOnScreen(node, desiredX, desiredY, padding, true, corners, true); + if(pos.dist == 0){ + best = pos; + break; + }else{ + //not perfect, find out whether it is better than the saved one + if(bestDistance > pos.dist){ + bestDistance = pos.dist; + best = pos; + } + } + } + + if(!tryOnly){ + node.style.left = best.left + "px"; + node.style.top = best.top + "px"; + } + return best; // object +} + +dojo.html.scrollIntoView = function(/* HTMLElement */node){ + // summary + // Scroll the passed node into view, if it is not. + if(!node){ return; } + + // don't rely on that node.scrollIntoView works just because the function is there + // it doesnt work in Konqueror or Opera even though the function is there and probably + // not safari either + // dont like browser sniffs implementations but sometimes you have to use it + if(dojo.render.html.ie){ + //only call scrollIntoView if there is a scrollbar for this menu, + //otherwise, scrollIntoView will scroll the window scrollbar + if(dojo.html.getBorderBox(node.parentNode).height <= node.parentNode.scrollHeight){ + node.scrollIntoView(false); + } + }else if(dojo.render.html.mozilla){ + // IE, mozilla + node.scrollIntoView(false); + }else{ + var parent = node.parentNode; + var parentBottom = parent.scrollTop + dojo.html.getBorderBox(parent).height; + var nodeBottom = node.offsetTop + dojo.html.getMarginBox(node).height; + if(parentBottom < nodeBottom){ + parent.scrollTop += (nodeBottom - parentBottom); + }else if(parent.scrollTop > node.offsetTop){ + parent.scrollTop -= (parent.scrollTop - node.offsetTop); + } + } +} + +dojo.provide("dojo.lfx.toggle"); + + +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.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.provide("dojo.widget.HtmlWidget"); + + + + + + + + +dojo.declare("dojo.widget.HtmlWidget", dojo.widget.DomWidget, { + // summary + // Base class for all browser based widgets, or at least "html" widgets. + // The meaning of "html" has become unclear; in practice, all widgets derive from this class. + + // templateCssPath: String + // Path to CSS file for this widget + templateCssPath: null, + + // templatePath: String + // Path to template (HTML file) for this widget + templatePath: null, + + // lang: String + // Language to display this widget in (like en-us). + // Defaults to brower's specified preferred language (typically the language of the OS) + lang: "", + + // toggle: String + // Controls animation effect for when show() and hide() (or toggle()) are called. + // Possible values: "plain", "wipe", "fade", "explode" + toggle: "plain", + + // toggleDuration: Integer + // Number of milliseconds for toggle animation effect to complete + toggleDuration: 150, + + initialize: function(args, frag){ + // summary: called after the widget is rendered; most subclasses won't override or call this function + }, + + postMixInProperties: function(args, frag){ + if(this.lang === ""){this.lang = null;} + // now that we know the setting for toggle, get toggle object + // (default to plain toggler if user specified toggler not present) + this.toggleObj = + dojo.lfx.toggle[this.toggle.toLowerCase()] || dojo.lfx.toggle.plain; + }, + + createNodesFromText: function(txt, wrap){ + return dojo.html.createNodesFromText(txt, wrap); + }, + + destroyRendering: function(finalize){ + try{ + if(this.bgIframe){ + this.bgIframe.remove(); + delete this.bgIframe; + } + if(!finalize && this.domNode){ + dojo.event.browser.clean(this.domNode); + } + dojo.widget.HtmlWidget.superclass.destroyRendering.call(this); + }catch(e){ /* squelch! */ } + }, + + ///////////////////////////////////////////////////////// + // Displaying/hiding the widget + ///////////////////////////////////////////////////////// + isShowing: function(){ + // summary + // Tests whether widget is set to show-mode or hide-mode (see show() and + // hide() methods) + // + // This function is poorly named. Even if widget is in show-mode, + // if it's inside a container that's hidden + // (either a container widget, or just a domnode with display:none), + // then it won't be displayed + return dojo.html.isShowing(this.domNode); // Boolean + }, + + toggleShowing: function(){ + // summary: show or hide the widget, to switch it's state + if(this.isShowing()){ + this.hide(); + }else{ + this.show(); + } + }, + + show: function(){ + // summary: show the widget + if(this.isShowing()){ return; } + this.animationInProgress=true; + this.toggleObj.show(this.domNode, this.toggleDuration, null, + dojo.lang.hitch(this, this.onShow), this.explodeSrc); + }, + + onShow: function(){ + // summary: called after the show() animation has completed + this.animationInProgress=false; + this.checkSize(); + }, + + hide: function(){ + // summary: hide the widget (ending up with display:none) + if(!this.isShowing()){ return; } + this.animationInProgress = true; + this.toggleObj.hide(this.domNode, this.toggleDuration, null, + dojo.lang.hitch(this, this.onHide), this.explodeSrc); + }, + + onHide: function(){ + // summary: called after the hide() animation has completed + this.animationInProgress=false; + }, + + ////////////////////////////////////////////////////////////////////////////// + // Sizing related methods + // If the parent changes size then for each child it should call either + // - resizeTo(): size the child explicitly + // - or checkSize(): notify the child the the parent has changed size + ////////////////////////////////////////////////////////////////////////////// + + _isResized: function(w, h){ + // summary + // Test if my size has changed. + // If width & height are specified then that's my new size; otherwise, + // query outerWidth/outerHeight of my domNode + + // If I'm not being displayed then disregard (show() must + // check if the size has changed) + if(!this.isShowing()){ return false; } + + // If my parent has been resized and I have style="height: 100%" + // or something similar then my size has changed too. + var wh = dojo.html.getMarginBox(this.domNode); + var width=w||wh.width; + var height=h||wh.height; + if(this.width == width && this.height == height){ return false; } + + this.width=width; + this.height=height; + return true; + }, + + checkSize: function(){ + // summary + // Called when my parent has changed size, but my parent won't call resizeTo(). + // This is useful if my size is height:100% or something similar. + // Also called whenever I am shown, because the first time I am shown I may need + // to do size calculations. + if(!this._isResized()){ return; } + this.onResized(); + }, + + resizeTo: function(w, h){ + // summary: explicitly set this widget's size (in pixels). + dojo.html.setMarginBox(this.domNode, { width: w, height: h }); + + // can't do sizing if widget is hidden because referencing node.offsetWidth/node.offsetHeight returns 0. + // do sizing on show() instead. + if(this.isShowing()){ + this.onResized(); + } + }, + + resizeSoon: function(){ + // summary + // schedule onResized() to be called soon, after browser has had + // a little more time to calculate the sizes + if(this.isShowing()){ + dojo.lang.setTimeout(this, this.onResized, 0); + } + }, + + onResized: function(){ + // summary + // Called when my size has changed. + // Must notify children if their size has (possibly) changed. + dojo.lang.forEach(this.children, function(child){ if(child.checkSize){child.checkSize();} }); + } +}); + +dojo.kwCompoundRequire({ + common: ["dojo.xml.Parse", + "dojo.widget.Widget", + "dojo.widget.Parse", + "dojo.widget.Manager"], + browser: ["dojo.widget.DomWidget", + "dojo.widget.HtmlWidget"], + dashboard: ["dojo.widget.DomWidget", + "dojo.widget.HtmlWidget"], + svg: ["dojo.widget.SvgWidget"], + rhino: ["dojo.widget.SwtWidget"] +}); +dojo.provide("dojo.widget.*"); + +dojo.kwCompoundRequire({ + common: [ "dojo.html.common", + "dojo.html.style" ] +}); +dojo.provide("dojo.html.*"); + + +dojo.provide("dojo.html.selection"); + + + + +/** + * type of selection +**/ +dojo.html.selectionType = { + NONE : 0, //selection is empty + TEXT : 1, //selection contains text (may also contains CONTROL objects) + CONTROL : 2 //only one element is selected (such as img, table etc) +}; + +dojo.html.clearSelection = function(){ + // summary: deselect the current selection to make it empty + var _window = dojo.global(); + var _document = dojo.doc(); + try{ + if(_window["getSelection"]){ + if(dojo.render.html.safari){ + // pulled from WebCore/ecma/kjs_window.cpp, line 2536 + _window.getSelection().collapse(); + }else{ + _window.getSelection().removeAllRanges(); + } + }else if(_document.selection){ + if(_document.selection.empty){ + _document.selection.empty(); + }else if(_document.selection.clear){ + _document.selection.clear(); + } + } + return true; + }catch(e){ + dojo.debug(e); + return false; + } +} + +dojo.html.disableSelection = function(/*DomNode*/element){ + // summary: disable selection on a node + element = dojo.byId(element)||dojo.body(); + var h = dojo.render.html; + + if(h.mozilla){ + element.style.MozUserSelect = "none"; + }else if(h.safari){ + element.style.KhtmlUserSelect = "none"; + }else if(h.ie){ + element.unselectable = "on"; + }else{ + return false; + } + return true; +} + +dojo.html.enableSelection = function(/*DomNode*/element){ + // summary: enable selection on a node + element = dojo.byId(element)||dojo.body(); + + var h = dojo.render.html; + if(h.mozilla){ + element.style.MozUserSelect = ""; + }else if(h.safari){ + element.style.KhtmlUserSelect = ""; + }else if(h.ie){ + element.unselectable = "off"; + }else{ + return false; + } + return true; +} + +dojo.html.selectElement = function(/*DomNode*/element){ + dojo.deprecated("dojo.html.selectElement", "replaced by dojo.html.selection.selectElementChildren", 0.5); +} + +dojo.html.selectInputText = function(/*DomNode*/element){ + // summary: select all the text in an input element + var _window = dojo.global(); + var _document = dojo.doc(); + element = dojo.byId(element); + if(_document["selection"] && dojo.body()["createTextRange"]){ // IE + var range = element.createTextRange(); + range.moveStart("character", 0); + range.moveEnd("character", element.value.length); + range.select(); + }else if(_window["getSelection"]){ + var selection = _window.getSelection(); + // FIXME: does this work on Safari? + element.setSelectionRange(0, element.value.length); + } + element.focus(); +} + + +dojo.html.isSelectionCollapsed = function(){ + dojo.deprecated("dojo.html.isSelectionCollapsed", "replaced by dojo.html.selection.isCollapsed", 0.5); + return dojo.html.selection.isCollapsed(); +} + +dojo.lang.mixin(dojo.html.selection, { + getType: function() { + // summary: Get the selection type (like document.select.type in IE). + if(dojo.doc()["selection"]){ //IE + return dojo.html.selectionType[dojo.doc().selection.type.toUpperCase()]; + }else{ + var stype = dojo.html.selectionType.TEXT; + + // Check if the actual selection is a CONTROL (IMG, TABLE, HR, etc...). + var oSel; + try {oSel = dojo.global().getSelection();} + catch (e) {} + + if(oSel && oSel.rangeCount==1){ + var oRange = oSel.getRangeAt(0); + if (oRange.startContainer == oRange.endContainer && (oRange.endOffset - oRange.startOffset) == 1 + && oRange.startContainer.nodeType != dojo.dom.TEXT_NODE) { + stype = dojo.html.selectionType.CONTROL; + } + } + return stype; + } + }, + isCollapsed: function() { + // summary: return whether the current selection is empty + var _window = dojo.global(); + var _document = dojo.doc(); + if(_document["selection"]){ // IE + return _document.selection.createRange().text == ""; + }else if(_window["getSelection"]){ + var selection = _window.getSelection(); + if(dojo.lang.isString(selection)){ // Safari + return selection == ""; + }else{ // Mozilla/W3 + return selection.isCollapsed || selection.toString() == ""; + } + } + }, + getSelectedElement: function() { + // summary: + // Retrieves the selected element (if any), just in the case that a single + // element (object like and image or a table) is selected. + if ( dojo.html.selection.getType() == dojo.html.selectionType.CONTROL ){ + if(dojo.doc()["selection"]){ //IE + var range = dojo.doc().selection.createRange(); + + if ( range && range.item ){ + return dojo.doc().selection.createRange().item(0); + } + }else{ + var selection = dojo.global().getSelection(); + return selection.anchorNode.childNodes[ selection.anchorOffset ]; + } + } + }, + getParentElement: function() { + // summary: + // Get the parent element of the current selection + if(dojo.html.selection.getType() == dojo.html.selectionType.CONTROL){ + var p = dojo.html.selection.getSelectedElement(); + if(p){ return p.parentNode; } + }else{ + if(dojo.doc()["selection"]){ //IE + return dojo.doc().selection.createRange().parentElement(); + }else{ + var selection = dojo.global().getSelection(); + if(selection){ + var node = selection.anchorNode; + + while ( node && node.nodeType != dojo.dom.ELEMENT_NODE ){ + node = node.parentNode; + } + + return node; + } + } + } + }, + getSelectedText: function(){ + // summary: + // Return the text (no html tags) included in the current selection or null if no text is selected + if(dojo.doc()["selection"]){ //IE + if(dojo.html.selection.getType() == dojo.html.selectionType.CONTROL){ + return null; + } + return dojo.doc().selection.createRange().text; + }else{ + var selection = dojo.global().getSelection(); + if(selection){ + return selection.toString(); + } + } + }, + getSelectedHtml: function(){ + // summary: + // Return the html of the current selection or null if unavailable + if(dojo.doc()["selection"]){ //IE + if(dojo.html.selection.getType() == dojo.html.selectionType.CONTROL){ + return null; + } + return dojo.doc().selection.createRange().htmlText; + }else{ + var selection = dojo.global().getSelection(); + if(selection && selection.rangeCount){ + var frag = selection.getRangeAt(0).cloneContents(); + var div = document.createElement("div"); + div.appendChild(frag); + return div.innerHTML; + } + return null; + } + }, + hasAncestorElement: function(/*String*/tagName /* ... */){ + // summary: + // Check whether current selection has a parent element which is of type tagName (or one of the other specified tagName) + return (dojo.html.selection.getAncestorElement.apply(this, arguments) != null); + }, + getAncestorElement: function(/*String*/tagName /* ... */){ + // summary: + // Return the parent element of the current selection which is of type tagName (or one of the other specified tagName) + var node = dojo.html.selection.getSelectedElement() || dojo.html.selection.getParentElement(); + while(node /*&& node.tagName.toLowerCase() != 'body'*/){ + if(dojo.html.selection.isTag(node, arguments).length>0){ + return node; + } + node = node.parentNode; + } + return null; + }, + //modified from dojo.html.isTag to take an array as second parameter + isTag: function(/*DomNode*/node, /*Array*/tags) { + if(node && node.tagName) { + for (var i=0; i. + + Why do we want this? JavaScript has no threads, and even if it did, + threads are hard. Deferreds are a way of abstracting non-blocking + events, such as the final response to an XMLHttpRequest. + + The sequence of callbacks is internally represented as a list + of 2-tuples containing the callback/errback pair. For example, + the following call sequence:: + + var d = new Deferred(); + d.addCallback(myCallback); + d.addErrback(myErrback); + d.addBoth(myBoth); + d.addCallbacks(myCallback, myErrback); + + is translated into a Deferred with the following internal + representation:: + + [ + [myCallback, null], + [null, myErrback], + [myBoth, myBoth], + [myCallback, myErrback] + ] + + The Deferred also keeps track of its current status (fired). + Its status may be one of three things: + + -1: no value yet (initial condition) + 0: success + 1: error + + A Deferred will be in the error state if one of the following + three conditions are met: + + 1. The result given to callback or errback is "instanceof" Error + 2. The previous callback or errback raised an exception while + executing + 3. The previous callback or errback returned a value "instanceof" + Error + + Otherwise, the Deferred will be in the success state. The state of + the Deferred determines the next element in the callback sequence to + run. + + When a callback or errback occurs with the example deferred chain, + something equivalent to the following will happen (imagine that + exceptions are caught and returned):: + + // d.callback(result) or d.errback(result) + if(!(result instanceof Error)){ + result = myCallback(result); + } + if(result instanceof Error){ + result = myErrback(result); + } + result = myBoth(result); + if(result instanceof Error){ + result = myErrback(result); + }else{ + result = myCallback(result); + } + + The result is then stored away in case another step is added to the + callback sequence. Since the Deferred already has a value available, + any new callbacks added will be called immediately. + + There are two other "advanced" details about this implementation that + are useful: + + Callbacks are allowed to return Deferred instances themselves, so you + can build complicated sequences of events with ease. + + The creator of the Deferred may specify a canceller. The canceller + is a function that will be called if Deferred.cancel is called before + the Deferred fires. You can use this to implement clean aborting of + an XMLHttpRequest, etc. Note that cancel will fire the deferred with + a CancelledError (unless your canceller returns another kind of + error), so the errbacks should be prepared to handle that error for + cancellable Deferreds. + + */ + + this.chain = []; + this.id = this._nextId(); + this.fired = -1; + this.paused = 0; + this.results = [null, null]; + this.canceller = canceller; + this.silentlyCancelled = false; +}; + +dojo.lang.extend(dojo.Deferred, { + getFunctionFromArgs: function(){ + var a = arguments; + if((a[0])&&(!a[1])){ + if(dojo.lang.isFunction(a[0])){ + return a[0]; + }else if(dojo.lang.isString(a[0])){ + return dj_global[a[0]]; + } + }else if((a[0])&&(a[1])){ + return dojo.lang.hitch(a[0], a[1]); + } + return null; + }, + + makeCalled: function() { + var deferred = new dojo.Deferred(); + deferred.callback(); + return deferred; + }, + + repr: function(){ + var state; + if(this.fired == -1){ + state = 'unfired'; + }else if(this.fired == 0){ + state = 'success'; + } else { + state = 'error'; + } + return 'Deferred(' + this.id + ', ' + state + ')'; + }, + + toString: dojo.lang.forward("repr"), + + _nextId: (function(){ + var n = 1; + return function(){ return n++; }; + })(), + + cancel: function(){ + // summary: Cancels a Deferred that has not yet received a value, or is + // waiting on another Deferred as its value. + // description: + // If a canceller is defined, the canceller is called. If the + // canceller did not return an error, or there was no canceller, + // then the errback chain is started with CancelledError. + if(this.fired == -1){ + if (this.canceller){ + this.canceller(this); + }else{ + this.silentlyCancelled = true; + } + if(this.fired == -1){ + this.errback(new Error(this.repr())); + } + }else if( (this.fired == 0)&& + (this.results[0] instanceof dojo.Deferred)){ + this.results[0].cancel(); + } + }, + + + _pause: function(){ + // summary: Used internally to signal that it's waiting on another Deferred + this.paused++; + }, + + _unpause: function(){ + // summary: Used internally to signal that it's no longer waiting on + // another Deferred. + this.paused--; + if ((this.paused == 0) && (this.fired >= 0)) { + this._fire(); + } + }, + + _continue: function(res){ + // summary: Used internally when a dependent deferred fires. + this._resback(res); + this._unpause(); + }, + + _resback: function(res){ + // The primitive that means either callback or errback + this.fired = ((res instanceof Error) ? 1 : 0); + this.results[this.fired] = res; + this._fire(); + }, + + _check: function(){ + if(this.fired != -1){ + if(!this.silentlyCancelled){ + dojo.raise("already called!"); + } + this.silentlyCancelled = false; + return; + } + }, + + callback: function(res){ + // summary: Begin the callback sequence with a non-error value. + + /* + callback or errback should only be called once on a given + Deferred. + */ + this._check(); + this._resback(res); + }, + + errback: function(res){ + // summary: Begin the callback sequence with an error result. + this._check(); + if(!(res instanceof Error)){ + res = new Error(res); + } + this._resback(res); + }, + + addBoth: function(cb, cbfn){ + /* summary + Add the same function as both a callback and an errback as the + next element on the callback sequence. This is useful for code + that you want to guarantee to run, e.g. a finalizer. + */ + var enclosed = this.getFunctionFromArgs(cb, cbfn); + if(arguments.length > 2){ + enclosed = dojo.lang.curryArguments(null, enclosed, arguments, 2); + } + return this.addCallbacks(enclosed, enclosed); + }, + + addCallback: function(cb, cbfn){ + // summary: Add a single callback to the end of the callback sequence. + var enclosed = this.getFunctionFromArgs(cb, cbfn); + if(arguments.length > 2){ + enclosed = dojo.lang.curryArguments(null, enclosed, arguments, 2); + } + return this.addCallbacks(enclosed, null); + }, + + addErrback: function(cb, cbfn){ + // summary: Add a single callback to the end of the callback sequence. + var enclosed = this.getFunctionFromArgs(cb, cbfn); + if(arguments.length > 2){ + enclosed = dojo.lang.curryArguments(null, enclosed, arguments, 2); + } + return this.addCallbacks(null, enclosed); + return this.addCallbacks(null, cbfn); + }, + + addCallbacks: function (cb, eb) { + // summary: Add separate callback and errback to the end of the callback + // sequence. + this.chain.push([cb, eb]) + if (this.fired >= 0) { + this._fire(); + } + return this; + }, + + _fire: function(){ + // summary: Used internally to exhaust the callback sequence when a result + // is available. + var chain = this.chain; + var fired = this.fired; + var res = this.results[fired]; + var self = this; + var cb = null; + while (chain.length > 0 && this.paused == 0) { + // Array + var pair = chain.shift(); + var f = pair[fired]; + if (f == null) { + continue; + } + try { + res = f(res); + fired = ((res instanceof Error) ? 1 : 0); + if(res instanceof dojo.Deferred) { + cb = function(res){ + self._continue(res); + } + this._pause(); + } + }catch(err){ + fired = 1; + res = err; + } + } + this.fired = fired; + this.results[fired] = res; + if((cb)&&(this.paused)){ + // this is for "tail recursion" in case the dependent + // deferred is already fired + res.addBoth(cb); + } + } +}); + + /* -*- tab-width: 4 -*- */ +dojo.provide("dojo.widget.RichText"); + + + + + + + + + + +// used to save content +// but do not try doing document.write if we are using xd loading. +// document.write will only work if RichText.js is included in the dojo.js +// file. If it is included in dojo.js and you want to allow rich text saving +// for back/forward actions, then set djConfig.allowXdRichTextSave = true. +if(!djConfig["useXDomain"] || djConfig["allowXdRichTextSave"]){ + if(dojo.hostenv.post_load_){ + (function(){ + var savetextarea = dojo.doc().createElement('textarea'); + savetextarea.id = "dojo.widget.RichText.savedContent"; + savetextarea.style = "display:none;position:absolute;top:-100px;left:-100px;height:3px;width:3px;overflow:hidden;"; + dojo.body().appendChild(savetextarea); + })(); + }else{ + //dojo.body() is not available before onLoad is fired + try { + dojo.doc().write(''); + }catch(e){ } + } +} + +dojo.widget.defineWidget( + "dojo.widget.RichText", + dojo.widget.HtmlWidget, + function(){ + // summary: + // dojo.widget.RichText is the core of the WYSIWYG editor in dojo, which + // provides the basic editing features. It also encapsulates the differences + // of different js engines for various browsers + + // contentPreFilters: Array + // pre content filter function register array + this.contentPreFilters = []; + + // contentPostFilters: Array + // post content filter function register array + this.contentPostFilters = []; + + // contentDomPreFilters: Array + // pre content dom filter function register array + this.contentDomPreFilters = []; + + // contentDomPostFilters: Array + // post content dom filter function register array + this.contentDomPostFilters = []; + + // editingAreaStyleSheets: Array + // array to store all the stylesheets applied to the editing area + this.editingAreaStyleSheets=[]; + + if(dojo.render.html.moz){ + this.contentPreFilters.push(this._fixContentForMoz); + } + + this._keyHandlers = {}; + + if(dojo.Deferred){ + this.onLoadDeferred = new dojo.Deferred(); + } + }, + { + // inheritWidth: Boolean + // whether to inherit the parent's width or simply use 100% + inheritWidth: false, + + // focusOnLoad: Boolean + // whether focusing into this instance of richtext when page onload + focusOnLoad: false, + + // saveName: String + // If a save name is specified the content is saved and restored when the user + // leave this page can come back, or if the editor is not properly closed after + // editing has started. + saveName: "", + + // styleSheets: String + // semicolon (";") separated list of css files for the editing area + styleSheets: "", + + // _content: String + // temporary content storage + _content: "", + + // height: String + // set height to fix the editor at a specific height, with scrolling + height: "", + + // minHeight: String + // The minimum height that the editor should have + minHeight: "1em", + + // isClosed: Boolean + isClosed: true, + + // isLoaded: Boolean + isLoaded: false, + + // useActiveX: Boolean + // whether to use the active-x object in IE + useActiveX: false, + + // relativeImageUrls: Boolean + // whether to use relative URLs for images - if this is enabled + // images will be given absolute URLs when inside the editor but + // will be changed to use relative URLs (to the current page) on save + relativeImageUrls: false, + + // _SEPARATOR: String + // used to concat contents from multiple textareas into a single string + _SEPARATOR: "@@**%%__RICHTEXTBOUNDRY__%%**@@", + + // onLoadDeferred: dojo.Deferred + // deferred that can be used to connect to the onLoad function. This + // will only be set if dojo.Deferred is required + onLoadDeferred: null, + + /* Init + *******/ + + fillInTemplate: function(){ + // summary: see dojo.widget.DomWidget + dojo.event.topic.publish("dojo.widget.RichText::init", this); + this.open(); + + + // backwards compatibility, needs to be removed + dojo.event.connect(this, "onKeyPressed", this, "afterKeyPress"); + dojo.event.connect(this, "onKeyPress", this, "keyPress"); + dojo.event.connect(this, "onKeyDown", this, "keyDown"); + dojo.event.connect(this, "onKeyUp", this, "keyUp"); + + this.setupDefaultShortcuts(); + }, + + setupDefaultShortcuts: function(){ + // summary: add some default key handlers + // description: + // Overwrite this to setup your own handlers. The default + // implementation does not use Editor2 commands, but directly + // executes the builtin commands within the underlying browser + // support. + var ctrl = this.KEY_CTRL; + var exec = function (cmd, arg) { + return arguments.length == 1 ? function () { this.execCommand(cmd); } : + function () { this.execCommand(cmd, arg); } + } + this.addKeyHandler("b", ctrl, exec("bold")); + this.addKeyHandler("i", ctrl, exec("italic")); + this.addKeyHandler("u", ctrl, exec("underline")); + this.addKeyHandler("a", ctrl, exec("selectall")); + this.addKeyHandler("s", ctrl, function () { this.save(true); }); + + this.addKeyHandler("1", ctrl, exec("formatblock", "h1")); + this.addKeyHandler("2", ctrl, exec("formatblock", "h2")); + this.addKeyHandler("3", ctrl, exec("formatblock", "h3")); + this.addKeyHandler("4", ctrl, exec("formatblock", "h4")); + + this.addKeyHandler("\\", ctrl, exec("insertunorderedlist")); + if(!dojo.render.html.ie){ + this.addKeyHandler("Z", ctrl, exec("redo")); + } + }, + + // events: Array + // events which should be connected to the underlying editing area + events: ["onBlur", "onFocus", "onKeyPress", "onKeyDown", "onKeyUp", "onClick"], + + /** + * Transforms the node referenced in this.domNode into a rich text editing + * node. This can result in the creation and replacement with an