Index: openacs-4/packages/ajaxhelper/ajaxhelper.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/ajaxhelper.info,v diff -u -N -r1.6 -r1.7 --- openacs-4/packages/ajaxhelper/ajaxhelper.info 21 Oct 2006 06:14:52 -0000 1.6 +++ openacs-4/packages/ajaxhelper/ajaxhelper.info 6 Nov 2006 13:15:28 -0000 1.7 @@ -8,18 +8,18 @@ t ajax - + Hamilton Chua - Provides helper procs to generate javascript used for Ajax and generating cinematic effects. Includes Scriptaculous (1.6.4) Javascript Libraries and the Yahoo UI Libraries (0.11.4). As of 0.7d, all javascript libraries have been moved to ajaxhelper/www/resources to take advantage of caching. + Provides helper procs to generate javascript used for Ajax and generating cinematic effects. Includes Scriptaculous (1.6.4) Javascript Libraries and the Yahoo UI Libraries (0.11.4). As of 0.7d, all javascript libraries have been moved to ajaxhelper/www/resources to take advantage of caching. As of 0.8d, the wrappers will now be able to check a global variable to see if the required sources are loaded. Solution Grove 0 - + - + Index: openacs-4/packages/ajaxhelper/tcl/ajax-dojo-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/tcl/ajax-dojo-procs.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/tcl/ajax-dojo-procs.tcl 6 Nov 2006 13:15:29 -0000 1.1 @@ -0,0 +1,187 @@ +ad_library { + + Library for Ajax Helper Procs + based on the dojo javascript toolkit + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-11-05 +} + +namespace eval ah::dojo { } + +ad_proc -private ah::dojo::load_js_sources { + -source_list +} { + Accepts a tcl list of sources to load. + This source_list will be the global ajax_helper_dojo_js_sources variable. + This script is called in the blank-master template. + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-11-05 +} { + + set ah_base_url [ah::get_url] + set script "" + set dojo_script "" + + foreach source $source_list { + switch $source { + "event" { + append dojo_script "dojo.require(\"dojo.event.*\"); " + } + "io" { + append dojo_script "dojo.require(\"dojo.io.*\"); " + } + "dnd" { + append dojo_script "dojo.require(\"dojo.dnd.*\"); " + } + "json" { + append dojo_script "dojo.require(\"dojo.json\"); " + } + "storage" { + append dojo_script "dojo.require(\"dojo.storage.*\"); " + } + "lfx" { + append dojo_script "dojo.require(\"dojo.lfx.*\"); " + } + "chart" { + append dojo_script "dojo.require(\"dojo.collections.Store\"); " + append dojo_script "dojo.require(\"dojo.charting.Chart\"); " + } + "widget-chart" { + append dojo_script "dojo.require(\"dojo.widget.Chart\"); " + } + } + } + append script [ah::enclose_in_script -script $dojo_script] + return $script + + return "" +} + +ad_proc -private ah::dojo::is_js_sources_loaded { + -js_source +} { + This proc will loops thru source_list and check for the presence of js_source. + If found, this proc will return 1 + If not found, this proc will return 0 + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-11-05 +} { + global ajax_helper_dojo_js_sources + set state 0 + if { [info exists ajax_helper_dojo_js_sources] } { + foreach source $ajax_helper_dojo_js_sources { + if { [string match $source $js_source] } { + set state 1 + break + } + } + } + return $state +} + +ad_proc -public ah::dojo::js_sources { + {-source ""} +} { + Generates the javascript that loads the dojo javascript sources. + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-11-05 + +} { + set ah_base_url [ah::get_url] + if { ![ah::dojo::is_js_sources_loaded -js_source "dojo"] } { + set script "" + } + set dojo_script "" + + foreach source $source_list { + switch $source { + "event" { + if { ![ah::dojo::is_js_sources_loaded -js_source "event"] } { + append dojo_script "dojo.require(\"dojo.event.*\"); " + } + } + "io" { + if { ![ah::dojo::is_js_sources_loaded -js_source "io"] } { + append dojo_script "dojo.require(\"dojo.io.*\"); " + } + } + "dnd" { + if { ![ah::dojo::is_js_sources_loaded -js_source "dnd"] } { + append dojo_script "dojo.require(\"dojo.dnd.*\"); " + } + } + "json" { + if { ![ah::dojo::is_js_sources_loaded -js_source "json"] } { + append dojo_script "dojo.require(\"dojo.json\"); " + } + } + "storage" { + if { ![ah::dojo::is_js_sources_loaded -js_source "storage"] } { + append dojo_script "dojo.require(\"dojo.storage.*\"); " + } + } + "lfx" { + if { ![ah::dojo::is_js_sources_loaded -js_source "lfx"] } { + append dojo_script "dojo.require(\"dojo.lfx.*\"); " + } + } + "chart" { + if { ![ah::dojo::is_js_sources_loaded -js_source "chart"] } { + append dojo_script "dojo.require(\"dojo.collections.Store\"); " + append dojo_script "dojo.require(\"dojo.charting.Chart\"); " + } + } + "widget-chart" { + if { ![ah::dojo::is_js_sources_loaded -js_source "widget-chart"] } { + append dojo_script "dojo.require(\"dojo.widget.Chart\"); " + } + } + } + } + append script [ah::enclose_in_script -script $dojo_script] + return $script +} + +ad_proc -public ah::dojo::args { + -varname:required + -argslist:required +} { + Builds a javascript object that holds the arguments that are commonly passed to a dojo function. + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-11-05 + +} { + set objargs [list] + foreach args $argslist { + lappend objargs [split ":" $args] + } + set objargs [split "," $objargs] + set script "var $varname = {$objargs}; " + return $script +} + +ad_proc -public ah::dojo::iobind { + -objargs:required +} { + Generates the javascript that loads the dojo javascript sources. + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-11-05 + + @param objargs A javascript object generated by ah::dojo::args which contain arguments that is passed to dojo.io.bind. +} { + if { ![ah::dojo::is_js_sources_loaded -js_source "dojo"] } { + global ajax_helper_dojo_js_sources + lappend ajax_helper_dojo_js_sources "dojo" + if { ![ah::dojo::is_js_sources_loaded -js_source "io"] } { + lappend ajax_helper_dojo_js_sources "io" + } + } + set script "dojo.io.bind($objargs); " + return $script +} \ No newline at end of file Index: openacs-4/packages/ajaxhelper/tcl/ajax-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/tcl/ajax-procs.tcl,v diff -u -N -r1.5 -r1.6 --- openacs-4/packages/ajaxhelper/tcl/ajax-procs.tcl 21 Oct 2006 06:14:53 -0000 1.5 +++ openacs-4/packages/ajaxhelper/tcl/ajax-procs.tcl 6 Nov 2006 13:15:29 -0000 1.6 @@ -1,15 +1,156 @@ ad_library { Library for Ajax Helper Procs - based on Scriptaculous and Prototype for Ajax and Effects - OverlibMWS for Popups - @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 { } +# ********* Loading Sources ********** + +ad_proc -private ah::load_js_sources { + -source_list +} { + Accepts a tcl list of sources to load. + This source_list will be the global ajax_helper_js_sources variable. + This script is called in the blank-master template. +} { + set ah_base_url [ah::get_url] + set script "" + foreach source $source_list { + switch $source { + "rico" { + append script " \n" + } + "rounder" { + append script " \n" + } + "overlibmws" { + append script " \n" + append script "\n" + } + "overlibmws_bubble" { + append script "\n" + append script "\n" + } + "overlibmws_scroll" { + append script "\n" + } + "overlibmws_drag" { + append script "\n" + } + "prototype" { + append script " \n" + } + "scriptaculous" { + append script " \n" + } + } + } + return $script +} + +ad_proc -private ah::is_js_sources_loaded { + -js_source +} { + This proc will loop thru source_list and check for the presence of js_source. + If found, this proc will return 1 + If not found, this proc will return 0 +} { + global ajax_helper_js_sources + set state 0 + if { [info exists ajax_helper_js_sources] } { + foreach source $ajax_helper_js_sources { + if { [string match $source $js_source] } { + set state 1 + break + } + } + } + return $state +} + +ad_proc -public ah::js_sources { + {-source "default"} +} { + Will load any of the following javascript sources + prototype, + scriptaculous, + rounder, + overlibmws popups. + This will also check global variables. + 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. + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-01-16 + + @param source The caller can specify which set of javascript source files to load. This can be a comma seprated list + Valid values include + "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. + + @return + @error +} { + + set ah_base_url [ah::get_url] + set js_file_list [split $source ","] + set script "" + + foreach x $js_file_list { + switch $x { + "rounder" { + if { ![ah::is_js_sources_loaded -js_source "rounder"] } { + append script " \n" + } + } + "overlibmws" { + if { ![ah::is_js_sources_loaded -js_source "overlibmws"] } { + append script " \n" + append script "\n" + } + } + "overlibmws_bubble" { + if { ![ah::is_js_sources_loaded -js_source "overlibmws_bubble"] } { + append script "\n" + append script "\n" + } + } + "overlibmws_scroll" { + if { ![ah::is_js_sources_loaded -js_source "overlibmws_scroll"] } { + append script "\n" + } + } + "overlibmws_drag" { + if { ![ah::is_js_sources_loaded -js_source "overlibmws_drag"] } { + append script "\n" + } + } + default { + if { ![ah::is_js_sources_loaded -js_source "prototype"] } { + append script " \n" + } + if { ![ah::is_js_sources_loaded -js_source "scriptaculous"] } { + append script " \n" + } + } + } + } + + return $script +} + +# ********* UTILS ************ + ad_proc -private ah::get_package_id { } { @@ -28,7 +169,7 @@ ad_proc -private ah::get_url { } { - Return the URL to the mounted ajax helper instance + Return the path to the ajaxhelper resource files @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-01-16 @@ -54,103 +195,66 @@ return "'$element'" } -ad_proc -private ah::dynamic_load_functions { - +ad_proc -private ah::enclose_in_script { + -script:required } { - Generates the javascript functions that perform dynamic loading of local javascript files. - http://www.phpied.com/javascript-include/ - WARNING : experimental - + Encloses whatever is passed to the script parameter in javascript tags. @author Hamilton Chua (ham@solutiongrove.com) - @creation-date 2006-04-20 + @creation-date 2006-01-16 + @param script string to enclose in javascript tags. } { - set ah_base_url [ah::get_url] - set script "" - return $script + set tag "" + return $tag } -ad_proc -public ah::js_include { - {-js_file ""} +ad_proc -public ah::create_js_function { + -name:required + -body:required + {-parameters {} } } { - Generates the javscript to include a js file dynamically via DOM to the head section of the page. - WARNING : experimental - + Helper procedure to generate a javascript function @author Hamilton Chua (ham@solutiongrove.com) - @creation-date 2006-04-20 + @creation-date 2006-11-05 + + @param name The name of the javascript function + @param body The body of the javascript function + @param parameters The parameters of the javascript function } { - return "js_include_once('$js_file'); " + set script "function ${name} (" + append script [split "," $parameters] + append script ") \{ " + append script $body + append script " \} " + return $script } -ad_proc -public ah::js_source_dynamic { - {-js "default"} - {-enclose:boolean} +ad_proc -public ah::insert { + -element:required + -text:required + {-position "After"} } { - Uses the javascript dynamic loading functions to load the comma separated list of javascript source file. - WARNING : experimental - + Inserts text or html in a position given the element as reference. @author Hamilton Chua (ham@solutiongrove.com) - @creation-date 2006-04-20 + @creation-date 2006-11-05 - - @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 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. } { - - 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"] - } - } + if { ![ah::is_js_sources_loaded -js_source "prototype"] } { + global ajax_helper_js_sources + lappend ajax_helper_js_sources "prototype" } - if { $enclose_p } { set script [ah::enclose_in_script -script ${script} ] } - - return $script + set script "new Insertion.${position}('${element}','${text}'); " + return $script } -ad_proc -private ah::enclose_in_script { - -script:required -} { - Encloses whatever is passed to the script parameter in javascript tags. - @author Hamilton Chua (ham@solutiongrove.com) - @creation-date 2006-01-16 +# ************ Listeners ************** - @param script string to enclose in javascript tags. -} { - set tag "" - return $tag -} - ad_proc -public ah::starteventwatch { -element:required -event:required @@ -160,15 +264,20 @@ } { Use prototype's Event object to watch/listen to 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 more superior. + 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 funcion that will be executed when the event is detected -} { +} { + if { ![ah::is_js_sources_loaded -js_source "prototype"] } { + global ajax_helper_js_sources + lappend ajax_helper_js_sources "prototype" + } + if { !$element_is_var_p } { set element [ah::isnot_js_var $element] } @@ -193,13 +302,21 @@ @param obs_function the funcion that will be executed when the event is detected } { + if { ![ah::is_js_sources_loaded -js_source "prototype"] } { + global ajax_helper_js_sources + lappend ajax_helper_js_sources "prototype" + } + if { !$element_is_var_p } { 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 @@ -215,6 +332,12 @@ Parameters and options are case sensitive, refer to scriptaculous documentation http://wiki.script.aculo.us/scriptaculous/show/Ajax.PeriodicalUpdater } { + + if { ![ah::is_js_sources_loaded -js_source "prototype"] } { + global ajax_helper_js_sources + lappend ajax_helper_js_sources "prototype" + } + set preoptions "asynchronous:${asynchronous},frequency:${frequency},method:'post'" if { [exists_and_not_null pars] } { @@ -249,6 +372,9 @@ @param asynchronous the default is true } { + global ajax_helper_js_sources + lappend ajax_helper_js_sources "prototype" + set preoptions "asynchronous:${asynchronous},method:'post'" if { [exists_and_not_null pars] } { @@ -300,6 +426,11 @@ @error } { + + global ajax_helper_js_sources + lappend ajax_helper_js_sources "prototype" + lappend ajax_helper_js_sources "scriptaculous" + if { !$container_is_var_p } { set container [ah::isnot_js_var $container] } @@ -323,6 +454,8 @@ return $script } +# *********** Overlib PopUp ************** + ad_proc -public ah::popup { -content:required {-options ""} @@ -345,6 +478,10 @@ @error } { + + global ajax_helper_js_sources + lappend ajax_helper_js_sources "overlibmws" + if { [exists_and_not_null options] } { set overlibopt "," append overlibopt $options @@ -370,6 +507,10 @@ @error } { + + global ajax_helper_js_sources + lappend ajax_helper_js_sources "overlibmws" + set script "nd();" return $script } @@ -383,7 +524,6 @@ This proc will generate mouseover and mouseout javascript for dhtml callout or popup using overlibmws and the overlibmws bubble plugin. - The ah::source must be called with -source "overlibmws,overlibmws_bubble" @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-01-16 @@ -396,6 +536,11 @@ @error } { + + global ajax_helper_js_sources + lappend ajax_helper_js_sources "overlibmws" + lappend ajax_helper_js_sources "overlibmws_bubble" + set script "onmouseover=\"" append script [ah::popup -content "'$text'" -options "BUBBLE,BUBBLETYPE,'$type',TEXTSIZE,'$textsize'"] append script "\" onmouseout=\"" @@ -426,12 +571,19 @@ @error } { + + global ajax_helper_js_sources + lappend ajax_helper_js_sources "overlibmws" + lappend ajax_helper_js_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 } +# ********** Effects ************** + ad_proc -public ah::effects { -element:required {-effect "Appear"} @@ -457,6 +609,14 @@ @error } { + if { ![ah::is_js_sources_loaded -js_source "prototype"] } { + global ajax_helper_js_sources + lappend ajax_helper_js_sources "prototype" + if { ![ah::is_js_sources_loaded -js_source "scriptaculous"] } { + lappend ajax_helper_js_sources "scriptaculous" + } + } + if { !$element_is_var_p } { set element [ah::isnot_js_var $element] } @@ -487,13 +647,23 @@ @error } { + if { ![ah::is_js_sources_loaded -js_source "prototype"] } { + global ajax_helper_js_sources + lappend ajax_helper_js_sources "prototype" + if { ![ah::is_js_sources_loaded -js_source "scriptaculous"] } { + lappend ajax_helper_js_sources "scriptaculous" + } + } + if { !$element_is_var_p } { 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 ""} @@ -518,6 +688,14 @@ @error } { + if { ![ah::is_js_sources_loaded -js_source "prototype"] } { + global ajax_helper_js_sources + lappend ajax_helper_js_sources "prototype" + if { ![ah::is_js_sources_loaded -js_source "scriptaculous"] } { + lappend ajax_helper_js_sources "scriptaculous" + } + } + if { !$element_is_var_p } { set element [ah::isnot_js_var $element] } @@ -550,6 +728,14 @@ @error } { + if { ![ah::is_js_sources_loaded -js_source "prototype"] } { + global ajax_helper_js_sources + lappend ajax_helper_js_sources "prototype" + if { ![ah::is_js_sources_loaded -js_source "scriptaculous"] } { + lappend ajax_helper_js_sources "scriptaculous" + } + } + if { !$element_is_var_p } { set element [ah::isnot_js_var $element] } @@ -578,6 +764,14 @@ @error } { + if { ![ah::is_js_sources_loaded -js_source "prototype"] } { + global ajax_helper_js_sources + lappend ajax_helper_js_sources "prototype" + if { ![ah::is_js_sources_loaded -js_source "scriptaculous"] } { + lappend ajax_helper_js_sources "scriptaculous" + } + } + if { !$element_is_var_p } { set element [ah::isnot_js_var $element] } @@ -607,6 +801,14 @@ @error } { + if { ![ah::is_js_sources_loaded -js_source "prototype"] } { + global ajax_helper_js_sources + lappend ajax_helper_js_sources "prototype" + if { ![ah::is_js_sources_loaded -js_source "scriptaculous"] } { + lappend ajax_helper_js_sources "scriptaculous" + } + } + if { !$element_is_var_p } { set element [ah::isnot_js_var $element] } @@ -615,88 +817,50 @@ return $script } +# ********** Round Corners ************ + ad_proc -public ah::rounder { - -element:required - {-options ""} + -classname:required + {-jsobjname "myBoxObject"} + {-validtags "div"} + {-radius "20"} {-element_is_var:boolean} + {-enclose:boolean} } { Generates javascript to round html div elements. - The ah::source must be executed with -source "rounder" Parameters are case sensitive. - http://encytemedia.com/blog/articles/2005/12/01/rico-rounded-corners-without-all-of-rico + http://www.curvycorners.net/ @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-01-24 - @param element the page element that you want the corners rounded - @param options specify the options for rounding the element + @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. } { + + if { ![ah::is_js_sources_loaded -js_source "rounder"] } { + global ajax_helper_js_sources + lappend ajax_helper_js_sources "rounder" + } + if { !$element_is_var_p } { set element [ah::isnot_js_var $element] } - set script "Rico.Corner.round\($element, \{$options\}\); " - return $script -} -ad_proc -public ah::js_sources { - {-source "default"} -} { - - Will load the prototype javascript library and scriptaculous javascript files. + 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();" - @author Hamilton Chua (ham@solutiongrove.com) - @creation-date 2006-01-16 + if { $enclose_p } { set script [ah::enclose_in_script -script ${script} ] } - @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, - "rico" : to load the rico javascript library, - "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. - - @return - @error -} { - - set ah_base_url [ah::get_url] - set js_file_list [split $source ","] - set script "" - - foreach x $js_file_list { - switch $x { - "rico" { - append script " \n" - } - "rounder" { - append script " \n" } - "overlibmws" { - append script " \n" - append script "\n" - } - "overlibmws_bubble" { - append script "\n" - append script "\n" - } - "overlibmws_scroll" { - append script "\n" - } - "overlibmws_drag" { - append script "\n" - } - default { - append script " \n" - append script " \n" - } - } - } - return $script } +# ************* Auto Suggest ***************** + ad_proc -public ah::generate_autosuggest_array { {-array_list {}} {-sql_query {}} @@ -715,6 +879,12 @@ @param sql_query sql query to pass to db_list_of_lists to generate the array } { + + if { ![ah::is_js_sources_loaded -js_source "prototype"] } { + global ajax_helper_js_sources + lappend ajax_helper_js_sources "prototype" + } + if {[llength $array_list]} { set suggestion_list $array_list } elseif {![string equal $sql_query {}]} { 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.3 -r1.4 --- openacs-4/packages/ajaxhelper/tcl/ajax-yahoo-procs.tcl 21 Oct 2006 06:14:53 -0000 1.3 +++ openacs-4/packages/ajaxhelper/tcl/ajax-yahoo-procs.tcl 6 Nov 2006 13:15:29 -0000 1.4 @@ -1,71 +1,97 @@ ad_library { Library for Ajax Helper Procs - based on Yahoo's User Interface Libraries + 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 { } -ad_proc -public ah::yui::js_source_dynamic { - {-js "default"} - {-enclose:boolean} +ad_proc -private ah::yui::load_js_sources { + -source_list } { - Dynamically Loads the Yahoo UI javascript libraries. - WARNING : experimental, use ah::yui::js_sources instead + Accepts a tcl list of sources to load. + This source_list will be the global ajax_helper_yui_js_sources variable. + This script is called in the blank-master template. - @author Hamilton Chua (ham@solutiongrove.com) - @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 - + @creation-date 2006-11-05 } { - set ah_base_url [ah::get_url] set script "" - set js_file_list [split $js ","] + set minsuffix "" - foreach x $js_file_list { - switch $x { + if { [parameter::get_from_package_key -package_key "ajaxhelper" -parameter "UseMinifiedJs"] == 1 } { + set minsuffix "-min" + } + + foreach source $source_list { + switch $source { "animation" { - append script [ah::js_include -js_file "${ah_base_url}yui/animation/animation.js"] + append script " \n" } "event" { - append script [ah::js_include -js_file "${ah_base_url}yui/event/event.js"] + append script " \n" } "treeview" { - append script [ah::js_include -js_file "${ah_base_url}yui/treeview/treeview.js"] + append script " \n" + global yahoo_treeview_css + if { [exists_and_not_null yahoo_treeview_css] } { + append script " \n" + } else { + append script " \n" + } } "calendar" { - append script [ah::js_include -js_file "${ah_base_url}yui/calendar/calendar.js"] + append script " \n" } "dragdrop" { - append script [ah::js_include -js_file "${ah_base_url}yui/dragdrop/dragdrop.js"] + append script " \n" } "slider" { - append script [ah::js_include -js_file "${ah_base_url}yui/slider/slider.js"] + append script " \n" } - 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"] + "container" { + append script " \n" + append script " \n" } + "dom" { + append script " \n" + } + "connection" { + append script " \n" + } + "yahoo" { + append script " \n" + } } } + return $script +} - if { $enclose_p } { set script [ah::enclose_in_script -script ${script} ] } +ad_proc -private ah::yui::is_js_sources_loaded { + -js_source +} { + This proc will loop thru source_list and check for the presence of js_source. + If found, this proc will return 1 + If not found, this proc will return 0 - return $script + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-11-05 +} { + global ajax_helper_yui_js_sources + set state 0 + if { [info exists ajax_helper_yui_js_sources] } { + foreach source $ajax_helper_yui_js_sources { + if { [string match $source $js_source] } { + set state 1 + break + } + } + } + return $state } ad_proc -public ah::yui::js_sources { @@ -74,7 +100,7 @@ } { Generates the < script > syntax needed on the head - for yui's User Interface Library + for Yahoo's User Interface Library The code :
 		[ah::yui::js_sources -default]
@@ -93,6 +119,8 @@
 		"calendar" : loads calendar.js
 		"dragdrop" : loads dragdrop.js
 		"slider" : loads slider.js
+		"container" : loads container.js
+	@param min Provide this parameter to use minified versions of the yahoo javascript sources
 
 	@return 
 	@error 
@@ -101,43 +129,67 @@
 	set ah_base_url [ah::get_url]
 	set script ""
 	set js_file_list [split $source ","]
-	if { $min_p } {
-		set min "-min"
-	} else {
-		set min ""
+	set minsuffix ""
+
+	if { $min_p || [parameter::get_from_package_key -package_key "ajaxhelper" -parameter "UseMinifiedJs"] == 1 } {
+		set minsuffix "-min"
 	}
 	
-	
 	foreach x $js_file_list {
 		switch $x { 
-			"animation" { 
-				append script " \n" 
+			"animation" {
+				if { ![ah::yui::is_js_sources_loaded -js_source "animation"] } {
+					append script " \n" 
+				}
 			}
 			"event" {
-				append script " \n" 
+				if { ![ah::yui::is_js_sources_loaded -js_source "event"] } {
+					append script " \n" 
+				}
 			}
 			"treeview" {
-				append script " \n" 
+				if { ![ah::yui::is_js_sources_loaded -js_source "treeview"] } {
+					append script " \n" 
+				}
 			}
 			"calendar" {
-				append script " \n" 
+				if { ![ah::yui::is_js_sources_loaded -js_source "calendar"] } {
+					append script " \n" 
+				}
 			}
 			"dragdrop" {
-				append script " \n" 
+				if { ![ah::yui::is_js_sources_loaded -js_source "dragdrop"] } {
+					append script " \n" 
+				}
 			}
 			"slider" {
-				append script " \n" 
+				if { ![ah::yui::is_js_sources_loaded -js_source "slider"] } {
+					append script " \n" 
+				}
 			}
 			"container" {
-				append script " \n" 
-				append script " \n" 
+				if { ![ah::yui::is_js_sources_loaded -js_source "container"] } {
+					append script " \n" 
+					append script " \n" 
+				}
 			}
 			"menu" {
-				append script " \n" 
+				if { ![ah::yui::is_js_sources_loaded -js_source "menu"] } {
+					append script " \n" 
+				}
 			}
+			"connection" {
+				if { ![ah::yui::is_js_sources_loaded -js_source "connection"] } {
+					append script " \n" 
+				}
+			}
 			default {
-				append script " \n"
-				append script " \n"		
+				if { ![ah::yui::is_js_sources_loaded -js_source "yahoo"] } {
+					append script " \n"
+				}
+				if { ![ah::yui::is_js_sources_loaded -js_source "dom"] } {
+					append script " \n"		
+				}
 			}
 		}
 	}
@@ -148,22 +200,32 @@
 ad_proc -public ah::yui::addlistener {
 	-element:required
 	-event:required
-	{-scope "''"}
-	{-callback ""}
+	-callback:required
 	{-element_is_var:boolean}
-	{-override:boolean}
 } {
 	Creates javascript for Yahoo's Event Listener.
+	http://developer.yahoo.com/yui/event/
+
+	@author Hamilton Chua (ham@solutiongrove.com)	
+	@creation-date 2006-11-05
+
+	@param element The element that this function will listen for events. This is the id of an html element (e.g. div or a form)
+	@param event The event that this function waits for. Values include load, mouseover, mouseout, unload etc.
+	@param callback The name of the javascript function to execute when the event for the given element has been triggered.
 } {
+
+	if { ![ah::yui::is_js_sources_loaded -js_source "yahoo"] } { 
+		global ajax_helper_yui_js_sources
+		lappend ajax_helper_yui_js_sources "yahoo"
+		if { ![ah::yui::is_js_sources_loaded -js_source "event"] } { 
+			lappend ajax_helper_yui_js_sources "event"
+		}
+	}
+
 	if { !$element_is_var_p } { 
 		set element [ah::isnot_js_var $element]
 	}
-	if { $override_p } {
-		set override "true"
-	} else {
-		set override "false"
-	}
-	return "YAHOO.util.Event.addListener($element,\"$event\",${callback},${scope},${override});\n"
+	return "YAHOO.util.Event.addListener($element,\"$event\",${callback});\n"
 }
 
 ad_proc -public ah::yui::tooltip {
@@ -174,9 +236,96 @@
 	{-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
+	http://developer.yahoo.com/yui/container/tooltip/index.html
+
+	@author Hamilton Chua (ham@solutiongrove.com)	
+	@creation-date 2006-11-05
+
+	@param varname The variable name you want to give to the tooltip
+	@param element The element where you wish to attache the tooltip
+	@param message The message that will appear in the tooltip
 } {
+	if { ![ah::yui::is_js_sources_loaded -js_source "yahoo"] } { 
+		global ajax_helper_yui_js_sources
+		lappend ajax_helper_yui_js_sources "yahoo"
+		if { ![ah::yui::is_js_sources_loaded -js_source "container"] } { 
+			lappend ajax_helper_yui_js_sources "container"
+		}
+	}
+
 	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
+}
+
+ad_proc -public ah::yui::create_tree {
+	-element:required
+	-nodes:required
+	{-varname "tree"}	
+	{-css ""}
+} {
+	Generates the javascript to create a yahoo tree view control.
+	http://developer.yahoo.com/yui/treeview/
+
+	@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.	
+
+} {
+	if { ![ah::yui::is_js_sources_loaded -js_source "yahoo"] } { 
+		global ajax_helper_yui_js_sources
+		lappend ajax_helper_yui_js_sources "yahoo"
+		if { ![ah::yui::is_js_sources_loaded -js_source "treeview"] } { 
+			lappend ajax_helper_yui_js_sources "treeview"
+			global yahoo_treeview_css
+			set yahoo_treeview_css $css
+		}
+	}
+
+
+	set script "${varname} = new YAHOO.widget.TreeView(\"${element}\"); "
+	append script "var ${varname}root = ${varname}.getRoot(); "
+	foreach node $nodes {
+		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] ]
+	}
+	append script "${varname}.draw(); "
+	return $script
+}
+
+ad_proc -private ah::yui::create_tree_node {
+	-varname:required
+	-label:required
+	-treevarname:required
+	{-href "javascript:void(0)"}
+	{-attach_to_node ""}
+	{-dynamic_load ""}
+} {
+	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
+} {
+	set script "var od${varname} = {label: \"${label}\", id: \"${varname}\", href: \"${href}\"}; "
+
+	if { [exists_and_not_null attach_to_node] } {
+		set rootvar "node"
+	} else {
+		set rootvar "${treevarname}root"
+	}
+	append script "var nd${varname} = new YAHOO.widget.TextNode(od${varname},${rootvar},false); "
+
+	if { [exists_and_not_null dynamic_load] } {
+		append script "nd${varname}.setDynamicLoad(${dynamic_load}); "
+	}
+
+	return $script
 }
\ No newline at end of file
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 -N
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/ajaxhelper/tcl/dynamic-load-procs.tcl	6 Nov 2006 13:15:29 -0000	1.1
@@ -0,0 +1,149 @@
+ad_library {
+
+	Ajax Exprimental Procs
+
+	@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}
+} {
+	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 -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
+
+	@author Hamilton Chua (ham@solutiongrove.com)	
+	@creation-date 2006-04-20
+
+} {
+	set ah_base_url [ah::get_url]
+	set script ""
+	return $script
+}
+
+ad_proc -public ah::exp::js_include {
+	{-js_file ""}
+} {
+	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
+} {
+	return "js_include_once('$js_file'); "
+}
+
+ad_proc -public ah::exp::js_source_dynamic {
+	{-js "default"}
+	{-enclose:boolean}
+} {
+	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
+
+	@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"]
+			}
+		}
+	}
+
+	if { $enclose_p } { set script [ah::enclose_in_script -script ${script} ] }
+
+	return $script
+}
Index: openacs-4/packages/ajaxhelper/www/doc/index.html
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/doc/index.html,v
diff -u -N -r1.4 -r1.5
--- openacs-4/packages/ajaxhelper/www/doc/index.html	21 Oct 2006 06:14:53 -0000	1.4
+++ openacs-4/packages/ajaxhelper/www/doc/index.html	6 Nov 2006 13:15:29 -0000	1.5
@@ -1,253 +1,286 @@
-
-
-
-  Ajax Helper
-  
-
-
-

