From d2d2017d118ab176c6ec44f98f5ff6f16781429f Mon Sep 17 00:00:00 2001 From: David Underhill Date: Sat, 6 Dec 2008 11:11:28 -0800 Subject: [PATCH] parent toolbars do not need to know all their possible children: removed that code --- jtoolbar.js | 68 ++++++++++------------------------------------------- 1 file changed, 12 insertions(+), 56 deletions(-) diff --git a/jtoolbar.js b/jtoolbar.js index d3086c8..be18b0b 100644 --- a/jtoolbar.js +++ b/jtoolbar.js @@ -358,7 +358,6 @@ var JTB = function() { /* toolbar hierarchy support */ this.tb_parent = null; - this.tb_children = []; this.vis_tb_child = null; /* sizing information helpers */ @@ -684,11 +683,13 @@ var JTB = function() { /** shows a child toolbar (makes childToolbar a child if it isn't already one) */ JTB.Toolbar.prototype.showChildToolbar = function(childToolbar, x, y) { - /* make sure childToolbar is one of our children */ - if(!this.hasChildToolbar(childToolbar)) { - this.addChildToolbar(childToolbar); - } + /* remove the child from any old parent */ + childToolbar.removeFromParentToolbar(childToolbar); + + /* tell the child toolbar it belongs to us now */ + childToolbar.tb_parent = this; + /* show the child */ this.vis_tb_child = childToolbar; this.refreshGfx(); @@ -700,60 +701,15 @@ var JTB = function() { return this.e_content === null; }; - /** adds a child toolbar to this toolbar */ - JTB.Toolbar.prototype.addChildToolbar = function(childToolbar) { - /* remove the child from any old parent */ - if(childToolbar.tb_parent !== null) { - childToolbar.tb_parent.removeChildToolbar(childToolbar); - } - - /* add the child toolbar to our list of toolbars */ - this.tb_children[this.tb_children.length] = childToolbar; - childToolbar.tb_parent = this; - return this; - }; - - /** gets whether e is a child toolbar of this toolbar */ - JTB.Toolbar.prototype.hasChildToolbar = function(e) { - return this.indexOfChildToolbar(e) != -1; - }; - - /** returns non-negative index if e is a child toolbar of this toolbar */ - JTB.Toolbar.prototype.indexOfChildToolbar = function(e) { - var i; - for(i=0; i= 0) { - var container = this.getContainer(); - if(container !== null) { - container.removeChild(e); - } - - if(this.vis_tb_child == e) { - this.vis_tb_child = null; - } - e.tb_parent = null; - - var j; - for(j=i; j