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 -r1.16 -r1.17 --- openacs-4/packages/ajaxhelper/tcl/ajax-yahoo-procs.tcl 21 Sep 2018 14:11:55 -0000 1.16 +++ openacs-4/packages/ajaxhelper/tcl/ajax-yahoo-procs.tcl 21 Sep 2018 14:19:14 -0000 1.17 @@ -1,10 +1,10 @@ ad_library { - Library for Ajax Helper Procs - based on Yahoo's User Interface Libraries + Library for Ajax Helper Procs + based on Yahoo's User Interface Libraries - @author Hamilton Chua (ham@solutiongrove.com) - @creation-date 2006-01-16 + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-01-16 } namespace eval ah::yui { } @@ -48,12 +48,12 @@ -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. + 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 + @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" \ @@ -78,37 +78,38 @@ } ad_proc -private ah::yui::is_js_sources_loaded { - -js_source + -js_source } { - 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 + 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) - @creation-date 2006-11-05 + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-11-05 } { - set state 0 - if { [info exists ::ajax_helper_yui_js_sources] } { - foreach source $::ajax_helper_yui_js_sources { - if { [string match $source $js_source] } { - set state 1 - break - } - } - } - return $state + set state 0 + if { [info exists ::ajax_helper_yui_js_sources] } { + foreach source $::ajax_helper_yui_js_sources { + if { [string match $source $js_source] } { + set state 1 + break + } + } + } + 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. + 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 + @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 ","] @@ -139,40 +140,40 @@ ad_proc -public ah::yui::js_sources { - {-source "default"} - {-min:boolean} + {-source "default"} + {-min:boolean} } { DEPRECATED. Use ah::yui::requires instead. - Generates the \n" - } - } - "event" { - if { ![ah::yui::is_js_sources_loaded -js_source "event"] } { - append script " \n" - } - } - "treeview" { - if { ![ah::yui::is_js_sources_loaded -js_source "treeview"] } { - append script " \n" - } - } - "calendar" { - if { ![ah::yui::is_js_sources_loaded -js_source "calendar"] } { - append script " \n" - } - } - "dragdrop" { - if { ![ah::yui::is_js_sources_loaded -js_source "dragdrop"] } { - append script " \n" - } - } - "slider" { - if { ![ah::yui::is_js_sources_loaded -js_source "slider"] } { - append script " \n" - } - } - "container" { - if { ![ah::yui::is_js_sources_loaded -js_source "container"] } { - append script " \n" - append script " \n" - } - } - "menu" { - if { ![ah::yui::is_js_sources_loaded -js_source "menu"] } { - append script " \n" - append script " \n" - } - } - "connection" { - if { ![ah::yui::is_js_sources_loaded -js_source "connection"] } { - append script " \n" - } - } - "dom" { - if { ![ah::yui::is_js_sources_loaded -js_source "yahoo"] } { - append script " \n" - } + foreach x $js_file_list { + switch $x { + "animation" { + if { ![ah::yui::is_js_sources_loaded -js_source "animation"] } { + append script " \n" + } } + "event" { + if { ![ah::yui::is_js_sources_loaded -js_source "event"] } { + append script " \n" + } + } + "treeview" { + if { ![ah::yui::is_js_sources_loaded -js_source "treeview"] } { + append script " \n" + } + } + "calendar" { + if { ![ah::yui::is_js_sources_loaded -js_source "calendar"] } { + append script " \n" + } + } + "dragdrop" { + if { ![ah::yui::is_js_sources_loaded -js_source "dragdrop"] } { + append script " \n" + } + } + "slider" { + if { ![ah::yui::is_js_sources_loaded -js_source "slider"] } { + append script " \n" + } + } + "container" { + if { ![ah::yui::is_js_sources_loaded -js_source "container"] } { + append script " \n" + append script " \n" + } + } + "menu" { + if { ![ah::yui::is_js_sources_loaded -js_source "menu"] } { + append script " \n" + append script " \n" + } + } + "connection" { + if { ![ah::yui::is_js_sources_loaded -js_source "connection"] } { + append script " \n" + } + } + "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 "yahoo"] } { + append script " \n" + } + } "utilities" { if { ![ah::yui::is_js_sources_loaded -js_source "utilities"] } { append script " \n" } } - } - } - return $script + } + } + return $script } ad_proc -public ah::yui::cssclass { @@ -276,7 +277,7 @@ } { Generates javascript code to control css class on html elements. - + http://developer.yahoo.com/yui/dom/ @author Hamilton Chua (ham@solutiongrove.com) @@ -299,70 +300,70 @@ "add" { append script "addClass(${element},\"${classname}\"); " } "remove" { append script "removeClass(${element},\"${classname}\") ;" } "check" { append script "hasClass(${element},\"${classname}\"); " } - + } return ${script} } ad_proc -public ah::yui::addlistener { - -element:required - -event:required - -callback:required - {-element_is_var:boolean} + -element:required + -event:required + -callback:required + {-element_is_var:boolean} } { - Creates javascript for Yahoo's Event Listener. - http://developer.yahoo.com/yui/event/ + Creates javascript for Yahoo's Event Listener. + http://developer.yahoo.com/yui/event/ - @author Hamilton Chua (ham@solutiongrove.com) - @creation-date 2006-11-05 + @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. + @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. } { ah::yui::requires -sources "event" - if { !$element_is_var_p } { - set element [ah::isnot_js_var $element] - } + if { !$element_is_var_p } { + set element [ah::isnot_js_var $element] + } - return "YAHOO.util.Event.addListener($element,\"$event\",${callback});\n" + return "YAHOO.util.Event.addListener($element,\"$event\",${callback});\n" } ad_proc -public ah::yui::tooltip { - -varname:required - -element:required - -message:required - {-enclose:boolean} - {-options ""} + -varname:required + -element:required + -message:required + {-enclose:boolean} + {-options ""} } { - Generates the javascript to create a tooltip using yahoo's user interface javascript library. - http://developer.yahoo.com/yui/container/tooltip/index.html + 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) - @creation-date 2006-11-05 + @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 + @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 } { ah::yui::requires -sources "container" - set script "var $varname = new YAHOO.widget.Tooltip(\"alertTip\", { context:\"$element\", text:\"$message\", $options });" + set script "var $varname = new YAHOO.widget.Tooltip(\"alertTip\", { context:\"$element\", text:\"$message\", $options });" global ajax_helper_init_scripts append ajax_helper_init_scripts $script } ad_proc -public ah::yui::create_tree { - -element:required - -nodes:required - {-varname "tree"} - {-css ""} + -element:required + -nodes:required + {-varname "tree"} + {-css ""} {-nodedroppable:boolean} } { - Generates the javascript to create a yahoo tree view control. + Generates the javascript to create a yahoo tree view control. Nodes accepts a list of lists. This is an example of a node list. @@ -381,44 +382,44 @@ 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/ + http://developer.yahoo.com/yui/treeview/ - @author Hamilton Chua (ham@solutiongrove.com) - @creation-date 2006-11-05 + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-11-05 - @param element This is the id of the html element 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 element This is the id of the html element 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. } { ah::yui::requires -sources "dom,treeview" if { $css ne "" } { template::head::add_css -href $css } - set script "var ${varname} = new YAHOO.widget.TreeView(\"${element}\"); " - append script "var ${varname}root = ${varname}.getRoot(); " - foreach node $nodes { + set script "var ${varname} = new YAHOO.widget.TreeView(\"${element}\"); " + append script "var ${varname}root = ${varname}.getRoot(); " + foreach node $nodes { if { $nodedroppable_p } { - append script [ah::yui::create_tree_node -varname [lindex $node 0] \ - -label [lindex $node 1] \ - -treevarname [lindex $node 2] \ - -href [lindex $node 3] \ - -attach_to_node [lindex $node 4] \ - -dynamic_load [lindex $node 5] \ - -open [lindex $node 6] \ - -droppable ] + append script [ah::yui::create_tree_node -varname [lindex $node 0] \ + -label [lindex $node 1] \ + -treevarname [lindex $node 2] \ + -href [lindex $node 3] \ + -attach_to_node [lindex $node 4] \ + -dynamic_load [lindex $node 5] \ + -open [lindex $node 6] \ + -droppable ] } else { - append script [ah::yui::create_tree_node -varname [lindex $node 0] \ - -label [lindex $node 1] \ - -treevarname [lindex $node 2] \ - -href [lindex $node 3] \ - -attach_to_node [lindex $node 4] \ - -dynamic_load [lindex $node 5] \ - -open [lindex $node 6] ] + append script [ah::yui::create_tree_node -varname [lindex $node 0] \ + -label [lindex $node 1] \ + -treevarname [lindex $node 2] \ + -href [lindex $node 3] \ + -attach_to_node [lindex $node 4] \ + -dynamic_load [lindex $node 5] \ + -open [lindex $node 6] ] } - } - append script "${varname}.draw(); " + } + append script "${varname}.draw(); " global ajax_helper_init_scripts append ajax_helper_init_scripts [ah::yui::addlistener \ @@ -431,20 +432,20 @@ } ad_proc -private ah::yui::create_tree_node { - -varname:required - -label:required - -treevarname:required - {-href "javascript:void(0)"} - {-attach_to_node ""} - {-dynamic_load ""} - {-open "false"} + -varname:required + -label:required + -treevarname:required + {-href "javascript:void(0)"} + {-attach_to_node ""} + {-dynamic_load ""} + {-open "false"} {-droppable:boolean} } { - Generates the javascript to add a node to a yahoo tree view control - http://developer.yahoo.com/yui/treeview/ + 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) - @creation-date 2006-11-05 + @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. @@ -454,28 +455,28 @@ @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}\"}; " + set script "var od${varname} = {label: \"${label}\", id: \"${varname}\", href: \"${href}\"}; " - if { $attach_to_node ne "" } { - 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; " - } + if { $attach_to_node ne "" } { + 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; " + } - if { $open eq "" } { set open "false" } + if { $open eq "" } { set open "false" } - append script "var nd${varname} = new YAHOO.widget.TextNode(od${varname},node,${open}); " + append script "var nd${varname} = new YAHOO.widget.TextNode(od${varname},node,${open}); " if { $droppable_p } { append script "var dd${varname} = new YAHOO.util.DDTarget(nd${varname}.labelElId); " } - if { $dynamic_load ne "" } { - append script "nd${varname}.setDynamicLoad(${dynamic_load}); " - } + if { $dynamic_load ne "" } { + append script "nd${varname}.setDynamicLoad(${dynamic_load}); " + } - return $script + return $script } ad_proc -public ah::yui::menu_from_markup { @@ -713,15 +714,15 @@ set format "${varname}.formatResult=function(oResultItem, sQuery) { var sMarkup=${markup}; return sMarkup; };" } else { - + # no, transform the list into an array set script "var ${varname}Arr = \[ '[join $suggestlist "','"]' \];" set format "" } - + # create the datasource object append script "var ${varname}DS = new YAHOO.widget.DS_JSArray(${varname}Arr);" - + # create autocomplete object with some predefined options append script "if (document.getElementById('${inputid}')) {" append script "var ${varname} = new YAHOO.widget.AutoComplete('${inputid}','${id}', ${varname}DS);" @@ -733,33 +734,32 @@ append script "${varname}.delimChar=\"${delimchar}\";" append script "${varname}.forceSelection=\"${forceselection}\";" - append script "${varname}.allowBrowserAutocomplete=false;" - append script "${varname}.typeAhead=true;" - append script ${format} + append script "${varname}.allowBrowserAutocomplete=false;" + append script "${varname}.typeAhead=true;" + append script ${format} -# append script "${varname}.doBeforeExpandContainer = function(oTextbox, oContainer, sQuery, aResults) {var pos = YAHOO.util.Dom.getXY(oTextbox);pos\[1\] += YAHOO.util.Dom.get(oTextbox).offsetHeight;YAHOO.util.Dom.setXY(oContainer,pos);YAHOO.util.Dom.setStyle(oContainer,'overflow-y','auto');YAHOO.util.Dom.setStyle(oContainer,'overflow-x','hidden');YAHOO.util.Dom.setStyle(oContainer,'position','absolute');YAHOO.util.Dom.setStyle(oContainer,'height','150px');YAHOO.util.Dom.setStyle(oContainer,'z-index','100');return true;};" -# append script ${format} -# append script "${varname}.containerCollapseEvent.subscribe([ah::create_js_function -body "YAHOO.util.Dom.setStyle('${id}', 'height', 0)" -parameters [list "type" "args"] ]);" -# append script "${varname}.itemArrowToEvent.subscribe([ah::create_js_function -body "elItem\[1\].scrollIntoView(false)" -parameters [list "oSelf" "elItem"] ]); " + # append script "${varname}.doBeforeExpandContainer = function(oTextbox, oContainer, sQuery, aResults) {var pos = YAHOO.util.Dom.getXY(oTextbox);pos\[1\] += YAHOO.util.Dom.get(oTextbox).offsetHeight;YAHOO.util.Dom.setXY(oContainer,pos);YAHOO.util.Dom.setStyle(oContainer,'overflow-y','auto');YAHOO.util.Dom.setStyle(oContainer,'overflow-x','hidden');YAHOO.util.Dom.setStyle(oContainer,'position','absolute');YAHOO.util.Dom.setStyle(oContainer,'height','150px');YAHOO.util.Dom.setStyle(oContainer,'z-index','100');return true;};" + # append script ${format} + # append script "${varname}.containerCollapseEvent.subscribe([ah::create_js_function -body "YAHOO.util.Dom.setStyle('${id}', 'height', 0)" -parameters [list "type" "args"] ]);" + # append script "${varname}.itemArrowToEvent.subscribe([ah::create_js_function -body "elItem\[1\].scrollIntoView(false)" -parameters [list "oSelf" "elItem"] ]); " - foreach {name value} $events { + foreach {name value} $events { append script "${varname}.${name}.subscribe${value};\n" } - + # prevent the container from overlapping other elements, e.g. buttons, links - # remove the yui-ac-input class + # remove the yui-ac-input class append script [ah::yui::cssclass \ -varname "yuiinputclass${varname}" \ -action "remove" \ -element ${inputid} \ -classname "yui-ac-input" ] - + append script "}; " - + global ajax_helper_init_scripts append ajax_helper_init_scripts $script } } - Index: openacs-4/packages/ajaxhelper/tcl/dynamic-load-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/tcl/dynamic-load-procs.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/ajaxhelper/tcl/dynamic-load-procs.tcl 21 Sep 2018 14:11:55 -0000 1.2 +++ openacs-4/packages/ajaxhelper/tcl/dynamic-load-procs.tcl 21 Sep 2018 14:19:14 -0000 1.3 @@ -1,149 +1,149 @@ ad_library { - Ajax Experimental Procs + Ajax Experimental Procs - @author Hamilton Chua (ham@solutiongrove.com) - @creation-date 2006-11-1 + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-11-1 } namespace eval ah::exp { } ad_proc -public ah::exp::yui_js_source_dynamic { - {-js "default"} - {-enclose:boolean} + {-js "default"} + {-enclose:boolean} } { - Dynamically Loads the Yahoo UI javascript libraries. - WARNING : experimental, use ah::yui::js_sources instead + Dynamically Loads the Yahoo UI javascript libraries. + WARNING : experimental, use ah::yui::js_sources instead - @author Hamilton Chua (ham@solutiongrove.com) - @creation-date 2006-04-20 + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-04-20 - @param js Comma separated list of javascript files to load - Valid values include - "default" : loads yui.js and dom.js, the most commonly used - "animation" : loads js for animation - "event" : loads js for event monitoring (e.g. listnern) - "treeview" : loads js for Yahoo's Tree View control - "calendar" : loads js for Yahoo's Calendar Control - "dragdrop" : loads js for Yahoo's Drag and Drop functions - "slider" : loads js for slider functions + @param js Comma separated list of javascript files to load + Valid values include + "default" : loads yui.js and dom.js, the most commonly used + "animation" : loads js for animation + "event" : loads js for event monitoring (e.g. listnern) + "treeview" : loads js for Yahoo's Tree View control + "calendar" : loads js for Yahoo's Calendar Control + "dragdrop" : loads js for Yahoo's Drag and Drop functions + "slider" : loads js for slider functions } { - set ah_base_url [ah::get_url] - set script "" - set js_file_list [split $js ","] - - foreach x $js_file_list { - switch $x { - "animation" { - append script [ah::js_include -js_file "${ah_base_url}yui/animation/animation.js"] - } - "event" { - append script [ah::js_include -js_file "${ah_base_url}yui/event/event.js"] - } - "treeview" { - append script [ah::js_include -js_file "${ah_base_url}yui/treeview/treeview.js"] - } - "calendar" { - append script [ah::js_include -js_file "${ah_base_url}yui/calendar/calendar.js"] - } - "dragdrop" { - append script [ah::js_include -js_file "${ah_base_url}yui/dragdrop/dragdrop.js"] - } - "slider" { - append script [ah::js_include -js_file "${ah_base_url}yui/slider/slider.js"] - } - default { - append script [ah::js_include -js_file "${ah_base_url}yui/yui.js"] - append script [ah::js_include -js_file "${ah_base_url}yui/dom/dom.js"] - } - } - } + set ah_base_url [ah::get_url] + set script "" + set js_file_list [split $js ","] - if { $enclose_p } { set script [ah::enclose_in_script -script ${script} ] } + foreach x $js_file_list { + switch $x { + "animation" { + append script [ah::js_include -js_file "${ah_base_url}yui/animation/animation.js"] + } + "event" { + append script [ah::js_include -js_file "${ah_base_url}yui/event/event.js"] + } + "treeview" { + append script [ah::js_include -js_file "${ah_base_url}yui/treeview/treeview.js"] + } + "calendar" { + append script [ah::js_include -js_file "${ah_base_url}yui/calendar/calendar.js"] + } + "dragdrop" { + append script [ah::js_include -js_file "${ah_base_url}yui/dragdrop/dragdrop.js"] + } + "slider" { + append script [ah::js_include -js_file "${ah_base_url}yui/slider/slider.js"] + } + default { + append script [ah::js_include -js_file "${ah_base_url}yui/yui.js"] + append script [ah::js_include -js_file "${ah_base_url}yui/dom/dom.js"] + } + } + } - return $script + if { $enclose_p } { set script [ah::enclose_in_script -script ${script} ] } + + return $script } ad_proc -private ah::exp::dynamic_load_functions { - + } { - Generates the javascript functions that perform dynamic loading of local javascript files. - http://www.phpied.com/javascript-include/ - WARNING : experimental + Generates the javascript functions that perform dynamic loading of local javascript files. + http://www.phpied.com/javascript-include/ + WARNING : experimental - @author Hamilton Chua (ham@solutiongrove.com) - @creation-date 2006-04-20 + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-04-20 } { - set ah_base_url [ah::get_url] - set script "" - return $script + set ah_base_url [ah::get_url] + set script "" + return $script } ad_proc -public ah::exp::js_include { - {-js_file ""} + {-js_file ""} } { - Generates the javscript to include a js file dynamically via DOM to the head section of the page. - WARNING : experimental + Generates the javscript to include a js file dynamically via DOM to the head section of the page. + WARNING : experimental - @author Hamilton Chua (ham@solutiongrove.com) - @creation-date 2006-04-20 + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-04-20 } { - return "js_include_once('$js_file'); " + return "js_include_once('$js_file'); " } ad_proc -public ah::exp::js_source_dynamic { - {-js "default"} - {-enclose:boolean} + {-js "default"} + {-enclose:boolean} } { - Uses the javascript dynamic loading functions to load the comma separated list of javascript source file. - WARNING : experimental + Uses the javascript dynamic loading functions to load the comma separated list of javascript source file. + WARNING : experimental - @author Hamilton Chua (ham@solutiongrove.com) - @creation-date 2006-04-20 + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-04-20 - @param js A comma separated list of js files to load. Possible values include prototype, scriptaculous, rounder, rico, overlibmws, overlibmws_bubble, overlibmws_scroll, overlibmws_drag - @param enclose Specify this if you want the javascript to be enclosed in script tags, which is usually the case unless you include this along with other javascript. + @param js A comma separated list of js files to load. Possible values include prototype, scriptaculous, rounder, rico, overlibmws, overlibmws_bubble, overlibmws_scroll, overlibmws_drag + @param enclose Specify this if you want the javascript to be enclosed in script tags, which is usually the case unless you include this along with other javascript. } { - set ah_base_url [ah::get_url] - set script "" - set js_file_list [split $js ","] - - foreach x $js_file_list { - switch $x { - "rico" { - append script [ah::js_include -js_file "${ah_base_url}rico/rico.js"] - } - "rounder" { - append script [ah::js_include -js_file "${ah_base_url}rico/rico.js"] - append script [ah::js_include -js_file "${ah_base_url}rico/rounder.js"] - } - "overlibmws" { - append script [ah::js_include -js_file "${ah_base_url}overlibmws/overlibmws.js"] - append script [ah::js_include -js_file "${ah_base_url}overlibmws/overlibmws_overtwo.js"] - } - "overlibmws_bubble" { - append script [ah::js_include -js_file "${ah_base_url}overlibmws/overlibmws_bubble.js"] - } - "overlibmws_scroll" { - append script [ah::js_include -js_file "${ah_base_url}overlibmws/overlibmws_scroll.js"] - } - "overlibmws_drag" { - append script [ah::js_include -js_file "${ah_base_url}overlibmws/overlibmws_draggable.js"] - } - default { - append script [ah::js_include -js_file "${ah_base_url}prototype/prototype.js"] - append script [ah::js_include -js_file "${ah_base_url}scriptaculous/scriptaculous.js"] - } - } - } + set ah_base_url [ah::get_url] + set script "" + set js_file_list [split $js ","] - if { $enclose_p } { set script [ah::enclose_in_script -script ${script} ] } + foreach x $js_file_list { + switch $x { + "rico" { + append script [ah::js_include -js_file "${ah_base_url}rico/rico.js"] + } + "rounder" { + append script [ah::js_include -js_file "${ah_base_url}rico/rico.js"] + append script [ah::js_include -js_file "${ah_base_url}rico/rounder.js"] + } + "overlibmws" { + append script [ah::js_include -js_file "${ah_base_url}overlibmws/overlibmws.js"] + append script [ah::js_include -js_file "${ah_base_url}overlibmws/overlibmws_overtwo.js"] + } + "overlibmws_bubble" { + append script [ah::js_include -js_file "${ah_base_url}overlibmws/overlibmws_bubble.js"] + } + "overlibmws_scroll" { + append script [ah::js_include -js_file "${ah_base_url}overlibmws/overlibmws_scroll.js"] + } + "overlibmws_drag" { + append script [ah::js_include -js_file "${ah_base_url}overlibmws/overlibmws_draggable.js"] + } + default { + append script [ah::js_include -js_file "${ah_base_url}prototype/prototype.js"] + append script [ah::js_include -js_file "${ah_base_url}scriptaculous/scriptaculous.js"] + } + } + } - return $script + if { $enclose_p } { set script [ah::enclose_in_script -script ${script} ] } + + return $script } Index: openacs-4/packages/dotlrn/tcl/dotlrn-init.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/tcl/dotlrn-init.tcl,v diff -u -r1.46 -r1.47 --- openacs-4/packages/dotlrn/tcl/dotlrn-init.tcl 21 Sep 2018 14:11:55 -0000 1.46 +++ openacs-4/packages/dotlrn/tcl/dotlrn-init.tcl 21 Sep 2018 14:19:14 -0000 1.47 @@ -43,22 +43,22 @@ -package_key dotlrn \ -parameter DotlrnCache \ -default_size 2000000 - + # dotlrn-user_cache: user specific stuff ::acs::KeyPartitionedCache create ::dotlrn::dotlrn_user_cache \ -package_key dotlrn \ -parameter DotlrnUserCache \ - -default_size 2000000 - + -default_size 2000000 + # dotlrn_community_cache: holds community specific stuff like # "package_id", "name", "portal_id" etc ::acs::KeyPartitionedCache create ::dotlrn::dotlrn_community_cache \ -package_key dotlrn \ -parameter DotlrnCommunityCache \ - -default_size 2000000 - - - + -default_size 2000000 + + + set package_id [dotlrn::get_package_id] # make sure we aren't inheriting permissions from dotlrn's parent object Index: openacs-4/packages/evaluation/www/admin/evaluations/evaluate-students.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/www/admin/evaluations/evaluate-students.tcl,v diff -u -r1.14 -r1.15 --- openacs-4/packages/evaluation/www/admin/evaluations/evaluate-students.tcl 21 Sep 2018 14:11:55 -0000 1.14 +++ openacs-4/packages/evaluation/www/admin/evaluations/evaluate-students.tcl 21 Sep 2018 14:19:14 -0000 1.15 @@ -1,17 +1,17 @@ # /packages/evaluation/www/admin/evaluations/evaluate-students.tcl -ad_page_contract { - This page asks for an evaluation confirmation - - @author jopez@galileo.edu +ad_page_contract { + This page asks for an evaluation confirmation + + @author jopez@galileo.edu @creation-date Mar 2004 @cvs-id $Id$ -} { +} { task_id:naturalnum,notnull max_grade:integer,notnull item_ids:array,integer,optional item_to_edit_ids:array,integer,optional - + grades:array,optional reasons:array,optional show_student:array,optional @@ -28,173 +28,173 @@ {grade_all ""} } -validate { valid_grades_wa { - set counter 0 - foreach party_id [array names grades_wa] { - if { [info exists grades_wa($party_id)] && $grades_wa($party_id) ne "" } { - incr counter - set grades_wa($party_id) [util::trim_leading_zeros $grades_wa($party_id)] - if { ![ad_var_type_check_number_p $grades_wa($party_id)] } { - set wrong_grade $grades_wa($party_id) - ad_complain "[_ evaluation.lt_The_grade_must_be_a_v]" - } - } - } - if { !$counter && ([array size show_student_wa] > 0) } { - ad_complain "[_ evaluation.lt_There_must_be_at_leas]" - } + set counter 0 + foreach party_id [array names grades_wa] { + if { [info exists grades_wa($party_id)] && $grades_wa($party_id) ne "" } { + incr counter + set grades_wa($party_id) [util::trim_leading_zeros $grades_wa($party_id)] + if { ![ad_var_type_check_number_p $grades_wa($party_id)] } { + set wrong_grade $grades_wa($party_id) + ad_complain "[_ evaluation.lt_The_grade_must_be_a_v]" + } + } + } + if { !$counter && ([array size show_student_wa] > 0) } { + ad_complain "[_ evaluation.lt_There_must_be_at_leas]" + } } valid_grades_na { - set counter 0 - foreach party_id [array names grades_na] { - if { $grade_all eq "" } { - if { [info exists grades_na($party_id)] && $grades_na($party_id) ne "" } { - incr counter - set grades_na($party_id) [util::trim_leading_zeros $grades_na($party_id)] - if { ![ad_var_type_check_number_p $grades_na($party_id)] } { - set wrong_grade $grades_na($party_id) - ad_complain "[_ evaluation.lt_The_grade_must_be_a_v]" - } - } - } else { - set grades_na($party_id) 0 - } - } - if { !$counter && ([array size show_student_na] > 0) && $grade_all eq "" } { - ad_complain "[_ evaluation.lt_There_must_be_at_leas]" - } + set counter 0 + foreach party_id [array names grades_na] { + if { $grade_all eq "" } { + if { [info exists grades_na($party_id)] && $grades_na($party_id) ne "" } { + incr counter + set grades_na($party_id) [util::trim_leading_zeros $grades_na($party_id)] + if { ![ad_var_type_check_number_p $grades_na($party_id)] } { + set wrong_grade $grades_na($party_id) + ad_complain "[_ evaluation.lt_The_grade_must_be_a_v]" + } + } + } else { + set grades_na($party_id) 0 + } + } + if { !$counter && ([array size show_student_na] > 0) && $grade_all eq "" } { + ad_complain "[_ evaluation.lt_There_must_be_at_leas]" + } } valid_grades { - set counter 0 - foreach party_id [array names grades] { - if { [info exists grades($party_id)] && $grades($party_id) ne "" } { - set grades($party_id) [util::trim_leading_zeros $grades($party_id)] - if { ![ad_var_type_check_number_p $grades($party_id)] } { - set wrong_grade $grades($party_id) - ad_complain "[_ evaluation.lt_The_grade_most_be_a_v]" - } else { - set old_grade [format %.2f [db_string get_old_grade { *SQL* }]] - if { ![string equal $old_grade [format %.2f [expr {$grades($party_id)*100/$max_grade}]]] } { - incr counter - if { $max_grade != 100 } { - append reasons($party_id) "[_ evaluation.Weight_change]" - } - if { ![info exists reasons($party_id)] || $reasons($party_id) eq "" } { - set grade_wo_reason $grades($party_id) - ad_complain "[_ evaluation.lt_You_must_give_an_edit]" - } - set grades_to_edit($party_id) $grades($party_id) - set reasons_to_edit($party_id) $reasons($party_id) - set show_student_to_edit($party_id) $show_student($party_id) - } - } - } - } - if { !$counter && ([array size show_student] > 0) && ($max_grade == 100) } { - ad_complain "[_ evaluation.lt_There_must_be_at_leas]" - } + set counter 0 + foreach party_id [array names grades] { + if { [info exists grades($party_id)] && $grades($party_id) ne "" } { + set grades($party_id) [util::trim_leading_zeros $grades($party_id)] + if { ![ad_var_type_check_number_p $grades($party_id)] } { + set wrong_grade $grades($party_id) + ad_complain "[_ evaluation.lt_The_grade_most_be_a_v]" + } else { + set old_grade [format %.2f [db_string get_old_grade { *SQL* }]] + if { ![string equal $old_grade [format %.2f [expr {$grades($party_id)*100/$max_grade}]]] } { + incr counter + if { $max_grade != 100 } { + append reasons($party_id) "[_ evaluation.Weight_change]" + } + if { ![info exists reasons($party_id)] || $reasons($party_id) eq "" } { + set grade_wo_reason $grades($party_id) + ad_complain "[_ evaluation.lt_You_must_give_an_edit]" + } + set grades_to_edit($party_id) $grades($party_id) + set reasons_to_edit($party_id) $reasons($party_id) + set show_student_to_edit($party_id) $show_student($party_id) + } + } + } + } + if { !$counter && ([array size show_student] > 0) && ($max_grade == 100) } { + ad_complain "[_ evaluation.lt_There_must_be_at_leas]" + } } valid_data { - foreach party_id [array names comments_wa] { - if { [info exists comments_wa($party_id)] && ![info exists grades_wa($party_id)] } { - set wrong_comments $comments_wa($party_id) - ad_complain "[_ evaluation.lt_There_is_a_comment_fo]" - } - if { [info exists comments_wa($party_id)] && ([string length $comments_wa($party_id)] > 400) } { - set wrong_comments $comments_wa($party_id) - ad_complain "[_ evaluation.lt_There_is_a_comment_la_1]" - } - } - foreach party_id [array names comments_na] { - if { [info exists comments_na($party_id)] && ![info exists grades_na($party_id)] } { - set wrong_comments $comments_na($party_id) - ad_complain "[_ evaluation.lt_There_is_a_comment_fo]" - } - if { [info exists comments_na($party_id)] && ([string length $comments_na($party_id)] > 400) } { - set wrong_comments $comments_na($party_id) - ad_complain "[_ evaluation.lt_There_is_a_comment_la]" - } - } - foreach party_id [array names reasons] { - if { [info exists reasons($party_id)] && ![info exists grades($party_id)] } { - set wrong_comments $reasons($party_id) - ad_complain "[_ evaluation.lt_There_is_an_edit_reas]" - } - if { [info exists reasons($party_id)] && ([string length $reasons($party_id)] > 400) } { - set wrong_comments $reasons($party_id) - ad_complain "[_ evaluation.lt_There_is_an_edit_reas_1]" - } - } + foreach party_id [array names comments_wa] { + if { [info exists comments_wa($party_id)] && ![info exists grades_wa($party_id)] } { + set wrong_comments $comments_wa($party_id) + ad_complain "[_ evaluation.lt_There_is_a_comment_fo]" + } + if { [info exists comments_wa($party_id)] && ([string length $comments_wa($party_id)] > 400) } { + set wrong_comments $comments_wa($party_id) + ad_complain "[_ evaluation.lt_There_is_a_comment_la_1]" + } + } + foreach party_id [array names comments_na] { + if { [info exists comments_na($party_id)] && ![info exists grades_na($party_id)] } { + set wrong_comments $comments_na($party_id) + ad_complain "[_ evaluation.lt_There_is_a_comment_fo]" + } + if { [info exists comments_na($party_id)] && ([string length $comments_na($party_id)] > 400) } { + set wrong_comments $comments_na($party_id) + ad_complain "[_ evaluation.lt_There_is_a_comment_la]" + } + } + foreach party_id [array names reasons] { + if { [info exists reasons($party_id)] && ![info exists grades($party_id)] } { + set wrong_comments $reasons($party_id) + ad_complain "[_ evaluation.lt_There_is_an_edit_reas]" + } + if { [info exists reasons($party_id)] && ([string length $reasons($party_id)] > 400) } { + set wrong_comments $reasons($party_id) + ad_complain "[_ evaluation.lt_There_is_an_edit_reas_1]" + } + } } } set page_title "[_ evaluation.lt_Confirm_Your_Evaluati]" set context [list [list "[export_vars -base student-list { task_id }]" "[_ evaluation.Studen_List_]"] "[_ evaluation.Confirm_Evaluation_]"] -db_1row get_task_info { *SQL* } +db_1row get_task_info { *SQL* } # students with answer -# if the structure of the multirow datasource ever changes, this needs to be rewritten +# if the structure of the multirow datasource ever changes, this needs to be rewritten set counter 0 foreach party_id [array names show_student_wa] { - if { [info exists grades_wa($party_id)] && $grades_wa($party_id) ne "" } { - incr counter - set party_name [db_string get_party_name { *SQL* }] - set evaluations_wa:${counter}(rownum) $counter - set evaluations_wa:${counter}(party_name) $party_name - set evaluations_wa:${counter}(grade) $grades_wa($party_id) - set evaluations_wa:${counter}(comment) " $comments_wa($party_id)" - if {$show_student_wa($party_id) == "t"} { - set evaluations_wa:${counter}(show_student) "[_ evaluation.Yes_]" - } else { - set evaluations_wa:${counter}(show_student) "[_ evaluation.No_]" - } - set item_ids($party_id) [db_nextval acs_object_id_seq] + if { [info exists grades_wa($party_id)] && $grades_wa($party_id) ne "" } { + incr counter + set party_name [db_string get_party_name { *SQL* }] + set evaluations_wa:${counter}(rownum) $counter + set evaluations_wa:${counter}(party_name) $party_name + set evaluations_wa:${counter}(grade) $grades_wa($party_id) + set evaluations_wa:${counter}(comment) " $comments_wa($party_id)" + if {$show_student_wa($party_id) == "t"} { + set evaluations_wa:${counter}(show_student) "[_ evaluation.Yes_]" + } else { + set evaluations_wa:${counter}(show_student) "[_ evaluation.No_]" + } + set item_ids($party_id) [db_nextval acs_object_id_seq] } } set evaluations_wa:rowcount $counter # students with no answer -# if the structure of the multirow datasource ever changes, this needs to be rewritten +# if the structure of the multirow datasource ever changes, this needs to be rewritten set counter 0 foreach party_id [array names show_student_na] { - if { [info exists grades_na($party_id)] && $grades_na($party_id) ne "" } { - incr counter - set party_name [db_string get_party_name { *SQL* }] - set evaluations_na:${counter}(rownum) $counter - set evaluations_na:${counter}(party_name) $party_name - set evaluations_na:${counter}(grade) $grades_na($party_id) - set evaluations_na:${counter}(comment) " $comments_na($party_id)" - if {$show_student_na($party_id) == "t"} { - set evaluations_na:${counter}(show_student) "[_ evaluation.Yes_]" - } else { - set evaluations_na:${counter}(show_student) "[_ evaluation.No_]" - } - set item_ids($party_id) [db_nextval acs_object_id_seq] + if { [info exists grades_na($party_id)] && $grades_na($party_id) ne "" } { + incr counter + set party_name [db_string get_party_name { *SQL* }] + set evaluations_na:${counter}(rownum) $counter + set evaluations_na:${counter}(party_name) $party_name + set evaluations_na:${counter}(grade) $grades_na($party_id) + set evaluations_na:${counter}(comment) " $comments_na($party_id)" + if {$show_student_na($party_id) == "t"} { + set evaluations_na:${counter}(show_student) "[_ evaluation.Yes_]" + } else { + set evaluations_na:${counter}(show_student) "[_ evaluation.No_]" + } + set item_ids($party_id) [db_nextval acs_object_id_seq] } } set evaluations_na:rowcount $counter # editing grades -# if the structure of the multirow datasource ever changes, this needs to be rewritten +# if the structure of the multirow datasource ever changes, this needs to be rewritten set counter 0 foreach party_id [array names show_student] { - if { [info exists grades_to_edit($party_id)] && $grades_to_edit($party_id) ne "" } { - incr counter - set party_name [db_string get_party_name { *SQL* }] - set evaluations:${counter}(rownum) $counter - set evaluations:${counter}(party_name) $party_name - set evaluations:${counter}(grade) $grades_to_edit($party_id) - set evaluations:${counter}(reason) $reasons_to_edit($party_id) - if {$show_student_to_edit($party_id) == "t"} { - set evaluations:${counter}(show_student) "[_ evaluation.Yes_]" - } else { - set evaluations:${counter}(show_student) "[_ evaluation.No_]" - } + if { [info exists grades_to_edit($party_id)] && $grades_to_edit($party_id) ne "" } { + incr counter + set party_name [db_string get_party_name { *SQL* }] + set evaluations:${counter}(rownum) $counter + set evaluations:${counter}(party_name) $party_name + set evaluations:${counter}(grade) $grades_to_edit($party_id) + set evaluations:${counter}(reason) $reasons_to_edit($party_id) + if {$show_student_to_edit($party_id) == "t"} { + set evaluations:${counter}(show_student) "[_ evaluation.Yes_]" + } else { + set evaluations:${counter}(show_student) "[_ evaluation.No_]" + } } } @@ -205,9 +205,6 @@ template::add_event_listener -CSSclass "backbuttons" -script {history.go(-1);} - - - # Local variables: # mode: tcl # tcl-indent-level: 4 Index: openacs-4/packages/xolp/tcl/test/xolp-test-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xolp/tcl/test/xolp-test-procs.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/xolp/tcl/test/xolp-test-procs.tcl 21 Sep 2018 14:11:55 -0000 1.5 +++ openacs-4/packages/xolp/tcl/test/xolp-test-procs.tcl 21 Sep 2018 14:19:14 -0000 1.6 @@ -1569,4 +1569,3 @@ aa_equals "User is not a thinker." [$level name] "luser" } } - Index: openacs-4/packages/xowiki/tcl/menu-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/menu-procs.tcl,v diff -u -r1.18 -r1.19 --- openacs-4/packages/xowiki/tcl/menu-procs.tcl 21 Sep 2018 14:11:55 -0000 1.18 +++ openacs-4/packages/xowiki/tcl/menu-procs.tcl 21 Sep 2018 14:19:14 -0000 1.19 @@ -18,7 +18,7 @@ # ::xo::tdom::Class create MenuComponent \ -superclass ::xo::tdom::Object - + MenuComponent instproc js_name {} { return [::xowiki::Includelet js_name [self]] } @@ -275,7 +275,7 @@ # {dropzone -name DropZone -label DropZone -uploader File} # {modebutton -name Admin -label admin -button admin} - + set :parent_id $parent_id foreach me $items { @@ -285,11 +285,11 @@ set properties [lrange $me 1 end] switch -- $kind { - + clear_menu { :clear_menu -menu [dict get $properties -menu] } - + form_link - entry { # sample entry: entry -name New.YouTubeLink -label YouTube -form en:YouTube.form @@ -316,7 +316,7 @@ } :add_menu_item -name [dict get $properties -name] -item $item } - + "dropzone" { foreach {var default} { name dropzone @@ -364,7 +364,7 @@ foreach e ${:Menues} { lappend result $e [list kind MenuButton {*}[set :Menu($e)]] } - + foreach e [:array name ModeButton] { lappend result $e [list kind ModeButton {*}[set :ModeButton($e)]] } @@ -385,7 +385,7 @@ } - + # ::xo::tdom::Class create MenuDropZone \ # -superclass MenuComponent \ # -parameter { 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 -r1.20 -r1.21 --- openacs-4/packages/ajaxhelper/tcl/ajax-procs.tcl 21 Sep 2018 14:23:01 -0000 1.20 +++ openacs-4/packages/ajaxhelper/tcl/ajax-procs.tcl 21 Sep 2018 14:28:45 -0000 1.21 @@ -1,9 +1,9 @@ ad_library { - Library for Ajax Helper Procs + Library for Ajax Helper Procs - @author Hamilton Chua (ham@solutiongrove.com) - @creation-date 2006-01-16 + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-01-16 } namespace eval ah { } @@ -19,37 +19,37 @@ global ajax_helper_dojo_js_sources global ajax_helper_custom_scripts global ajax_helper_init_scripts - + set js_sources "" set init_body "" - + if { [info exists ajax_helper_js_sources] } { append js_sources [ah::load_js_sources -source_list $ajax_helper_js_sources] } - + if { [info exists ajax_helper_yui_js_sources] } { - + append js_sources [ah::yui::load_js_sources -source_list $ajax_helper_yui_js_sources] - + # Yahoo has implemented a theming system, to make the css work, a class must be added # to the body of the page before any widget is rendered append init_body [ah::yui::cssclass \ - -varname "yuiclass" \ - -action "add" \ - -element "document.body" \ - -classname "yui-skin-sam" \ - -element_is_var ] + -varname "yuiclass" \ + -action "add" \ + -element "document.body" \ + -classname "yui-skin-sam" \ + -element_is_var ] } - + if { [info exists ajax_helper_dojo_js_sources] } { append js_sources [ah::dojo::load_js_sources -source_list $ajax_helper_dojo_js_sources] } - + if { ![info exists ajax_helper_custom_scripts] } { set ajax_helper_custom_scripts "" } - if { [info exists ajax_helper_init_scripts] } { append init_body $ajax_helper_init_scripts } - + if { [info exists ajax_helper_init_scripts] } { append init_body $ajax_helper_init_scripts } + set js_init_script [ah::create_js_function -name "ah_page_init" -body ${init_body}] - + set script " ${js_init_script} ${ajax_helper_custom_scripts} @@ -59,7 +59,7 @@ return $js_sources -} +} # ********* Loading Sources ********** @@ -68,13 +68,13 @@ -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. + 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 + @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 +#split up the comma delimited sources into a list set source_list [split $sources ","] set ah_base_url [ah::get_url] @@ -122,40 +122,40 @@ } ad_proc -deprecated -public ah::js_sources { - {-source "default"} + {-source "default"} } { - Will load any of the following javascript sources - prototype, - scriptaculous, - rounder, - 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, unless of course you want to write your own javascript. + Will load any of the following javascript sources + prototype, + scriptaculous, + rounder, + 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, unless of course you want to write your own javascript. - @author Hamilton Chua (ham@solutiongrove.com) - @creation-date 2006-01-16 + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-01-16 @see ah::requires instead - @param source The caller can specify which set of javascript source files to load. This can be a comma seprated list - 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, - "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. + @param source The caller can specify which set of javascript source files to load. This can be a comma seprated list + 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, + "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. - @return - @error + @return + @error } { - set ah_base_url [ah::get_url] + set ah_base_url [ah::get_url] set script "" set minsuffix "" @@ -166,50 +166,50 @@ # js_sources was called with no parameters, just load the defaults if { $source eq "default" } { if { ![ah::is_js_sources_loaded -js_source "prototype"] } { - # load prototype - template::head::add_javascript -src "${ah_base_url}prototype/prototype${minsuffix}.js" - # make sure helper procs don't load it again - lappend ajax_helper_js_sources "prototype" + # load prototype + template::head::add_javascript -src "${ah_base_url}prototype/prototype${minsuffix}.js" + # make sure helper procs don't load it again + lappend ajax_helper_js_sources "prototype" } if { ![ah::is_js_sources_loaded -js_source "scriptaculous"] } { - # load scriptaculous - template::head::add_javascript -src "${ah_base_url}scriptaculous/scriptaculous${minsuffix}.js" - # make sure it doesn't get loaded again - lappend ajax_helper_js_sources "scriptaculous" + # load scriptaculous + template::head::add_javascript -src "${ah_base_url}scriptaculous/scriptaculous${minsuffix}.js" + # make sure it doesn't get loaded again + lappend ajax_helper_js_sources "scriptaculous" } } - set js_file_list [split $source ","] + set js_file_list [split $source ","] - foreach x $js_file_list { - switch $x { - "rounder" { - if { ![ah::is_js_sources_loaded -js_source "rounder"] } { - template::head::add_javascript -src "${ah_base_url}curvycorners/rounded_corners_lite.inc.js" - } - } - "overlibmws" { - if { ![ah::is_js_sources_loaded -js_source "overlibmws"] } { - template::head::add_javascript -src "${ah_base_url}overlibmws/overlibmws${minsuffix}.js" - template::head::add_javascript -src "${ah_base_url}overlibmws/overlibmws_overtwo${minsuffix}.js" - } - } - "overlibmws_bubble" { - if { ![ah::is_js_sources_loaded -js_source "overlibmws_bubble"] } { - template::head::add_javascript -script "var OLbubbleImageDir=\"${ah_base_url}overlibmws\";" - template::head::add_javascript -src "${ah_base_url}overlibmws/overlibmws_bubble${minsuffix}.js" - } - } - "overlibmws_scroll" { - if { ![ah::is_js_sources_loaded -js_source "overlibmws_scroll"] } { - template::head::add_javascript -src "${ah_base_url}overlibmws/overlibmws_scroll${minsuffix}.js" - } - } - "overlibmws_drag" { - if { ![ah::is_js_sources_loaded -js_source "overlibmws_drag"] } { - template::head::add_javascript -src "${ah_base_url}overlibmws/overlibmws_draggable${minsuffix}.js" - } - } + foreach x $js_file_list { + switch $x { + "rounder" { + if { ![ah::is_js_sources_loaded -js_source "rounder"] } { + template::head::add_javascript -src "${ah_base_url}curvycorners/rounded_corners_lite.inc.js" + } + } + "overlibmws" { + if { ![ah::is_js_sources_loaded -js_source "overlibmws"] } { + template::head::add_javascript -src "${ah_base_url}overlibmws/overlibmws${minsuffix}.js" + template::head::add_javascript -src "${ah_base_url}overlibmws/overlibmws_overtwo${minsuffix}.js" + } + } + "overlibmws_bubble" { + if { ![ah::is_js_sources_loaded -js_source "overlibmws_bubble"] } { + template::head::add_javascript -script "var OLbubbleImageDir=\"${ah_base_url}overlibmws\";" + template::head::add_javascript -src "${ah_base_url}overlibmws/overlibmws_bubble${minsuffix}.js" + } + } + "overlibmws_scroll" { + if { ![ah::is_js_sources_loaded -js_source "overlibmws_scroll"] } { + template::head::add_javascript -src "${ah_base_url}overlibmws/overlibmws_scroll${minsuffix}.js" + } + } + "overlibmws_drag" { + if { ![ah::is_js_sources_loaded -js_source "overlibmws_drag"] } { + template::head::add_javascript -src "${ah_base_url}overlibmws/overlibmws_draggable${minsuffix}.js" + } + } "prototype" { if { ![ah::is_js_sources_loaded -js_source "prototype"] } { template::head::add_javascript -src "${ah_base_url}prototype/prototype${minsuffix}.js" @@ -226,10 +226,10 @@ template::head::add_css -href "${ah_base_url}autosuggest/autosuggest.css" } } - } - } + } + } - return $script + return $script } # ********* UTILS ************ @@ -238,14 +238,14 @@ -lists_of_pairs } { Converts a properly structured list of lists into JSON format. - The list of lists may look something like + 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"] ] + 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 ":". + 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 { @@ -261,173 +261,173 @@ ad_proc -private ah::get_package_id { } { - Return the package_id of the installed and mounted ajax helper instance + Return the package_id of the installed and mounted ajax helper instance - @author Hamilton Chua (ham@solutiongrove.com) - @creation-date 2006-01-16 - @return + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-01-16 + @return - @error + @error } { - return [apm_package_id_from_key "ajaxhelper"] + return [apm_package_id_from_key "ajaxhelper"] } ad_proc -private ah::get_url { } { - Return the path to the ajaxhelper resource files + Return the path to the ajaxhelper resource files - @author Hamilton Chua (ham@solutiongrove.com) - @creation-date 2006-01-16 - @return + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-01-16 + @return - @error + @error } { - return "/resources/ajaxhelper/" + return "/resources/ajaxhelper/" } ad_proc -private ah::isnot_js_var { - element + element } { - Receives a string and surrounds it with single quotes. - 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. + Receives a string and surrounds it with single quotes. + 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) - @creation-date 2006-01-16 - @return + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-01-16 + @return } { - return "'$element'" + return "'$element'" } ad_proc -private ah::enclose_in_script { - -script:required + -script:required } { - Encloses whatever is passed to the script parameter in javascript tags. - @author Hamilton Chua (ham@solutiongrove.com) - @creation-date 2006-01-16 + Encloses whatever is passed to the script parameter in javascript tags. + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-01-16 - @param script string to enclose in javascript tags. + @param script string to enclose in javascript tags. } { - set tag "" - return $tag + set tag "" + return $tag } ad_proc -public ah::create_js_function { - -body:required - {-name ""} - {-parameters "" } + -body:required + {-name ""} + {-parameters "" } } { - Helper procedure to generate a javascript function - @author Hamilton Chua (ham@solutiongrove.com) - @creation-date 2006-11-05 + Helper procedure to generate a javascript function + @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 comma separated list of parameters of the javascript function + @param name The name of the javascript function + @param body The body of the javascript function + @param parameters The comma separated list of parameters of the javascript function } { - set script "function ${name} (" - if { $parameters ne "" } { append script [join $parameters ","] } - append script ") \{ $body \}" - return $script + set script "function ${name} (" + if { $parameters ne "" } { append script [join $parameters ","] } + append script ") \{ $body \}" + return $script } ad_proc -public ah::insert { - -element:required - -text:required - {-position "After"} + -element:required + -text:required + {-position "After"} } { - Inserts text or html in a position given the element as reference. - @author Hamilton Chua (ham@solutiongrove.com) - @creation-date 2006-11-05 + Inserts text or html in a position given the element as reference. + @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. + @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. } { - ah::requires -sources "prototype" + ah::requires -sources "prototype" - set script "new Insertion.${position}('${element}','${text}'); " - return $script + set script "new Insertion.${position}('${element}','${text}'); " + return $script } # ************ Listeners ************** ad_proc -public ah::starteventwatch { - -element:required - -event:required - -obs_function:required - {-element_is_var:boolean} - {-useCapture "false"} + -element:required + -event:required + -obs_function:required + {-element_is_var:boolean} + {-useCapture "false"} } { - 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) - @creation-date 2006-02-28 + 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) + @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 function that will be executed when the event is detected + @param element the element you want to observe + @param event the event that the observer will wait for + @param obs_function the function that will be executed when the event is detected } { - ah::requires -sources "prototype" + 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);" - return $script + if { !$element_is_var_p } { + set element [ah::isnot_js_var $element] + } + set script "Event.observe(${element}, '${event}', ${obs_function}, $useCapture);" + return $script } ad_proc -public ah::stopeventwatch { - -element:required - -event:required - -obs_function:required - {-useCapture "false"} - {-element_is_var:boolean} + -element:required + -event:required + -obs_function:required + {-useCapture "false"} + {-element_is_var:boolean} } { - 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) - @creation-date 2006-02-28 + 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) + @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 function that will be executed when the event is detected + @param element the element you want to observe + @param event the event that the observer will wait for + @param obs_function the function that will be executed when the event is detected } { ah::requires -sources "prototype" - if { !$element_is_var_p } { - set element [ah::isnot_js_var $element] - } - set script "Event.stopObserving(${element}, '${event}', ${obs_function}, $useCapture);" - return $script + if { !$element_is_var_p } { + set element [ah::isnot_js_var $element] + } + set script "Event.stopObserving(${element}, '${event}', ${obs_function}, $useCapture);" + return $script } # *********** Ajax Procs ************* ad_proc -public ah::ajaxperiodical { - -url:required - -container:required - {-frequency "5"} - {-asynchronous "true"} - {-pars ""} - {-options ""} + -url:required + -container:required + {-frequency "5"} + {-asynchronous "true"} + {-pars ""} + {-options ""} } { - 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. - 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 + 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. + 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 @@ -439,480 +439,480 @@ ah::requires -sources "prototype" - set preoptions "asynchronous:${asynchronous},frequency:${frequency},method:'post'" + set preoptions "asynchronous:${asynchronous},frequency:${frequency},method:'post'" - if { $pars ne "" } { - append preoptions ",parameters:$pars" - } - if { $options ne "" } { append preoptions ",$options" } - set script "new Ajax.PeriodicalUpdater('$container','$url',{$preoptions}); " + if { $pars ne "" } { + append preoptions ",parameters:$pars" + } + if { $options ne "" } { append preoptions ",$options" } + set script "new Ajax.PeriodicalUpdater('$container','$url',{$preoptions}); " - return $script + return $script } ad_proc -public ah::ajaxrequest { - -url:required - {-asynchronous "true"} - {-pars ""} - {-options ""} + -url:required + {-asynchronous "true"} + {-pars ""} + {-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. - 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 + 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. + 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) - @creation-date 2006-01-16 + @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 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 } { ah::requires -sources "prototype" - set preoptions "asynchronous:${asynchronous},method:'post'" + set preoptions "asynchronous:${asynchronous},method:'post'" - if { $pars ne "" } { - append preoptions ",parameters:$pars" - } - if { $options ne "" } { append preoptions ",$options" } - set script "new Ajax.Request('$url',{$preoptions}); " + if { $pars ne "" } { + append preoptions ",parameters:$pars" + } + if { $options ne "" } { append preoptions ",$options" } + set script "new Ajax.Request('$url',{$preoptions}); " - return $script + return $script } ad_proc -public ah::ajaxupdate { - -container:required - -url:required - {-asynchronous "true"} - {-pars ""} - {-options ""} - {-effect ""} - {-effectopts ""} - {-enclose:boolean} - {-container_is_var:boolean} + -container:required + -url:required + {-asynchronous "true"} + {-pars ""} + {-options ""} + {-effect ""} + {-effectopts ""} + {-enclose:boolean} + {-container_is_var:boolean} } { - 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. - 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 + 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. + 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 -
-		set script [ah::ajaxupdate -container "connections"  \
-				-url "/xmlhttp/getconnections" \
-				-pars "'q=test&limit_n=3'"
-				-enclose  \
-				-effectopts "duration: 1.5"]
-	
+
+    set script [ah::ajaxupdate -container "connections"  \
+        -url "/xmlhttp/getconnections" \
+        -pars "'q=test&limit_n=3'"
+    -enclose  \
+        -effectopts "duration: 1.5"]
+    
- @author Hamilton Chua (ham@solutiongrove.com) - @creation-date 2006-01-16 + @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 - @param url the url that will be querried for the content to update the container's innerHtml - @param options optional parameters that you can pass to the Ajax.Updater script - @param effect optionally specify an effect to use as the container is updated - @param effectopts options for the effect - @param enclose optionally specify whether you want your script to be enclosed in < script > tags + @param container the 'id' of the layer (div) you want to update via ajax + @param url the url that will be querried for the content to update the container's innerHtml + @param options optional parameters that you can pass to the Ajax.Updater script + @param effect optionally specify an effect to use as the container is updated + @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 } { ah::requires -sources "scriptaculous" - if { !$container_is_var_p } { - set container [ah::isnot_js_var $container] - } + if { !$container_is_var_p } { + set container [ah::isnot_js_var $container] + } - set preoptions "asynchronous:$asynchronous,method:'post'" + set preoptions "asynchronous:$asynchronous,method:'post'" - if { $pars ne "" } { - append preoptions ",parameters:$pars" - } - if { $options ne "" } { append preoptions ",$options" } + if { $pars ne "" } { + append preoptions ",parameters:$pars" + } + if { $options ne "" } { append preoptions ",$options" } - if { $effect ne "" } { - set effects_script [ah::effects -element $container -effect $effect -options $effectopts -element_is_var] - append preoptions ",onSuccess: function(t) { $effects_script }" - } + if { $effect ne "" } { + set effects_script [ah::effects -element $container -effect $effect -options $effectopts -element_is_var] + append preoptions ",onSuccess: function(t) { $effects_script }" + } - set script "new Ajax.Updater ($container,'$url',\{$preoptions\}); " + set script "new Ajax.Updater ($container,'$url',\{$preoptions\}); " - if { $enclose_p } { set script [ah::enclose_in_script -script ${script} ] } + if { $enclose_p } { set script [ah::enclose_in_script -script ${script} ] } - return $script + return $script } # *********** Overlib PopUp ************** ad_proc -public ah::popup { - -content:required - {-options ""} + -content:required + {-options ""} } { - This proc will generate javascript for an overlibmws popup. - This script has to go into a javascript event like onClick or onMouseover. - The ah::source must be executed with -source "overlibmws" - For more information about the options that you can pass - http://www.macridesweb.com/oltest/ - See ah::yui::tooltip for Yahoo's implementation + This proc will generate javascript for an overlibmws popup. + This script has to go into a javascript event like onClick or onMouseover. + The ah::source must be executed with -source "overlibmws" + 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) - @creation-date 2006-02-12 + @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 + @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 } { ah::requires -sources "overlibmws" - if { $options ne "" } { - set overlibopt "," - append overlibopt $options - } else { - set overlibopt "" - } - set script "return overlib\(${content}${overlibopt}\);" - return $script + if { $options ne "" } { + set overlibopt "," + append overlibopt $options + } else { + set overlibopt "" + } + set script "return overlib\(${content}${overlibopt}\);" + return $script } ad_proc -public ah::clearpopup { } { - This proc will generate javascript for to clear a popup. - This script has to go into a javascript event like onClick or onMouseover. - The ah::source must be executed with -source "overlibmws" + This proc will generate javascript for to clear a popup. + This script has to go into a javascript event like onClick or onMouseover. + The ah::source must be executed with -source "overlibmws" - @author Hamilton Chua (ham@solutiongrove.com) - @creation-date 2006-02-12 + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-02-12 - @return + @return - @error + @error } { ah::requires -sources "overlibmws" - set script "nd();" - return $script + set script "nd();" + return $script } ad_proc -public ah::bubblecallout { - -text:required - {-type "square"} - {-textsize "x-small"} + -text:required + {-type "square"} + {-textsize "x-small"} } { - This proc will generate mouseover and mouseout javascript - for dhtml callout or popup using overlibmws - and the overlibmws bubble plugin. + 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) - @creation-date 2006-01-16 + @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 + @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 } { ah::requires -sources "overlibmws_bubble" - set script "onmouseover=\"" - append script [ah::popup -content "'$text'" -options "BUBBLE,BUBBLETYPE,'$type',TEXTSIZE,'$textsize'"] - append script "\" onmouseout=\"" - append script [ah::clearpopup] - append script "\"" - return $script + set script "onmouseover=\"" + append script [ah::popup -content "'$text'" -options "BUBBLE,BUBBLETYPE,'$type',TEXTSIZE,'$textsize'"] + append script "\" onmouseout=\"" + append script [ah::clearpopup] + append script "\"" + return $script } ad_proc -public ah::ajax_bubblecallout { - -url:required - {-pars ""} - {-options ""} - {-type "square"} - {-textsize "x-small"} + -url:required + {-pars ""} + {-options ""} + {-type "square"} + {-textsize "x-small"} } { - This proc executes an xmlhttp call and outputs the response text in a bubblecallout. + This proc executes an xmlhttp call and outputs the response text in a bubblecallout. - @author Hamilton Chua (ham@solutiongrove.com) - @creation-date 2006-01-16 + @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 + @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 } { ah::requires -sources "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();\"" - return $script + 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();\"" + return $script } # ********** Effects ************** ad_proc -public ah::effects { - -element:required - {-effect "Appear"} - {-options ""} - {-element_is_var:boolean} + -element:required + {-effect "Appear"} + {-options ""} + {-element_is_var:boolean} } { - Generates javascript for effects by scriptaculous. - Refer to the scriptaculous documentation for a list of effects. - This proc by default will use the "Appear" effect - 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 + Generates javascript for effects by scriptaculous. + Refer to the scriptaculous documentation for a list of effects. + This proc by default will use the "Appear" effect + 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) - @creation-date 2006-01-16 + @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 + @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 } { ah::requires -sources "scriptaculous" - if { !$element_is_var_p } { - set element [ah::isnot_js_var $element] - } - set script "new Effect.$effect\($element,\{$options\}\); " - return $script + if { !$element_is_var_p } { + set element [ah::isnot_js_var $element] + } + set script "new Effect.$effect\($element,\{$options\}\); " + return $script } ad_proc -public ah::toggle { - -element:required - {-effect "Appear"} - {-options ""} - {-element_is_var:boolean} + -element:required + {-effect "Appear"} + {-options ""} + {-element_is_var:boolean} } { - Generates javascript that toggles the state of an element. - 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 + Generates javascript that toggles the state of an element. + 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) - @creation-date 2006-02-23 + @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 + @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 } { ah::requires -sources "scriptaculous" - if { !$element_is_var_p } { - set element [ah::isnot_js_var $element] - } - set script "Effect.toggle\($element,'$effect',{$options}\)" - return $script + if { !$element_is_var_p } { + set element [ah::isnot_js_var $element] + } + set script "Effect.toggle\($element,'$effect',{$options}\)" + return $script } # ********** Drag n Drop ************** ad_proc -public ah::draggable { - -element:required - {-options ""} - {-uid ""} - {-element_is_var:boolean} + -element:required + {-options ""} + {-uid ""} + {-element_is_var:boolean} } { - Generates javascript to make the given element a draggable. - 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 + Generates javascript to make the given element a draggable. + 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) - @creation-date 2006-01-24 + @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 javascript variable + @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 javascript variable - @return + @return - @error + @error } { ah::requires -sources "scriptaculous" - if { !$element_is_var_p } { - set element [ah::isnot_js_var $element] - } - set script "new Draggable \($element,\{$options\}\);" - return $script + if { !$element_is_var_p } { + set element [ah::isnot_js_var $element] + } + set script "new Draggable \($element,\{$options\}\);" + return $script } ad_proc -public ah::droppable { - -element:required - {-options ""} - {-uid ""} - {-element_is_var:boolean} + -element:required + {-options ""} + {-uid ""} + {-element_is_var:boolean} } { - 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. - Parameters and options are case sensitive, refer to scriptaculous documentation. - http://wiki.script.aculo.us/scriptaculous/show/Droppables + 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. + Parameters and options are case sensitive, refer to scriptaculous documentation. + http://wiki.script.aculo.us/scriptaculous/show/Droppables - @author Hamilton Chua (ham@solutiongrove.com) - @creation-date 2006-02-24 + @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 javascript 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 + @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 javascript 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 } { ah::requires -sources "scriptaculous" - if { !$element_is_var_p } { - set element [ah::isnot_js_var $element] - } + if { !$element_is_var_p } { + set element [ah::isnot_js_var $element] + } - set script "Droppables.add (${element},{${options}});" + set script "Droppables.add (${element},{${options}});" - return $script + return $script } ad_proc -public ah::droppableremove { - -element:required - {-element_is_var:boolean} + -element:required + {-element_is_var:boolean} } { - Generates javascript to remove a droppable. - 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 + Generates javascript to remove a droppable. + 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) - @creation-date 2006-02-24 + @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 javascript variable + @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 javascript variable - @return - @error + @return + @error } { ah::requires -sources "scriptaculous" - if { !$element_is_var_p } { - set element [ah::isnot_js_var $element] - } - set script "Droppables.remove \($element);" - return $script + if { !$element_is_var_p } { + set element [ah::isnot_js_var $element] + } + set script "Droppables.remove \($element);" + return $script } ad_proc -public ah::sortable { - -element:required - {-options ""} - {-element_is_var:boolean} + -element:required + {-options ""} + {-element_is_var:boolean} } { - Generates javascript for sortable elements. - 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 + Generates javascript for sortable elements. + 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) - @creation-date 2006-01-24 + @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 javascript variable + @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 javascript variable - @return - @error + @return + @error } { ah::requires -sources "scriptaculous" - if { !$element_is_var_p } { - set element [ah::isnot_js_var $element] - } - set script "Sortable.destroy($element); " - append script "Sortable.create\($element, \{$options\}\); " - return $script + if { !$element_is_var_p } { + set element [ah::isnot_js_var $element] + } + set script "Sortable.destroy($element); " + append script "Sortable.create\($element, \{$options\}\); " + return $script } # ********** Round Corners ************ ad_proc -public ah::rounder { - -classname:required - {-jsobjname "myBoxObject"} - {-validtags "div"} - {-radius "20"} - {-element_is_var:boolean} - {-enclose:boolean} + -classname:required + {-jsobjname "myBoxObject"} + {-validtags "div"} + {-radius "20"} + {-element_is_var:boolean} + {-enclose:boolean} } { - Generates javascript to round html div elements. - Parameters are case sensitive. - http://www.curvycorners.net/ + Generates javascript to round html div elements. + Parameters are case sensitive. + http://www.curvycorners.net/ - @author Hamilton Chua (ham@solutiongrove.com) - @creation-date 2006-01-24 + @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. - @param jsobjname The javascript object name you want to use. - @param validtags Comma separated values of valid tags to apply rounded corners. Values include "div", "form" or "div,form" - @param radius The radius of the rounded corners. + @param classname The name of the html class that the script will look for. All validtags with this classname will be rounded. + @param jsobjname The javascript object name you want to use. + @param validtags Comma separated values of valid tags to apply rounded corners. Values include "div", "form" or "div,form" + @param radius The radius of the rounded corners. } { ah::requires -sources "rounder" - if { !$element_is_var_p } { - set element [ah::isnot_js_var $element] - } + if { !$element_is_var_p } { + set element [ah::isnot_js_var $element] + } - set script "var settings = { tl: { radius: ${radius} },tr: { radius: ${radius} },bl: { radius: ${radius} },br: { radius: ${radius} },antiAlias: true,autoPad: true,validTags: \[\"${validtags}\"\]}; - var ${jsobjname} = new curvyCorners(settings, \"${classname}\"); - ${jsobjname}.applyCornersToAll();" + set script "var settings = { tl: { radius: ${radius} },tr: { radius: ${radius} },bl: { radius: ${radius} },br: { radius: ${radius} },antiAlias: true,autoPad: true,validTags: \[\"${validtags}\"\]}; + var ${jsobjname} = new curvyCorners(settings, \"${classname}\"); + ${jsobjname}.applyCornersToAll();" - if { $enclose_p } { set script [ah::enclose_in_script -script ${script} ] } + if { $enclose_p } { set script [ah::enclose_in_script -script ${script} ] } - return $script + return $script } # ************* Auto Suggest ***************** @@ -930,65 +930,65 @@ @creation-date 2006-06-21 @param array_list a list of lists which will be constructed - as the javascript array. this takes priority - over sql_query parameter. + as the javascript array. this takes priority + over sql_query parameter. @param sql_query sql query to pass to db_list_of_lists to generate - the array + the array } { ah::requires -sources "autosuggest" if {[llength $array_list]} { - set suggestion_list $array_list + set suggestion_list $array_list } elseif {$sql_query ne {} } { - set suggestion_list [db_list_of_lists get_array_list $sql_query] + set suggestion_list [db_list_of_lists get_array_list $sql_query] } else { - # just do something for failover - set suggestion_list {} + # just do something for failover + set suggestion_list {} } set suggestions_stub {} append suggestions_stub " -function AUTOSuggestions() { - this.auto = \[ - " + function AUTOSuggestions() { + this.auto = \[ + " -set suggestion_formatted_list {} -foreach suggestion $suggestion_list { - lappend suggestion_formatted_list "\[\"[lindex $suggestion 0]\",\"[lindex $suggestion 1]\"\]" -} + set suggestion_formatted_list {} + foreach suggestion $suggestion_list { + lappend suggestion_formatted_list "\[\"[lindex $suggestion 0]\",\"[lindex $suggestion 1]\"\]" + } -append suggestions_stub [join $suggestion_formatted_list ","] + append suggestions_stub [join $suggestion_formatted_list ","] -append suggestions_stub " - \]; -} -" -append suggestions_stub { - AUTOSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /*:AutoSuggestControl*/, - bTypeAhead /*:boolean*/) { - var aSuggestions = []; - var aDescriptions = []; - var sTextboxValue = oAutoSuggestControl.textbox.value.toLowerCase(); + append suggestions_stub " + \]; + } + " + append suggestions_stub { + AUTOSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /*:AutoSuggestControl*/, + bTypeAhead /*:boolean*/) { + var aSuggestions = []; + var aDescriptions = []; + var sTextboxValue = oAutoSuggestControl.textbox.value.toLowerCase(); - if (sTextboxValue.length > 0){ + 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) { - aSuggestions.push(this.auto[i][0]); - aDescriptions.push(this.auto[i][1]); - } - } - } + //search for matching states + for (var i=0; i < this.auto.length; i++) { + if (this.auto[i][0].toLowerCase().indexOf(sTextboxValue) == 0) { + aSuggestions.push(this.auto[i][0]); + aDescriptions.push(this.auto[i][1]); + } + } + } - //provide suggestions to the control - oAutoSuggestControl.autosuggest(aSuggestions, aDescriptions, bTypeAhead); - }; -} + //provide suggestions to the control + oAutoSuggestControl.autosuggest(aSuggestions, aDescriptions, bTypeAhead); + }; + } -return $suggestions_stub + return $suggestions_stub }