Index: openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/LICENSE =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/Attic/LICENSE,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/LICENSE 6 Nov 2006 14:37:19 -0000 1.1 @@ -0,0 +1,195 @@ +Dojo is availble under *either* the terms of the modified BSD license *or* the +Academic Free License version 2.1. As a recipient of Dojo, you may choose which +license to receive this code under (except as noted in per-module LICENSE +files). Some modules may not be the copyright of the Dojo Foundation. These +modules contain explicit declarations of copyright in both the LICENSE files in +the directories in which they reside and in the code itself. No external +contributions are allowed under licenses which are fundamentally incompatible +with the AFL or BSD licenses that Dojo is distributed under. + +The text of the AFL and BSD licenses is reproduced below. + +------------------------------------------------------------------------------- +The "New" BSD License: +********************** + +Copyright (c) 2005, The Dojo Foundation +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of the Dojo Foundation nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +------------------------------------------------------------------------------- +The Academic Free License, v. 2.1: +********************************** + +This Academic Free License (the "License") applies to any original work of +authorship (the "Original Work") whose owner (the "Licensor") has placed the +following notice immediately following the copyright notice for the Original +Work: + +Licensed under the Academic Free License version 2.1 + +1) Grant of Copyright License. Licensor hereby grants You a world-wide, +royalty-free, non-exclusive, perpetual, sublicenseable license to do the +following: + +a) to reproduce the Original Work in copies; + +b) to prepare derivative works ("Derivative Works") based upon the Original +Work; + +c) to distribute copies of the Original Work and Derivative Works to the +public; + +d) to perform the Original Work publicly; and + +e) to display the Original Work publicly. + +2) Grant of Patent License. Licensor hereby grants You a world-wide, +royalty-free, non-exclusive, perpetual, sublicenseable license, under patent +claims owned or controlled by the Licensor that are embodied in the Original +Work as furnished by the Licensor, to make, use, sell and offer for sale the +Original Work and Derivative Works. + +3) Grant of Source Code License. The term "Source Code" means the preferred +form of the Original Work for making modifications to it and all available +documentation describing how to modify the Original Work. Licensor hereby +agrees to provide a machine-readable copy of the Source Code of the Original +Work along with each copy of the Original Work that Licensor distributes. +Licensor reserves the right to satisfy this obligation by placing a +machine-readable copy of the Source Code in an information repository +reasonably calculated to permit inexpensive and convenient access by You for as +long as Licensor continues to distribute the Original Work, and by publishing +the address of that information repository in a notice immediately following +the copyright notice that applies to the Original Work. + +4) Exclusions From License Grant. Neither the names of Licensor, nor the names +of any contributors to the Original Work, nor any of their trademarks or +service marks, may be used to endorse or promote products derived from this +Original Work without express prior written permission of the Licensor. Nothing +in this License shall be deemed to grant any rights to trademarks, copyrights, +patents, trade secrets or any other intellectual property of Licensor except as +expressly stated herein. No patent license is granted to make, use, sell or +offer to sell embodiments of any patent claims other than the licensed claims +defined in Section 2. No right is granted to the trademarks of Licensor even if +such marks are included in the Original Work. Nothing in this License shall be +interpreted to prohibit Licensor from licensing under different terms from this +License any Original Work that Licensor otherwise would have a right to +license. + +5) This section intentionally omitted. + +6) Attribution Rights. You must retain, in the Source Code of any Derivative +Works that You create, all copyright, patent or trademark notices from the +Source Code of the Original Work, as well as any notices of licensing and any +descriptive text identified therein as an "Attribution Notice." You must cause +the Source Code for any Derivative Works that You create to carry a prominent +Attribution Notice reasonably calculated to inform recipients that You have +modified the Original Work. + +7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that +the copyright in and to the Original Work and the patent rights granted herein +by Licensor are owned by the Licensor or are sublicensed to You under the terms +of this License with the permission of the contributor(s) of those copyrights +and patent rights. Except as expressly stated in the immediately proceeding +sentence, the Original Work is provided under this License on an "AS IS" BASIS +and WITHOUT WARRANTY, either express or implied, including, without limitation, +the warranties of NON-INFRINGEMENT, MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. +This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No +license to Original Work is granted hereunder except under this disclaimer. + +8) Limitation of Liability. Under no circumstances and under no legal theory, +whether in tort (including negligence), contract, or otherwise, shall the +Licensor be liable to any person for any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License +or the use of the Original Work including, without limitation, damages for loss +of goodwill, work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses. This limitation of liability shall not +apply to liability for death or personal injury resulting from Licensor's +negligence to the extent applicable law prohibits such limitation. Some +jurisdictions do not allow the exclusion or limitation of incidental or +consequential damages, so this exclusion and limitation may not apply to You. + +9) Acceptance and Termination. If You distribute copies of the Original Work or +a Derivative Work, You must make a reasonable effort under the circumstances to +obtain the express assent of recipients to the terms of this License. Nothing +else but this License (or another written agreement between Licensor and You) +grants You permission to create Derivative Works based upon the Original Work +or to exercise any of the rights granted in Section 1 herein, and any attempt +to do so except under the terms of this License (or another written agreement +between Licensor and You) is expressly prohibited by U.S. copyright law, the +equivalent laws of other countries, and by international treaty. Therefore, by +exercising any of the rights granted to You in Section 1 herein, You indicate +Your acceptance of this License and all of its terms and conditions. + +10) Termination for Patent Action. This License shall terminate automatically +and You may no longer exercise any of the rights granted to You by this License +as of the date You commence an action, including a cross-claim or counterclaim, +against Licensor or any licensee alleging that the Original Work infringes a +patent. This termination provision shall not apply for an action alleging +patent infringement by combinations of the Original Work with other software or +hardware. + +11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this +License may be brought only in the courts of a jurisdiction wherein the +Licensor resides or in which Licensor conducts its primary business, and under +the laws of that jurisdiction excluding its conflict-of-law provisions. The +application of the United Nations Convention on Contracts for the International +Sale of Goods is expressly excluded. Any use of the Original Work outside the +scope of this License or after its termination shall be subject to the +requirements and penalties of the U.S. Copyright Act, 17 U.S.C. § 101 et +seq., the equivalent laws of other countries, and international treaty. This +section shall survive the termination of this License. + +12) Attorneys Fees. In any action to enforce the terms of this License or +seeking damages relating thereto, the prevailing party shall be entitled to +recover its costs and expenses, including, without limitation, reasonable +attorneys' fees and costs incurred in connection with such action, including +any appeal of such action. This section shall survive the termination of this +License. + +13) Miscellaneous. This License represents the complete agreement concerning +the subject matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent necessary to +make it enforceable. + +14) Definition of "You" in This License. "You" throughout this License, whether +in upper or lower case, means an individual or a legal entity exercising rights +under, and complying with all of the terms of, this License. For legal +entities, "You" includes any entity that controls, is controlled by, or is +under common control with you. For purposes of this definition, "control" means +(i) the power, direct or indirect, to cause the direction or management of such +entity, whether by contract or otherwise, or (ii) ownership of fifty percent +(50%) or more of the outstanding shares, or (iii) beneficial ownership of such +entity. + +15) Right to Use. You may use the Original Work in all ways not otherwise +restricted or conditioned by this License or by law, and Licensor promises not +to interfere with or be responsible for such uses by You. + +This license is Copyright (C) 2003-2004 Lawrence E. Rosen. All rights reserved. +Permission is hereby granted to copy and distribute this license without +modification. This license may not be modified without the express written +permission of its copyright owner. Index: openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/README =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/Attic/README,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/README 6 Nov 2006 14:37:19 -0000 1.1 @@ -0,0 +1,176 @@ +The Dojo Toolkit +---------------- + +Dojo is a portable JavaScript toolkit for web application developers and +JavaScript professionals. Dojo solves real-world problems by providing powerful +abstractions and solid, tested implementations. + +Getting Started +--------------- + +To use Dojo in your application, download one of the pre-built editions from the +Dojo website, http://dojotoolkit.org. Once you have downloaded the file you will +need to unzip the archive in your website root. At a minimum, you will need to +extract: + + src/ (folder) + dojo.js + iframe_history.html + +To begin using dojo, include dojo in your pages by using: + + + +Depending on the edition that you have downloaded, this base dojo.js file may or +may not include the modules you wish to use in your application. The files which +have been "baked in" to the dojo.js that is part of your distribution are listed +in the file build.txt that is part of the top-level directory that is created +when you unpack the archive. To ensure modules you wish to use are available, +use dojo.require() to request them. A very rich application might include: + + + + +Note that only those modules which are *not* already "baked in" to dojo.js by +the edition's build process are requested by dojo.require(). This helps make +your application faster without forcing you to use a build tool while in +development. See "Building Dojo" and "Working From Source" for more details. + + +Compatibility +------------- + +In addition to it's suite of unit-tests for core system components, Dojo has +been tested on almost every modern browser, including: + + - IE 5.5+ + - Mozilla 1.5+, Firefox 1.0+ + - Safari 1.3.9+ + - Konqueror 3.4+ + - Opera 8.5+ + +Note that some widgets and features may not perform exactly the same on every +browser due to browser implementation differences. + +For those looking to use Dojo in non-browser environments, please see "Working +From Source". + + +Documentation and Getting Help +------------------------------ + +Articles outlining major Dojo systems are linked from: + + http://dojotoolkit.org/docs/ + +Toolkit APIs are listed in outline form at: + + http://dojotoolkit.org/docs/apis/ + +And documented in full at: + + http://manual.dojotoolkit.org/ + +The project also maintains a JotSpot Wiki at: + + http://dojo.jot.com/ + +A FAQ has been extracted from mailing list traffic: + + http://dojo.jot.com/FAQ + +And the main Dojo user mailing list is archived and made searchable at: + + http://news.gmane.org/gmane.comp.web.dojo.user/ + +You can sign up for this list, which is a great place to ask questions, at: + + http://dojotoolkit.org/mailman/listinfo/dojo-interest + +The Dojo developers also tend to hang out in IRC and help people with Dojo +problems. You're most likely to find them at: + + irc.freenode.net #dojo + +Note that 2PM Wed PST in this channel is reserved for a weekly meeting between +project developers, although anyone is welcome to participate. + + +Working From Source +------------------- + +The core of Dojo is a powerful package system that allows developers to optimize +Dojo for deployment while using *exactly the same* application code in +development. Therefore, working from source is almost exactly like working from +a pre-built edition. Pre-built editions are significantly faster to load than +working from source, but are not as flexible when in development. + +There are multiple ways to get the source. Nightly snapshots of the Dojo source +repository are available at: + + http://archive.dojotoolkit.org/nightly.tgz + +Anonymous Subversion access is also available: + + %> svn co http://svn.dojotoolkit.org/dojo/trunk/ dojo + +Each of these sources will include some extra directories not included in the +pre-packaged editions, including command-line tests and build tools for +constructing your own packages. + +Running the command-line unit test suite requires Ant 1.6. If it is installed +and in your path, you can run the tests using: + + %> cd buildscripts + %> ant test + +The command-line test harness makes use of Rhino, a JavaScript interpreter +written in Java. Once you have a copy of Dojo's source tree, you have a copy of +Rhino. From the root directory, you can use Rhino interactively to load Dojo: + + %> java -jar buildscripts/lib/js.jar + Rhino 1.5 release 3 2002 01 27 + js> load("dojo.js"); + js> print(dojo); + [object Object] + js> quit(); + +This environment is wonderful for testing raw JavaScript functionality in, or +even for scripting your system. Since Rhino has full access to anything in +Java's classpath, the sky is the limit! + +Building Dojo +------------- + +Dojo requires Ant 1.6.x in order to build correctly. While using Dojo from +source does *NOT* require that you make a build, speeding up your application by +constructing a custom profile build does. + +Once you have Ant and a source snapshot of Dojo, you can make your own profile +build ("edition") which includes only those modules your application uses by +customizing one of the files in: + + [dojo]/buildscripts/profiles/ + +These files are named *.profile.js and each one contains a list of modules to +include in a build. If we created a new profile called "test.profile.js", we +could then make a profile build using it by doing: + + %> cd buildscripts + %> ant -Dprofile=test -Ddocless=true release intern-strings + +If the build is successful, your newly minted and compressed profile build will +be placed in [dojo]/release/dojo/ + +------------------------------------------------------------------------------- +Copyright (c) 2004-2006, The Dojo Foundation, All Rights Reserved + +vim:ts=4:et:tw=80:shiftwidth=4: Index: openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/Storage_version6.swf =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/Attic/Storage_version6.swf,v diff -u Binary files differ Index: openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/Storage_version8.swf =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/Attic/Storage_version8.swf,v diff -u Binary files differ Index: openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/build.txt =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/Attic/build.txt,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/build.txt 6 Nov 2006 14:37:19 -0000 1.1 @@ -0,0 +1,39 @@ + +Files baked into this package: + +dojoGuardStart.js, +../src/bootstrap1.js, +../src/loader.js, +dojoGuardEnd.js, +../src/hostenv_browser.js, +../src/bootstrap2.js, +../src/string/common.js, +../src/string.js, +../src/lang/common.js, +../src/lang/extras.js, +../src/io/common.js, +../src/lang/array.js, +../src/lang/func.js, +../src/string/extras.js, +../src/dom.js, +../src/undo/browser.js, +../src/io/BrowserIO.js, +../src/io/cookie.js, +../src/io/__package__.js, +../src/io.js, +../src/event/common.js, +../src/event/topic.js, +../src/event/browser.js, +../src/event/__package__.js, +../src/gfx/color.js, +../src/lfx/Animation.js, +../src/uri/Uri.js, +../src/html/style.js, +../src/html/display.js, +../src/html/color.js, +../src/html/common.js, +../src/html/layout.js, +../src/lfx/html.js, +../src/lfx/__package__.js + + \ No newline at end of file Index: openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/dojo.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/Attic/dojo.js,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/dojo.js 6 Nov 2006 14:37:19 -0000 1.1 @@ -0,0 +1,6246 @@ +/* + 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:0,flag:"",revision:Number("$Rev: 6258 $".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"){ +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--){ +_73.push(_72.slice(0,i).join("-")); +} +_73.push(false); +if(_70){ +_73.reverse(); +} +for(var j=_73.length-1;j>=0;j--){ +var loc=_73[j]||"ROOT"; +var _77=_71(loc); +if(_77){ +break; +} +} +}; +dojo.hostenv.localesGenerated; +dojo.hostenv.registerNlsPrefix=function(){ +dojo.registerModulePath("nls","nls"); +}; +dojo.hostenv.preloadLocalizations=function(){ +if(dojo.hostenv.localesGenerated){ +dojo.hostenv.registerNlsPrefix(); +function preload(_78){ +_78=dojo.hostenv.normalizeLocale(_78); +dojo.hostenv.searchLocalePath(_78,true,function(loc){ +for(var i=0;i1){ +var _98=_97[1]; +var _99=_98.split("&"); +for(var x in _99){ +var sp=_99[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 _9d=document.getElementsByTagName("script"); +var _9e=/(__package__|dojo|bootstrap1)\.js([\?\.]|$)/i; +for(var i=0;i<_9d.length;i++){ +var src=_9d[i].getAttribute("src"); +if(!src){ +continue; +} +var m=src.match(_9e); +if(m){ +var _a2=src.substring(0,m.index); +if(src.indexOf("bootstrap1")>-1){ +_a2+="../"; +} +if(!this["djConfig"]){ +djConfig={}; +} +if(djConfig["baseScriptUri"]==""){ +djConfig["baseScriptUri"]=_a2; +} +if(djConfig["baseRelativePath"]==""){ +djConfig["baseRelativePath"]=_a2; +} +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 _aa=dua.indexOf("Gecko"); +drh.mozilla=drh.moz=(_aa>=0)&&(!drh.khtml); +if(drh.mozilla){ +drh.geckoVersion=dua.substring(_aa+6,_aa+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 _ac=window["document"]; +var tdi=_ac["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; +} +} +})(); +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 _b0=null; +var _b1=null; +try{ +_b0=new XMLHttpRequest(); +} +catch(e){ +} +if(!_b0){ +for(var i=0;i<3;++i){ +var _b3=dojo.hostenv._XMLHTTP_PROGIDS[i]; +try{ +_b0=new ActiveXObject(_b3); +} +catch(e){ +_b1=e; +} +if(_b0){ +dojo.hostenv._XMLHTTP_PROGIDS=[_b3]; +break; +} +} +} +if(!_b0){ +return dojo.raise("XMLHTTP not available",_b1); +} +return _b0; +}; +dojo.hostenv._blockAsync=false; +dojo.hostenv.getText=function(uri,_b5,_b6){ +if(!_b5){ +this._blockAsync=true; +} +var _b7=this.getXmlhttpObject(); +function isDocumentOk(_b8){ +var _b9=_b8["status"]; +return Boolean((!_b9)||((200<=_b9)&&(300>_b9))||(_b9==304)); +} +if(_b5){ +var _ba=this,_bb=null,gbl=dojo.global(); +var xhr=dojo.evalObjPath("dojo.io.XMLHTTPTransport"); +_b7.onreadystatechange=function(){ +if(_bb){ +gbl.clearTimeout(_bb); +_bb=null; +} +if(_ba._blockAsync||(xhr&&xhr._blockAsync)){ +_bb=gbl.setTimeout(function(){ +_b7.onreadystatechange.apply(this); +},10); +}else{ +if(4==_b7.readyState){ +if(isDocumentOk(_b7)){ +_b5(_b7.responseText); +} +} +} +}; +} +_b7.open("GET",uri,_b5?true:false); +try{ +_b7.send(null); +if(_b5){ +return null; +} +if(!isDocumentOk(_b7)){ +var err=Error("Unable to load "+uri+" status:"+_b7.status); +err.status=_b7.status; +err.responseText=_b7.responseText; +throw err; +} +} +catch(e){ +this._blockAsync=false; +if((_b6)&&(!_b5)){ +return null; +}else{ +throw e; +} +} +this._blockAsync=false; +return _b7.responseText; +}; +dojo.hostenv.defaultDebugContainerId="dojoDebug"; +dojo.hostenv._println_buffer=[]; +dojo.hostenv._println_safe=false; +dojo.hostenv.println=function(_bf){ +if(!dojo.hostenv._println_safe){ +dojo.hostenv._println_buffer.push(_bf); +}else{ +try{ +var _c0=document.getElementById(djConfig.debugContainerId?djConfig.debugContainerId:dojo.hostenv.defaultDebugContainerId); +if(!_c0){ +_c0=dojo.body(); +} +var div=document.createElement("div"); +div.appendChild(document.createTextNode(_bf)); +_c0.appendChild(div); +} +catch(e){ +try{ +document.write("
"+_bf+"
"); +} +catch(e2){ +window.status=_bf; +} +} +} +}; +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(_c2,_c3,fp,_c5){ +var _c6=_c2["on"+_c3]||function(){ +}; +_c2["on"+_c3]=function(){ +fp.apply(_c2,arguments); +_c6.apply(_c2,arguments); +}; +return true; +} +function dj_load_init(e){ +var _c8=(e&&e.type)?e.type.toLowerCase():"load"; +if(arguments.callee.initialized||(_c8!="domcontentloaded"&&_c8!="load")){ +return; +} +arguments.callee.initialized=true; +if(typeof (_timer)!="undefined"){ +clearInterval(_timer); +delete _timer; +} +var _c9=function(){ +if(dojo.render.html.ie){ +dojo.hostenv.makeWidgets(); +} +}; +if(dojo.hostenv.inFlightCount==0){ +_c9(); +dojo.hostenv.modulesLoaded(); +}else{ +dojo.addOnLoad(_c9); +} +} +if(document.addEventListener){ +if(dojo.render.html.opera||(dojo.render.html.moz&&!djConfig.delayMozLoadingFix)){ +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 _cb=[]; +if(djConfig.searchIds&&djConfig.searchIds.length>0){ +_cb=_cb.concat(djConfig.searchIds); +} +if(dojo.hostenv.searchIds&&dojo.hostenv.searchIds.length>0){ +_cb=_cb.concat(dojo.hostenv.searchIds); +} +if((djConfig.parseWidgets)||(_cb.length>0)){ +if(dojo.evalObjPath("dojo.widget.Parse")){ +var _cc=new dojo.xml.Parse(); +if(_cb.length>0){ +for(var x=0;x<_cb.length;x++){ +var _ce=document.getElementById(_cb[x]); +if(!_ce){ +continue; +} +var _cf=_cc.parseElement(_ce,null,true); +dojo.widget.getParser().createComponents(_cf); +} +}else{ +if(djConfig.parseWidgets){ +var _cf=_cc.parseElement(dojo.body(),null,true); +dojo.widget.getParser().createComponents(_cf); +} +} +} +} +}; +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;i"); +} +catch(e){ +var _ed=document.createElement("script"); +_ed.src=_ec; +document.getElementsByTagName("head")[0].appendChild(_ed); +} +} +} +})(); +dojo.provide("dojo.string.common"); +dojo.string.trim=function(str,wh){ +if(!str.replace){ +return str; +} +if(!str.length){ +return str; +} +var re=(wh>0)?(/^\s+/):(wh<0)?(/\s+$/):(/^\s+|\s+$/g); +return str.replace(re,""); +}; +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(typeof _104!="function"){ +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){ +if(!it){ +return false; +} +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()&&/\{\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,_129){ +var _12a=window,_12b=2; +if(!dojo.lang.isFunction(func)){ +_12a=func; +func=_129; +_129=arguments[2]; +_12b++; +} +if(dojo.lang.isString(func)){ +func=_12a[func]; +} +var args=[]; +for(var i=_12b;i=4){ +this.changeUrl=_141; +} +} +}; +dojo.lang.extend(dojo.io.Request,{url:"",mimetype:"text/plain",method:"GET",content:undefined,transport:undefined,changeUrl:undefined,formNode:undefined,sync:false,bindSuccess:false,useCache:false,preventCache:false,load:function(type,data,_144,_145){ +},error:function(type,_147,_148,_149){ +},timeout:function(type,_14b,_14c,_14d){ +},handle:function(type,data,_150,_151){ +},timeoutSeconds:0,abort:function(){ +},fromKwArgs:function(_152){ +if(_152["url"]){ +_152.url=_152.url.toString(); +} +if(_152["formNode"]){ +_152.formNode=dojo.byId(_152.formNode); +} +if(!_152["method"]&&_152["formNode"]&&_152["formNode"].method){ +_152.method=_152["formNode"].method; +} +if(!_152["handle"]&&_152["handler"]){ +_152.handle=_152.handler; +} +if(!_152["load"]&&_152["loaded"]){ +_152.load=_152.loaded; +} +if(!_152["changeUrl"]&&_152["changeURL"]){ +_152.changeUrl=_152.changeURL; +} +_152.encoding=dojo.lang.firstValued(_152["encoding"],djConfig["bindEncoding"],""); +_152.sendTransport=dojo.lang.firstValued(_152["sendTransport"],djConfig["ioSendTransport"],false); +var _153=dojo.lang.isFunction; +for(var x=0;x0){ +dojo.io.bind(dojo.io._bindQueue.shift()); +}else{ +dojo.io._queueBindInFlight=false; +} +} +}; +dojo.io._bindQueue=[]; +dojo.io._queueBindInFlight=false; +dojo.io.argsFromMap=function(map,_167,last){ +var enc=/utf/i.test(_167||"")?encodeURIComponent:dojo.string.encodeAscii; +var _16a=[]; +var _16b=new Object(); +for(var name in map){ +var _16d=function(elt){ +var val=enc(name)+"="+enc(elt); +_16a[(last==name)?"push":"unshift"](val); +}; +if(!_16b[name]){ +var _170=map[name]; +if(dojo.lang.isArray(_170)){ +dojo.lang.forEach(_170,_16d); +}else{ +_16d(_170); +} +} +} +return _16a.join("&"); +}; +dojo.io.setIFrameSrc=function(_171,src,_173){ +try{ +var r=dojo.render.html; +if(!_173){ +if(r.safari){ +_171.location=src; +}else{ +frames[_171.name].location=src; +} +}else{ +var idoc; +if(r.ie){ +idoc=_171.contentWindow.document; +}else{ +if(r.safari){ +idoc=_171.document; +}else{ +idoc=_171.contentWindow; +} +} +if(!idoc){ +_171.location=src; +return; +}else{ +idoc.location.replace(src); +} +} +} +catch(e){ +dojo.debug(e); +dojo.debug("setIFrameSrc: "+e); +} +}; +dojo.provide("dojo.lang.array"); +dojo.lang.has=function(obj,name){ +try{ +return typeof obj[name]!="undefined"; +} +catch(e){ +return false; +} +}; +dojo.lang.isEmpty=function(obj){ +if(dojo.lang.isObject(obj)){ +var tmp={}; +var _17a=0; +for(var x in obj){ +if(obj[x]&&(!tmp[x])){ +_17a++; +break; +} +} +return _17a==0; +}else{ +if(dojo.lang.isArrayLike(obj)||dojo.lang.isString(obj)){ +return obj.length==0; +} +} +}; +dojo.lang.map=function(arr,obj,_17e){ +var _17f=dojo.lang.isString(arr); +if(_17f){ +arr=arr.split(""); +} +if(dojo.lang.isFunction(obj)&&(!_17e)){ +_17e=obj; +obj=dj_global; +}else{ +if(dojo.lang.isFunction(obj)&&_17e){ +var _180=obj; +obj=_17e; +_17e=_180; +} +} +if(Array.map){ +var _181=Array.map(arr,_17e,obj); +}else{ +var _181=[]; +for(var i=0;i=3){ +dojo.raise("thisObject doesn't exist!"); +} +_19e=dj_global; +} +_1a0=[]; +for(var i=0;i/gm,">").replace(/"/gm,"""); +if(!_1df){ +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,_1e8){ +if(_1e8){ +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,_1f3){ +if(_1f3=="\n"){ +text=text.replace(/\r\n/g,"\n"); +text=text.replace(/\r/g,"\n"); +}else{ +if(_1f3=="\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,_1f5){ +var _1f6=[]; +for(var i=0,_1f8=0;i0){ +return _216[0]; +} +node=node.parentNode; +} +if(_215){ +return null; +} +return _216; +}; +dojo.dom.getAncestorsByTag=function(node,tag,_21a){ +tag=tag.toLowerCase(); +return dojo.dom.getAncestors(node,function(el){ +return ((el.tagName)&&(el.tagName.toLowerCase()==tag)); +},_21a); +}; +dojo.dom.getFirstAncestorByTag=function(node,tag){ +return dojo.dom.getAncestorsByTag(node,tag,true); +}; +dojo.dom.isDescendantOf=function(node,_21f,_220){ +if(_220&&node){ +node=node.parentNode; +} +while(node){ +if(node==_21f){ +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 _223=dojo.doc(); +if(!dj_undef("ActiveXObject")){ +var _224=["MSXML2","Microsoft","MSXML","MSXML3"]; +for(var i=0;i<_224.length;i++){ +try{ +doc=new ActiveXObject(_224[i]+".XMLDOM"); +} +catch(e){ +} +if(doc){ +break; +} +} +}else{ +if((_223.implementation)&&(_223.implementation.createDocument)){ +doc=_223.implementation.createDocument("","",null); +} +} +return doc; +}; +dojo.dom.createDocumentFromText=function(str,_227){ +if(!_227){ +_227="text/xml"; +} +if(!dj_undef("DOMParser")){ +var _228=new DOMParser(); +return _228.parseFromString(str,_227); +}else{ +if(!dj_undef("ActiveXObject")){ +var _229=dojo.dom.createDocument(); +if(_229){ +_229.async=false; +_229.loadXML(str); +return _229; +}else{ +dojo.debug("toXml didn't work?"); +} +}else{ +var _22a=dojo.doc(); +if(_22a.createElement){ +var tmp=_22a.createElement("xml"); +tmp.innerHTML=str; +if(_22a.implementation&&_22a.implementation.createDocument){ +var _22c=_22a.implementation.createDocument("foo","",null); +for(var i=0;i1){ +var _244=dojo.doc(); +dojo.dom.replaceChildren(node,_244.createTextNode(text)); +return text; +}else{ +if(node.textContent!=undefined){ +return node.textContent; +} +var _245=""; +if(node==null){ +return _245; +} +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:window.location.href,initialHash: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){ +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 _254=args["back"]||args["backButton"]||args["handle"]; +var tcb=function(_256){ +if(window.location.hash!=""){ +setTimeout("window.location.href = '"+hash+"';",1); +} +_254.apply(this,[_256]); +}; +if(args["back"]){ +args.back=tcb; +}else{ +if(args["backButton"]){ +args.backButton=tcb; +}else{ +if(args["handle"]){ +args.handle=tcb; +} +} +} +var _257=args["forward"]||args["forwardButton"]||args["handle"]; +var tfw=function(_259){ +if(window.location.hash!=""){ +window.location.href=hash; +} +if(_257){ +_257.apply(this,[_259]); +} +}; +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,_25c){ +if(!dojo.render.html.opera){ +var _25d=this._getUrlQuery(_25c.href); +if(_25d==null){ +if(this.historyStack.length==1){ +this.handleBackButton(); +} +return; +} +if(this.moveForward){ +this.moveForward=false; +return; +} +if(this.historyStack.length>=2&&_25d==this._getUrlQuery(this.historyStack[this.historyStack.length-2].url)){ +this.handleBackButton(); +}else{ +if(this.forwardStack.length>0&&_25d==this._getUrlQuery(this.forwardStack[this.forwardStack.length-1].url)){ +this.handleForwardButton(); +} +} +} +},handleBackButton:function(){ +var _25e=this.historyStack.pop(); +if(!_25e){ +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(_25e); +},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 _265=url.split("?"); +if(_265.length<2){ +return null; +}else{ +return _265[1]; +} +},_loadIframeHistory:function(){ +var url=dojo.hostenv.getBaseScriptUri()+"iframe_history.html?"+(new Date()).getTime(); +this.moveForward=true; +dojo.io.setIFrameSrc(this.historyIframe,url,false); +return url; +}}; +dojo.provide("dojo.io.BrowserIO"); +dojo.io.checkChildrenForFile=function(node){ +var _268=false; +var _269=node.getElementsByTagName("input"); +dojo.lang.forEach(_269,function(_26a){ +if(_268){ +return; +} +if(_26a.getAttribute("type")=="file"){ +_268=true; +} +}); +return _268; +}; +dojo.io.formHasFile=function(_26b){ +return dojo.io.checkChildrenForFile(_26b); +}; +dojo.io.updateNode=function(node,_26d){ +node=dojo.byId(node); +var args=_26d; +if(dojo.lang.isString(_26d)){ +args={url:_26d}; +} +args.mimetype="text/html"; +args.load=function(t,d,e){ +while(node.firstChild){ +if(dojo["event"]){ +try{ +dojo.event.browser.clean(node.firstChild); +} +catch(e){ +} +} +node.removeChild(node.firstChild); +} +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(_274,_275,_276){ +if((!_274)||(!_274.tagName)||(!_274.tagName.toLowerCase()=="form")){ +dojo.raise("Attempted to encode a non-form element."); +} +if(!_276){ +_276=dojo.io.formFilter; +} +var enc=/utf/i.test(_275||"")?encodeURIComponent:dojo.string.encodeAscii; +var _278=[]; +for(var i=0;i<_274.elements.length;i++){ +var elm=_274.elements[i]; +if(!elm||elm.tagName.toLowerCase()=="fieldset"||!_276(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(_29f.method.toLowerCase()=="head"){ +var _2a5=http.getAllResponseHeaders(); +ret={}; +ret.toString=function(){ +return _2a5; +}; +var _2a6=_2a5.split(/[\r\n]+/g); +for(var i=0;i<_2a6.length;i++){ +var pair=_2a6[i].match(/^([^:]+)\s*:\s*(.+)$/i); +if(pair){ +ret[pair[1]]=pair[2]; +} +} +}else{ +if(_29f.mimetype=="text/javascript"){ +try{ +ret=dj_eval(http.responseText); +} +catch(e){ +dojo.debug(e); +dojo.debug(http.responseText); +ret=null; +} +}else{ +if(_29f.mimetype=="text/json"||_29f.mimetype=="application/json"){ +try{ +ret=dj_eval("("+http.responseText+")"); +} +catch(e){ +dojo.debug(e); +dojo.debug(http.responseText); +ret=false; +} +}else{ +if((_29f.mimetype=="application/xml")||(_29f.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(_2a3){ +addToCache(url,_2a2,_29f.method,http); +} +_29f[(typeof _29f.load=="function")?"load":"handle"]("load",ret,http,_29f); +}else{ +var _2a9=new dojo.io.Error("XMLHttpTransport Error: "+http.status+" "+http.statusText); +_29f[(typeof _29f.error=="function")?"error":"handle"]("error",_2a9,http,_29f); +} +} +function setHeaders(http,_2ab){ +if(_2ab["headers"]){ +for(var _2ac in _2ab["headers"]){ +if(_2ac.toLowerCase()=="content-type"&&!_2ab["contentType"]){ +_2ab["contentType"]=_2ab["headers"][_2ac]; +}else{ +http.setRequestHeader(_2ac,_2ab["headers"][_2ac]); +} +} +} +} +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&&!_293._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(_2b3["file"]){ +_2b3.method="post"; +} +if(!_2b3["method"]){ +_2b3.method="get"; +} +if(_2b3.method.toLowerCase()=="get"){ +_2b3.multipart=false; +}else{ +if(_2b3["file"]){ +_2b3.multipart=true; +}else{ +if(!_2b3["multipart"]){ +_2b3.multipart=false; +} +} +} +if(_2b3["backButton"]||_2b3["back"]||_2b3["changeUrl"]){ +dojo.undo.browser.addToHistory(_2b3); +} +var _2b8=_2b3["content"]||{}; +if(_2b3.sendTransport){ +_2b8["dojo.transport"]="xmlhttp"; +} +do{ +if(_2b3.postContent){ +_2b5=_2b3.postContent; +break; +} +if(_2b8){ +_2b5+=dojo.io.argsFromMap(_2b8,_2b3.encoding); +} +if(_2b3.method.toLowerCase()=="get"||!_2b3.multipart){ +break; +} +var t=[]; +if(_2b5.length){ +var q=_2b5.split("&"); +for(var i=0;i-1?"&":"?")+_2b5; +} +if(_2bf){ +_2c5+=(dojo.string.endsWithAny(_2c5,"?","&")?"":(_2c5.indexOf("?")>-1?"&":"?"))+"dojo.preventCache="+new Date().valueOf(); +} +if(!_2b3.user){ +http.open(_2b3.method.toUpperCase(),_2c5,_2be); +}else{ +http.open(_2b3.method.toUpperCase(),_2c5,_2be,_2b3.user,_2b3.password); +} +setHeaders(http,_2b3); +try{ +http.send(null); +} +catch(e){ +if(typeof http.abort=="function"){ +http.abort(); +} +doLoad(_2b3,{status:404},url,_2b5,_2c0); +} +} +if(!_2be){ +doLoad(_2b3,http,url,_2b5,_2c0); +_293._blockAsync=false; +} +_2b3.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,_2c7,days,path,_2ca,_2cb){ +var _2cc=-1; +if(typeof days=="number"&&days>=0){ +var d=new Date(); +d.setTime(d.getTime()+(days*24*60*60*1000)); +_2cc=d.toGMTString(); +} +_2c7=escape(_2c7); +document.cookie=name+"="+_2c7+";"+(_2cc!=-1?" expires="+_2cc+";":"")+(path?"path="+path:"")+(_2ca?"; domain="+_2ca:"")+(_2cb?"; 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 _2d0=document.cookie.substring(idx+name.length+1); +var end=_2d0.indexOf(";"); +if(end==-1){ +end=_2d0.length; +} +_2d0=_2d0.substring(0,end); +_2d0=unescape(_2d0); +return _2d0; +}; +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,_2d7,_2d8,_2d9){ +if(arguments.length==5){ +_2d9=_2d7; +_2d7=null; +_2d8=null; +} +var _2da=[],_2db,_2dc=""; +if(!_2d9){ +_2db=dojo.io.cookie.getObjectCookie(name); +} +if(days>=0){ +if(!_2db){ +_2db={}; +} +for(var prop in obj){ +if(prop==null){ +delete _2db[prop]; +}else{ +if(typeof obj[prop]=="string"||typeof obj[prop]=="number"){ +_2db[prop]=obj[prop]; +} +} +} +prop=null; +for(var prop in _2db){ +_2da.push(escape(prop)+"="+escape(_2db[prop])); +} +_2dc=_2da.join("&"); +} +dojo.io.cookie.setCookie(name,_2dc,days,path,_2d7,_2d8); +}; +dojo.io.cookie.getObjectCookie=function(name){ +var _2df=null,_2e0=dojo.io.cookie.getCookie(name); +if(_2e0){ +_2df={}; +var _2e1=_2e0.split("&"); +for(var i=0;i<_2e1.length;i++){ +var pair=_2e1[i].split("="); +var _2e4=pair[1]; +if(isNaN(_2e4)){ +_2e4=unescape(pair[1]); +} +_2df[unescape(pair[0])]=_2e4; +} +} +return _2df; +}; +dojo.io.cookie.isSupported=function(){ +if(typeof navigator.cookieEnabled!="boolean"){ +dojo.io.cookie.setCookie("__TestingYourBrowserForCookieSupport__","CookiesAllowed",90,null); +var _2e5=dojo.io.cookie.getCookie("__TestingYourBrowserForCookieSupport__"); +navigator.cookieEnabled=(_2e5=="CookiesAllowed"); +if(navigator.cookieEnabled){ +this.deleteCookie("__TestingYourBrowserForCookieSupport__"); +} +} +return navigator.cookieEnabled; +}; +if(!dojo.io.cookies){ +dojo.io.cookies=dojo.io.cookie; +} +dojo.provide("dojo.io.*"); +dojo.provide("dojo.io"); +dojo.deprecated("dojo.io","replaced by dojo.io.*","0.5"); +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,_2e7){ +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}; +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 _2ea=dl.nameAnonFunc(args[2],ao.adviceObj,_2e7); +ao.adviceFunc=_2ea; +}else{ +if((dl.isFunction(args[0]))&&(dl.isObject(args[1]))&&(dl.isString(args[2]))){ +ao.adviceType="after"; +ao.srcObj=dj_global; +var _2ea=dl.nameAnonFunc(args[0],ao.srcObj,_2e7); +ao.srcFunc=_2ea; +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 _2ea=dl.nameAnonFunc(args[1],dj_global,_2e7); +ao.srcFunc=_2ea; +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 _2ea=dl.nameAnonFunc(args[3],dj_global,_2e7); +ao.adviceObj=dj_global; +ao.adviceFunc=_2ea; +}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]; +break; +} +if(dl.isFunction(ao.aroundFunc)){ +var _2ea=dl.nameAnonFunc(ao.aroundFunc,ao.aroundObj,_2e7); +ao.aroundFunc=_2ea; +} +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.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 _2ec={}; +for(var x in ao){ +_2ec[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); +} +_2ec.srcObj=src; +mjps.push(dojo.event.connect.call(dojo.event,_2ec)); +}); +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 _2f4; +if((arguments.length==1)&&(typeof a1=="object")){ +_2f4=a1; +}else{ +_2f4={srcObj:a1,srcFunc:a2}; +} +_2f4.adviceFunc=function(){ +var _2f5=[]; +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,_30c){ +this.object=obj||dj_global; +this.methodname=_30c; +this.methodfunc=this.object[_30c]; +this.squelch=false; +}; +dojo.event.MethodJoinPoint.getForMethod=function(obj,_30e){ +if(!obj){ +obj=dj_global; +} +if(!obj[_30e]){ +obj[_30e]=function(){ +}; +if(!obj[_30e]){ +dojo.raise("Cannot set do-nothing method on that object "+_30e); +} +}else{ +if((!dojo.lang.isFunction(obj[_30e]))&&(!dojo.lang.isAlien(obj[_30e]))){ +return null; +} +} +var _30f=_30e+"$joinpoint"; +var _310=_30e+"$joinpoint$method"; +var _311=obj[_30f]; +if(!_311){ +var _312=false; +if(dojo.event["browser"]){ +if((obj["attachEvent"])||(obj["nodeType"])||(obj["addEventListener"])){ +_312=true; +dojo.event.browser.addClobberNodeAttrs(obj,[_30f,_310,_30e]); +} +} +var _313=obj[_30e].length; +obj[_310]=obj[_30e]; +_311=obj[_30f]=new dojo.event.MethodJoinPoint(obj,_310); +obj[_30e]=function(){ +var args=[]; +if((_312)&&(!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;x0)){ +dojo.lang.forEach(this.before.concat(new Array()),_32b); +} +var _32c; +try{ +if((this["around"])&&(this.around.length>0)){ +var mi=new dojo.event.MethodInvocation(this,obj,args); +_32c=mi.proceed(); +}else{ +if(this.methodfunc){ +_32c=this.object[this.methodname].apply(this.object,args); +} +} +} +catch(e){ +if(!this.squelch){ +dojo.raise(e); +} +} +if((this["after"])&&(this.after.length>0)){ +dojo.lang.forEach(this.after.concat(new Array()),_32b); +} +return (this.methodfunc)?_32c: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"]); +},addAdvice:function(_331,_332,_333,_334,_335,_336,once,_338,rate,_33a){ +var arr=this.getArr(_335); +if(!arr){ +dojo.raise("bad this: "+this); +} +var ao=[_331,_332,_333,_334,_338,rate,_33a]; +if(once){ +if(this.hasAdvice(_331,_332,_335,arr)>=0){ +return; +} +} +if(_336=="first"){ +arr.unshift(ao); +}else{ +arr.push(ao); +} +},hasAdvice:function(_33d,_33e,_33f,arr){ +if(!arr){ +arr=this.getArr(_33f); +} +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&&_38f<=90&&evt.shiftKey==false){ +_38f+=32; +} +if(_38f>=1&&_38f<=26&&evt.ctrlKey){ +_38f+=96; +} +evt.key=String.fromCharCode(_38f); +} +} +}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 _38f=evt.which; +if((evt.ctrlKey||evt.altKey||evt.metaKey)&&(evt.which>=65&&evt.which<=90&&evt.shiftKey==false)){ +_38f+=32; +} +evt.key=String.fromCharCode(_38f); +} +} +} +}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 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; +default: +evt.key=evt.charCode>0?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=(_38d?_38d: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 _391=((dojo.render.html.ie55)||(doc["compatMode"]=="BackCompat"))?doc.body:doc.documentElement; +if(!evt.pageX){ +evt.pageX=evt.clientX+(_391.scrollLeft||0); +} +if(!evt.pageY){ +evt.pageY=evt.clientY+(_391.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.returnValue=false; +evt.cancelBubble=true; +}else{ +evt.preventDefault(); +evt.stopPropagation(); +} +}; +}; +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(_399){ +if(_399){ +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(_39a,_39b){ +var rgb=null; +if(dojo.lang.isArray(_39a)){ +rgb=_39a; +}else{ +if(_39a instanceof dojo.gfx.color.Color){ +rgb=_39a.toRgb(); +}else{ +rgb=new dojo.gfx.color.Color(_39a).toRgb(); +} +} +return dojo.gfx.color.blend(this.toRgb(),rgb,_39b); +}}); +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,_39f){ +if(typeof a=="string"){ +return dojo.gfx.color.blendHex(a,b,_39f); +} +if(!_39f){ +_39f=0; +} +_39f=Math.min(Math.max(-1,_39f),1); +_39f=((_39f+1)/2); +var c=[]; +for(var x=0;x<3;x++){ +c[x]=parseInt(b[x]+((a[x]-b[x])*_39f)); +} +return c; +}; +dojo.gfx.color.blendHex=function(a,b,_3a4){ +return dojo.gfx.color.rgb2hex(dojo.gfx.color.blend(dojo.gfx.color.hex2rgb(a),dojo.gfx.color.hex2rgb(b),_3a4)); +}; +dojo.gfx.color.extractRGB=function(_3a5){ +var hex="0123456789abcdef"; +_3a5=_3a5.toLowerCase(); +if(_3a5.indexOf("rgb")==0){ +var _3a7=_3a5.match(/rgba*\((\d+), *(\d+), *(\d+)/i); +var ret=_3a7.splice(1,3); +return ret; +}else{ +var _3a9=dojo.gfx.color.hex2rgb(_3a5); +if(_3a9){ +return _3a9; +}else{ +return dojo.gfx.color.named[_3a5]||[255,255,255]; +} +} +}; +dojo.gfx.color.hex2rgb=function(hex){ +var _3ab="0123456789ABCDEF"; +var rgb=new Array(3); +if(hex.indexOf("#")==0){ +hex=hex.substring(1); +} +hex=hex.toUpperCase(); +if(hex.replace(new RegExp("["+_3ab+"]","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=_3cb; +} +if(_3ce){ +this.repeatCount=_3ce; +} +if(rate){ +this.rate=rate; +} +if(_3ca){ +dojo.lang.forEach(["handler","beforeBegin","onBegin","onEnd","onPlay","onStop","onAnimate"],function(item){ +if(_3ca[item]){ +this.connect(item,_3ca[item]); +} +},this); +} +if(_3cd&&dojo.lang.isFunction(_3cd)){ +this.easing=_3cd; +} +}; +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(_3d1,_3d2){ +if(_3d2){ +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(_3d1>0){ +setTimeout(dojo.lang.hitch(this,function(){ +this.play(null,_3d2); +}),_3d1); +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 _3d4=this.curve.getValue(step); +if(this._percent==0){ +if(!this._startRepeatCount){ +this._startRepeatCount=this.repeatCount; +} +this.fire("handler",["begin",_3d4]); +this.fire("onBegin",[_3d4]); +} +this.fire("handler",["play",_3d4]); +this.fire("onPlay",[_3d4]); +this._cycle(); +return this; +},pause:function(){ +clearTimeout(this._timer); +if(!this._active){ +return this; +} +this._paused=true; +var _3d5=this.curve.getValue(this._percent/100); +this.fire("handler",["pause",_3d5]); +this.fire("onPause",[_3d5]); +return this; +},gotoPercent:function(pct,_3d7){ +clearTimeout(this._timer); +this._active=true; +this._paused=true; +this._percent=pct; +if(_3d7){ +this.play(); +} +return this; +},stop:function(_3d8){ +clearTimeout(this._timer); +var step=this._percent/100; +if(_3d8){ +step=1; +} +var _3da=this.curve.getValue(step); +this.fire("handler",["stop",_3da]); +this.fire("onStop",[_3da]); +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 _3dd=this.curve.getValue(step); +this.fire("handler",["animate",_3dd]); +this.fire("onAnimate",[_3dd]); +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(_3de){ +dojo.lfx.IAnimation.call(this); +this._anims=[]; +this._animsEnded=0; +var _3df=arguments; +if(_3df.length==1&&(dojo.lang.isArray(_3df[0])||dojo.lang.isArrayLike(_3df[0]))){ +_3df=_3df[0]; +} +dojo.lang.forEach(_3df,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(_3e1,_3e2){ +if(!this._anims.length){ +return this; +} +this.fire("beforeBegin"); +if(_3e1>0){ +setTimeout(dojo.lang.hitch(this,function(){ +this.play(null,_3e2); +}),_3e1); +return this; +} +if(_3e2||this._anims[0].percent==0){ +this.fire("onBegin"); +} +this.fire("onPlay"); +this._animsCall("play",null,_3e2); +return this; +},pause:function(){ +this.fire("onPause"); +this._animsCall("pause"); +return this; +},stop:function(_3e3){ +this.fire("onStop"); +this._animsCall("stop",_3e3); +return this; +},_onAnimsEnded:function(){ +this._animsEnded++; +if(this._animsEnded>=this._anims.length){ +this.fire("onEnd"); +} +return this; +},_animsCall:function(_3e4){ +var args=[]; +if(arguments.length>1){ +for(var i=1;i0){ +setTimeout(dojo.lang.hitch(this,function(){ +this.play(null,_3f0); +}),_3ef); +return this; +} +if(_3f1){ +if(this._currAnim==0){ +this.fire("handler",["begin",this._currAnim]); +this.fire("onBegin",[this._currAnim]); +} +this.fire("onPlay",[this._currAnim]); +_3f1.play(null,_3f0); +} +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 _3f2=this._anims[this._currAnim]; +if(_3f2){ +if(!_3f2._active||_3f2._paused){ +this.play(); +}else{ +this.pause(); +} +} +return this; +},stop:function(){ +var _3f3=this._anims[this._currAnim]; +if(_3f3){ +_3f3.stop(); +this.fire("onStop",[this._currAnim]); +} +return _3f3; +},_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(_3f4){ +var _3f5=arguments; +if(dojo.lang.isArray(arguments[0])){ +_3f5=arguments[0]; +} +if(_3f5.length==1){ +return _3f5[0]; +} +return new dojo.lfx.Combine(_3f5); +}; +dojo.lfx.chain=function(_3f6){ +var _3f7=arguments; +if(dojo.lang.isArray(arguments[0])){ +_3f7=arguments[0]; +} +if(_3f7.length==1){ +return _3f7[0]; +} +return new dojo.lfx.Chain(_3f7); +}; +dojo.provide("dojo.uri.Uri"); +dojo.uri=new function(){ +this.dojoUri=function(uri){ +return new dojo.uri.Uri(dojo.hostenv.getBaseScriptUri(),uri); +}; +this.moduleUri=function(_3f9,uri){ +var loc=dojo.hostenv.getModulePrefix(_3f9); +if(!loc){ +return null; +} +if(loc.lastIndexOf("/")!=loc.length-1){ +loc+="/"; +} +return new dojo.uri.Uri(dojo.hostenv.getBaseScriptUri()+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; +} +} +} +} +_3fe.path=segs.join("/"); +} +} +} +} +uri=""; +if(_3fe.scheme!=null){ +uri+=_3fe.scheme+":"; +} +if(_3fe.authority!=null){ +uri+="//"+_3fe.authority; +} +uri+=_3fe.path; +if(_3fe.query!=null){ +uri+="?"+_3fe.query; +} +if(_3fe.fragment!=null){ +uri+="#"+_3fe.fragment; +} +} +this.uri=uri.toString(); +var _403="^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$"; +var r=this.uri.match(new RegExp(_403)); +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){ +_403="^((([^:]+:)?([^@]+))@)?([^:]*)(:([0-9]+))?$"; +r=this.authority.match(new RegExp(_403)); +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,_40a){ +return (new RegExp("(^|\\s+)"+_40a+"(\\s+|$)")).test(dojo.html.getClass(node)); +}; +dojo.html.prependClass=function(node,_40c){ +_40c+=" "+dojo.html.getClass(node); +return dojo.html.setClass(node,_40c); +}; +dojo.html.addClass=function(node,_40e){ +if(dojo.html.hasClass(node,_40e)){ +return false; +} +_40e=(dojo.html.getClass(node)+" "+_40e).replace(/^\s+|\s+$/g,""); +return dojo.html.setClass(node,_40e); +}; +dojo.html.setClass=function(node,_410){ +node=dojo.byId(node); +var cs=new String(_410); +try{ +if(typeof node.className=="string"){ +node.className=cs; +}else{ +if(node.setAttribute){ +node.setAttribute("class",_410); +node.className=cs; +}else{ +return false; +} +} +} +catch(e){ +dojo.debug("dojo.html.setClass() failed",e); +} +return true; +}; +dojo.html.removeClass=function(node,_413,_414){ +try{ +if(!_414){ +var _415=dojo.html.getClass(node).replace(new RegExp("(^|\\s+)"+_413+"(\\s+|$)"),"$1$2"); +}else{ +var _415=dojo.html.getClass(node).replace(_413,""); +} +dojo.html.setClass(node,_415); +} +catch(e){ +dojo.debug("dojo.html.removeClass() failed",e); +} +return true; +}; +dojo.html.replaceClass=function(node,_417,_418){ +dojo.html.removeClass(node,_418); +dojo.html.addClass(node,_417); +}; +dojo.html.classMatchType={ContainsAll:0,ContainsAny:1,IsOnly:2}; +dojo.html.getElementsByClass=function(_419,_41a,_41b,_41c,_41d){ +_41d=false; +var _41e=dojo.doc(); +_41a=dojo.byId(_41a)||_41e; +var _41f=_419.split(/\s+/g); +var _420=[]; +if(_41c!=1&&_41c!=2){ +_41c=0; +} +var _421=new RegExp("(\\s|^)(("+_41f.join(")|(")+"))(\\s|$)"); +var _422=_41f.join(" ").length; +var _423=[]; +if(!_41d&&_41e.evaluate){ +var _424=".//"+(_41b||"*")+"[contains("; +if(_41c!=dojo.html.classMatchType.ContainsAny){ +_424+="concat(' ',@class,' '), ' "+_41f.join(" ') and contains(concat(' ',@class,' '), ' ")+" ')"; +if(_41c==2){ +_424+=" and string-length(@class)="+_422+"]"; +}else{ +_424+="]"; +} +}else{ +_424+="concat(' ',@class,' '), ' "+_41f.join(" ') or contains(concat(' ',@class,' '), ' ")+" ')]"; +} +var _425=_41e.evaluate(_424,_41a,null,XPathResult.ANY_TYPE,null); +var _426=_425.iterateNext(); +while(_426){ +try{ +_423.push(_426); +_426=_425.iterateNext(); +} +catch(e){ +break; +} +} +return _423; +}else{ +if(!_41b){ +_41b="*"; +} +_423=_41a.getElementsByTagName(_41b); +var node,i=0; +outer: +while(node=_423[i++]){ +var _429=dojo.html.getClasses(node); +if(_429.length==0){ +continue outer; +} +var _42a=0; +for(var j=0;j<_429.length;j++){ +if(_421.test(_429[j])){ +if(_41c==dojo.html.classMatchType.ContainsAny){ +_420.push(node); +continue outer; +}else{ +_42a++; +} +}else{ +if(_41c==dojo.html.classMatchType.IsOnly){ +continue outer; +} +} +} +if(_42a==_41f.length){ +if((_41c==dojo.html.classMatchType.IsOnly)&&(_42a==_429.length)){ +_420.push(node); +}else{ +if(_41c==dojo.html.classMatchType.ContainsAll){ +_420.push(node); +} +} +} +} +return _420; +} +}; +dojo.html.getElementsByClassName=dojo.html.getElementsByClass; +dojo.html.toCamelCase=function(_42c){ +var arr=_42c.split("-"),cc=arr[0]; +for(var i=1;i=1){ +if(h.ie){ +dojo.html.clearOpacity(node); +return; +}else{ +_491=0.999999; +} +}else{ +if(_491<0){ +_491=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 _49d; +do{ +_49d=dojo.html.getStyle(node,"background-color"); +if(_49d.toLowerCase()=="rgba(0, 0, 0, 0)"){ +_49d="transparent"; +} +if(node==document.getElementsByTagName("body")[0]){ +node=null; +break; +} +node=node.parentNode; +}while(node&&dojo.lang.inArray(["transparent",""],_49d)); +if(_49d=="transparent"){ +_49d=[255,255,255,0]; +}else{ +_49d=dojo.gfx.color.extractRGB(_49d); +} +return _49d; +}; +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 _4a0=dojo.global(); +var _4a1=dojo.doc(); +var w=0; +var h=0; +if(dojo.render.html.mozilla){ +w=_4a1.documentElement.clientWidth; +h=_4a0.innerHeight; +}else{ +if(!dojo.render.html.opera&&_4a0.innerWidth){ +w=_4a0.innerWidth; +h=_4a0.innerHeight; +}else{ +if(!dojo.render.html.opera&&dojo.exists(_4a1,"documentElement.clientWidth")){ +var w2=_4a1.documentElement.clientWidth; +if(!w||w2&&w20){ +ret.x+=isNaN(n)?0:n; +} +var m=_4db["offsetTop"]; +ret.y+=isNaN(m)?0:m; +_4db=_4db.offsetParent; +}while((_4db!=_4d9)&&(_4db!=null)); +}else{ +if(node["x"]&&node["y"]){ +ret.x+=isNaN(node.x)?0:node.x; +ret.y+=isNaN(node.y)?0:node.y; +} +} +} +} +if(_4d0){ +var _4de=dojo.html.getScroll(); +ret.y+=_4de.top; +ret.x+=_4de.left; +} +var _4df=[dojo.html.getPaddingExtent,dojo.html.getBorderExtent,dojo.html.getMarginExtent]; +if(_4d4>_4d5){ +for(var i=_4d5;i<_4d4;++i){ +ret.y+=_4df[i](node,"top"); +ret.x+=_4df[i](node,"left"); +} +}else{ +if(_4d4<_4d5){ +for(var i=_4d5;i>_4d4;--i){ +ret.y-=_4df[i-1](node,"top"); +ret.x-=_4df[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,_4e3,_4e4){ +var _4e5=0; +for(var x=0;x<_4e3.length;x++){ +_4e5+=dojo.html.getPixelValue(node,_4e3[x],_4e4); +} +return _4e5; +}; +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 _4f2=dojo.html.getBorder(node); +return {width:pad.width+_4f2.width,height:pad.height+_4f2.height}; +}; +dojo.html.getBoxSizing=function(node){ +var h=dojo.render.html; +var bs=dojo.html.boxSizing; +if((h.ie)||(h.opera)){ +var cm=document["compatMode"]; +if((cm=="BackCompat")||(cm=="QuirksMode")){ +return bs.BORDER_BOX; +}else{ +return bs.CONTENT_BOX; +} +}else{ +if(arguments.length==0){ +node=document.documentElement; +} +var _4f7=dojo.html.getStyle(node,"-moz-box-sizing"); +if(!_4f7){ +_4f7=dojo.html.getStyle(node,"box-sizing"); +} +return (_4f7?_4f7: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 _4fc=dojo.html.getBorder(node); +return {width:box.width-_4fc.width,height:box.height-_4fc.height}; +}; +dojo.html.getContentBox=function(node){ +node=dojo.byId(node); +var _4fe=dojo.html.getPadBorder(node); +return {width:node.offsetWidth-_4fe.width,height:node.offsetHeight-_4fe.height}; +}; +dojo.html.setContentBox=function(node,args){ +node=dojo.byId(node); +var _501=0; +var _502=0; +var isbb=dojo.html.isBorderBox(node); +var _504=(isbb?dojo.html.getPadBorder(node):{width:0,height:0}); +var ret={}; +if(typeof args.width!="undefined"){ +_501=args.width+_504.width; +ret.width=dojo.html.setPositivePixelValue(node,"width",_501); +} +if(typeof args.height!="undefined"){ +_502=args.height+_504.height; +ret.height=dojo.html.setPositivePixelValue(node,"height",_502); +} +return ret; +}; +dojo.html.getMarginBox=function(node){ +var _507=dojo.html.getBorderBox(node); +var _508=dojo.html.getMargin(node); +return {width:_507.width+_508.width,height:_507.height+_508.height}; +}; +dojo.html.setMarginBox=function(node,args){ +node=dojo.byId(node); +var _50b=0; +var _50c=0; +var isbb=dojo.html.isBorderBox(node); +var _50e=(!isbb?dojo.html.getPadBorder(node):{width:0,height:0}); +var _50f=dojo.html.getMargin(node); +var ret={}; +if(typeof args.width!="undefined"){ +_50b=args.width-_50e.width; +_50b-=_50f.width; +ret.width=dojo.html.setPositivePixelValue(node,"width",_50b); +} +if(typeof args.height!="undefined"){ +_50c=args.height-_50e.height; +_50c-=_50f.height; +ret.height=dojo.html.setPositivePixelValue(node,"height",_50c); +} +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(_514,_515,_516){ +if(_514 instanceof Array||typeof _514=="array"){ +dojo.deprecated("dojo.html.toCoordinateArray","use dojo.html.toCoordinateObject({left: , top: , width: , height: }) instead","0.5"); +while(_514.length<4){ +_514.push(0); +} +while(_514.length>4){ +_514.pop(); +} +var ret={left:_514[0],top:_514[1],width:_514[2],height:_514[3]}; +}else{ +if(!_514.nodeType&&!(_514 instanceof String||typeof _514=="string")&&("width" in _514||"height" in _514||"left" in _514||"x" in _514||"top" in _514||"y" in _514)){ +var ret={left:_514.left||_514.x||0,top:_514.top||_514.y||0,width:_514.width||0,height:_514.height||0}; +}else{ +var node=dojo.byId(_514); +var pos=dojo.html.abs(node,_515,_516); +var _51a=dojo.html.getMarginBox(node); +var ret={left:pos.left,top:pos.top,width:_51a.width,height:_51a.height}; +} +} +ret.x=ret.left; +ret.y=ret.top; +return ret; +}; +dojo.html.setMarginBoxWidth=dojo.html.setOuterWidth=function(node,_51c){ +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,_51f){ +return dojo.html._callDeprecated("getTotalOffset","getAbsolutePosition",arguments,null,type); +}; +dojo.html.getAbsoluteX=function(node,_521){ +return dojo.html._callDeprecated("getAbsoluteX","getAbsolutePosition",arguments,null,"x"); +}; +dojo.html.getAbsoluteY=function(node,_523){ +return dojo.html._callDeprecated("getAbsoluteY","getAbsolutePosition",arguments,null,"y"); +}; +dojo.html.totalOffsetLeft=function(node,_525){ +return dojo.html._callDeprecated("totalOffsetLeft","getAbsolutePosition",arguments,null,"left"); +}; +dojo.html.totalOffsetTop=function(node,_527){ +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,_531){ +return dojo.html._callDeprecated("setContentBoxWidth","setContentBox",arguments,"width"); +}; +dojo.html.setContentBoxHeight=dojo.html.setContentHeight=function(node,_533){ +return dojo.html._callDeprecated("setContentBoxHeight","setContentBox",arguments,"height"); +}; +dojo.provide("dojo.lfx.html"); +dojo.lfx.html._byId=function(_534){ +if(!_534){ +return []; +} +if(dojo.lang.isArrayLike(_534)){ +if(!_534.alreadyChecked){ +var n=[]; +dojo.lang.forEach(_534,function(node){ +n.push(dojo.byId(node)); +}); +n.alreadyChecked=true; +return n; +}else{ +return _534; +} +}else{ +var n=[]; +n.push(dojo.byId(_534)); +n.alreadyChecked=true; +return n; +} +}; +dojo.lfx.html.propertyAnimation=function(_537,_538,_539,_53a,_53b){ +_537=dojo.lfx.html._byId(_537); +var _53c={"propertyMap":_538,"nodes":_537,"duration":_539,"easing":_53a||dojo.lfx.easeDefault}; +var _53d=function(args){ +if(args.nodes.length==1){ +var pm=args.propertyMap; +if(!dojo.lang.isArray(args.propertyMap)){ +var parr=[]; +for(var _541 in pm){ +pm[_541].property=_541; +parr.push(pm[_541]); +} +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 _543=function(_544){ +var _545=[]; +dojo.lang.forEach(_544,function(c){ +_545.push(Math.round(c)); +}); +return _545; +}; +var _547=function(n,_549){ +n=dojo.byId(n); +if(!n||!n.style){ +return; +} +for(var s in _549){ +if(s=="opacity"){ +dojo.html.setOpacity(n,_549[s]); +}else{ +n.style[s]=_549[s]; +} +} +}; +var _54b=function(_54c){ +this._properties=_54c; +this.diffs=new Array(_54c.length); +dojo.lang.forEach(_54c,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 _553=null; +if(dojo.lang.isArray(prop.start)){ +}else{ +if(prop.start instanceof dojo.gfx.color.Color){ +_553=(prop.units||"rgb")+"("; +for(var j=0;j3){ +_5c4.pop(); +} +var rgb=new dojo.gfx.color.Color(_5be); +var _5c9=new dojo.gfx.color.Color(_5c4); +var anim=dojo.lfx.propertyAnimation(node,{"background-color":{start:rgb,end:_5c9}},_5bf,_5c0,{"beforeBegin":function(){ +if(_5c6){ +node.style.backgroundImage="none"; +} +node.style.backgroundColor="rgb("+rgb.toRgb().join(",")+")"; +},"onEnd":function(){ +if(_5c6){ +node.style.backgroundImage=_5c6; +} +if(_5c7){ +node.style.backgroundColor="transparent"; +} +if(_5c1){ +_5c1(node,anim); +} +}}); +_5c2.push(anim); +}); +return dojo.lfx.combine(_5c2); +}; +dojo.lfx.html.unhighlight=function(_5cb,_5cc,_5cd,_5ce,_5cf){ +_5cb=dojo.lfx.html._byId(_5cb); +var _5d0=[]; +dojo.lang.forEach(_5cb,function(node){ +var _5d2=new dojo.gfx.color.Color(dojo.html.getBackgroundColor(node)); +var rgb=new dojo.gfx.color.Color(_5cc); +var _5d4=dojo.html.getStyle(node,"background-image"); +var anim=dojo.lfx.propertyAnimation(node,{"background-color":{start:_5d2,end:rgb}},_5cd,_5ce,{"beforeBegin":function(){ +if(_5d4){ +node.style.backgroundImage="none"; +} +node.style.backgroundColor="rgb("+_5d2.toRgb().join(",")+")"; +},"onEnd":function(){ +if(_5cf){ +_5cf(node,anim); +} +}}); +_5d0.push(anim); +}); +return dojo.lfx.combine(_5d0); +}; +dojo.lang.mixin(dojo.lfx,dojo.lfx.html); +dojo.provide("dojo.lfx.*"); + Index: openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/dojo.js.uncompressed.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/Attic/dojo.js.uncompressed.js,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/dojo.js.uncompressed.js 6 Nov 2006 14:37:19 -0000 1.1 @@ -0,0 +1,9197 @@ +if(typeof dojo == "undefined"){ + +/** +* @file bootstrap1.js +* +* summary: First file that is loaded that 'bootstraps' the entire dojo library suite. +* note: Must run before hostenv_*.js file. +* +* @author Copyright 2004 Mark D. Anderson (mda@discerning.com) +* TODOC: should the copyright be changed to Dojo Foundation? +* @license Licensed under the Academic Free License 2.1 http://www.opensource.org/licenses/afl-2.1.php +* +* $Id: dojo.js.uncompressed.js,v 1.1 2006/11/06 14:37:19 hamiltonc Exp $ +*/ + +// 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: 0, flag: "", + revision: Number("$Rev: 6258 $".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(){ + if(typeof setTimeout == "object"){ + 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) + 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); +} + +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. + + return locale ? locale.toLowerCase() : dojo.locale; // 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 /***BUILD:localesGenerated***/; // value will be inserted here at build time, if necessary + +dojo.hostenv.registerNlsPrefix = function(){ +// summary: +// Register module "nls" to point where Dojo can find pre-built localization files + dojo.registerModulePath("nls","nls"); +} + +dojo.hostenv.preloadLocalizations = function(){ +// summary: +// Load built, flattened resource bundles, if available for all locales used in the page. +// Execute only once. Note that this is a no-op unless there is a build. + + if(dojo.hostenv.localesGenerated){ + dojo.hostenv.registerNlsPrefix(); + + function preload(locale){ + locale = dojo.hostenv.normalizeLocale(locale); + dojo.hostenv.searchLocalePath(locale, true, function(loc){ + 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; + } + } +})(); + +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(){ + 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; +} + +/** + * Read the contents of the specified uri and return those contents. + * + * @param uri A relative or absolute uri. If absolute, it still must be in the + * same "domain" as we are. + * + * @param 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. + * + * @param fail_ok Default false. If fail_ok and !async_cb and loading fails, + * return null instead of throwing. + */ +dojo.hostenv._blockAsync = false; +dojo.hostenv.getText = function(uri, async_cb, fail_ok){ + // 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; +} + +/* + * It turns out that if we check *right now*, as this script file is being loaded, + * then the last script element in the window DOM is ourselves. + * That is because any subsequent script elements haven't shown up in the document + * object yet. + */ + /* +function dj_last_script_src() { + var scripts = window.document.getElementsByTagName('script'); + if(scripts.length < 1){ + dojo.raise("No script elements in window.document, so can't figure out my script src"); + } + var script = scripts[scripts.length - 1]; + var src = script.src; + if(!src){ + dojo.raise("Last script element (out of " + scripts.length + ") has no src"); + } + return src; +} + +if(!dojo.hostenv["library_script_uri_"]){ + dojo.hostenv.library_script_uri_ = dj_last_script_src(); +} +*/ + +dojo.hostenv.defaultDebugContainerId = 'dojoDebug'; +dojo.hostenv._println_buffer = []; +dojo.hostenv._println_safe = false; +dojo.hostenv.println = function (line){ + 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(node, evtName, fp, capture){ + 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{ + dojo.addOnLoad(initFunc); + } +} + +// START DOMContentLoaded +// Mozilla and Opera 9 expose the event we could use +if(document.addEventListener){ + if(dojo.render.html.opera || (dojo.render.html.moz && !djConfig.delayMozLoadingFix)){ + 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"); + } catch (e) { + var script = document.createElement("script"); + script.src = spath; + document.getElementsByTagName("head")[0].appendChild(script); + } + } + } +})(); + +dojo.provide("dojo.string.common"); + +dojo.string.trim = function(/* string */str, /* integer? */wh){ + // summary + // Trim whitespace from str. If wh > 0, trim from start, if wh < 0, trim from end, else both + if(!str.replace){ return str; } + if(!str.length){ return str; } + 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(typeof superclass != 'function'){ + 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. + 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. + if(!it){ return false; } + // webkit treats NodeList as a function, which is bad + if((typeof(it) == "function") && (it == "[object NodeList]")) { return false; } + return (it instanceof Function || typeof it == "function"); // Boolean +} + +dojo.lang.isString = function(/*anything*/ it){ + // summary: Return true if it is a String. + return (typeof it == "string" || it instanceof String); +} + +dojo.lang.isAlien = function(/*anything*/ it){ + // summary: Return true if it is not a built-in function. + if(!it){ return false; } + return !dojo.lang.isFunction() && /\{\s*\[native code\]\s*\}/.test(String(it)); // Boolean +} + +dojo.lang.isBoolean = function(/*anything*/ it){ + // summary: Return true if it is a Boolean. + return (it instanceof Boolean || typeof it == "boolean"); // Boolean +} + +/** + * The following is***() functions are somewhat "unsafe". Fortunately, + * there are workarounds the the language provides and are mentioned + * in the WARNING messages. + * + */ +dojo.lang.isNumber = function(/*anything*/ it){ + // summary: Return true if it is a number. + // description: + // WARNING - In most cases, isNaN(it) is sufficient to determine whether or not + // something is a number or can be used as such. For example, a number or string + // can be used interchangably when accessing array items (array["1"] is the same as + // array[1]) and isNaN will return false for both values ("1" and 1). However, + // isNumber("1") will return false, which is generally not too useful. + // Also, isNumber(NaN) returns true, again, this isn't generally useful, but there + // are corner cases (like when you want to make sure that two things are really + // the same type of thing). That is really where isNumber "shines". + // + // Recommendation - Use isNaN(it) when possible + + return (it instanceof Number || typeof it == "number"); // Boolean +} + +/* + * FIXME: Should isUndefined go away since it is error prone? + */ +dojo.lang.isUndefined = function(/*anything*/ it){ + // summary: Return true if it is not defined. + // description: + // WARNING - In some cases, isUndefined will not behave as you + // might expect. If you do isUndefined(foo) and there is no earlier + // reference to foo, an error will be thrown before isUndefined is + // called. It behaves correctly if you scope yor object first, i.e. + // isUndefined(foo.bar) where foo is an object and bar isn't a + // property of the object. + // + // Recommendation - Use typeof foo == "undefined" when possible + + return ((typeof(it) == "undefined")&&(it == undefined)); // Boolean +} + +// end Crockford functions + +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: + // setTimeout (Object context, function func, number delay[, arg1[, ...]]); + // 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 + 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 match + 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(). 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: + // A string with value "load" + // data: + // 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: + // 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 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: + // A string with value "error" + // error: + // The error object. Should be a dojo.io.Error object, but not guaranteed. + // transportImplementation: + // 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 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: + // A string with value "timeout" + // empty: + // Should be null. Just a spacer argument so that load, error, timeout and handle have the + // same signatures. + // transportImplementation: + // 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 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: + // A string with the type of callback: "load", "error", or "timeout". + // data: + // See the above callbacks for what this parameter could be. + // transportImplementation: + // 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 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 that has the contains the names and values. + // encoding: + // 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: + // 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; x= 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 + } +} + +dojo.lang.unnest = function(/* ... */){ + // summary: + // Creates a 1-D array out of all the arguments passed, + // unravelling any array-like objects in the process + // + // usage: + // unnest(1, 2, 3) ==> [1, 2, 3] + // unnest(1, [2, [3], [[[4]]]]) ==> [1, 2, 3, 4] + + 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 +} + +dojo.lang.toArray = function(/*Object*/arrayLike, /*Number*/startOffset){ + // summary: + // Converts an array-like object (i.e. arguments, DOMCollection) + // to an array + var array = []; + for(var i = startOffset||0; i < arrayLike.length; i++){ + array.push(arrayLike[i]); + } + return array; // Array +} + +dojo.provide("dojo.lang.func"); + + +/** + * Runs a function in a given scope (thisObject), can + * also be used to preserve scope. + * + * hitch(foo, "bar"); // runs foo.bar() in the scope of foo + * hitch(foo, myFunction); // runs myFunction in the scope of foo + */ +dojo.lang.hitch = function(thisObject, method){ + var fcn = (dojo.lang.isString(method) ? thisObject[method] : method) || function(){}; + + return function() { + return fcn.apply(thisObject, arguments); + }; +} + +dojo.lang.anonCtr = 0; +dojo.lang.anon = {}; +dojo.lang.nameAnonFunc = function(anonFuncPtr, namespaceObj, searchForNames){ + var nso = (namespaceObj || 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; +} + +dojo.lang.forward = function(funcName){ + // Returns a function that forwards a method call to this.func(...) + return function(){ + return this[funcName].apply(this, arguments); + }; +} + +dojo.lang.curry = function(ns, func /* args ... */){ + var outerArgs = []; + ns = ns||dj_global; + if(dojo.lang.isString(func)){ + func = ns[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.removeChildren = function(/* Element */node){ + // summary + // removes all children from node and returns the count of children removed. + var count = node.childNodes.length; + while(node.hasChildNodes()){ node.removeChild(node.firstChild); } + return count; // number +} + +dojo.dom.replaceChildren = function(/* Element */node, /* Node */newChild){ + // summary + // Removes all children of node and appends newChild + // FIXME: what if newChild is an array-like object? + dojo.dom.removeChildren(node); + node.appendChild(newChild); +} + +dojo.dom.removeNode = function(/* Node */node){ + // summary + // if node has a parent, removes node from parent and returns a reference to the removed child. + if(node && node.parentNode){ + // return a ref to the removed child + return node.parentNode.removeChild(node); // Node + } +} + +dojo.dom.getAncestors = function(/* Node */node, /* function? */filterFunction, /* boolean? */returnFirstHit) { + // summary + // returns all ancestors matching optional filterFunction; will return only the first if returnFirstHit + var ancestors = []; + var isFunction = (filterFunction && (filterFunction instanceof Function || typeof filterFunction == "function")); + while(node) { + if (!isFunction || filterFunction(node)) { + ancestors.push(node); + } + if (returnFirstHit && ancestors.length > 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 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."); +} + +/* NOTES: + * Safari 1.2: + * back button "works" fine, however it's not possible to actually + * DETECT that you've moved backwards by inspecting window.location. + * Unless there is some other means of locating. + * FIXME: perhaps we can poll on history.length? + * Safari 2.0.3+ (and probably 1.3.2+): + * works fine, except when changeUrl is used. When changeUrl is used, + * Safari jumps all the way back to whatever page was shown before + * the page that uses dojo.undo.browser support. + * IE 5.5 SP2: + * back button behavior is macro. It does not move back to the + * previous hash value, but to the last full page load. This suggests + * that the iframe is the correct way to capture the back button in + * these cases. + * Don't test this page using local disk for MSIE. MSIE will not create + * a history list for iframe_history.html if served from a file: URL. + * The XML served back from the XHR tests will also not be properly + * created if served from local disk. Serve the test pages from a web + * server to test in that browser. + * IE 6.0: + * same behavior as IE 5.5 SP2 + * Firefox 1.0+: + * the back button will return us to the previous hash on the same + * page, thereby not requiring an iframe hack, although we do then + * need to run a timer to detect inter-page movement. + */ + +dojo.undo.browser = { + initialHref: window.location.href, + initialHash: window.location.hash, + + moveForward: false, + historyStack: [], + forwardStack: [], + historyIframe: null, + bookmarkAnchor: null, + locationTimer: null, + + /** + * setInitialState sets the state object and back callback for the very first page that is loaded. + * It is recommended that you call this method as part of an event listener that is registered via + * dojo.addOnLoad(). + */ + setInitialState: function(args){ + this.initialState = this._createState(this.initialHref, args, this.initialHash); + }, + + //FIXME: Would like to support arbitrary back/forward jumps. Have to rework iframeLoaded among other things. + //FIXME: is there a slight race condition in moz using change URL with the timer check and when + // the hash gets set? I think I have seen a back/forward call in quick succession, but not consistent. + /** + * addToHistory takes one argument, and it is an object that defines the following functions: + * - To support getting back button notifications, the object argument should implement a + * function called either "back", "backButton", or "handle". The string "back" will be + * passed as the first and only argument to this callback. + * - To support getting forward button notifications, the object argument should implement a + * function called either "forward", "forwardButton", or "handle". The string "forward" will be + * passed as the first and only argument to this callback. + * - If you want the browser location string to change, define "changeUrl" on the object. If the + * value of "changeUrl" is true, then a unique number will be appended to the URL as a fragment + * identifier (http://some.domain.com/path#uniquenumber). If it is any other value that does + * not evaluate to false, that value will be used as the fragment identifier. For example, + * if changeUrl: 'page1', then the URL will look like: http://some.domain.com/path#page1 + * + * Full example: + * + * dojo.undo.browser.addToHistory({ + * back: function() { alert('back pressed'); }, + * forward: function() { alert('forward pressed'); }, + * changeUrl: true + * }); + */ + addToHistory: function(args){ + //If addToHistory is called, then that means we prune the + //forward stack -- the user went back, then wanted to + //start a new forward path. + this.forwardStack = []; + + var hash = null; + var url = null; + if(!this.historyIframe){ + this.historyIframe = window.frames["djhistory"]; + } + 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(){ + 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){ + 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(){ + //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(){ + var last = this.forwardStack.pop(); + if(!last){ return; } + if(last.kwArgs["forward"]){ + last.kwArgs.forward(); + }else if(last.kwArgs["forwardButton"]){ + last.kwArgs.forwardButton(); + }else if(last.kwArgs["handle"]){ + last.kwArgs.handle("forward"); + } + this.historyStack.push(last); + }, + + _createState: function(url, args, hash){ + return {"url": url, "kwArgs": args, "urlHash": hash}; + }, + + _getUrlQuery: function(url){ + var segments = url.split("?"); + if (segments.length < 2){ + return null; + } + else{ + return segments[1]; + } + }, + + _loadIframeHistory: function(){ + var url = dojo.hostenv.getBaseScriptUri()+"iframe_history.html?"+(new Date()).getTime(); + this.moveForward = true; + dojo.io.setIFrameSrc(this.historyIframe, url, false); + return url; + } +} + +dojo.provide("dojo.io.BrowserIO"); + + +dojo.io.checkChildrenForFile = function(node){ + 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; +} + +dojo.io.formHasFile = function(formNode){ + return dojo.io.checkChildrenForFile(formNode); +} + +dojo.io.updateNode = function(node, urlOrArgs){ + 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){ + if(dojo["event"]){ + try{ + dojo.event.browser.clean(node.firstChild); + }catch(e){} + } + node.removeChild(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); +} + +// TODO: Move to htmlUtils +dojo.io.encodeForm = function(formNode, encoding, formFilter){ + 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("&") + "&"; +} + +dojo.io.FormBind = function(args) { + 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(args) { + 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(form) { + return true; + }, + + submit: function(e) { + e.preventDefault(); + if(this.onSubmit(this.form)) { + dojo.io.bind(dojo.lang.mixin(this.bindArgs, { + formFilter: dojo.lang.hitch(this, "formFilter") + })); + } + }, + + click: function(e) { + var node = e.currentTarget; + if(node.disabled) { return; } + this.clickedButton = node; + }, + + formFilter: function(node) { + 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; + }, + + // in case you don't have dojo.event.* pulled in + connect: function(srcObj, srcFcn, targetFcn) { + 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(){ + 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(){ + 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(){ + 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(kwArgs){ + // canHandle just tells dojo.io.bind() if this is a good transport to + // use for the particular type of request. + + // 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"]) ); + } + + this.multipartBoundary = "45309FFF-BD65-4d50-99C9-36986896A96F"; // unique guid as a boundary value for multipart posts + + this.bind = function(kwArgs){ + 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(name, value, days, path, domain, secure) { + 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(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; +} + +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, domain, secure, clearCurrent) { + if(arguments.length == 5) { // for backwards compat + clearCurrent = domain; + domain = null; + secure = null; + } + var pairs = [], cookie, value = ""; + if(!clearCurrent) { cookie = dojo.io.cookie.getObjectCookie(name); } + if(days >= 0) { + if(!cookie) { cookie = {}; } + for(var prop in obj) { + if(prop == null) { + 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(name) { + 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() { + 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; +} + +// 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.provide("dojo.io.*"); + +dojo.provide("dojo.io"); + +dojo.deprecated("dojo.io", "replaced by dojo.io.*", "0.5"); + +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 + }; + + 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]; + 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]; + */ + 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; } + if(!obj[funcName]){ + // supply a do-nothing method implementation + 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((!dojo.lang.isFunction(obj[funcName]))&&(!dojo.lang.isAlien(obj[funcName]))){ + // 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 = obj[funcName].length; + obj[jpfuncname] = obj[funcName]; + // joinpoint = obj[jpname] = new dojo.event.MethodJoinPoint(obj, funcName); + joinpoint = obj[jpname] = new dojo.event.MethodJoinPoint(obj, jpfuncname); + obj[funcName] = function(){ + var args = []; + + if((isNode)&&(!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){ //obj is a window + 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; x0)){ + // 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.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 + this.addAdvice( args["adviceObj"], args["adviceFunc"], + args["aroundObj"], args["aroundFunc"], + args["adviceType"], args["precedence"], + args["once"], args["delay"], args["rate"], + args["adviceMsg"]); + }, + + addAdvice: function( thisAdviceObj, thisAdvice, + thisAroundObj, thisAround, + adviceType, precedence, + once, delay, rate, asMessage){ + // 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? + var arr = this.getArr(adviceType); + if(!arr){ + dojo.raise("bad this: " + this); + } + + var ao = [thisAdviceObj, thisAdvice, thisAroundObj, thisAround, delay, rate, asMessage]; + + 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 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; + default: + evt.key = evt.charCode > 0 ? 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.returnValue = false; + evt.cancelBubble = true; + }else{ + evt.preventDefault(); + evt.stopPropagation(); + } + } +} + +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 + } + } +} + +dojo.lfx.easeDefault = function(/*Decimal?*/ n){ + // summary: Returns the point for point n on a sin wave. + if(dojo.render.html.khtml){ + // 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) + return (parseFloat("0.5")+((Math.sin( (n+parseFloat("1.5")) * Math.PI))/2)); + }else{ + 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: 25, + + // 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.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 (top-level) module + // description: Examples: dojo.uri.moduleUri("dojo","Editor"), or dojo.uri.moduleUri("acme","someWidget") + var loc = dojo.hostenv.getModulePrefix(module); + if(!loc){return null;} + if(loc.lastIndexOf("/") != loc.length-1){loc += "/";} + return new dojo.uri.Uri(dojo.hostenv.getBaseScriptUri()+loc,uri); + } + + this.Uri = function (/*dojo.uri.Uri||String...*/) { + // summary: Constructor to create an object representing a URI. + // description: + // Each argument is evaluated in order relative to the next until + // a canonical uri is produced. To get an absolute Uri relative + // to the current document use + // new dojo.uri.Uri(document.baseURI, uri) + + // TODO: support for IPv6, see RFC 2732 + + // resolve uri components relative to each other + 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 +} + +dojo.html.getComputedStyle = function(/* HTMLElement */node, /* string */cssSelector, /* integer? */inValue){ + // summary + // Returns the computed style of cssSelector on node. + node = dojo.byId(node); + // cssSelector may actually be in camel case, so force selector version + var cssSelector = dojo.html.toSelectorCase(cssSelector); + var property = dojo.html.toCamelCase(cssSelector); + if(!node || !node.style){ + return inValue; + } else if (document.defaultView && dojo.html.isDescendantOf(node, node.ownerDocument)){ // W3, gecko, KHTML + try{ + // mozilla segfaults when margin-* and node is removed from doc + // FIXME: need to figure out a if there is quicker workaround + var cs = document.defaultView.getComputedStyle(node, ""); + if(cs){ + return cs.getPropertyValue(cssSelector); // integer + } + }catch(e){ // reports are that Safari can throw an exception above + if(node.style.getPropertyValue){ // W3 + return node.style.getPropertyValue(cssSelector); // integer + } else { + return inValue; // integer + } + } + } else if(node.currentStyle){ // IE + return node.currentStyle[property]; // integer + } + + if(node.style.getPropertyValue){ // W3 + return node.style.getPropertyValue(cssSelector); // integer + }else{ + return inValue; // integer + } +} + +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: '' }; + +dojo.html.getPixelValue = function(/* HTMLElement */node, /* string */cssSelector, /* boolean? */autoIsZero){ + // summary + // Get the value of passed selector in pixels. + var result = dojo.html.getUnitValue(node, cssSelector, autoIsZero); + // FIXME: there is serious debate as to whether or not this is the right solution + if(isNaN(result.value)){ + return 0; // integer + } + // FIXME: code exists for converting other units to px (see Dean Edward's IE7) + // but there are cross-browser complexities + if((result.value)&&(result.units != 'px')){ + return NaN; // integer + } + return result.value; // integer +} + +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); + 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 + style.styleSheet.cssText = cssStr; + }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/ + function iefixPathsInCssText() { + var regexIe = /AlphaImageLoader\(src\=['"]([\t\s\w()\/.\\'"-:#=&?~]*)['"]/; + while(match = regexIe.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) + "AlphaImageLoader(src='" + url + "'"; + cssStr = cssStr.substr(match.index + match[0].length); + } + return str + cssStr; + } + + if(!cssStr || !URI){ return; } + var match, str = "", url = ""; + var regex = /url\(\s*([\t\s\w()\/.\\'"-:#=&?]+)\s*\)/; + var regexProtocol = /(file|https?|ftps?):\/\//; + var regexTrim = /^[\s]*(['"]?)([\w()\/.\\'"-:#=&?]*)\1[\s]*?$/; + if (dojo.render.html.ie55 || dojo.render.html.ie60) { + cssStr = iefixPathsInCssText(); + } + 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.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.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){ + if(s == "opacity"){ + dojo.html.setOpacity(n, style[s]); + }else{ + n.style[s] = style[s]; + } + } + } + + 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) + dojo.html.show(node); + var height = dojo.html.getBorderBox(node).height; + dojo.html.hide(node); + + var anim = dojo.lfx.propertyAnimation(node, + { "height": { + start: 1, // 0 causes IE to display the whole panel + end: function(){ return height; } + } + }, + duration, + easing); + + anim.connect("beforeBegin", function(){ + 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"; + } + 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.provide("dojo.lfx.*"); Index: openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/flash6_gateway.swf =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/Attic/flash6_gateway.swf,v diff -u Binary files differ Index: openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/iframe_history.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/Attic/iframe_history.html,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/iframe_history.html 6 Nov 2006 14:37:19 -0000 1.1 @@ -0,0 +1,54 @@ + + + + + + + + + +

The Dojo Toolkit -- iframe_history.html

+ +

This file is used in Dojo's back/fwd button management.

+ + Index: openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/storage_dialog.swf =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/Attic/storage_dialog.swf,v diff -u Binary files differ Index: openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/AdapterRegistry.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/Attic/AdapterRegistry.js,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/AdapterRegistry.js 6 Nov 2006 14:37:20 -0000 1.1 @@ -0,0 +1,89 @@ +/* + Copyright (c) 2004-2006, The Dojo Foundation + All Rights Reserved. + + Licensed under the Academic Free License version 2.1 or above OR the + modified BSD license. For more information on Dojo licensing, see: + + http://dojotoolkit.org/community/licensing.shtml +*/ + +dojo.provide("dojo.AdapterRegistry"); +dojo.require("dojo.lang.func"); + +dojo.AdapterRegistry = function(/*boolean, optional*/returnWrappers){ + // summary: + // A registry to make contextual calling/searching easier. + // description: + // Objects of this class keep list of arrays in the form [name, check, + // wrap, directReturn] that are used to determine what the contextual + // result of a set of checked arguments is. All check/wrap functions + // in this registry should be of the same arity. + this.pairs = []; + this.returnWrappers = returnWrappers || false; +} + +dojo.lang.extend(dojo.AdapterRegistry, { + register: function( /*string*/ name, /*function*/ check, /*function*/ wrap, + /*boolean, optional*/ directReturn, + /*boolean, optional*/ override){ + // summary: + // register a check function to determine if the wrap function or + // object gets selected + // name: a way to identify this matcher. + // check: + // a function that arguments are passed to from the adapter's + // match() function. The check function should return true if the + // given arguments are appropriate for the wrap function. + // directReturn: + // If directReturn is true, the value passed in for wrap will be + // returned instead of being called. Alternately, the + // AdapterRegistry can be set globally to "return not call" using + // the returnWrappers property. Either way, this behavior allows + // the registry to act as a "search" function instead of a + // function interception library. + // override: + // If override is given and true, the check function will be given + // highest priority. Otherwise, it will be the lowest priority + // adapter. + + var type = (override) ? "unshift" : "push"; + this.pairs[type]([name, check, wrap, directReturn]); + }, + + match: function(/* ... */){ + // summary: + // Find an adapter for the given arguments. If no suitable adapter + // is found, throws an exception. match() accepts any number of + // arguments, all of which are passed to all matching functions + // from the registered pairs. + for(var i = 0; i < this.pairs.length; i++){ + var pair = this.pairs[i]; + if(pair[1].apply(this, arguments)){ + if((pair[3])||(this.returnWrappers)){ + return pair[2]; + }else{ + return pair[2].apply(this, arguments); + } + } + } + throw new Error("No match found"); + // dojo.raise("No match found"); + }, + + unregister: function(name){ + // summary: Remove a named adapter from the registry + + // FIXME: this is kind of a dumb way to handle this. On a large + // registry this will be slow-ish and we can use the name as a lookup + // should we choose to trade memory for speed. + for(var i = 0; i < this.pairs.length; i++){ + var pair = this.pairs[i]; + if(pair[0] == name){ + this.pairs.splice(i, 1); + return true; + } + } + return false; + } +}); Index: openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/Deferred.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/Attic/Deferred.js,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/Deferred.js 6 Nov 2006 14:37:20 -0000 1.1 @@ -0,0 +1,315 @@ +/* + Copyright (c) 2004-2006, The Dojo Foundation + All Rights Reserved. + + Licensed under the Academic Free License version 2.1 or above OR the + modified BSD license. For more information on Dojo licensing, see: + + http://dojotoolkit.org/community/licensing.shtml +*/ + +dojo.provide("dojo.Deferred"); +dojo.require("dojo.lang.func"); + +dojo.Deferred = function(/* optional */ canceller){ + /* + NOTE: this namespace and documentation are imported wholesale + from MochiKit + + Encapsulates a sequence of callbacks in response to a value that + may not yet be available. This is modeled after the Deferred class + from Twisted . + + 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(){ + /*** + Cancels a Deferred that has not yet received a value, or is + waiting on another Deferred as its value. + + 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(){ + // Used internally to signal that it's waiting on another Deferred + this.paused++; + }, + + _unpause: function(){ + // 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){ + // 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){ + /* + 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){ + // 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){ + /* + 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){ + // 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){ + // 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) { + // 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(){ + // 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); + } + } +}); Index: openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/DeferredList.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/Attic/DeferredList.js,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/DeferredList.js 6 Nov 2006 14:37:20 -0000 1.1 @@ -0,0 +1,88 @@ +/* + Copyright (c) 2004-2006, The Dojo Foundation + All Rights Reserved. + + Licensed under the Academic Free License version 2.1 or above OR the + modified BSD license. For more information on Dojo licensing, see: + + http://dojotoolkit.org/community/licensing.shtml +*/ + +dojo.require("dojo.Deferred"); + +dojo.provide("dojo.DeferredList"); + + +dojo.DeferredList = function (list, /*bool?*/ fireOnOneCallback, /*bool?*/ fireOnOneErrback, /*bool?*/ consumeErrors, /*Function?*/ canceller) { + this.list = list; + this.resultList = new Array(this.list.length); + + // Deferred init + this.chain = []; + this.id = this._nextId(); + this.fired = -1; + this.paused = 0; + this.results = [null, null]; + this.canceller = canceller; + this.silentlyCancelled = false; + + if (this.list.length === 0 && !fireOnOneCallback) { + this.callback(this.resultList); + } + + this.finishedCount = 0; + this.fireOnOneCallback = fireOnOneCallback; + this.fireOnOneErrback = fireOnOneErrback; + this.consumeErrors = consumeErrors; + + var index = 0; + + var _this = this; + + dojo.lang.forEach(this.list, function(d) { + var _index = index; + //dojo.debug("add cb/errb index "+_index); + d.addCallback(function(r) { _this._cbDeferred(_index, true, r) }); + d.addErrback(function(r) { _this._cbDeferred(_index, false, r) }); + index++; + }); + +}; + + +dojo.inherits(dojo.DeferredList, dojo.Deferred); + +dojo.lang.extend(dojo.DeferredList, { + + _cbDeferred: function (index, succeeded, result) { + //dojo.debug("Fire "+index+" succ "+succeeded+" res "+result); + this.resultList[index] = [succeeded, result]; + this.finishedCount += 1; + if (this.fired !== 0) { + if (succeeded && this.fireOnOneCallback) { + this.callback([index, result]); + } else if (!succeeded && this.fireOnOneErrback) { + this.errback(result); + } else if (this.finishedCount == this.list.length) { + this.callback(this.resultList); + } + } + if (!succeeded && this.consumeErrors) { + result = null; + } + return result; + }, + + gatherResults: function (deferredList) { + var d = new dojo.DeferredList(deferredList, false, true, false); + d.addCallback(function (results) { + var ret = []; + for (var i = 0; i < results.length; i++) { + ret.push(results[i][1]); + } + return ret; + }); + return d; + } +}); + Index: openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/a11y.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/Attic/a11y.js,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/a11y.js 6 Nov 2006 14:37:20 -0000 1.1 @@ -0,0 +1,103 @@ +/* + Copyright (c) 2004-2006, The Dojo Foundation + All Rights Reserved. + + Licensed under the Academic Free License version 2.1 or above OR the + modified BSD license. For more information on Dojo licensing, see: + + http://dojotoolkit.org/community/licensing.shtml +*/ + +dojo.provide("dojo.a11y"); + +dojo.require("dojo.uri.*"); +dojo.require("dojo.html.common"); + +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.dojoUri("src/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"); Index: openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/animation.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/Attic/animation.js,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/animation.js 6 Nov 2006 14:37:20 -0000 1.1 @@ -0,0 +1,14 @@ +/* + Copyright (c) 2004-2006, The Dojo Foundation + All Rights Reserved. + + Licensed under the Academic Free License version 2.1 or above OR the + modified BSD license. For more information on Dojo licensing, see: + + http://dojotoolkit.org/community/licensing.shtml +*/ + +dojo.provide("dojo.animation"); +dojo.require("dojo.animation.Animation"); + +dojo.deprecated("dojo.animation is slated for removal in 0.5; use dojo.lfx instead.", "0.5"); Index: openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/behavior.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/Attic/behavior.js,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/behavior.js 6 Nov 2006 14:37:20 -0000 1.1 @@ -0,0 +1,248 @@ +/* + Copyright (c) 2004-2006, The Dojo Foundation + All Rights Reserved. + + Licensed under the Academic Free License version 2.1 or above OR the + modified BSD license. For more information on Dojo licensing, see: + + http://dojotoolkit.org/community/licensing.shtml +*/ + +dojo.provide("dojo.behavior"); +dojo.require("dojo.event.*"); + +dojo.require("dojo.experimental"); +dojo.experimental("dojo.behavior"); + +dojo.behavior = new function(){ + function arrIn(obj, name){ + if(!obj[name]){ obj[name] = []; } + return obj[name]; + } + + function forIn(obj, scope, func){ + var tmpObj = {}; + for(var x in obj){ + if(typeof tmpObj[x] == "undefined"){ + if(!func){ + scope(obj[x], x); + }else{ + func.call(scope, obj[x], x); + } + } + } + } + + // FIXME: need a better test so we don't exclude nightly Safari's! + this.behaviors = {}; + this.add = function(behaviorObj){ + /* behavior objects are specified in the following format: + * + * { + * "#id": { + * "found": function(element){ + * // ... + * }, + * + * "onblah": {targetObj: foo, targetFunc: "bar"}, + * + * "onblarg": "/foo/bar/baz/blarg", + * + * "onevent": function(evt){ + * }, + * + * "onotherevent: function(evt){ + * // ... + * } + * }, + * + * "#id2": { + * // ... + * }, + * + * "#id3": function(element){ + * // ... + * }, + * + * // publish the match on a topic + * "#id4": "/found/topic/name", + * + * // match all direct descendants + * "#id4 > *": function(element){ + * // ... + * }, + * + * // match the first child node that's an element + * "#id4 > @firstElement": { ... }, + * + * // match the last child node that's an element + * "#id4 > @lastElement": { ... }, + * + * // all elements of type tagname + * "tagname": { + * // ... + * }, + * + * // maps to roughly: + * // dojo.lang.forEach(body.getElementsByTagName("tagname1"), function(node){ + * // dojo.lang.forEach(node.getElementsByTagName("tagname2"), function(node2){ + * // dojo.lang.forEach(node2.getElementsByTagName("tagname3", function(node3){ + * // // apply rules + * // }); + * // }); + * // }); + * "tagname1 tagname2 tagname3": { + * // ... + * }, + * + * ".classname": { + * // ... + * }, + * + * "tagname.classname": { + * // ... + * }, + * } + * + * The "found" method is a generalized handler that's called as soon + * as the node matches the selector. Rules for values that follow also + * apply to the "found" key. + * + * The "on*" handlers are attached with dojo.event.connect(). If the + * value is not a function but is rather an object, it's assumed to be + * the "other half" of a dojo.event.kwConnect() argument object. It + * may contain any/all properties of such a connection modifier save + * for the sourceObj and sourceFunc properties which are filled in by + * the system automatically. If a string is instead encountered, the + * node publishes the specified event on the topic contained in the + * string value. + * + * If the value corresponding to the ID key is a function and not a + * list, it's treated as though it was the value of "found". + * + */ + + var tmpObj = {}; + forIn(behaviorObj, this, function(behavior, name){ + var tBehavior = arrIn(this.behaviors, name); + if((dojo.lang.isString(behavior))||(dojo.lang.isFunction(behavior))){ + behavior = { found: behavior }; + } + forIn(behavior, function(rule, ruleName){ + arrIn(tBehavior, ruleName).push(rule); + }); + }); + } + + this.apply = function(){ + dojo.profile.start("dojo.behavior.apply"); + var r = dojo.render.html; + // note, we apply one way for fast queries and one way for slow + // iteration. So be it. + var safariGoodEnough = (!r.safari); + if(r.safari){ + // Anything over release #420 should work the fast way + var uas = r.UA.split("AppleWebKit/")[1]; + if(parseInt(uas.match(/[0-9.]{3,}/)) >= 420){ + safariGoodEnough = true; + } + } + if((dj_undef("behaviorFastParse", djConfig) ? (safariGoodEnough) : djConfig["behaviorFastParse"])){ + this.applyFast(); + }else{ + this.applySlow(); + } + dojo.profile.end("dojo.behavior.apply"); + } + + this.matchCache = {}; + + this.elementsById = function(id, handleRemoved){ + var removed = []; + var added = []; + arrIn(this.matchCache, id); + if(handleRemoved){ + var nodes = this.matchCache[id]; + for(var x=0; x"); + } catch (e) { + var script = document.createElement("script"); + script.src = spath; + document.getElementsByTagName("head")[0].appendChild(script); + } + } + } +})(); Index: openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/browser_debug.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/Attic/browser_debug.js,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/browser_debug.js 6 Nov 2006 14:37:20 -0000 1.1 @@ -0,0 +1,176 @@ +/* + Copyright (c) 2004-2006, The Dojo Foundation + All Rights Reserved. + + Licensed under the Academic Free License version 2.1 or above OR the + modified BSD license. For more information on Dojo licensing, see: + + http://dojotoolkit.org/community/licensing.shtml +*/ + +dojo.hostenv.loadedUris.push("../src/bootstrap1.js"); +dojo.hostenv.loadedUris.push("../src/loader.js"); +dojo.hostenv.loadedUris.push("../src/hostenv_browser.js"); +dojo.hostenv.loadedUris.push("../src/bootstrap2.js"); +dojo.hostenv._loadedUrisListStart = dojo.hostenv.loadedUris.length; + +function removeComments(contents){ + contents = new String((!contents) ? "" : contents); + // clobber all comments + // FIXME broken if // or /* inside quotes or regexp + contents = contents.replace( /^(.*?)\/\/(.*)$/mg , "$1"); + contents = contents.replace( /(\n)/mg , "__DOJONEWLINE"); + contents = contents.replace( /\/\*(.*?)\*\//g , ""); + return contents.replace( /__DOJONEWLINE/mg , "\n"); +} + +dojo.hostenv.getRequiresAndProvides = function(contents){ + // FIXME: should probably memoize this! + if(!contents){ return []; } + + + // check to see if we need to load anything else first. Ugg. + var deps = []; + var tmp; + RegExp.lastIndex = 0; + var testExp = /dojo.(hostenv.loadModule|hostenv.require|require|requireIf|kwCompoundRequire|hostenv.conditionalLoadModule|hostenv.startPackage|provide)\([\w\W]*?\)/mg; + while((tmp = testExp.exec(contents)) != null){ + deps.push(tmp[0]); + } + return deps; +} + +dojo.hostenv.getDelayRequiresAndProvides = function(contents){ + // FIXME: should probably memoize this! + if(!contents){ return []; } + + // check to see if we need to load anything else first. Ugg. + var deps = []; + var tmp; + RegExp.lastIndex = 0; + var testExp = /dojo.(requireAfterIf)\([\w\W]*?\)/mg; + while((tmp = testExp.exec(contents)) != null){ + deps.push(tmp[0]); + } + return deps; +} + +/* +dojo.getNonExistantDescendants = function(objpath){ + var ret = []; + // fast path for no periods + if(typeof objpath != "string"){ return dj_global; } + if(objpath.indexOf('.') == -1){ + if(dj_undef(objpath, dj_global)){ + ret.push[objpath]; + } + return ret; + } + + var syms = objpath.split(/\./); + var obj = dj_global; + for(var i=0;i=0; x--){ + dojo.clobberLastObject(removals[x]); + } + var depList = []; + var seen = dojo.hostenv._writtenIncludes; + for(var x=0; x"); + } + document.write(""); + dojo.hostenv._loadedUrisListStart = 0; + if (!willCallAgain) { + // turn off debugAtAllCosts, so that dojo.require() calls inside of ContentPane hrefs + // work correctly + dj_eval = old_dj_eval; + dojo.hostenv.loadUri = dojo.hostenv.oldLoadUri; + } +} Index: openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/crypto.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/Attic/crypto.js,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/crypto.js 6 Nov 2006 14:37:20 -0000 1.1 @@ -0,0 +1,31 @@ +/* + Copyright (c) 2004-2006, The Dojo Foundation + All Rights Reserved. + + Licensed under the Academic Free License version 2.1 or above OR the + modified BSD license. For more information on Dojo licensing, see: + + http://dojotoolkit.org/community/licensing.shtml +*/ + +dojo.provide("dojo.crypto"); + +dojo.crypto.cipherModes={ + // summary + // Enumeration for various cipher modes. + ECB:0, + CBC:1, + PCBC:2, + CFB:3, + OFB:4, + CTR:5 +}; + +dojo.crypto.outputTypes={ + // summary + // Enumeration for input and output encodings. + Base64:0, + Hex:1, + String:2, + Raw:3 +}; Index: openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/data.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/Attic/data.js,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/data.js 6 Nov 2006 14:37:20 -0000 1.1 @@ -0,0 +1,15 @@ +/* + Copyright (c) 2004-2006, The Dojo Foundation + All Rights Reserved. + + Licensed under the Academic Free License version 2.1 or above OR the + modified BSD license. For more information on Dojo licensing, see: + + http://dojotoolkit.org/community/licensing.shtml +*/ + +dojo.provide("dojo.data"); + +// currently a stub for dojo.data + +dojo.data = {}; Index: openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/date.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/Attic/date.js,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/date.js 6 Nov 2006 14:37:20 -0000 1.1 @@ -0,0 +1,13 @@ +/* + Copyright (c) 2004-2006, The Dojo Foundation + All Rights Reserved. + + Licensed under the Academic Free License version 2.1 or above OR the + modified BSD license. For more information on Dojo licensing, see: + + http://dojotoolkit.org/community/licensing.shtml +*/ + +dojo.provide("dojo.date"); + +dojo.deprecated("dojo.date", "use one of the modules in dojo.date.* instead", "0.5"); Index: openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/debug.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/Attic/debug.js,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/debug.js 6 Nov 2006 14:37:20 -0000 1.1 @@ -0,0 +1,91 @@ +/* + Copyright (c) 2004-2006, The Dojo Foundation + All Rights Reserved. + + Licensed under the Academic Free License version 2.1 or above OR the + modified BSD license. For more information on Dojo licensing, see: + + http://dojotoolkit.org/community/licensing.shtml +*/ + +dojo.debug = function(/*...*/){ + // summary: + // Produce a line of debug output. Does nothing unless + // djConfig.isDebug is true. Accepts any nubmer of args, joined with + // '' to produce a single line of debugging output. Caller should not + // supply a trailing "\n". + if (!djConfig.isDebug) { return; } + var args = arguments; + if(dj_undef("println", dojo.hostenv)){ + dojo.raise("dojo.debug not available (yet?)"); + } + var isJUM = dj_global["jum"] && !dj_global["jum"].isBrowser; + var s = [(isJUM ? "": "DEBUG: ")]; + for(var i=0;i 1){ + args.url = [args.url, dirs[1]].join("."); + } + } + } + } + + dojo.io.bind(args); + return deferred; + }, + getFunctionNames: function(){ + return this.require("function_names"); // dojo.Deferred + }, + unFormat: function(/*String*/ string){ + var fString = string; + if(string.charAt(string.length - 1) == "_"){ + fString = [string.substring(0, string.length - 1), "*"].join(""); + } + return fString; + }, + getMeta: function(/*mixed*/ selectKey, /*String*/ pkg, /*String*/ name, /*Function*/ callback, /*String?*/ id){ + // summary: Gets information about a function in regards to its meta data + if(typeof name == "function"){ + // pId: a + // pkg: ignore + id = callback; + callback = name; + name = pkg; + pkg = null; + dojo.debug("getMeta(" + name + ")"); + }else{ + dojo.debug("getMeta(" + pkg + "/" + name + ")"); + } + + if(!id){ + id = "_"; + } + + if(!selectKey){ + selectKey = ++dojo.docs._count; + } + + var input; + if(typeof selectKey == "object" && selectKey.selectKey){ + input = selectKey; + selectKey = selectKey.selectKey; + }else{ + input = {}; + } + + dojo.docs._buildCache({ + type: "meta", + callbacks: [dojo.docs._gotMeta, callback], + pkg: pkg, + name: name, + id: id, + selectKey: selectKey, + input: input + }); + }, + _withPkg: function(/*String*/ type, /*Object*/ data, /*Object*/ evt, /*Object*/ input, /*String*/ newType){ + dojo.debug("_withPkg(" + evt.name + ") has package: " + data[0]); + evt.pkg = data[0]; + if("load" == type && evt.pkg){ + evt.type = newType; + dojo.docs._buildCache(evt); + }else{ + if(evt.callbacks && evt.callbacks.length){ + evt.callbacks.shift()("error", {}, evt, evt.input); + } + } + }, + _gotMeta: function(/*String*/ type, /*Object*/ data, /*Object*/ evt){ + dojo.debug("_gotMeta(" + evt.name + ")"); + + var cached = dojo.docs._getCache(evt.pkg, evt.name, "meta", "functions", evt.id); + if(cached.summary){ + data.summary = cached.summary; + } + if(evt.callbacks && evt.callbacks.length){ + evt.callbacks.shift()(type, data, evt, evt.input); + } + }, + getSrc: function(/*mixed*/ selectKey, /*String*/ name, /*Function*/ callback, /*String?*/ id){ + // summary: Gets src file (created by the doc parser) + dojo.debug("getSrc(" + name + ")"); + if(!id){ + id = "_"; + } + if(!selectKey){ + selectKey = ++dojo.docs._count; + } + + var input; + if(typeof selectKey == "object" && selectKey.selectKey){ + input = selectKey; + selectKey = selectKey.selectKey; + }else{ + input = {}; + } + + dojo.docs._buildCache({ + type: "src", + callbacks: [callback], + name: name, + id: id, + input: input, + selectKey: selectKey + }); + }, + getDoc: function(/*mixed*/ selectKey, /*String*/ name, /*Function*/ callback, /*String?*/ id){ + // summary: Gets external documentation stored on Jot for a given function + dojo.debug("getDoc(" + name + ")"); + + if(!id){ + id = "_"; + } + + if(!selectKey){ + selectKey = ++dojo.docs._count; + } + + var input = {}; + if(typeof selectKey == "object" && selectKey.selectKey){ + input.input = selectKey; + selectKey = selectKey.selectKey; + } + + input.type = "doc"; + input.name = name; + input.selectKey = selectKey; + input.callbacks = [callback]; + input.selectKey = selectKey; + + dojo.docs._buildCache(input); + }, + _gotDoc: function(/*String*/ type, /*Array*/ data, /*Object*/ evt, /*Object*/ input){ + dojo.debug("_gotDoc(" + evt.type + ")"); + + evt[evt.type] = data; + if(evt.expects && evt.expects.doc){ + for(var i = 0, expect; expect = evt.expects.doc[i]; i++){ + if(!(expect in evt)){ + dojo.debug("_gotDoc() waiting for more data"); + return; + } + } + } + + var cache = dojo.docs._getCache(evt.pkg, "meta", "functions", evt.name, evt.id, "meta"); + + var description = evt.fn.description; + cache.description = description; + data = { + returns: evt.fn.returns, + id: evt.id, + variables: [], + selectKey: evt.selectKey + } + if(!cache.parameters){ + cache.parameters = {}; + } + for(var i = 0, param; param = evt.param[i]; i++){ + var fName = param["DocParamForm/name"]; + if(!cache.parameters[fName]){ + cache.parameters[fName] = {}; + } + cache.parameters[fName].description = param["DocParamForm/desc"] + } + + data.description = cache.description; + data.parameters = cache.parameters; + + evt.type = "doc"; + + if(evt.callbacks && evt.callbacks.length){ + evt.callbacks.shift()("load", data, evt, input); + } + }, + getPkgDoc: function(/*mixed*/ selectKey, /*String*/ name, /*Function*/ callback){ + // summary: Gets external documentation stored on Jot for a given package + dojo.debug("getPkgDoc(" + name + ")"); + var input = {}; + if(typeof selectKey == "object" && selectKey.selectKey){ + input = selectKey; + selectKey = selectKey.selectKey; + } + if(!selectKey){ + selectKey = ++dojo.docs._count; + } + dojo.docs._buildCache({ + type: "pkgdoc", + callbacks: [callback], + name: name, + selectKey: selectKey, + input: input + }); + }, + getPkgInfo: function(/*mixed*/ selectKey, /*String*/ name, /*Function*/ callback){ + // summary: Gets a combination of the metadata and external documentation for a given package + dojo.debug("getPkgInfo(" + name + ")"); + if(!selectKey){ + selectKey = ++dojo.docs._count; + } + + var input = { + selectKey: selectKey, + expects: { + pkginfo: ["pkgmeta", "pkgdoc"] + }, + callback: callback + }; + dojo.docs.getPkgMeta(input, name, dojo.docs._getPkgInfo); + dojo.docs.getPkgDoc(input, name, dojo.docs._getPkgInfo); + }, + _getPkgInfo: function(/*String*/ type, /*Object*/ data, /*Object*/ evt){ + dojo.debug("_getPkgInfo() for " + evt.type); + var key = evt.selectKey; + var input = {}; + var results = {}; + if(typeof key == "object"){ + input = key; + key = key.selectKey; + input[evt.type] = data; + if(input.expects && input.expects.pkginfo){ + for(var i = 0, expect; expect = input.expects.pkginfo[i]; i++){ + if(!(expect in input)){ + dojo.debug("_getPkgInfo() waiting for more data"); + return; + } + } + } + results = input.pkgmeta; + results.description = input.pkgdoc; + } + + if(input.callback){ + input.callback("load", results, evt); + } + }, + getInfo: function(/*mixed*/ selectKey, /*String*/ name, /*Function*/ callback){ + dojo.debug("getInfo(" + name + ")"); + var input = { + expects: { + "info": ["meta", "doc"] + }, + selectKey: selectKey, + callback: callback + } + dojo.docs.getMeta(input, name, dojo.docs._getInfo); + dojo.docs.getDoc(input, name, dojo.docs._getInfo); + }, + _getInfo: function(/*String*/ type, /*String*/ data, /*Object*/ evt, /*Object*/ input){ + dojo.debug("_getInfo(" + evt.type + ")"); + if(input && input.expects && input.expects.info){ + input[evt.type] = data; + for(var i = 0, expect; expect = input.expects.info[i]; i++){ + if(!(expect in input)){ + dojo.debug("_getInfo() waiting for more data"); + return; + } + } + } + + if(input.callback){ + input.callback("load", dojo.docs._getCache(evt.pkg, "meta", "functions", evt.name, evt.id, "meta"), evt, input); + } + }, + _getMainText: function(/*String*/ text){ + // summary: Grabs the innerHTML from a Jot Rech Text node + dojo.debug("_getMainText()"); + return text.replace(/^/, "").replace(/<\/html>$/, "").replace(/<\w+\s*\/>/g, ""); + }, + getPackageMeta: function(/*Object*/ input){ + dojo.debug("getPackageMeta(): " + input.pkg); + return this.require(input.pkg + "/meta", input.sync); + }, + OLDgetPkgMeta: function(/*mixed*/ selectKey, /*String*/ name, /*Function*/ callback){ + dojo.debug("getPkgMeta(" + name + ")"); + var input = {}; + if(typeof selectKey == "object" && selectKey.selectKey){ + input = selectKey; + selectKey = selectKey.selectKey; + }else if(!selectKey){ + selectKey = ++dojo.docs._count; + } + dojo.docs._buildCache({ + type: "pkgmeta", + callbacks: [callback], + name: name, + selectKey: selectKey, + input: input + }); + }, + OLD_getPkgMeta: function(/*Object*/ input){ + dojo.debug("_getPkgMeta(" + input.name + ")"); + input.type = "pkgmeta"; + dojo.docs._buildCache(input); + }, + _onDocSearch: function(/*Object*/ input){ + var _this = this; + var name = input.name.toLowerCase(); + if(!name) return; + + this.getFunctionNames().addCallback(function(data){ + dojo.debug("_onDocSearch(): function names loaded for " + name); + + var output = []; + var list = []; + var closure = function(pkg, fn) { + return function(data){ + dojo.debug("_onDocSearch(): package meta loaded for: " + pkg); + if(data.functions){ + var functions = data.functions; + for(var key in functions){ + if(fn == key){ + var ids = functions[key]; + for(var id in ids){ + var fnMeta = ids[id]; + output.push({ + package: pkg, + name: fn, + id: id, + summary: fnMeta.summary + }); + } + } + } + } + return output; + } + } + + pkgLoop: + for(var pkg in data){ + if(pkg.toLowerCase() == name){ + name = pkg; + dojo.debug("_onDocSearch found a package"); + //dojo.docs._onDocSelectPackage(input); + return; + } + for(var i = 0, fn; fn = data[pkg][i]; i++){ + if(fn.toLowerCase().indexOf(name) != -1){ + dojo.debug("_onDocSearch(): Search matched " + fn); + var meta = _this.getPackageMeta({pkg: pkg}); + meta.addCallback(closure(pkg, fn)); + list.push(meta); + + // Build a list of all packages that need to be loaded and their loaded state. + continue pkgLoop; + } + } + } + + list = new dojo.DeferredList(list); + list.addCallback(function(results){ + dojo.debug("_onDocSearch(): All packages loaded"); + _this._printFunctionResults(results[0][1]); + }); + }); + }, + _onDocSearchFn: function(/*String*/ type, /*Array*/ data, /*Object*/ evt){ + dojo.debug("_onDocSearchFn(" + evt.name + ")"); + + var name = evt.name || evt.pkg; + + dojo.debug("_onDocSearchFn found a function"); + + evt.pkgs = packages; + evt.pkg = name; + evt.loaded = 0; + for(var i = 0, pkg; pkg = packages[i]; i++){ + dojo.docs.getPkgMeta(evt, pkg, dojo.docs._onDocResults); + } + }, + _onPkgResults: function(/*String*/ type, /*Object*/ data, /*Object*/ evt, /*Object*/ input){ + dojo.debug("_onPkgResults(" + evt.type + ")"); + var description = ""; + var path = ""; + var methods = {}; + var requires = {}; + if(input){ + input[evt.type] = data; + if(input.expects && input.expects.pkgresults){ + for(var i = 0, expect; expect = input.expects.pkgresults[i]; i++){ + if(!(expect in input)){ + dojo.debug("_onPkgResults() waiting for more data"); + return; + } + } + } + path = input.pkgdoc.path; + description = input.pkgdoc.description; + methods = input.pkgmeta.methods; + requires = input.pkgmeta.requires; + } + var pkg = evt.name.replace("_", "*"); + var results = { + path: path, + description: description, + size: 0, + methods: [], + pkg: pkg, + selectKey: evt.selectKey, + requires: requires + } + var rePrivate = /_[^.]+$/; + for(var method in methods){ + if(!rePrivate.test(method)){ + for(var pId in methods[method]){ + results.methods.push({ + pkg: pkg, + name: method, + id: pId, + summary: methods[method][pId].summary + }) + } + } + } + results.size = results.methods.length; + dojo.docs._printPkgResult(results); + }, + _onDocResults: function(/*String*/ type, /*Object*/ data, /*Object*/ evt, /*Object*/ input){ + dojo.debug("_onDocResults(" + evt.name + "/" + input.pkg + ") " + type); + ++input.loaded; + + if(input.loaded == input.pkgs.length){ + var pkgs = input.pkgs; + var name = input.pkg; + var results = {selectKey: evt.selectKey, methods: []}; + var rePrivate = /_[^.]+$/; + data = dojo.docs._cache; + + for(var i = 0, pkg; pkg = pkgs[i]; i++){ + var methods = dojo.docs._getCache(pkg, "meta", "methods"); + for(var fn in methods){ + if(fn.toLowerCase().indexOf(name) == -1){ + continue; + } + if(fn != "requires" && !rePrivate.test(fn)){ + for(var pId in methods[fn]){ + var result = { + pkg: pkg, + name: fn, + id: "_", + summary: "" + } + if(methods[fn][pId].summary){ + result.summary = methods[fn][pId].summary; + } + results.methods.push(result); + } + } + } + } + + dojo.debug("Publishing docResults"); + dojo.docs._printFnResults(results); + } + }, + _printFunctionResults: function(results){ + dojo.debug("_printFnResults(): called"); + // summary: Call this function to send the /docs/function/results topic + }, + _printPkgResult: function(results){ + dojo.debug("_printPkgResult(): called"); + }, + _onDocSelectFunction: function(/*Object*/ input){ + // summary: Get doc, meta, and src + var name = input.name; + var pkg = input.pkg; + dojo.debug("_onDocSelectFunction(" + name + ")"); + if(!name){ + return false; + } + if(!input.selectKey){ + input.selectKey = ++dojo.docs._count; + } + input.expects = { + "docresults": ["meta", "doc", "pkgmeta"] + } + dojo.docs.getMeta(input, pkg, name, dojo.docs._onDocSelectResults); + dojo.docs.getDoc(input, pkg, name, dojo.docs._onDocSelectResults); + }, + _onDocSelectPackage: function(/*Object*/ input){ + dojo.debug("_onDocSelectPackage(" + input.name + ")") + input.expects = { + "pkgresults": ["pkgmeta", "pkgdoc"] + }; + if(!input.selectKey){ + input.selectKey = ++dojo.docs._count; + } + dojo.docs.getPkgMeta(input, input.name, dojo.docs._onPkgResults); + dojo.docs.getPkgDoc(input, input.name, dojo.docs._onPkgResults); + }, + _onDocSelectResults: function(/*String*/ type, /*Object*/ data, /*Object*/ evt, /*Object*/ input){ + dojo.debug("_onDocSelectResults(" + evt.type + ", " + evt.name + ")"); + if(evt.type == "meta"){ + dojo.docs.getPkgMeta(input, evt.pkg, dojo.docs._onDocSelectResults); + } + if(input){ + input[evt.type] = data; + if(input.expects && input.expects.docresults){ + for(var i = 0, expect; expect = input.expects.docresults[i]; i++){ + if(!(expect in input)){ + dojo.debug("_onDocSelectResults() waiting for more data"); + return; + } + } + } + } + + dojo.docs._printFunctionDetail(input); + }, + + _printFunctionDetail: function(results) { + // summary: Call this function to send the /docs/function/detail topic event + }, + + _buildCache: function(/*Object*/ input){ + dojo.debug("_buildCache(" + input.type + ", " + input.name + ")"); + // Get stuff from the input object + var type = input.type; + var pkg = input.pkg; + var callbacks = input.callbacks; + var id = input.id; + if(!id){ + id = input.id = "_"; + } + var name = input.name; + var selectKey = input.selectKey; + + var META = "meta"; + var METHODS = "methods"; + var SRC = "src"; + var DESCRIPTION = "description"; + var INPUT = "input"; + var LOAD = "load"; + var ERROR = "error"; + + var docs = dojo.docs; + var getCache = docs._getCache; + + // Stuff to pass to RPC + var search = []; + + if(type == "doc"){ + if(!pkg){ + docs.functionPackages(selectKey, name, function(){ var a = arguments; docs._withPkg.call(this, a[0], a[1], a[2], a[3], "doc"); }, input); + return; + }else{ + var cached = getCache(pkg, META, METHODS, name, id, META); + + if(cached[DESCRIPTION]){ + callbacks.shift()(LOAD, cached[DESCRIPTION], input, input[INPUT]); + return; + } + + var obj = {}; + obj.forFormName = "DocFnForm"; + obj.limit = 1; + + obj.filter = "it/DocFnForm/require = '" + pkg + "' and it/DocFnForm/name = '" + name + "' and "; + if(id == "_"){ + obj.filter += " not(it/DocFnForm/id)"; + }else{ + obj.filter += " it/DocFnForm/id = '" + id + "'"; + } + + obj.load = function(data){ + var cached = getCache(pkg, META, METHODS, name, id, META); + + var description = ""; + var returns = ""; + if(data.list && data.list.length){ + description = docs._getMainText(data.list[0]["main/text"]); + returns = data.list[0]["DocFnForm/returns"]; + } + + cached[DESCRIPTION] = description; + if(!cached.returns){ + cached.returns = {}; + } + cached.returns.summary = returns; + + input.type = "fn"; + docs._gotDoc(LOAD, cached, input, input[INPUT]); + } + obj.error = function(data){ + input.type = "fn"; + docs._gotDoc(ERROR, {}, input, input[INPUT]); + } + search.push(obj); + + obj = {}; + obj.forFormName = "DocParamForm"; + + obj.filter = "it/DocParamForm/fns = '" + pkg + "=>" + name; + if(id != "_"){ + obj.filter += "=>" + id; + } + obj.filter += "'"; + + obj.load = function(data){ + var cache = getCache(pkg, META, METHODS, name, id, META); + for(var i = 0, param; param = data.list[i]; i++){ + var pName = param["DocParamForm/name"]; + if(!cache.parameters[pName]){ + cache.parameters[pName] = {}; + } + cache.parameters[pName].summary = param["DocParamForm/desc"]; + } + input.type = "param"; + docs._gotDoc(LOAD, cache.parameters, input); + } + obj.error = function(data){ + input.type = "param"; + docs._gotDoc(ERROR, {}, input); + } + search.push(obj); + } + }else if(type == "pkgdoc"){ + var cached = getCache(name, META); + + if(cached[DESCRIPTION]){ + callbacks.shift()(LOAD, {description: cached[DESCRIPTION], path: cached.path}, input, input.input); + return; + } + + var obj = {}; + obj.forFormName = "DocPkgForm"; + obj.limit = 1; + obj.filter = "it/DocPkgForm/require = '" + name + "'"; + + obj.load = function(data){ + var description = ""; + var list = data.list; + if(list && list.length && list[0]["main/text"]){ + description = docs._getMainText(list[0]["main/text"]); + cached[DESCRIPTION] = description; + cached.path = list[0].name; + } + + if(callbacks && callbacks.length){ + callbacks.shift()(LOAD, {description: description, path: cached.path}, input, input.input); + } + } + obj.error = function(data){ + if(callbacks && callbacks.length){ + callbacks.shift()(ERROR, "", input, input.input); + } + } + search.push(obj); + }else if(type == "function_names"){ + var cached = getCache(); + if(!cached.function_names){ + dojo.debug("_buildCache() new cache"); + if(callbacks && callbacks.length){ + docs._callbacks.function_names.push([input, callbacks.shift()]); + } + cached.function_names = {loading: true}; + + var obj = {}; + obj.url = "function_names"; + obj.load = function(type, data, evt){ + cached.function_names = data; + while(docs._callbacks.function_names.length){ + var parts = docs._callbacks.function_names.pop(); + parts[1](LOAD, data, parts[0]); + } + } + obj.error = function(type, data, evt){ + while(docs._callbacks.function_names.length){ + var parts = docs._callbacks.function_names.pop(); + parts[1](LOAD, {}, parts[0]); + } + } + search.push(obj); + }else if(cached.function_names.loading){ + dojo.debug("_buildCache() loading cache, adding to callback list"); + if(callbacks && callbacks.length){ + docs._callbacks.function_names.push([input, callbacks.shift()]); + } + return; + }else{ + dojo.debug("_buildCache() loading from cache"); + if(callbacks && callbacks.length){ + callbacks.shift()(LOAD, cached.function_names, input); + } + return; + } + }else if(type == META || type == SRC){ + if(!pkg){ + if(type == META){ + docs.functionPackages(selectKey, name, function(){ var a = arguments; docs._withPkg.call(this, a[0], a[1], a[2], a[3], META); }, input); + return; + }else{ + docs.functionPackages(selectKey, name, function(){ var a = arguments; docs._withPkg.call(this, a[0], a[1], a[2], a[3], SRC); }, input); + return; + } + }else{ + var cached = getCache(pkg, META, METHODS, name, id); + + if(cached[type] && cached[type].returns){ + if(callbacks && callbacks.length){ + callbacks.shift()(LOAD, cached[type], input); + return; + } + } + + dojo.debug("Finding " + type + " for: " + pkg + ", function: " + name + ", id: " + id); + + var obj = {}; + + if(type == SRC){ + obj.mimetype = "text/plain" + } + obj.url = pkg + "/" + name + "/" + id + "/" + type; + obj.load = function(type, data, evt){ + dojo.debug("_buildCache() loaded " + input.type); + + if(input.type == SRC){ + getCache(pkg, META, METHODS, name, id).src = data; + if(callbacks && callbacks.length){ + callbacks.shift()(LOAD, data, input, input[INPUT]); + } + }else{ + var cache = getCache(pkg, META, METHODS, name, id, META); + if(!cache.parameters){ + cache.parameters = {}; + } + for(var i = 0, param; param = data.parameters[i]; i++){ + if(!cache.parameters[param[1]]){ + cache.parameters[param[1]] = {}; + } + cache.parameters[param[1]].type = param[0]; + } + if(!cache.returns){ + cache.returns = {}; + } + cache.returns.type = data.returns; + } + + if(callbacks && callbacks.length){ + callbacks.shift()(LOAD, cache, input, input[INPUT]); + } + } + obj.error = function(type, data, evt){ + if(callbacks && callbacks.length){ + callbacks.shift()(ERROR, {}, input, input[INPUT]); + } + } + } + + search.push(obj); + }else if(type == "pkgmeta"){ + var cached = getCache(name, "meta"); + + if(cached.requires){ + if(callbacks && callbacks.length){ + callbacks.shift()(LOAD, cached, input, input[INPUT]); + return; + } + } + + dojo.debug("Finding package meta for: " + name); + + var obj = {}; + + obj.url = name + "/meta"; + obj.load = function(type, data, evt){ + dojo.debug("_buildCache() loaded for: " + name); + + var methods = data.methods; + if(methods){ + for(var method in methods){ + if (method == "is") { + continue; + } + for(var pId in methods[method]){ + getCache(name, META, METHODS, method, pId, META).summary = methods[method][pId]; + } + } + } + + var requires = data.requires; + var cache = getCache(name, META); + if(requires){ + cache.requires = requires; + } + if(callbacks && callbacks.length){ + callbacks.shift()(LOAD, cache, input, input[INPUT]); + } + } + obj.error = function(type, data, evt){ + if(callbacks && callbacks.length){ + callbacks.shift()(ERROR, {}, input, input[INPUT]); + } + } + search.push(obj); + } + + for(var i = 0, obj; obj = search[i]; i++){ + var load = obj.load; + var error = obj.error; + delete obj.load; + delete obj.error; + var mimetype = obj.mimetype; + if(!mimetype){ + mimetype = "text/json" + } + if(obj.url){ + dojo.io.bind({ + url: new dojo.uri.Uri(docs._url, obj.url), + input: input, + mimetype: mimetype, + error: error, + load: load + }); + }else{ + docs._rpc.callRemote("search", obj).addCallbacks(load, error); + } + } + }, + selectFunction: function(/*String*/ name, /*String?*/ id){ + // summary: The combined information + }, + savePackage: function(/*Object*/ callbackObject, /*String*/ callback, /*Object*/ parameters){ + dojo.event.kwConnect({ + srcObj: dojo.docs, + srcFunc: "_savedPkgRpc", + targetObj: callbackObject, + targetFunc: callback, + once: true + }); + + var props = {}; + var cache = dojo.docs._getCache(parameters.pkg, "meta"); + + var i = 1; + + if(!cache.path){ + var path = "id"; + props[["pname", i].join("")] = "DocPkgForm/require"; + props[["pvalue", i++].join("")] = parameters.pkg; + }else{ + var path = cache.path; + } + + props.form = "//DocPkgForm"; + props.path = ["/WikiHome/DojoDotDoc/", path].join(""); + + if(parameters.description){ + props[["pname", i].join("")] = "main/text"; + props[["pvalue", i++].join("")] = parameters.description; + } + + dojo.docs._rpc.callRemote("saveForm", props).addCallbacks(dojo.docs._pkgRpc, dojo.docs._pkgRpc); + }, + _pkgRpc: function(data){ + if(data.name){ + dojo.docs._getCache(data["DocPkgForm/require"], "meta").path = data.name; + dojo.docs._savedPkgRpc("load"); + }else{ + dojo.docs._savedPkgRpc("error"); + } + }, + _savedPkgRpc: function(type){ + }, + functionPackages: function(/*mixed*/ selectKey, /*String*/ name, /*Function*/ callback, /*Object*/ input){ + // summary: Gets the package associated with a function and stores it in the .pkg value of input + dojo.debug("functionPackages() name: " + name); + + if(!input){ + input = {}; + } + if(!input.callbacks){ + input.callbacks = []; + } + + input.type = "function_names"; + input.name = name; + input.callbacks.unshift(callback); + input.callbacks.unshift(dojo.docs._functionPackages); + dojo.docs._buildCache(input); + }, + _functionPackages: function(/*String*/ type, /*Array*/ data, /*Object*/ evt){ + dojo.debug("_functionPackages() name: " + evt.name); + evt.pkg = ''; + + var results = []; + var data = dojo.docs._cache['function_names']; + for(var key in data){ + if(dojo.lang.inArray(data[key], evt.name)){ + dojo.debug("_functionPackages() package: " + key); + results.push(key); + } + } + + if(evt.callbacks && evt.callbacks.length){ + evt.callbacks.shift()(type, results, evt, evt.input); + } + }, + setUserName: function(/*String*/ name){ + dojo.docs._userName = name; + if(name && dojo.docs._password){ + dojo.docs._logIn(); + } + }, + setPassword: function(/*String*/ password){ + dojo.docs._password = password; + if(password && dojo.docs._userName){ + dojo.docs._logIn(); + } + }, + _logIn: function(){ + dojo.io.bind({ + url: dojo.docs._rpc.serviceUrl.toString(), + method: "post", + mimetype: "text/json", + content: { + username: dojo.docs._userName, + password: dojo.docs._password + }, + load: function(type, data){ + if(data.error){ + dojo.docs.logInSuccess(); + }else{ + dojo.docs.logInFailure(); + } + }, + error: function(){ + dojo.docs.logInFailure(); + } + }); + }, + logInSuccess: function(){}, + logInFailure: function(){}, + _set: function(/*Object*/ base, /*String...*/ keys, /*String*/ value){ + var args = []; + for(var i = 0, arg; arg = arguments[i]; i++){ + args.push(arg); + } + + if(args.length < 3) return; + base = args.shift(); + value = args.pop(); + var key = args.pop(); + for(var i = 0, arg; arg = args[i]; i++){ + if(typeof base[arg] != "object"){ + base[arg] = {}; + } + base = base[arg]; + } + base[key] = value; + }, + _getCache: function(/*String...*/ keys){ + var obj = dojo.docs._cache; + for(var i = 0; i < arguments.length; i++){ + var arg = arguments[i]; + if(!obj[arg]){ + obj[arg] = {}; + } + obj = obj[arg]; + } + return obj; + } +}); + +dojo.event.topic.subscribe("/docs/search", dojo.docs, "_onDocSearch"); +dojo.event.topic.subscribe("/docs/function/select", dojo.docs, "_onDocSelectFunction"); +dojo.event.topic.subscribe("/docs/package/select", dojo.docs, "_onDocSelectPackage"); + +dojo.event.topic.registerPublisher("/docs/function/results", dojo.docs, "_printFunctionResults"); +dojo.event.topic.registerPublisher("/docs/function/detail", dojo.docs, "_printFunctionDetail"); +dojo.event.topic.registerPublisher("/docs/package/detail", dojo.docs, "_printPkgResult"); \ No newline at end of file Index: openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/dom.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/Attic/dom.js,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/dom.js 6 Nov 2006 14:37:20 -0000 1.1 @@ -0,0 +1,522 @@ +/* + Copyright (c) 2004-2006, The Dojo Foundation + All Rights Reserved. + + Licensed under the Academic Free License version 2.1 or above OR the + modified BSD license. For more information on Dojo licensing, see: + + http://dojotoolkit.org/community/licensing.shtml +*/ + +dojo.provide("dojo.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.removeChildren = function(/* Element */node){ + // summary + // removes all children from node and returns the count of children removed. + var count = node.childNodes.length; + while(node.hasChildNodes()){ node.removeChild(node.firstChild); } + return count; // number +} + +dojo.dom.replaceChildren = function(/* Element */node, /* Node */newChild){ + // summary + // Removes all children of node and appends newChild + // FIXME: what if newChild is an array-like object? + dojo.dom.removeChildren(node); + node.appendChild(newChild); +} + +dojo.dom.removeNode = function(/* Node */node){ + // summary + // if node has a parent, removes node from parent and returns a reference to the removed child. + if(node && node.parentNode){ + // return a ref to the removed child + return node.parentNode.removeChild(node); // Node + } +} + +dojo.dom.getAncestors = function(/* Node */node, /* function? */filterFunction, /* boolean? */returnFirstHit) { + // summary + // returns all ancestors matching optional filterFunction; will return only the first if returnFirstHit + var ancestors = []; + var isFunction = (filterFunction && (filterFunction instanceof Function || typeof filterFunction == "function")); + while(node) { + if (!isFunction || filterFunction(node)) { + ancestors.push(node); + } + if (returnFirstHit && ancestors.length > 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 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 0){ + for(var i = 0;i < dojo.flash._loadedListeners.length; i++){ + dojo.flash._loadedListeners[i].call(null); + } + } + }, + + /** + A callback to know if Flash is currently being installed or + having its version revved. To be notified if Flash is installing, connect + your callback to this method using the following: + + dojo.event.connect(dojo.flash, "installing", myInstance, "myCallback"); + */ + installing: function(){ + //dojo.debug("installing"); + if(dojo.flash._installingListeners.length > 0){ + for(var i = 0; i < dojo.flash._installingListeners.length; i++){ + dojo.flash._installingListeners[i].call(null); + } + } + }, + + /** Initializes dojo.flash. */ + _initialize: function(){ + //dojo.debug("dojo.flash._initialize"); + // see if we need to rev or install Flash on this platform + var installer = new dojo.flash.Install(); + dojo.flash.installer = installer; + + if(installer.needed() == true){ + installer.install(); + }else{ + //dojo.debug("Writing object out"); + // write the flash object into the page + dojo.flash.obj = new dojo.flash.Embed(this._visible); + dojo.flash.obj.write(dojo.flash.info.commVersion); + + // initialize the way we do Flash/JavaScript communication + dojo.flash.comm = new dojo.flash.Communicator(); + } + } +}; + + +/** + A class that helps us determine whether Flash is available, + it's major and minor versions, and what Flash version features should + be used for Flash/JavaScript communication. Parts of this code + are adapted from the automatic Flash plugin detection code autogenerated + by the Macromedia Flash 8 authoring environment. + + An instance of this class can be accessed on dojo.flash.info after + the page is finished loading. + + This constructor must be called before the page is finished loading. +*/ +dojo.flash.Info = function(){ + // Visual basic helper required to detect Flash Player ActiveX control + // version information on Internet Explorer + if(dojo.render.html.ie){ + document.writeln(''); + + // hook for Internet Explorer to receive FSCommands from Flash + if(dojo.render.html.ie){ + document.writeln('