Index: openacs-4/packages/ajaxhelper/ajaxhelper.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/ajaxhelper.info,v diff -u -N -r1.7 -r1.8 --- openacs-4/packages/ajaxhelper/ajaxhelper.info 6 Nov 2006 13:15:28 -0000 1.7 +++ openacs-4/packages/ajaxhelper/ajaxhelper.info 25 Dec 2006 16:39:49 -0000 1.8 @@ -8,13 +8,13 @@ t ajax - + Hamilton Chua - Provides helper procs to generate javascript used for Ajax and generating cinematic effects. Includes Scriptaculous (1.6.4) Javascript Libraries and the Yahoo UI Libraries (0.11.4). As of 0.7d, all javascript libraries have been moved to ajaxhelper/www/resources to take advantage of caching. As of 0.8d, the wrappers will now be able to check a global variable to see if the required sources are loaded. + Provides helper procs to generate javascript used for Ajax and generating cinematic effects. Includes Scriptaculous (1.6.5) Javascript Libraries, dojo Toolkit (0.4.1) and the Yahoo UI Libraries (0.12.1). As of 0.7d, all javascript libraries have been moved to ajaxhelper/www/resources to take advantage of caching. As of 0.8d, the wrappers will now be able to check a global variable to see if the required sources are loaded, this allows helper procs to automatically load the javascript sources you need. Solution Grove 0 - + Index: openacs-4/packages/ajaxhelper/tcl/ajax-dojo-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/tcl/ajax-dojo-procs.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/ajaxhelper/tcl/ajax-dojo-procs.tcl 6 Nov 2006 13:15:29 -0000 1.1 +++ openacs-4/packages/ajaxhelper/tcl/ajax-dojo-procs.tcl 25 Dec 2006 16:39:50 -0000 1.2 @@ -16,12 +16,12 @@ This source_list will be the global ajax_helper_dojo_js_sources variable. This script is called in the blank-master template. - @author Hamilton Chua (ham@solutiongrove.com) + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-11-05 } { set ah_base_url [ah::get_url] - set script "" + set script "\n" set dojo_script "" foreach source $source_list { @@ -44,8 +44,10 @@ "lfx" { append dojo_script "dojo.require(\"dojo.lfx.*\"); " } + "collections" { + append dojo_script "dojo.require(\"dojo.collections.Store\"); " + } "chart" { - append dojo_script "dojo.require(\"dojo.collections.Store\"); " append dojo_script "dojo.require(\"dojo.charting.Chart\"); " } "widget-chart" { @@ -59,21 +61,50 @@ return "" } +ad_proc -private ah::dojo::requires { + -sources +} { + This proc should be called by an ajaxhelper proc that uses dojo with a comma separated list of dojo javascript sources + that the ajaxhelper proc needs in order to work. + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-12-19 + @param sources Comma separated list of sources +} { + #split up the comma delimited sources into a list + set source_list [split $sources ","] + #declare the global variable + global ajax_helper_dojo_js_sources + foreach source $source_list { + # do some checks before we add the source to the global + # - is it already loaded + # - is it a valid source name + # - is the source utilities or yahoo,dom,event + if { ![ah::dojo::is_js_sources_loaded -js_source $source] && [ah::dojo::is_valid_source -js_source $source] } { + # TODO : figure out other dependencies and possible overlaps and try to work them out here + lappend ajax_helper_dojo_js_sources $source + } else { + # TODO : we must return an error/exception, for now just add a notice in the log + ns_log Notice "AJAXHELPER dojo: $source is already loaded or not valid" + } + } +} + ad_proc -private ah::dojo::is_js_sources_loaded { -js_source } { This proc will loops thru source_list and check for the presence of js_source. - If found, this proc will return 1 + If found, this proc will return 1 If not found, this proc will return 0 - @author Hamilton Chua (ham@solutiongrove.com) + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-11-05 } { global ajax_helper_dojo_js_sources set state 0 if { [info exists ajax_helper_dojo_js_sources] } { foreach source $ajax_helper_dojo_js_sources { - if { [string match $source $js_source] } { + if { [string match $source $js_source] } { set state 1 break } @@ -87,7 +118,7 @@ } { Generates the javascript that loads the dojo javascript sources. - @author Hamilton Chua (ham@solutiongrove.com) + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-11-05 } { @@ -129,9 +160,13 @@ append dojo_script "dojo.require(\"dojo.lfx.*\"); " } } + "collections" { + if { ![ah::dojo::is_js_sources_loaded -js_source "collections"] } { + append dojo_script "dojo.require(\"dojo.collections.Store\"); " + } + } "chart" { if { ![ah::dojo::is_js_sources_loaded -js_source "chart"] } { - append dojo_script "dojo.require(\"dojo.collections.Store\"); " append dojo_script "dojo.require(\"dojo.charting.Chart\"); " } } @@ -151,37 +186,88 @@ -argslist:required } { Builds a javascript object that holds the arguments that are commonly passed to a dojo function. - - @author Hamilton Chua (ham@solutiongrove.com) + + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-11-05 -} { +} { set objargs [list] foreach args $argslist { - lappend objargs [split ":" $args] + lappend objargs [join $args ":"] } - set objargs [split "," $objargs] + set objargs [join $objargs ","] set script "var $varname = {$objargs}; " return $script } ad_proc -public ah::dojo::iobind { -objargs:required } { - Generates the javascript that loads the dojo javascript sources. + Generates the javascript for a dojo io bind. + Does the same thing as ah::ajaxrequest or ah::ajaxupdate + but is more robust as dojo.io.bind is capable of using + different transport layers. In fact, it's smart enough to determine + which transport layer to use given a certain situation without bothering + the developer. More details in the dojo book. + http://manual.dojotoolkit.org/WikiHome/DojoDotBook/Book8 - @author Hamilton Chua (ham@solutiongrove.com) + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-11-05 @param objargs A javascript object generated by ah::dojo::args which contain arguments that is passed to dojo.io.bind. } { - if { ![ah::dojo::is_js_sources_loaded -js_source "dojo"] } { - global ajax_helper_dojo_js_sources - lappend ajax_helper_dojo_js_sources "dojo" - if { ![ah::dojo::is_js_sources_loaded -js_source "io"] } { - lappend ajax_helper_dojo_js_sources "io" - } - } + ah::dojo::requires -sources "dojo,io" set script "dojo.io.bind($objargs); " return $script -} \ No newline at end of file +} + +ad_proc -public ah::dojo::util_list_to_json { + -lists_of_pairs +} { + Converts a properly structured list of lists into JSON format. + The list of lists may look something like + + set data [list] + lappend data [list [list "x" "1"] [list "y" "10"] ] + lappend data [list [list "x" "5"] [list "y" "20"] ] + + each line represents a row composed of lists. + Each list in the row holds a pair that will be joined by ":". +} { + set rows [list] + foreach row $lists_of_pairs { + set pairs [list] + foreach pair $row { + lappend pairs [join $pair ":"] + } + lappend rows [join $pairs ","] + } + return "\{[join $rows "\},\{"]\}" +} + +ad_proc -public ah::dojo::collections_store { + -varname:required + -lists_of_pairs:required +} { + Creates a dojo collection store +} { + ah::dojo::requires -sources "dojo,collections" + set json [ah::dojo::util_list_to_json -lists_of_pairs $lists_of_pairs] + set script "var ${varname}_data = \[$json\]; \n" + append script "var ${varname} = new dojo.collections.Store(); ${varname}.setData(${varname}_data); \n" + return $script +} + +ad_proc -public ah::dojo::chart { + -varname:required + -node:required + -datalist + -serieslist + -axislist + -plotlist + -onload:boolean +} { + Creates a chart using the dojo charting engine +} { + ah::dojo::requires -sources "dojo,chart" +} Index: openacs-4/packages/ajaxhelper/tcl/ajax-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/tcl/ajax-procs.tcl,v diff -u -N -r1.6 -r1.7 --- openacs-4/packages/ajaxhelper/tcl/ajax-procs.tcl 6 Nov 2006 13:15:29 -0000 1.6 +++ openacs-4/packages/ajaxhelper/tcl/ajax-procs.tcl 25 Dec 2006 16:39:50 -0000 1.7 @@ -13,57 +13,114 @@ ad_proc -private ah::load_js_sources { -source_list } { - Accepts a tcl list of sources to load. - This source_list will be the global ajax_helper_js_sources variable. - This script is called in the blank-master template. + Accepts a tcl list of sources to load. + This source_list will be the global ajax_helper_js_sources variable. + This script is called in the blank-master template and + should preferrably NOT BE USED to load your + javascript sources. Use ah::js_sources instead. + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-11-05 + @param source_list The list of javascript source names to load } { set ah_base_url [ah::get_url] set script "" + set minsuffix "" + if { [parameter::get_from_package_key -package_key "ajaxhelper" -parameter "UseMinifiedJs"] == 1 } { + set minsuffix "-min" + } + + # TODO : 12/19/06 + # Prior to just loading, we also have to think about dependencies + # we might need to sort the source_list first and check for dependencies. + # For example, we need to load prototype first before scriptaculous. + foreach source $source_list { - switch $source { - "rico" { - append script " \n" - } - "rounder" { - append script " \n" - } - "overlibmws" { - append script " \n" - append script "\n" - } - "overlibmws_bubble" { - append script "\n" - append script "\n" - } - "overlibmws_scroll" { - append script "\n" - } - "overlibmws_drag" { - append script "\n" - } - "prototype" { - append script " \n" - } - "scriptaculous" { - append script " \n" - } - } + switch $source { + "rounder" { + append script " \n" + } + "overlibmws" { + append script " \n" + } + "overlibmws_bubble" { + append script "\n" + append script "\n" + } + "overlibmws_scroll" { + append script "\n" + } + "overlibmws_drag" { + append script "\n" + } + "prototype" { + append script " \n" + } + "scriptaculous" { + append script " \n" + } + "scriptaculous-effects" { + append script " \n" + } + "scriptaculous-dragdrop" { + append script " \n" + } + "autosuggest" { + append script "\n" + append script " \n" + } + } } return $script } +ad_proc -private ah::is_valid_source { + -js_source +} { + This proc will determine if the js_source file is the name is a valid name associated to + a javascript source. This proc contains hard coded list of javascript sources that + ajaxhelper supports. + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-12-19 + @param js_source The name of the javascript source to check +} { + + set valid_sources [list "prototype" \ + "scriptaculous" \ + "scriptaculous-effects" \ + "scriptaculous-dragdrop" \ + "autosuggest" \ + "rounder" \ + "overlibmws" \ + "overlibmws_bubble" \ + "overlibmws_scroll" \ + "overlibmws_drag" ] + set found [lsearch -exact $valid_sources $js_source] + if { $found == -1 } { + return 0 + } else { + return 1 + } +} + ad_proc -private ah::is_js_sources_loaded { -js_source } { - This proc will loop thru source_list and check for the presence of js_source. - If found, this proc will return 1 + This proc will loop thru source_list global variable and + check for the presence of the specified js_source. + If found, this proc will return 1 If not found, this proc will return 0 + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-11-05 + @param js_source The name of the javascript source to check } { global ajax_helper_js_sources set state 0 if { [info exists ajax_helper_js_sources] } { foreach source $ajax_helper_js_sources { - if { [string match $source $js_source] } { + if { [string match $source $js_source] } { set state 1 break } @@ -72,39 +129,119 @@ return $state } +ad_proc -private ah::requires { + -sources +} { + This proc should be called by an ajaxhelper proc with a comma separated list of javascript sources + that the ajaxhelper proc needs in order to work. + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-12-19 + @param sources Comma separated list of sources +} { + #split up the comma delimited sources into a list + set source_list [split $sources ","] + #declare the global variable + global ajax_helper_js_sources + foreach source $source_list { + # do some checks before we add the source to the global + # - is it already loaded + # - is it a valid source name + # - is the source scriptaculous, scriptaculous-effects or scriptaculous-dragdrop + if { ![ah::is_js_sources_loaded -js_source $source] && [ah::is_valid_source -js_source $source] } { + if { $source == "scriptaculous" || $source == "scriptaculous-effects" || $source == "scriptaculous-dragdrop" } { + # source is scriptaculous + # load only if scriptaculous-effects and scriptaculous-dragdrop are not loaded yet + if { $source == "scriptaculous" } { + if { ![ah::is_js_sources_loaded -js_source "scriptaculous-effects"] || ![ah::is_js_sources_loaded -js_source "scriptaculous-dragdrop"]} { + lappend ajax_helper_js_sources $source + } + } + # source is scriptaculous-effects + # load only if scriptaculous and scriptaculous-dragdrop are not loaded yet + if { $source == "scriptaculous-effects" } { + if { ![ah::is_js_sources_loaded -js_source "scriptaculous"] || ![ah::is_js_sources_loaded -js_source "scriptaculous-dragdrop"]} { + lappend ajax_helper_js_sources $source + } + } + # source is scriptaculous-dragdrop + # load only if scriptaculous and scriptaculous-effects are not loaded yet + if { $source == "scriptaculous-dragdrop" } { + if { ![ah::is_js_sources_loaded -js_source "scriptaculous"] || ![ah::is_js_sources_loaded -js_source "scriptaculous-effects"]} { + lappend ajax_helper_js_sources $source + } + } + } else { + lappend ajax_helper_js_sources $source + } + } else { + # TODO : we must return an error/exception, for now just add a notice in the log + ns_log Notice "AJAXHELPER : $source is already loaded or not valid" + } + } +} + ad_proc -public ah::js_sources { {-source "default"} } { Will load any of the following javascript sources prototype, scriptaculous, rounder, - overlibmws popups. - This will also check global variables. + overlibmws. + This will also check global variables. If the sources have already been defined, we will not define them again. Once the js_source has been loaded, the global variable with list of sources will be updated. - Calling this function is not necessary anymore as long as the required code to dynamically call - javascript functions is in the blank-master template. + Calling this function is not necessary anymore as long as the required code to dynamically call + javascript functions is in the blank-master template, unless of course you want to write your own javascript. - @author Hamilton Chua (ham@solutiongrove.com) + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-01-16 @param source The caller can specify which set of javascript source files to load. This can be a comma seprated list - Valid values include + Valid values include "default" : to load prototype and scriptaculous libraries - "rounder" : to load the rico corner rounder functions only, use this if you are working primarily with scriptaculous, + "rounder" : to load the rico corner rounder functions only, use this if you are working primarily with scriptaculous, "overlibmws" : to load the overlibmws javascript files for dhtml callouts and popups. "overlibmws_bubble" : to load the overlibmws javascript files for dhtml callouts and popups. "overlibmws_scroll" : to load the overlibmws javascript files for dhtml bubble callouts and popups that scroll. "overlibmws_drag" : to load the overlibmws javascript files for draggable dhtml callouts and popups. + "prototype" : to load ONLY the prototype javascript source. + "scriptaculous" : to load all scriptaculous javascript sources. + "scriptaculous-effects" : to load only the scriptaculous javascript sources needed for effects. + "scriptaculous-dragdrop" : to load only the scriptaculous javascript sources needed for drag and drop. @return - @error + @error } { set ah_base_url [ah::get_url] + set script "" + + set minsuffix "" + if { [parameter::get_from_package_key -package_key "ajaxhelper" -parameter "UseMinifiedJs"] == 1 } { + set minsuffix "-min" + } + + # js_sources was called with no parameters, just load the defaults + if { $source == "default" } { + if { ![ah::is_js_sources_loaded -js_source "prototype"] } { + # load prototype + append script " \n" + # make sure helper procs don't load it again + lappend ajax_helper_js_sources "prototype" + } + if { ![ah::is_js_sources_loaded -js_source "scriptaculous"] && ![ah::is_js_sources_loaded -js_source "scriptaculous-effects"] && ![ah::is_js_sources_loaded -js_source "scriptaculous-dragdrop"]} { + # load scriptaculous + append script " \n" + # make sure it doesn't get loaded again + lappend ajax_helper_js_sources "scriptaculous" + lappend ajax_helper_js_sources "scriptaculous-dragdrop" + lappend ajax_helper_js_sources "scriptaculous-effects" + } + } + set js_file_list [split $source ","] - set script "" foreach x $js_file_list { switch $x { @@ -135,14 +272,32 @@ append script "\n" } } - default { - if { ![ah::is_js_sources_loaded -js_source "prototype"] } { - append script " \n" - } - if { ![ah::is_js_sources_loaded -js_source "scriptaculous"] } { - append script " \n" - } - } + "prototype" { + if { ![ah::is_js_sources_loaded -js_source "prototype"] } { + append script " \n" + } + } + "autosuggest" { + if { ![ah::is_js_sources_loaded -js_source "autosuggest"] } { + append script "\n" + append script " \n" + } + } + "scriptaculous" { + if { ![ah::is_js_sources_loaded -js_source "scriptaculous"] } { + append script " \n" + } + } + "scriptaculous-effects" { + if { ![ah::is_js_sources_loaded -js_source "scriptaculous-effects"] } { + append script " \n" + } + } + "scriptaculous-dragdrop" { + if { ![ah::is_js_sources_loaded -js_source "scriptaculous-dragdrop"] } { + append script " \n" + } + } } } @@ -156,11 +311,11 @@ } { Return the package_id of the installed and mounted ajax helper instance - @author Hamilton Chua (ham@solutiongrove.com) + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-01-16 - @return + @return - @error + @error } { return [apm_package_id_from_key "ajaxhelper"] @@ -171,11 +326,11 @@ } { Return the path to the ajaxhelper resource files - @author Hamilton Chua (ham@solutiongrove.com) + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-01-16 - @return + @return - @error + @error } { return "/resources/ajaxhelper/" @@ -185,12 +340,12 @@ element } { Receives a string and surrounds it with single quotes. - This is a utility proc used to make a parameter passed to a proc a string. + This is a utility proc used to turn a parameter passed to a proc into a string. The assumption is that an element passed as a parameter is a javascript variable. - @author Hamilton Chua (ham@solutiongrove.com) + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-01-16 - @return + @return } { return "'$element'" } @@ -199,7 +354,7 @@ -script:required } { Encloses whatever is passed to the script parameter in javascript tags. - @author Hamilton Chua (ham@solutiongrove.com) + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-01-16 @param script string to enclose in javascript tags. @@ -211,20 +366,20 @@ } ad_proc -public ah::create_js_function { - -name:required -body:required + {-name ""} {-parameters {} } } { Helper procedure to generate a javascript function - @author Hamilton Chua (ham@solutiongrove.com) + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-11-05 @param name The name of the javascript function @param body The body of the javascript function - @param parameters The parameters of the javascript function + @param parameters The comma separated list of parameters of the javascript function } { set script "function ${name} (" - append script [split "," $parameters] + if { [exists_and_not_null parameters] } { append script [join $parameters ","] } append script ") \{ " append script $body append script " \} " @@ -237,20 +392,20 @@ {-position "After"} } { Inserts text or html in a position given the element as reference. - @author Hamilton Chua (ham@solutiongrove.com) + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-11-05 @param element The element that will be used as reference @param text What you want to insert. @param position Where you want to insert text. This is case sensitive. Possible values include After, Bottom, Before and Top. Defaults to After. } { - if { ![ah::is_js_sources_loaded -js_source "prototype"] } { + if { ![ah::is_js_sources_loaded -js_source "prototype"] } { global ajax_helper_js_sources - lappend ajax_helper_js_sources "prototype" + lappend ajax_helper_js_sources "prototype" } set script "new Insertion.${position}('${element}','${text}'); " - return $script + return $script } # ************ Listeners ************** @@ -262,23 +417,20 @@ {-element_is_var:boolean} {-useCapture "false"} } { - Use prototype's Event object to watch/listen to a specific event from a specific html element. + Use prototype's Event object to watch/listen for a specific event from a specific html element. Valid events include click, load, mouseover etc. See ah::yui::addlistener for Yahoo's implementation which some say is superior. - @author Hamilton Chua (ham@solutiongrove.com) + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-02-28 @param element the element you want to observe @param event the event that the observer will wait for @param obs_function the funcion that will be executed when the event is detected - -} { - if { ![ah::is_js_sources_loaded -js_source "prototype"] } { - global ajax_helper_js_sources - lappend ajax_helper_js_sources "prototype" - } - if { !$element_is_var_p } { +} { + ah::requires -sources "prototype" + + if { !$element_is_var_p } { set element [ah::isnot_js_var $element] } set script "Event.observe(${element}, '${event}', ${obs_function}, $useCapture);" @@ -294,20 +446,17 @@ } { Use prototype's Event object to watch/listen to a specific event from a specific html element. Valid events include click, load, mouseover etc. - @author Hamilton Chua (ham@solutiongrove.com) + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-02-28 @param element the element you want to observe @param event the event that the observer will wait for @param obs_function the funcion that will be executed when the event is detected - + } { - if { ![ah::is_js_sources_loaded -js_source "prototype"] } { - global ajax_helper_js_sources - lappend ajax_helper_js_sources "prototype" - } + ah::requires -sources "prototype" - if { !$element_is_var_p } { + if { !$element_is_var_p } { set element [ah::isnot_js_var $element] } set script "Event.stopObserving(${element}, '${event}', ${obs_function}, $useCapture);" @@ -327,23 +476,27 @@ } { Returns javascript that calls the prototype javascript library's ajax periodic updater object. This object makes "polling" possible. Polling is a way by which a website can regularly update itself. - The ajax script is executed periodically in a set interval. + The ajax script is executed periodically in a set interval. It has the same properties as ajax update, the only difference is that it is executed after x number of seconds. Parameters and options are case sensitive, refer to scriptaculous documentation http://wiki.script.aculo.us/scriptaculous/show/Ajax.PeriodicalUpdater + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-11-05 + + @param url the url that the ajax will call + @param container the html object that will get updated periodically + @param frequency how often is the script called, default is 5 seconds } { - if { ![ah::is_js_sources_loaded -js_source "prototype"] } { - global ajax_helper_js_sources - lappend ajax_helper_js_sources "prototype" - } + ah::requires -sources "prototype" set preoptions "asynchronous:${asynchronous},frequency:${frequency},method:'post'" - if { [exists_and_not_null pars] } { + if { [exists_and_not_null pars] } { append preoptions ",parameters:$pars" } - if { [exists_and_not_null options] } { append preoptions ",$options" } + if { [exists_and_not_null options] } { append preoptions ",$options" } set script "new Ajax.PeriodicalUpdater('$container','$url',{$preoptions}); " return $script @@ -357,30 +510,28 @@ {-options ""} } { Returns javascript that calls the prototype javascript library's ajax request (Ajax.Request) object. - The Ajax.Request object will only perform an xmlhttp request to a url. + The Ajax.Request object will only perform an xmlhttp request to a url. If you prefer to perform an xmlhttp request and then update the contents of a < div >, look at ah::ajaxupdate. Parameters and options are case sensitive, refer to scriptaculous documentation. http://wiki.script.aculo.us/scriptaculous/show/Ajax.Request - - @author Hamilton Chua (ham@solutiongrove.com) + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-01-16 @param url the url that the javascript will call/query @param pars the parameters that will be passed to Ajax.Request. these parameters should normally be enclosed in single quotes ('') unless you intend to provide a javascript variable or function as a parameter @param options the options that will be passed to the Ajax.Request javascript function - @param asynchronous the default is true + @param asynchronous the default is true } { - global ajax_helper_js_sources - lappend ajax_helper_js_sources "prototype" + ah::requires -sources "prototype" set preoptions "asynchronous:${asynchronous},method:'post'" - if { [exists_and_not_null pars] } { + if { [exists_and_not_null pars] } { append preoptions ",parameters:$pars" } - if { [exists_and_not_null options] } { append preoptions ",$options" } + if { [exists_and_not_null options] } { append preoptions ",$options" } set script "new Ajax.Request('$url',{$preoptions}); " return $script @@ -397,9 +548,9 @@ {-enclose:boolean} {-container_is_var:boolean} } { - Generate an Ajax.Updater javascript object. + Generate an Ajax.Updater javascript object. The parameters are passed directly to the Ajax.Update script. - You can optionally specify an effect to use as the container is updated. + You can optionally specify an effect to use as the container is updated. By default it will use the "Appear" effect. Parameters and options are case sensitive, refer to scriptaculous documentation. http://wiki.script.aculo.us/scriptaculous/show/Ajax.Updater @@ -411,8 +562,8 @@ -enclose \ -effectopts "duration: 1.5"] - - @author Hamilton Chua (ham@solutiongrove.com) + + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-01-16 @param container the 'id' of the layer (div) you want to update via ajax @@ -422,22 +573,20 @@ @param effectopts options for the effect @param enclose optionally specify whether you want your script to be enclosed in < script > tags - @return + @return - @error + @error } { - global ajax_helper_js_sources - lappend ajax_helper_js_sources "prototype" - lappend ajax_helper_js_sources "scriptaculous" + ah::requires -sources "prototype,scriptaculous-effects" if { !$container_is_var_p } { set container [ah::isnot_js_var $container] } set preoptions "asynchronous:$asynchronous,method:'post'" - if { [exists_and_not_null pars] } { + if { [exists_and_not_null pars] } { append preoptions ",parameters:$pars" } if { [exists_and_not_null options] } { append preoptions ",$options" } @@ -448,7 +597,7 @@ } set script "new Ajax.Updater ($container,'$url',\{$preoptions\}); " - + if { $enclose_p } { set script [ah::enclose_in_script -script ${script} ] } return $script @@ -463,28 +612,27 @@ This proc will generate javascript for an overlibmws popup. This script has to go into a javscript event like onClick or onMouseover. The ah::source must be executed with -source "overlibmws" - For more information about the options that you can pass + For more information about the options that you can pass http://www.macridesweb.com/oltest/ See ah::yui::tooltip for Yahoo's implementation - @author Hamilton Chua (ham@solutiongrove.com) + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-02-12 @param content this is what the popup will contain or display. if content is text, enclose it in single quotes (' '). @param options the options to pass to overlibmws - @return + @return - @error + @error } { - global ajax_helper_js_sources - lappend ajax_helper_js_sources "overlibmws" + ah::requires -sources "overlibmws" if { [exists_and_not_null options] } { set overlibopt "," - append overlibopt $options + append overlibopt $options } else { set overlibopt "" } @@ -499,17 +647,16 @@ This script has to go into a javscript event like onClick or onMouseover. The ah::source must be executed with -source "overlibmws" - @author Hamilton Chua (ham@solutiongrove.com) + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-02-12 - @return + @return - @error + @error } { - global ajax_helper_js_sources - lappend ajax_helper_js_sources "overlibmws" + ah::requires -sources "overlibmws" set script "nd();" return $script @@ -521,25 +668,23 @@ {-textsize "x-small"} } { - This proc will generate mouseover and mouseout javascript - for dhtml callout or popup using overlibmws + This proc will generate mouseover and mouseout javascript + for dhtml callout or popup using overlibmws and the overlibmws bubble plugin. - @author Hamilton Chua (ham@solutiongrove.com) + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-01-16 @param type this is passed to the overlibmws script, refer to overlib documentation for possible values. @param text the text that will appear in the popup. @param textsize the size of the text in the popup - @return - @error + @return + @error } { - global ajax_helper_js_sources - lappend ajax_helper_js_sources "overlibmws" - lappend ajax_helper_js_sources "overlibmws_bubble" + ah::requires -sources "overlibmws,overlibmws_bubble" set script "onmouseover=\"" append script [ah::popup -content "'$text'" -options "BUBBLE,BUBBLETYPE,'$type',TEXTSIZE,'$textsize'"] @@ -554,31 +699,29 @@ {-pars ""} {-options ""} {-type "square"} - {-textsize "x-small"} + {-textsize "x-small"} } { This proc executes an xmlhttp call and outputs the response text in a bubblecallout. - @author Hamilton Chua (ham@solutiongrove.com) + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-01-16 - + @param url the url to make the xmlhttp call to @param pars the parameters in querystring format you want to pass to the url @param options the options you want to pass to overlibmws @param type parameter specific to the bubble callout @param textsize the size of the text in the callout - @return + @return - @error + @error } { - global ajax_helper_js_sources - lappend ajax_helper_js_sources "overlibmws" - lappend ajax_helper_js_sources "overlibmws_bubble" + ah::requires -sources "overlibmws,overlibmws_bubble" set popup [ah::popup -content "t.responseText" -options "BUBBLE,BUBBLETYPE,'$type',TEXTSIZE,'$textsize'"] set request [ah::ajaxrequest -url $url -pars '$pars' -options "onSuccess: function(t) { $popup }" ] - set script "onmouseover=\"$request\" onmouseout=\"nd();\"" + set script "onmouseover=\"$request\" onmouseout=\"nd();\"" return $script } @@ -590,34 +733,28 @@ {-options ""} {-element_is_var:boolean} } { - Generates javascript for effects by scriptaculous. + Generates javascript for effects by scriptaculous. Refer to the scriptaculous documentaiton for a list of effects. This proc by default will use the "Appear" effect - The parameters are passed directly to the scriptaculous effects script. + The parameters are passed directly to the scriptaculous effects script. Parameters and options are case sensitive, refer to scriptaculous documentation. http://wiki.script.aculo.us/scriptaculous/show/CoreEffects - @author Hamilton Chua (ham@solutiongrove.com) + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-01-16 @param element the page element that you want to apply the effect to @param effect specify one of the scriptaculous effects you want to implement @param options specify the options to pass to the scritpaculous javascript @param element_is_var specify this if the element you are passing is a javascript variable - @return - @error + @return + @error } { - if { ![ah::is_js_sources_loaded -js_source "prototype"] } { - global ajax_helper_js_sources - lappend ajax_helper_js_sources "prototype" - if { ![ah::is_js_sources_loaded -js_source "scriptaculous"] } { - lappend ajax_helper_js_sources "scriptaculous" - } - } + ah::requires -sources "prototype,scriptaculous-effects" - if { !$element_is_var_p } { + if { !$element_is_var_p } { set element [ah::isnot_js_var $element] } set script "new Effect.$effect\($element,\{$options\}\); " @@ -631,31 +768,25 @@ {-element_is_var:boolean} } { Generates javascript that toggles the state of an element. - The parameters are passed directly to the scriptaculous toggle script. + The parameters are passed directly to the scriptaculous toggle script. Parameters and options are case sensitive, refer to scriptaculous documentation. http://wiki.script.aculo.us/scriptaculous/show/Effect.toggle - @author Hamilton Chua (ham@solutiongrove.com) + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-02-23 @param element the page element that you want to apply the effect to @param effect specify one of the scriptaculous effects you want to toggle @param options specify the options to pass to the scritpaculous javascript @param element_is_var specify this if the element you are passing is a javascript variable - - @return - @error + @return + @error + } { - if { ![ah::is_js_sources_loaded -js_source "prototype"] } { - global ajax_helper_js_sources - lappend ajax_helper_js_sources "prototype" - if { ![ah::is_js_sources_loaded -js_source "scriptaculous"] } { - lappend ajax_helper_js_sources "scriptaculous" - } - } + ah::requires -sources "prototype,scriptaculous-effects" - if { !$element_is_var_p } { + if { !$element_is_var_p } { set element [ah::isnot_js_var $element] } set script "Effect.toggle\($element,'$effect',{$options}\)" @@ -671,32 +802,26 @@ {-element_is_var:boolean} } { Generates javascript to make the given element a draggable. - The parameters are passed directly to the scriptaculous script. + The parameters are passed directly to the scriptaculous script. Parameters and options are case sensitive, refer to scriptaculous documentation. http://wiki.script.aculo.us/scriptaculous/show/Draggables - @author Hamilton Chua (ham@solutiongrove.com) + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-01-24 @param element the page element that you want to make draggable @param options specify the scriptaculous options @param uid provide a unique id that is used as a variable to associate with the draggable @param element_is_var specify this parameter if the element you are passing is a javscript variable - @return + @return - @error + @error } { - if { ![ah::is_js_sources_loaded -js_source "prototype"] } { - global ajax_helper_js_sources - lappend ajax_helper_js_sources "prototype" - if { ![ah::is_js_sources_loaded -js_source "scriptaculous"] } { - lappend ajax_helper_js_sources "scriptaculous" - } - } + ah::requires -sources "prototype,scriptaculous-dragdrop" - if { !$element_is_var_p } { + if { !$element_is_var_p } { set element [ah::isnot_js_var $element] } set script "new Draggable \($element,\{$options\}\);" @@ -711,32 +836,26 @@ } { Generates javascript to make the given element a droppable. If a uid parameter is provided, the script will also check if the droppable with the same uid has already been created. - The parameters are passed directly to the scriptaculous script. + The parameters are passed directly to the scriptaculous script. Parameters and options are case sensitive, refer to scriptaculous documentation. http://wiki.script.aculo.us/scriptaculous/show/Droppables - @author Hamilton Chua (ham@solutiongrove.com) + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-02-24 @param element the page element that you want to be a droppable @param element_is_var specify this parameter if the element you are passing is a javscript variable @param uid provide a unique id that is used as a variable to associate with the droppable @param options specify the scriptaculous options for droppables - @return + @return - @error + @error -} { - if { ![ah::is_js_sources_loaded -js_source "prototype"] } { - global ajax_helper_js_sources - lappend ajax_helper_js_sources "prototype" - if { ![ah::is_js_sources_loaded -js_source "scriptaculous"] } { - lappend ajax_helper_js_sources "scriptaculous" - } - } +} { + ah::requires -sources "prototype,scriptaculous-dragdrop" - if { !$element_is_var_p } { + if { !$element_is_var_p } { set element [ah::isnot_js_var $element] } @@ -750,29 +869,24 @@ {-element_is_var:boolean} } { Generates javascript to remove a droppable. - The parameters are passed directly to the scriptaculous script. + The parameters are passed directly to the scriptaculous script. Parameters and options are case sensitive, refer to scriptaculous documentation. http://wiki.script.aculo.us/scriptaculous/show/Droppables - @author Hamilton Chua (ham@solutiongrove.com) + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-02-24 @param element the page element that you want to be a droppable @param element_is_var specify this parameter if the element you are passing is a javscript variable - @return - @error + @return + @error } { - if { ![ah::is_js_sources_loaded -js_source "prototype"] } { - global ajax_helper_js_sources - lappend ajax_helper_js_sources "prototype" - if { ![ah::is_js_sources_loaded -js_source "scriptaculous"] } { - lappend ajax_helper_js_sources "scriptaculous" - } - } - if { !$element_is_var_p } { + ah::requires -sources "prototype,scriptaculous-dragdrop" + + if { !$element_is_var_p } { set element [ah::isnot_js_var $element] } set script "Droppables.remove \($element);" @@ -786,30 +900,25 @@ {-element_is_var:boolean} } { Generates javascript for sortable elements. - The parameters are passed directly to the scriptaculous sortable script. + The parameters are passed directly to the scriptaculous sortable script. Parameters and options are case sensitive, refer to scriptaculous documentation. http://wiki.script.aculo.us/scriptaculous/show/Sortables - @author Hamilton Chua (ham@solutiongrove.com) + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-01-24 @param element the page element that you want to apply the effect to @param options specify the scriptaculous options @param element_is_var specify this parameter if the element you are passing is a javscript variable - @return - @error + @return + @error } { - if { ![ah::is_js_sources_loaded -js_source "prototype"] } { - global ajax_helper_js_sources - lappend ajax_helper_js_sources "prototype" - if { ![ah::is_js_sources_loaded -js_source "scriptaculous"] } { - lappend ajax_helper_js_sources "scriptaculous" - } - } - if { !$element_is_var_p } { + ah::requires -sources "prototype,scriptaculous-dragdrop" + + if { !$element_is_var_p } { set element [ah::isnot_js_var $element] } set script "Sortable.destroy($element); " @@ -831,7 +940,7 @@ Parameters are case sensitive. http://www.curvycorners.net/ - @author Hamilton Chua (ham@solutiongrove.com) + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-01-24 @param classname The name of the html class that the script will look for. All validtags with this classname will be rounded. @@ -841,12 +950,10 @@ } { - if { ![ah::is_js_sources_loaded -js_source "rounder"] } { - global ajax_helper_js_sources - lappend ajax_helper_js_sources "rounder" - } - if { !$element_is_var_p } { + ah::requires -sources "rounder" + + if { !$element_is_var_p } { set element [ah::isnot_js_var $element] } @@ -880,11 +987,9 @@ the array } { - if { ![ah::is_js_sources_loaded -js_source "prototype"] } { - global ajax_helper_js_sources - lappend ajax_helper_js_sources "prototype" - } + ah::requires -sources "prototype,autosuggest" + if {[llength $array_list]} { set suggestion_list $array_list } elseif {![string equal $sql_query {}]} { @@ -895,7 +1000,7 @@ } set suggestions_stub {} - + append suggestions_stub " function AUTOSuggestions() { this.auto = \[ @@ -918,9 +1023,9 @@ var aSuggestions = []; var aDescriptions = []; var sTextboxValue = oAutoSuggestControl.textbox.value.toLowerCase(); - + if (sTextboxValue.length > 0){ - + //search for matching states for (var i=0; i < this.auto.length; i++) { if (this.auto[i][0].toLowerCase().indexOf(sTextboxValue) == 0) { @@ -929,12 +1034,12 @@ } } } - + //provide suggestions to the control oAutoSuggestControl.autosuggest(aSuggestions, aDescriptions, bTypeAhead); }; } - + return $suggestions_stub } \ No newline at end of file Index: openacs-4/packages/ajaxhelper/tcl/ajax-yahoo-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/tcl/ajax-yahoo-procs.tcl,v diff -u -N -r1.5 -r1.6 --- openacs-4/packages/ajaxhelper/tcl/ajax-yahoo-procs.tcl 7 Nov 2006 05:00:01 -0000 1.5 +++ openacs-4/packages/ajaxhelper/tcl/ajax-yahoo-procs.tcl 25 Dec 2006 16:39:50 -0000 1.6 @@ -16,7 +16,7 @@ This source_list will be the global ajax_helper_yui_js_sources variable. This script is called in the blank-master template. - @author Hamilton Chua (ham@solutiongrove.com) + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-11-05 } { set ah_base_url [ah::get_url] @@ -29,63 +29,110 @@ foreach source $source_list { switch $source { - "animation" { - append script " \n" + "animation" { + append script " \n" } "event" { - append script " \n" + append script " \n" } "treeview" { - append script " \n" + append script " \n" global yahoo_treeview_css if { [exists_and_not_null yahoo_treeview_css] } { - append script " \n" + append script " \n" } else { - append script " \n" + append script " \n" } } + "menu" { + append script " \n" + global yahoo_menu_css + if { [exists_and_not_null yahoo_menu_css] } { + append script " \n" + } else { + append script " \n" + } + append script " \n" + append script " \n" + } "calendar" { - append script " \n" + append script " \n" } "dragdrop" { - append script " \n" + append script " \n" } "slider" { - append script " \n" + append script " \n" } "container" { - append script " \n" - append script " \n" + append script " \n" + append script " \n" } "dom" { - append script " \n" + append script " \n" } "connection" { - append script " \n" + append script " \n" } "yahoo" { append script " \n" } + "utilities" { + append script " \n" + } } } return $script } +ad_proc -private ah::yui::is_valid_source { + -js_source +} { + This proc will determine if the YUI js_source file is the name is a valid name associated to + a javascript source. This proc contains hard coded list of javascript sources that + ajaxhelper supports. + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-12-19 + @param js_source The name of the javascript source to check +} { + + set valid_sources [list "utilities" \ + "yahoo" \ + "dom" \ + "event" \ + "connection" \ + "treeview" \ + "animation" \ + "calendar" \ + "menu" \ + "dragdrop" \ + "slider" \ + "container" ] + set found [lsearch -exact $valid_sources $js_source] + if { $found == -1 } { + return 0 + } else { + return 1 + } +} + ad_proc -private ah::yui::is_js_sources_loaded { -js_source } { - This proc will loop thru source_list and check for the presence of js_source. - If found, this proc will return 1 + This proc will loop thru the global source_list + and check for the presence of the given js_source. + If found, this proc will return 1 If not found, this proc will return 0 - @author Hamilton Chua (ham@solutiongrove.com) + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-11-05 } { global ajax_helper_yui_js_sources set state 0 if { [info exists ajax_helper_yui_js_sources] } { foreach source $ajax_helper_yui_js_sources { - if { [string match $source $js_source] } { + if { [string match $source $js_source] } { set state 1 break } @@ -94,25 +141,63 @@ return $state } +ad_proc -private ah::yui::requires { + -sources +} { + This proc should be called by an ajaxhelper proc that uses YUI with a comma separated list of YUI javascript sources + that the ajaxhelper proc needs in order to work. + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-12-19 + @param sources Comma separated list of sources +} { + #split up the comma delimited sources into a list + set source_list [split $sources ","] + #declare the global variable + global ajax_helper_yui_js_sources + foreach source $source_list { + # do some checks before we add the source to the global + # - is it already loaded + # - is it a valid source name + # - is the source utilities or yahoo,dom,event + if { ![ah::yui::is_js_sources_loaded -js_source $source] && [ah::yui::is_valid_source -js_source $source] } { + # source is utilities + if { $source == "utilities"} { + # load it only if yahoo, dom and event are not loaded + if { ![ah::yui::is_js_sources_loaded -js_source "yahoo"] && ![ah::yui::is_js_sources_loaded -js_source "dom"] && ![ah::yui::is_js_sources_loaded -js_source "event"]} { + lappend ajax_helper_yui_js_sources $source + } + } else { + # TODO : figure out other dependencies and possible overlaps and try to work them out here + lappend ajax_helper_yui_js_sources $source + } + } else { + # TODO : we must return an error/exception, for now just add a notice in the log + ns_log Notice "AJAXHELPER YUI: $source is already loaded or not valid" + } + } +} + + ad_proc -public ah::yui::js_sources { {-source "default"} {-min:boolean} } { - Generates the < script > syntax needed on the head + Generates the \n" + # make sure it doesn't load again + lappend ajax_helper_yui_js_sources "utilities" + } + } + set js_file_list [split $source ","] - set minsuffix "" - if { $min_p || [parameter::get_from_package_key -package_key "ajaxhelper" -parameter "UseMinifiedJs"] == 1 } { - set minsuffix "-min" - } - foreach x $js_file_list { - switch $x { + switch $x { "animation" { if { ![ah::yui::is_js_sources_loaded -js_source "animation"] } { - append script " \n" + append script " \n" } } "event" { if { ![ah::yui::is_js_sources_loaded -js_source "event"] } { - append script " \n" + append script " \n" } } "treeview" { if { ![ah::yui::is_js_sources_loaded -js_source "treeview"] } { - append script " \n" + append script " \n" } } "calendar" { if { ![ah::yui::is_js_sources_loaded -js_source "calendar"] } { - append script " \n" + append script " \n" } } "dragdrop" { if { ![ah::yui::is_js_sources_loaded -js_source "dragdrop"] } { - append script " \n" + append script " \n" } } "slider" { if { ![ah::yui::is_js_sources_loaded -js_source "slider"] } { - append script " \n" + append script " \n" } } "container" { if { ![ah::yui::is_js_sources_loaded -js_source "container"] } { - append script " \n" - append script " \n" + append script " \n" + append script " \n" } } "menu" { if { ![ah::yui::is_js_sources_loaded -js_source "menu"] } { - append script " \n" + append script " \n" + append script " \n" } } "connection" { if { ![ah::yui::is_js_sources_loaded -js_source "connection"] } { - append script " \n" + append script " \n" } } - default { + "dom" { if { ![ah::yui::is_js_sources_loaded -js_source "yahoo"] } { + append script " \n" + } + } + "yahoo" { + if { ![ah::yui::is_js_sources_loaded -js_source "yahoo"] } { append script " \n" } - if { ![ah::yui::is_js_sources_loaded -js_source "dom"] } { - append script " \n" - } } + "utilities" { + if { ![ah::yui::is_js_sources_loaded -js_source "utilities"] } { + append script " \n" + } + } } } - return $script } @@ -206,23 +309,17 @@ Creates javascript for Yahoo's Event Listener. http://developer.yahoo.com/yui/event/ - @author Hamilton Chua (ham@solutiongrove.com) + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-11-05 @param element The element that this function will listen for events. This is the id of an html element (e.g. div or a form) @param event The event that this function waits for. Values include load, mouseover, mouseout, unload etc. @param callback The name of the javascript function to execute when the event for the given element has been triggered. } { - if { ![ah::yui::is_js_sources_loaded -js_source "yahoo"] } { - global ajax_helper_yui_js_sources - lappend ajax_helper_yui_js_sources "yahoo" - if { ![ah::yui::is_js_sources_loaded -js_source "event"] } { - lappend ajax_helper_yui_js_sources "event" - } - } + ah::yui::requires -sources "yahoo,event" - if { !$element_is_var_p } { + if { !$element_is_var_p } { set element [ah::isnot_js_var $element] } return "YAHOO.util.Event.addListener($element,\"$event\",${callback});\n" @@ -238,21 +335,16 @@ Generates the javascript to create a tooltip using yahoo's user interface javascript library. http://developer.yahoo.com/yui/container/tooltip/index.html - @author Hamilton Chua (ham@solutiongrove.com) + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-11-05 @param varname The variable name you want to give to the tooltip @param element The element where you wish to attache the tooltip @param message The message that will appear in the tooltip } { - if { ![ah::yui::is_js_sources_loaded -js_source "yahoo"] } { - global ajax_helper_yui_js_sources - lappend ajax_helper_yui_js_sources "yahoo" - if { ![ah::yui::is_js_sources_loaded -js_source "container"] } { - lappend ajax_helper_yui_js_sources "container" - } - } + ah::yui::requires -sources "utilities,container" + set script "var $varname = new YAHOO.widget.Tooltip(\"alertTip\", { context:\"$element\", text:\"$message\", $options });" if { $enclose_p } { set script [ah::enclose_in_script -script ${script} ] } return $script @@ -261,31 +353,43 @@ ad_proc -public ah::yui::create_tree { -element:required -nodes:required - {-varname "tree"} + {-varname "tree"} {-css ""} + {-enclose:boolean} } { Generates the javascript to create a yahoo tree view control. + Nodes accepts a list of lists. + + This is an example of a node list. + + set nodes [list] + lappend nodes [list "fld1" "Folder 1" "tree" "" "" "" ""] + lappend nodes [list "fld2" "Folder 2" "tree" "javascript:alert('this is a tree node')" "" "" ""] + + A node list is expected to have the following values in the given order : + list index - expected value + 0 - javascript variable name of the nodes + 1 - the pretty name or label of the nodes + 2 - the javascript variable name of the treeview + 3 - the value of the href attribute of a nodes + 4 - the variable name of the node to attach to, if blank it will automatically attach to the root nodes + 5 - a javascript function to execute if the node should load it's children dynamically + 6 - should the node be opened or closed + http://developer.yahoo.com/yui/treeview/ - @author Hamilton Chua (ham@solutiongrove.com) + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-11-05 - + @param element This is the id of the html elment where you want to generate the tree view control. @param nodes Is list of lists. Each list contains the node information to be passed to ah::yui::create_tree_node to create a node. - @param varname The javascript variable name to give the tree. + @param varname The javascript variable name to give the tree. } { - if { ![ah::yui::is_js_sources_loaded -js_source "yahoo"] } { - global ajax_helper_yui_js_sources - lappend ajax_helper_yui_js_sources "yahoo" - lappend ajax_helper_yui_js_sources "dom" - if { ![ah::yui::is_js_sources_loaded -js_source "treeview"] } { - lappend ajax_helper_yui_js_sources "treeview" - global yahoo_treeview_css - set yahoo_treeview_css $css - } - } + ah::yui::requires -sources "utilities,treeview" + global yahoo_treeview_css + set yahoo_treeview_css $css set script "${varname} = new YAHOO.widget.TreeView(\"${element}\"); " append script "var ${varname}root = ${varname}.getRoot(); " @@ -295,9 +399,11 @@ -treevarname [lindex $node 2] \ -href [lindex $node 3] \ -attach_to_node [lindex $node 4] \ - -dynamic_load [lindex $node 5] ] + -dynamic_load [lindex $node 5] \ + -open [lindex $node 6] ] } append script "${varname}.draw(); " + if { $enclose_p } { set script [ah::enclose_in_script -script ${script} ] } return $script } @@ -308,27 +414,235 @@ {-href "javascript:void(0)"} {-attach_to_node ""} {-dynamic_load ""} + {-open "false"} } { Generates the javascript to add a node to a yahoo tree view control http://developer.yahoo.com/yui/treeview/ - @author Hamilton Chua (ham@solutiongrove.com) + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-11-05 + + @param varname The name to give the javascript variable to represent the node. + @param label The label to assign the node. + @param treevarname The javascript variable associated with the tree object + @param href Link that the node goes to when it is clicked. + @param attach_to_node The variable name of an existing node to attach this node to. + @param dynamic_load A javascript function that is executed when the children of this node are loaded. + @param open Set this to "true" if you want this node to be open by default when it is rendered. } { set script "var od${varname} = {label: \"${label}\", id: \"${varname}\", href: \"${href}\"}; " if { [exists_and_not_null attach_to_node] } { append script "var node = ${treevarname}.getNodeByProperty('id','${attach_to_node}'); " append script "if ( node == null ) { var node = nd${attach_to_node}; } " - + } else { append script "var node = ${treevarname}root; " } - append script "var nd${varname} = new YAHOO.widget.TextNode(od${varname},node,false); " + if { ![exists_and_not_null open] } { set open "false" } + append script "var nd${varname} = new YAHOO.widget.TextNode(od${varname},node,${open}); " if { [exists_and_not_null dynamic_load] } { append script "nd${varname}.setDynamicLoad(${dynamic_load}); " } return $script +} + +ad_proc -public ah::yui::menu_from_markup { + -varname:required + -markupid:required + {-enclose:boolean} + {-arrayname "yuimenu"} + {-css ""} + {-options ""} +} { + Generates the javascript to create a YUI menu from existing html markup. + The resulting script is placed in an array named $arrayname which defaults to "yuimenu". + The array will have 2 items $yuimenu(show) and $yuimenu(render). + render holds the script that creates the Yui Menu widget while + show holds the script to display the menu, the show script can be placed in an onclick event of an html element. + + http://developer.yahoo.com/yui/menu/ + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-12-23 + + @param varname The javascript variable to represent the menu object. + @param markupid The html id of with the markup we want to transform into a menu. + @param enclose Specify this if you want to enclose the entire script in script tags. + @param arrayname Type the name of an array to use. "yuimenu" will be used if none is specified. + @param css Specify the full path to a css style sheet file to use an alternative to the menu.css that is used. + @param options Additional options that you want to pass to the javascript object constructor. + +} { + ah::yui::requires -sources "utilities,menu" + + global yahoo_menu_css + set yahoo_menu_css $css + + set script "${varname} = new YAHOO.widget.Menu(\"${markupid}\",{${options}}); " + append script "${varname}.render(); " + + set script [ah::yui::addlistener \ + -element "window" \ + -event "load" \ + -callback [ah::create_js_function -body ${script}] \ + -element_is_var ] + + if { $enclose_p } { set script [ah::enclose_in_script -script ${script} ] } + + set showscript "${varname}.show(); " + + upvar $arrayname arr + set arr(render) $script + set arr(show) $showscript +} + +ad_proc -public ah::yui::menu_list_to_json { + -lists_of_pairs +} { + Converts a properly structured list of menu items into JSON format. + The list of lists may look something like + + set submenu [list] + lappend submenu [list [list "text" "Submenu1"] [list "url" "http://www.google.com"] ] + lappend submenu [list [list "text" "Submenu2"] [list "url" "http://www.yahoo.com"] ] + + each line represents a row composed of lists. + Each list in the row holds a pair that will be joined by ":". +} { + set rows [list] + foreach row $lists_of_pairs { + set pairs [list] + foreach pair $row { + if { [lindex $pair 0] == "submenu" } { + set submenulist [lindex $pair 1] + + set submenuid [lindex $submenulist 0] + set itemdata [lindex $submenulist 1] + + set itemdatajson [ah::yui::menu_list_to_json -lists_of_pairs [lindex $itemdata 1] ] + + set submenujson "\"[join $submenuid "\":\""]\"" + append submenujson ", [lindex $itemdata 0] : \[ $itemdatajson \]" + + lappend pairs "\"[lindex $pair 0]\": { $submenujson }" + } else { + lappend pairs "\"[join $pair "\":\""]\"" + } + } + lappend rows [join $pairs ","] + } + return "\{[join $rows "\},\{"]\}" +} + + +ad_proc -public ah::yui::menu_from_list { + -varname:required + -id:required + -menulist:required + {-enclose:boolean} + {-arrayname "yuimenu"} + {-css ""} + {-options ""} + {-renderin "document.body"} +} { + Generates the javascript to create a YUI menu from a tcl list. + The resulting script is placed in an array named $arrayname which defaults to "yuimenu". + The array will have 2 items $yuimenu(show) and $yuimenu(render). + render holds the script that creates the Yui Menu widget while + show holds the script to display the menu, the show script can be placed in an onclick event of an html element. + + http://developer.yahoo.com/yui/menu/ + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-12-25 + + @param varname The javascript variable to represent the menu object. + @param menulist A list of lists with the parameters this script needs to generate your menu. + @param id The html id the menu element. + @param enclose Specify this if you want to enclose the entire script in script tags. + @param arrayname Type the name of an array to use. "yuimenu" will be used if none is specified. + @param css Specify the full path to a css style sheet file to use an alternative to the menu.css that is used. + @param options Additional options that you want to pass to the javascript object constructor. + +} { + + ah::yui::requires -sources "utilities,menu" + + global yahoo_menu_css + set yahoo_menu_css $css + + set jsonlist [ah::yui::menu_list_to_json -lists_of_pairs $menulist] + + set script "$varname = new YAHOO.widget.Menu(\"${id}\",{${options}}); " + append script "$varname.addItems(\[${jsonlist}\]); " + append script "${varname}.render(${renderin}); " + + set script [ah::yui::addlistener \ + -element "window" \ + -event "load" \ + -callback [ah::create_js_function -body ${script}] \ + -element_is_var ] + + if { $enclose_p } { set script [ah::enclose_in_script -script ${script} ] } + + set showscript "${varname}.show(); " + + upvar $arrayname arr + set arr(render) $script + set arr(show) $showscript + +} + +ad_proc -public ah::yui::contextmenu { + -varname:required + -id:required + -menulist:required + {-enclose:boolean} + {-css ""} + {-options ""} + {-trigger "document"} + {-renderin "document.body"} +} { + Generates the javascript to create a YUI context menu from a tcl list. + http://developer.yahoo.com/yui/menu/ + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-12-25 + + @param varname The javascript variable to represent the menu object. + @param menulist A list of lists with the parameters this script needs to generate your menu. + @param id The html id the menu element. + @param enclose Specify this if you want to enclose the entire script in script tags. + @param css Specify the full path to a css style sheet file to use an alternative to the menu.css that is used. + @param options Additional options that you want to pass to the javascript object constructor. + +} { + + ah::yui::requires -sources "utilities,menu" + + set jsonlist [ah::yui::menu_list_to_json -lists_of_pairs $menulist] + + set initoptions "trigger: ${trigger}" + if { [exists_and_not_null options] } { + set options "${initoptions},${options}" + } else { + set options "${initoptions}" + } + + set script "var $varname = new YAHOO.widget.ContextMenu(\"${id}\", { ${options} } ); " + append script "$varname.addItems(\[${jsonlist}\]); " + append script "$varname.render(${renderin}); " + + set script [ah::yui::addlistener \ + -element "window" \ + -event "load" \ + -callback [ah::create_js_function -body ${script}] \ + -element_is_var ] + + if { $enclose_p } { set script [ah::enclose_in_script -script ${script} ] } + return ${script} + } \ No newline at end of file Index: openacs-4/packages/ajaxhelper/www/doc/index.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/doc/index.html,v diff -u -N -r1.5 -r1.6 --- openacs-4/packages/ajaxhelper/www/doc/index.html 6 Nov 2006 13:15:29 -0000 1.5 +++ openacs-4/packages/ajaxhelper/www/doc/index.html 25 Dec 2006 16:39:50 -0000 1.6 @@ -59,7 +59,7 @@ # if we're using ajax, let's use doc_type strict so we can get # consistent results accross standards compliant browsers - set doc_type { < !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > } + set doc_type { <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> } if { [info exists ajax_helper_js_sources] } { append js_sources [ah::load_js_sources -source_list $ajax_helper_js_sources] 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 -N -r1.1 -r1.2 --- openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/LICENSE 6 Nov 2006 14:37:19 -0000 1.1 +++ openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/LICENSE 25 Dec 2006 16:39:50 -0000 1.2 @@ -13,20 +13,20 @@ The "New" BSD License: ********************** -Copyright (c) 2005, The Dojo Foundation +Copyright (c) 2005-2006, The Dojo Foundation All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. + list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. * Neither the name of the Dojo Foundation nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. + may be used to endorse or promote products derived from this software + without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 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 -N -r1.1 -r1.2 --- openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/README 6 Nov 2006 14:37:19 -0000 1.1 +++ openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/README 25 Dec 2006 16:39:50 -0000 1.2 @@ -100,7 +100,7 @@ irc.freenode.net #dojo -Note that 2PM Wed PST in this channel is reserved for a weekly meeting between +Note that 3PM Wed PST in #dojo-meeting is reserved for a weekly meeting between project developers, although anyone is welcome to participate. 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 -N -r1.1 -r1.2 --- openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/build.txt 6 Nov 2006 14:37:19 -0000 1.1 +++ openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/build.txt 25 Dec 2006 16:39:50 -0000 1.2 @@ -20,18 +20,17 @@ ../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/html/common.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 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 -N -r1.1 -r1.2 --- openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/dojo.js 6 Nov 2006 14:37:19 -0000 1.1 +++ openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/dojo.js 25 Dec 2006 16:39:50 -0000 1.2 @@ -33,7 +33,7 @@ return dj_currentContext; }; dojo.locale=djConfig.locale; -dojo.version={major:0,minor:4,patch:0,flag:"",revision:Number("$Rev: 6258 $".match(/[0-9]+/)[0]),toString:function(){ +dojo.version={major:0,minor:4,patch:1,flag:"",revision:Number("$Rev: 6824 $".match(/[0-9]+/)[0]),toString:function(){ with(dojo.version){ return major+"."+minor+"."+patch+flag+" ("+revision+")"; } @@ -83,6 +83,8 @@ dojo.raise=function(_12,_13){ if(_13){ _12=_12+": "+dojo.errorToString(_13); +}else{ +_12=dojo.errorToString(_12); } try{ if(djConfig.isDebug){ @@ -450,23 +452,27 @@ return true; }; dojo.hostenv.normalizeLocale=function(_6e){ -return _6e?_6e.toLowerCase():dojo.locale; +var _6f=_6e?_6e.toLowerCase():dojo.locale; +if(_6f=="root"){ +_6f="ROOT"; +} +return _6f; }; -dojo.hostenv.searchLocalePath=function(_6f,_70,_71){ -_6f=dojo.hostenv.normalizeLocale(_6f); -var _72=_6f.split("-"); -var _73=[]; -for(var i=_72.length;i>0;i--){ -_73.push(_72.slice(0,i).join("-")); +dojo.hostenv.searchLocalePath=function(_70,_71,_72){ +_70=dojo.hostenv.normalizeLocale(_70); +var _73=_70.split("-"); +var _74=[]; +for(var i=_73.length;i>0;i--){ +_74.push(_73.slice(0,i).join("-")); } -_73.push(false); -if(_70){ -_73.reverse(); +_74.push(false); +if(_71){ +_74.reverse(); } -for(var j=_73.length-1;j>=0;j--){ -var loc=_73[j]||"ROOT"; -var _77=_71(loc); -if(_77){ +for(var j=_74.length-1;j>=0;j--){ +var loc=_74[j]||"ROOT"; +var _78=_72(loc); +if(_78){ break; } } @@ -478,9 +484,9 @@ dojo.hostenv.preloadLocalizations=function(){ if(dojo.hostenv.localesGenerated){ dojo.hostenv.registerNlsPrefix(); -function preload(_78){ -_78=dojo.hostenv.normalizeLocale(_78); -dojo.hostenv.searchLocalePath(_78,true,function(loc){ +function preload(_79){ +_79=dojo.hostenv.normalizeLocale(_79); +dojo.hostenv.searchLocalePath(_79,true,function(loc){ for(var i=0;i_84.length){ +_84=_85[i]; } -var _82=dojo.hostenv.normalizeLocale(_7f).replace("-","_"); -var _83=_80+"."+_82; -if(dojo.hostenv.findModule(_83)){ +} +} +if(!_84){ +_84="ROOT"; +} +} +var _87=_81?_84:_82; +var _88=dojo.hostenv.findModule(_83); +var _89=null; +if(_88){ +if(djConfig.localizationComplete&&_88._built){ return; } +var _8a=_87.replace("-","_"); +var _8b=_83+"."+_8a; +_89=dojo.hostenv.findModule(_8b); } -_81=dojo.hostenv.startPackage(_80); -var _84=dojo.hostenv.getModuleSymbols(_7d); -var _85=_84.concat("nls").join("/"); -var _86; -dojo.hostenv.searchLocalePath(_7f,false,function(loc){ -var _88=loc.replace("-","_"); -var _89=_80+"."+_88; -var _8a=false; -if(!dojo.hostenv.findModule(_89)){ -dojo.hostenv.startPackage(_89); -var _8b=[_85]; +if(!_89){ +_88=dojo.hostenv.startPackage(_83); +var _8c=dojo.hostenv.getModuleSymbols(_7e); +var _8d=_8c.concat("nls").join("/"); +var _8e; +dojo.hostenv.searchLocalePath(_87,_81,function(loc){ +var _90=loc.replace("-","_"); +var _91=_83+"."+_90; +var _92=false; +if(!dojo.hostenv.findModule(_91)){ +dojo.hostenv.startPackage(_91); +var _93=[_8d]; if(loc!="ROOT"){ -_8b.push(loc); +_93.push(loc); } -_8b.push(_7e); -var _8c=_8b.join("/")+".js"; -_8a=dojo.hostenv.loadPath(_8c,null,function(_8d){ -var _8e=function(){ +_93.push(_7f); +var _94=_93.join("/")+".js"; +_92=dojo.hostenv.loadPath(_94,null,function(_95){ +var _96=function(){ }; -_8e.prototype=_86; -_81[_88]=new _8e(); -for(var j in _8d){ -_81[_88][j]=_8d[j]; +_96.prototype=_8e; +_88[_90]=new _96(); +for(var j in _95){ +_88[_90][j]=_95[j]; } }); }else{ -_8a=true; +_92=true; } -if(_8a&&_81[_88]){ -_86=_81[_88]; +if(_92&&_88[_90]){ +_8e=_88[_90]; }else{ -_81[_88]=_86; +_88[_90]=_8e; } +if(_81){ +return true; +} }); +} +if(_81&&_82!=_84){ +_88[_82.replace("-","_")]=_88[_84.replace("-","_")]; +} }; (function(){ -var _90=djConfig.extraLocale; -if(_90){ -if(!_90 instanceof Array){ -_90=[_90]; +var _98=djConfig.extraLocale; +if(_98){ +if(!_98 instanceof Array){ +_98=[_98]; } var req=dojo.requireLocalization; -dojo.requireLocalization=function(m,b,_94){ -req(m,b,_94); -if(_94){ +dojo.requireLocalization=function(m,b,_9c,_9d){ +req(m,b,_9c,_9d); +if(_9c){ return; } -for(var i=0;i<_90.length;i++){ -req(m,b,_90[i]); +for(var i=0;i<_98.length;i++){ +req(m,b,_98[i],_9d); } }; } @@ -570,13 +599,13 @@ if(typeof window!="undefined"){ (function(){ if(djConfig.allowQueryConfig){ -var _96=document.location.toString(); -var _97=_96.split("?",2); -if(_97.length>1){ -var _98=_97[1]; -var _99=_98.split("&"); -for(var x in _99){ -var sp=_99[x].split("="); +var _9f=document.location.toString(); +var _a0=_9f.split("?",2); +if(_a0.length>1){ +var _a1=_a0[1]; +var _a2=_a1.split("&"); +for(var x in _a2){ +var sp=_a2[x].split("="); if((sp[0].length>9)&&(sp[0].substr(0,9)=="djConfig.")){ var opt=sp[0].substr(9); try{ @@ -590,27 +619,27 @@ } } if(((djConfig["baseScriptUri"]=="")||(djConfig["baseRelativePath"]==""))&&(document&&document.getElementsByTagName)){ -var _9d=document.getElementsByTagName("script"); -var _9e=/(__package__|dojo|bootstrap1)\.js([\?\.]|$)/i; -for(var i=0;i<_9d.length;i++){ -var src=_9d[i].getAttribute("src"); +var _a6=document.getElementsByTagName("script"); +var _a7=/(__package__|dojo|bootstrap1)\.js([\?\.]|$)/i; +for(var i=0;i<_a6.length;i++){ +var src=_a6[i].getAttribute("src"); if(!src){ continue; } -var m=src.match(_9e); +var m=src.match(_a7); if(m){ -var _a2=src.substring(0,m.index); +var _ab=src.substring(0,m.index); if(src.indexOf("bootstrap1")>-1){ -_a2+="../"; +_ab+="../"; } if(!this["djConfig"]){ djConfig={}; } if(djConfig["baseScriptUri"]==""){ -djConfig["baseScriptUri"]=_a2; +djConfig["baseScriptUri"]=_ab; } if(djConfig["baseRelativePath"]==""){ -djConfig["baseRelativePath"]=_a2; +djConfig["baseRelativePath"]=_ab; } break; } @@ -632,10 +661,10 @@ drh.opera=dua.indexOf("Opera")>=0; drh.khtml=(dav.indexOf("Konqueror")>=0)||(dav.indexOf("Safari")>=0); drh.safari=dav.indexOf("Safari")>=0; -var _aa=dua.indexOf("Gecko"); -drh.mozilla=drh.moz=(_aa>=0)&&(!drh.khtml); +var _b3=dua.indexOf("Gecko"); +drh.mozilla=drh.moz=(_b3>=0)&&(!drh.khtml); if(drh.mozilla){ -drh.geckoVersion=dua.substring(_aa+6,_aa+14); +drh.geckoVersion=dua.substring(_b3+6,_b3+14); } drh.ie=(document.all)&&(!drh.opera); drh.ie50=drh.ie&&dav.indexOf("MSIE 5.0")>=0; @@ -649,8 +678,8 @@ drs.capable=f; drs.support.plugin=f; drs.support.builtin=f; -var _ac=window["document"]; -var tdi=_ac["implementation"]; +var _b5=window["document"]; +var tdi=_b5["implementation"]; if((tdi)&&(tdi["hasFeature"])&&(tdi.hasFeature("org.w3c.dom.svg","1.0"))){ drs.capable=t; drs.support.builtin=t; @@ -664,117 +693,118 @@ drs.support.builtin=t; drs.support.plugin=f; } +}else{ } })(); dojo.hostenv.startPackage("dojo.hostenv"); dojo.render.name=dojo.hostenv.name_="browser"; dojo.hostenv.searchIds=[]; dojo.hostenv._XMLHTTP_PROGIDS=["Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0"]; dojo.hostenv.getXmlhttpObject=function(){ -var _b0=null; -var _b1=null; +var _b9=null; +var _ba=null; try{ -_b0=new XMLHttpRequest(); +_b9=new XMLHttpRequest(); } catch(e){ } -if(!_b0){ +if(!_b9){ for(var i=0;i<3;++i){ -var _b3=dojo.hostenv._XMLHTTP_PROGIDS[i]; +var _bc=dojo.hostenv._XMLHTTP_PROGIDS[i]; try{ -_b0=new ActiveXObject(_b3); +_b9=new ActiveXObject(_bc); } catch(e){ -_b1=e; +_ba=e; } -if(_b0){ -dojo.hostenv._XMLHTTP_PROGIDS=[_b3]; +if(_b9){ +dojo.hostenv._XMLHTTP_PROGIDS=[_bc]; break; } } } -if(!_b0){ -return dojo.raise("XMLHTTP not available",_b1); +if(!_b9){ +return dojo.raise("XMLHTTP not available",_ba); } -return _b0; +return _b9; }; dojo.hostenv._blockAsync=false; -dojo.hostenv.getText=function(uri,_b5,_b6){ -if(!_b5){ +dojo.hostenv.getText=function(uri,_be,_bf){ +if(!_be){ this._blockAsync=true; } -var _b7=this.getXmlhttpObject(); -function isDocumentOk(_b8){ -var _b9=_b8["status"]; -return Boolean((!_b9)||((200<=_b9)&&(300>_b9))||(_b9==304)); +var _c0=this.getXmlhttpObject(); +function isDocumentOk(_c1){ +var _c2=_c1["status"]; +return Boolean((!_c2)||((200<=_c2)&&(300>_c2))||(_c2==304)); } -if(_b5){ -var _ba=this,_bb=null,gbl=dojo.global(); +if(_be){ +var _c3=this,_c4=null,gbl=dojo.global(); var xhr=dojo.evalObjPath("dojo.io.XMLHTTPTransport"); -_b7.onreadystatechange=function(){ -if(_bb){ -gbl.clearTimeout(_bb); -_bb=null; +_c0.onreadystatechange=function(){ +if(_c4){ +gbl.clearTimeout(_c4); +_c4=null; } -if(_ba._blockAsync||(xhr&&xhr._blockAsync)){ -_bb=gbl.setTimeout(function(){ -_b7.onreadystatechange.apply(this); +if(_c3._blockAsync||(xhr&&xhr._blockAsync)){ +_c4=gbl.setTimeout(function(){ +_c0.onreadystatechange.apply(this); },10); }else{ -if(4==_b7.readyState){ -if(isDocumentOk(_b7)){ -_b5(_b7.responseText); +if(4==_c0.readyState){ +if(isDocumentOk(_c0)){ +_be(_c0.responseText); } } } }; } -_b7.open("GET",uri,_b5?true:false); +_c0.open("GET",uri,_be?true:false); try{ -_b7.send(null); -if(_b5){ +_c0.send(null); +if(_be){ return null; } -if(!isDocumentOk(_b7)){ -var err=Error("Unable to load "+uri+" status:"+_b7.status); -err.status=_b7.status; -err.responseText=_b7.responseText; +if(!isDocumentOk(_c0)){ +var err=Error("Unable to load "+uri+" status:"+_c0.status); +err.status=_c0.status; +err.responseText=_c0.responseText; throw err; } } catch(e){ this._blockAsync=false; -if((_b6)&&(!_b5)){ +if((_bf)&&(!_be)){ return null; }else{ throw e; } } this._blockAsync=false; -return _b7.responseText; +return _c0.responseText; }; dojo.hostenv.defaultDebugContainerId="dojoDebug"; dojo.hostenv._println_buffer=[]; dojo.hostenv._println_safe=false; -dojo.hostenv.println=function(_bf){ +dojo.hostenv.println=function(_c8){ if(!dojo.hostenv._println_safe){ -dojo.hostenv._println_buffer.push(_bf); +dojo.hostenv._println_buffer.push(_c8); }else{ try{ -var _c0=document.getElementById(djConfig.debugContainerId?djConfig.debugContainerId:dojo.hostenv.defaultDebugContainerId); -if(!_c0){ -_c0=dojo.body(); +var _c9=document.getElementById(djConfig.debugContainerId?djConfig.debugContainerId:dojo.hostenv.defaultDebugContainerId); +if(!_c9){ +_c9=dojo.body(); } var div=document.createElement("div"); -div.appendChild(document.createTextNode(_bf)); -_c0.appendChild(div); +div.appendChild(document.createTextNode(_c8)); +_c9.appendChild(div); } catch(e){ try{ -document.write("
"+_bf+"
"); +document.write("
"+_c8+"
"); } catch(e2){ -window.status=_bf; +window.status=_c8; } } } @@ -785,35 +815,35 @@ dojo.hostenv.println(dojo.hostenv._println_buffer.shift()); } }); -function dj_addNodeEvtHdlr(_c2,_c3,fp,_c5){ -var _c6=_c2["on"+_c3]||function(){ +function dj_addNodeEvtHdlr(_cb,_cc,fp){ +var _ce=_cb["on"+_cc]||function(){ }; -_c2["on"+_c3]=function(){ -fp.apply(_c2,arguments); -_c6.apply(_c2,arguments); +_cb["on"+_cc]=function(){ +fp.apply(_cb,arguments); +_ce.apply(_cb,arguments); }; return true; } function dj_load_init(e){ -var _c8=(e&&e.type)?e.type.toLowerCase():"load"; -if(arguments.callee.initialized||(_c8!="domcontentloaded"&&_c8!="load")){ +var _d0=(e&&e.type)?e.type.toLowerCase():"load"; +if(arguments.callee.initialized||(_d0!="domcontentloaded"&&_d0!="load")){ return; } arguments.callee.initialized=true; if(typeof (_timer)!="undefined"){ clearInterval(_timer); delete _timer; } -var _c9=function(){ +var _d1=function(){ if(dojo.render.html.ie){ dojo.hostenv.makeWidgets(); } }; if(dojo.hostenv.inFlightCount==0){ -_c9(); +_d1(); dojo.hostenv.modulesLoaded(); }else{ -dojo.addOnLoad(_c9); +dojo.hostenv.modulesLoadedListeners.unshift(_d1); } } if(document.addEventListener){ @@ -851,29 +881,29 @@ } }); dojo.hostenv.makeWidgets=function(){ -var _cb=[]; +var _d3=[]; if(djConfig.searchIds&&djConfig.searchIds.length>0){ -_cb=_cb.concat(djConfig.searchIds); +_d3=_d3.concat(djConfig.searchIds); } if(dojo.hostenv.searchIds&&dojo.hostenv.searchIds.length>0){ -_cb=_cb.concat(dojo.hostenv.searchIds); +_d3=_d3.concat(dojo.hostenv.searchIds); } -if((djConfig.parseWidgets)||(_cb.length>0)){ +if((djConfig.parseWidgets)||(_d3.length>0)){ if(dojo.evalObjPath("dojo.widget.Parse")){ -var _cc=new dojo.xml.Parse(); -if(_cb.length>0){ -for(var x=0;x<_cb.length;x++){ -var _ce=document.getElementById(_cb[x]); -if(!_ce){ +var _d4=new dojo.xml.Parse(); +if(_d3.length>0){ +for(var x=0;x<_d3.length;x++){ +var _d6=document.getElementById(_d3[x]); +if(!_d6){ continue; } -var _cf=_cc.parseElement(_ce,null,true); -dojo.widget.getParser().createComponents(_cf); +var _d7=_d4.parseElement(_d6,null,true); +dojo.widget.getParser().createComponents(_d7); } }else{ if(djConfig.parseWidgets){ -var _cf=_cc.parseElement(dojo.body(),null,true); -dojo.widget.getParser().createComponents(_cf); +var _d7=_d4.parseElement(dojo.body(),null,true); +dojo.widget.getParser().createComponents(_d7); } } } @@ -929,83 +959,83 @@ } return id; }; -dojo.setContext=function(_d4,_d5){ -dj_currentContext=_d4; -dj_currentDocument=_d5; +dojo.setContext=function(_dc,_dd){ +dj_currentContext=_dc; +dj_currentDocument=_dd; }; -dojo._fireCallback=function(_d6,_d7,_d8){ -if((_d7)&&((typeof _d6=="string")||(_d6 instanceof String))){ -_d6=_d7[_d6]; +dojo._fireCallback=function(_de,_df,_e0){ +if((_df)&&((typeof _de=="string")||(_de instanceof String))){ +_de=_df[_de]; } -return (_d7?_d6.apply(_d7,_d8||[]):_d6()); +return (_df?_de.apply(_df,_e0||[]):_de()); }; -dojo.withGlobal=function(_d9,_da,_db,_dc){ -var _dd; -var _de=dj_currentContext; -var _df=dj_currentDocument; +dojo.withGlobal=function(_e1,_e2,_e3,_e4){ +var _e5; +var _e6=dj_currentContext; +var _e7=dj_currentDocument; try{ -dojo.setContext(_d9,_d9.document); -_dd=dojo._fireCallback(_da,_db,_dc); +dojo.setContext(_e1,_e1.document); +_e5=dojo._fireCallback(_e2,_e3,_e4); } finally{ -dojo.setContext(_de,_df); +dojo.setContext(_e6,_e7); } -return _dd; +return _e5; }; -dojo.withDoc=function(_e0,_e1,_e2,_e3){ -var _e4; -var _e5=dj_currentDocument; +dojo.withDoc=function(_e8,_e9,_ea,_eb){ +var _ec; +var _ed=dj_currentDocument; try{ -dj_currentDocument=_e0; -_e4=dojo._fireCallback(_e1,_e2,_e3); +dj_currentDocument=_e8; +_ec=dojo._fireCallback(_e9,_ea,_eb); } finally{ -dj_currentDocument=_e5; +dj_currentDocument=_ed; } -return _e4; +return _ec; }; } (function(){ if(typeof dj_usingBootstrap!="undefined"){ return; } -var _e6=false; -var _e7=false; -var _e8=false; +var _ee=false; +var _ef=false; +var _f0=false; if((typeof this["load"]=="function")&&((typeof this["Packages"]=="function")||(typeof this["Packages"]=="object"))){ -_e6=true; +_ee=true; }else{ if(typeof this["load"]=="function"){ -_e7=true; +_ef=true; }else{ if(window.widget){ -_e8=true; +_f0=true; } } } -var _e9=[]; +var _f1=[]; if((this["djConfig"])&&((djConfig["isDebug"])||(djConfig["debugAtAllCosts"]))){ -_e9.push("debug.js"); +_f1.push("debug.js"); } -if((this["djConfig"])&&(djConfig["debugAtAllCosts"])&&(!_e6)&&(!_e8)){ -_e9.push("browser_debug.js"); +if((this["djConfig"])&&(djConfig["debugAtAllCosts"])&&(!_ee)&&(!_f0)){ +_f1.push("browser_debug.js"); } -var _ea=djConfig["baseScriptUri"]; +var _f2=djConfig["baseScriptUri"]; if((this["djConfig"])&&(djConfig["baseLoaderUri"])){ -_ea=djConfig["baseLoaderUri"]; +_f2=djConfig["baseLoaderUri"]; } -for(var x=0;x<_e9.length;x++){ -var _ec=_ea+"src/"+_e9[x]; -if(_e6||_e7){ -load(_ec); +for(var x=0;x<_f1.length;x++){ +var _f4=_f2+"src/"+_f1[x]; +if(_ee||_ef){ +load(_f4); }else{ try{ -document.write(""); +document.write(""); } catch(e){ -var _ed=document.createElement("script"); -_ed.src=_ec; -document.getElementsByTagName("head")[0].appendChild(_ed); +var _f5=document.createElement("script"); +_f5.src=_f4; +document.getElementsByTagName("head")[0].appendChild(_f5); } } } @@ -1027,12 +1057,12 @@ dojo.string.trimEnd=function(str){ return dojo.string.trim(str,-1); }; -dojo.string.repeat=function(str,_f4,_f5){ +dojo.string.repeat=function(str,_fc,_fd){ var out=""; -for(var i=0;i<_f4;i++){ +for(var i=0;i<_fc;i++){ out+=str; -if(_f5&&i<_f4-1){ -out+=_f5; +if(_fd&&i<_fc-1){ +out+=_fd; } } return out; @@ -1062,72 +1092,72 @@ }; 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+"']"); +dojo.lang.inherits=function(_10b,_10c){ +if(!dojo.lang.isFunction(_10c)){ +dojo.raise("dojo.inherits: superclass argument ["+_10c+"] must be a function (subclass: ["+_10b+"']"); } -_103.prototype=new _104(); -_103.prototype.constructor=_103; -_103.superclass=_104.prototype; -_103["super"]=_104.prototype; +_10b.prototype=new _10c(); +_10b.prototype.constructor=_10b; +_10b.superclass=_10c.prototype; +_10b["super"]=_10c.prototype; }; -dojo.lang._mixin=function(obj,_106){ +dojo.lang._mixin=function(obj,_10e){ var tobj={}; -for(var x in _106){ -if((typeof tobj[x]=="undefined")||(tobj[x]!=_106[x])){ -obj[x]=_106[x]; +for(var x in _10e){ +if((typeof tobj[x]=="undefined")||(tobj[x]!=_10e[x])){ +obj[x]=_10e[x]; } } -if(dojo.render.html.ie&&(typeof (_106["toString"])=="function")&&(_106["toString"]!=obj["toString"])&&(_106["toString"]!=tobj["toString"])){ -obj.toString=_106.toString; +if(dojo.render.html.ie&&(typeof (_10e["toString"])=="function")&&(_10e["toString"]!=obj["toString"])&&(_10e["toString"]!=tobj["toString"])){ +obj.toString=_10e.toString; } return obj; }; -dojo.lang.mixin=function(obj,_10a){ +dojo.lang.mixin=function(obj,_112){ for(var i=1,l=arguments.length;i-1; +dojo.lang.inArray=function(_125,_126){ +return dojo.lang.find(_125,_126)>-1; }; dojo.lang.isObject=function(it){ if(typeof it=="undefined"){ @@ -1174,22 +1204,26 @@ return false; }; dojo.lang.isFunction=function(it){ -if(!it){ -return false; -} +return (it instanceof Function||typeof it=="function"); +}; +(function(){ +if((dojo.render.html.capable)&&(dojo.render.html["safari"])){ +dojo.lang.isFunction=function(it){ if((typeof (it)=="function")&&(it=="[object NodeList]")){ return false; } return (it instanceof Function||typeof it=="function"); }; +} +})(); dojo.lang.isString=function(it){ return (typeof it=="string"||it instanceof String); }; dojo.lang.isAlien=function(it){ if(!it){ return false; } -return !dojo.lang.isFunction()&&/\{\s*\[native code\]\s*\}/.test(String(it)); +return !dojo.lang.isFunction(it)&&/\{\s*\[native code\]\s*\}/.test(String(it)); }; dojo.lang.isBoolean=function(it){ return (it instanceof Boolean||typeof it=="boolean"); @@ -1201,27 +1235,27 @@ return ((typeof (it)=="undefined")&&(it==undefined)); }; dojo.provide("dojo.lang.extras"); -dojo.lang.setTimeout=function(func,_129){ -var _12a=window,_12b=2; +dojo.lang.setTimeout=function(func,_132){ +var _133=window,_134=2; if(!dojo.lang.isFunction(func)){ -_12a=func; -func=_129; -_129=arguments[2]; -_12b++; +_133=func; +func=_132; +_132=arguments[2]; +_134++; } if(dojo.lang.isString(func)){ -func=_12a[func]; +func=_133[func]; } var args=[]; -for(var i=_12b;i=3){ dojo.raise("thisObject doesn't exist!"); } -_19e=dj_global; +_1a8=dj_global; } -_1a0=[]; +_1aa=[]; for(var i=0;i/gm,">").replace(/"/gm,"""); -if(!_1df){ +if(!_1e9){ str=str.replace(/'/gm,"'"); } return str; @@ -1845,8 +1892,8 @@ } return str.substring(0,len).replace(/\.+$/,"")+"..."; }; -dojo.string.endsWith=function(str,end,_1e8){ -if(_1e8){ +dojo.string.endsWith=function(str,end,_1f2){ +if(_1f2){ str=str.toLowerCase(); end=end.toLowerCase(); } @@ -1863,12 +1910,12 @@ } return false; }; -dojo.string.startsWith=function(str,_1ec,_1ed){ -if(_1ed){ +dojo.string.startsWith=function(str,_1f6,_1f7){ +if(_1f7){ str=str.toLowerCase(); -_1ec=_1ec.toLowerCase(); +_1f6=_1f6.toLowerCase(); } -return str.indexOf(_1ec)==0; +return str.indexOf(_1f6)==0; }; dojo.string.startsWithAny=function(str){ for(var i=1;i0){ -return _216[0]; +if(_224&&_225.length>0){ +return _225[0]; } node=node.parentNode; } -if(_215){ +if(_224){ return null; } -return _216; +return _225; }; -dojo.dom.getAncestorsByTag=function(node,tag,_21a){ +dojo.dom.getAncestorsByTag=function(node,tag,_229){ tag=tag.toLowerCase(); return dojo.dom.getAncestors(node,function(el){ return ((el.tagName)&&(el.tagName.toLowerCase()==tag)); -},_21a); +},_229); }; dojo.dom.getFirstAncestorByTag=function(node,tag){ return dojo.dom.getAncestorsByTag(node,tag,true); }; -dojo.dom.isDescendantOf=function(node,_21f,_220){ -if(_220&&node){ +dojo.dom.isDescendantOf=function(node,_22e,_22f){ +if(_22f&&node){ node=node.parentNode; } while(node){ -if(node==_21f){ +if(node==_22e){ return true; } node=node.parentNode; @@ -2085,12 +2157,12 @@ }; dojo.dom.createDocument=function(){ var doc=null; -var _223=dojo.doc(); +var _232=dojo.doc(); if(!dj_undef("ActiveXObject")){ -var _224=["MSXML2","Microsoft","MSXML","MSXML3"]; -for(var i=0;i<_224.length;i++){ +var _233=["MSXML2","Microsoft","MSXML","MSXML3"]; +for(var i=0;i<_233.length;i++){ try{ -doc=new ActiveXObject(_224[i]+".XMLDOM"); +doc=new ActiveXObject(_233[i]+".XMLDOM"); } catch(e){ } @@ -2099,80 +2171,80 @@ } } }else{ -if((_223.implementation)&&(_223.implementation.createDocument)){ -doc=_223.implementation.createDocument("","",null); +if((_232.implementation)&&(_232.implementation.createDocument)){ +doc=_232.implementation.createDocument("","",null); } } return doc; }; -dojo.dom.createDocumentFromText=function(str,_227){ -if(!_227){ -_227="text/xml"; +dojo.dom.createDocumentFromText=function(str,_236){ +if(!_236){ +_236="text/xml"; } if(!dj_undef("DOMParser")){ -var _228=new DOMParser(); -return _228.parseFromString(str,_227); +var _237=new DOMParser(); +return _237.parseFromString(str,_236); }else{ if(!dj_undef("ActiveXObject")){ -var _229=dojo.dom.createDocument(); -if(_229){ -_229.async=false; -_229.loadXML(str); -return _229; +var _238=dojo.dom.createDocument(); +if(_238){ +_238.async=false; +_238.loadXML(str); +return _238; }else{ dojo.debug("toXml didn't work?"); } }else{ -var _22a=dojo.doc(); -if(_22a.createElement){ -var tmp=_22a.createElement("xml"); +var _239=dojo.doc(); +if(_239.createElement){ +var tmp=_239.createElement("xml"); tmp.innerHTML=str; -if(_22a.implementation&&_22a.implementation.createDocument){ -var _22c=_22a.implementation.createDocument("foo","",null); +if(_239.implementation&&_239.implementation.createDocument){ +var _23b=_239.implementation.createDocument("foo","",null); for(var i=0;i1){ -var _244=dojo.doc(); -dojo.dom.replaceChildren(node,_244.createTextNode(text)); +var _250=dojo.doc(); +dojo.dom.replaceChildren(node,_250.createTextNode(text)); return text; }else{ if(node.textContent!=undefined){ return node.textContent; } -var _245=""; +var _251=""; if(node==null){ -return _245; +return _251; } for(var i=0;i=2&&_25d==this._getUrlQuery(this.historyStack[this.historyStack.length-2].url)){ +if(this.historyStack.length>=2&&_269==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)){ +if(this.forwardStack.length>0&&_269==this._getUrlQuery(this.forwardStack[this.forwardStack.length-1].url)){ this.handleForwardButton(); } } } },handleBackButton:function(){ -var _25e=this.historyStack.pop(); -if(!_25e){ +var _26a=this.historyStack.pop(); +if(!_26a){ return; } var last=this.historyStack[this.historyStack.length-1]; @@ -2419,7 +2483,7 @@ } } } -this.forwardStack.push(_25e); +this.forwardStack.push(_26a); },handleForwardButton:function(){ var last=this.forwardStack.pop(); if(!last){ @@ -2440,11 +2504,11 @@ },_createState:function(url,args,hash){ return {"url":url,"kwArgs":args,"urlHash":hash}; },_getUrlQuery:function(url){ -var _265=url.split("?"); -if(_265.length<2){ +var _271=url.split("?"); +if(_271.length<2){ return null; }else{ -return _265[1]; +return _271[1]; } },_loadIframeHistory:function(){ var url=dojo.hostenv.getBaseScriptUri()+"iframe_history.html?"+(new Date()).getTime(); @@ -2453,40 +2517,34 @@ return url; }}; dojo.provide("dojo.io.BrowserIO"); +if(!dj_undef("window")){ dojo.io.checkChildrenForFile=function(node){ -var _268=false; -var _269=node.getElementsByTagName("input"); -dojo.lang.forEach(_269,function(_26a){ -if(_268){ +var _274=false; +var _275=node.getElementsByTagName("input"); +dojo.lang.forEach(_275,function(_276){ +if(_274){ return; } -if(_26a.getAttribute("type")=="file"){ -_268=true; +if(_276.getAttribute("type")=="file"){ +_274=true; } }); -return _268; +return _274; }; -dojo.io.formHasFile=function(_26b){ -return dojo.io.checkChildrenForFile(_26b); +dojo.io.formHasFile=function(_277){ +return dojo.io.checkChildrenForFile(_277); }; -dojo.io.updateNode=function(node,_26d){ +dojo.io.updateNode=function(node,_279){ node=dojo.byId(node); -var args=_26d; -if(dojo.lang.isString(_26d)){ -args={url:_26d}; +var args=_279; +if(dojo.lang.isString(_279)){ +args={url:_279}; } args.mimetype="text/html"; args.load=function(t,d,e){ while(node.firstChild){ -if(dojo["event"]){ -try{ -dojo.event.browser.clean(node.firstChild); +dojo.dom.destroyNode(node.firstChild); } -catch(e){ -} -} -node.removeChild(node.firstChild); -} node.innerHTML=d; }; dojo.io.bind(args); @@ -2495,49 +2553,49 @@ 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.io.encodeForm=function(_280,_281,_282){ +if((!_280)||(!_280.tagName)||(!_280.tagName.toLowerCase()=="form")){ dojo.raise("Attempted to encode a non-form element."); } -if(!_276){ -_276=dojo.io.formFilter; +if(!_282){ +_282=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)){ +var enc=/utf/i.test(_281||"")?encodeURIComponent:dojo.string.encodeAscii; +var _284=[]; +for(var i=0;i<_280.elements.length;i++){ +var elm=_280.elements[i]; +if(!elm||elm.tagName.toLowerCase()=="fieldset"||!_282(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(); +if(_2ab.method.toLowerCase()=="head"){ +var _2b1=http.getAllResponseHeaders(); ret={}; ret.toString=function(){ -return _2a5; +return _2b1; }; -var _2a6=_2a5.split(/[\r\n]+/g); -for(var i=0;i<_2a6.length;i++){ -var pair=_2a6[i].match(/^([^:]+)\s*:\s*(.+)$/i); +var _2b2=_2b1.split(/[\r\n]+/g); +for(var i=0;i<_2b2.length;i++){ +var pair=_2b2[i].match(/^([^:]+)\s*:\s*(.+)$/i); if(pair){ ret[pair[1]]=pair[2]; } } }else{ -if(_29f.mimetype=="text/javascript"){ +if(_2ab.mimetype=="text/javascript"){ try{ ret=dj_eval(http.responseText); } @@ -2672,7 +2730,7 @@ ret=null; } }else{ -if(_29f.mimetype=="text/json"||_29f.mimetype=="application/json"){ +if(_2ab.mimetype=="text/json"||_2ab.mimetype=="application/json"){ try{ ret=dj_eval("("+http.responseText+")"); } @@ -2682,7 +2740,7 @@ ret=false; } }else{ -if((_29f.mimetype=="application/xml")||(_29f.mimetype=="text/xml")){ +if((_2ab.mimetype=="application/xml")||(_2ab.mimetype=="text/xml")){ ret=http.responseXML; if(!ret||typeof ret=="string"||!http.getResponseHeader("Content-Type")){ ret=dojo.dom.createDocumentFromText(http.responseText); @@ -2693,22 +2751,22 @@ } } } -if(_2a3){ -addToCache(url,_2a2,_29f.method,http); +if(_2af){ +addToCache(url,_2ae,_2ab.method,http); } -_29f[(typeof _29f.load=="function")?"load":"handle"]("load",ret,http,_29f); +_2ab[(typeof _2ab.load=="function")?"load":"handle"]("load",ret,http,_2ab); }else{ -var _2a9=new dojo.io.Error("XMLHttpTransport Error: "+http.status+" "+http.statusText); -_29f[(typeof _29f.error=="function")?"error":"handle"]("error",_2a9,http,_29f); +var _2b5=new dojo.io.Error("XMLHttpTransport Error: "+http.status+" "+http.statusText); +_2ab[(typeof _2ab.error=="function")?"error":"handle"]("error",_2b5,http,_2ab); } } -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]; +function setHeaders(http,_2b7){ +if(_2b7["headers"]){ +for(var _2b8 in _2b7["headers"]){ +if(_2b8.toLowerCase()=="content-type"&&!_2b7["contentType"]){ +_2b7["contentType"]=_2b7["headers"][_2b8]; }else{ -http.setRequestHeader(_2ac,_2ab["headers"][_2ac]); +http.setRequestHeader(_2b8,_2b7["headers"][_2b8]); } } } @@ -2722,7 +2780,7 @@ }; this.watchInFlight=function(){ var now=null; -if(!dojo.hostenv._blockAsync&&!_293._blockAsync){ +if(!dojo.hostenv._blockAsync&&!_29f._blockAsync){ for(var x=this.inFlight.length-1;x>=0;x--){ try{ var tif=this.inFlight[x]; @@ -2750,8 +2808,8 @@ } catch(e){ try{ -var _2b0=new dojo.io.Error("XMLHttpTransport.watchInFlight Error: "+e); -tif.req[(typeof tif.req.error=="function")?"error":"handle"]("error",_2b0,tif.http,tif.req); +var _2bc=new dojo.io.Error("XMLHttpTransport.watchInFlight Error: "+e); +tif.req[(typeof tif.req.error=="function")?"error":"handle"]("error",_2bc,tif.http,tif.req); } catch(e2){ dojo.debug("XMLHttpTransport error callback failed: "+e2); @@ -2766,161 +2824,161 @@ } this.inFlightTimer=setTimeout("dojo.io.XMLHTTPTransport.watchInFlight();",10); }; -var _2b1=dojo.hostenv.getXmlhttpObject()?true:false; -this.canHandle=function(_2b2){ -return _2b1&&dojo.lang.inArray(["text/plain","text/html","application/xml","text/xml","text/javascript","text/json","application/json"],(_2b2["mimetype"].toLowerCase()||""))&&!(_2b2["formNode"]&&dojo.io.formHasFile(_2b2["formNode"])); +var _2bd=dojo.hostenv.getXmlhttpObject()?true:false; +this.canHandle=function(_2be){ +return _2bd&&dojo.lang.inArray(["text/plain","text/html","application/xml","text/xml","text/javascript","text/json","application/json"],(_2be["mimetype"].toLowerCase()||""))&&!(_2be["formNode"]&&dojo.io.formHasFile(_2be["formNode"])); }; this.multipartBoundary="45309FFF-BD65-4d50-99C9-36986896A96F"; -this.bind=function(_2b3){ -if(!_2b3["url"]){ -if(!_2b3["formNode"]&&(_2b3["backButton"]||_2b3["back"]||_2b3["changeUrl"]||_2b3["watchForURL"])&&(!djConfig.preventBackButtonFix)){ +this.bind=function(_2bf){ +if(!_2bf["url"]){ +if(!_2bf["formNode"]&&(_2bf["backButton"]||_2bf["back"]||_2bf["changeUrl"]||_2bf["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(_2b3); +dojo.undo.browser.addToHistory(_2bf); return true; } } -var url=_2b3.url; -var _2b5=""; -if(_2b3["formNode"]){ -var ta=_2b3.formNode.getAttribute("action"); -if((ta)&&(!_2b3["url"])){ +var url=_2bf.url; +var _2c1=""; +if(_2bf["formNode"]){ +var ta=_2bf.formNode.getAttribute("action"); +if((ta)&&(!_2bf["url"])){ url=ta; } -var tp=_2b3.formNode.getAttribute("method"); -if((tp)&&(!_2b3["method"])){ -_2b3.method=tp; +var tp=_2bf.formNode.getAttribute("method"); +if((tp)&&(!_2bf["method"])){ +_2bf.method=tp; } -_2b5+=dojo.io.encodeForm(_2b3.formNode,_2b3.encoding,_2b3["formFilter"]); +_2c1+=dojo.io.encodeForm(_2bf.formNode,_2bf.encoding,_2bf["formFilter"]); } if(url.indexOf("#")>-1){ dojo.debug("Warning: dojo.io.bind: stripping hash values from url:",url); url=url.split("#")[0]; } -if(_2b3["file"]){ -_2b3.method="post"; +if(_2bf["file"]){ +_2bf.method="post"; } -if(!_2b3["method"]){ -_2b3.method="get"; +if(!_2bf["method"]){ +_2bf.method="get"; } -if(_2b3.method.toLowerCase()=="get"){ -_2b3.multipart=false; +if(_2bf.method.toLowerCase()=="get"){ +_2bf.multipart=false; }else{ -if(_2b3["file"]){ -_2b3.multipart=true; +if(_2bf["file"]){ +_2bf.multipart=true; }else{ -if(!_2b3["multipart"]){ -_2b3.multipart=false; +if(!_2bf["multipart"]){ +_2bf.multipart=false; } } } -if(_2b3["backButton"]||_2b3["back"]||_2b3["changeUrl"]){ -dojo.undo.browser.addToHistory(_2b3); +if(_2bf["backButton"]||_2bf["back"]||_2bf["changeUrl"]){ +dojo.undo.browser.addToHistory(_2bf); } -var _2b8=_2b3["content"]||{}; -if(_2b3.sendTransport){ -_2b8["dojo.transport"]="xmlhttp"; +var _2c4=_2bf["content"]||{}; +if(_2bf.sendTransport){ +_2c4["dojo.transport"]="xmlhttp"; } do{ -if(_2b3.postContent){ -_2b5=_2b3.postContent; +if(_2bf.postContent){ +_2c1=_2bf.postContent; break; } -if(_2b8){ -_2b5+=dojo.io.argsFromMap(_2b8,_2b3.encoding); +if(_2c4){ +_2c1+=dojo.io.argsFromMap(_2c4,_2bf.encoding); } -if(_2b3.method.toLowerCase()=="get"||!_2b3.multipart){ +if(_2bf.method.toLowerCase()=="get"||!_2bf.multipart){ break; } var t=[]; -if(_2b5.length){ -var q=_2b5.split("&"); +if(_2c1.length){ +var q=_2c1.split("&"); for(var i=0;i-1?"&":"?")+_2b5; +var _2d1=url; +if(_2c1!=""){ +_2d1+=(_2d1.indexOf("?")>-1?"&":"?")+_2c1; } -if(_2bf){ -_2c5+=(dojo.string.endsWithAny(_2c5,"?","&")?"":(_2c5.indexOf("?")>-1?"&":"?"))+"dojo.preventCache="+new Date().valueOf(); +if(_2cb){ +_2d1+=(dojo.string.endsWithAny(_2d1,"?","&")?"":(_2d1.indexOf("?")>-1?"&":"?"))+"dojo.preventCache="+new Date().valueOf(); } -if(!_2b3.user){ -http.open(_2b3.method.toUpperCase(),_2c5,_2be); +if(!_2bf.user){ +http.open(_2bf.method.toUpperCase(),_2d1,_2ca); }else{ -http.open(_2b3.method.toUpperCase(),_2c5,_2be,_2b3.user,_2b3.password); +http.open(_2bf.method.toUpperCase(),_2d1,_2ca,_2bf.user,_2bf.password); } -setHeaders(http,_2b3); +setHeaders(http,_2bf); try{ http.send(null); } catch(e){ if(typeof http.abort=="function"){ http.abort(); } -doLoad(_2b3,{status:404},url,_2b5,_2c0); +doLoad(_2bf,{status:404},url,_2c1,_2cc); } } -if(!_2be){ -doLoad(_2b3,http,url,_2b5,_2c0); -_293._blockAsync=false; +if(!_2ca){ +doLoad(_2bf,http,url,_2c1,_2cc); +_29f._blockAsync=false; } -_2b3.abort=function(){ +_2bf.abort=function(){ try{ http._aborted=true; } @@ -2932,88 +2990,89 @@ }; 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){ +dojo.io.cookie.setCookie=function(name,_2d3,days,path,_2d6,_2d7){ +var _2d8=-1; +if((typeof days=="number")&&(days>=0)){ var d=new Date(); d.setTime(d.getTime()+(days*24*60*60*1000)); -_2cc=d.toGMTString(); +_2d8=d.toGMTString(); } -_2c7=escape(_2c7); -document.cookie=name+"="+_2c7+";"+(_2cc!=-1?" expires="+_2cc+";":"")+(path?"path="+path:"")+(_2ca?"; domain="+_2ca:"")+(_2cb?"; secure":""); +_2d3=escape(_2d3); +document.cookie=name+"="+_2d3+";"+(_2d8!=-1?" expires="+_2d8+";":"")+(path?"path="+path:"")+(_2d6?"; domain="+_2d6:"")+(_2d7?"; 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(";"); +var _2dc=document.cookie.substring(idx+name.length+1); +var end=_2dc.indexOf(";"); if(end==-1){ -end=_2d0.length; +end=_2dc.length; } -_2d0=_2d0.substring(0,end); -_2d0=unescape(_2d0); -return _2d0; +_2dc=_2dc.substring(0,end); +_2dc=unescape(_2dc); +return _2dc; }; 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){ +dojo.io.cookie.setObjectCookie=function(name,obj,days,path,_2e3,_2e4,_2e5){ if(arguments.length==5){ -_2d9=_2d7; -_2d7=null; -_2d8=null; +_2e5=_2e3; +_2e3=null; +_2e4=null; } -var _2da=[],_2db,_2dc=""; -if(!_2d9){ -_2db=dojo.io.cookie.getObjectCookie(name); +var _2e6=[],_2e7,_2e8=""; +if(!_2e5){ +_2e7=dojo.io.cookie.getObjectCookie(name); } if(days>=0){ -if(!_2db){ -_2db={}; +if(!_2e7){ +_2e7={}; } for(var prop in obj){ -if(prop==null){ -delete _2db[prop]; +if(obj[prop]==null){ +delete _2e7[prop]; }else{ -if(typeof obj[prop]=="string"||typeof obj[prop]=="number"){ -_2db[prop]=obj[prop]; +if((typeof obj[prop]=="string")||(typeof obj[prop]=="number")){ +_2e7[prop]=obj[prop]; } } } prop=null; -for(var prop in _2db){ -_2da.push(escape(prop)+"="+escape(_2db[prop])); +for(var prop in _2e7){ +_2e6.push(escape(prop)+"="+escape(_2e7[prop])); } -_2dc=_2da.join("&"); +_2e8=_2e6.join("&"); } -dojo.io.cookie.setCookie(name,_2dc,days,path,_2d7,_2d8); +dojo.io.cookie.setCookie(name,_2e8,days,path,_2e3,_2e4); }; 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]); +var _2eb=null,_2ec=dojo.io.cookie.getCookie(name); +if(_2ec){ +_2eb={}; +var _2ed=_2ec.split("&"); +for(var i=0;i<_2ed.length;i++){ +var pair=_2ed[i].split("="); +var _2f0=pair[1]; +if(isNaN(_2f0)){ +_2f0=unescape(pair[1]); } -_2df[unescape(pair[0])]=_2e4; +_2eb[unescape(pair[0])]=_2f0; } } -return _2df; +return _2eb; }; 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"); +var _2f1=dojo.io.cookie.getCookie("__TestingYourBrowserForCookieSupport__"); +navigator.cookieEnabled=(_2f1=="CookiesAllowed"); if(navigator.cookieEnabled){ this.deleteCookie("__TestingYourBrowserForCookieSupport__"); } @@ -3024,12 +3083,10 @@ 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){ +function interpolateArgs(args,_2f3){ 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){ @@ -3056,14 +3113,14 @@ ao.adviceType="after"; ao.srcObj=args[0]; ao.srcFunc=args[1]; -var _2ea=dl.nameAnonFunc(args[2],ao.adviceObj,_2e7); -ao.adviceFunc=_2ea; +var _2f6=dl.nameAnonFunc(args[2],ao.adviceObj,_2f3); +ao.adviceFunc=_2f6; }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; +var _2f6=dl.nameAnonFunc(args[0],ao.srcObj,_2f3); +ao.srcFunc=_2f6; ao.adviceObj=args[1]; ao.adviceFunc=args[2]; } @@ -3089,17 +3146,17 @@ 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; +var _2f6=dl.nameAnonFunc(args[1],dj_global,_2f3); +ao.srcFunc=_2f6; 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); +var _2f6=dl.nameAnonFunc(args[3],dj_global,_2f3); ao.adviceObj=dj_global; -ao.adviceFunc=_2ea; +ao.adviceFunc=_2f6; }else{ if(dl.isObject(args[1])){ ao.srcObj=args[1]; @@ -3146,8 +3203,8 @@ break; } if(dl.isFunction(ao.aroundFunc)){ -var _2ea=dl.nameAnonFunc(ao.aroundFunc,ao.aroundObj,_2e7); -ao.aroundFunc=_2ea; +var _2f6=dl.nameAnonFunc(ao.aroundFunc,ao.aroundObj,_2f3); +ao.aroundFunc=_2f6; } if(dl.isFunction(ao.srcFunc)){ ao.srcFunc=dl.getNameInObj(ao.srcObj,ao.srcFunc); @@ -3184,17 +3241,17 @@ ao.srcFunc="onkeypress"; } if(dojo.lang.isArray(ao.srcObj)&&ao.srcObj!=""){ -var _2ec={}; +var _2f8={}; for(var x in ao){ -_2ec[x]=ao[x]; +_2f8[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)); +_2f8.srcObj=src; +mjps.push(dojo.event.connect.call(dojo.event,_2f8)); }); return mjps; } @@ -3206,20 +3263,20 @@ return mjp; }; this.log=function(a1,a2){ -var _2f4; +var _300; if((arguments.length==1)&&(typeof a1=="object")){ -_2f4=a1; +_300=a1; }else{ -_2f4={srcObj:a1,srcFunc:a2}; +_300={srcObj:a1,srcFunc:a2}; } -_2f4.adviceFunc=function(){ -var _2f5=[]; +_300.adviceFunc=function(){ +var _301=[]; for(var x=0;x0)){ -dojo.lang.forEach(this.before.concat(new Array()),_32b); +dojo.lang.forEach(this.before.concat(new Array()),_337); } -var _32c; +var _338; try{ if((this["around"])&&(this.around.length>0)){ var mi=new dojo.event.MethodInvocation(this,obj,args); -_32c=mi.proceed(); +_338=mi.proceed(); }else{ if(this.methodfunc){ -_32c=this.object[this.methodname].apply(this.object,args); +_338=this.object[this.methodname].apply(this.object,args); } } } catch(e){ if(!this.squelch){ +dojo.debug(e,"when calling",this.methodname,"on",this.object,"with arguments",args); dojo.raise(e); } } if((this["after"])&&(this.after.length>0)){ -dojo.lang.forEach(this.after.concat(new Array()),_32b); +dojo.lang.forEach(this.after.concat(new Array()),_337); } -return (this.methodfunc)?_32c:null; +return (this.methodfunc)?_338:null; },getArr:function(kind){ var type="after"; if((typeof kind=="string")&&(kind.indexOf("before")!=-1)){ @@ -3501,38 +3563,38 @@ 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); +},addAdvice:function(_33d,_33e,_33f,_340,_341,_342,once,_344,rate,_346){ +var arr=this.getArr(_341); if(!arr){ dojo.raise("bad this: "+this); } -var ao=[_331,_332,_333,_334,_338,rate,_33a]; +var ao=[_33d,_33e,_33f,_340,_344,rate,_346]; if(once){ -if(this.hasAdvice(_331,_332,_335,arr)>=0){ +if(this.hasAdvice(_33d,_33e,_341,arr)>=0){ return; } } -if(_336=="first"){ +if(_342=="first"){ arr.unshift(ao); }else{ arr.push(ao); } -},hasAdvice:function(_33d,_33e,_33f,arr){ +},hasAdvice:function(_349,_34a,_34b,arr){ if(!arr){ -arr=this.getArr(_33f); +arr=this.getArr(_34b); } var ind=-1; for(var x=0;x=0;i=i-1){ var el=na[i]; try{ @@ -3678,6 +3740,15 @@ } catch(e){ } +if(dojo.widget){ +for(var name in dojo.widget._templateCache){ +if(dojo.widget._templateCache[name].node){ +dojo.dom.destroyNode(dojo.widget._templateCache[name].node); +dojo.widget._templateCache[name].node=null; +delete dojo.widget._templateCache[name].node; +} +} +} try{ window.onload=null; } @@ -3692,9 +3763,9 @@ }); } dojo.event.browser=new function(){ -var _373=0; -this.normalizedEventName=function(_374){ -switch(_374){ +var _380=0; +this.normalizedEventName=function(_381){ +switch(_381){ case "CheckboxStateChange": case "DOMAttrModified": case "DOMMenuItemActive": @@ -3703,10 +3774,10 @@ case "DOMNodeInserted": case "DOMNodeRemoved": case "RadioStateChange": -return _374; +return _381; break; default: -return _374.toLowerCase(); +return _381.toLowerCase(); break; } }; @@ -3725,93 +3796,93 @@ node.__clobberAttrs__=[]; } }; -this.addClobberNodeAttrs=function(node,_378){ +this.addClobberNodeAttrs=function(node,_385){ if(!dojo.render.html.ie){ return; } this.addClobberNode(node); -for(var x=0;x<_378.length;x++){ -node.__clobberAttrs__.push(_378[x]); +for(var x=0;x<_385.length;x++){ +node.__clobberAttrs__.push(_385[x]); } }; -this.removeListener=function(node,_37b,fp,_37d){ -if(!_37d){ -var _37d=false; +this.removeListener=function(node,_388,fp,_38a){ +if(!_38a){ +var _38a=false; } -_37b=dojo.event.browser.normalizedEventName(_37b); -if((_37b=="onkey")||(_37b=="key")){ +_388=dojo.event.browser.normalizedEventName(_388); +if((_388=="onkey")||(_388=="key")){ if(dojo.render.html.ie){ -this.removeListener(node,"onkeydown",fp,_37d); +this.removeListener(node,"onkeydown",fp,_38a); } -_37b="onkeypress"; +_388="onkeypress"; } -if(_37b.substr(0,2)=="on"){ -_37b=_37b.substr(2); +if(_388.substr(0,2)=="on"){ +_388=_388.substr(2); } if(node.removeEventListener){ -node.removeEventListener(_37b,fp,_37d); +node.removeEventListener(_388,fp,_38a); } }; -this.addListener=function(node,_37f,fp,_381,_382){ +this.addListener=function(node,_38c,fp,_38e,_38f){ if(!node){ return; } -if(!_381){ -var _381=false; +if(!_38e){ +var _38e=false; } -_37f=dojo.event.browser.normalizedEventName(_37f); -if((_37f=="onkey")||(_37f=="key")){ +_38c=dojo.event.browser.normalizedEventName(_38c); +if((_38c=="onkey")||(_38c=="key")){ if(dojo.render.html.ie){ -this.addListener(node,"onkeydown",fp,_381,_382); +this.addListener(node,"onkeydown",fp,_38e,_38f); } -_37f="onkeypress"; +_38c="onkeypress"; } -if(_37f.substr(0,2)!="on"){ -_37f="on"+_37f; +if(_38c.substr(0,2)!="on"){ +_38c="on"+_38c; } -if(!_382){ -var _383=function(evt){ +if(!_38f){ +var _390=function(evt){ if(!evt){ evt=window.event; } var ret=fp(dojo.event.browser.fixEvent(evt,this)); -if(_381){ +if(_38e){ dojo.event.browser.stopEvent(evt); } return ret; }; }else{ -_383=fp; +_390=fp; } if(node.addEventListener){ -node.addEventListener(_37f.substr(2),_383,_381); -return _383; +node.addEventListener(_38c.substr(2),_390,_38e); +return _390; }else{ -if(typeof node[_37f]=="function"){ -var _386=node[_37f]; -node[_37f]=function(e){ -_386(e); -return _383(e); +if(typeof node[_38c]=="function"){ +var _393=node[_38c]; +node[_38c]=function(e){ +_393(e); +return _390(e); }; }else{ -node[_37f]=_383; +node[_38c]=_390; } if(dojo.render.html.ie){ -this.addClobberNodeAttrs(node,[_37f]); +this.addClobberNodeAttrs(node,[_38c]); } -return _383; +return _390; } }; this.isEvent=function(obj){ -return (typeof obj!="undefined")&&(typeof Event!="undefined")&&(obj.eventPhase); +return (typeof obj!="undefined")&&(obj)&&(typeof Event!="undefined")&&(obj.eventPhase); }; this.currentEvent=null; -this.callListener=function(_389,_38a){ -if(typeof _389!="function"){ -dojo.raise("listener not a function: "+_389); +this.callListener=function(_396,_397){ +if(typeof _396!="function"){ +dojo.raise("listener not a function: "+_396); } -dojo.event.browser.currentEvent.currentTarget=_38a; -return _389.call(_38a,dojo.event.browser.currentEvent); +dojo.event.browser.currentEvent.currentTarget=_397; +return _396.call(_397,dojo.event.browser.currentEvent); }; this._stopPropagation=function(){ dojo.event.browser.currentEvent.cancelBubble=true; @@ -3824,7 +3895,7 @@ for(var key in this.keys){ this.revKeys[this.keys[key]]=key; } -this.fixEvent=function(evt,_38d){ +this.fixEvent=function(evt,_39a){ if(!evt){ if(window["event"]){ evt=window.event; @@ -3901,14 +3972,14 @@ break; default: if(evt.ctrlKey||evt.altKey){ -var _38f=evt.keyCode; -if(_38f>=65&&_38f<=90&&evt.shiftKey==false){ -_38f+=32; +var _39c=evt.keyCode; +if(_39c>=65&&_39c<=90&&evt.shiftKey==false){ +_39c+=32; } -if(_38f>=1&&_38f<=26&&evt.ctrlKey){ -_38f+=96; +if(_39c>=1&&_39c<=26&&evt.ctrlKey){ +_39c+=96; } -evt.key=String.fromCharCode(_38f); +evt.key=String.fromCharCode(_39c); } } }else{ @@ -3934,11 +4005,11 @@ evt.key=evt.which; break; default: -var _38f=evt.which; +var _39c=evt.which; if((evt.ctrlKey||evt.altKey||evt.metaKey)&&(evt.which>=65&&evt.which<=90&&evt.shiftKey==false)){ -_38f+=32; +_39c+=32; } -evt.key=String.fromCharCode(_38f); +evt.key=String.fromCharCode(_39c); } } } @@ -3950,6 +4021,10 @@ }else{ if(dojo.render.html.safari){ switch(evt.keyCode){ +case 25: +evt.key=evt.KEY_TAB; +evt.shift=true; +break; case 63232: evt.key=evt.KEY_UP_ARROW; break; @@ -3962,8 +4037,69 @@ case 63235: evt.key=evt.KEY_RIGHT_ARROW; break; +case 63236: +evt.key=evt.KEY_F1; +break; +case 63237: +evt.key=evt.KEY_F2; +break; +case 63238: +evt.key=evt.KEY_F3; +break; +case 63239: +evt.key=evt.KEY_F4; +break; +case 63240: +evt.key=evt.KEY_F5; +break; +case 63241: +evt.key=evt.KEY_F6; +break; +case 63242: +evt.key=evt.KEY_F7; +break; +case 63243: +evt.key=evt.KEY_F8; +break; +case 63244: +evt.key=evt.KEY_F9; +break; +case 63245: +evt.key=evt.KEY_F10; +break; +case 63246: +evt.key=evt.KEY_F11; +break; +case 63247: +evt.key=evt.KEY_F12; +break; +case 63250: +evt.key=evt.KEY_PAUSE; +break; +case 63272: +evt.key=evt.KEY_DELETE; +break; +case 63273: +evt.key=evt.KEY_HOME; +break; +case 63275: +evt.key=evt.KEY_END; +break; +case 63276: +evt.key=evt.KEY_PAGE_UP; +break; +case 63277: +evt.key=evt.KEY_PAGE_DOWN; +break; +case 63302: +evt.key=evt.KEY_INSERT; +break; +case 63248: +case 63249: +case 63289: +break; default: -evt.key=evt.charCode>0?String.fromCharCode(evt.charCode):evt.keyCode; +evt.key=evt.charCode>=evt.KEY_SPACE?String.fromCharCode(evt.charCode):evt.keyCode; } }else{ evt.key=evt.charCode>0?String.fromCharCode(evt.charCode):evt.keyCode; @@ -3978,7 +4114,7 @@ evt.target=evt.srcElement; } if(!evt.currentTarget){ -evt.currentTarget=(_38d?_38d:evt.srcElement); +evt.currentTarget=(_39a?_39a:evt.srcElement); } if(!evt.layerX){ evt.layerX=evt.offsetX; @@ -3987,12 +4123,12 @@ 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; +var _39e=((dojo.render.html.ie55)||(doc["compatMode"]=="BackCompat"))?doc.body:doc.documentElement; if(!evt.pageX){ -evt.pageX=evt.clientX+(_391.scrollLeft||0); +evt.pageX=evt.clientX+(_39e.scrollLeft||0); } if(!evt.pageY){ -evt.pageY=evt.clientY+(_391.scrollTop||0); +evt.pageY=evt.clientY+(_39e.scrollTop||0); } if(evt.type=="mouseover"){ evt.relatedTarget=evt.fromElement; @@ -4009,8 +4145,8 @@ }; this.stopEvent=function(evt){ if(window.event){ -evt.returnValue=false; evt.cancelBubble=true; +evt.returnValue=false; }else{ evt.preventDefault(); evt.stopPropagation(); @@ -4050,8 +4186,8 @@ 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){ +dojo.extend(dojo.gfx.color.Color,{toRgb:function(_3a6){ +if(_3a6){ return this.toRgba(); }else{ return [this.r,this.g,this.b]; @@ -4064,62 +4200,62 @@ return "rgb("+this.toRgb().join()+")"; },toString:function(){ return this.toHex(); -},blend:function(_39a,_39b){ +},blend:function(_3a7,_3a8){ var rgb=null; -if(dojo.lang.isArray(_39a)){ -rgb=_39a; +if(dojo.lang.isArray(_3a7)){ +rgb=_3a7; }else{ -if(_39a instanceof dojo.gfx.color.Color){ -rgb=_39a.toRgb(); +if(_3a7 instanceof dojo.gfx.color.Color){ +rgb=_3a7.toRgb(); }else{ -rgb=new dojo.gfx.color.Color(_39a).toRgb(); +rgb=new dojo.gfx.color.Color(_3a7).toRgb(); } } -return dojo.gfx.color.blend(this.toRgb(),rgb,_39b); +return dojo.gfx.color.blend(this.toRgb(),rgb,_3a8); }}); 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){ +dojo.gfx.color.blend=function(a,b,_3ac){ if(typeof a=="string"){ -return dojo.gfx.color.blendHex(a,b,_39f); +return dojo.gfx.color.blendHex(a,b,_3ac); } -if(!_39f){ -_39f=0; +if(!_3ac){ +_3ac=0; } -_39f=Math.min(Math.max(-1,_39f),1); -_39f=((_39f+1)/2); +_3ac=Math.min(Math.max(-1,_3ac),1); +_3ac=((_3ac+1)/2); var c=[]; for(var x=0;x<3;x++){ -c[x]=parseInt(b[x]+((a[x]-b[x])*_39f)); +c[x]=parseInt(b[x]+((a[x]-b[x])*_3ac)); } 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.blendHex=function(a,b,_3b1){ +return dojo.gfx.color.rgb2hex(dojo.gfx.color.blend(dojo.gfx.color.hex2rgb(a),dojo.gfx.color.hex2rgb(b),_3b1)); }; -dojo.gfx.color.extractRGB=function(_3a5){ +dojo.gfx.color.extractRGB=function(_3b2){ 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); +_3b2=_3b2.toLowerCase(); +if(_3b2.indexOf("rgb")==0){ +var _3b4=_3b2.match(/rgba*\((\d+), *(\d+), *(\d+)/i); +var ret=_3b4.splice(1,3); return ret; }else{ -var _3a9=dojo.gfx.color.hex2rgb(_3a5); -if(_3a9){ -return _3a9; +var _3b6=dojo.gfx.color.hex2rgb(_3b2); +if(_3b6){ +return _3b6; }else{ -return dojo.gfx.color.named[_3a5]||[255,255,255]; +return dojo.gfx.color.named[_3b2]||[255,255,255]; } } }; dojo.gfx.color.hex2rgb=function(hex){ -var _3ab="0123456789ABCDEF"; +var _3b8="0123456789ABCDEF"; var rgb=new Array(3); if(hex.indexOf("#")==0){ hex=hex.substring(1); } hex=hex.toUpperCase(); -if(hex.replace(new RegExp("["+_3ab+"]","g"),"")!=""){ +if(hex.replace(new RegExp("["+_3b8+"]","g"),"")!=""){ return null; } if(hex.length==3){ @@ -4132,7 +4268,7 @@ rgb[2]=hex.substring(4); } for(var i=0;i0){ -this.duration=_3cb; +if(_3d8!=null&&_3d8>0){ +this.duration=_3d8; } -if(_3ce){ -this.repeatCount=_3ce; +if(_3db){ +this.repeatCount=_3db; } if(rate){ this.rate=rate; } -if(_3ca){ +if(_3d7){ dojo.lang.forEach(["handler","beforeBegin","onBegin","onEnd","onPlay","onStop","onAnimate"],function(item){ -if(_3ca[item]){ -this.connect(item,_3ca[item]); +if(_3d7[item]){ +this.connect(item,_3d7[item]); } },this); } -if(_3cd&&dojo.lang.isFunction(_3cd)){ -this.easing=_3cd; +if(_3da&&dojo.lang.isFunction(_3da)){ +this.easing=_3da; } }; 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){ +dojo.lang.extend(dojo.lfx.Animation,{_startTime:null,_endTime:null,_timer:null,_percent:0,_startRepeatCount:0,play:function(_3de,_3df){ +if(_3df){ clearTimeout(this._timer); this._active=false; this._paused=false; @@ -4275,10 +4411,10 @@ } this.fire("handler",["beforeBegin"]); this.fire("beforeBegin"); -if(_3d1>0){ +if(_3de>0){ setTimeout(dojo.lang.hitch(this,function(){ -this.play(null,_3d2); -}),_3d1); +this.play(null,_3df); +}),_3de); return this; } this._startTime=new Date().valueOf(); @@ -4289,16 +4425,16 @@ this._active=true; this._paused=false; var step=this._percent/100; -var _3d4=this.curve.getValue(step); +var _3e1=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",["begin",_3e1]); +this.fire("onBegin",[_3e1]); } -this.fire("handler",["play",_3d4]); -this.fire("onPlay",[_3d4]); +this.fire("handler",["play",_3e1]); +this.fire("onPlay",[_3e1]); this._cycle(); return this; },pause:function(){ @@ -4307,28 +4443,28 @@ return this; } this._paused=true; -var _3d5=this.curve.getValue(this._percent/100); -this.fire("handler",["pause",_3d5]); -this.fire("onPause",[_3d5]); +var _3e2=this.curve.getValue(this._percent/100); +this.fire("handler",["pause",_3e2]); +this.fire("onPause",[_3e2]); return this; -},gotoPercent:function(pct,_3d7){ +},gotoPercent:function(pct,_3e4){ clearTimeout(this._timer); this._active=true; this._paused=true; this._percent=pct; -if(_3d7){ +if(_3e4){ this.play(); } return this; -},stop:function(_3d8){ +},stop:function(_3e5){ clearTimeout(this._timer); var step=this._percent/100; -if(_3d8){ +if(_3e5){ step=1; } -var _3da=this.curve.getValue(step); -this.fire("handler",["stop",_3da]); -this.fire("onStop",[_3da]); +var _3e7=this.curve.getValue(step); +this.fire("handler",["stop",_3e7]); +this.fire("onStop",[_3e7]); this._active=false; this._paused=false; return this; @@ -4353,9 +4489,9 @@ 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]); +var _3ea=this.curve.getValue(step); +this.fire("handler",["animate",_3ea]); +this.fire("onAnimate",[_3ea]); if(step<1){ this._timer=setTimeout(dojo.lang.hitch(this,"_cycle"),this.rate); }else{ @@ -4379,76 +4515,76 @@ } return this; }}); -dojo.lfx.Combine=function(_3de){ +dojo.lfx.Combine=function(_3eb){ 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]; +var _3ec=arguments; +if(_3ec.length==1&&(dojo.lang.isArray(_3ec[0])||dojo.lang.isArrayLike(_3ec[0]))){ +_3ec=_3ec[0]; } -dojo.lang.forEach(_3df,function(anim){ +dojo.lang.forEach(_3ec,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){ +dojo.lang.extend(dojo.lfx.Combine,{_animsEnded:0,play:function(_3ee,_3ef){ if(!this._anims.length){ return this; } this.fire("beforeBegin"); -if(_3e1>0){ +if(_3ee>0){ setTimeout(dojo.lang.hitch(this,function(){ -this.play(null,_3e2); -}),_3e1); +this.play(null,_3ef); +}),_3ee); return this; } -if(_3e2||this._anims[0].percent==0){ +if(_3ef||this._anims[0].percent==0){ this.fire("onBegin"); } this.fire("onPlay"); -this._animsCall("play",null,_3e2); +this._animsCall("play",null,_3ef); return this; },pause:function(){ this.fire("onPause"); this._animsCall("pause"); return this; -},stop:function(_3e3){ +},stop:function(_3f0){ this.fire("onStop"); -this._animsCall("stop",_3e3); +this._animsCall("stop",_3f0); return this; },_onAnimsEnded:function(){ this._animsEnded++; if(this._animsEnded>=this._anims.length){ this.fire("onEnd"); } return this; -},_animsCall:function(_3e4){ +},_animsCall:function(_3f1){ var args=[]; if(arguments.length>1){ for(var i=1;i0){ +if(_3fc>0){ setTimeout(dojo.lang.hitch(this,function(){ -this.play(null,_3f0); -}),_3ef); +this.play(null,_3fd); +}),_3fc); return this; } -if(_3f1){ +if(_3fe){ if(this._currAnim==0){ this.fire("handler",["begin",this._currAnim]); this.fire("onBegin",[this._currAnim]); } this.fire("onPlay",[this._currAnim]); -_3f1.play(null,_3f0); +_3fe.play(null,_3fd); } return this; },pause:function(){ @@ -4495,22 +4631,22 @@ if(this._currAnim==-1){ this._currAnim=0; } -var _3f2=this._anims[this._currAnim]; -if(_3f2){ -if(!_3f2._active||_3f2._paused){ +var _3ff=this._anims[this._currAnim]; +if(_3ff){ +if(!_3ff._active||_3ff._paused){ this.play(); }else{ this.pause(); } } return this; },stop:function(){ -var _3f3=this._anims[this._currAnim]; -if(_3f3){ -_3f3.stop(); +var _400=this._anims[this._currAnim]; +if(_400){ +_400.stop(); this.fire("onStop",[this._currAnim]); } -return _3f3; +return _400; },_playNext:function(){ if(this._currAnim==-1||this._anims.length==0){ return this; @@ -4521,33 +4657,200 @@ } return this; }}); -dojo.lfx.combine=function(_3f4){ -var _3f5=arguments; +dojo.lfx.combine=function(_401){ +var _402=arguments; if(dojo.lang.isArray(arguments[0])){ -_3f5=arguments[0]; +_402=arguments[0]; } -if(_3f5.length==1){ -return _3f5[0]; +if(_402.length==1){ +return _402[0]; } -return new dojo.lfx.Combine(_3f5); +return new dojo.lfx.Combine(_402); }; -dojo.lfx.chain=function(_3f6){ -var _3f7=arguments; +dojo.lfx.chain=function(_403){ +var _404=arguments; if(dojo.lang.isArray(arguments[0])){ -_3f7=arguments[0]; +_404=arguments[0]; } -if(_3f7.length==1){ -return _3f7[0]; +if(_404.length==1){ +return _404[0]; } -return new dojo.lfx.Chain(_3f7); +return new dojo.lfx.Chain(_404); }; +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 _407=dojo.global(); +var _408=dojo.doc(); +var w=0; +var h=0; +if(dojo.render.html.mozilla){ +w=_408.documentElement.clientWidth; +h=_407.innerHeight; +}else{ +if(!dojo.render.html.opera&&_407.innerWidth){ +w=_407.innerWidth; +h=_407.innerHeight; +}else{ +if(!dojo.render.html.opera&&dojo.exists(_408,"documentElement.clientWidth")){ +var w2=_408.documentElement.clientWidth; +if(!w||w2&&w2=1){ +if(!_4c6){ +if(_4c5>=1){ if(h.ie){ dojo.html.clearOpacity(node); return; }else{ -_491=0.999999; +_4c5=0.999999; } }else{ -if(_491<0){ -_491=0; +if(_4c5<0){ +_4c5=0; } } } if(h.ie){ if(node.nodeName.toLowerCase()=="tr"){ var tds=node.getElementsByTagName("td"); for(var x=0;x0){ ret.x+=isNaN(n)?0:n; } -var m=_4db["offsetTop"]; +var m=_4e9["offsetTop"]; ret.y+=isNaN(m)?0:m; -_4db=_4db.offsetParent; -}while((_4db!=_4d9)&&(_4db!=null)); +_4e9=_4e9.offsetParent; +}while((_4e9!=_4e7)&&(_4e9!=null)); }else{ if(node["x"]&&node["y"]){ ret.x+=isNaN(node.x)?0:node.x; @@ -5531,22 +5677,22 @@ } } } -if(_4d0){ -var _4de=dojo.html.getScroll(); -ret.y+=_4de.top; -ret.x+=_4de.left; +if(_4de){ +var _4ec=dojo.html.getScroll(); +ret.y+=_4ec.top; +ret.x+=_4ec.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"); +var _4ed=[dojo.html.getPaddingExtent,dojo.html.getBorderExtent,dojo.html.getMarginExtent]; +if(_4e2>_4e3){ +for(var i=_4e3;i<_4e2;++i){ +ret.y+=_4ed[i](node,"top"); +ret.x+=_4ed[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"); +if(_4e2<_4e3){ +for(var i=_4e3;i>_4e2;--i){ +ret.y-=_4ed[i-1](node,"top"); +ret.x-=_4ed[i-1](node,"left"); } } } @@ -5557,12 +5703,12 @@ 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); +dojo.html._sumPixelValues=function(node,_4f1,_4f2){ +var _4f3=0; +for(var x=0;x<_4f1.length;x++){ +_4f3+=dojo.html.getPixelValue(node,_4f1[x],_4f2); } -return _4e5; +return _4f3; }; 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"))}; @@ -5584,13 +5730,13 @@ }; 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}; +var _500=dojo.html.getBorder(node); +return {width:pad.width+_500.width,height:pad.height+_500.height}; }; dojo.html.getBoxSizing=function(node){ var h=dojo.render.html; var bs=dojo.html.boxSizing; -if((h.ie)||(h.opera)){ +if(((h.ie)||(h.opera))&&node.nodeName!="IMG"){ var cm=document["compatMode"]; if((cm=="BackCompat")||(cm=="QuirksMode")){ return bs.BORDER_BOX; @@ -5601,11 +5747,11 @@ 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"); +var _505=dojo.html.getStyle(node,"-moz-box-sizing"); +if(!_505){ +_505=dojo.html.getStyle(node,"box-sizing"); } -return (_4f7?_4f7:bs.CONTENT_BOX); +return (_505?_505:bs.CONTENT_BOX); } }; dojo.html.isBorderBox=function(node){ @@ -5617,53 +5763,53 @@ }; 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}; +var _50a=dojo.html.getBorder(node); +return {width:box.width-_50a.width,height:box.height-_50a.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}; +var _50c=dojo.html.getPadBorder(node); +return {width:node.offsetWidth-_50c.width,height:node.offsetHeight-_50c.height}; }; dojo.html.setContentBox=function(node,args){ node=dojo.byId(node); -var _501=0; -var _502=0; +var _50f=0; +var _510=0; var isbb=dojo.html.isBorderBox(node); -var _504=(isbb?dojo.html.getPadBorder(node):{width:0,height:0}); +var _512=(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); +_50f=args.width+_512.width; +ret.width=dojo.html.setPositivePixelValue(node,"width",_50f); } if(typeof args.height!="undefined"){ -_502=args.height+_504.height; -ret.height=dojo.html.setPositivePixelValue(node,"height",_502); +_510=args.height+_512.height; +ret.height=dojo.html.setPositivePixelValue(node,"height",_510); } 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}; +var _515=dojo.html.getBorderBox(node); +var _516=dojo.html.getMargin(node); +return {width:_515.width+_516.width,height:_515.height+_516.height}; }; dojo.html.setMarginBox=function(node,args){ node=dojo.byId(node); -var _50b=0; -var _50c=0; +var _519=0; +var _51a=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 _51c=(!isbb?dojo.html.getPadBorder(node):{width:0,height:0}); +var _51d=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); +_519=args.width-_51c.width; +_519-=_51d.width; +ret.width=dojo.html.setPositivePixelValue(node,"width",_519); } if(typeof args.height!="undefined"){ -_50c=args.height-_50e.height; -_50c-=_50f.height; -ret.height=dojo.html.setPositivePixelValue(node,"height",_50c); +_51a=args.height-_51c.height; +_51a-=_51d.height; +ret.height=dojo.html.setPositivePixelValue(node,"height",_51a); } return ret; }; @@ -5681,31 +5827,31 @@ return dojo.html.getContentBox(node); } }; -dojo.html.toCoordinateObject=dojo.html.toCoordinateArray=function(_514,_515,_516){ -if(_514 instanceof Array||typeof _514=="array"){ +dojo.html.toCoordinateObject=dojo.html.toCoordinateArray=function(_522,_523,_524){ +if(_522 instanceof Array||typeof _522=="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(_522.length<4){ +_522.push(0); } -while(_514.length>4){ -_514.pop(); +while(_522.length>4){ +_522.pop(); } -var ret={left:_514[0],top:_514[1],width:_514[2],height:_514[3]}; +var ret={left:_522[0],top:_522[1],width:_522[2],height:_522[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}; +if(!_522.nodeType&&!(_522 instanceof String||typeof _522=="string")&&("width" in _522||"height" in _522||"left" in _522||"x" in _522||"top" in _522||"y" in _522)){ +var ret={left:_522.left||_522.x||0,top:_522.top||_522.y||0,width:_522.width||0,height:_522.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}; +var node=dojo.byId(_522); +var pos=dojo.html.abs(node,_523,_524); +var _528=dojo.html.getMarginBox(node); +var ret={left:pos.left,top:pos.top,width:_528.width,height:_528.height}; } } ret.x=ret.left; ret.y=ret.top; return ret; }; -dojo.html.setMarginBoxWidth=dojo.html.setOuterWidth=function(node,_51c){ +dojo.html.setMarginBoxWidth=dojo.html.setOuterWidth=function(node,_52a){ return dojo.html._callDeprecated("setMarginBoxWidth","setMarginBox",arguments,"width"); }; dojo.html.setMarginBoxHeight=dojo.html.setOuterHeight=function(){ @@ -5717,19 +5863,19 @@ dojo.html.getMarginBoxHeight=dojo.html.getOuterHeight=function(){ return dojo.html._callDeprecated("getMarginBoxHeight","getMarginBox",arguments,null,"height"); }; -dojo.html.getTotalOffset=function(node,type,_51f){ +dojo.html.getTotalOffset=function(node,type,_52d){ return dojo.html._callDeprecated("getTotalOffset","getAbsolutePosition",arguments,null,type); }; -dojo.html.getAbsoluteX=function(node,_521){ +dojo.html.getAbsoluteX=function(node,_52f){ return dojo.html._callDeprecated("getAbsoluteX","getAbsolutePosition",arguments,null,"x"); }; -dojo.html.getAbsoluteY=function(node,_523){ +dojo.html.getAbsoluteY=function(node,_531){ return dojo.html._callDeprecated("getAbsoluteY","getAbsolutePosition",arguments,null,"y"); }; -dojo.html.totalOffsetLeft=function(node,_525){ +dojo.html.totalOffsetLeft=function(node,_533){ return dojo.html._callDeprecated("totalOffsetLeft","getAbsolutePosition",arguments,null,"left"); }; -dojo.html.totalOffsetTop=function(node,_527){ +dojo.html.totalOffsetTop=function(node,_535){ return dojo.html._callDeprecated("totalOffsetTop","getAbsolutePosition",arguments,null,"top"); }; dojo.html.getMarginWidth=function(node){ @@ -5768,46 +5914,46 @@ 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){ +dojo.html.setContentBoxWidth=dojo.html.setContentWidth=function(node,_53f){ return dojo.html._callDeprecated("setContentBoxWidth","setContentBox",arguments,"width"); }; -dojo.html.setContentBoxHeight=dojo.html.setContentHeight=function(node,_533){ +dojo.html.setContentBoxHeight=dojo.html.setContentHeight=function(node,_541){ return dojo.html._callDeprecated("setContentBoxHeight","setContentBox",arguments,"height"); }; dojo.provide("dojo.lfx.html"); -dojo.lfx.html._byId=function(_534){ -if(!_534){ +dojo.lfx.html._byId=function(_542){ +if(!_542){ return []; } -if(dojo.lang.isArrayLike(_534)){ -if(!_534.alreadyChecked){ +if(dojo.lang.isArrayLike(_542)){ +if(!_542.alreadyChecked){ var n=[]; -dojo.lang.forEach(_534,function(node){ +dojo.lang.forEach(_542,function(node){ n.push(dojo.byId(node)); }); n.alreadyChecked=true; return n; }else{ -return _534; +return _542; } }else{ var n=[]; -n.push(dojo.byId(_534)); +n.push(dojo.byId(_542)); 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){ +dojo.lfx.html.propertyAnimation=function(_545,_546,_547,_548,_549){ +_545=dojo.lfx.html._byId(_545); +var _54a={"propertyMap":_546,"nodes":_545,"duration":_547,"easing":_548||dojo.lfx.easeDefault}; +var _54b=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]); +for(var _54f in pm){ +pm[_54f].property=_54f; +parr.push(pm[_54f]); } pm=args.propertyMap=parr; } @@ -5822,30 +5968,35 @@ }); } }; -var _543=function(_544){ -var _545=[]; -dojo.lang.forEach(_544,function(c){ -_545.push(Math.round(c)); +var _551=function(_552){ +var _553=[]; +dojo.lang.forEach(_552,function(c){ +_553.push(Math.round(c)); }); -return _545; +return _553; }; -var _547=function(n,_549){ +var _555=function(n,_557){ n=dojo.byId(n); if(!n||!n.style){ return; } -for(var s in _549){ +for(var s in _557){ +try{ if(s=="opacity"){ -dojo.html.setOpacity(n,_549[s]); +dojo.html.setOpacity(n,_557[s]); }else{ -n.style[s]=_549[s]; +n.style[s]=_557[s]; } } +catch(e){ +dojo.debug(e); +} +} }; -var _54b=function(_54c){ -this._properties=_54c; -this.diffs=new Array(_54c.length); -dojo.lang.forEach(_54c,function(prop,i){ +var _559=function(_55a){ +this._properties=_55a; +this.diffs=new Array(_55a.length); +dojo.lang.forEach(_55a,function(prop,i){ if(dojo.lang.isFunction(prop.start)){ prop.start=prop.start(prop,i); } @@ -5866,43 +6017,43 @@ this.getValue=function(n){ var ret={}; dojo.lang.forEach(this._properties,function(prop,i){ -var _553=null; +var _561=null; if(dojo.lang.isArray(prop.start)){ }else{ if(prop.start instanceof dojo.gfx.color.Color){ -_553=(prop.units||"rgb")+"("; +_561=(prop.units||"rgb")+"("; for(var j=0;j3){ -_5c4.pop(); +var _5d8=dojo.html.getStyle(node,"background-image"); +var _5d9=(bg=="transparent"||bg=="rgba(0, 0, 0, 0)"); +while(_5d6.length>3){ +_5d6.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){ +var rgb=new dojo.gfx.color.Color(_5d0); +var _5db=new dojo.gfx.color.Color(_5d6); +var anim=dojo.lfx.propertyAnimation(node,{"background-color":{start:rgb,end:_5db}},_5d1,_5d2,{"beforeBegin":function(){ +if(_5d8){ node.style.backgroundImage="none"; } node.style.backgroundColor="rgb("+rgb.toRgb().join(",")+")"; },"onEnd":function(){ -if(_5c6){ -node.style.backgroundImage=_5c6; +if(_5d8){ +node.style.backgroundImage=_5d8; } -if(_5c7){ +if(_5d9){ node.style.backgroundColor="transparent"; } -if(_5c1){ -_5c1(node,anim); +if(_5d3){ +_5d3(node,anim); } }}); -_5c2.push(anim); +_5d4.push(anim); }); -return dojo.lfx.combine(_5c2); +return dojo.lfx.combine(_5d4); }; -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){ +dojo.lfx.html.unhighlight=function(_5dd,_5de,_5df,_5e0,_5e1){ +_5dd=dojo.lfx.html._byId(_5dd); +var _5e2=[]; +dojo.lang.forEach(_5dd,function(node){ +var _5e4=new dojo.gfx.color.Color(dojo.html.getBackgroundColor(node)); +var rgb=new dojo.gfx.color.Color(_5de); +var _5e6=dojo.html.getStyle(node,"background-image"); +var anim=dojo.lfx.propertyAnimation(node,{"background-color":{start:_5e4,end:rgb}},_5df,_5e0,{"beforeBegin":function(){ +if(_5e6){ node.style.backgroundImage="none"; } -node.style.backgroundColor="rgb("+_5d2.toRgb().join(",")+")"; +node.style.backgroundColor="rgb("+_5e4.toRgb().join(",")+")"; },"onEnd":function(){ -if(_5cf){ -_5cf(node,anim); +if(_5e1){ +_5e1(node,anim); } }}); -_5d0.push(anim); +_5e2.push(anim); }); -return dojo.lfx.combine(_5d0); +return dojo.lfx.combine(_5e2); }; 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 -N -r1.1 -r1.2 --- openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/dojo.js.uncompressed.js 6 Nov 2006 14:37:19 -0000 1.1 +++ openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/dojo.js.uncompressed.js 25 Dec 2006 16:39:50 -0000 1.2 @@ -15,9 +15,9 @@ // TODOC: HOW TO DOC THE BELOW? // @global: djConfig -// summary: +// summary: // Application code can set the global 'djConfig' prior to loading -// the library to override certain global settings for how dojo works. +// 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 @@ -34,31 +34,31 @@ // 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. +// '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. +// 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: +// summary: // an alias for the top-level global object in the host environment // (e.g., the window object in a browser). -// description: +// 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: +// 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: +// description: // Refer to dojo.global() rather than referring to dj_global to ensure your // code runs correctly in managed contexts. var dj_currentContext = this; @@ -76,21 +76,21 @@ } // make sure djConfig is defined -if(dj_undef("djConfig", this)){ - var djConfig = {}; +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 = {}; +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: + // 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; @@ -102,8 +102,8 @@ //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]), + major: 0, minor: 4, patch: 1, flag: "", + revision: Number("$Rev: 6824 $".match(/[0-9]+/)[0]), toString: function(){ with(dojo.version){ return major + "." + minor + "." + patch + flag + " (" + revision + ")"; // String @@ -113,18 +113,18 @@ 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: + // description: // Returns null if 'object[name]' is not defined and 'create' is not true. - // Note: 'defined' and 'exists' are not the same concept. + // 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'. + // 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()'. @@ -142,8 +142,8 @@ // summary: Return the value of object at 'path' in the global scope, without using 'eval()'. // path: Path to an object, in the form "A.B.C". // create: If true, Objects will be created at any point along the 'path' that is undefined. - if(typeof path != "string"){ - return dojo.global(); + if(typeof path != "string"){ + return dojo.global(); } // fast path for no periods if(path.indexOf('.') == -1){ @@ -179,6 +179,8 @@ if(exception){ message = message + ": "+dojo.errorToString(exception); + }else{ + message = dojo.errorToString(message); } // print the message to the user if hostenv.println is defined @@ -193,7 +195,7 @@ dojo.debugShallow = function(obj){}; dojo.profile = { start: function(){}, end: function(){}, stop: function(){}, dump: function(){} }; -function dj_eval(/*String*/ scriptFragment){ +function dj_eval(/*String*/ scriptFragment){ // summary: Perform an evaluation in the global scope. Use this rather than calling 'eval()' directly. // description: Placed in a separate function to minimize size of trapped evaluation context. // note: @@ -266,11 +268,11 @@ */ dojo.hostenv = (function(){ // TODOC: HOW TO DOC THIS? - // summary: Provides encapsulation of behavior that changes across different 'host environments' + // summary: Provides encapsulation of behavior that changes across different 'host environments' // (different browsers, server via Rhino, etc). // description: None of these methods should ever be called directly by library users. // Use public methods such as 'loadModule' instead. - + // default configuration options var config = { isDebug: false, @@ -300,21 +302,21 @@ version_: '(unset)', - getName: function(){ + getName: function(){ // sumary: Return the name of the host environment. return this.name_; // String }, - getVersion: function(){ + getVersion: function(){ // summary: Return the version of the hostenv. return this.version_; // String }, getText: function(/*String*/ uri){ // summary: Read the plain/text contents at the specified 'uri'. - // description: - // If 'getText()' is not implemented, then it is necessary to override + // description: + // If 'getText()' is not implemented, then it is necessary to override // 'loadUri()' with an implementation that doesn't rely on it. dojo.unimplemented('getText', "uri=" + uri); @@ -328,7 +330,7 @@ // TODOC: HUH? This comment means nothing to me. What other scripts? Is this the path to other dojo libraries? // MAYBE: Return the base uri to scripts in the dojo library. ??? // return: Empty string or a path ending in '/'. - if(djConfig.baseScriptUri.length){ + if(djConfig.baseScriptUri.length){ return djConfig.baseScriptUri; } @@ -578,12 +580,11 @@ 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) + if((i==1) && !this.moduleHasPrefix(parentModule)){ + // Support default module directory (sibling of dojo) for top-level modules syms[0] = "../" + syms[0]; }else{ var parentModulePath = this.getModulePrefix(parentModule); @@ -879,7 +880,11 @@ // 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 + var result = locale ? locale.toLowerCase() : dojo.locale; + if(result == "root"){ + result = "ROOT"; + } + return result;// String }; dojo.hostenv.searchLocalePath = function(/*String*/locale, /*Boolean*/down, /*Function*/searchFunc){ @@ -944,7 +949,7 @@ dojo.hostenv.preloadLocalizations = function(){}; } -dojo.requireLocalization = function(/*String*/moduleName, /*String*/bundleName, /*String?*/locale){ +dojo.requireLocalization = function(/*String*/moduleName, /*String*/bundleName, /*String?*/locale, /*String?*/availableFlatLocales){ // summary: // Declares translated resources and loads them if necessary, in the same style as dojo.require. // Contents of the resource bundle are typically strings, but may be any name/value pair, @@ -953,6 +958,8 @@ // moduleName: name of the package containing the "nls" directory in which the bundle is found // bundleName: bundle name, i.e. the filename without the '.js' suffix // locale: the locale to load (optional) By default, the browser's user locale as defined by dojo.locale +// availableFlatLocales: A comma-separated list of the available, flattened locales for this bundle. +// This argument should only be set by the build process. // // description: // Load translated resource bundles provided underneath the "nls" directory within a package. @@ -991,53 +998,89 @@ // load these resources. dojo.hostenv.preloadLocalizations(); + var targetLocale = dojo.hostenv.normalizeLocale(locale); var bundlePackage = [moduleName, "nls", bundleName].join("."); //NOTE: When loading these resources, the packaging does not match what is on disk. This is an // implementation detail, as this is just a private data structure to hold the loaded resources. // e.g. tests/hello/nls/en-us/salutations.js is loaded as the object tests.hello.nls.salutations.en_us={...} // The structure on disk is intended to be most convenient for developers and translators, but in memory // it is more logical and efficient to store in a different order. Locales cannot use dashes, since the // resulting path will not evaluate as valid JS, so we translate them to underscores. + + //Find the best-match locale to load if we have available flat locales. + var bestLocale = ""; + if(availableFlatLocales){ + var flatLocales = availableFlatLocales.split(","); + for(var i = 0; i < flatLocales.length; i++){ + //Locale must match from start of string. + if(targetLocale.indexOf(flatLocales[i]) == 0){ + if(flatLocales[i].length > bestLocale.length){ + bestLocale = flatLocales[i]; + } + } + } + if(!bestLocale){ + bestLocale = "ROOT"; + } + } + //See if the desired locale is already loaded. + var tempLocale = availableFlatLocales ? bestLocale : targetLocale; var bundle = dojo.hostenv.findModule(bundlePackage); + var localizedBundle = null; if(bundle){ if(djConfig.localizationComplete && bundle._built){return;} - var jsLoc = dojo.hostenv.normalizeLocale(locale).replace('-', '_'); + var jsLoc = tempLocale.replace('-', '_'); var translationPackage = bundlePackage+"."+jsLoc; - if(dojo.hostenv.findModule(translationPackage)){return;} + localizedBundle = dojo.hostenv.findModule(translationPackage); } - bundle = dojo.hostenv.startPackage(bundlePackage); - var syms = dojo.hostenv.getModuleSymbols(moduleName); - var modpath = syms.concat("nls").join("/"); - var parent; - dojo.hostenv.searchLocalePath(locale, false, function(loc){ - var jsLoc = loc.replace('-', '_'); - var translationPackage = bundlePackage + "." + jsLoc; - var loaded = false; - if(!dojo.hostenv.findModule(translationPackage)){ - // Mark loaded whether it's found or not, so that further load attempts will not be made - dojo.hostenv.startPackage(translationPackage); - var module = [modpath]; - if(loc != "ROOT"){module.push(loc);} - module.push(bundleName); - var filespec = module.join("/") + '.js'; - loaded = dojo.hostenv.loadPath(filespec, null, function(hash){ - // Use singleton with prototype to point to parent bundle, then mix-in result from loadPath - var clazz = function(){}; - clazz.prototype = parent; - bundle[jsLoc] = new clazz(); - for(var j in hash){ bundle[jsLoc][j] = hash[j]; } - }); - }else{ - loaded = true; - } - if(loaded && bundle[jsLoc]){ - parent = bundle[jsLoc]; - }else{ - bundle[jsLoc] = parent; - } - }); + if(!localizedBundle){ + bundle = dojo.hostenv.startPackage(bundlePackage); + var syms = dojo.hostenv.getModuleSymbols(moduleName); + var modpath = syms.concat("nls").join("/"); + var parent; + + dojo.hostenv.searchLocalePath(tempLocale, availableFlatLocales, function(loc){ + var jsLoc = loc.replace('-', '_'); + var translationPackage = bundlePackage + "." + jsLoc; + var loaded = false; + if(!dojo.hostenv.findModule(translationPackage)){ + // Mark loaded whether it's found or not, so that further load attempts will not be made + dojo.hostenv.startPackage(translationPackage); + var module = [modpath]; + if(loc != "ROOT"){module.push(loc);} + module.push(bundleName); + var filespec = module.join("/") + '.js'; + loaded = dojo.hostenv.loadPath(filespec, null, function(hash){ + // Use singleton with prototype to point to parent bundle, then mix-in result from loadPath + var clazz = function(){}; + clazz.prototype = parent; + bundle[jsLoc] = new clazz(); + for(var j in hash){ bundle[jsLoc][j] = hash[j]; } + }); + }else{ + loaded = true; + } + if(loaded && bundle[jsLoc]){ + parent = bundle[jsLoc]; + }else{ + bundle[jsLoc] = parent; + } + + if(availableFlatLocales){ + //Stop the locale path searching if we know the availableFlatLocales, since + //the first call to this function will load the only bundle that is needed. + return true; + } + }); + } + + //Save the best locale bundle as the target locale bundle when we know the + //the available bundles. + if(availableFlatLocales && targetLocale != bestLocale){ + bundle[targetLocale.replace('-', '_')] = bundle[bestLocale.replace('-', '_')]; + } }; (function(){ @@ -1052,534 +1095,544 @@ } var req = dojo.requireLocalization; - dojo.requireLocalization = function(m, b, locale){ - req(m,b,locale); + dojo.requireLocalization = function(m, b, locale, availableFlatLocales){ + req(m,b,locale, availableFlatLocales); if(locale){return;} for(var i=0; i 1){ - var paramStr = params[1]; - var pairs = paramStr.split("&"); - for(var x in pairs){ - var sp = pairs[x].split("="); - // FIXME: is this eval dangerous? - if((sp[0].length > 9)&&(sp[0].substr(0, 9) == "djConfig.")){ - var opt = sp[0].substr(9); - try{ - djConfig[opt]=eval(sp[1]); - }catch(e){ - djConfig[opt]=sp[1]; + // attempt to figure out the path to dojo if it isn't set in the config + (function(){ + // before we get any further with the config options, try to pick them out + // of the URL. Most of this code is from NW + if(djConfig.allowQueryConfig){ + var baseUrl = document.location.toString(); // FIXME: use location.query instead? + var params = baseUrl.split("?", 2); + if(params.length > 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; + 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; + // 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; + 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; + 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; + 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(); + // 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; + dr.vml.capable=drh.ie; + drs.capable = f; 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.support.builtin = f; + var tdoc = window["document"]; + var tdi = tdoc["implementation"]; + + if((tdi)&&(tdi["hasFeature"])&&(tdi.hasFeature("org.w3c.dom.svg", "1.0"))){ drs.capable = t; drs.support.builtin = t; drs.support.plugin = f; } - } -})(); + // webkits after 420 support SVG natively. The test string is "AppleWebKit/420+" + if(drh.safari){ + var tmp = dua.split("AppleWebKit/")[1]; + var ver = parseFloat(tmp.split(" ")[0]); + if(ver >= 420){ + drs.capable = t; + drs.support.builtin = t; + drs.support.plugin = f; + } + }else{ + } + })(); -dojo.hostenv.startPackage("dojo.hostenv"); + dojo.hostenv.startPackage("dojo.hostenv"); -dojo.render.name = dojo.hostenv.name_ = 'browser'; -dojo.hostenv.searchIds = []; + 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']; + // 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; - } + dojo.hostenv.getXmlhttpObject = function(){ + // summary: does the work of portably generating a new XMLHTTPRequest object. + var http = null; + var last_e = null; + try{ http = new XMLHttpRequest(); }catch(e){} + if(!http){ + for(var i=0; i<3; ++i){ + var progid = dojo.hostenv._XMLHTTP_PROGIDS[i]; + try{ + http = new ActiveXObject(progid); + }catch(e){ + last_e = e; + } - if(http){ - dojo.hostenv._XMLHTTP_PROGIDS = [progid]; // so faster next time - break; + if(http){ + dojo.hostenv._XMLHTTP_PROGIDS = [progid]; // so faster next time + break; + } } + + /*if(http && !http.toString) { + http.toString = function() { "[object XMLHttpRequest]"; } + }*/ } - /*if(http && !http.toString) { - http.toString = function() { "[object XMLHttpRequest]"; } - }*/ - } + if(!http){ + return dojo.raise("XMLHTTP not available", last_e); + } - if(!http){ - return dojo.raise("XMLHTTP not available", last_e); + return http; // XMLHTTPRequest instance } - return http; -} + dojo.hostenv._blockAsync = false; + dojo.hostenv.getText = function(uri, async_cb, fail_ok){ + // summary: Read the contents of the specified uri and return those contents. + // uri: + // A relative or absolute uri. If absolute, it still must be in + // the same "domain" as we are. + // async_cb: + // If not specified, load synchronously. If specified, load + // asynchronously, and use async_cb as the progress handler which + // takes the xmlhttp object as its argument. If async_cb, this + // function returns null. + // fail_ok: + // Default false. If fail_ok and !async_cb and loading fails, + // return null instead of throwing. -/** - * 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; } + // 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(); + 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)); - } + 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); + 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; + 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; + } } - 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; + return http.responseText; // String + } + + dojo.hostenv.defaultDebugContainerId = 'dojoDebug'; + dojo.hostenv._println_buffer = []; + dojo.hostenv._println_safe = false; + dojo.hostenv.println = function(/*String*/line){ + // summary: + // prints the provided line to whatever logging container is + // available. If the page isn't loaded yet, the line may be added + // to a buffer for printing later. + if(!dojo.hostenv._println_safe){ + dojo.hostenv._println_buffer.push(line); }else{ - throw e; + 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; + } + } } } - this._blockAsync = false; - return http.responseText; -} + dojo.addOnLoad(function(){ + dojo.hostenv._println_safe = true; + while(dojo.hostenv._println_buffer.length > 0){ + dojo.hostenv.println(dojo.hostenv._println_buffer.shift()); + } + }); -/* - * 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"); + function dj_addNodeEvtHdlr(/*DomNode*/node, /*String*/evtName, /*Function*/fp){ + // summary: + // non-destructively adds the specified function to the node's + // evtName handler. + // node: the DomNode to add the handler to + // evtName: should be in the form "click" for "onclick" handlers + var oldHandler = node["on"+evtName] || function(){}; + node["on"+evtName] = function(){ + fp.apply(node, arguments); + oldHandler.apply(node, arguments); + } + return true; } - 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(); -} -*/ + // 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; + } -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; + var initFunc = function(){ + //perform initialization + if(dojo.render.html.ie){ + dojo.hostenv.makeWidgets(); } + }; + + if(dojo.hostenv.inFlightCount == 0){ + initFunc(); + dojo.hostenv.modulesLoaded(); + }else{ + //This else case should be xdomain loading. + //Make sure this is the first thing in the load listener array. + //Part of the dojo.addOnLoad guarantee is that when the listeners are notified, + //It means the DOM (or page) has loaded and that widgets have been parsed. + dojo.hostenv.modulesLoadedListeners.unshift(initFunc); } } -} -dojo.addOnLoad(function(){ - dojo.hostenv._println_safe = true; - while(dojo.hostenv._println_buffer.length > 0){ - dojo.hostenv.println(dojo.hostenv._println_buffer.shift()); - } -}); + // 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); + } -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); + // 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); } - 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; + // 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(); + } + }); } - 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); + 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 -// 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); + // 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); + }); } - // 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(); + dj_addNodeEvtHdlr(window, "unload", function(){ + dojo.hostenv.unloaded(); + if((!dojo.render.html.ie)||(dojo.render.html.ie && dojo.hostenv._unloading)){ + dojo.hostenv.unloaded(); } }); -} -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 + 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); + } -// IE WebControl hosted in an application can fire "beforeunload" and "unload" -// events when control visibility changes, causing Dojo to unload too soon. The -// following code fixes the problem -// Reference: http://support.microsoft.com/default.aspx?scid=kb;en-us;199155 -if(dojo.render.html.ie){ - dj_addNodeEvtHdlr(window, "beforeunload", function(){ - dojo.hostenv._unloading = true; - window.setTimeout(function() { - dojo.hostenv._unloading = false; - }, 0); - }); -} - -dj_addNodeEvtHdlr(window, "unload", function(){ - dojo.hostenv.unloaded(); - if((!dojo.render.html.ie)||(dojo.render.html.ie && dojo.hostenv._unloading)){ - dojo.hostenv.unloaded(); - } -}); - -dojo.hostenv.makeWidgets = function(){ - // you can put searchIds in djConfig and dojo.hostenv at the moment - // we should probably eventually move to one or the other - var sids = []; - if(djConfig.searchIds && djConfig.searchIds.length > 0) { - sids = sids.concat(djConfig.searchIds); - } - if(dojo.hostenv.searchIds && dojo.hostenv.searchIds.length > 0) { - sids = sids.concat(dojo.hostenv.searchIds); - } - - if((djConfig.parseWidgets)||(sids.length > 0)){ - if(dojo.evalObjPath("dojo.widget.Parse")){ - // we must do this on a delay to avoid: - // http://www.shaftek.org/blog/archives/000212.html - // (IE bug) - var parser = new dojo.xml.Parse(); - if(sids.length > 0){ - for(var x=0; x 0)){ + 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; x1; }); + // // returns false + // dojo.lang.every([1, 2, 3, 4], function(item){ return item>0; }); + // // returns true + return this._everyOrSome(true, arr, callback, thisObject); // Boolean + }, -dojo.lang.some = function(/*Array*/arr, /*Function*/callback, /*Object?*/thisObject){ - return this._everyOrSome(false, arr, callback, thisObject); // Boolean -} + some: function(/*Array*/arr, /*Function*/callback, /*Object?*/thisObject){ + // summary: + // determines whether or not any item in the array satisfies the + // condition implemented by callback. thisObject may be used to + // scope the call to callback. The function signature is derived + // from the JavaScript 1.6 Array.some() function. More + // information on this can be found here: + // http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:some + // examples: + // dojo.lang.some([1, 2, 3, 4], function(item){ return item>1; }); + // // returns true + // dojo.lang.some([1, 2, 3, 4], function(item){ return item<1; }); + // // returns false + return this._everyOrSome(false, arr, callback, thisObject); // Boolean + }, -dojo.lang.filter = function(/*Array*/arr, /*Function*/callback, /*Object?*/thisObject){ - var isString = dojo.lang.isString(arr); - if(isString){ /*arr: String*/arr = arr.split(""); } - var outArr; - if(Array.filter){ - outArr = Array.filter(arr, callback, thisObject); - } else { - if(!thisObject){ - if(arguments.length >= 3){ dojo.raise("thisObject doesn't exist!"); } - thisObject = dj_global; - } + filter: function(/*Array*/arr, /*Function*/callback, /*Object?*/thisObject){ + // summary: + // returns a new Array with those items from arr that match the + // condition implemented by callback.thisObject may be used to + // scope the call to callback. The function signature is derived + // from the JavaScript 1.6 Array.filter() function, although + // special accomidation is made in our implementation for strings. + // More information on the JS 1.6 API can be found here: + // http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:filter + // examples: + // dojo.lang.some([1, 2, 3, 4], function(item){ return item>1; }); + // // returns [2, 3, 4] + var isString = dojo.lang.isString(arr); + if(isString){ /*arr: String*/arr = arr.split(""); } + var outArr; + if(Array.filter){ + outArr = Array.filter(arr, callback, thisObject); + }else{ + if(!thisObject){ + if(arguments.length >= 3){ dojo.raise("thisObject doesn't exist!"); } + thisObject = dj_global; + } - outArr = []; - for(var i = 0; i < arr.length; i++){ - if(callback.call(thisObject, arr[i], i, arr)){ - outArr.push(arr[i]); + 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 - } -} + 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] + 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]); + 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 -} + 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]); + toArray: function(/*Object*/arrayLike, /*Number*/startOffset){ + // summary: + // Converts an array-like object (i.e. arguments, DOMCollection) + // to an array. Returns a new Array object. + var array = []; + for(var i = startOffset||0; i < arrayLike.length; i++){ + array.push(arrayLike[i]); + } + return array; // Array } - return array; // Array -} +}); dojo.provide("dojo.lang.func"); +dojo.lang.hitch = function(/*Object*/thisObject, /*Function|String*/method){ + // summary: + // Returns a function that will only ever execute in the a given scope + // (thisObject). This allows for easy use of object member functions + // in callbacks and other places in which the "this" keyword may + // otherwise not reference the expected scope. Note that the order of + // arguments may be reversed in a future version. + // thisObject: the scope to run the method in + // method: + // a function to be "bound" to thisObject or the name of the method in + // thisObject to be used as the basis for the binding + // usage: + // dojo.lang.hitch(foo, "bar")(); // runs foo.bar() in the scope of foo + // dojo.lang.hitch(foo, myFunction); // returns a function that runs myFunction in the scope of foo -/** - * 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){ + // FIXME: + // should this be extended to "fixate" arguments in a manner similar + // to dojo.lang.curry, but without the default execution of curry()? var fcn = (dojo.lang.isString(method) ? thisObject[method] : method) || function(){}; - - return function() { - return fcn.apply(thisObject, arguments); + return function(){ + return fcn.apply(thisObject, arguments); // Function }; } dojo.lang.anonCtr = 0; dojo.lang.anon = {}; -dojo.lang.nameAnonFunc = function(anonFuncPtr, namespaceObj, searchForNames){ - var nso = (namespaceObj || dojo.lang.anon); + +dojo.lang.nameAnonFunc = function(/*Function*/anonFuncPtr, /*Object*/thisObj, /*Boolean*/searchForNames){ + // summary: + // Creates a reference to anonFuncPtr in thisObj with a completely + // unique name. The new name is returned as a String. If + // searchForNames is true, an effort will be made to locate an + // existing reference to anonFuncPtr in thisObj, and if one is found, + // the existing name will be returned instead. The default is for + // searchForNames to be false. + var nso = (thisObj|| dojo.lang.anon); if( (searchForNames) || ((dj_global["djConfig"])&&(djConfig["slowAnonFuncLookups"] == true)) ){ for(var x in nso){ @@ -2760,21 +2967,72 @@ ret = "__"+dojo.lang.anonCtr++; } nso[ret] = anonFuncPtr; - return ret; + return ret; // String } dojo.lang.forward = function(funcName){ - // Returns a function that forwards a method call to this.func(...) + // summary: + // Returns a function that forwards a method call to + // this.funcName(...). Unlike dojo.lang.hitch(), the "this" scope is + // not fixed on a single object. Ported from MochiKit. return function(){ return this[funcName].apply(this, arguments); - }; + }; // Function } -dojo.lang.curry = function(ns, func /* args ... */){ +dojo.lang.curry = function(thisObj, func /* args ... */){ + // summary: + // similar to the curry() method found in many functional programming + // environments, this function returns an "argument accumulator" + // function, bound to a particular scope, and "primed" with a variable + // number of arguments. The curry method is unique in that it returns + // a function that may return other "partial" function which can be + // called repeatedly. New functions are returned until the arity of + // the original function is reached, at which point the underlying + // function (func) is called in the scope thisObj with all of the + // accumulated arguments (plus any extras) in positional order. + // examples: + // assuming a function defined like this: + // var foo = { + // bar: function(arg1, arg2, arg3){ + // dojo.debug.apply(dojo, arguments); + // } + // }; + // + // dojo.lang.curry() can be used most simply in this way: + // + // tmp = dojo.lang.curry(foo, foo.bar, "arg one", "thinger"); + // tmp("blah", "this is superfluous"); + // // debugs: "arg one thinger blah this is superfluous" + // tmp("blah"); + // // debugs: "arg one thinger blah" + // tmp(); + // // returns a function exactly like tmp that expects one argument + // + // other intermittent functions could be created until the 3 + // positional arguments are filled: + // + // tmp = dojo.lang.curry(foo, foo.bar, "arg one"); + // tmp2 = tmp("arg two"); + // tmp2("blah blah"); + // // debugs: "arg one arg two blah blah" + // tmp2("oy"); + // // debugs: "arg one arg two oy" + // + // curry() can also be used to call the function if enough arguments + // are passed in the initial invocation: + // + // dojo.lang.curry(foo, foo.bar, "one", "two", "three", "four"); + // // debugs: "one two three four" + // dojo.lang.curry(foo, foo.bar, "one", "two", "three"); + // // debugs: "one two three" + + + // FIXME: the order of func and thisObj should be changed!!! var outerArgs = []; - ns = ns||dj_global; + thisObj = thisObj||dj_global; if(dojo.lang.isString(func)){ - func = ns[func]; + func = thisObj[func]; } for(var x=2; x 0) { + if(returnFirstHit && ancestors.length > 0){ return ancestors[0]; // Node } node = node.parentNode; } - if (returnFirstHit) { return null; } + 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 +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 +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 } @@ -3351,9 +3671,9 @@ return false; // boolean } -dojo.dom.innerXML = function(/* Node */node){ - // summary - // Implementation of MS's innerXML function. +dojo.dom.innerXML = function(/*Node*/node){ + // summary: + // Implementation of MS's innerXML function. if(node.innerXML){ return node.innerXML; // string }else if (node.xml){ @@ -3364,8 +3684,8 @@ } dojo.dom.createDocument = function(){ - // summary - // cross-browser implementation of creating an XML document object. + // summary: + // cross-browser implementation of creating an XML document object. var doc = null; var _document = dojo.doc(); @@ -3386,9 +3706,10 @@ return doc; // DOMDocument } -dojo.dom.createDocumentFromText = function(/* string */str, /* string? */mimetype){ - // summary - // attempts to create a Document object based on optional mime-type, using str as the contents of the document +dojo.dom.createDocumentFromText = function(/*string*/str, /*string?*/mimetype){ + // summary: + // attempts to create a Document object based on optional mime-type, + // using str as the contents of the document if(!mimetype){ mimetype = "text/xml"; } if(!dj_undef("DOMParser")){ var parser = new DOMParser(); @@ -3422,7 +3743,7 @@ // FIXME: this may change all tags to uppercase! var tmp = _document.createElement("xml"); tmp.innerHTML = str; - if(_document.implementation && _document.implementation.createDocument) { + if(_document.implementation && _document.implementation.createDocument){ var xmlDoc = _document.implementation.createDocument("foo", "", null); for(var i = 0; i < tmp.childNodes.length; i++) { xmlDoc.importNode(tmp.childNodes.item(i), true); @@ -3439,9 +3760,9 @@ return null; } -dojo.dom.prependChild = function(/* Element */node, /* Element */parent) { - // summary - // prepends node to parent's children nodes +dojo.dom.prependChild = function(/*Element*/node, /*Element*/parent){ + // summary: + // prepends node to parent's children nodes if(parent.firstChild) { parent.insertBefore(node, parent.firstChild); } else { @@ -3450,19 +3771,19 @@ return true; // boolean } -dojo.dom.insertBefore = function(/* Node */node, /* Node */ref, /* boolean? */force){ - // summary - // Try to insert node before ref - if (force != true && +dojo.dom.insertBefore = function(/*Node*/node, /*Node*/ref, /*boolean?*/force){ + // summary: + // Try to insert node before ref + if( (force != true)&& (node === ref || node.nextSibling === ref)){ return false; } var parent = ref.parentNode; parent.insertBefore(node, ref); return true; // boolean } -dojo.dom.insertAfter = function(/* Node */node, /* Node */ref, /* boolean? */force){ - // summary - // Try to insert node after ref +dojo.dom.insertAfter = function(/*Node*/node, /*Node*/ref, /*boolean?*/force){ + // summary: + // Try to insert node after ref var pn = ref.parentNode; if(ref == pn.lastChild){ if((force != true)&&(node === ref)){ @@ -3475,9 +3796,9 @@ return true; // boolean } -dojo.dom.insertAtPosition = function(/* Node */node, /* Node */ref, /* string */position){ - // summary - // attempt to insert node in relation to ref based on position +dojo.dom.insertAtPosition = function(/*Node*/node, /*Node*/ref, /*string*/position){ + // summary: + // attempt to insert node in relation to ref based on position if((!node)||(!ref)||(!position)){ return false; // boolean } @@ -3500,46 +3821,35 @@ } } -dojo.dom.insertAtIndex = function(/* Node */node, /* Element */containingNode, /* number */insertionIndex){ - // summary - // insert node into child nodes nodelist of containingNode at insertionIndex. +dojo.dom.insertAtIndex = function(/*Node*/node, /*Element*/containingNode, /*number*/insertionIndex){ + // summary: + // insert node into child nodes nodelist of containingNode at + // insertionIndex. insertionIndex should be between 0 and + // the number of the childNodes in containingNode. insertionIndex + // specifys after how many childNodes in containingNode the node + // shall be inserted. If 0 is given, node will be appended to + // containingNode. var siblingNodes = containingNode.childNodes; // if there aren't any kids yet, just add it to the beginning - if (!siblingNodes.length){ + if (!siblingNodes.length || siblingNodes.length == insertionIndex){ containingNode.appendChild(node); return true; // boolean } + if(insertionIndex == 0){ + return dojo.dom.prependChild(node, containingNode); // boolean + } // otherwise we need to walk the childNodes // and find our spot - var after = null; - - for(var i=0; i1) { var _document = dojo.doc(); dojo.dom.replaceChildren(node, _document.createTextNode(text)); @@ -3569,10 +3879,10 @@ } } -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 +dojo.dom.hasParent = function(/*Node*/node){ + // summary: + // returns whether or not node is a child of another node. + return Boolean(node && node.parentNode && dojo.dom.isNode(node.parentNode)); // boolean } /** @@ -3584,9 +3894,10 @@ * 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. +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) { + if((typeof days == "number")&&(days >= 0)){ var d = new Date(); d.setTime(d.getTime()+(days*24*60*60*1000)); expires = d.toGMTString(); @@ -4518,7 +4933,9 @@ dojo.io.cookie.set = dojo.io.cookie.setCookie; -dojo.io.cookie.getCookie = function(name) { +dojo.io.cookie.getCookie = function(/*String*/name){ + //summary: Gets a cookie with the given name. + // FIXME: Which cookie should we return? // If there are cookies set for different sub domains in the current // scope there could be more than one cookie with the same name. @@ -4531,79 +4948,92 @@ if(end == -1) { end = value.length; } value = value.substring(0, end); value = unescape(value); - return value; + return value; //String } dojo.io.cookie.get = dojo.io.cookie.getCookie; -dojo.io.cookie.deleteCookie = function(name) { +dojo.io.cookie.deleteCookie = function(/*String*/name){ + //summary: Deletes a cookie with the given name. dojo.io.cookie.setCookie(name, "-", 0); } -dojo.io.cookie.setObjectCookie = function(name, obj, days, path, domain, secure, clearCurrent) { - if(arguments.length == 5) { // for backwards compat +dojo.io.cookie.setObjectCookie = function( /*String*/name, /*Object*/obj, + /*Number?*/days, /*String?*/path, + /*String?*/domain, /*boolean?*/secure, + /*boolean?*/clearCurrent){ + //summary: Takes an object, serializes it to a cookie value, and either + //sets a cookie with the serialized value. + //description: If clearCurrent is true, then any current cookie value + //for this object will be replaced with the the new serialized object value. + //If clearCurrent is false, then the existing cookie value will be modified + //with any changes from the new object value. + //Objects must be simple name/value pairs where the value is either a string + //or a number. Any other value will be ignored. + if(arguments.length == 5){ // for backwards compat clearCurrent = domain; domain = null; secure = null; } var pairs = [], cookie, value = ""; - if(!clearCurrent) { cookie = dojo.io.cookie.getObjectCookie(name); } - if(days >= 0) { - if(!cookie) { cookie = {}; } - for(var prop in obj) { - if(prop == null) { + if(!clearCurrent){ + cookie = dojo.io.cookie.getObjectCookie(name); + } + if(days >= 0){ + if(!cookie){ cookie = {}; } + for(var prop in obj){ + if(obj[prop] == null){ delete cookie[prop]; - } else if(typeof obj[prop] == "string" || typeof obj[prop] == "number") { + }else if((typeof obj[prop] == "string")||(typeof obj[prop] == "number")){ cookie[prop] = obj[prop]; } } prop = null; - for(var prop in cookie) { + for(var prop in cookie){ pairs.push(escape(prop) + "=" + escape(cookie[prop])); } value = pairs.join("&"); } dojo.io.cookie.setCookie(name, value, days, path, domain, secure); } -dojo.io.cookie.getObjectCookie = function(name) { +dojo.io.cookie.getObjectCookie = function(/*String*/name){ + //summary: Gets an object value for the given cookie name. The complement of + //dojo.io.cookie.setObjectCookie(). var values = null, cookie = dojo.io.cookie.getCookie(name); - if(cookie) { + if(cookie){ values = {}; var pairs = cookie.split("&"); - for(var i = 0; i < pairs.length; i++) { + for(var i = 0; i < pairs.length; i++){ var pair = pairs[i].split("="); var value = pair[1]; - if( isNaN(value) ) { value = unescape(pair[1]); } + if( isNaN(value) ){ value = unescape(pair[1]); } values[ unescape(pair[0]) ] = value; } } return values; } -dojo.io.cookie.isSupported = function() { - if(typeof navigator.cookieEnabled != "boolean") { +dojo.io.cookie.isSupported = function(){ + //summary: Tests the browser to see if cookies are enabled. + if(typeof navigator.cookieEnabled != "boolean"){ dojo.io.cookie.setCookie("__TestingYourBrowserForCookieSupport__", "CookiesAllowed", 90, null); var cookieVal = dojo.io.cookie.getCookie("__TestingYourBrowserForCookieSupport__"); navigator.cookieEnabled = (cookieVal == "CookiesAllowed"); - if(navigator.cookieEnabled) { + if(navigator.cookieEnabled){ // FIXME: should we leave this around? this.deleteCookie("__TestingYourBrowserForCookieSupport__"); } } - return navigator.cookieEnabled; + return navigator.cookieEnabled; //boolean } // need to leave this in for backwards-compat from 0.1 for when it gets pulled in by dojo.io.* -if(!dojo.io.cookies) { dojo.io.cookies = dojo.io.cookie; } +if(!dojo.io.cookies){ dojo.io.cookies = dojo.io.cookie; } dojo.provide("dojo.io.*"); -dojo.provide("dojo.io"); - -dojo.deprecated("dojo.io", "replaced by dojo.io.*", "0.5"); - dojo.provide("dojo.event.common"); @@ -5039,8 +5469,10 @@ } ao.srcFunc = "onkeypress"; } - var mjp = dojo.event.MethodJoinPoint.getForMethod(ao.srcObj, ao.srcFunc); - return mjp.removeAdvice(ao.adviceObj, ao.adviceFunc, ao.adviceType, ao.once); // a MethodJoinPoint object + if(!ao.srcObj[ao.srcFunc]){ return null; } // prevent un-necessaray joinpoint creation + var mjp = dojo.event.MethodJoinPoint.getForMethod(ao.srcObj, ao.srcFunc, true); + mjp.removeAdvice(ao.adviceObj, ao.adviceFunc, ao.adviceType, ao.once); // a MethodJoinPoint object + return mjp; } this.kwDisconnect = function(kwArgs){ @@ -5315,7 +5747,12 @@ }else if(this.methodfunc){ result = this.object[this.methodname].apply(this.object, args); } - }catch(e){ if(!this.squelch){ dojo.raise(e); } } + }catch(e){ + if(!this.squelch){ + dojo.debug(e,"when calling",this.methodname,"on",this.object,"with arguments",args); + dojo.raise(e); + } + } if((this["after"])&&(this.after.length>0)){ // see comment on this.before above @@ -5718,6 +6155,18 @@ dojo.widget.manager.destroyAll(); } }catch(e){} + + // Workaround for IE leak recommended in ticket #1727 by schallm + if(dojo.widget){ + for(var name in dojo.widget._templateCache){ + if(dojo.widget._templateCache[name].node){ + dojo.dom.destroyNode(dojo.widget._templateCache[name].node); + dojo.widget._templateCache[name].node = null; + delete dojo.widget._templateCache[name].node; + } + } + } + try{ window.onload = null; }catch(e){} try{ window.onunload = null; }catch(e){} dojo._ie_clobber.clobberNodes = []; @@ -5886,7 +6335,7 @@ // FIXME: event detection hack ... could test for additional attributes // if necessary - return (typeof obj != "undefined")&&(typeof Event != "undefined")&&(obj.eventPhase); // Boolean + return (typeof obj != "undefined")&&(obj)&&(typeof Event != "undefined")&&(obj.eventPhase); // Boolean // Event does not support instanceof in Opera, otherwise: //return (typeof Event != "undefined")&&(obj instanceof Event); } @@ -6114,12 +6563,36 @@ } }else if(dojo.render.html.safari){ switch(evt.keyCode){ + case 25: evt.key = evt.KEY_TAB; evt.shift = true;break; case 63232: evt.key = evt.KEY_UP_ARROW; break; case 63233: evt.key = evt.KEY_DOWN_ARROW; break; case 63234: evt.key = evt.KEY_LEFT_ARROW; break; case 63235: evt.key = evt.KEY_RIGHT_ARROW; break; + case 63236: evt.key = evt.KEY_F1; break; + case 63237: evt.key = evt.KEY_F2; break; + case 63238: evt.key = evt.KEY_F3; break; + case 63239: evt.key = evt.KEY_F4; break; + case 63240: evt.key = evt.KEY_F5; break; + case 63241: evt.key = evt.KEY_F6; break; + case 63242: evt.key = evt.KEY_F7; break; + case 63243: evt.key = evt.KEY_F8; break; + case 63244: evt.key = evt.KEY_F9; break; + case 63245: evt.key = evt.KEY_F10; break; + case 63246: evt.key = evt.KEY_F11; break; + case 63247: evt.key = evt.KEY_F12; break; + case 63250: evt.key = evt.KEY_PAUSE; break; + case 63272: evt.key = evt.KEY_DELETE; break; + case 63273: evt.key = evt.KEY_HOME; break; + case 63275: evt.key = evt.KEY_END; break; + case 63276: evt.key = evt.KEY_PAGE_UP; break; + case 63277: evt.key = evt.KEY_PAGE_DOWN; break; + case 63302: evt.key = evt.KEY_INSERT; break; + case 63248://prtscr + case 63249://scrolllock + case 63289://numlock + break; default: - evt.key = evt.charCode > 0 ? String.fromCharCode(evt.charCode) : evt.keyCode; + evt.key = evt.charCode >= evt.KEY_SPACE ? String.fromCharCode(evt.charCode) : evt.keyCode; } }else{ evt.key = evt.charCode > 0 ? String.fromCharCode(evt.charCode) : evt.keyCode; @@ -6156,8 +6629,8 @@ // passed event // evt: Optional for IE. The native event object. if(window.event){ - evt.returnValue = false; evt.cancelBubble = true; + evt.returnValue = false; }else{ evt.preventDefault(); evt.stopPropagation(); @@ -6904,18 +7377,238 @@ return new dojo.lfx.Chain(anims); // dojo.lfx.Combine } +dojo.provide("dojo.html.common"); + +dojo.lang.mixin(dojo.html, dojo.dom); + +dojo.html.body = function(){ + dojo.deprecated("dojo.html.body() moved to dojo.body()", "0.5"); + return dojo.body(); +} + +// FIXME: we are going to assume that we can throw any and every rendering +// engine into the IE 5.x box model. In Mozilla, we do this w/ CSS. +// Need to investigate for KHTML and Opera + +dojo.html.getEventTarget = function(/* DOMEvent */evt){ + // summary + // Returns the target of an event + if(!evt) { evt = dojo.global().event || {} }; + var t = (evt.srcElement ? evt.srcElement : (evt.target ? evt.target : null)); + while((t)&&(t.nodeType!=1)){ t = t.parentNode; } + return t; // HTMLElement +} + +dojo.html.getViewport = function(){ + // summary + // Returns the dimensions of the viewable area of a browser window + var _window = dojo.global(); + var _document = dojo.doc(); + var w = 0; + var h = 0; + + if(dojo.render.html.mozilla){ + // mozilla + w = _document.documentElement.clientWidth; + h = _window.innerHeight; + }else if(!dojo.render.html.opera && _window.innerWidth){ + //in opera9, dojo.body().clientWidth should be used, instead + //of window.innerWidth/document.documentElement.clientWidth + //so we have to check whether it is opera + w = _window.innerWidth; + h = _window.innerHeight; + } else if (!dojo.render.html.opera && dojo.exists(_document, "documentElement.clientWidth")){ + // IE6 Strict + var w2 = _document.documentElement.clientWidth; + // this lets us account for scrollbars + if(!w || w2 && w2 < w) { + w = w2; + } + h = _document.documentElement.clientHeight; + } else if (dojo.body().clientWidth){ + // IE, Opera + w = dojo.body().clientWidth; + h = dojo.body().clientHeight; + } + return { width: w, height: h }; // object +} + +dojo.html.getScroll = function(){ + // summary + // Returns the scroll position of the document + var _window = dojo.global(); + var _document = dojo.doc(); + var top = _window.pageYOffset || _document.documentElement.scrollTop || dojo.body().scrollTop || 0; + var left = _window.pageXOffset || _document.documentElement.scrollLeft || dojo.body().scrollLeft || 0; + return { + top: top, + left: left, + offset:{ x: left, y: top } // note the change, NOT an Array with added properties. + }; // object +} + +dojo.html.getParentByType = function(/* HTMLElement */node, /* string */type) { + // summary + // Returns the first ancestor of node with tagName type. + var _document = dojo.doc(); + var parent = dojo.byId(node); + type = type.toLowerCase(); + while((parent)&&(parent.nodeName.toLowerCase()!=type)){ + if(parent==(_document["body"]||_document["documentElement"])){ + return null; + } + parent = parent.parentNode; + } + return parent; // HTMLElement +} + +dojo.html.getAttribute = function(/* HTMLElement */node, /* string */attr){ + // summary + // Returns the value of attribute attr from node. + node = dojo.byId(node); + // FIXME: need to add support for attr-specific accessors + if((!node)||(!node.getAttribute)){ + // if(attr !== 'nwType'){ + // alert("getAttr of '" + attr + "' with bad node"); + // } + return null; + } + var ta = typeof attr == 'string' ? attr : new String(attr); + + // first try the approach most likely to succeed + var v = node.getAttribute(ta.toUpperCase()); + if((v)&&(typeof v == 'string')&&(v!="")){ + return v; // string + } + + // try returning the attributes value, if we couldn't get it as a string + if(v && v.value){ + return v.value; // string + } + + // this should work on Opera 7, but it's a little on the crashy side + if((node.getAttributeNode)&&(node.getAttributeNode(ta))){ + return (node.getAttributeNode(ta)).value; // string + }else if(node.getAttribute(ta)){ + return node.getAttribute(ta); // string + }else if(node.getAttribute(ta.toLowerCase())){ + return node.getAttribute(ta.toLowerCase()); // string + } + return null; // string +} + +dojo.html.hasAttribute = function(/* HTMLElement */node, /* string */attr){ + // summary + // Determines whether or not the specified node carries a value for the attribute in question. + return dojo.html.getAttribute(dojo.byId(node), attr) ? true : false; // boolean +} + +dojo.html.getCursorPosition = function(/* DOMEvent */e){ + // summary + // Returns the mouse position relative to the document (not the viewport). + // For example, if you have a document that is 10000px tall, + // but your browser window is only 100px tall, + // if you scroll to the bottom of the document and call this function it + // will return {x: 0, y: 10000} + // NOTE: for events delivered via dojo.event.connect() and/or dojoAttachEvent (for widgets), + // you can just access evt.pageX and evt.pageY, rather than calling this function. + e = e || dojo.global().event; + var cursor = {x:0, y:0}; + if(e.pageX || e.pageY){ + cursor.x = e.pageX; + cursor.y = e.pageY; + }else{ + var de = dojo.doc().documentElement; + var db = dojo.body(); + cursor.x = e.clientX + ((de||db)["scrollLeft"]) - ((de||db)["clientLeft"]); + cursor.y = e.clientY + ((de||db)["scrollTop"]) - ((de||db)["clientTop"]); + } + return cursor; // object +} + +dojo.html.isTag = function(/* HTMLElement */node) { + // summary + // Like dojo.dom.isTag, except case-insensitive + node = dojo.byId(node); + if(node && node.tagName) { + for (var i=1; i, + //which will be treated as an external javascript file in IE + var xscript = dojo.doc().createElement('script'); + xscript.src = "javascript:'dojo.html.createExternalElement=function(doc, tag){ return doc.createElement(tag); }'"; + dojo.doc().getElementsByTagName("head")[0].appendChild(xscript); + })(); + } +}else{ + //for other browsers, simply use document.createElement + //is enough + dojo.html.createExternalElement = function(/* HTMLDocument */doc, /* string */tag){ + // summary + // Creates an element in the HTML document, here for ActiveX activation workaround. + return doc.createElement(tag); // HTMLElement + } +} + +dojo.html._callDeprecated = function(inFunc, replFunc, args, argName, retValue){ + dojo.deprecated("dojo.html." + inFunc, + "replaced by dojo.html." + replFunc + "(" + (argName ? "node, {"+ argName + ": " + argName + "}" : "" ) + ")" + (retValue ? "." + retValue : ""), "0.5"); + var newArgs = []; + if(argName){ var argsIn = {}; argsIn[argName] = args[1]; newArgs.push(args[0]); newArgs.push(argsIn); } + else { newArgs = args } + var ret = dojo.html[replFunc].apply(dojo.html, args); + if(retValue){ return ret[retValue]; } + else { return ret; } +} + +dojo.html.getViewportWidth = function(){ + return dojo.html._callDeprecated("getViewportWidth", "getViewport", arguments, null, "width"); +} +dojo.html.getViewportHeight = function(){ + return dojo.html._callDeprecated("getViewportHeight", "getViewport", arguments, null, "height"); +} +dojo.html.getViewportSize = function(){ + return dojo.html._callDeprecated("getViewportSize", "getViewport", arguments); +} +dojo.html.getScrollTop = function(){ + return dojo.html._callDeprecated("getScrollTop", "getScroll", arguments, null, "top"); +} +dojo.html.getScrollLeft = function(){ + return dojo.html._callDeprecated("getScrollLeft", "getScroll", arguments, null, "left"); +} +dojo.html.getScrollOffset = function(){ + return dojo.html._callDeprecated("getScrollOffset", "getScroll", arguments, null, "offset"); +} + dojo.provide("dojo.uri.Uri"); dojo.uri = new function() { this.dojoUri = function (/*dojo.uri.Uri||String*/uri) { // summary: returns a Uri object resolved relative to the dojo root return new dojo.uri.Uri(dojo.hostenv.getBaseScriptUri(), uri); } - + this.moduleUri = function(/*String*/module, /*dojo.uri.Uri||String*/uri){ - // summary: returns a Uri object relative to a (top-level) module + // summary: returns a Uri object relative to a module // description: Examples: dojo.uri.moduleUri("dojo","Editor"), or dojo.uri.moduleUri("acme","someWidget") - var loc = dojo.hostenv.getModulePrefix(module); + var loc = dojo.hostenv.getModuleSymbols(module).join('/'); + //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); @@ -6945,10 +7638,10 @@ 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; @@ -6982,25 +7675,25 @@ // break the uri into its main components var regexp = "^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$"; - var r = this.uri.match(new RegExp(regexp)); + var r = this.uri.match(new RegExp(regexp)); this.scheme = r[2] || (r[1] ? "" : null); this.authority = r[4] || (r[3] ? "" : null); this.path = r[5]; // can never be undefined this.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; } } }; @@ -7404,7 +8097,7 @@ if(!URI){ return; } if(!doc){ doc = document; } var cssStr = dojo.hostenv.getText(URI, false, fail_ok); - if(cssStr===null){ return; } + if(cssStr===null){ return; } cssStr = dojo.html.fixPathsInCssText(cssStr, URI); if(checkDuplicates){ @@ -7428,7 +8121,7 @@ } } - var style = dojo.html.insertCssText(cssStr); + var style = dojo.html.insertCssText(cssStr, doc); dojo.html._insertedCssFiles.push({'doc': doc, 'cssText': cssStr, 'nodeRef': style}); // insert custom attribute ex dbgHref="../foo.css" usefull when debugging in DOM inspectors, no? @@ -7461,7 +8154,16 @@ head.appendChild(style); } if(style.styleSheet){// IE - style.styleSheet.cssText = cssStr; + var setFunc = function(){ + try{ + style.styleSheet.cssText = cssStr; + }catch(e){ dojo.debug(e); } + }; + if(style.styleSheet.disabled){ + setTimeout(setFunc, 10); + }else{ + setFunc(); + } }else{ // w3c var cssText = doc.createTextNode(cssStr); style.appendChild(cssText); @@ -7473,27 +8175,27 @@ // 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()\/.\\'"-:#=&?~]*)['"]/; + if(!cssStr || !URI){ return; } + var match, str = "", url = "", urlChrs = "[\\t\\s\\w\\(\\)\\/\\.\\\\'\"-:#=&?~]+"; + var regex = new RegExp('url\\(\\s*('+urlChrs+')\\s*\\)'); + var regexProtocol = /(file|https?|ftps?):\/\//; + regexTrim = new RegExp("^[\\s]*(['\"]?)("+urlChrs+")\\1[\\s]*?$"); + if(dojo.render.html.ie55 || dojo.render.html.ie60){ + var regexIe = new RegExp("AlphaImageLoader\\((.*)src\=['\"]("+urlChrs+")['\"]"); + // TODO: need to decide how to handle relative paths and AlphaImageLoader see #1441 + // current implementation breaks on build with intern_strings while(match = regexIe.exec(cssStr)){ - url = match[1].replace(regexTrim, "$2"); + url = match[2].replace(regexTrim, "$2"); if(!regexProtocol.exec(url)){ url = (new dojo.uri.Uri(URI, url).toString()); } - str += cssStr.substring(0, match.index) + "AlphaImageLoader(src='" + url + "'"; + str += cssStr.substring(0, match.index) + "AlphaImageLoader(" + match[1] + "src='" + url + "'"; cssStr = cssStr.substr(match.index + match[0].length); } - return str + cssStr; + cssStr = str + cssStr; + str = ""; } - 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)){ @@ -7781,225 +8483,6 @@ 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"); @@ -8247,9 +8730,9 @@ // Returns which box model the passed element is working with var h = dojo.render.html; var bs = dojo.html.boxSizing; - if((h.ie)||(h.opera)){ + if(((h.ie)||(h.opera)) && node.nodeName!="IMG"){ var cm = document["compatMode"]; - if((cm == "BackCompat")||(cm == "QuirksMode")){ + if((cm == "BackCompat")||(cm == "QuirksMode")){ return bs.BORDER_BOX; // string }else{ return bs.CONTENT_BOX; // string @@ -8561,11 +9044,13 @@ 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]; - } + try{ + if(s == "opacity"){ + dojo.html.setOpacity(n, style[s]); + }else{ + n.style[s] = style[s]; + } + }catch(e){ dojo.debug(e); } } } @@ -8778,9 +9263,18 @@ // 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); + // TODO: should this offscreen code be part of dojo.html, so that getBorderBox() works on hidden nodes? + var origTop, origLeft, origPosition; + with(node.style){ + origTop=top; origLeft=left; origPosition=position; + top="-9999px"; left="-9999px"; position="absolute"; + display=""; + } var height = dojo.html.getBorderBox(node).height; - dojo.html.hide(node); + with(node.style){ + top=origTop; left=origLeft; position=origPosition; + display="none"; + } var anim = dojo.lfx.propertyAnimation(node, { "height": { @@ -8996,11 +9490,14 @@ var startCoords = h.toCoordinateObject(start, true); var outline = document.createElement("div"); h.copyStyle(outline, endNode); - if (endNode.explodeClassName) { outline.className = endNode.explodeClassName; } + if(endNode.explodeClassName){ outline.className = endNode.explodeClassName; } with(outline.style){ position = "absolute"; display = "none"; // border = "1px solid black"; + var backgroundStyle = h.getStyle(start, "background-color"); + backgroundColor = backgroundStyle ? backgroundStyle.toLowerCase() : "transparent"; + backgroundColor = (backgroundColor == "transparent") ? "rgb(221, 221, 221)" : backgroundColor; } dojo.body().appendChild(outline); Index: openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/demos/storage/editor.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/demos/storage/Attic/editor.html,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/demos/storage/editor.html 22 Nov 2006 01:49:00 -0000 1.1 +++ openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/demos/storage/editor.html 25 Dec 2006 16:39:50 -0000 1.2 @@ -65,12 +65,16 @@ -
-
+
+
Click Here to Begin Editing
+ Index: openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/demos/storage/editor.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/demos/storage/Attic/editor.js,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/demos/storage/editor.js 22 Nov 2006 01:49:00 -0000 1.1 +++ openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/demos/storage/editor.js 25 Dec 2006 16:39:50 -0000 1.2 @@ -12,7 +12,7 @@ dojo.require("dojo.event.*"); dojo.require("dojo.html"); dojo.require("dojo.lfx.*"); -dojo.require("dojo.widget.Editor"); +dojo.require("dojo.widget.Editor2"); dojo.require("dojo.storage.*"); var Moxie = { @@ -58,9 +58,9 @@ // get the new values var key = dojo.byId("storageKey").value; - var value = dojo.widget.byId("storageValue").getEditorContent(); + var richTextControl = dojo.widget.byId("storageValue"); + var value = richTextControl.getEditorContent(); - if(key == null || typeof key == "undefined" || key == ""){ alert("Please enter a file name"); return; @@ -183,9 +183,12 @@ var results = dojo.storage.get(key); // set the new Editor widget value - var storageValue = dojo.widget.byId("storageValue"); - storageValue._richText.editNode.innerHTML = results; - storageValue._richText._updateHeight(); + var richTextControl = dojo.widget.byId("storageValue") + richTextControl.replaceEditorContent(results); + // FIXME: Editor2 should be reflowing this height + // internally; we shouldn't be exposed to this - fix + // bug in Editor2 + richTextControl._updateHeight(); // print out that we are done this._printStatus("Loaded '" + key + "'"); Index: openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/demos/widget/Fisheye.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/demos/widget/Attic/Fisheye.html,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/demos/widget/Fisheye.html 22 Nov 2006 02:12:20 -0000 1.1 +++ openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/demos/widget/Fisheye.html 25 Dec 2006 16:39:51 -0000 1.2 @@ -8,9 +8,8 @@ var djConfig = {isDebug: true, debugAtAllCosts: false}; - @@ -195,6 +249,6 @@

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

- + Index: openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/io/xip_server.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/io/Attic/xip_server.html,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/io/xip_server.html 6 Nov 2006 14:50:09 -0000 1.1 +++ openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/io/xip_server.html 25 Dec 2006 16:39:53 -0000 1.2 @@ -42,23 +42,20 @@ - data: The URL-encoded data for the request. For a GET request, this would be the querystring parameters. For a POST request, it wll be the body data. + + See xip_client.html for more info on the xip fragment identifier protocol. --> @@ -333,5 +366,6 @@

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

+
Index: openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/lang/array.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/lang/Attic/array.js,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/lang/array.js 6 Nov 2006 14:50:09 -0000 1.1 +++ openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/lang/array.js 25 Dec 2006 16:39:53 -0000 1.2 @@ -14,173 +14,271 @@ // FIXME: Is this worthless since you can do: if(name in obj) // is this the right place for this? -dojo.lang.has = function(/*Object*/obj, /*String*/name){ - try{ - return typeof obj[name] != "undefined"; - }catch(e){ return false; } -} -dojo.lang.isEmpty = function(/*Object*/obj){ - if(dojo.lang.isObject(obj)){ - var tmp = {}; - var count = 0; - for(var x in obj){ - if(obj[x] && (!tmp[x])){ - count++; - break; - } +dojo.lang.mixin(dojo.lang, { + has: function(/*Object*/obj, /*String*/name){ + // summary: is there a property with the passed name in obj? + try{ + return typeof obj[name] != "undefined"; // Boolean + }catch(e){ return false; } // Boolean + }, + + isEmpty: function(/*Object*/obj){ + // summary: + // can be used to determine if the passed object is "empty". In + // the case of array-like objects, the length, property is + // examined, but for other types of objects iteration is used to + // examine the iterable "surface area" to determine if any + // non-prototypal properties have been assigned. This iteration is + // prototype-extension safe. + if(dojo.lang.isObject(obj)){ + var tmp = {}; + var count = 0; + for(var x in obj){ + if(obj[x] && (!tmp[x])){ + count++; + break; + } + } + return count == 0; // boolean + }else if(dojo.lang.isArrayLike(obj) || dojo.lang.isString(obj)){ + return obj.length == 0; // boolean } - return count == 0; - }else if(dojo.lang.isArrayLike(obj) || dojo.lang.isString(obj)){ - return obj.length == 0; - } -} + }, -dojo.lang.map = function(/*Array*/arr, /*Object|Function*/obj, /*Function?*/unary_func){ - var isString = dojo.lang.isString(arr); - if(isString){ - // arr: String - arr = arr.split(""); - } - if(dojo.lang.isFunction(obj)&&(!unary_func)){ - unary_func = obj; - obj = dj_global; - }else if(dojo.lang.isFunction(obj) && unary_func){ - // ff 1.5 compat - var tmpObj = obj; - obj = unary_func; - unary_func = tmpObj; - } - if(Array.map){ - var outArr = Array.map(arr, unary_func, obj); - }else{ - var outArr = []; - for(var i=0;i1; }); + // // returns false + // dojo.lang.every([1, 2, 3, 4], function(item){ return item>0; }); + // // returns true + return this._everyOrSome(true, arr, callback, thisObject); // Boolean + }, -dojo.lang.some = function(/*Array*/arr, /*Function*/callback, /*Object?*/thisObject){ - return this._everyOrSome(false, arr, callback, thisObject); // Boolean -} + some: function(/*Array*/arr, /*Function*/callback, /*Object?*/thisObject){ + // summary: + // determines whether or not any item in the array satisfies the + // condition implemented by callback. thisObject may be used to + // scope the call to callback. The function signature is derived + // from the JavaScript 1.6 Array.some() function. More + // information on this can be found here: + // http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:some + // examples: + // dojo.lang.some([1, 2, 3, 4], function(item){ return item>1; }); + // // returns true + // dojo.lang.some([1, 2, 3, 4], function(item){ return item<1; }); + // // returns false + return this._everyOrSome(false, arr, callback, thisObject); // Boolean + }, -dojo.lang.filter = function(/*Array*/arr, /*Function*/callback, /*Object?*/thisObject){ - var isString = dojo.lang.isString(arr); - if(isString){ /*arr: String*/arr = arr.split(""); } - var outArr; - if(Array.filter){ - outArr = Array.filter(arr, callback, thisObject); - } else { - if(!thisObject){ - if(arguments.length >= 3){ dojo.raise("thisObject doesn't exist!"); } - thisObject = dj_global; - } + filter: function(/*Array*/arr, /*Function*/callback, /*Object?*/thisObject){ + // summary: + // returns a new Array with those items from arr that match the + // condition implemented by callback.thisObject may be used to + // scope the call to callback. The function signature is derived + // from the JavaScript 1.6 Array.filter() function, although + // special accomidation is made in our implementation for strings. + // More information on the JS 1.6 API can be found here: + // http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:filter + // examples: + // dojo.lang.some([1, 2, 3, 4], function(item){ return item>1; }); + // // returns [2, 3, 4] + var isString = dojo.lang.isString(arr); + if(isString){ /*arr: String*/arr = arr.split(""); } + var outArr; + if(Array.filter){ + outArr = Array.filter(arr, callback, thisObject); + }else{ + if(!thisObject){ + if(arguments.length >= 3){ dojo.raise("thisObject doesn't exist!"); } + thisObject = dj_global; + } - outArr = []; - for(var i = 0; i < arr.length; i++){ - if(callback.call(thisObject, arr[i], i, arr)){ - outArr.push(arr[i]); + 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 - } -} + 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] + 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]); + 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 -} + 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]); + toArray: function(/*Object*/arrayLike, /*Number*/startOffset){ + // summary: + // Converts an array-like object (i.e. arguments, DOMCollection) + // to an array. Returns a new Array object. + var array = []; + for(var i = startOffset||0; i < arrayLike.length; i++){ + array.push(arrayLike[i]); + } + return array; // Array } - return array; // Array -} +}); Index: openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/lang/common.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/lang/Attic/common.js,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/lang/common.js 6 Nov 2006 14:50:09 -0000 1.1 +++ openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/lang/common.js 25 Dec 2006 16:39:53 -0000 1.2 @@ -10,9 +10,9 @@ dojo.provide("dojo.lang.common"); -dojo.lang.inherits = function(/*Function*/ subclass, /*Function*/ superclass){ +dojo.lang.inherits = function(/*Function*/subclass, /*Function*/superclass){ // summary: Set up inheritance between two classes. - if(typeof superclass != 'function'){ + if(!dojo.lang.isFunction(superclass)){ dojo.raise("dojo.inherits: superclass argument ["+superclass+"] must be a function (subclass: ["+subclass+"']"); } subclass.prototype = new superclass(); @@ -23,7 +23,10 @@ } dojo.lang._mixin = function(/*Object*/ obj, /*Object*/ props){ - // summary: Adds all properties and methods of props to obj. + // summary: + // Adds all properties and methods of props to obj. This addition is + // "prototype extension safe", so that instances of objects will not + // pass along prototype defaults. var tobj = {}; for(var x in props){ // the "tobj" condition avoid copying properties in "props" @@ -45,17 +48,19 @@ return obj; // Object } -dojo.lang.mixin = function(/*Object*/ obj, /*Object...*/props){ - // summary: Adds all properties and methods of props to obj. +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