From 4c3aac5eabd93052b1554a03d78235215bb49db4 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 29 May 2012 00:34:40 -0700 Subject: document bindings phase 1 - using array controller to bind the current document to all ninja components - removed open document event - removed references to the document controller Signed-off-by: Valerio Virgillito --- .../layout/document-bar.reel/document-bar.js | 48 +++++++++++++++++----- 1 file changed, 38 insertions(+), 10 deletions(-) (limited to 'js/components/layout/document-bar.reel/document-bar.js') diff --git a/js/components/layout/document-bar.reel/document-bar.js b/js/components/layout/document-bar.reel/document-bar.js index 56b61f1d..6a7b0f3f 100755 --- a/js/components/layout/document-bar.reel/document-bar.js +++ b/js/components/layout/document-bar.reel/document-bar.js @@ -9,13 +9,32 @@ var Component = require("montage/ui/component").Component; exports.DocumentBar = Montage.create(Component, { + _currentDocument: { + enumerable: false, + value: null + }, + + currentDocument: { + enumerable: false, + get: function() { + return this._currentDocument; + }, + set: function(value) { + if (value === this._currentDocument) { + return; + } + + this._currentDocument = value; + + this.disabled = !this._currentDocument; + + } + }, + designView: { value: null, enumerable: false}, codeView: { value: null, enumerable: false}, zoomControl: { value: null, enumerable: false }, _type: { enumerable: false, value: null }, - disabled: { value: true }, - - type: { enumerable: false, @@ -86,7 +105,6 @@ exports.DocumentBar = Montage.create(Component, { prepareForDraw: { value: function() { - this.eventManager.addEventListener( "openDocument", this, false); this.eventManager.addEventListener( "closeDocument", this, false); this.designView.addEventListener("click", this, false); this.codeView.addEventListener("click", this, false); @@ -94,6 +112,22 @@ exports.DocumentBar = Montage.create(Component, { } }, + _disabled: { + value: true + }, + + disabled: { + get: function() { + return this._disabled; + }, + set: function(value) { + if(value !== this._disabled) { + this._disabled = value; + } + } + }, + + handleClick: { value: function(event) { if(event._event.target.id === this.currentView) return; @@ -103,12 +137,6 @@ exports.DocumentBar = Montage.create(Component, { } }, - handleOpenDocument: { - value: function() { - this.disabled = false; - } - }, - handleCloseDocument: { value: function() { if(!this.application.ninja.documentController.activeDocument) { -- cgit v1.2.3 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/components/layout/document-bar.reel/document-bar.js | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'js/components/layout/document-bar.reel/document-bar.js') diff --git a/js/components/layout/document-bar.reel/document-bar.js b/js/components/layout/document-bar.reel/document-bar.js index 6a7b0f3f..90d3a207 100755 --- a/js/components/layout/document-bar.reel/document-bar.js +++ b/js/components/layout/document-bar.reel/document-bar.js @@ -105,7 +105,6 @@ exports.DocumentBar = Montage.create(Component, { prepareForDraw: { value: function() { - this.eventManager.addEventListener( "closeDocument", this, false); this.designView.addEventListener("click", this, false); this.codeView.addEventListener("click", this, false); @@ -135,19 +134,5 @@ exports.DocumentBar = Montage.create(Component, { this.currentView = event._event.target.id; this.application.ninja.documentController.stage.stageView.switchDesignDocViews(event._event.target.id);//switch between design view } - }, - - handleCloseDocument: { - value: function() { - if(!this.application.ninja.documentController.activeDocument) { - this.disabled = true; - } - } - }, - - handleOnDocumentChanged:{ - value:function(event){ - - } } }); -- cgit v1.2.3 From 6079ceedb5b340c78ecd02f27dfa734eedccf512 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 1 Jun 2012 00:39:14 -0700 Subject: making the document bar handle the current document to hide/show itself Signed-off-by: Valerio Virgillito --- .../layout/document-bar.reel/document-bar.js | 55 +++++++++++++++++++--- 1 file changed, 49 insertions(+), 6 deletions(-) (limited to 'js/components/layout/document-bar.reel/document-bar.js') diff --git a/js/components/layout/document-bar.reel/document-bar.js b/js/components/layout/document-bar.reel/document-bar.js index 90d3a207..1cb0bd90 100755 --- a/js/components/layout/document-bar.reel/document-bar.js +++ b/js/components/layout/document-bar.reel/document-bar.js @@ -28,13 +28,45 @@ exports.DocumentBar = Montage.create(Component, { this.disabled = !this._currentDocument; + if(this._currentDocument && this._currentDocument.currentView === "design") { + this.visible = true; + } else if(this._currentDocument && this._currentDocument.currentView === "code") { + this.visible = false; + } } }, - designView: { value: null, enumerable: false}, - codeView: { value: null, enumerable: false}, - zoomControl: { value: null, enumerable: false }, - _type: { enumerable: false, value: null }, + _visible: { + value: false + }, + + visible: { + get: function() { + return this._visible; + }, + set: function(value) { + if(this._visible !== value) { + this._visible = value; + this.needsDraw = true; + } + } + }, + + designView: { + value: null + }, + + codeView: { + value: null + }, + + zoomControl: { + value: null + }, + + _type: { + value: null + }, type: { enumerable: false, @@ -50,7 +82,9 @@ exports.DocumentBar = Montage.create(Component, { } }, - _currentView: { value: null, enumerable: false }, + _currentView: { + value: null + }, currentView: { get: function() { return this._currentView}, @@ -64,7 +98,9 @@ exports.DocumentBar = Montage.create(Component, { } }, - _zoomFactor: { value: 100, enumerable: false }, + _zoomFactor: { + value: 100 + }, zoomFactor: { get: function() { return this._zoomFactor; }, @@ -84,6 +120,7 @@ exports.DocumentBar = Montage.create(Component, { draw: { value: function() { + /* if(this.type === "htm" || this.type === "html") { this.designView.classList.add("active"); this.codeView.classList.add("active"); @@ -99,6 +136,12 @@ exports.DocumentBar = Montage.create(Component, { } else if(this.type) { this.designView.classList.remove("active"); } + */ + if(this.visible) { + this.element.style.display = "block"; + } else { + this.element.style.display = "none"; + } } }, -- cgit v1.2.3