Index: openacs-4/packages/xowiki/tcl/folder-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/folder-procs.tcl,v diff -u -N -r1.27.2.6 -r1.27.2.7 --- openacs-4/packages/xowiki/tcl/folder-procs.tcl 15 Apr 2014 06:47:00 -0000 1.27.2.6 +++ openacs-4/packages/xowiki/tcl/folder-procs.tcl 15 Apr 2014 07:05:37 -0000 1.27.2.7 @@ -630,315 +630,7 @@ } } -##################### -# # -# YUI stuff # -# # -##################### -namespace eval ::YUI { - - Object loader -ad_doc { - The YUI Library comes with a "Loader" module, that resolves YUI-module - dependencies. Also, it combines numerous files into one single file to - increase page loading performance. - This works only for the "hosted" YUI library. This Loader module should - basically do the same (in future). For two simple calls like e.g. - "::YUI::loader require menu" and "::YUI::loader require datatable" - it should take care of selecting all the files needed and assemble them - into one single resource, that may be delivered. - Note, that this is not implemented yet. - } - - loader set ajaxhelper 1 - - # TODO: Make "::YUI::loader require -module XYZ" work everywhere "out-of-the-box" - # Now, as we use "::xo:Page require_JS" we have to include the generated - # header_stuff "manually" (e.g. in tcl-adp pairs), whereas ::template::head... - # includes it directly, which is nice. - - loader ad_proc require { - -module - {-version "2.7.0b"} - } { - This is the key function of the loader, that will be used by other packages. - @param module - The YUI Module to be loaded - } { - my instvar ajaxhelper - switch -- [string tolower $module] { - - utilities { - # utilities.js: The utilities.js aggregate combines the Yahoo Global Object, - # Dom Collection, Event Utility, Element Utility, Connection Manager, - # Drag & Drop Utility, Animation Utility, YUI Loader and the Get Utility. - # Use this file to reduce HTTP requests whenever you are including more - # than three of its constituent components. - ::xowiki::Includelet require_YUI_JS -ajaxhelper $ajaxhelper "yahoo-dom-event/yahoo-dom-event.js" - ::xowiki::Includelet require_YUI_JS -ajaxhelper $ajaxhelper "utilities/utilities.js" - } - menubar { - # - # We should not have two different versions of the YUI - # library on one page, because YUI2 (afaik) doesnt support - # "sandboxing". If we use e.g. the yui-hosted utilities.js file here - # we may end up with two YAHOO object definitions, because e.g. - # the tree-procs uses the local yahoo-dom-event. - - # In future, the YUI loader object should be capable of - # resolving such conflicts. for now, the simple fix is to stick to - # the local versions, because then the requireJS function takes care - # of duplicates. - # - my require -module "utilities" - # todo : this is more than necessary - foreach jsFile { - "container/container-min.js" - "treeview/treeview-min.js" - "button/button-min.js" - "menu/menu-min.js" - "datasource/datasource-min.js" - "autocomplete/autocomplete-min.js" - "datatable/datatable-min.js" - "selector/selector-min.js" - } { - ::xowiki::Includelet require_YUI_JS -ajaxhelper $ajaxhelper $jsFile - } - - my require -module "reset-fonts-grids" - my require -module "base" - - foreach cssFile { - "container/assets/container.css" - "datatable/assets/skins/sam/datatable.css" - "button/assets/skins/sam/button.css" - "assets/skins/sam/skin.css" - "menu/assets/skins/sam/menu.css" - } { - ::xowiki::Includelet require_YUI_CSS -ajaxhelper $ajaxhelper $cssFile - } - ::xowiki::Includelet require_YUI_CSS -ajaxhelper 1 "treeview/assets/folders/tree.css" - } - datatable { - # see comment above - my require -module "utilities" - # todo : this is more than necessary - foreach jsFile { - "container/container-min.js" - "treeview/treeview-min.js" - "button/button-min.js" - "menu/menu-min.js" - "datasource/datasource-min.js" - "autocomplete/autocomplete-min.js" - "datatable/datatable-min.js" - "selector/selector-min.js" - } { - ::xowiki::Includelet require_YUI_JS -version "2.7.0b" -ajaxhelper $ajaxhelper $jsFile - } - - my require -module "reset-fonts-grids" - my require -module "base" - - foreach cssFile { - "container/assets/container.css" - "datatable/assets/skins/sam/datatable.css" - "button/assets/skins/sam/button.css" - "assets/skins/sam/skin.css" - "menu/assets/skins/sam/menu.css" - } { - ::xowiki::Includelet require_YUI_CSS -ajaxhelper $ajaxhelper $cssFile - } - #::xowiki::Includelet require_YUI_CSS -ajaxhelper 1 "treeview/assets/skins/sam/treeview.css" - #::xowiki::Includelet require_YUI_CSS -ajaxhelper 1 "treeview/assets/folders/tree.css" - } - reset { - ::xowiki::Includelet require_YUI_CSS -ajaxhelper $ajaxhelper "reset/reset.css" - } - fonts { - ::xowiki::Includelet require_YUI_CSS -ajaxhelper $ajaxhelper "fonts/fonts.css" - } - grids { - ::xowiki::Includelet require_YUI_CSS -ajaxhelper $ajaxhelper "grids/grids.css" - } - base { - ::xowiki::Includelet require_YUI_CSS -ajaxhelper $ajaxhelper "base/base.css" - } - "reset-fonts-grids" { - ::xowiki::Includelet require_YUI_CSS -ajaxhelper $ajaxhelper "reset-fonts-grids/reset-fonts-grids.css" - } - } - } - - Class ::xowiki::YUIDataTable \ - -superclass ::xo::Table \ - -parameter { - {skin "yui-skin-sam"} - } - - ::xowiki::YUIDataTable instproc init {} { - set trn_mixin [expr {[lang::util::translator_mode_p] ?"::xo::TRN-Mode" : ""}] - my render_with YUIDataTableRenderer $trn_mixin - next - } - - Class AnchorField \ - -superclass ::xo::Table::AnchorField \ - -ad_doc " - In addition to the standard TableWidget's AnchorField, we also allow the attributes - - " \ - -instproc get-slots {} { - set slots [list -[my name]] - foreach subfield {href title CSSclass target onclick} { - lappend slots [list -[my name].$subfield ""] - } - return $slots - } -} - -# TODO Allow renderers from other namespaces in 30-widget-procs - -namespace eval ::xo::Table { - - Class create YUIDataTableRenderer \ - -superclass TABLE3 \ - -instproc init_renderer {} { - next - my set css.table-class list-table - my set css.tr.even-class even - my set css.tr.odd-class odd - my set id [::xowiki::Includelet js_name [::xowiki::Includelet html_id [self]]] - } - - YUIDataTableRenderer ad_instproc -private render_yui_js {} { - Generates the JavaScript fragment, that is put below and - (progressively enhances) the HTML table. - } { - my instvar id - set container ${id}_container - set datasource ${id}_datasource - set datatable ${id}_datatable - set coldef ${id}_coldef - - set js "var $datasource = new YAHOO.util.DataSource(YAHOO.util.Dom.get('$id')); \n" - append js "$datasource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE; \n" - append js "$datasource.responseSchema = \{ \n" - append js " fields: \[ \n" - set js_fields [list] - foreach field [[self]::__columns children] { - if {[$field hide]} continue - lappend js_fields " \{ key: \"[$field set name]\" \}" - } - append js [join $js_fields ", "] " \] \n\};\n" - append js "var $coldef = \[\n" - set js_fields [list] - foreach field [[self]::__columns children] { - if {[$field hide]} continue - if {[$field istype HiddenField]} continue - if {[$field istype BulkAction]} { - set label "" - set sortable false - } else { - set label [$field label] - set sortable [expr {[$field exists sortable] ? [$field set sortable] : true}] - } - lappend js_fields " \{ key: \"[$field set name]\" , sortable: $sortable, label: \"$label\" \}" - } - append js [join $js_fields ", "] "\];\n" - append js "var $datatable = new YAHOO.widget.DataTable('$container', $coldef, $datasource);\n" - return $js - } - - YUIDataTableRenderer instproc render-body {} { - html::thead { - html::tr -class list-header { - foreach o [[self]::__columns children] { - if {[$o hide]} continue - $o render - } - } - } - set children [my children] - html::tbody { - foreach line [my children] { - html::tr -class [expr {[my incr __rowcount]%2 ? [my set css.tr.odd-class] : [my set css.tr.even-class] }] { - foreach field [[self]::__columns children] { - if {[$field hide]} continue - html::td [concat [list class list] [$field html]] { - $field render-data $line - } - } - } - } - } - } - - YUIDataTableRenderer instproc render {} { - ::YUI::loader require -module "datatable" - if {![my isobject [self]::__actions]} {my actions {}} - if {![my isobject [self]::__bulkactions]} {my __bulkactions {}} - set bulkactions [[self]::__bulkactions children] - if {[llength $bulkactions]>0} { - set name [[self]::__bulkactions set __identifier] - } else { - set name [::xowiki::Includelet js_name [self]] - } - # TODO: maybe use skin everywhere? hen to use style/CSSclass or skin? - set skin [expr {[my exists skin] ? [my set skin] : ""}] - html::div -id [my set id]_wrapper -class $skin { - html::form -name $name -id $name -method POST { - html::div -id [my set id]_container { - html::table -id [my set id] -class [my set css.table-class] { - # TODO do i need that? - my render-actions - my render-body - } - if {[llength $bulkactions]>0} { my render-bulkactions } - } - } - ::xo::Page requireJS "YAHOO.util.Event.onDOMReady(function () {\n[my render_yui_js]});" - } - } - - - #Class create YUIDataTableRenderer::AnchorField -superclass TABLE::AnchorField - - Class create YUIDataTableRenderer::AnchorField \ - -superclass TABLE::Field \ - -ad_doc " - In addition to the standard TableWidget's AnchorField, we also allow the attributes - - " \ - -instproc render-data {line} { - set __name [my name] - if {[$line exists $__name.href] && - [set href [$line set $__name.href]] ne ""} { - # use the CSS class rather from the Field than not the line - my instvar CSSclass - $line instvar [list $__name.title title] \ - [list $__name.target target] \ - [list $__name.onclick onclick] - html::a [my get_local_attributes href title {CSSclass class} target onclick] { - return "[next]" - } - } - next - } - - Class create YUIDataTableRenderer::Action -superclass TABLE::Action - Class create YUIDataTableRenderer::Field -superclass TABLE::Field - Class create YUIDataTableRenderer::HiddenField -superclass TABLE::HiddenField - Class create YUIDataTableRenderer::ImageField -superclass TABLE::ImageField - Class create YUIDataTableRenderer::ImageAnchorField -superclass TABLE::ImageAnchorField - Class create YUIDataTableRenderer::BulkAction -superclass TABLE::BulkAction -} - ::xo::library source_dependent #