Index: openacs-4/packages/xowiki/tcl/menu-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/menu-procs.tcl,v diff -u -r1.7.2.3 -r1.7.2.4 --- openacs-4/packages/xowiki/tcl/menu-procs.tcl 15 Apr 2014 06:47:00 -0000 1.7.2.3 +++ openacs-4/packages/xowiki/tcl/menu-procs.tcl 15 Apr 2014 07:05:38 -0000 1.7.2.4 @@ -91,231 +91,7 @@ } - ::xo::tdom::Class YUIMenuItemList \ - -superclass Menu \ - -parameter { - header - } - - YUIMenuItemList ad_instproc render {} {} { - if {[my exists header]} { - html::h6 { - html::t [my header] - } - } - next - } - - ################################################### # - # YUIMenu - # - ::xo::tdom::Class create YUIMenu \ - -superclass Menu \ - -parameter { - header - footer - shadow - {autorender false} - {configuration {{}}} - } - - YUIMenu instproc init {} { - ::xowiki::Includelet require_YUI_CSS -ajaxhelper 1 "menu/assets/skins/sam/menu.css" - ::xowiki::Includelet require_YUI_JS -ajaxhelper 1 "yahoo-dom-event/yahoo-dom-event.js" - ::xowiki::Includelet require_YUI_JS -ajaxhelper 1 "container/container_core-min.js" - ::xowiki::Includelet require_YUI_JS -ajaxhelper 1 "menu/menu-min.js" - next - } - - YUIMenu instproc split_menu_groups {list} { - # - # split the list of entries into groups, which will be separated - # with lines in the rendering - # - set result [list] - if {[llength $list] < 1} {return $result} - set group_name [[lindex $list 0] group] - set group_list [list] - foreach e $list { - set gn [$e group] - if {$gn ne $group_name} { - lappend result $group_list - set group_name $gn - set group_list [list] - } - lappend group_list $e - } - lappend result $group_list - return $result - } - - YUIMenu ad_instproc render {} { - http://developer.yahoo.com/yui/menu/ - } { - my append CSSclass " yuimenu" - - # I want the menu to show up when JS is disabled - # This gets overridden by JS, so its only relevant for the non-JS version - #my set style "visibility: visible; position: relative;" - - html::div [my get_attributes {CSSclass class} id style] { - # Header - html::t \n - if {[my exists header]} { - html::div -class "hd" { - html::t [my header] - } - } - # Body - html::t \n - html::div -class "bd" { - foreach group [my split_menu_groups [my children]] { - html::ul { - foreach menuitemlist $group {$menuitemlist render} - } - } - } - # Footer - if {[my exists footer]} { - html::div -class "ft" { - html::t [my footer] - } - } - # Shadow - if {[my exists shadow]} { - html::div -class "yui-menu-shadow" {} - } - # JavaScript - # only "root-level" menus need JS - # TODO: is this parent-check sufficient / future-safe? - if {![my exists __parent]} { - html::script -type "text/javascript" { - html::t "var [my js_name] = new YAHOO.widget.Menu(\"[my id]\", [my set configuration]);" - html::t " - [my js_name].render(); - [my js_name].show(); - " - } - } - } - } - - # - # YUIMenuItem - # - ::xo::tdom::Class create YUIMenuItem \ - -superclass MenuItem \ - -parameter { - {href "#"} - helptext - } - - YUIMenuItem ad_instproc render {} {doku} { - html::li [my get_attributes id {CSSclass class} style] { - # if we have no href, mark entry as disabled - if {![my exists href] || [my href] eq ""} {my append linkclass " disabled"} - html::a [my get_attributes target href {linkclass class} title] { - html::t [my text] - if {[my exists helptext]} { - html::em { - html::t [my helptext] - } - } - } - foreach menu [my children] {$menu render} - } - html::t \n - } - - - # - # YUIMenuBar - # - ::xo::tdom::Class create YUIMenuBar \ - -superclass YUIMenu \ - -parameter { - {navbar true} - } - - YUIMenuBar ad_instproc render {} { - http://developer.yahoo.com/yui/menu/#menubar - MenuBar looks best without a header and with one MenuItemList only - } { - my append CSSclass " yuimenubar" - if {[my navbar]} {my append CSSclass " yuimenubarnav"} - html::div [my get_attributes id {CSSclass class}] { - html::div -class "bd" { - html::t \n - html::ul -class "first-of-type" { - foreach li [my children] {$li render} - } - html::t \n - } - html::t \n - ::xo::Page set_property body class "yui-skin-sam" - ::xo::Page requireJS "YAHOO.util.Event.onDOMReady(function () { - var [my js_name] = new YAHOO.widget.MenuBar('[my id]', [my set configuration]); - [my js_name].render(); - });" - } - } - - # - # YUIMenuBarItem - # - ::xo::tdom::Class create YUIMenuBarItem \ - -superclass YUIMenuItem - - YUIMenuBarItem ad_instproc init {} {} { - #goto YUIMenuItem and set all those nice defaults - next - my append CSSclass " first-of-type" - if {![my exists href]} { - # If not set to #, the title of the menubaritems wont expand the submenu (only the arrow) - my set href "#" - } - } - - - # - # YUIContextMenu - # - - # TODO: Support for Multiple Element IDs/Refs as Trigger - - ::xo::tdom::Class YUIContextMenu \ - -superclass YUIMenu \ - -parameter { - {trigger "document"} - {triggertype "reference"} - } - - YUIContextMenu ad_instproc render {} { - http://developer.yahoo.com/yui/menu/#contextmenu - } { - my append CSSclass " yuimenu" - html::div [my get_attributes id {CSSclass class}] { - html::div -class "bd" { - html::ul { - foreach li [my children] {$li render} - } - } - html::script -type "text/javascript" { - html::t "var [my js_name] = new YAHOO.widget.ContextMenu('[my id]', { trigger: '[my set trigger]' } );" - html::t "[my js_name].render(document.body);" - } - } - } - - # - # YUIContextMenuItem - # - ::xo::tdom::Class YUIContextMenuItem \ - -superclass YUIMenuItem - - - # # Simple Generic MenuBar # # Class for creating and updating Menubars in an incremental @@ -511,45 +287,15 @@ } ::xowiki::MenuBar instproc render-preferred {} { - switch [$context_package_id get_parameter "PreferredCSSToolkit" yui] { + switch [[xo::cc package_id] get_parameter "PreferredCSSToolkit" yui] { bootstrap {set menuBarRenderer render-bootstrap} default {set menuBarRenderer render-yui} } my $menuBarRenderer } - ::xowiki::MenuBar instproc render-yui {} { - set M [my content] - set mb [::xowiki::YUIMenuBar -id [my get_prop $M id] -configuration { - {autosubmenudisplay: false, keepopen: true, lazyload: false} - } { - foreach {menu_att menu} $M { - if {$menu_att eq "id"} continue - if {[llength $menu_att] > 1} { - # We expect a dict as second list element.. but ignore here for the time being - lassign $menu_att menu_att props - } - ::xowiki::YUIMenuBarItem -text [my get_prop $menu text] { - ::xowiki::YUIMenu { - foreach {item_att item} $menu { - if {[string match {[a-z]*} $item_att]} continue - set text [my get_prop $item text] - set url [my get_prop $item url] - set group [my get_prop $item group] - #my msg "ia=$item_att group '$group' // t=$text item=$item" - ::xowiki::YUIMenuItem -text $text -href $url -group $group {} - } - } - } - } - }] - return [$mb asHTML] - } namespace export Menu - namespace export YUIMenuBar YUIMenuBarItem - namespace export YUIMenu YUIMenuItem YUIMenuItemList - namespace export YUIContextMenu YUIContextMenuItem # end of namespace } ::xo::library source_dependent