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/bread-crumb.reel/bread-crumb.js | 44 ++++- .../layout/document-bar.reel/document-bar.html | 6 +- .../layout/document-bar.reel/document-bar.js | 48 ++++-- .../layout/document-entry.reel/document-entry.css | 22 ++- .../layout/document-entry.reel/document-entry.html | 14 +- .../layout/document-entry.reel/document-entry.js | 44 ++--- .../layout/documents-tab.reel/documents-tab.html | 13 +- .../layout/documents-tab.reel/documents-tab.js | 5 + .../layout/tools-list.reel/tools-list.html | 6 +- js/components/layout/tools-list.reel/tools-list.js | 39 ++++- .../tools-properties.reel/tools-properties.js | 42 ++++- js/components/menu/menu-item.reel/menu-item.js | 6 +- js/components/menu/menu.reel/menu.html | 20 +-- js/controllers/document-controller.js | 182 ++++----------------- js/controllers/elements/shapes-controller.js | 4 +- js/controllers/selection-controller.js | 61 ++++--- js/controllers/styles-controller.js | 93 +++++++---- js/controllers/undo-controller.js | 8 - js/document/models/text.js | 2 +- js/mediators/element-mediator.js | 6 +- js/ninja.reel/ninja.html | 80 +++++---- js/ninja.reel/ninja.js | 50 +++++- .../CSSPanel/CSSPanelBase.reel/CSSPanelBase.js | 29 +++- js/panels/Panel.reel/Panel.js | 24 +++ js/panels/PanelContainer.reel/PanelContainer.html | 21 +++ js/panels/PanelContainer.reel/PanelContainer.js | 29 ++-- js/panels/Timeline/Layer.reel/Layer.js | 4 +- .../Timeline/TimelinePanel.reel/TimelinePanel.js | 1 - .../Timeline/TimelineTrack.reel/TimelineTrack.js | 4 +- .../style-sheets-view.reel/style-sheets-view.js | 8 +- js/panels/properties.reel/properties.js | 40 +++-- .../sections/three-d-view.reel/three-d-view.js | 91 +++++------ js/stage/layout.js | 37 +++-- js/stage/stage-deps.js | 40 +++-- js/stage/stage.reel/stage.html | 18 +- js/stage/stage.reel/stage.js | 37 +++-- js/tools/PanTool.js | 1 - 37 files changed, 681 insertions(+), 498 deletions(-) (limited to 'js') diff --git a/js/components/layout/bread-crumb.reel/bread-crumb.js b/js/components/layout/bread-crumb.reel/bread-crumb.js index 49dbe3cb..74e89ac1 100755 --- a/js/components/layout/bread-crumb.reel/bread-crumb.js +++ b/js/components/layout/bread-crumb.reel/bread-crumb.js @@ -9,13 +9,45 @@ var Montage = require("montage/core/core").Montage, exports.Breadcrumb = Montage.create(Component, { - disabled: { + _currentDocument: { + enumerable: false, + value: null + }, + + currentDocument: { + enumerable: false, + get: function() { + return this._currentDocument; + }, + set: function(value) { + if (value === this._currentDocument) { + return; + } + + this._currentDocument = value; + + if(!this._currentDocument) { + this.disabled = true; + } + + this.disabled = this._currentDocument.currentView !== "design"; + + } + }, + + + _disabled: { value: true }, - handleOpenDocument: { - value: function(){ - this.disabled = false; + disabled: { + get: function() { + return this._disabled; + }, + set: function(value) { + if(value !== this._disabled) { + this._disabled = value; + } } }, @@ -50,7 +82,6 @@ exports.Breadcrumb = Montage.create(Component, { prepareForDraw: { value: function() { - this.eventManager.addEventListener("openDocument", this, false); this.eventManager.addEventListener("closeDocument", this, false); this.breadcrumbBt.addEventListener("action", this, false); } @@ -65,7 +96,7 @@ exports.Breadcrumb = Montage.create(Component, { parentNode = this.container; - while(parentNode !== this.application.ninja.currentDocument.model.documentRoot) { + while(parentNode !== this.currentDocument.model.documentRoot) { this.containerElements.unshift({"node": parentNode, "nodeUuid":parentNode.uuid, "label": parentNode.nodeName}); parentNode = parentNode.parentNode; } @@ -87,6 +118,7 @@ exports.Breadcrumb = Montage.create(Component, { this.containerElements.pop(); } + // TODO: This is bound 2 ways, update the internal property this.application.ninja.currentSelectedContainer = this.containerElements[i].node; } } diff --git a/js/components/layout/document-bar.reel/document-bar.html b/js/components/layout/document-bar.reel/document-bar.html index 760186ba..a35b5590 100755 --- a/js/components/layout/document-bar.reel/document-bar.html +++ b/js/components/layout/document-bar.reel/document-bar.html @@ -37,11 +37,7 @@ "element": {"#": "disabledCondition"} }, "bindings": { - "condition": { - "boundObject": {"@": "owner"}, - "boundObjectPropertyPath": "disabled", - "oneway": true - } + "condition": {"<-": "@owner.disabled"} } }, 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) { diff --git a/js/components/layout/document-entry.reel/document-entry.css b/js/components/layout/document-entry.reel/document-entry.css index 4601974f..010e1da7 100755 --- a/js/components/layout/document-entry.reel/document-entry.css +++ b/js/components/layout/document-entry.reel/document-entry.css @@ -19,7 +19,20 @@ min-width:0px; } -.documentEntry img { +.mybutton { + display: inline; + -webkit-appearance: none; + outline: none; + + font-size: 9px; + cursor: pointer; + border: 0px; + background-color: #474747; + background-image: -webkit-linear-gradient(top, #505050 0%, #3c3c3c 100%); + +} + +.documentEntry button { opacity: 0.5; /* 50% */ width: 12px; max-width:12px; @@ -29,17 +42,14 @@ transition: opacity 0.2s ease; } -.documentEntry:hover, -.documentEntry:active, -.documentEntry.activeTab { - /*background-color: #7f7f7f; *//* rgb(127, 127, 127); */ +.documentEntry.selected { + background-color:#7F7F7F; } .documentEntry img:hover { opacity: 1.0; /* 100% */ } - .documentEntry span.dirty:before{ content: "*"; display:inline; diff --git a/js/components/layout/document-entry.reel/document-entry.html b/js/components/layout/document-entry.reel/document-entry.html index 679ebb62..bd8c25cb 100755 --- a/js/components/layout/document-entry.reel/document-entry.html +++ b/js/components/layout/document-entry.reel/document-entry.html @@ -15,8 +15,14 @@ "prototype": "js/components/layout/document-entry.reel", "properties": { "element": {"#": "documentEntry"}, - "label": {"#": "name"}, - "activeBack": {"#": "isActive"} + "label": {"#": "name"} + } + }, + + "closeButton": { + "prototype": "montage/ui/button.reel", + "properties": { + "element": {"#": "close-btn"} } } } @@ -24,9 +30,9 @@
  • -
    - + +
  • \ No newline at end of file diff --git a/js/components/layout/document-entry.reel/document-entry.js b/js/components/layout/document-entry.reel/document-entry.js index 50b3624c..2e66c7cd 100755 --- a/js/components/layout/document-entry.reel/document-entry.js +++ b/js/components/layout/document-entry.reel/document-entry.js @@ -58,25 +58,6 @@ exports.DocumentEntry = Montage.create(Component, { } }, - _active: { - enumerable: false, - value: null - }, - - active: { - get: function() { - return this._active; - }, - set: function(value) { - var previousValue = this._active; - this._active = value; - - if (previousValue !== this._active) { - this.needsDraw = true; - } - } - }, - _saveFlag: { value: false }, @@ -96,7 +77,8 @@ exports.DocumentEntry = Montage.create(Component, { prepareForDraw: { enumerable: false, value: function() { - this.element.addEventListener("click", this, false); +// this.element.addEventListener("click", this, false); +// this.closeBtn.addEventListener("click", this, true); } }, @@ -106,7 +88,7 @@ exports.DocumentEntry = Montage.create(Component, { value: function() { this.label.innerText = this._name ? this._name : ""; - this._active ? this.element.classList.add("activeTab") : this.element.classList.remove("activeTab"); +// this._active ? this.element.classList.add("activeTab") : this.element.classList.remove("activeTab"); if(this.saveFlag) { this.label.classList.add("dirty"); @@ -116,15 +98,19 @@ exports.DocumentEntry = Montage.create(Component, { } }, - handleClick: { + captureClick: { value: function(event) { - if(event._event.target.nodeName === "IMG") { - this.application.ninja.documentController.closeFile(this.application.ninja.documentController._findDocumentByUUID(this._uuid)); - } else { - if(!this.active) { - this.application.ninja.documentController.switchDocuments(this.application.ninja.currentDocument, this.application.ninja.documentController._findDocumentByUUID(this._uuid)); - } - } + console.log("clicked on the X"); + event.preventDefault(); + event.stopImmediatePropagation(); + event.stopPropagation(); +// if(event._event.target.nodeName === "IMG") { +// this.application.ninja.documentController.closeFile(this.application.ninja.documentController._findDocumentByUUID(this._uuid)); +// } else { +// if(!this.active) { +// this.application.ninja.documentController.switchDocuments(this.application.ninja.currentDocument, this.application.ninja.documentController._findDocumentByUUID(this._uuid)); +// } +// } } } diff --git a/js/components/layout/documents-tab.reel/documents-tab.html b/js/components/layout/documents-tab.reel/documents-tab.html index 304c8871..04b2bd7b 100755 --- a/js/components/layout/documents-tab.reel/documents-tab.html +++ b/js/components/layout/documents-tab.reel/documents-tab.html @@ -28,22 +28,19 @@ "bindings": { "document": {"<-": "@repetition1.objectAtCurrentIteration"}, "name": {"<-": "@repetition1.objectAtCurrentIteration.model.file.name"}, - "saveFlag": {"<-": "@repetition1.objectAtCurrentIteration.model.needsSave"}, - "active": {"<-": "@repetition1.objectAtCurrentIteration.model.isActive"} + "saveFlag": {"<-": "@repetition1.objectAtCurrentIteration.model.needsSave"} } }, "repetition1": { "prototype": "montage/ui/repetition.reel", "properties": { - "element": {"#": "openDocuments"} + "element": {"#": "openDocuments"}, + "isSelectionEnabled": true }, "bindings": { - "objects": { - "boundObject": {"@": "owner"}, - "boundObjectPropertyPath": "openDocuments", - "oneway": true - } + + "contentController": {"<-": "@owner.contentController"} } } diff --git a/js/components/layout/documents-tab.reel/documents-tab.js b/js/components/layout/documents-tab.reel/documents-tab.js index 982f6ecd..0be639db 100755 --- a/js/components/layout/documents-tab.reel/documents-tab.js +++ b/js/components/layout/documents-tab.reel/documents-tab.js @@ -9,6 +9,7 @@ var Component = require("montage/ui/component").Component; exports.DocumentsTab = Montage.create(Component, { + /* openDocuments: { value: [] }, @@ -40,4 +41,8 @@ exports.DocumentsTab = Montage.create(Component, { } } + */ + contentController: { + value: null + } }); \ No newline at end of file diff --git a/js/components/layout/tools-list.reel/tools-list.html b/js/components/layout/tools-list.reel/tools-list.html index df603bf8..4e5b85ee 100755 --- a/js/components/layout/tools-list.reel/tools-list.html +++ b/js/components/layout/tools-list.reel/tools-list.html @@ -102,11 +102,7 @@ "element": {"#": "disabledCondition"} }, "bindings": { - "condition": { - "boundObject": {"@": "owner"}, - "boundObjectPropertyPath": "disabled", - "oneway": true - } + "condition": {"<-": "@owner.disabled"} } }, diff --git a/js/components/layout/tools-list.reel/tools-list.js b/js/components/layout/tools-list.reel/tools-list.js index a10b6c3e..638aea41 100755 --- a/js/components/layout/tools-list.reel/tools-list.js +++ b/js/components/layout/tools-list.reel/tools-list.js @@ -26,11 +26,41 @@ exports.ToolsList = Montage.create(Component, { RotateStageTool3D: { value: null }, PanTool: { value: null }, ZoomTool: { value: null }, - disabled: { value: true}, - handleOpenDocument: { - value: function(){ - this.disabled = false; + _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; + + } + }, + + _disabled: { + value: true + }, + + disabled: { + get: function() { + return this._disabled; + }, + set: function(value) { + if(value !== this._disabled) { + this._disabled = value; + } } }, @@ -45,7 +75,6 @@ exports.ToolsList = Montage.create(Component, { prepareForDraw: { enumerable: false, value: function() { - this.eventManager.addEventListener( "openDocument", this, false); this.eventManager.addEventListener( "closeDocument", this, false); this.PenTool.options = this.application.ninja.toolsProperties.shapeProperties.lineProperties;//this.application.Ninja.toolsProperties.penProperties; diff --git a/js/components/layout/tools-properties.reel/tools-properties.js b/js/components/layout/tools-properties.reel/tools-properties.js index 47945b58..c25559ae 100755 --- a/js/components/layout/tools-properties.reel/tools-properties.js +++ b/js/components/layout/tools-properties.reel/tools-properties.js @@ -9,10 +9,43 @@ var Component = require("montage/ui/component").Component; exports.ToolsProperties = Montage.create(Component, { - disabled: { + _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; + + } + }, + + _disabled: { value: true }, + disabled: { + get: function() { + return this._disabled; + }, + set: function(value) { + if(value !== this._disabled) { + this._disabled = value; + } + } + }, + handleCloseDocument: { value: function(){ if(!this.application.ninja.documentController.activeDocument) { @@ -21,16 +54,9 @@ exports.ToolsProperties = Montage.create(Component, { } }, - handleOpenDocument: { - value: function() { - this.disabled = false; - } - }, - prepareForDraw: { enumerable: false, value: function() { - this.eventManager.addEventListener( "openDocument", this, false); this.eventManager.addEventListener( "closeDocument", this, false); } }, diff --git a/js/components/menu/menu-item.reel/menu-item.js b/js/components/menu/menu-item.reel/menu-item.js index fc3913b8..9c18ed37 100755 --- a/js/components/menu/menu-item.reel/menu-item.js +++ b/js/components/menu/menu-item.reel/menu-item.js @@ -82,7 +82,7 @@ exports.MenuItem = Montage.create(Component, { }); } - +/* if(this.data.enabled.boundProperty) { boundObject = this.application.ninja[this.data.enabled.boundObj]; @@ -95,9 +95,11 @@ exports.MenuItem = Montage.create(Component, { }); } else { + */ this.enabled = this.data.enabled; + /* } - + */ if(this.data.submenu) { this.submenu = true; diff --git a/js/components/menu/menu.reel/menu.html b/js/components/menu/menu.reel/menu.html index 49956f8a..7f2aeeef 100755 --- a/js/components/menu/menu.reel/menu.html +++ b/js/components/menu/menu.reel/menu.html @@ -21,11 +21,7 @@ "automaticallyOrganizeObjects": false }, "bindings": { - "content": { - "boundObject": {"@": "menudata"}, - "boundObjectPropertyPath": "topLevelMenu", - "oneway": true - } + "content": {"<-": "@menudata.topLevelMenu"} } }, @@ -44,18 +40,8 @@ "element": { "#": "menuItem" } }, "bindings": { - "data": { - "boundObject": {"@": "repetition"}, - "boundObjectPropertyPath": "objectAtCurrentIteration", - "oneway": true - }, - "_menu": { - "boundObject": {"@": "repetition"}, - "boundObjectPropertyPath": "menuComponent", - "oneway": true - } - - + "data": {"<-": "@repetition.objectAtCurrentIteration"}, + "_menu": {"<-": "@repetition.menuComponent"} } }, diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 2c34eedf..948e4550 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -8,38 +8,18 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot // var Montage = require("montage/core/core").Montage, Component = require("montage/ui/component").Component, - Uuid = require("montage/core/uuid").Uuid, HTMLDocument = require("js/document/document-html").HtmlDocument, TextDocument = require("js/document/document-text").TextDocument; //////////////////////////////////////////////////////////////////////// // exports.DocumentController = Montage.create(Component, { // - hasTemplate: {value: false}, - _documents: {value: []}, - //TODO: what is this?!?! - _hackInitialStyles: {value: true}, - _activeDocument: { value: null }, - //TODO: Are any of these needed? - _iframeCounter: { value: 1, enumerable: false }, - _iframeHolder: { value: null, enumerable: false }, - _textHolder: { value: null, enumerable: false }, - _codeMirrorCounter: {value: 1, enumerable: false}, - - activeDocument: { - get: function() { - return this._activeDocument; - }, - set: function(doc) { - //if(!!this._activeDocument){ this._activeDocument.isActive = false;} - - this._activeDocument = doc; - - if(!!this._activeDocument){ - if(this._documents.indexOf(doc) === -1) this._documents.push(doc); - this._activeDocument.isActive = true; - } - } + hasTemplate: { + value: false + }, + + documents: { + value: [] }, deserializedFromTemplate: { @@ -52,8 +32,6 @@ exports.DocumentController = Montage.create(Component, { this.eventManager.addEventListener("executeSaveAll", this, false); this.eventManager.addEventListener("executeFileClose", this, false); this.eventManager.addEventListener("executeFileCloseAll", this, false); - - this.eventManager.addEventListener("styleSheetDirty", this, false); } }, @@ -70,11 +48,11 @@ exports.DocumentController = Montage.create(Component, { if (this.redirectRequests && request.parentFrameId !== -1) { //Checking for proper URL redirect (from different directories) if (request.url.indexOf('js/document/templates/banner') !== -1) { - return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/banner/'))[1]}; + return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/banner/'))[1]}; } else if (request.url.indexOf('js/document/templates/html') !== -1) { - return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/html/'))[1]}; + return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/html/'))[1]}; } else if (request.url.indexOf('js/document/templates/app') !== -1) { - return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/app/'))[1]}; + return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/app/'))[1]}; } else { //Error, not a valid folder } @@ -98,13 +76,7 @@ exports.DocumentController = Montage.create(Component, { }, //////////////////////////////////////////////////////////////////// - - - - - - - + handleExecuteFileOpen: { value: function(event) { var pickerSettings = event._event.settings || {}; @@ -325,44 +297,6 @@ exports.DocumentController = Montage.create(Component, { } }, - //todo: remove this funciton as it is not used - textDocumentOpened: { - value: function(doc) { - - - - this.application.ninja.stage.stageView.createTextView(doc); - - /* - DocumentManager._hideCurrentDocument(); - stageManagerModule.stageManager._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe - DocumentManager.activeDocument = doc; - - var type; - - switch(doc.documentType) { - case "css" : - type = "css"; - break; - case "js" : - type = "javascript"; - break; - } - - DocumentManager._codeEditor.editor = CodeMirror.fromTextArea(doc.textArea, { - 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"); - } - }); - DocumentManager._codeEditor.hline = DocumentManager._codeEditor.editor.setLineClass(0, "activeline"); - */ - - } - }, - closeFile: { value: function(document) { document.closeDocument(this, this.onCloseFile); @@ -373,7 +307,8 @@ exports.DocumentController = Montage.create(Component, { value: function(doc) { var previousFocusedDocument; - this._documents.splice(this._documents.indexOf(doc), 1); +// this._documents.splice(this._documents.indexOf(doc), 1); + this.application.ninja.docController.removeObjects(this._documents.indexOf(doc)); if(this._documents.length > 0) { previousFocusedDocument = this._documents[this._documents.length - 1]; @@ -433,48 +368,44 @@ exports.DocumentController = Montage.create(Component, { // Open document callback _onOpenDocument: { value: function(doc){ - var currentDocument; - if(this.activeDocument) { + + + // Bypass all and call main. + // TODO: Call ninja directly once this is all cleaned up. + + this.application.ninja.handleOnOpenDocument(doc); + + +// var currentDocument; +// if(this.activeDocument) { // There is a document currently opened - currentDocument = this.activeDocument; - } else { +// currentDocument = this.activeDocument; +// } else { // There is no document opened - // Show the rulers - // TODO: Move this indo design view - this.application.ninja.stage.showRulers(); - - // Show the canvas - this.application.ninja.stage.hideCanvas(false); - } +// } // Set the active document - this.activeDocument = doc; +// this.activeDocument = doc; + + +// this.switchDocuments(currentDocument, doc, true); - // Initialize the documentRoot styles - this.initializeRootStyles(doc.model.documentRoot); - // Flag to stop stylesheet dirty event - this._hackInitialStyles = false; - this.switchDocuments(currentDocument, doc, true); } }, _onOpenTextDocument: { value: function(doc) { - var currentDocument = null; - if(this.activeDocument) { - // There is a document currently opened - currentDocument = this.activeDocument; - } - this.application.ninja.currentDocument = this.activeDocument = doc; + this.application.ninja.handleOnOpenDocument(doc); - document.getElementById("iframeContainer").style.display = "none"; - this.application.ninja.codeEditorController.applySettings(); + // Main DIFFERENCE -- + // TODO: Implement Code View here + //document.getElementById("iframeContainer").style.display = "none"; + //this.application.ninja.codeEditorController.applySettings(); - this.switchDocuments(currentDocument, doc, true); } }, @@ -512,10 +443,10 @@ exports.DocumentController = Montage.create(Component, { this.application.ninja.stage.hideRulers(); } - this.application.ninja.stage.clearAllCanvas(); +// this.application.ninja.stage.clearAllCanvas(); if(didCreate) { - newDocument.model.currentView.show(); +// newDocument.model.currentView.show(); if(newDocument.currentView === "design") { NJevent("onOpenDocument", newDocument); @@ -566,46 +497,5 @@ exports.DocumentController = Montage.create(Component, { return false; } - }, - - handleStyleSheetDirty:{ - value:function(){ - if(!this._hackInitialStyles) { - this.activeDocument.model.needsSave = true; - } - } - }, - - // TODO: Move this into the design views - initializeRootStyles: { - value: function(documentRoot) { - var sc = this.application.ninja.stylesController, - styles = {}, - needsRule = false, - rule; - - if(sc.getElementStyle(documentRoot, "width", false, false) == null) { - styles['width'] = '100%'; - needsRule = true; - } - if(sc.getElementStyle(documentRoot, "height", false, false) == null) { - styles['height'] = '100%'; - needsRule = true; - } - if(sc.getElementStyle(documentRoot, "-webkit-transform", false, false) == null) { - styles['-webkit-transform'] = 'perspective(1400) matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'; - needsRule = true; - } - if(sc.getElementStyle(documentRoot, "-webkit-transform-style", false, false) == null) { - styles['-webkit-transform-style'] = 'preserve-3d'; - needsRule = true; - } - - if(needsRule) { - rule = sc.addRule('.ninja-body{}'); - sc.setStyles(rule, styles); - sc.addClass(documentRoot, "ninja-body"); - } - } } }); diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index 38f133b5..626dedb6 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -213,7 +213,7 @@ exports.ShapesController = Montage.create(CanvasController, { default: CanvasController.setProperty(el, p, value); } - this.application.ninja.documentController.activeDocument.model.needsSave = true; + this.application.ninja.currentDocument.model.needsSave = true; } }, @@ -559,7 +559,7 @@ exports.ShapesController = Montage.create(CanvasController, { } } el.elementModel.shapeModel.GLWorld.render(); - this.application.ninja.documentController.activeDocument.model.needsSave = true; + this.application.ninja.currentDocument.model.needsSave = true; } }, diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 75bffc5c..db8bdf51 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -20,6 +20,41 @@ exports.SelectionController = Montage.create(Component, { } }, + _currentDocument: { + value : null, + enumerable : false + }, + + currentDocument : { + get : function() { + return this._currentDocument; + }, + set : function(value) { + if (value === this._currentDocument) { + return; + } + + this._currentDocument = value; + + if(this._currentDocument.currentView === "design") { + + /* + this._isDocument = true; + + if(currentSelectionArray) { + this.application.ninja.selectedElements = currentSelectionArray; + if(currentSelectionArray.length) { + this._isDocument = false; + NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument}); + } + } + + this._selectionContainer = this.application.ninja.currentSelectedContainer; + */ + } + } + }, + /* * Bound property to the ninja currentSelectedContainer */ @@ -52,32 +87,6 @@ exports.SelectionController = Montage.create(Component, { } }, - /** - * Get the current document selection array. If nothing is selected the currentSelectionArray should be null - */ - handleOpenDocument: { - value: function() { - // Handle initializing the selection array here. - this.initWithDocument([]); - } - }, - - initWithDocument: { - value: function(currentSelectionArray) { - this._isDocument = true; - - if(currentSelectionArray) { - this.application.ninja.selectedElements = currentSelectionArray; - if(currentSelectionArray.length) { - this._isDocument = false; - NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument}); - } - } - - this._selectionContainer = this.application.ninja.currentSelectedContainer; - } - }, - handleSwitchDocument: { value: function() { // if(this.application.ninja.documentController.activeDocument.currentView === "design"){ diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index 534f77c7..217a536d 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js @@ -50,10 +50,10 @@ var stylesController = exports.StylesController = Montage.create(Component, { handleAppLoaded : { value: function() { - ///// Bind app's activeDocument property to - ///// styles controller's _activeDocument property + ///// Bind app's currentDocument property to + ///// styles controller's _currentDocument property -// Object.defineBinding(this, "activeDocument", { +// Object.defineBinding(this, "currentDocument", { // boundObject: this.application.ninja, // boundObjectPropertyPath: "currentDocument", // oneway: true @@ -69,20 +69,20 @@ var stylesController = exports.StylesController = Montage.create(Component, { }, ///// Active document gets automatically set when the ///// document controller changes it - _activeDocument : { + _currentDocument : { value : null, enumerable : false }, - activeDocument : { + currentDocument : { get : function() { - return this._activeDocument; + return this._currentDocument; }, set : function(document) { ///// If the document is null set default stylesheets to null if(!document || document.currentView === "code") { - this._activeDocument = null; + this._currentDocument = null; this._stageStylesheet = null; this.defaultStylesheet = null; this.userStyleSheets = []; @@ -91,7 +91,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { } ///// setting document via binding - this._activeDocument = document; + this._currentDocument = document; ///// Stage stylesheet should always be found this._stageStylesheet = this.getSheetFromElement(this.CONST.STAGE_SHEET_ID); @@ -103,6 +103,8 @@ var stylesController = exports.StylesController = Montage.create(Component, { return sheet !== this._stageStylesheet; }, this); + this.initializeRootStyles(); + NJevent('styleSheetsReady', this); }, enumerable : false @@ -129,10 +131,10 @@ var stylesController = exports.StylesController = Montage.create(Component, { return false; } //check that the document has a design view - else if(this._activeDocument.model && this._activeDocument.model.views && this._activeDocument.model.views.design){ + else if(this._currentDocument.model && this._currentDocument.model.views && this._currentDocument.model.views.design){ ///// Use the last stylesheet in the document as the default - var sheets = this._activeDocument.model.views.design.document.styleSheets, + var sheets = this._currentDocument.model.views.design.document.styleSheets, lastIndex = sheets.length-1; ///// If the only sheet is the stage stylesheet, this will be true @@ -148,7 +150,37 @@ var stylesController = exports.StylesController = Montage.create(Component, { } } }, - + + initializeRootStyles: { + value: function() { + var styles = {}, + needsRule = false, + rule; + + if(this.getElementStyle(this.currentDocument.model.documentRoot, "width", false, false) == null) { + styles['width'] = '100%'; + needsRule = true; + } + if(this.getElementStyle(this.currentDocument.model.documentRoot, "height", false, false) == null) { + styles['height'] = '100%'; + needsRule = true; + } + if(this.getElementStyle(this.currentDocument.model.documentRoot, "-webkit-transform", false, false) == null) { + styles['-webkit-transform'] = 'perspective(1400) matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'; + needsRule = true; + } + if(this.getElementStyle(this.currentDocument.model.documentRoot, "-webkit-transform-style", false, false) == null) { + styles['-webkit-transform-style'] = 'preserve-3d'; + needsRule = true; + } + + if(needsRule) { + rule = this.addRule('.ninja-body{}'); + this.setStyles(rule, styles); + this.addClass(this.currentDocument.model.documentRoot, "ninja-body"); + } + } + }, /* ----------------- Rule methods ----------------- */ ///// Add Rule @@ -538,7 +570,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { return true; } - var doc = document || this._activeDocument; + var doc = document || this._currentDocument; ///// TODO: somehow cache the number of elements affected ///// by the rule, because querySelectorAll() is expensive return !!(doc.querySelectorAll(rule.selectorText).length > 1); @@ -887,7 +919,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { getAnimationRuleWithName : { value: function(name, document) { - var doc = document || this._activeDocument.model.views.design.document, + var doc = document || this._currentDocument.model.views.design.document, animRules = this.getDocumentAnimationRules(doc), rule, i; @@ -909,7 +941,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { getDocumentAnimationRules : { value: function(document) { - var sheets = (document) ? document.styleSheets : this._activeDocument.model.views.design.document.styleSheets, + var sheets = (document) ? document.styleSheets : this._currentDocument.model.views.design.document.styleSheets, rules = []; nj.toArray(sheets).forEach(function(sheet) { @@ -1272,7 +1304,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { createStylesheet : { value: function(id, document) { - var doc = document || this._activeDocument.model.views.design.document, + var doc = document || this._currentDocument.model.views.design.document, sheetElement, sheet; sheetElement = nj.make('style', { @@ -1329,15 +1361,12 @@ var stylesController = exports.StylesController = Montage.create(Component, { getSheetFromElement : { value : function(element, context) { - var doc = context || this._activeDocument.model.views.design.document, + var doc = context || this._currentDocument.model.views.design.document, el = (typeof element === 'string') ? nj.$(element, doc) : element; if(el && el.sheet) { return el.sheet; } - - return; - } }, @@ -1363,7 +1392,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { ///// If the sheet doesn't already exist in the list of modified ///// sheets, dispatch dirty event and add the sheet to the list if(sheetSearch.length === 0) { - NJevent('styleSheetDirty', eventData); + this.currentDocument.model.needsSave = true; this.dirtyStyleSheets.push({ document : sheet.ownerNode.ownerDocument, stylesheet : sheet @@ -1572,7 +1601,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { getStyleTest : function() { var properties = ['background-position', 'width', 'height']; - var el = stylesController.activeDocument.model.views.design.document.getElementById('Div_1'); + var el = stylesController.currentDocument.model.views.design.document.getElementById('Div_1'); properties.forEach(function(prop) { console.log('Getting value for "' + prop + '": ' + stylesController.getElementStyle(el, prop, true)); @@ -1591,7 +1620,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { }); }, getMatchingRulesTest : function() { - var el = stylesController.activeDocument.model.views.design.document.getElementById('Div_1'), + var el = stylesController.currentDocument.model.views.design.document.getElementById('Div_1'), mRules; this.addRulesTest(); @@ -1606,7 +1635,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { ///// apply a new style using setElementStyle, and print out the new ///// value. - var el = stylesController.activeDocument.model.views.design.document.getElementById('Div_1'), + var el = stylesController.currentDocument.model.views.design.document.getElementById('Div_1'), bg; console.log('----- Set Element Style Test -----'); @@ -1631,14 +1660,14 @@ var stylesController = exports.StylesController = Montage.create(Component, { var rules = ['#UserContent div { background-color: blue }']; rules.forEach(function(rule) { stylesController.addRule(rule); }); - var el = stylesController.activeDocument.model.views.design.document.getElementById('Div_1'); + var el = stylesController.currentDocument.model.views.design.document.getElementById('Div_1'); stylesController.setElementStyle(el, 'color', 'red'); ///// the #Div_1 rule created by tag tool should have the color style }, setElementStyle3Test : function() { ///// First, draw a div onto the stage - var el = stylesController.activeDocument.model.views.design.document.getElementById('Div_1'); + var el = stylesController.currentDocument.model.views.design.document.getElementById('Div_1'); //// now add a multi-target rule overriding the bg color var rules = [ @@ -1655,14 +1684,14 @@ var stylesController = exports.StylesController = Montage.create(Component, { }, setGroupStyleTest : function() { ///// draw 2 divs on stage - var el1 = stylesController.activeDocument.model.views.design.document.getElementById('Div_1'); - var el2 = stylesController.activeDocument.model.views.design.document.getElementById('Div_2'); + var el1 = stylesController.currentDocument.model.views.design.document.getElementById('Div_1'); + var el2 = stylesController.currentDocument.model.views.design.document.getElementById('Div_2'); var dominantRule = stylesController.getDominantRuleForGroup([el1, el2], 'color'); }, setElementStylesTest : function() { ///// draw a div on stage - var el = stylesController.activeDocument.model.views.design.document.getElementById('Div_1'); + var el = stylesController.currentDocument.model.views.design.document.getElementById('Div_1'); mRules = stylesController.getMatchingRules(el, true); mRules.forEach(function(rule) { @@ -1681,7 +1710,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { console.log('----- Create Override Rule Test -----'); - var el = stylesController.activeDocument.model.views.design.document.getElementById('Div_1'), + var el = stylesController.currentDocument.model.views.design.document.getElementById('Div_1'), rule = stylesController.addRule('#UserContent div { background-color: blue }'), override; @@ -1693,7 +1722,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { }, deleteRulesTest : function() { // drag one div on stage - var el = stylesController.activeDocument.model.views.design.document.getElementById('Div_1'); + var el = stylesController.currentDocument.model.views.design.document.getElementById('Div_1'); this.addRulesTest(); mRules = stylesController.getMatchingRules(el, true); @@ -1705,8 +1734,8 @@ var stylesController = exports.StylesController = Montage.create(Component, { matchesElementsExclusivelyTest : function() { /// drag two divs on stage var rule = stylesController.addRule('#Div_1, #Div_3 { color:black; }'); - var el1 = stylesController.activeDocument.model.views.design.document.getElementById('Div_1'); - var el2 = stylesController.activeDocument.model.views.design.document.getElementById('Div_2'); + var el1 = stylesController.currentDocument.model.views.design.document.getElementById('Div_1'); + var el2 = stylesController.currentDocument.model.views.design.document.getElementById('Div_2'); console.log('Does rule match elements exclusively? ' + stylesController.matchesElementsExclusively(rule, [el1, el2])); } diff --git a/js/controllers/undo-controller.js b/js/controllers/undo-controller.js index 19cfb6e6..8514df3d 100755 --- a/js/controllers/undo-controller.js +++ b/js/controllers/undo-controller.js @@ -113,20 +113,12 @@ exports.UndoController = Montage.create( Component, { deserializedFromTemplate: { value: function(){ - this.eventManager.addEventListener( "openDocument", this, false); this.eventManager.addEventListener( "sendToUndo", this, false); this.eventManager.addEventListener( "executeUndo", this, false); this.eventManager.addEventListener( "executeRedo", this, false); } }, - handleOpenDocument: { - value: function(undoQueue, redoQueue) { -// this._undoQueue = undoQueue; -// this._redoQueue = redoQueue; - } - }, - handleSendToUndo: { value: function(event) { this.undoQueue.push(event.detail); diff --git a/js/document/models/text.js b/js/document/models/text.js index d1252b7d..0135b9ba 100755 --- a/js/document/models/text.js +++ b/js/document/models/text.js @@ -22,7 +22,7 @@ exports.TextDocumentModel = Montage.create(BaseDocumentModel, { save: { enumerable: false, value: function (callback) { - this.application.ninja.documentController.activeDocument.model.views.code.editor.save();//save to textarea + this.application.ninja.currentDocument.model.views.code.editor.save();//save to textarea var self = this; diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index f71a6f4d..1d5e9ade 100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js @@ -48,7 +48,7 @@ exports.ElementMediator = Montage.create(Component, { document.application.undoManager.add(undoLabel, this.removeElements, this, elements, notify); - this.application.ninja.documentController.activeDocument.model.needsSave = true; + this.application.ninja.currentDocument.model.needsSave = true; if(notify || notify === undefined) { NJevent("elementAdded", elements); @@ -77,7 +77,7 @@ exports.ElementMediator = Montage.create(Component, { document.application.undoManager.add(undoLabel, this.addElements, this, elements, null, notify); - this.application.ninja.documentController.activeDocument.model.needsSave = true; + this.application.ninja.currentDocument.model.needsSave = true; NJevent("elementsRemoved", elements); } @@ -92,7 +92,7 @@ exports.ElementMediator = Montage.create(Component, { document.application.undoManager.add(undoLabel, this.replaceElement, this, oldChild, newChild); - this.application.ninja.documentController.activeDocument.model.needsSave = true; + this.application.ninja.currentDocument.model.needsSave = true; if(notify || notify === undefined) { NJevent("elementReplaced", {type : "replaceElement", data: {"newChild": newChild, "oldChild": oldChild}}); diff --git a/js/ninja.reel/ninja.html b/js/ninja.reel/ninja.html index 51d74cb2..f2b0a281 100755 --- a/js/ninja.reel/ninja.html +++ b/js/ninja.reel/ninja.html @@ -118,7 +118,7 @@ ] }, - "Resizer": { + "resizer3": { "prototype": "js/panels/resize-composer", "properties": { "element": {"#": "pasteboardResizer"}, @@ -150,45 +150,48 @@ "element": {"#": "stageMode"} }, "bindings" : { - "livePreview": { - "boundObject": {"@": "appModel"}, - "boundObjectPropertyPath": "livePreview", - "oneway": false - } + "livePreview": {"<<->": "@appModel.livePreview"} } }, - "toolsList1": { + "toolsList": { "prototype": "js/components/layout/tools-list.reel", "properties": { "element": {"#": "toolsList"}, "toolsData": {"@": "toolsData1"} + }, + "bindings": { + "currentDocument": {"<-": "@documentList.selectedObjects.0"} } }, - "toolsProperties1": { + "toolsProperties": { "prototype": "js/components/layout/tools-properties.reel", "properties": { "element": {"#": "toolsProperties"}, "toolsData": {"@": "toolsData1"} + }, + "bindings": { + "currentDocument": {"<-": "@documentList.selectedObjects.0"} } }, "documentsTab": { "prototype": "js/components/layout/documents-tab.reel", "properties": { - "element": {"#": "openDocumentsTabComponent"} + "element": {"#": "openDocumentsTabComponent"}, + "contentController": {"@": "documentList"} } }, - "stage1": { + "stage": { "prototype": "js/stage/stage.reel", "properties": { "element": {"#": "stageAndScenesContainer"}, "appModel": {"@": "appModel"} }, "bindings": { - "activeDocument": {"<-": "@documentController1.activeDocument"} + "currentDocument": {"<-": "@documentList.selectedObjects.0"} } }, @@ -196,6 +199,9 @@ "prototype": "js/components/layout/document-bar.reel", "properties": { "element": {"#": "documentBar"} + }, + "bindings": { + "currentDocument": {"<-": "@documentList.selectedObjects.0"} } }, @@ -212,6 +218,9 @@ "element": {"#": "rightPanelContent"}, "panelSplitter": {"@": "splitter3"}, "appModel": {"@": "appModel"} + }, + "bindings" : { + "currentDocument": {"<-": "@documentList.selectedObjects.0"} } }, @@ -221,19 +230,16 @@ "element":{"#" : "breadCrumbComponent"} }, "bindings" : { - "container": { - "boundObject": {"@": "owner"}, - "boundObjectPropertyPath": "currentSelectedContainer", - "oneway": false - } + "container": {"<<->": "@owner.currentSelectedContainer"}, + "currentDocument": {"<-": "@documentList.selectedObjects.0"} } - }, + }, "timeline": { - "prototype": "js/panels/Timeline/TimelinePanel.reel", - "properties": { - "element": {"#": "timelinePanelComponent"} - } + "prototype": "js/panels/Timeline/TimelinePanel.reel", + "properties": { + "element": {"#": "timelinePanelComponent"} + } }, "mouseMediator": { @@ -263,17 +269,28 @@ "prototype": "js/controllers/undo-controller" }, - "selectionController1": { + "selectionController": { "prototype": "js/controllers/selection-controller", "bindings" : { - "selectionContainer": {"<-": "@owner.currentSelectedContainer"} + "selectionContainer": {"<-": "@owner.currentSelectedContainer"}, + "currentDocument": {"<-": "@documentList.selectedObjects.0"} } }, - "documentController1": { + "documentController": { "prototype": "js/controllers/document-controller" }, + "documentList": { + "prototype": "montage/ui/controller/array-controller", + "properties": { + "selectObjectsOnAddition": true + }, + "bindings": { + "content": {"<<->": "@documentController.documents"} + } + }, + "popupManager1": { "prototype": "js/components/popup-manager.reel", "properties": { @@ -288,7 +305,7 @@ "stylesController": { "prototype": "js/controllers/styles-controller", "bindings": { - "activeDocument": {"<-": "@documentController1.activeDocument"} + "currentDocument": {"<-": "@documentList.selectedObjects.0"} } }, @@ -331,14 +348,14 @@ "rulerLeft": {"#": "rulerLeft"}, "appModel": {"@": "appModel"}, "toolsData": {"@": "toolsData1"}, - "toolsList": {"@": "toolsList1"}, - "toolsProperties": {"@": "toolsProperties1"}, - "stage": {"@": "stage1"}, + "toolsList": {"@": "toolsList"}, + "toolsProperties": {"@": "toolsProperties"}, + "stage": {"@": "stage"}, "elementMediator": {"@": "elementMediator"}, "dragDropMediator": {"@": "dragDropMediator"}, "undocontroller": {"@": "undocontroller1"}, - "selectionController": {"@": "selectionController1"}, - "documentController": {"@": "documentController1"}, + "selectionController": {"@": "selectionController"}, + "documentController": {"@": "documentController"}, "popupManager": {"@": "popupManager1"}, "colorController": {"@": "colorController1"}, "stylesController": {"@": "stylesController"}, @@ -356,7 +373,8 @@ "panelSplitter": {"@": "splitter3"}, "timelineSplitter": {"@": "splitter4"}, "toolsSplitter": {"@": "splitter2"}, - "optionsSplitter": {"@": "splitter1"} + "optionsSplitter": {"@": "splitter1"}, + "documentList": {"@": "documentList"} } } } diff --git a/js/ninja.reel/ninja.js b/js/ninja.reel/ninja.js index d0eb1557..0b4fd14d 100755 --- a/js/ninja.reel/ninja.js +++ b/js/ninja.reel/ninja.js @@ -18,12 +18,33 @@ exports.Ninja = Montage.create(Component, { value: null }, - toolsData: { value: null }, - appData: { value: AppData }, + toolsData: { + value: null + }, + + appData: { + value: AppData + }, + /* currentDocument: { value: null }, + */ + + documentList: { + value: null + }, + + currentDocument: { + get: function() { + if(this.documentList.selectedObjects) { + return this.documentList.selectedObjects[0]; + } else { + return null; + } + } + }, _isResizing: { value: null @@ -55,9 +76,10 @@ exports.Ninja = Montage.create(Component, { } }, - _resizedWidth : { + _resizedWidth: { value: 0 }, + _width: { value: null }, @@ -174,7 +196,6 @@ exports.Ninja = Montage.create(Component, { this.eventManager.addEventListener("selectTool", this, false); this.eventManager.addEventListener("selectSubTool", this, false); - this.eventManager.addEventListener("onOpenDocument", this, false); this.eventManager.addEventListener("onSwitchDocument", this, false); this.addPropertyChangeListener("appModel.livePreview", this.executeLivePreview, false); @@ -190,7 +211,7 @@ exports.Ninja = Montage.create(Component, { //TODO: Expand method to allow other browsers for preview executeChromePreview: { value: function () { - this.application.ninja.documentController.activeDocument.model.browserPreview('chrome'); + this.currentDocument.model.browserPreview('chrome'); } }, //////////////////////////////////////////////////////////////////// @@ -276,7 +297,22 @@ exports.Ninja = Montage.create(Component, { }, handleOnOpenDocument: { - value: function(event) { + value: function(doc) { + + + + this.documentList.content.push(doc); + // This is not needed with the latest 0.10