From 806974142d44afdd23534bf2d18eff0a8e701e0c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 8 Jun 2012 16:59:59 -0700 Subject: rewrite: currentSelectedContainer -> domContainer Fixed the currentSelectedContainer by removing bindings and using property change on the current document added the red outline back. Signed-off-by: Valerio Virgillito --- js/controllers/elements/element-controller.js | 4 +-- js/controllers/selection-controller.js | 38 +++++++++++---------------- 2 files changed, 18 insertions(+), 24 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index 4a02e9a3..e40a646a 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js @@ -19,13 +19,13 @@ exports.ElementController = Montage.create(Component, { var selectedLayerIndex = this.application.ninja.timeline.getLayerIndexByID(this.application.ninja.timeline.currentLayerSelected.layerData.layerID); if(selectedLayerIndex === 0) { - this.application.ninja.currentSelectedContainer.appendChild(el); + this.application.ninja.currentDocument.model.domContainer.appendChild(el); } else { var element = this.application.ninja.timeline.arrLayers[selectedLayerIndex].layerData.elementsList[0]; element.parentNode.insertBefore(el, element.nextSibling); } } else { - this.application.ninja.currentSelectedContainer.appendChild(el); + this.application.ninja.currentDocument.model.domContainer.appendChild(el); } if(styles) { diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 4bca0755..9ae1cfc9 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -35,7 +35,7 @@ exports.SelectionController = Montage.create(Component, { if(this._currentDocument && this._currentDocument.currentView === "design") { this._currentDocument.model._selection = this.application.ninja.selectedElements; - this._currentDocument.model.selectionContainer = this.application.ninja._currentSelectedContainer; +// this._currentDocument.model.selectionContainer = this.application.ninja._currentSelectedContainer; } this._currentDocument = value; @@ -65,7 +65,7 @@ exports.SelectionController = Montage.create(Component, { this._selectedElements = value; this.application.ninja.selectedElements = this._selectedElements; - this.application.ninja._currentSelectedContainer = this._selectionContainer = this.application.ninja.currentDocument.model.documentRoot; +// this.application.ninja._currentSelectedContainer = this._selectionContainer = this.application.ninja.currentDocument.model.documentRoot; if(this._selectedElements.length === 0) { this.executeSelectElement(); @@ -78,30 +78,24 @@ exports.SelectionController = Montage.create(Component, { } }, - // Bound property to the ninja currentSelectedContainer - _selectionContainer: { - value: null - }, - - selectionContainer: { - get: function() { - return this._selectionContainer - }, - set: function(value) { - if(this._selectionContainer && this._selectionContainer !== value) { - this.executeSelectElement(); - } - - this._selectionContainer = value; - } - }, - deserializedFromTemplate: { value: function() { this.eventManager.addEventListener("elementAdded", this, false); this.eventManager.addEventListener("elementsRemoved", this, false); this.eventManager.addEventListener("elementReplaced", this, false); this.eventManager.addEventListener("selectAll", this, false); + + this.addPropertyChangeListener("currentDocument.model.domContainer", this); + } + }, + + handleChange: { + value: function() { + if(this.currentDocument && this.currentDocument.model.getProperty("domContainer")) { + if(this.currentDocument.model.getProperty("domContainer") !== null) { + this.executeSelectElement(); + } + } } }, @@ -175,12 +169,12 @@ exports.SelectionController = Montage.create(Component, { if(this.isDocument) return; // If the stage is already selected do nothing. this.executeSelectElement(); // Else execute selection with no element } else { - if(element.parentNode.uuid === this.selectionContainer.uuid) { + if(element.parentNode.uuid === this.currentDocument.model.domContainer.uuid) { this.executeSelectElement(element); } else { var outerElement = element.parentNode; - while(outerElement.parentNode && outerElement.parentNode.uuid !== this.selectionContainer.uuid) { + while(outerElement.parentNode && outerElement.parentNode.uuid !== this.currentDocument.model.domContainer.uuid) { // If element is higher up than current container then return if(outerElement.nodeName === "BODY") return; // else keep going up the chain -- cgit v1.2.3 From 52ca1c95d6f000503f44fa5f3139557e770a7773 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 12 Jun 2012 15:12:52 -0700 Subject: hack fix for the PI section throwing errors when dom is not ready to draw Signed-off-by: Valerio Virgillito --- js/controllers/selection-controller.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 9ae1cfc9..6d982e69 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -34,6 +34,7 @@ exports.SelectionController = Montage.create(Component, { } if(this._currentDocument && this._currentDocument.currentView === "design") { + this.ignoreFlag = false; this._currentDocument.model._selection = this.application.ninja.selectedElements; // this._currentDocument.model.selectionContainer = this.application.ninja._currentSelectedContainer; } @@ -50,6 +51,10 @@ exports.SelectionController = Montage.create(Component, { } }, + ignoreFlag: { + value: true + }, + _selectedElements: { value: null }, @@ -91,10 +96,14 @@ exports.SelectionController = Montage.create(Component, { handleChange: { value: function() { - if(this.currentDocument && this.currentDocument.model.getProperty("domContainer")) { - if(this.currentDocument.model.getProperty("domContainer") !== null) { - this.executeSelectElement(); + if(this.ignoreFlag) { + if(this.currentDocument && this.currentDocument.model.getProperty("domContainer")) { + if(this.currentDocument.model.getProperty("domContainer") !== null) { + this.executeSelectElement(); + } } + } else { + this.ignoreFlag = true; } } }, -- cgit v1.2.3 From 509092ff335f74517a413cfb2deeb9d2de20f8e3 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 12 Jun 2012 15:13:09 -0700 Subject: Fixing properties panel to support px and % for body and other elements. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/body-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/controllers') diff --git a/js/controllers/elements/body-controller.js b/js/controllers/elements/body-controller.js index 0dc11b82..27989c65 100755 --- a/js/controllers/elements/body-controller.js +++ b/js/controllers/elements/body-controller.js @@ -37,7 +37,7 @@ exports.BodyController = Montage.create(ElementController, { case "height": case "width": case "-webkit-transform-style": - return this.application.ninja.stylesController.getElementStyle(el, p, true, true); + return this.application.ninja.stylesController.getElementStyle(el, p); default: return ElementController.getProperty(el, p, true, true); //console.log("Undefined Stage property ", p); -- cgit v1.2.3 From a75947d69f571d723552f926f94d195514a01cbd Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 12 Jun 2012 23:04:07 -0700 Subject: fixed document switching issues Signed-off-by: Valerio Virgillito --- js/controllers/selection-controller.js | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 6d982e69..b327bea4 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -34,13 +34,14 @@ exports.SelectionController = Montage.create(Component, { } if(this._currentDocument && this._currentDocument.currentView === "design") { - this.ignoreFlag = false; this._currentDocument.model._selection = this.application.ninja.selectedElements; -// this._currentDocument.model.selectionContainer = this.application.ninja._currentSelectedContainer; } this._currentDocument = value; + if(this._currentDocument && this._currentDocument.currentView === "design") { + this.selectedElements = this._currentDocument.model.selection; + } /* if(!value) { } else if(this._currentDocument.currentView === "design") { @@ -51,10 +52,6 @@ exports.SelectionController = Montage.create(Component, { } }, - ignoreFlag: { - value: true - }, - _selectedElements: { value: null }, @@ -64,21 +61,17 @@ exports.SelectionController = Montage.create(Component, { return this._selectedElements; }, set: function(value) { - if(this.currentDocument && this.currentDocument.currentView === "code") return; if(value) { this._selectedElements = value; this.application.ninja.selectedElements = this._selectedElements; -// this.application.ninja._currentSelectedContainer = this._selectionContainer = this.application.ninja.currentDocument.model.documentRoot; if(this._selectedElements.length === 0) { this.executeSelectElement(); } else { this.executeSelectElement(this._selectedElements); } - - } } }, @@ -89,22 +82,6 @@ exports.SelectionController = Montage.create(Component, { this.eventManager.addEventListener("elementsRemoved", this, false); this.eventManager.addEventListener("elementReplaced", this, false); this.eventManager.addEventListener("selectAll", this, false); - - this.addPropertyChangeListener("currentDocument.model.domContainer", this); - } - }, - - handleChange: { - value: function() { - if(this.ignoreFlag) { - if(this.currentDocument && this.currentDocument.model.getProperty("domContainer")) { - if(this.currentDocument.model.getProperty("domContainer") !== null) { - this.executeSelectElement(); - } - } - } else { - this.ignoreFlag = true; - } } }, @@ -134,7 +111,7 @@ exports.SelectionController = Montage.create(Component, { value: function(event) { var selected = [], childNodes = [], self = this; - childNodes = this.application.ninja.currentDocument.model.documentRoot.childNodes; + childNodes = this.currentDocument.model.domContainer.childNodes; childNodes = Array.prototype.slice.call(childNodes, 0); childNodes.forEach(function(item) { if(self.isNodeTraversable(item)) { -- cgit v1.2.3