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.1 -r1.2 --- openacs-4/packages/ajaxhelper/tcl/ajax-yahoo-procs.tcl 5 Apr 2006 06:38:41 -0000 1.1 +++ openacs-4/packages/ajaxhelper/tcl/ajax-yahoo-procs.tcl 20 Aug 2006 14:39:20 -0000 1.2 @@ -7,26 +7,84 @@ @creation-date 2006-01-16 } -namespace eval ah::yahoo { } +namespace eval ah::yui { } -ad_proc -public ah::yahoo::js_sources { - {-default:boolean} - {-source ""} +ad_proc -public ah::yui::js_source_dynamic { + {-js "default"} + {-enclose:boolean} } { + 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 + + @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"] + } + } + } + + if { $enclose_p } { set script [ah::enclose_in_script -script ${script} ] } + + return $script +} + +ad_proc -public ah::yui::js_sources { + {-source "default"} +} { + Generates the < script > syntax needed on the head - for Yahoo's User Interface Library + for yui's User Interface Library The code :
-		[ah::yahoo::js_sources -default]
+		[ah::yui::js_sources -default]
 	
will load the default YUI javascript library which includes the connections and doms js files @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-01-16 @param default Loads the prototype and scriptaculous javascript libraries. - @param source The caller can specify which set of javascript source files to load. + @param source The caller can specify which set of javascript source files to load. You can specify more than one by separating the list with commas. Valid values include "animation" : loads animation.js "event" : loads events.js @@ -36,50 +94,48 @@ "slider" : loads slider.js @return - @error } { set ah_base_url [ah::get_url] set script "" - - if { $default_p } { - append script " \n" - append script " \n" - } else { - if { [info exists source] } { - # load other js libraries - switch $source { - "animation" { - append script " \n" - } - "event" { - append script " \n" - } - "treeview" { - append script " \n" - } - "calendar" { - append script " \n" - } - "dragdrop" { - append script " \n" - } - "slider" { - append script " \n" - } - - default { - # invalid value for source - } + set js_file_list [split $source ","] + + foreach x $js_file_list { + switch $x { + "animation" { + append script " \n" } + "event" { + append script " \n" + } + "treeview" { + append script " \n" + } + "calendar" { + append script " \n" + } + "dragdrop" { + append script " \n" + } + "slider" { + append script " \n" + } + "container" { + append script " \n" + append script " \n" + } + default { + append script " \n" + append script " \n" + } } } return $script } -ad_proc -public ah::yahoo::addlistener { +ad_proc -public ah::yui::addlistener { -element:required -event:required {-callback ""} @@ -91,4 +147,19 @@ set element [ah::isnot_js_var $element] } return "YAHOO.util.Event.addListener($element,\"$event\",${callback});\n" +} + +ad_proc -public ah::yui::tooltip { + -varname:required + -element:required + -message:required + {-enclose:boolean} + {-options ""} +} { + Generates the javascript to create a tooltip using yahoo's user interface javascript library. + For this to work, the default and container sources need to be loaded, see ah::yui::js_sources +} { + set script "var $varname = new YAHOO.widget.Tooltip(\"alertTip\", { context:\"$element\", text:\"$message\", $options });" + if { $enclose_p } { set script [ah::enclose_in_script -script ${script} ] } + return $script } \ No newline at end of file