Ajax Helper

-Hamilton G. Chua (ham@solutiongrove.com)
-October 2006
-v0.7d
-
-Components :
-Prototype v1.5.0_rc1 (http://prototype.conio.net/)
-Scriptaculous v1.6.4 (http://script.aculo.us/)
-Rico v1.1.0 (http://www.openrico.org)
-Overlibmws (http://www.macridesweb.com/oltest/)
-Extracted Rounder Functions from Rico
-(http://encytemedia.com/blog/articles/2005/12/01/rico-rounded-corners-without-all-of-rico)
-
-Yahoo User Interface Library v0.11.4(http://developer.yahoo.com) -
-Introduction :
-
-
The Ajax Helper package provides TCL API to generate the -javascript from the above components to enable their various features -for use in OpenACS applications. -The motivation for this package is to easily enable Web 2.0 like -features in OpenACS applications using the most popular javascript -library prototype.js and it's derivatives like Scriptaculous and Rico.
-
-Prerequisites :
-
-
The ajax helper package must be installed and mounted in /ajax -to be able ot use these features. The installer should automatically -mount the ajax helper in /ajax.
-

-Javascript Sources :
-
-The javascript files from prototype and scriptaculous must be declared -in the < head > section of an html page. In the case of OpenACS -applications that use the templating system, the sources must be -declared in the blank-master.adp file.
-
-To have the ajax helper generate -the javascript declaration ....
-
-TCL File (blank-master.tcl) :
-
-    set ah_sources [ah::js_sources -default]
-
-ADP File (blank-master.adp):
-
-    @ah_sources;noquote@
-
-Compiled Template:
-
<script type="text/javascript" src="/ajax/prototype/prototype.js"></script> 
<script type="text/javascript" src="/ajax/scriptaculous/builder.js"></script>
<script type="text/javascript" src="/ajax/scriptaculous/controls.js"></script>
<script type="text/javascript" src="/ajax/scriptaculous/dragdrop.js"></script>
<script type="text/javascript" src="/ajax/scriptaculous/effects.js"></script>
<script type="text/javascript" src="/ajax/scriptaculous/slider.js"></script>
<script type="text/javascript" src="/ajax/scriptaculous/scriptaculous.js"></script>

-The above TCL API generates the default -sources that must be declared for you to be able to use the javascript -libraries Ajax Helper has support for overlibmws (DHTML callouts) and -RICO (other cinematic effects) in addition to scriptaculous.  -Scriptaculous is the default javascript library.
-
-To generate the javascript sources for Rico :
-
-    set ah_sources [ah::js_sources -source "rico"]
-
-To generate the javscript sources for Overlibmws :
-
-    set ah_sources [ah::js_sources -source "overlibmws"]
-
-The functions that are responsible for rounded corners has been -extracted into rounded.js to work with scriptaculous.
-To use these functions wihtout using all of rico.js
-
-    set ah_sources [ah::js_sources -source "rounder"]
-
-NOTE :
-
-You can combine sources by doing this
-
-    set ah_sources [ah::js_sources -default]
-    append ah_sources [ah::js_sources -source -"overlibmws"]
-
-The above code will generate the overlibmws javascript source -declaration with the default declarations.
-
-Overlibmws and the default sources (Scriptaculous) are compatible with -each other. It is not advisable to use both Scriptaculous and Rico at -the same time.
-
-Ajax Procedures :
-
-Prototype
has a pair of javascript functions that alllow -programmers to use XMLHTTP. The ajax.updater and ajax.request -functions. See http://wiki.script.aculo.us/scriptaculous/show/Ajax.Updater -and http://wiki.script.aculo.us/scriptaculous/show/Ajax.Request -for more information about these javascript functions.
-
-The TCL API is used like this
-
-    set request [ah::ajaxrequest -url -"/url/to/call"  -\
-            -            -            -            -     -pars -"parameter1=parameter_value&parameter1=parameter_value"  ]
-
-The above api will generate an ajax.request javascript function that is -best placed in an  event like "onClick".
-
-    <a href="#" onClick="@request;noquote@">
-
-Consult the api-doc for more information about other parameters you can -pass on to the ah::ajaxrequest proc.
-
-The ah::ajaxrequest will make an xmlhttp call but does not do anything -about the response. To update content based on the response from an -xmlhttp request, use ah::ajaxupdate. This procedure will not only make -an xmlhttp call but update the contents of a div or layer with the -response text of the xmlhttp request.
-
-Here's an example :
-
-       set js_update_connections -[ah::ajaxupdate -container "connections"  \
-            -    -url "/url/to/call" \
-            -    -enclose  \
-            -    -pars -"'effects=$effects&limit_n=$limit_n'"  \
-                --effect "Fade" \
-            -    -effectopts "duration: 0.5"]
-
-On the adp side, you can just put
-
-      @js_update_connections;noquote@
-
-The "-enclose" parameter tells the procedure to enclose the resulting -script in script tags <script></script>. This is another -option in addition to putting the scripts in html event attributes like -onClick, onMouseover or onChange.
-
-The "-pars" parameter is where you pass the querystring that you want -to send along with the xmlhttp request. Notice that it takes the form -of a querystring that you normally see in the address bar of your -browser. Use this to pass values to the URL you are making an xmlhttp -request to.
-
-The "-effect" parameter is an optional parameter that allows you to -specify the effect you want to execute after the container's content -has been updated.
-
-Cinematic Effects :
-
-
Use ah::effects to generate javascript that allows you to -implement transitional and cinematic effects to html elements. You will -need to consult the scriptaculous documentation -http://wiki.script.aculo.us/scriptaculous/tags/effects to know what -kinds of -effects and what kinds of options you can pass to the effect script.
-
-The procedure is called in this manner :
-
-    set effect [ah::effect -element "container"
-            -            -               --effect "Fade"
-            -            -        -       -options "duration: 1.5"]
-NOTE :
-The Effect name and the options are case sensitive.
-
-

-DHTML Callouts :
-
-
There is currently basic support for overlibmws. Right now we -are able to create bubble type call outs.
-
-In your tcl file ...
-
-   set onmouseover [ah::bubblecallout -text " Contents of My -Popup" ]
-
-The adp file should have something like this ....
-  
-   <a href="#" @onmouseover;noquote@ >Link with -Popup</a>
-
-Drag and Drop Sortables :
-
-
Sortables are documented in the scriptaculous wiki http://wiki.script.aculo.us/scriptaculous/show/Sortables.
-For sortables to work you will need to define a container which will -hold the elements you want to be sortable.
-
-Here is what the script looks like
-
-    append scripts [ah::sortable -element "container"
-            -            -            -            -     -options -"tag:'div',only:'portlet',overlap:'horizontal',constraint:false,ghosting:false"]
-
-You adp page should contain a div with id attribute container. This -"container" should have subcontainers which the above script will make -sortable.
-
-
-

-
-
-
-
- - \ No newline at end of file + + + + Ajax Helper + + + +

Ajax Helper

+

Hamilton G. Chua (ham@solutiongrove.com)
+ November 2006
+ v0.8d
+
+ Components :
+ Prototype v1.5.0_rc_1 (http://prototype.conio.net/)
+ Scriptaculous v1.6.4 (http://script.aculo.us/)
+ +Overlibmws (http://www.macridesweb.com/oltest/)
+Curvey Corners (http://www.curvycorners.net/)
+Yahoo User Interface Library 0.11.4 (http://developer.yahoo.com/yui/)
+Dojo Toolkit + 0.4 (http://dojotoolkit.com)
+
+
+ Introduction :
+
+
The Ajax Helper package provides TCL API to generate the + javascript from the above components to enable their various features + for use in OpenACS applications. + The motivation for this package is to easily enable Web 2.0 like + features in OpenACS applications using the most popular javascript + libraries.
+
+ Prerequisites :
+
+
The ajax helper package must be installed and mounted in /ajax + to be able ot use these features. The installer should automatically + mount the ajax helper in /ajax upon installation of the package.
+

+Javascript Sources :

+

As of version 0.8d, required javascript sources will be loaded automatically depending on the wrapper function used. The following piece of code must be present in the blank-master.tcl template file to make this automated loading of javascript source files possible.

+

TCL File (blank-master.tcl) :

+

+if { ![info exists header_stuff] } {
+    set header_stuff {} 
+}
+
+# HAM : lets check ajaxhelper globals ***********************
+
+global ajax_helper_js_sources
+global ajax_helper_yui_js_sources
+global ajax_helper_dojo_js_sources
+set js_sources ""
+
+if { [info exists ajax_helper_js_sources] || [info exists ajax_helper_yui_js_sources] || [info exists ajax_helper_dojo_js_sources] } {
+
+	# if we're using ajax, let's use doc_type strict so we can get
+	# consistent results accross standards compliant browsers
+	set doc_type { < !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > }
+
+	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]
+	}
+
+	if { [info exists ajax_helper_dojo_js_sources] } {
+		append js_sources [ah::dojo::load_js_sources -source_list $ajax_helper_dojo_js_sources]
+	}
+}
+
+# ***********************************************************
+
+# Attributes
+
+multirow create attribute key value
+set onload {}
+
+

ADP File (blank-master.adp):

+

@js_sources;noquote@
+ @header_stuff;noquote@

+

Automated loading will work only if you are using a wrapper script.

+

Alternatively if you wish to have more control of what javascript sources are loaded, you can still use the ah::js_sources procedure.

+

To have the ajax helper generate + the javascript declaration ....
+
+ TCL File (e.g blank-master.tcl) :
+
+    set ah_sources [ah::js_sources -default]
+
+ ADP File (eg. blank-master.adp):
+
+    @ah_sources;noquote@
+
+ Compiled Template:
+
+ <script type="text/javascript" src="/ajax/prototype/prototype.js"></script>
+ <script type="text/javascript" src="/ajax/scriptaculous/builder.js"></script>
+ <script type="text/javascript" src="/ajax/scriptaculous/controls.js"></script>
+ <script type="text/javascript" src="/ajax/scriptaculous/dragdrop.js"></script>
+ <script type="text/javascript" src="/ajax/scriptaculous/effects.js"></script>
+ <script type="text/javascript" src="/ajax/scriptaculous/slider.js"></script>
+ <script type="text/javascript" src="/ajax/scriptaculous/scriptaculous.js"></script>
+
The above TCL API generates the default +sources that must be declared for you to be able to use the javascript +libraries
+
+ +To generate the javscript sources for Overlibmws :
+
+    set ah_sources [ah::js_sources -source "overlibmws"]
+
+The functions that are responsible for rounded corners has been +extracted into rounded.js to work with scriptaculous.
+ +
+    set ah_sources [ah::js_sources -source "rounder"]
+
+NOTE :
+
+You can combine sources by specifying them in the source parameter separated by commas.
+
+ + set ah_sources [ah::js_sources -source +"default,overlibmws"]
+
+The above code will generate the overlibmws javascript source +declaration with the default declarations.
+
+
+Ajax Procedures :
+
+Prototype
has a pair of javascript functions that alllow +programmers to use XMLHTTP. The ajax.updater and ajax.request +functions. See http://wiki.script.aculo.us/scriptaculous/show/Ajax.Updater +and http://wiki.script.aculo.us/scriptaculous/show/Ajax.Request +for more information about these javascript functions.
+
+The TCL API is used like this
+
+    set request [ah::ajaxrequest -url +"/url/to/call"  \
+            +            +            +            +     -pars +"parameter1=parameter_value&parameter1=parameter_value"  ]
+
+The above api will generate an ajax.request javascript function that is +best placed in an  event like "onClick".
+
+    <a href="#" onClick="@request;noquote@">
+
+Consult the api-doc for more information about other parameters you can +pass on to the ah::ajaxrequest proc.
+
+The ah::ajaxrequest will make an xmlhttp call but does not do anything +about the response. To update content based on the response from an +xmlhttp request, use ah::ajaxupdate. This procedure will not only make +an xmlhttp call but update the contents of a div or layer with the +response text of the xmlhttp request.
+
+Here's an example :
+
+       set js_update_connections +[ah::ajaxupdate -container "connections"  \
+            +    -url "/url/to/call" \
+            +    -enclose  \
+            +    -pars +"'effects=$effects&limit_n=$limit_n'"  \
+                +-effect "Fade" \
+            +    -effectopts "duration: 0.5"]
+
+On the adp side, you can just put
+
+      @js_update_connections;noquote@
+
+The "-enclose" parameter tells the procedure to enclose the resulting +script in script tags <script></script>. This is another +option in addition to putting the scripts in html event attributes like +onClick, onMouseover or onChange.
+
+The "-pars" parameter is where you pass the querystring that you want +to send along with the xmlhttp request. Notice that it takes the form +of a querystring that you normally see in the address bar of your +browser. Use this to pass values to the URL you are making an xmlhttp +request to.
+
+The "-effect" parameter is an optional parameter that allows you to +specify the effect you want to execute after the container's content +has been updated.
+
+Cinematic Effects :
+
+
Use ah::effects to generate javascript that allows you to +implement transitional and cinematic effects to html elements. You will +need to consult the scriptaculous documentation +http://wiki.script.aculo.us/scriptaculous/tags/effects to know what +kinds of +effects and what kinds of options you can pass to the effect script.
+
+The procedure is called in this manner :
+
+    set effect [ah::effect -element "container"
+            +            +               +-effect "Fade"
+            +            +        +       -options "duration: 1.5"]
+NOTE :
+The Effect name and the options are case sensitive.
+
+

+DHTML Callouts :
+
+
There is currently basic support for overlibmws. Right now we +are able to create bubble type call outs.
+
+In your tcl file ...
+
+   set onmouseover [ah::bubblecallout -text " Contents of My +Popup" ]
+
+The adp file should have something like this ....
+  
+   <a href="#" @onmouseover;noquote@ >Link with +Popup</a>
+
+Drag and Drop Sortables :
+
+
Sortables are documented in the scriptaculous wiki http://wiki.script.aculo.us/scriptaculous/show/Sortables.
+For sortables to work you will need to define a container which will +hold the elements you want to be sortable.
+
+Here is what the script looks like
+
+    append scripts [ah::sortable -element "container"
+            +            +            +            +     -options +"tag:'div',only:'portlet',overlap:'horizontal',constraint:false,ghosting:false"]
+
+You adp page should contain a div with id attribute container. This "container" should have subcontainers which the above script will make +sortable.

+ + Index: openacs-4/packages/ajaxhelper/www/resources/dynamicInclude.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/Attic/dynamicInclude.js,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/resources/dynamicInclude.js 6 Nov 2006 13:15:29 -0000 1.1 @@ -0,0 +1,155 @@ +//Javascript dynamic Include Library +//Code derived from: +//Author: Stoyan Stefanov +//SITE: www.phpied.com +//email: ssttoo at gmaildotcom +//mad props due.. +//I made the manager objects and added the css methods so +//I can use this library for both +//me: Greg Patmore +//hit me up: //greg at ito-ydotcom + + +//js + +//holds the currently loaded .js libraries +//NOTE: idiot alert! any files included outside these methods cannot be +// referenced by this array +var js_includes = new Array(); + + +//use this manager to keep things simple +function JSManager(){ + this.included = js_includes; + this.include = js_include_once; + this.remove = js_remove_include; +} + +function js_include_dom(script_filename) { + var html_doc = document.getElementsByTagName('head').item(0); + var js = document.createElement('script'); + js.setAttribute('language', 'javascript'); + js.setAttribute('type', 'text/javascript'); + js.setAttribute('src', script_filename); + html_doc.appendChild(js); + return false; +} + +function js_include_once(script_filename) { + if (!in_array(script_filename, js_includes)) { + js_includes[js_includes.length] = script_filename; + js_include_dom(script_filename); + } +} + +//"un-includes" the included js file from the document +//use sparingly, as it's a memory whore +//NOTE: will not kill any timeouts you may have going +// but the script will be removed from the rendered source +function js_remove_include(scriptname){ + var docScripts = document.getElementsByTagName('script'); + for(var i=0;i + + +curvyCorners Demo + + + + + + +



+ +
+ + Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Curabitur mi est, cursus sit amet, pellentesque et, ultricies a, ipsum. Nulla facilisi. Sed quis lacus. Aenean ut risus et lectus blandit gravida. Nam sed nunc. Aliquam non felis non diam aliquam gravida. Phasellus quis sem. Curabitur at velit. Vivamus libero velit, condimentum sit amet, tempus ut, aliquam sit amet, velit. Nunc hendrerit ante. Quisque egestas feugiat erat. Morbi tellus. +

+ Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nulla ac ante sit amet metus hendrerit euismod. Aenean vestibulum, lectus in eleifend tempor, quam libero iaculis dolor, pellentesque pellentesque lorem nibh ut urna. Nulla rhoncus, ante sit amet tristique interdum, eros nulla nonummy justo, eu dapibus risus quam sit amet metus. Maecenas tristique augue vel enim. Duis blandit euismod pede. Pellentesque facilisis. Fusce dapibus sapien tristique massa. Nunc accumsan. Integer pretium risus et odio. Phasellus tincidunt rhoncus velit. Donec eu neque at massa mollis iaculis. Aliquam pellentesque auctor mi. Cras ante justo, ultricies quis, iaculis eu, tincidunt ac, velit. Etiam nunc erat, tincidunt sit amet, luctus quis, interdum a, nunc. Suspendisse elit. +

+ Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nulla ac ante sit amet metus hendrerit euismod. Aenean vestibulum, lectus in eleifend tempor, quam libero iaculis dolor, pellentesque pellentesque lorem nibh ut urna. Nulla rhoncus, ante sit amet tristique interdum, eros nulla nonummy justo, eu dapibus risus quam sit amet metus. Maecenas tristique augue vel enim. Duis blandit euismod pede. Pellentesque facilisis. Fusce dapibus sapien tristique massa. Nunc accumsan. Integer pretium risus et odio. Phasellus tincidunt rhoncus velit. Donec eu neque at massa mollis iaculis. Aliquam pellentesque auctor mi. Cras ante justo, ultricies quis, iaculis eu, tincidunt ac, velit. Etiam nunc erat, tincidunt sit amet, luctus quis, interdum a, nunc. Suspendisse elit. + +
+ + + + + \ No newline at end of file Index: openacs-4/packages/ajaxhelper/www/resources/curvycorners/demo2.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/curvycorners/demo2.html,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/resources/curvycorners/demo2.html 6 Nov 2006 13:15:30 -0000 1.1 @@ -0,0 +1,88 @@ + + + +curvyCorners Demo + + + + + + + +



+ +
+ + + +
+ + + \ No newline at end of file Index: openacs-4/packages/ajaxhelper/www/resources/curvycorners/grass.jpg =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/curvycorners/grass.jpg,v diff -u -N Binary files differ Index: openacs-4/packages/ajaxhelper/www/resources/curvycorners/lgpl.txt =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/curvycorners/lgpl.txt,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/resources/curvycorners/lgpl.txt 6 Nov 2006 13:15:30 -0000 1.1 @@ -0,0 +1,502 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! \ No newline at end of file Index: openacs-4/packages/ajaxhelper/www/resources/curvycorners/rounded_corners.inc.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/curvycorners/rounded_corners.inc.js,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/resources/curvycorners/rounded_corners.inc.js 6 Nov 2006 13:15:30 -0000 1.1 @@ -0,0 +1,1090 @@ + + /**************************************************************** + * * + * curvyCorners * + * ------------ * + * * + * This script generates rounded corners for your divs. * + * * + * Version 1.2.9 * + * Copyright (c) 2006 Cameron Cooke * + * By: Cameron Cooke and Tim Hutchison. * + * * + * * + * Website: http://www.curvycorners.net * + * Email: info@totalinfinity.com * + * Forum: http://www.curvycorners.net/forum/ * + * * + * * + * This library is free software; you can redistribute * + * it and/or modify it under the terms of the GNU * + * Lesser General Public License as published by the * + * Free Software Foundation; either version 2.1 of the * + * License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will * + * be useful, but WITHOUT ANY WARRANTY; without even the * + * implied warranty of MERCHANTABILITY or FITNESS FOR A * + * PARTICULAR PURPOSE. See the GNU Lesser General Public * + * License for more details. * + * * + * You should have received a copy of the GNU Lesser * + * General Public License along with this library; * + * Inc., 59 Temple Place, Suite 330, Boston, * + * MA 02111-1307 USA * + * * + ****************************************************************/ + + // Browser detection + var isIE = navigator.userAgent.toLowerCase().indexOf("msie") > -1; + var isMoz = document.implementation && document.implementation.createDocument; + var isSafari = ((navigator.userAgent.toLowerCase().indexOf('safari')!=-1)&&(navigator.userAgent.toLowerCase().indexOf('mac')!=-1))?true:false; + + /* + Usage: + + newCornersObj = new curvyCorners(settingsObj, "classNameStr"); + newCornersObj = new curvyCorners(settingsObj, divObj1[, divObj2[, divObj3[, . . . [, divObjN]]]]); + */ + function curvyCorners() + { + // Check parameters + if(typeof(arguments[0]) != "object") throw newCurvyError("First parameter of curvyCorners() must be an object."); + if(typeof(arguments[1]) != "object" && typeof(arguments[1]) != "string") throw newCurvyError("Second parameter of curvyCorners() must be an object or a class name."); + + // Get object(s) + if(typeof(arguments[1]) == "string") + { + // Get elements by class name + var startIndex = 0; + var boxCol = getElementsByClass(arguments[1]); + } + else + { + // Get objects + var startIndex = 1; + var boxCol = arguments; + } + + // Create return collection/object + var curvyCornersCol = new Array(); + + // Create array of html elements that can have rounded corners + if(arguments[0].validTags) + var validElements = arguments[0].validTags; + else + var validElements = ["div"]; // Default + + // Loop through each argument + for(var i = startIndex, j = boxCol.length; i < j; i++) + { + // Current element tag name + var currentTag = boxCol[i].tagName.toLowerCase(); + + if(inArray(validElements, currentTag) !== false) + { + curvyCornersCol[curvyCornersCol.length] = new curvyObject(arguments[0], boxCol[i]); + } + } + + this.objects = curvyCornersCol; + + // Applys the curvyCorners to all objects + this.applyCornersToAll = function() + { + for(var x = 0, k = this.objects.length; x < k; x++) + { + this.objects[x].applyCorners(); + } + } + } + + // curvyCorners object (can be called directly) + function curvyObject() + { + // Setup Globals + this.box = arguments[1]; + this.settings = arguments[0]; + this.topContainer = null; + this.bottomContainer = null; + this.masterCorners = new Array(); + this.contentDIV = null; + + // Get box formatting details + var boxHeight = get_style(this.box, "height", "height"); + var boxWidth = get_style(this.box, "width", "width"); + var borderWidth = get_style(this.box, "borderTopWidth", "border-top-width"); + var borderColour = get_style(this.box, "borderTopColor", "border-top-color"); + var boxColour = get_style(this.box, "backgroundColor", "background-color"); + var backgroundImage = get_style(this.box, "backgroundImage", "background-image"); + var boxPosition = get_style(this.box, "position", "position"); + var boxPadding = get_style(this.box, "paddingTop", "padding-top"); + + // Set formatting propertes + this.boxHeight = parseInt(((boxHeight != "" && boxHeight != "auto" && boxHeight.indexOf("%") == -1)? boxHeight.substring(0, boxHeight.indexOf("px")) : this.box.scrollHeight)); + this.boxWidth = parseInt(((boxWidth != "" && boxWidth != "auto" && boxWidth.indexOf("%") == -1)? boxWidth.substring(0, boxWidth.indexOf("px")) : this.box.scrollWidth)); + this.borderWidth = parseInt(((borderWidth != "" && borderWidth.indexOf("px") !== -1)? borderWidth.slice(0, borderWidth.indexOf("px")) : 0)); + this.boxColour = format_colour(boxColour); + this.boxPadding = parseInt(((boxPadding != "" && boxPadding.indexOf("px") !== -1)? boxPadding.slice(0, boxPadding.indexOf("px")) : 0)); + this.borderColour = format_colour(borderColour); + this.borderString = this.borderWidth + "px" + " solid " + this.borderColour; + this.backgroundImage = ((backgroundImage != "none")? backgroundImage : ""); + this.boxContent = this.box.innerHTML; + + // Make box relative if not already absolute and remove any padding + if(boxPosition != "absolute") this.box.style.position = "relative"; + this.box.style.padding = "0px"; + + // If IE and height and width are not set, we need to set width so that we get positioning + if(isIE && boxWidth == "auto" && boxHeight == "auto") this.box.style.width = "100%"; + + // Resize box so that it stays to the orignal height + + + // Remove content if box is using autoPad + if(this.settings.autoPad == true && this.boxPadding > 0) + this.box.innerHTML = ""; + + /* + This method creates the corners and + applies them to the div element. + */ + this.applyCorners = function() + { + /* + Create top and bottom containers. + These will be used as a parent for the corners and bars. + */ + for(var t = 0; t < 2; t++) + { + switch(t) + { + // Top + case 0: + + // Only build top bar if a top corner is to be draw + if(this.settings.tl || this.settings.tr) + { + var newMainContainer = document.createElement("DIV"); + newMainContainer.style.width = "100%"; + newMainContainer.style.fontSize = "1px"; + newMainContainer.style.overflow = "hidden"; + newMainContainer.style.position = "absolute"; + newMainContainer.style.paddingLeft = this.borderWidth + "px"; + newMainContainer.style.paddingRight = this.borderWidth + "px"; + var topMaxRadius = Math.max(this.settings.tl ? this.settings.tl.radius : 0, this.settings.tr ? this.settings.tr.radius : 0); + newMainContainer.style.height = topMaxRadius + "px"; + newMainContainer.style.top = 0 - topMaxRadius + "px"; + newMainContainer.style.left = 0 - this.borderWidth + "px"; + this.topContainer = this.box.appendChild(newMainContainer); + } + break; + + // Bottom + case 1: + + // Only build bottom bar if a top corner is to be draw + if(this.settings.bl || this.settings.br) + { + var newMainContainer = document.createElement("DIV"); + newMainContainer.style.width = "100%"; + newMainContainer.style.fontSize = "1px"; + newMainContainer.style.overflow = "hidden"; + newMainContainer.style.position = "absolute"; + newMainContainer.style.paddingLeft = this.borderWidth + "px"; + newMainContainer.style.paddingRight = this.borderWidth + "px"; + var botMaxRadius = Math.max(this.settings.bl ? this.settings.bl.radius : 0, this.settings.br ? this.settings.br.radius : 0); + newMainContainer.style.height = botMaxRadius + "px"; + newMainContainer.style.bottom = 0 - botMaxRadius + "px"; + newMainContainer.style.left = 0 - this.borderWidth + "px"; + this.bottomContainer = this.box.appendChild(newMainContainer); + } + break; + } + } + + // Turn off current borders + if(this.topContainer) this.box.style.borderTopWidth = "0px"; + if(this.bottomContainer) this.box.style.borderBottomWidth = "0px"; + + // Create array of available corners + var corners = ["tr", "tl", "br", "bl"]; + + /* + Loop for each corner + */ + for(var i in corners) + { + // FIX for prototype lib + if(i > -1 < 4) + { + // Get current corner type from array + var cc = corners[i]; + + // Has the user requested the currentCorner be round? + if(!this.settings[cc]) + { + // No + if(((cc == "tr" || cc == "tl") && this.topContainer != null) || ((cc == "br" || cc == "bl") && this.bottomContainer != null)) + { + // We need to create a filler div to fill the space upto the next horzontal corner. + var newCorner = document.createElement("DIV"); + + // Setup corners properties + newCorner.style.position = "relative"; + newCorner.style.fontSize = "1px"; + newCorner.style.overflow = "hidden"; + + // Add background image? + if(this.backgroundImage == "") + newCorner.style.backgroundColor = this.boxColour; + else + newCorner.style.backgroundImage = this.backgroundImage; + + switch(cc) + { + case "tl": + newCorner.style.height = topMaxRadius - this.borderWidth + "px"; + newCorner.style.marginRight = this.settings.tr.radius - (this.borderWidth*2) + "px"; + newCorner.style.borderLeft = this.borderString; + newCorner.style.borderTop = this.borderString; + newCorner.style.left = -this.borderWidth + "px"; + break; + + case "tr": + newCorner.style.height = topMaxRadius - this.borderWidth + "px"; + newCorner.style.marginLeft = this.settings.tl.radius - (this.borderWidth*2) + "px"; + newCorner.style.borderRight = this.borderString; + newCorner.style.borderTop = this.borderString; + newCorner.style.backgroundPosition = "-" + (topMaxRadius + this.borderWidth) + "px 0px"; + newCorner.style.left = this.borderWidth + "px"; + break; + + case "bl": + newCorner.style.height = botMaxRadius - this.borderWidth + "px"; + newCorner.style.marginRight = this.settings.br.radius - (this.borderWidth*2) + "px"; + newCorner.style.borderLeft = this.borderString; + newCorner.style.borderBottom = this.borderString; + newCorner.style.left = -this.borderWidth + "px"; + newCorner.style.backgroundPosition = "-" + (this.borderWidth) + "px -" + (this.boxHeight + (botMaxRadius + this.borderWidth)) + "px"; + break; + + case "br": + newCorner.style.height = botMaxRadius - this.borderWidth + "px"; + newCorner.style.marginLeft = this.settings.bl.radius - (this.borderWidth*2) + "px"; + newCorner.style.borderRight = this.borderString; + newCorner.style.borderBottom = this.borderString; + newCorner.style.left = this.borderWidth + "px" + newCorner.style.backgroundPosition = "-" + (botMaxRadius + this.borderWidth) + "px -" + (this.boxHeight + (botMaxRadius + this.borderWidth)) + "px"; + break; + } + } + } + else + { + /* + PERFORMANCE NOTE: + + If more than one corner is requested and a corner has been already + created for the same radius then that corner will be used as a master and cloned. + The pixel bars will then be repositioned to form the new corner type. + All new corners start as a bottom right corner. + */ + if(this.masterCorners[this.settings[cc].radius]) + { + // Create clone of the master corner + var newCorner = this.masterCorners[this.settings[cc].radius].cloneNode(true); + } + else + { + // Yes, we need to create a new corner + var newCorner = document.createElement("DIV"); + newCorner.style.height = this.settings[cc].radius + "px"; + newCorner.style.width = this.settings[cc].radius + "px"; + newCorner.style.position = "absolute"; + newCorner.style.fontSize = "1px"; + newCorner.style.overflow = "hidden"; + + // THE FOLLOWING BLOCK OF CODE CREATES A ROUNDED CORNER + // ---------------------------------------------------- TOP + + // Get border radius + var borderRadius = parseInt(this.settings[cc].radius - this.borderWidth); + + // Cycle the x-axis + for(var intx = 0, j = this.settings[cc].radius; intx < j; intx++) + { + // Calculate the value of y1 which identifies the pixels inside the border + if((intx +1) >= borderRadius) + var y1 = -1; + else + var y1 = (Math.floor(Math.sqrt(Math.pow(borderRadius, 2) - Math.pow((intx+1), 2))) - 1); + + // Only calculate y2 and y3 if there is a border defined + if(borderRadius != j) + { + if((intx) >= borderRadius) + var y2 = -1; + else + var y2 = Math.ceil(Math.sqrt(Math.pow(borderRadius,2) - Math.pow(intx, 2))); + + if((intx+1) >= j) + var y3 = -1; + else + var y3 = (Math.floor(Math.sqrt(Math.pow(j ,2) - Math.pow((intx+1), 2))) - 1); + } + + // Calculate y4 + if((intx) >= j) + var y4 = -1; + else + var y4 = Math.ceil(Math.sqrt(Math.pow(j ,2) - Math.pow(intx, 2))); + + // Draw bar on inside of the border with foreground colour + if(y1 > -1) this.drawPixel(intx, 0, this.boxColour, 100, (y1+1), newCorner, -1, this.settings[cc].radius); + + // Only draw border/foreground antialiased pixels and border if there is a border defined + if(borderRadius != j) + { + // Cycle the y-axis + for(var inty = (y1 + 1); inty < y2; inty++) + { + // Draw anti-alias pixels + if(this.settings.antiAlias) + { + // For each of the pixels that need anti aliasing between the foreground and border colour draw single pixel divs + if(this.backgroundImage != "") + { + var borderFract = (pixelFraction(intx, inty, borderRadius) * 100); + + if(borderFract < 30) + { + this.drawPixel(intx, inty, this.borderColour, 100, 1, newCorner, 0, this.settings[cc].radius); + } + else + { + this.drawPixel(intx, inty, this.borderColour, 100, 1, newCorner, -1, this.settings[cc].radius); + } + } + else + { + var pixelcolour = BlendColour(this.boxColour, this.borderColour, pixelFraction(intx, inty, borderRadius)); + this.drawPixel(intx, inty, pixelcolour, 100, 1, newCorner, 0, this.settings[cc].radius, cc); + } + } + } + + // Draw bar for the border + if(this.settings.antiAlias) + { + if(y3 >= y2) + { + if (y2 == -1) y2 = 0; + this.drawPixel(intx, y2, this.borderColour, 100, (y3 - y2 + 1), newCorner, 0, 0); + } + } + else + { + if(y3 >= y1) + { + this.drawPixel(intx, (y1 + 1), this.borderColour, 100, (y3 - y1), newCorner, 0, 0); + } + } + + // Set the colour for the outside curve + var outsideColour = this.borderColour; + } + else + { + // Set the coour for the outside curve + var outsideColour = this.boxColour; + var y3 = y1; + } + + // Draw aa pixels? + if(this.settings.antiAlias) + { + // Cycle the y-axis and draw the anti aliased pixels on the outside of the curve + for(var inty = (y3 + 1); inty < y4; inty++) + { + // For each of the pixels that need anti aliasing between the foreground/border colour & background draw single pixel divs + this.drawPixel(intx, inty, outsideColour, (pixelFraction(intx, inty , j) * 100), 1, newCorner, ((this.borderWidth > 0)? 0 : -1), this.settings[cc].radius); + } + } + } + + // END OF CORNER CREATION + // ---------------------------------------------------- END + + // We now need to store the current corner in the masterConers array + this.masterCorners[this.settings[cc].radius] = newCorner.cloneNode(true); + } + + /* + Now we have a new corner we need to reposition all the pixels unless + the current corner is the bottom right. + */ + if(cc != "br") + { + // Loop through all children (pixel bars) + for(var t = 0, k = newCorner.childNodes.length; t < k; t++) + { + // Get current pixel bar + var pixelBar = newCorner.childNodes[t]; + + // Get current top and left properties + var pixelBarTop = parseInt(pixelBar.style.top.substring(0, pixelBar.style.top.indexOf("px"))); + var pixelBarLeft = parseInt(pixelBar.style.left.substring(0, pixelBar.style.left.indexOf("px"))); + var pixelBarHeight = parseInt(pixelBar.style.height.substring(0, pixelBar.style.height.indexOf("px"))); + + // Reposition pixels + if(cc == "tl" || cc == "bl"){ + pixelBar.style.left = this.settings[cc].radius -pixelBarLeft -1 + "px"; // Left + } + if(cc == "tr" || cc == "tl"){ + pixelBar.style.top = this.settings[cc].radius -pixelBarHeight -pixelBarTop + "px"; // Top + } + + switch(cc) + { + case "tr": + pixelBar.style.backgroundPosition = "-" + Math.abs((this.boxWidth - this.settings[cc].radius + this.borderWidth) + pixelBarLeft) + "px -" + Math.abs(this.settings[cc].radius -pixelBarHeight -pixelBarTop - this.borderWidth) + "px"; + break; + + case "tl": + pixelBar.style.backgroundPosition = "-" + Math.abs((this.settings[cc].radius -pixelBarLeft -1) - this.borderWidth) + "px -" + Math.abs(this.settings[cc].radius -pixelBarHeight -pixelBarTop - this.borderWidth) + "px"; + break; + + case "bl": + pixelBar.style.backgroundPosition = "-" + Math.abs((this.settings[cc].radius -pixelBarLeft -1) - this.borderWidth) + "px -" + Math.abs((this.boxHeight + this.settings[cc].radius + pixelBarTop) -this.borderWidth) + "px"; + break; + } + } + } + } + + if(newCorner) + { + // Position the container + switch(cc) + { + case "tl": + if(newCorner.style.position == "absolute") newCorner.style.top = "0px"; + if(newCorner.style.position == "absolute") newCorner.style.left = "0px"; + if(this.topContainer) this.topContainer.appendChild(newCorner); + break; + + case "tr": + if(newCorner.style.position == "absolute") newCorner.style.top = "0px"; + if(newCorner.style.position == "absolute") newCorner.style.right = "0px"; + if(this.topContainer) this.topContainer.appendChild(newCorner); + break; + + case "bl": + if(newCorner.style.position == "absolute") newCorner.style.bottom = "0px"; + if(newCorner.style.position == "absolute") newCorner.style.left = "0px"; + if(this.bottomContainer) this.bottomContainer.appendChild(newCorner); + break; + + case "br": + if(newCorner.style.position == "absolute") newCorner.style.bottom = "0px"; + if(newCorner.style.position == "absolute") newCorner.style.right = "0px"; + if(this.bottomContainer) this.bottomContainer.appendChild(newCorner); + break; + } + } + } + } + + /* + The last thing to do is draw the rest of the filler DIVs. + We only need to create a filler DIVs when two corners have + diffrent radiuses in either the top or bottom container. + */ + + // Find out which corner has the biiger radius and get the difference amount + var radiusDiff = new Array(); + radiusDiff["t"] = Math.abs(this.settings.tl.radius - this.settings.tr.radius) + radiusDiff["b"] = Math.abs(this.settings.bl.radius - this.settings.br.radius); + + for(z in radiusDiff) + { + // FIX for prototype lib + if(z == "t" || z == "b") + { + if(radiusDiff[z]) + { + // Get the type of corner that is the smaller one + var smallerCornerType = ((this.settings[z + "l"].radius < this.settings[z + "r"].radius)? z +"l" : z +"r"); + + // First we need to create a DIV for the space under the smaller corner + var newFiller = document.createElement("DIV"); + newFiller.style.height = radiusDiff[z] + "px"; + newFiller.style.width = this.settings[smallerCornerType].radius+ "px" + newFiller.style.position = "absolute"; + newFiller.style.fontSize = "1px"; + newFiller.style.overflow = "hidden"; + newFiller.style.backgroundColor = this.boxColour; + //newFiller.style.backgroundColor = get_random_color(); + + // Position filler + switch(smallerCornerType) + { + case "tl": + newFiller.style.bottom = "0px"; + newFiller.style.left = "0px"; + newFiller.style.borderLeft = this.borderString; + this.topContainer.appendChild(newFiller); + break; + + case "tr": + newFiller.style.bottom = "0px"; + newFiller.style.right = "0px"; + newFiller.style.borderRight = this.borderString; + this.topContainer.appendChild(newFiller); + break; + + case "bl": + newFiller.style.top = "0px"; + newFiller.style.left = "0px"; + newFiller.style.borderLeft = this.borderString; + this.bottomContainer.appendChild(newFiller); + break; + + case "br": + newFiller.style.top = "0px"; + newFiller.style.right = "0px"; + newFiller.style.borderRight = this.borderString; + this.bottomContainer.appendChild(newFiller); + break; + } + } + + // Create the bar to fill the gap between each corner horizontally + var newFillerBar = document.createElement("DIV"); + newFillerBar.style.position = "relative"; + newFillerBar.style.fontSize = "1px"; + newFillerBar.style.overflow = "hidden"; + newFillerBar.style.backgroundColor = this.boxColour; + newFillerBar.style.backgroundImage = this.backgroundImage; + + switch(z) + { + case "t": + // Top Bar + if(this.topContainer) + { + // Edit by Asger Hallas: Check if settings.xx.radius is not false + if(this.settings.tl.radius && this.settings.tr.radius) + { + newFillerBar.style.height = topMaxRadius - this.borderWidth + "px"; + newFillerBar.style.marginLeft = this.settings.tl.radius - this.borderWidth + "px"; + newFillerBar.style.marginRight = this.settings.tr.radius - this.borderWidth + "px"; + newFillerBar.style.borderTop = this.borderString; + + if(this.backgroundImage != "") + newFillerBar.style.backgroundPosition = "-" + (topMaxRadius + this.borderWidth) + "px 0px"; + + this.topContainer.appendChild(newFillerBar); + } + + // Repos the boxes background image + this.box.style.backgroundPosition = "0px -" + (topMaxRadius - this.borderWidth) + "px"; + } + break; + + case "b": + if(this.bottomContainer) + { + // Edit by Asger Hallas: Check if settings.xx.radius is not false + if(this.settings.bl.radius && this.settings.br.radius) + { + // Bottom Bar + newFillerBar.style.height = botMaxRadius - this.borderWidth + "px"; + newFillerBar.style.marginLeft = this.settings.bl.radius - this.borderWidth + "px"; + newFillerBar.style.marginRight = this.settings.br.radius - this.borderWidth + "px"; + newFillerBar.style.borderBottom = this.borderString; + + if(this.backgroundImage != "") + newFillerBar.style.backgroundPosition = "-" + (botMaxRadius + this.borderWidth) + "px -" + (this.boxHeight + (topMaxRadius + this.borderWidth)) + "px"; + + this.bottomContainer.appendChild(newFillerBar); + } + } + break; + } + } + } + + /* + AutoPad! apply padding if set. + */ + if(this.settings.autoPad == true && this.boxPadding > 0) + { + // Create content container + var contentContainer = document.createElement("DIV"); + + // Set contentContainer's properties + contentContainer.style.position = "relative"; + contentContainer.innerHTML = this.boxContent; + contentContainer.className = "autoPadDiv"; + + // Get padding amounts + var topPadding = Math.abs(topMaxRadius - this.boxPadding); + var botPadding = Math.abs(botMaxRadius - this.boxPadding); + + // Apply top padding + if(topMaxRadius < this.boxPadding) + contentContainer.style.paddingTop = topPadding + "px"; + + // Apply Bottom padding + if(botMaxRadius < this.boxPadding) + contentContainer.style.paddingBottom = botMaxRadius + "px"; + + // Apply left and right padding + contentContainer.style.paddingLeft = this.boxPadding + "px"; + contentContainer.style.paddingRight = this.boxPadding + "px"; + + // Append contentContainer + this.contentDIV = this.box.appendChild(contentContainer); + } + } + + /* + This function draws the pixles + */ + this.drawPixel = function(intx, inty, colour, transAmount, height, newCorner, image, cornerRadius) + { + // Create pixel + var pixel = document.createElement("DIV"); + pixel.style.height = height + "px"; + pixel.style.width = "1px"; + pixel.style.position = "absolute"; + pixel.style.fontSize = "1px"; + pixel.style.overflow = "hidden"; + + // Max Top Radius + var topMaxRadius = Math.max(this.settings["tr"].radius, this.settings["tl"].radius); + + // Dont apply background image to border pixels + if(image == -1 && this.backgroundImage != "") + { + pixel.style.backgroundImage = this.backgroundImage; + pixel.style.backgroundPosition = "-" + (this.boxWidth - (cornerRadius - intx) + this.borderWidth) + "px -" + ((this.boxHeight + topMaxRadius + inty) -this.borderWidth) + "px"; + } + else + { + pixel.style.backgroundColor = colour; + } + + // Set opacity if the transparency is anything other than 100 + if (transAmount != 100) + setOpacity(pixel, transAmount); + + // Set the pixels position + pixel.style.top = inty + "px"; + pixel.style.left = intx + "px"; + + newCorner.appendChild(pixel); + } + } + + // ------------- UTILITY FUNCTIONS + + // Inserts a element after another + function insertAfter(parent, node, referenceNode) + { + parent.insertBefore(node, referenceNode.nextSibling); + } + + /* + Blends the two colours by the fraction + returns the resulting colour as a string in the format "#FFFFFF" + */ + function BlendColour(Col1, Col2, Col1Fraction) + { + var red1 = parseInt(Col1.substr(1,2),16); + var green1 = parseInt(Col1.substr(3,2),16); + var blue1 = parseInt(Col1.substr(5,2),16); + var red2 = parseInt(Col2.substr(1,2),16); + var green2 = parseInt(Col2.substr(3,2),16); + var blue2 = parseInt(Col2.substr(5,2),16); + + if(Col1Fraction > 1 || Col1Fraction < 0) Col1Fraction = 1; + + var endRed = Math.round((red1 * Col1Fraction) + (red2 * (1 - Col1Fraction))); + if(endRed > 255) endRed = 255; + if(endRed < 0) endRed = 0; + + var endGreen = Math.round((green1 * Col1Fraction) + (green2 * (1 - Col1Fraction))); + if(endGreen > 255) endGreen = 255; + if(endGreen < 0) endGreen = 0; + + var endBlue = Math.round((blue1 * Col1Fraction) + (blue2 * (1 - Col1Fraction))); + if(endBlue > 255) endBlue = 255; + if(endBlue < 0) endBlue = 0; + + return "#" + IntToHex(endRed)+ IntToHex(endGreen)+ IntToHex(endBlue); + } + + /* + Converts a number to hexadecimal format + */ + function IntToHex(strNum) + { + base = strNum / 16; + rem = strNum % 16; + base = base - (rem / 16); + baseS = MakeHex(base); + remS = MakeHex(rem); + + return baseS + '' + remS; + } + + + /* + gets the hex bits of a number + */ + function MakeHex(x) + { + if((x >= 0) && (x <= 9)) + { + return x; + } + else + { + switch(x) + { + case 10: return "A"; + case 11: return "B"; + case 12: return "C"; + case 13: return "D"; + case 14: return "E"; + case 15: return "F"; + } + } + } + + + /* + For a pixel cut by the line determines the fraction of the pixel on the 'inside' of the + line. Returns a number between 0 and 1 + */ + function pixelFraction(x, y, r) + { + var pixelfraction = 0; + + /* + determine the co-ordinates of the two points on the perimeter of the pixel that the + circle crosses + */ + var xvalues = new Array(1); + var yvalues = new Array(1); + var point = 0; + var whatsides = ""; + + // x + 0 = Left + var intersect = Math.sqrt((Math.pow(r,2) - Math.pow(x,2))); + + if ((intersect >= y) && (intersect < (y+1))) + { + whatsides = "Left"; + xvalues[point] = 0; + yvalues[point] = intersect - y; + point = point + 1; + } + // y + 1 = Top + var intersect = Math.sqrt((Math.pow(r,2) - Math.pow(y+1,2))); + + if ((intersect >= x) && (intersect < (x+1))) + { + whatsides = whatsides + "Top"; + xvalues[point] = intersect - x; + yvalues[point] = 1; + point = point + 1; + } + // x + 1 = Right + var intersect = Math.sqrt((Math.pow(r,2) - Math.pow(x+1,2))); + + if ((intersect >= y) && (intersect < (y+1))) + { + whatsides = whatsides + "Right"; + xvalues[point] = 1; + yvalues[point] = intersect - y; + point = point + 1; + } + // y + 0 = Bottom + var intersect = Math.sqrt((Math.pow(r,2) - Math.pow(y,2))); + + if ((intersect >= x) && (intersect < (x+1))) + { + whatsides = whatsides + "Bottom"; + xvalues[point] = intersect - x; + yvalues[point] = 0; + } + + /* + depending on which sides of the perimeter of the pixel the circle crosses calculate the + fraction of the pixel inside the circle + */ + switch (whatsides) + { + case "LeftRight": + pixelfraction = Math.min(yvalues[0],yvalues[1]) + ((Math.max(yvalues[0],yvalues[1]) - Math.min(yvalues[0],yvalues[1]))/2); + break; + + case "TopRight": + pixelfraction = 1-(((1-xvalues[0])*(1-yvalues[1]))/2); + break; + + case "TopBottom": + pixelfraction = Math.min(xvalues[0],xvalues[1]) + ((Math.max(xvalues[0],xvalues[1]) - Math.min(xvalues[0],xvalues[1]))/2); + break; + + case "LeftBottom": + pixelfraction = (yvalues[0]*xvalues[1])/2; + break; + + default: + pixelfraction = 1; + } + + return pixelfraction; + } + + + // This function converts CSS rgb(x, x, x) to hexadecimal + function rgb2Hex(rgbColour) + { + try{ + + // Get array of RGB values + var rgbArray = rgb2Array(rgbColour); + + // Get RGB values + var red = parseInt(rgbArray[0]); + var green = parseInt(rgbArray[1]); + var blue = parseInt(rgbArray[2]); + + // Build hex colour code + var hexColour = "#" + IntToHex(red) + IntToHex(green) + IntToHex(blue); + } + catch(e){ + + alert("There was an error converting the RGB value to Hexadecimal in function rgb2Hex"); + } + + return hexColour; + } + + // Returns an array of rbg values + function rgb2Array(rgbColour) + { + // Remove rgb() + var rgbValues = rgbColour.substring(4, rgbColour.indexOf(")")); + + // Split RGB into array + var rgbArray = rgbValues.split(", "); + + return rgbArray; + } + + /* + Function by Simon Willison from sitepoint.com + Modified by Cameron Cooke adding Safari's rgba support + */ + function setOpacity(obj, opacity) + { + opacity = (opacity == 100)?99.999:opacity; + + if(isSafari && obj.tagName != "IFRAME") + { + // Get array of RGB values + var rgbArray = rgb2Array(obj.style.backgroundColor); + + // Get RGB values + var red = parseInt(rgbArray[0]); + var green = parseInt(rgbArray[1]); + var blue = parseInt(rgbArray[2]); + + // Safari using RGBA support + obj.style.backgroundColor = "rgba(" + red + ", " + green + ", " + blue + ", " + opacity/100 + ")"; + } + else if(typeof(obj.style.opacity) != "undefined") + { + // W3C + obj.style.opacity = opacity/100; + } + else if(typeof(obj.style.MozOpacity) != "undefined") + { + // Older Mozilla + obj.style.MozOpacity = opacity/100; + } + else if(typeof(obj.style.filter) != "undefined") + { + // IE + obj.style.filter = "alpha(opacity:" + opacity + ")"; + } + else if(typeof(obj.style.KHTMLOpacity) != "undefined") + { + // Older KHTML Based Browsers + obj.style.KHTMLOpacity = opacity/100; + } + } + + /* + Returns index if the passed value is found in the + array otherwise returns false. + */ + function inArray(array, value) + { + for(var i = 0; i < array.length; i++){ + + // Matches identical (===), not just similar (==). + if (array[i] === value) return i; + } + + return false; + } + + /* + Returns true if the passed value is found as a key + in the array otherwise returns false. + */ + function inArrayKey(array, value) + { + for(key in array){ + + // Matches identical (===), not just similar (==). + if(key === value) return true; + } + + return false; + } + + // Cross browser add event wrapper + function addEvent(elm, evType, fn, useCapture) { + if (elm.addEventListener) { + elm.addEventListener(evType, fn, useCapture); + return true; + } + else if (elm.attachEvent) { + var r = elm.attachEvent('on' + evType, fn); + return r; + } + else { + elm['on' + evType] = fn; + } + } + + // Cross browser remove event wrapper + function removeEvent(obj, evType, fn, useCapture){ + if (obj.removeEventListener){ + obj.removeEventListener(evType, fn, useCapture); + return true; + } else if (obj.detachEvent){ + var r = obj.detachEvent("on"+evType, fn); + return r; + } else { + alert("Handler could not be removed"); + } + } + + // Formats colours + function format_colour(colour) + { + var returnColour = "#ffffff"; + + // Make sure colour is set and not transparent + if(colour != "" && colour != "transparent") + { + // RGB Value? + if(colour.substr(0, 3) == "rgb") + { + // Get HEX aquiv. + returnColour = rgb2Hex(colour); + } + else if(colour.length == 4) + { + // 3 chr colour code add remainder + returnColour = "#" + colour.substring(1, 2) + colour.substring(1, 2) + colour.substring(2, 3) + colour.substring(2, 3) + colour.substring(3, 4) + colour.substring(3, 4); + } + else + { + // Normal valid hex colour + returnColour = colour; + } + } + + return returnColour; + } + + // Returns the style value for the property specfied + function get_style(obj, property, propertyNS) + { + try + { + if(obj.currentStyle) + { + var returnVal = eval("obj.currentStyle." + property); + } + else + { + /* + Safari does not expose any information for the object if display is + set to none is set so we temporally enable it. + */ + if(isSafari && obj.style.display == "none") + { + obj.style.display = ""; + var wasHidden = true; + } + + var returnVal = document.defaultView.getComputedStyle(obj, '').getPropertyValue(propertyNS); + + // Rehide the object + if(isSafari && wasHidden) + { + obj.style.display = "none"; + } + } + } + catch(e) + { + // Do nothing + } + + return returnVal; + } + + // Get elements by class by Dustin Diaz. + function getElementsByClass(searchClass, node, tag) + { + var classElements = new Array(); + + if(node == null) + node = document; + if(tag == null) + tag = '*'; + + var els = node.getElementsByTagName(tag); + var elsLen = els.length; + var pattern = new RegExp("(^|\s)"+searchClass+"(\s|$)"); + + for (i = 0, j = 0; i < elsLen; i++) + { + if(pattern.test(els[i].className)) + { + classElements[j] = els[i]; + j++; + } + } + + return classElements; + } + + // Displays error message + function newCurvyError(errorMessage) + { + return new Error("curvyCorners Error:\n" + errorMessage) + } \ No newline at end of file Index: openacs-4/packages/ajaxhelper/www/resources/curvycorners/rounded_corners_lite.inc.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/curvycorners/rounded_corners_lite.inc.js,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/resources/curvycorners/rounded_corners_lite.inc.js 6 Nov 2006 13:15:30 -0000 1.1 @@ -0,0 +1,285 @@ + + /**************************************************************** + * * + * curvyCorners * + * ------------ * + * * + * This script generates rounded corners for your divs. * + * * + * Version 1.2.9 * + * Copyright (c) 2006 Cameron Cooke * + * By: Cameron Cooke and Tim Hutchison. * + * * + * * + * Website: http://www.curvycorners.net * + * Email: info@totalinfinity.com * + * Forum: http://www.curvycorners.net/forum/ * + * * + * * + * This library is free software; you can redistribute * + * it and/or modify it under the terms of the GNU * + * Lesser General Public License as published by the * + * Free Software Foundation; either version 2.1 of the * + * License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will * + * be useful, but WITHOUT ANY WARRANTY; without even the * + * implied warranty of MERCHANTABILITY or FITNESS FOR A * + * PARTICULAR PURPOSE. See the GNU Lesser General Public * + * License for more details. * + * * + * You should have received a copy of the GNU Lesser * + * General Public License along with this library; * + * Inc., 59 Temple Place, Suite 330, Boston, * + * MA 02111-1307 USA * + * * + ****************************************************************/ + +var isIE = navigator.userAgent.toLowerCase().indexOf("msie") > -1; var isMoz = document.implementation && document.implementation.createDocument; var isSafari = ((navigator.userAgent.toLowerCase().indexOf('safari')!=-1)&&(navigator.userAgent.toLowerCase().indexOf('mac')!=-1))?true:false; function curvyCorners() +{ if(typeof(arguments[0]) != "object") throw newCurvyError("First parameter of curvyCorners() must be an object."); if(typeof(arguments[1]) != "object" && typeof(arguments[1]) != "string") throw newCurvyError("Second parameter of curvyCorners() must be an object or a class name."); if(typeof(arguments[1]) == "string") +{ var startIndex = 0; var boxCol = getElementsByClass(arguments[1]);} +else +{ var startIndex = 1; var boxCol = arguments;} +var curvyCornersCol = new Array(); if(arguments[0].validTags) +var validElements = arguments[0].validTags; else +var validElements = ["div"]; for(var i = startIndex, j = boxCol.length; i < j; i++) +{ var currentTag = boxCol[i].tagName.toLowerCase(); if(inArray(validElements, currentTag) !== false) +{ curvyCornersCol[curvyCornersCol.length] = new curvyObject(arguments[0], boxCol[i]);} +} +this.objects = curvyCornersCol; this.applyCornersToAll = function() +{ for(var x = 0, k = this.objects.length; x < k; x++) +{ this.objects[x].applyCorners();} +} +} +function curvyObject() +{ this.box = arguments[1]; this.settings = arguments[0]; this.topContainer = null; this.bottomContainer = null; this.masterCorners = new Array(); this.contentDIV = null; var boxHeight = get_style(this.box, "height", "height"); var boxWidth = get_style(this.box, "width", "width"); var borderWidth = get_style(this.box, "borderTopWidth", "border-top-width"); var borderColour = get_style(this.box, "borderTopColor", "border-top-color"); var boxColour = get_style(this.box, "backgroundColor", "background-color"); var backgroundImage = get_style(this.box, "backgroundImage", "background-image"); var boxPosition = get_style(this.box, "position", "position"); var boxPadding = get_style(this.box, "paddingTop", "padding-top"); this.boxHeight = parseInt(((boxHeight != "" && boxHeight != "auto" && boxHeight.indexOf("%") == -1)? boxHeight.substring(0, boxHeight.indexOf("px")) : this.box.scrollHeight)); this.boxWidth = parseInt(((boxWidth != "" && boxWidth != "auto" && boxWidth.indexOf("%") == -1)? boxWidth.substring(0, boxWidth.indexOf("px")) : this.box.scrollWidth)); this.borderWidth = parseInt(((borderWidth != "" && borderWidth.indexOf("px") !== -1)? borderWidth.slice(0, borderWidth.indexOf("px")) : 0)); this.boxColour = format_colour(boxColour); this.boxPadding = parseInt(((boxPadding != "" && boxPadding.indexOf("px") !== -1)? boxPadding.slice(0, boxPadding.indexOf("px")) : 0)); this.borderColour = format_colour(borderColour); this.borderString = this.borderWidth + "px" + " solid " + this.borderColour; this.backgroundImage = ((backgroundImage != "none")? backgroundImage : ""); this.boxContent = this.box.innerHTML; if(boxPosition != "absolute") this.box.style.position = "relative"; this.box.style.padding = "0px"; if(isIE && boxWidth == "auto" && boxHeight == "auto") this.box.style.width = "100%"; if(this.settings.autoPad == true && this.boxPadding > 0) +this.box.innerHTML = ""; this.applyCorners = function() +{ for(var t = 0; t < 2; t++) +{ switch(t) +{ case 0: +if(this.settings.tl || this.settings.tr) +{ var newMainContainer = document.createElement("DIV"); newMainContainer.style.width = "100%"; newMainContainer.style.fontSize = "1px"; newMainContainer.style.overflow = "hidden"; newMainContainer.style.position = "absolute"; newMainContainer.style.paddingLeft = this.borderWidth + "px"; newMainContainer.style.paddingRight = this.borderWidth + "px"; var topMaxRadius = Math.max(this.settings.tl ? this.settings.tl.radius : 0, this.settings.tr ? this.settings.tr.radius : 0); newMainContainer.style.height = topMaxRadius + "px"; newMainContainer.style.top = 0 - topMaxRadius + "px"; newMainContainer.style.left = 0 - this.borderWidth + "px"; this.topContainer = this.box.appendChild(newMainContainer);} +break; case 1: +if(this.settings.bl || this.settings.br) +{ var newMainContainer = document.createElement("DIV"); newMainContainer.style.width = "100%"; newMainContainer.style.fontSize = "1px"; newMainContainer.style.overflow = "hidden"; newMainContainer.style.position = "absolute"; newMainContainer.style.paddingLeft = this.borderWidth + "px"; newMainContainer.style.paddingRight = this.borderWidth + "px"; var botMaxRadius = Math.max(this.settings.bl ? this.settings.bl.radius : 0, this.settings.br ? this.settings.br.radius : 0); newMainContainer.style.height = botMaxRadius + "px"; newMainContainer.style.bottom = 0 - botMaxRadius + "px"; newMainContainer.style.left = 0 - this.borderWidth + "px"; this.bottomContainer = this.box.appendChild(newMainContainer);} +break;} +} +if(this.topContainer) this.box.style.borderTopWidth = "0px"; if(this.bottomContainer) this.box.style.borderBottomWidth = "0px"; var corners = ["tr", "tl", "br", "bl"]; for(var i in corners) +{ if(i > -1 < 4) +{ var cc = corners[i]; if(!this.settings[cc]) +{ if(((cc == "tr" || cc == "tl") && this.topContainer != null) || ((cc == "br" || cc == "bl") && this.bottomContainer != null)) +{ var newCorner = document.createElement("DIV"); newCorner.style.position = "relative"; newCorner.style.fontSize = "1px"; newCorner.style.overflow = "hidden"; if(this.backgroundImage == "") +newCorner.style.backgroundColor = this.boxColour; else +newCorner.style.backgroundImage = this.backgroundImage; switch(cc) +{ case "tl": +newCorner.style.height = topMaxRadius - this.borderWidth + "px"; newCorner.style.marginRight = this.settings.tr.radius - (this.borderWidth*2) + "px"; newCorner.style.borderLeft = this.borderString; newCorner.style.borderTop = this.borderString; newCorner.style.left = -this.borderWidth + "px"; break; case "tr": +newCorner.style.height = topMaxRadius - this.borderWidth + "px"; newCorner.style.marginLeft = this.settings.tl.radius - (this.borderWidth*2) + "px"; newCorner.style.borderRight = this.borderString; newCorner.style.borderTop = this.borderString; newCorner.style.backgroundPosition = "-" + (topMaxRadius + this.borderWidth) + "px 0px"; newCorner.style.left = this.borderWidth + "px"; break; case "bl": +newCorner.style.height = botMaxRadius - this.borderWidth + "px"; newCorner.style.marginRight = this.settings.br.radius - (this.borderWidth*2) + "px"; newCorner.style.borderLeft = this.borderString; newCorner.style.borderBottom = this.borderString; newCorner.style.left = -this.borderWidth + "px"; newCorner.style.backgroundPosition = "-" + (this.borderWidth) + "px -" + (this.boxHeight + (botMaxRadius + this.borderWidth)) + "px"; break; case "br": +newCorner.style.height = botMaxRadius - this.borderWidth + "px"; newCorner.style.marginLeft = this.settings.bl.radius - (this.borderWidth*2) + "px"; newCorner.style.borderRight = this.borderString; newCorner.style.borderBottom = this.borderString; newCorner.style.left = this.borderWidth + "px" +newCorner.style.backgroundPosition = "-" + (botMaxRadius + this.borderWidth) + "px -" + (this.boxHeight + (botMaxRadius + this.borderWidth)) + "px"; break;} +} +} +else +{ if(this.masterCorners[this.settings[cc].radius]) +{ var newCorner = this.masterCorners[this.settings[cc].radius].cloneNode(true);} +else +{ var newCorner = document.createElement("DIV"); newCorner.style.height = this.settings[cc].radius + "px"; newCorner.style.width = this.settings[cc].radius + "px"; newCorner.style.position = "absolute"; newCorner.style.fontSize = "1px"; newCorner.style.overflow = "hidden"; var borderRadius = parseInt(this.settings[cc].radius - this.borderWidth); for(var intx = 0, j = this.settings[cc].radius; intx < j; intx++) +{ if((intx +1) >= borderRadius) +var y1 = -1; else +var y1 = (Math.floor(Math.sqrt(Math.pow(borderRadius, 2) - Math.pow((intx+1), 2))) - 1); if(borderRadius != j) +{ if((intx) >= borderRadius) +var y2 = -1; else +var y2 = Math.ceil(Math.sqrt(Math.pow(borderRadius,2) - Math.pow(intx, 2))); if((intx+1) >= j) +var y3 = -1; else +var y3 = (Math.floor(Math.sqrt(Math.pow(j ,2) - Math.pow((intx+1), 2))) - 1);} +if((intx) >= j) +var y4 = -1; else +var y4 = Math.ceil(Math.sqrt(Math.pow(j ,2) - Math.pow(intx, 2))); if(y1 > -1) this.drawPixel(intx, 0, this.boxColour, 100, (y1+1), newCorner, -1, this.settings[cc].radius); if(borderRadius != j) +{ for(var inty = (y1 + 1); inty < y2; inty++) +{ if(this.settings.antiAlias) +{ if(this.backgroundImage != "") +{ var borderFract = (pixelFraction(intx, inty, borderRadius) * 100); if(borderFract < 30) +{ this.drawPixel(intx, inty, this.borderColour, 100, 1, newCorner, 0, this.settings[cc].radius);} +else +{ this.drawPixel(intx, inty, this.borderColour, 100, 1, newCorner, -1, this.settings[cc].radius);} +} +else +{ var pixelcolour = BlendColour(this.boxColour, this.borderColour, pixelFraction(intx, inty, borderRadius)); this.drawPixel(intx, inty, pixelcolour, 100, 1, newCorner, 0, this.settings[cc].radius, cc);} +} +} +if(this.settings.antiAlias) +{ if(y3 >= y2) +{ if (y2 == -1) y2 = 0; this.drawPixel(intx, y2, this.borderColour, 100, (y3 - y2 + 1), newCorner, 0, 0);} +} +else +{ if(y3 >= y1) +{ this.drawPixel(intx, (y1 + 1), this.borderColour, 100, (y3 - y1), newCorner, 0, 0);} +} +var outsideColour = this.borderColour;} +else +{ var outsideColour = this.boxColour; var y3 = y1;} +if(this.settings.antiAlias) +{ for(var inty = (y3 + 1); inty < y4; inty++) +{ this.drawPixel(intx, inty, outsideColour, (pixelFraction(intx, inty , j) * 100), 1, newCorner, ((this.borderWidth > 0)? 0 : -1), this.settings[cc].radius);} +} +} +this.masterCorners[this.settings[cc].radius] = newCorner.cloneNode(true);} +if(cc != "br") +{ for(var t = 0, k = newCorner.childNodes.length; t < k; t++) +{ var pixelBar = newCorner.childNodes[t]; var pixelBarTop = parseInt(pixelBar.style.top.substring(0, pixelBar.style.top.indexOf("px"))); var pixelBarLeft = parseInt(pixelBar.style.left.substring(0, pixelBar.style.left.indexOf("px"))); var pixelBarHeight = parseInt(pixelBar.style.height.substring(0, pixelBar.style.height.indexOf("px"))); if(cc == "tl" || cc == "bl"){ pixelBar.style.left = this.settings[cc].radius -pixelBarLeft -1 + "px";} +if(cc == "tr" || cc == "tl"){ pixelBar.style.top = this.settings[cc].radius -pixelBarHeight -pixelBarTop + "px";} +switch(cc) +{ case "tr": +pixelBar.style.backgroundPosition = "-" + Math.abs((this.boxWidth - this.settings[cc].radius + this.borderWidth) + pixelBarLeft) + "px -" + Math.abs(this.settings[cc].radius -pixelBarHeight -pixelBarTop - this.borderWidth) + "px"; break; case "tl": +pixelBar.style.backgroundPosition = "-" + Math.abs((this.settings[cc].radius -pixelBarLeft -1) - this.borderWidth) + "px -" + Math.abs(this.settings[cc].radius -pixelBarHeight -pixelBarTop - this.borderWidth) + "px"; break; case "bl": +pixelBar.style.backgroundPosition = "-" + Math.abs((this.settings[cc].radius -pixelBarLeft -1) - this.borderWidth) + "px -" + Math.abs((this.boxHeight + this.settings[cc].radius + pixelBarTop) -this.borderWidth) + "px"; break;} +} +} +} +if(newCorner) +{ switch(cc) +{ case "tl": +if(newCorner.style.position == "absolute") newCorner.style.top = "0px"; if(newCorner.style.position == "absolute") newCorner.style.left = "0px"; if(this.topContainer) this.topContainer.appendChild(newCorner); break; case "tr": +if(newCorner.style.position == "absolute") newCorner.style.top = "0px"; if(newCorner.style.position == "absolute") newCorner.style.right = "0px"; if(this.topContainer) this.topContainer.appendChild(newCorner); break; case "bl": +if(newCorner.style.position == "absolute") newCorner.style.bottom = "0px"; if(newCorner.style.position == "absolute") newCorner.style.left = "0px"; if(this.bottomContainer) this.bottomContainer.appendChild(newCorner); break; case "br": +if(newCorner.style.position == "absolute") newCorner.style.bottom = "0px"; if(newCorner.style.position == "absolute") newCorner.style.right = "0px"; if(this.bottomContainer) this.bottomContainer.appendChild(newCorner); break;} +} +} +} +var radiusDiff = new Array(); radiusDiff["t"] = Math.abs(this.settings.tl.radius - this.settings.tr.radius) +radiusDiff["b"] = Math.abs(this.settings.bl.radius - this.settings.br.radius); for(z in radiusDiff) +{ if(z == "t" || z == "b") +{ if(radiusDiff[z]) +{ var smallerCornerType = ((this.settings[z + "l"].radius < this.settings[z + "r"].radius)? z +"l" : z +"r"); var newFiller = document.createElement("DIV"); newFiller.style.height = radiusDiff[z] + "px"; newFiller.style.width = this.settings[smallerCornerType].radius+ "px" +newFiller.style.position = "absolute"; newFiller.style.fontSize = "1px"; newFiller.style.overflow = "hidden"; newFiller.style.backgroundColor = this.boxColour; switch(smallerCornerType) +{ case "tl": +newFiller.style.bottom = "0px"; newFiller.style.left = "0px"; newFiller.style.borderLeft = this.borderString; this.topContainer.appendChild(newFiller); break; case "tr": +newFiller.style.bottom = "0px"; newFiller.style.right = "0px"; newFiller.style.borderRight = this.borderString; this.topContainer.appendChild(newFiller); break; case "bl": +newFiller.style.top = "0px"; newFiller.style.left = "0px"; newFiller.style.borderLeft = this.borderString; this.bottomContainer.appendChild(newFiller); break; case "br": +newFiller.style.top = "0px"; newFiller.style.right = "0px"; newFiller.style.borderRight = this.borderString; this.bottomContainer.appendChild(newFiller); break;} +} +var newFillerBar = document.createElement("DIV"); newFillerBar.style.position = "relative"; newFillerBar.style.fontSize = "1px"; newFillerBar.style.overflow = "hidden"; newFillerBar.style.backgroundColor = this.boxColour; newFillerBar.style.backgroundImage = this.backgroundImage; switch(z) +{ case "t": +if(this.topContainer) +{ if(this.settings.tl.radius && this.settings.tr.radius) +{ newFillerBar.style.height = topMaxRadius - this.borderWidth + "px"; newFillerBar.style.marginLeft = this.settings.tl.radius - this.borderWidth + "px"; newFillerBar.style.marginRight = this.settings.tr.radius - this.borderWidth + "px"; newFillerBar.style.borderTop = this.borderString; if(this.backgroundImage != "") +newFillerBar.style.backgroundPosition = "-" + (topMaxRadius + this.borderWidth) + "px 0px"; this.topContainer.appendChild(newFillerBar);} +this.box.style.backgroundPosition = "0px -" + (topMaxRadius - this.borderWidth) + "px";} +break; case "b": +if(this.bottomContainer) +{ if(this.settings.bl.radius && this.settings.br.radius) +{ newFillerBar.style.height = botMaxRadius - this.borderWidth + "px"; newFillerBar.style.marginLeft = this.settings.bl.radius - this.borderWidth + "px"; newFillerBar.style.marginRight = this.settings.br.radius - this.borderWidth + "px"; newFillerBar.style.borderBottom = this.borderString; if(this.backgroundImage != "") +newFillerBar.style.backgroundPosition = "-" + (botMaxRadius + this.borderWidth) + "px -" + (this.boxHeight + (topMaxRadius + this.borderWidth)) + "px"; this.bottomContainer.appendChild(newFillerBar);} +} +break;} +} +} +if(this.settings.autoPad == true && this.boxPadding > 0) +{ var contentContainer = document.createElement("DIV"); contentContainer.style.position = "relative"; contentContainer.innerHTML = this.boxContent; contentContainer.className = "autoPadDiv"; var topPadding = Math.abs(topMaxRadius - this.boxPadding); var botPadding = Math.abs(botMaxRadius - this.boxPadding); if(topMaxRadius < this.boxPadding) +contentContainer.style.paddingTop = topPadding + "px"; if(botMaxRadius < this.boxPadding) +contentContainer.style.paddingBottom = botMaxRadius + "px"; contentContainer.style.paddingLeft = this.boxPadding + "px"; contentContainer.style.paddingRight = this.boxPadding + "px"; this.contentDIV = this.box.appendChild(contentContainer);} +} +this.drawPixel = function(intx, inty, colour, transAmount, height, newCorner, image, cornerRadius) +{ var pixel = document.createElement("DIV"); pixel.style.height = height + "px"; pixel.style.width = "1px"; pixel.style.position = "absolute"; pixel.style.fontSize = "1px"; pixel.style.overflow = "hidden"; var topMaxRadius = Math.max(this.settings["tr"].radius, this.settings["tl"].radius); if(image == -1 && this.backgroundImage != "") +{ pixel.style.backgroundImage = this.backgroundImage; pixel.style.backgroundPosition = "-" + (this.boxWidth - (cornerRadius - intx) + this.borderWidth) + "px -" + ((this.boxHeight + topMaxRadius + inty) -this.borderWidth) + "px";} +else +{ pixel.style.backgroundColor = colour;} +if (transAmount != 100) +setOpacity(pixel, transAmount); pixel.style.top = inty + "px"; pixel.style.left = intx + "px"; newCorner.appendChild(pixel);} +} +function insertAfter(parent, node, referenceNode) +{ parent.insertBefore(node, referenceNode.nextSibling);} +function BlendColour(Col1, Col2, Col1Fraction) +{ var red1 = parseInt(Col1.substr(1,2),16); var green1 = parseInt(Col1.substr(3,2),16); var blue1 = parseInt(Col1.substr(5,2),16); var red2 = parseInt(Col2.substr(1,2),16); var green2 = parseInt(Col2.substr(3,2),16); var blue2 = parseInt(Col2.substr(5,2),16); if(Col1Fraction > 1 || Col1Fraction < 0) Col1Fraction = 1; var endRed = Math.round((red1 * Col1Fraction) + (red2 * (1 - Col1Fraction))); if(endRed > 255) endRed = 255; if(endRed < 0) endRed = 0; var endGreen = Math.round((green1 * Col1Fraction) + (green2 * (1 - Col1Fraction))); if(endGreen > 255) endGreen = 255; if(endGreen < 0) endGreen = 0; var endBlue = Math.round((blue1 * Col1Fraction) + (blue2 * (1 - Col1Fraction))); if(endBlue > 255) endBlue = 255; if(endBlue < 0) endBlue = 0; return "#" + IntToHex(endRed)+ IntToHex(endGreen)+ IntToHex(endBlue);} +function IntToHex(strNum) +{ base = strNum / 16; rem = strNum % 16; base = base - (rem / 16); baseS = MakeHex(base); remS = MakeHex(rem); return baseS + '' + remS;} +function MakeHex(x) +{ if((x >= 0) && (x <= 9)) +{ return x;} +else +{ switch(x) +{ case 10: return "A"; case 11: return "B"; case 12: return "C"; case 13: return "D"; case 14: return "E"; case 15: return "F";} +} +} +function pixelFraction(x, y, r) +{ var pixelfraction = 0; var xvalues = new Array(1); var yvalues = new Array(1); var point = 0; var whatsides = ""; var intersect = Math.sqrt((Math.pow(r,2) - Math.pow(x,2))); if ((intersect >= y) && (intersect < (y+1))) +{ whatsides = "Left"; xvalues[point] = 0; yvalues[point] = intersect - y; point = point + 1;} +var intersect = Math.sqrt((Math.pow(r,2) - Math.pow(y+1,2))); if ((intersect >= x) && (intersect < (x+1))) +{ whatsides = whatsides + "Top"; xvalues[point] = intersect - x; yvalues[point] = 1; point = point + 1;} +var intersect = Math.sqrt((Math.pow(r,2) - Math.pow(x+1,2))); if ((intersect >= y) && (intersect < (y+1))) +{ whatsides = whatsides + "Right"; xvalues[point] = 1; yvalues[point] = intersect - y; point = point + 1;} +var intersect = Math.sqrt((Math.pow(r,2) - Math.pow(y,2))); if ((intersect >= x) && (intersect < (x+1))) +{ whatsides = whatsides + "Bottom"; xvalues[point] = intersect - x; yvalues[point] = 0;} +switch (whatsides) +{ case "LeftRight": +pixelfraction = Math.min(yvalues[0],yvalues[1]) + ((Math.max(yvalues[0],yvalues[1]) - Math.min(yvalues[0],yvalues[1]))/2); break; case "TopRight": +pixelfraction = 1-(((1-xvalues[0])*(1-yvalues[1]))/2); break; case "TopBottom": +pixelfraction = Math.min(xvalues[0],xvalues[1]) + ((Math.max(xvalues[0],xvalues[1]) - Math.min(xvalues[0],xvalues[1]))/2); break; case "LeftBottom": +pixelfraction = (yvalues[0]*xvalues[1])/2; break; default: +pixelfraction = 1;} +return pixelfraction;} +function rgb2Hex(rgbColour) +{ try{ var rgbArray = rgb2Array(rgbColour); var red = parseInt(rgbArray[0]); var green = parseInt(rgbArray[1]); var blue = parseInt(rgbArray[2]); var hexColour = "#" + IntToHex(red) + IntToHex(green) + IntToHex(blue);} +catch(e){ alert("There was an error converting the RGB value to Hexadecimal in function rgb2Hex");} +return hexColour;} +function rgb2Array(rgbColour) +{ var rgbValues = rgbColour.substring(4, rgbColour.indexOf(")")); var rgbArray = rgbValues.split(", "); return rgbArray;} +function setOpacity(obj, opacity) +{ opacity = (opacity == 100)?99.999:opacity; if(isSafari && obj.tagName != "IFRAME") +{ var rgbArray = rgb2Array(obj.style.backgroundColor); var red = parseInt(rgbArray[0]); var green = parseInt(rgbArray[1]); var blue = parseInt(rgbArray[2]); obj.style.backgroundColor = "rgba(" + red + ", " + green + ", " + blue + ", " + opacity/100 + ")";} +else if(typeof(obj.style.opacity) != "undefined") +{ obj.style.opacity = opacity/100;} +else if(typeof(obj.style.MozOpacity) != "undefined") +{ obj.style.MozOpacity = opacity/100;} +else if(typeof(obj.style.filter) != "undefined") +{ obj.style.filter = "alpha(opacity:" + opacity + ")";} +else if(typeof(obj.style.KHTMLOpacity) != "undefined") +{ obj.style.KHTMLOpacity = opacity/100;} +} +function inArray(array, value) +{ for(var i = 0; i < array.length; i++){ if (array[i] === value) return i;} +return false;} +function inArrayKey(array, value) +{ for(key in array){ if(key === value) return true;} +return false;} +function addEvent(elm, evType, fn, useCapture) { if (elm.addEventListener) { elm.addEventListener(evType, fn, useCapture); return true;} +else if (elm.attachEvent) { var r = elm.attachEvent('on' + evType, fn); return r;} +else { elm['on' + evType] = fn;} +} +function removeEvent(obj, evType, fn, useCapture){ if (obj.removeEventListener){ obj.removeEventListener(evType, fn, useCapture); return true;} else if (obj.detachEvent){ var r = obj.detachEvent("on"+evType, fn); return r;} else { alert("Handler could not be removed");} +} +function format_colour(colour) +{ var returnColour = "#ffffff"; if(colour != "" && colour != "transparent") +{ if(colour.substr(0, 3) == "rgb") +{ returnColour = rgb2Hex(colour);} +else if(colour.length == 4) +{ returnColour = "#" + colour.substring(1, 2) + colour.substring(1, 2) + colour.substring(2, 3) + colour.substring(2, 3) + colour.substring(3, 4) + colour.substring(3, 4);} +else +{ returnColour = colour;} +} +return returnColour;} +function get_style(obj, property, propertyNS) +{ try +{ if(obj.currentStyle) +{ var returnVal = eval("obj.currentStyle." + property);} +else +{ if(isSafari && obj.style.display == "none") +{ obj.style.display = ""; var wasHidden = true;} +var returnVal = document.defaultView.getComputedStyle(obj, '').getPropertyValue(propertyNS); if(isSafari && wasHidden) +{ obj.style.display = "none";} +} +} +catch(e) +{ } +return returnVal;} +function getElementsByClass(searchClass, node, tag) +{ var classElements = new Array(); if(node == null) +node = document; if(tag == null) +tag = '*'; var els = node.getElementsByTagName(tag); var elsLen = els.length; var pattern = new RegExp("(^|\s)"+searchClass+"(\s|$)"); for (i = 0, j = 0; i < elsLen; i++) +{ if(pattern.test(els[i].className)) +{ classElements[j] = els[i]; j++;} +} +return classElements;} +function newCurvyError(errorMessage) +{ return new Error("curvyCorners Error:\n" + errorMessage) +} Index: openacs-4/packages/ajaxhelper/www/tests/test_ajax-handle.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/tests/test_ajax-handle.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/tests/test_ajax-handle.adp 6 Nov 2006 13:15:30 -0000 1.1 @@ -0,0 +1 @@ +... jumped over @name;noquote@. \ No newline at end of file Index: openacs-4/packages/ajaxhelper/www/tests/test_ajax-handle.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/tests/test_ajax-handle.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/tests/test_ajax-handle.tcl 6 Nov 2006 13:15:30 -0000 1.1 @@ -0,0 +1,2 @@ + +set name [ns_queryget "myname"] \ No newline at end of file Index: openacs-4/packages/ajaxhelper/www/tests/test_ajax.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/tests/test_ajax.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/tests/test_ajax.adp 6 Nov 2006 13:15:30 -0000 1.1 @@ -0,0 +1,10 @@ + + TEST : Ajax + +Type your name please : +
+ Update Content +

+
+ The quick brown fox ..... +
Index: openacs-4/packages/ajaxhelper/www/tests/test_ajax.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/tests/test_ajax.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/tests/test_ajax.tcl 6 Nov 2006 13:15:30 -0000 1.1 @@ -0,0 +1,4 @@ +set updatescript [ah::ajaxupdate -container "test" \ + -url "test_ajax-handle" \ + -pars "'myname='+document.getElementById('name').value" \ + -options "onSuccess:function(t){ alert('update done : '+t.responseText); }"] Index: openacs-4/packages/ajaxhelper/www/tests/test_dragdrop.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/tests/test_dragdrop.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/tests/test_dragdrop.adp 6 Nov 2006 13:15:30 -0000 1.1 @@ -0,0 +1,19 @@ + +TEST : Drag n Drop + +
+

This portlet is draggable .... drag me.

+
+ +@jscript;noquote@ Index: openacs-4/packages/ajaxhelper/www/tests/test_dragdrop.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/tests/test_dragdrop.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/tests/test_dragdrop.tcl 6 Nov 2006 13:15:30 -0000 1.1 @@ -0,0 +1,2 @@ +set draggable_script [ah::draggable -element "test"] +set jscript [ah::enclose_in_script -script $draggable_script] \ No newline at end of file Index: openacs-4/packages/ajaxhelper/www/tests/test_effects.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/tests/test_effects.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/tests/test_effects.adp 6 Nov 2006 13:15:30 -0000 1.1 @@ -0,0 +1,8 @@ + + Test Effects + + Show | Hide +

+
+this is a test div +
Index: openacs-4/packages/ajaxhelper/www/tests/test_effects.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/tests/test_effects.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/tests/test_effects.tcl 6 Nov 2006 13:15:30 -0000 1.1 @@ -0,0 +1,6 @@ +set fadescript [ah::effects -element "test" \ + -effect "Fade" \ + -options "duration:2.0,afterFinish:function() { alert('element is gone'); }" ] +set showscript [ah::effects -element "test" \ + -effect "Appear" \ + -options "duration:2.0,afterFinish:function() { alert('element has appeared'); }" ] \ No newline at end of file Index: openacs-4/packages/ajaxhelper/www/tests/test_insertion.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/tests/test_insertion.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/tests/test_insertion.adp 6 Nov 2006 13:15:30 -0000 1.1 @@ -0,0 +1,6 @@ + + TEST : DOM Insert + +
The quick brown fox jumped over the
+
+ \ No newline at end of file Index: openacs-4/packages/ajaxhelper/www/tests/test_insertion.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/tests/test_insertion.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/tests/test_insertion.tcl 6 Nov 2006 13:15:30 -0000 1.1 @@ -0,0 +1 @@ +set script [ah::insert -element "maindiv" -text " quick brown fox" -position "Bottom"] \ No newline at end of file Index: openacs-4/packages/ajaxhelper/www/tests/test_roundcorners.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/tests/test_roundcorners.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/tests/test_roundcorners.adp 6 Nov 2006 13:15:30 -0000 1.1 @@ -0,0 +1,21 @@ + + TEST : Rounded Corners + + + + +
+
+ this is a div with rounded corners +
+@roundcorners;noquote@ Index: openacs-4/packages/ajaxhelper/www/tests/test_roundcorners.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/tests/test_roundcorners.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/tests/test_roundcorners.tcl 6 Nov 2006 13:15:30 -0000 1.1 @@ -0,0 +1,6 @@ +set roundcorners [ah::rounder -classname "myBox" \ + -jsobjname "boxobj" \ + -validtags "div" \ + -radius "20" \ + -element_is_var \ + -enclose ] \ No newline at end of file Index: openacs-4/packages/ajaxhelper/www/tests/test_yahootreeview.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/tests/test_yahootreeview.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/tests/test_yahootreeview.adp 6 Nov 2006 13:15:30 -0000 1.1 @@ -0,0 +1,9 @@ + + TEST : Yahoo Tree View + + + + +
+ +@js_script;noquote@ \ No newline at end of file Index: openacs-4/packages/ajaxhelper/www/tests/test_yahootreeview.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/tests/test_yahootreeview.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajaxhelper/www/tests/test_yahootreeview.tcl 6 Nov 2006 13:15:30 -0000 1.1 @@ -0,0 +1,12 @@ +# create the nodes for our tree +set nodes [list] +lappend nodes [list "fld1" "Folder 1" "tree" "" ""] +lappend nodes [list "fld11" "Folder 1.1" "tree" "" "fld1"] +lappend nodes [list "fld12" "Folder 1.2" "tree" "" "fld1"] +lappend nodes [list "fld2" "Folder 2" "tree" "javascript:alert('this is a tree node')" ""] + +set js_script [ah::yui::create_tree -element "folders" \ + -nodes $nodes \ + -varname "tree" ] + +set js_script [ah::enclose_in_script -script $js_script] \ No newline at end of file