From 26bfb7a4cbf66c35e23eec46def045bd295be2e1 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 9 Feb 2012 21:21:29 -0800 Subject: disabling the auto open of a document on load. Temporary using the new project button to open a document. Signed-off-by: Valerio Virgillito --- js/io/document/document-controller.js | 43 +++++++++++++--------- js/panels/properties/content.reel/content.js | 9 +++++ .../sections/three-d-view.reel/three-d-view.js | 35 ++++++++++-------- 3 files changed, 54 insertions(+), 33 deletions(-) diff --git a/js/io/document/document-controller.js b/js/io/document/document-controller.js index e36181bf..15f026a3 100755 --- a/js/io/document/document-controller.js +++ b/js/io/document/document-controller.js @@ -37,7 +37,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, value: "function CodeMirror(place, givenOptions) {" + "// Determine effective options based on given values and defaults." + "var options = {}, defaults = CodeMirror.defaults; }" - }, + }, activeDocument: { get: function() { @@ -45,7 +45,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, }, set: function(doc) { if(this._activeDocument) this._activeDocument.isActive = false; - + if(this._documents.indexOf(doc) === -1) this._documents.push(doc); this._activeDocument = doc; @@ -66,10 +66,19 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.eventManager.addEventListener("executeSave", this, false); this.eventManager.addEventListener("recordStyleChanged", this, false); + + // Temporary testing opening a new file after Ninja has loaded + this.eventManager.addEventListener("executeNewProject", this, false); } }, handleAppLoaded: { + value: function() { + //this.openDocument({"type": "html"}); + } + }, + + handleExecuteNewProject: { value: function() { this.openDocument({"type": "html"}); } @@ -107,9 +116,9 @@ var DocumentController = exports.DocumentController = Montage.create(Component, if((newFileObj.fileExtension !== ".html") && (newFileObj.fileExtension !== ".htm")){//open code view - }else{ + } else { //open design view - } + } } }, @@ -153,7 +162,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, openFileCallback:{ value:function(doc){ this.openDocument(doc); - } + } }, @@ -188,7 +197,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.textDocumentOpened(newDoc); - } + } // } catch (err) { // console.log("Could not open Document ", err); @@ -220,24 +229,24 @@ var DocumentController = exports.DocumentController = Montage.create(Component, } DocumentManager._codeEditor.editor = CodeMirror.fromTextArea(doc.textArea, { - lineNumbers: true, + lineNumbers: true, mode: type, - onCursorActivity: function() { - DocumentManager._codeEditor.editor.setLineClass(DocumentManager._codeEditor.hline, null); - DocumentManager._codeEditor.hline = DocumentManager._codeEditor.editor.setLineClass(DocumentManager._codeEditor.editor.getCursor().line, "activeline"); - } - }); + onCursorActivity: function() { + DocumentManager._codeEditor.editor.setLineClass(DocumentManager._codeEditor.hline, null); + DocumentManager._codeEditor.hline = DocumentManager._codeEditor.editor.setLineClass(DocumentManager._codeEditor.editor.getCursor().line, "activeline"); + } + }); DocumentManager._codeEditor.hline = DocumentManager._codeEditor.editor.setLineClass(0, "activeline"); */ - } + } }, closeDocument: { value: function(id) { if(this.activeDocument.dirtyFlag === true){ //if file dirty then alert user to save - } + } var doc = this._findDocumentByUUID(id); this._removeDocumentView(doc.container); @@ -362,9 +371,9 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.application.ninja.stage.restoreScroll(); this.application.ninja.stage.hideCanvas(false); this.application.ninja.stage.stageView.showRulers(); - } } } + } }, _removeDocumentView: { @@ -405,5 +414,5 @@ var DocumentController = exports.DocumentController = Montage.create(Component, value: function() { return "userDocument_" + (this._iframeCounter++); } - } -}); \ No newline at end of file + } +}); diff --git a/js/panels/properties/content.reel/content.js b/js/panels/properties/content.reel/content.js index 0088447a..51b776f1 100755 --- a/js/panels/properties/content.reel/content.js +++ b/js/panels/properties/content.reel/content.js @@ -54,8 +54,17 @@ exports.Content = Montage.create(Component, { this.eventManager.addEventListener( "elementChanging", this, false); } + this.eventManager.addEventListener("openDocument", this, false); + } + }, + + // Document is opened - Display the current selection + handleOpenDocument: { + value: function() { + this.eventManager.addEventListener( "elementChange", this, false); + // For now always assume that the stage is selected by default if(this.application.ninja.selectedElements.length === 0) { this.displayStageProperties(); } diff --git a/js/panels/properties/sections/three-d-view.reel/three-d-view.js b/js/panels/properties/sections/three-d-view.reel/three-d-view.js index 0c4a9171..35591afa 100755 --- a/js/panels/properties/sections/three-d-view.reel/three-d-view.js +++ b/js/panels/properties/sections/three-d-view.reel/three-d-view.js @@ -207,29 +207,32 @@ exports.ThreeD = Montage.create(Component, { templateDidLoad : { value: function() { Object.defineBinding(this, "axisMode", { - boundObject: this.axisModeGroupControl, - boundObjectPropertyPath: "selectedIndex", - oneway: false - }); + boundObject: this.axisModeGroupControl, + boundObjectPropertyPath: "selectedIndex", + oneway: false + }); + + this.eventManager.addEventListener("openDocument", this, false); + } + }, + + handleOpenDocument: { + value: function() { Object.defineBinding(this, "item", { - boundObject: this, - boundObjectPropertyPath: "application.ninja.selectedElements", - boundValueMutator: this._getSelectedItem, - oneway: true - }); + boundObject: this, + boundObjectPropertyPath: "application.ninja.selectedElements", + boundValueMutator: this._getSelectedItem, + oneway: true + }); } }, _getSelectedItem: { - value: function(els) - { - if(els.length) - { + value: function(els) { + if(els.length) { return els[0]._element || els[0]; - } - else - { + } else { return this.boundObject.application.ninja.currentDocument.documentRoot; } } -- cgit v1.2.3