Index: openacs-4/packages/ajaxhelper/tcl/ajax-yahoo-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/tcl/ajax-yahoo-procs.tcl,v
diff -u -N -r1.14 -r1.14.2.1
--- openacs-4/packages/ajaxhelper/tcl/ajax-yahoo-procs.tcl 25 Apr 2018 19:47:46 -0000 1.14
+++ openacs-4/packages/ajaxhelper/tcl/ajax-yahoo-procs.tcl 14 Feb 2019 16:15:01 -0000 1.14.2.1
@@ -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 ","]
@@ -138,41 +139,40 @@
}
-ad_proc -public ah::yui::js_sources {
- {-source "default"}
- {-min:boolean}
+ad_proc -deprecated -public ah::yui::js_sources {
+ {-source "default"}
+ {-min:boolean}
} {
+ 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 +276,7 @@
} {
Generates javascript code to control css class on html elements.
-
+
http://developer.yahoo.com/yui/dom/
@author Hamilton Chua (ham@solutiongrove.com)
@@ -299,75 +299,75 @@
"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.
- set nodes {}
+ set nodes [list]
lappend nodes [list "fld1" "Folder 1" "tree" "" "" "" ""]
lappend nodes [list "fld2" "Folder 2" "tree" "javascript:alert('this is a tree node')" "" "" ""]
@@ -381,44 +381,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 elment where you want to generate the tree view control.
- @param nodes Is list of lists. Each list contains the node information to be passed to ah::yui::create_tree_node to create a node.
- @param varname The javascript variable name to give the tree.
+ @param 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 +431,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 +454,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 {
@@ -531,17 +531,17 @@
Converts a properly structured list of menu items into JSON format.
The list of lists may look something like
- set submenu {}
+ set submenu [list]
lappend submenu [list [list "text" "Submenu1"] [list "url" "http://www.google.com"] ]
lappend submenu [list [list "text" "Submenu2"] [list "url" "http://www.yahoo.com"] ]
each line represents a row composed of lists.
Each list in the row holds a pair that will be joined by ":".
} {
- set rows {}
+ set rows [list]
foreach row $lists_of_pairs {
- set pairs {}
+ set pairs [list]
foreach pair $row {
if { [lindex $pair 0] eq "submenu" } {
set submenulist [lindex $pair 1]
@@ -695,33 +695,33 @@
if { [llength [lindex $suggestlist 0]] > 1} {
# yes , let's create the array for the innerlist and put each array into one big array
- set outerlist {}
+ set outerlist [list]
foreach onelist $suggestlist {
- set escaped_list {}
+ set escaped_list [list]
foreach elm $onelist {
lappend escaped_list [string map {' \\'} $elm]
}
lappend outerlist "\[ '[join $escaped_list "','"]' \]"
}
set script "var ${varname}Arr = \[ [join $outerlist ","] \];"
- set markup {}
+ set markup [list]
for { set x 0} { $x < [llength [lindex $suggestlist 0]] } { incr x} {
lappend markup "oResultItem\[${x}\]"
}
set markup [join $markup "+\" \"+"]
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 +733,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
}
}
-