From d18d91946627c53c646a6f167855551a1891f8f4 Mon Sep 17 00:00:00 2001 From: Armen Kesablyan Date: Wed, 7 Mar 2012 14:33:09 -0800 Subject: Reordering and resizing now works Signed-off-by: Armen Kesablyan --- js/panels/PanelContainer.reel/PanelContainer.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/js/panels/PanelContainer.reel/PanelContainer.js b/js/panels/PanelContainer.reel/PanelContainer.js index 3da9b44c..b285b49d 100755 --- a/js/panels/PanelContainer.reel/PanelContainer.js +++ b/js/panels/PanelContainer.reel/PanelContainer.js @@ -47,6 +47,7 @@ exports.PanelContainer = Montage.create(Component, { this['panel_'+i].flexible = p.flexible; this['panel_'+i].modulePath = p.modulePath; this['panel_'+i].moduleName = p.moduleName; + this['panel_'+i].index = i; this.currentPanelState[p.name] = {}; this.currentPanelState.version = "1.0"; @@ -102,8 +103,21 @@ exports.PanelContainer = Montage.create(Component, { if(draggedIndex !== droppedIndex) { // switch panels - this.panels[droppedIndex].element.parentNode.insertBefore(this.panels[draggedIndex].element, this.panels[droppedIndex].element); + if (droppedIndex === draggedIndex +1) { + if(this.panels[droppedIndex].element.nextSibling) { + this.panels[droppedIndex].element.parentNode.insertBefore(this.panels[draggedIndex].element, this.panels[droppedIndex].element.nextSibling); + } else { + return this.appendChild(this.panels[draggedIndex].element); + } + } else { + + this.panels[droppedIndex].element.parentNode.insertBefore(this.panels[draggedIndex].element, this.panels[droppedIndex].element); + } + var panelRemoved = this.panels.splice(draggedIndex, 1); + this.panels.splice(droppedIndex, 0, panelRemoved[0]); + } + } }, @@ -112,12 +126,12 @@ exports.PanelContainer = Montage.create(Component, { var len = this.panels.length, setLocked = true; for(var i = 0; i < len; i++) { - if(this['panel_'+i] === panelActivated || panelActivated === null) { + if(this.panels[i] === panelActivated || panelActivated === null) { setLocked = false; } - this['panel_'+i].locked = setLocked; - this['panel_'+i].needsDraw = true; + this.panels[i].locked = setLocked; + this.panels[i].needsDraw = true; } } }, -- cgit v1.2.3