From 31b094ee21102f99a4021d505bc3a28527c9e23d Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 30 May 2012 01:33:20 -0700 Subject: Fixing the close document. Signed-off-by: Valerio Virgillito --- js/panels/Panel.reel/Panel.js | 7 ++++- js/panels/PanelContainer.reel/PanelContainer.js | 12 --------- js/panels/css-panel/css-panel.reel/css-panel.html | 3 +++ js/panels/css-panel/css-panel.reel/css-panel.js | 18 +++++++++++++ .../styles-view-container.js | 31 ++++++++++++++++------ js/panels/properties.reel/properties.js | 11 +++----- 6 files changed, 53 insertions(+), 29 deletions(-) (limited to 'js/panels') diff --git a/js/panels/Panel.reel/Panel.js b/js/panels/Panel.reel/Panel.js index 14b25c36..0c5f0b4b 100755 --- a/js/panels/Panel.reel/Panel.js +++ b/js/panels/Panel.reel/Panel.js @@ -120,7 +120,12 @@ exports.Panel = Montage.create(Component, { this.panelContent.content[0].controller.currentDocument = this._currentDocument; } - this.disabled = this._currentDocument.currentView !== "design"; + if(!value) { + this.disabled = true; + } else { + this.disabled = this._currentDocument.currentView !== "design"; + } + } }, diff --git a/js/panels/PanelContainer.reel/PanelContainer.js b/js/panels/PanelContainer.reel/PanelContainer.js index dc501a99..7cb03255 100755 --- a/js/panels/PanelContainer.reel/PanelContainer.js +++ b/js/panels/PanelContainer.reel/PanelContainer.js @@ -81,8 +81,6 @@ exports.PanelContainer = Montage.create(Component, { } this.application.localStorage.setItem("panels", this.currentPanelState); - - this.eventManager.addEventListener( "closeDocument", this, false); } }, @@ -104,16 +102,6 @@ exports.PanelContainer = Montage.create(Component, { } }, - handleCloseDocument: { - value: function(){ - if(!this.application.ninja.documentController.activeDocument) { - this.panels.forEach(function(obj) { - obj.disabled = true; - }); - } - } - }, - handleDropped: { value: function(e) { var draggedIndex, droppedIndex = 0, len = this.panels.length; diff --git a/js/panels/css-panel/css-panel.reel/css-panel.html b/js/panels/css-panel/css-panel.reel/css-panel.html index 42dca8a2..789635a0 100644 --- a/js/panels/css-panel/css-panel.reel/css-panel.html +++ b/js/panels/css-panel/css-panel.reel/css-panel.html @@ -31,6 +31,9 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot "properties": { "element": {"#": "styles-view-container" }, "selectionName": {"@": "selectionName" } + }, + "bindings": { + "currentDocument" : {"<-": "@owner.currentDocument" } } }, "selectionName" : { diff --git a/js/panels/css-panel/css-panel.reel/css-panel.js b/js/panels/css-panel/css-panel.reel/css-panel.js index a117787e..96d94b36 100644 --- a/js/panels/css-panel/css-panel.reel/css-panel.js +++ b/js/panels/css-panel/css-panel.reel/css-panel.js @@ -8,6 +8,24 @@ var Montage = require("montage/core/core").Montage, Component = require("montage/ui/component").Component; exports.CssPanel = Montage.create(Component, { + + _currentDocument: { + value : null + }, + + currentDocument : { + get : function() { + return this._currentDocument; + }, + set : function(value) { + if (value === this._currentDocument) { + return; + } + + this._currentDocument = value; + } + }, + prepareForDraw : { value: function() { } diff --git a/js/panels/css-panel/styles-view-container.reel/styles-view-container.js b/js/panels/css-panel/styles-view-container.reel/styles-view-container.js index 4a391421..157d99de 100644 --- a/js/panels/css-panel/styles-view-container.reel/styles-view-container.js +++ b/js/panels/css-panel/styles-view-container.reel/styles-view-container.js @@ -8,6 +8,29 @@ var Montage = require("montage/core/core").Montage, Component = require("montage/ui/component").Component; exports.StylesViewContainer = Montage.create(Component, { + + _currentDocument: { + value : null + }, + + currentDocument : { + get : function() { + return this._currentDocument; + }, + set : function(value) { + if (value === this._currentDocument) { + return; + } + + this._currentDocument = value; + + if(!value) { + this.hasStyles = false; + this.needsDraw = true; + } + } + }, + contentController : { value: null }, @@ -74,7 +97,6 @@ exports.StylesViewContainer = Montage.create(Component, { value: function() { this.eventManager.addEventListener('styleSheetsReady', this, false); this.eventManager.addEventListener('elementChange', this, false); - this.eventManager.addEventListener("closeDocument", this, false); } }, handleStyleSheetsReady: { @@ -150,13 +172,6 @@ exports.StylesViewContainer = Montage.create(Component, { } }, - handleCloseDocument: { - value: function(e) { - this.hasStyles = false; - this.needsDraw = true; - } - }, - draw : { value: function() { if(this.hasStyles) { diff --git a/js/panels/properties.reel/properties.js b/js/panels/properties.reel/properties.js index e99f58e9..4b663220 100755 --- a/js/panels/properties.reel/properties.js +++ b/js/panels/properties.reel/properties.js @@ -29,7 +29,9 @@ exports.Properties = Montage.create(Component, { this._currentDocument = value; - if(this._currentDocument.currentView === "design") { + if(!value) { + this.clear(); + } else if(this._currentDocument.currentView === "design") { // Save a reference of the pi inside the document view to be able to clear this._currentDocument.model.views.design.propertiesPanel = this; @@ -74,7 +76,6 @@ exports.Properties = Montage.create(Component, { value : function() { this.eventManager.addEventListener("elementChange", this, false); this.eventManager.addEventListener("selectionChange", this, false); - this.eventManager.addEventListener("closeDocument", this, false); // This will be a toggle option if(this.application.ninja.appData.PILiveUpdate) { @@ -91,12 +92,6 @@ exports.Properties = Montage.create(Component, { } }, - handleCloseDocument: { - value: function(){ - this.clear(); - } - }, - /** * Blur and Key up to handle change in the Element ID field. */ -- cgit v1.2.3