From d47c4c0f6053fb8390526f32c2ee08dee0bdec20 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 17 Feb 2012 15:22:23 -0800 Subject: Chrome Preview --- js/controllers/document-controller.js | 3 +-- js/data/menu-data.js | 9 +++++++ js/document/html-document.js | 45 +++++++++++++++++++++++++++++++++++ js/mediators/keyboard-mediator.js | 6 +++++ js/models/app-model.js | 12 ++++++++++ js/ninja.reel/ninja.js | 7 ++++++ 6 files changed, 80 insertions(+), 2 deletions(-) diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 5e2a6461..1f339fe7 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -61,11 +61,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.eventManager.addEventListener("recordStyleChanged", this, false); - - } }, + handleWebRequest: { value: function (request) { diff --git a/js/data/menu-data.js b/js/data/menu-data.js index 6503e776..7c3ca5d4 100755 --- a/js/data/menu-data.js +++ b/js/data/menu-data.js @@ -139,6 +139,15 @@ exports.MenuData = Montage.create( Montage, { "boundProperty": "livePreview" } }, + { + "displayText" : "Chrome Preview", + "hasSubMenu" : false, + "enabled": true, + "checked": { + "value": false, + "boundProperty": "chromePreview" + } + }, { "displayText" : "Layout View", "hasSubMenu" : false, diff --git a/js/document/html-document.js b/js/document/html-document.js index ae2b4600..77cc711d 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -363,6 +363,9 @@ exports.HTMLDocument = Montage.create(TextDocument, { // handleEvent: { value: function(event){ + //TODO: Remove + window.hackPreview = this.livePreview.bind(this); + this.application.ninja.documentController._hackRootFlag = true; //console.log(this._userDocument.root, this); //TODO: Clean up, using for prototyping save @@ -471,6 +474,48 @@ exports.HTMLDocument = Montage.create(TextDocument, { } }, + + + + + + + + + + + + + + + + + + + + + + + //////////////////////////////////////////////////////////////////// + // + livePreview: { + enumerable: false, + value: function () { + //this.application.ninja.documentController + //console.log(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController._activeDocument.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]); + chrome.tabs.create({url: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController._activeDocument.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]}); + } + }, + //////////////////////////////////////////////////////////////////// + + + + + + + + + //////////////////////////////////////////////////////////////////// // save: { diff --git a/js/mediators/keyboard-mediator.js b/js/mediators/keyboard-mediator.js index a1fdead3..e8a11ad8 100755 --- a/js/mediators/keyboard-mediator.js +++ b/js/mediators/keyboard-mediator.js @@ -201,6 +201,12 @@ exports.KeyboardMediator = Montage.create(Component, { if(this.application.ninja.toolsData) this.application.ninja.toolsData.selectedToolInstance.HandleEscape(evt); //menuViewManagerModule.MenuViewManager.closeMenu("mainMenuBar"); } + + // Check if cmd+a/ctrl+a for Select All + if((evt.keyCode == Keyboard.ENTER) && (evt.ctrlKey || evt.metaKey)) { + this.application.ninja.executeChromePreview(); + return; + } if(this.application.ninja.toolsData) this.application.ninja.toolsData.selectedToolInstance.HandleKeyPress(evt); diff --git a/js/models/app-model.js b/js/models/app-model.js index bfa1871c..1c599a32 100755 --- a/js/models/app-model.js +++ b/js/models/app-model.js @@ -21,6 +21,18 @@ exports.AppModel = Montage.create(Component, { this._livePreview = value; } }, + _chromePreview: { + value: false + }, + + chromePreview: { + get: function() { + return this._chromePreview; + }, + set: function(value) { + this._chromePreview = value; + } + }, _layoutView: { value: "layoutAll" diff --git a/js/ninja.reel/ninja.js b/js/ninja.reel/ninja.js index 43087c39..399d7b4d 100755 --- a/js/ninja.reel/ninja.js +++ b/js/ninja.reel/ninja.js @@ -60,11 +60,18 @@ exports.Ninja = Montage.create(Component, { this.eventManager.addEventListener( "onOpenDocument", this, false); this.addEventListener("change@appModel.livePreview", this.executeLivePreview, false); + this.addEventListener("change@appModel.chromePreview", this.executeChromePreview, false); this.addEventListener("change@appModel.debug", this.toggleDebug, false); NJevent("appLoading"); } }, + + executeChromePreview: { + value: function () { + this.application.ninja.documentController.activeDocument.livePreview(); + } + }, handleResize: { value: function() { -- cgit v1.2.3