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

This commit is contained in:
Scott Walters 2013-09-12 13:32:29 -05:00
parent 9d047a788d
commit 5736fdf4d1
2 changed files with 23 additions and 0 deletions

View file

@ -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 );
}
}

View file

@ -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 ) );