From 5736fdf4d17339c62b77948eff00a5f16422b9f3 Mon Sep 17 00:00:00 2001 From: Scott Walters Date: Thu, 12 Sep 2013 13:32:29 -0500 Subject: [PATCH] when flipping between Tree and View tabs with edit on, clear out the containers for the toolbars before re-adding the toolbars -- this time in YUI -- and this time doing the same for the drag and drop bar --- www/extras/admin/layout.js | 14 ++++++++++++++ www/extras/admin/toolbar.js | 9 +++++++++ 2 files changed, 23 insertions(+) diff --git a/www/extras/admin/layout.js b/www/extras/admin/layout.js index e1b0b106c..0755150be 100644 --- a/www/extras/admin/layout.js +++ b/www/extras/admin/layout.js @@ -39,6 +39,20 @@ WebGUI.Layout = function (elem, cfg) { for ( var x = 0; x < children.length; x++ ) { var elem = children[x]; if ( elem.id.match(/wg-content-asset-(.{22})/) ) { + + // when flipping between Tree and View tabs with edit on, clear out the containers for the drag controls before re-adding them + var elem_yui = new YAHOO.util.Element( elem ); + var child = YAHOO.util.Dom.getFirstChild( elem ); + while( child ) { + var child_yui = new YAHOO.util.Element( child ); + if( child_yui.hasClass('draggable') ) { + elem_yui.removeChild( child ); + // console.log("removing in drag and drop control: " + child + " from " + elem_yui); + } + // nested assets are also children in here, with ids like "wg-content-asset-xxxxxxxxxxx"; leave those alone + child = YAHOO.util.Dom.getNextSibling( child ); + } + new WebGUI.LayoutItem( elem, null, null, this ); } } diff --git a/www/extras/admin/toolbar.js b/www/extras/admin/toolbar.js index 72421a7e6..fc3ee9ffe 100644 --- a/www/extras/admin/toolbar.js +++ b/www/extras/admin/toolbar.js @@ -32,6 +32,15 @@ WebGUI.Toolbar.createAll = function( ) { var holders = YAHOO.util.Selector.query( '.wg-admin-toolbar' ); for ( var i = 0; i < holders.length; i++ ) { var holder = holders[i]; + + // when flipping between Tree and View tabs with edit on, clear out the containers for the toolbars before re-adding the toolbars + var holder_yui = new YAHOO.util.Element( holder ); + var child; + while( child = YAHOO.util.Dom.getFirstChild( holder ) ) { + holder_yui.removeChild( child ); + // console.log("removing: " + child + " from " + holder_yui); + } + var assetId = holder.id.match( /wg-admin-toolbar-(.+)/ )[1]; var toolbar = new WebGUI.Toolbar( assetId, { "parent" : holder } ); toolbar.getAssetData( assetId, bind( toolbar, toolbar.render ) );