Index: openacs-4/packages/xowiki/tcl/tree-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/tree-procs.tcl,v diff -u -r1.23.2.2 -r1.23.2.3 --- openacs-4/packages/xowiki/tcl/tree-procs.tcl 13 May 2019 07:17:17 -0000 1.23.2.2 +++ openacs-4/packages/xowiki/tcl/tree-procs.tcl 13 May 2019 07:18:01 -0000 1.23.2.3 @@ -17,12 +17,12 @@ -superclass ::xo::OrderedComposite \ -parameter { {name ""} - {owner} + {owner} {verbose 0} id } - # + # # Class methods # Tree proc renderer {style} { @@ -51,11 +51,11 @@ -category -orderby -itemobj - {-increasing:boolean true} + {-increasing:boolean true} {-open_item:boolean false} } { set items ${category}::items - if {![:isobject $items]} { + if {![:isobject $items]} { ::xo::OrderedComposite create $items if {[info exists orderby]} { if {$orderby eq "page_order"} { @@ -86,10 +86,10 @@ } Tree instproc add_pages { - {-full false} - {-remove_levels 0} - {-book_mode false} - {-open_page ""} + {-full false} + {-remove_levels 0} + {-book_mode false} + {-open_page ""} {-expand_all false} -owner pages @@ -126,7 +126,7 @@ } # - # ::xowiki::TreeNode + # ::xowiki::TreeNode # # The TreeNode represents an n-ary node storing its child nodes in # an ordered composite. In addition to its children, every node may @@ -138,7 +138,7 @@ level label pos {open_requests 0} count - {href ""} + {href ""} object owner li_id ul_id ul_class {prefix ""} {expanded false} @@ -183,7 +183,7 @@ # The rendering of trees is performed via rendering classes. All # renderers are created and configured via the meta-class # TreeRenderer. This meta-class defines the common attributes and - # behavior of all TreeRenders. + # behavior of all TreeRenders. # # In particular, the TreeRenders are defined to work with xowiki's # page fragment caching. Via page fragment caching, the result of @@ -217,7 +217,7 @@ # - render {tree} # # (both are optional) and the following methods as instprocs - # + # # - render_node {{-open:boolean false} cat_content} # - render_item {{-highlight:boolean false} item} # @@ -227,13 +227,13 @@ #-------------------------------------------------------------------------------- # List-specific renderer - # + # # This is a very common render that maps the tree structure into an # unordered HTML list. The rendered is specialized by e.g. the # mktree an yuitree render below. - #-------------------------------------------------------------------------------- + #-------------------------------------------------------------------------------- - TreeRenderer create TreeRenderer=list + TreeRenderer create TreeRenderer=list TreeRenderer=list proc include_head_entries {args} { # In the general case, we have nothing to include. More # specialized renders will provide their head entries. @@ -265,7 +265,7 @@ if {[info exists :li_id]} {append o_atts " id='${:li_id}'"} if {[info exists :li_atts]} {append o_atts " ${:li_atts}"} if {[info exists :ul_id]} {append u_atts " id='${:ul_id}'"} - if {[info exists :ul_atts]} {append u_atts " ${:ul_atts}"} + if {[info exists :ul_atts]} {append u_atts " ${:ul_atts}"} if {[info exists :ul_class]} {append u_atts " class='${:ul_class}'"} set label [::xowiki::Includelet html_encode [:label]] @@ -288,7 +288,7 @@ } return "
  • ${:prefix} $entry$content
  • " } - + #-------------------------------------------------------------------------------- # List-specific renderer based on mktree #-------------------------------------------------------------------------------- @@ -307,7 +307,7 @@ #-------------------------------------------------------------------------------- # List-specific renderer based for some menus - #-------------------------------------------------------------------------------- + #-------------------------------------------------------------------------------- TreeRenderer create TreeRenderer=samplemenu \ -superclass TreeRenderer=list \ -li_expanded_atts [list "class='menu-open'" "class='menu-closed'"] \ @@ -367,7 +367,7 @@ } return "
  • $entry $content" } - + TreeRenderer=bootstrap3horizontal proc render {tree} { set name [$tree name] if {$name ne ""} { @@ -379,19 +379,19 @@ } else { set navbarLabel "" } - + return [subst { }] } - - + + #-------------------------------------------------------------------------------- # List-specific renderer based on yuitree #-------------------------------------------------------------------------------- @@ -425,7 +425,7 @@ #-------------------------------------------------------------------------------- # list-specific render with drag and drop functionality - #-------------------------------------------------------------------------------- + #-------------------------------------------------------------------------------- TreeRenderer create TreeRenderer=listdnd \ -superclass TreeRenderer=list \ -li_expanded_atts [list "" ""] @@ -485,10 +485,10 @@ set :li_id [::xowiki::Includelet js_name [${:owner} set id]_$page_order] set :ul_id [::xowiki::Includelet js_name [${:owner} set id]__l${:level}_$page_order] - + set min_level [[self class] min_level] set reorder_child [expr {$min_level ne "" && ${:level} >= $min_level}] - set reorder_self [expr {$min_level ne "" && ${:level} > $min_level}] + set reorder_self [expr {$min_level ne "" && ${:level} > $min_level}] :log "=== render_node $page_order min_level $min_level level ${:level} reorder_child $reorder_child reorder_self $reorder_self" if {$reorder_child} { @@ -512,7 +512,7 @@ # Tree renderer based on a section structure #-------------------------------------------------------------------------------- TreeRenderer create TreeRenderer=sections \ - -superclass TreeRenderer=list + -superclass TreeRenderer=list TreeRenderer=sections instproc render_item {{-highlight:boolean false} item} { $item instvar title href set prefix [$item set prefix] @@ -537,7 +537,7 @@ #-------------------------------------------------------------------------------- # Bootstrap tree renderer based on # http://jonmiles.github.io/bootstrap-treeview/ - #-------------------------------------------------------------------------------- + #-------------------------------------------------------------------------------- TreeRenderer create TreeRenderer=bootstrap3 TreeRenderer=bootstrap3 proc include_head_entries {args} { @@ -598,7 +598,7 @@ #-------------------------------------------------------------------------------- # Bootstrap3 tree renderer with folder structure - #-------------------------------------------------------------------------------- + #-------------------------------------------------------------------------------- TreeRenderer create TreeRenderer=bootstrap3-folders -superclass TreeRenderer=bootstrap3 TreeRenderer=bootstrap3-folders proc render {tree} { set jsTree [string trimright [next] ", \n"] @@ -612,9 +612,9 @@ return "
    " } - + } -::xo::library source_dependent +::xo::library source_dependent # # Local variables: Index: openacs-4/packages/xowiki/www/resources/listdnd.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/www/resources/listdnd.js,v diff -u -r1.1.2.2 -r1.1.2.3 --- openacs-4/packages/xowiki/www/resources/listdnd.js 13 May 2019 07:19:59 -0000 1.1.2.2 +++ openacs-4/packages/xowiki/www/resources/listdnd.js 13 May 2019 07:23:23 -0000 1.1.2.3 @@ -13,10 +13,10 @@ * of the items in a "toc" is determiend by the "page_order" attribute * in the database, it reports the changed lists of page_orders back. * - * The implementation uses the following data attributes: + * The implementation uses the following data attributes: * -
  • data-value (containing page_order) * -
    data-folder_id data-package_url (for reporting to the backend) - * + * * Gustaf Neumann fecit May 2019 */ @@ -40,10 +40,10 @@ var result = []; for (var j = 0; j < items.length; j++) { - var page_order = items[j].dataset.value; - if (page_order != '') { - result.push(page_order); - } + var page_order = items[j].dataset.value; + if (page_order != '') { + result.push(page_order); + } } return result; } @@ -66,15 +66,15 @@ //console.log("listdnd_dragover on " + target.id + " value " + value + " source " + sourceElement); if (typeof value !== 'undefined' && sourceElement !== null) { - var bounding = target.getBoundingClientRect() - var offset = bounding.y + (bounding.height/2); - if ( event.clientY - offset > 0 ) { - target.classList.add('mark-below') - target.classList.remove('mark-above') - } else { - target.classList.add('mark-above') - target.classList.remove('mark-below') - } + var bounding = target.getBoundingClientRect() + var offset = bounding.y + (bounding.height/2); + if ( event.clientY - offset > 0 ) { + target.classList.add('mark-below') + target.classList.remove('mark-above') + } else { + target.classList.add('mark-above') + target.classList.remove('mark-below') + } } } @@ -100,62 +100,69 @@ var value = target.dataset.value; if (typeof value !== 'undefined' && sourceElement !== null) { - - // Used variables: - // - dropul: The target ul, which should be updated with - // the dropped item. - // - div: The outer did, needed for obtaining "folder_id" - // and "package_url". - // - before: collection of "page_orders" before drop. - // - after: collection of "page_orders" after drop. - // - var dropul = target.parentNode; - var div = listdnd_get_parent( target.parentNode, 'DIV'); - var before = listdnd_page_orders(dropul); - - if ( target.classList.contains('mark-above') ) { - target.classList.remove('mark-above') - target.parentNode.insertBefore(sourceElement, target); - } else { - target.classList.remove('mark-below') - target.parentNode.insertBefore(sourceElement, target.nextSibling); - } - - var after = listdnd_page_orders(dropul); - var diff = after.filter(x => !before.includes(x) ); - - //console.log('drop before <' + before + '> after <' + after + '> diff <' + diff + '>'); - - var data = 'change-page-order=1' + + + // Used variables: + // - dropul: The target ul, which should be updated with + // the dropped item. + // - div: The outer did, needed for obtaining "folder_id" + // and "package_url". + // - before: collection of "page_orders" before drop. + // - after: collection of "page_orders" after drop. + // + var dropul = target.parentNode; + var div = listdnd_get_parent( target.parentNode, 'DIV'); + var before = listdnd_page_orders(dropul); + + if ( target.classList.contains('mark-above') ) { + target.classList.remove('mark-above') + target.parentNode.insertBefore(sourceElement, target); + } else { + target.classList.remove('mark-below') + target.parentNode.insertBefore(sourceElement, target.nextSibling); + } + + var after = listdnd_page_orders(dropul); + var diff = after.filter(x => !before.includes(x) ); + + //console.log('drop before <' + before + '> after <' + after + '> diff <' + diff + '>'); + + var data = 'change-page-order=1' + '&from=' + escape(before.join(' ')) + '&to=' + escape(after.join(' ')) + - '&clean=' + escape(diff.join(' ')) + - '&folder_id=' + escape(div.dataset.folder_id) + - ''; + '&clean=' + escape(diff.join(' ')) + + '&folder_id=' + escape(div.dataset.folder_id) + + ''; - //console.log('package_url <' + div.dataset.package_url + '>'); - if (1) { - var request = new XMLHttpRequest(); - request.onload = function(e) { - // There seems no good way to handle redirects (301 or - // 302) in XHR. Since we know valid results (just the - // "OK"), everything else must have been a - // redirect. We could be brutal and display the - // returned page, but not sure, if this would be - // desirable either. - if (this.getResponseHeader["Content-Length"] > 10) { - // there must have happened a redirect - alert("Refresh your login and redo update"); - window.location.href = div.dataset.package_url - + "?refresh-login&return_url=" - + escape(window.location.href); - } else { - window.location.reload(); - } - }; - request.open('POST', div.dataset.package_url, true); - request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); - request.send(data); - } + //console.log('package_url <' + div.dataset.package_url + '>'); + if (1) { + var request = new XMLHttpRequest(); + request.onload = function(e) { + // There seems no good way to handle redirects (301 or + // 302) in XHR. Since we know valid results (just the + // "OK"), everything else must have been a + // redirect. We could be brutal and display the + // returned page, but not sure, if this would be + // desirable either. + if (this.getResponseHeader["Content-Length"] > 10) { + // there must have happened a redirect + alert("Refresh your login and redo update"); + window.location.href = div.dataset.package_url + + "?refresh-login&return_url=" + + escape(window.location.href); + } else { + window.location.reload(); + } + }; + request.open('POST', div.dataset.package_url, true); + request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); + request.send(data); + } } } + +/* + * Local variables: + * mode: Javascript + * indent-tabs-mode: nil + * End: + */