From 7a94696e19b14e15261df516e2ba75e693b1313d Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 18 May 2012 00:21:56 -0700 Subject: enabling basic document switching Signed-off-by: Valerio Virgillito --- .../layout/document-entry.reel/document-entry.js | 4 +- js/controllers/document-controller.js | 37 +++++----- js/controllers/selection-controller.js | 4 +- js/document/document-html.js | 20 +++++- js/document/html-document.js | 78 +--------------------- js/document/models/base.js | 2 +- js/ninja.reel/ninja.js | 17 ++++- js/panels/properties.reel/properties.js | 16 ----- js/stage/stage-deps.js | 13 ++-- js/stage/stage-view.reel/stage-view.js | 22 ------ 10 files changed, 59 insertions(+), 154 deletions(-) (limited to 'js') diff --git a/js/components/layout/document-entry.reel/document-entry.js b/js/components/layout/document-entry.reel/document-entry.js index ad0236c6..50b3624c 100755 --- a/js/components/layout/document-entry.reel/document-entry.js +++ b/js/components/layout/document-entry.reel/document-entry.js @@ -121,8 +121,8 @@ exports.DocumentEntry = Montage.create(Component, { if(event._event.target.nodeName === "IMG") { this.application.ninja.documentController.closeFile(this.application.ninja.documentController._findDocumentByUUID(this._uuid)); } else { - if(!this._document.isActive) { - this.application.ninja.stage.stageView.switchDocument(this.application.ninja.documentController._findDocumentByUUID(this._uuid)); + if(!this.active) { + this.application.ninja.documentController.switchDocuments(this.application.ninja.currentDocument, this.application.ninja.documentController._findDocumentByUUID(this._uuid)); } } } diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 50874725..fc1f2c0f 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -459,16 +459,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, // There is a document currently opened currentDocument = this.activeDocument; - //this.application.ninja.stage.stageView.showCodeViewBar(false); //this.application.ninja.stage.stageView.restoreAllPanels(); - - //this.activeDocument.saveAppState(); - - // TODO: Do we need this? - //this.application.ninja.stage.hideCanvas(true); - //this.application.ninja.stage.stageView.hideRulers(); - - //this.activeDocument.restoreAppState(); } else { // There is no document opened @@ -480,7 +471,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.application.ninja.stage.hideCanvas(false); } - // Set the active document this.activeDocument = doc; @@ -489,22 +479,27 @@ var DocumentController = exports.DocumentController = Montage.create(Component, // Flag to stop stylesheet dirty event this._hackInitialStyles = false; - this.switchDocuments(currentDocument, doc); - - NJevent("onOpenDocument", doc); - - //Setting opacity to be viewable after load - //doc.model.views.design.iframe.style.opacity = 1; - + this.switchDocuments(currentDocument, doc, true); } }, switchDocuments: { - value: function(current, newDocument) { - newDocument.model.views.design.iframe.style.opacity = 1; + value: function(currentDocument, newDocument, didCreate) { + + if(currentDocument) { + currentDocument.serializeDocument(); - if(current) { - current.model.views.design.hide(); + currentDocument.model.views.design.hide(); + } + + if(didCreate) { + newDocument.model.views.design.iframe.style.opacity = 1; + NJevent("onOpenDocument", newDocument); + } else { + this.activeDocument = newDocument; + newDocument.model.views.design.show(); + newDocument.deserializeDocument(); + NJevent("switchDocument"); } } }, diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 6e40abb5..1092615a 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -81,10 +81,10 @@ exports.SelectionController = Montage.create(Component, { handleSwitchDocument: { value: function() { - if(this.application.ninja.documentController.activeDocument.currentView === "design"){ +// if(this.application.ninja.documentController.activeDocument.currentView === "design"){ this._isDocument = this.application.ninja.selectedElements.length === 0; NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} ); - } +// } } }, diff --git a/js/document/document-html.js b/js/document/document-html.js index c77ed7bc..0037c94d 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js @@ -134,7 +134,7 @@ exports.HtmlDocument = Montage.create(Component, { // serializeDocument: { value: function () { - // There are not needed for now ssince we cannot change them + // There are not needed for now since we cannot change them //this.gridHorizontalSpacing = this.application.ninja.stage.drawUtils.gridHorizontalSpacing; //this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing; @@ -150,13 +150,29 @@ exports.HtmlDocument = Montage.create(Component, { // Pause the videos this.model.views.design.pauseVideos(); + + this.model.isActive = false; } }, //////////////////////////////////////////////////////////////////// // deserializeDocument: { value: function () { - //TODO: Import functionality + // There are not needed for now since we cannot change them + //this.application.ninja.stage.drawUtils.gridHorizontalSpacing = this.gridHorizontalSpacing; + //this.application.ninja.stage.drawUtils.gridVerticalSpacing = this.gridVerticalSpacing; + + // Deserialize the current scroll position + // TODO: Implement + + this.application.ninja.selectedElements = this.model.selection.slice(0); + + this.application.ninja.appModel.show3dGrid = this.draw3DGrid; + + // Serialize the undo + // TODO: Save the montage undo queue + + this.model.isActive = true; } } //////////////////////////////////////////////////////////////////// diff --git a/js/document/html-document.js b/js/document/html-document.js index 68c2a9fb..bcf2b5c2 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -454,55 +454,6 @@ exports.HTMLDocument = Montage.create(TextDocument, { } }, - /** - * Return the specified inline attribute from the element. - */ - GetElementAttribute: { - value: function(element, attribute) { - - var value; - - if(attribute === "src") { - return element[attribute].replace(window.location.href, ''); - } - - value = element[attribute]; - - if(value !== undefined) return value; -// if(value || value === false) return [value, "inline"]; - - // 3. - //value = this._document.defaultView.getComputedStyle(element,null).getPropertyValue(attribute); - //if(value) return value; - - return null; - } - }, - - GetElementStyle: { - value: function(element, style) { -// return this._queryStylesheets(element, style); - } - }, - - SetStyle: { - value: function(type, selector, style, value) { - try { - for(var j=0; j