From c58dc96130c7eb5d964af53e9ad6e80bba5e647f Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 18 Apr 2012 17:24:40 -0700 Subject: initial stage web template Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index ddaeb061..e56c3e31 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -10,8 +10,7 @@ var Montage = require("montage/core/core").Montage, Component = require("montage/ui/component").Component, Uuid = require("montage/core/uuid").Uuid, HTMLDocument = require("js/document/html-document").HTMLDocument, - TextDocument = require("js/document/text-document").TextDocument, - DocumentController; + TextDocument = require("js/document/text-document").TextDocument; //////////////////////////////////////////////////////////////////////// // var DocumentController = exports.DocumentController = Montage.create(Component, { @@ -19,6 +18,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component, value: false }, + webTemplate: { + value: false + }, + _documents: { value: [] }, @@ -65,6 +68,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.eventManager.addEventListener("styleSheetDirty", this, false); this.eventManager.addEventListener("addComponentFirstDraw", this, false); + + // Temporary add listeners for the new stage templates + this.eventManager.addEventListener("executeWebpageOpen", this, false); + this.eventManager.addEventListener("executeNewWebpage", this, false); } }, @@ -130,6 +137,20 @@ var DocumentController = exports.DocumentController = Montage.create(Component, } }, + handleExecuteWebpageOpen: { + value: function(event) { + this.webTemplate = true; + this.handleExecuteFileOpen(event); + } + }, + + handleExecuteNewWebpage: { + value: function(event) { + this.webTemplate = true; + this.handleExecuteNewFile(event); + } + }, + handleExecuteNewFile: { value: function(event) { var newFileSettings = event._event.settings || {}; @@ -235,7 +256,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.creatingNewFile = true;//flag for timeline to identify new file flow this.application.ninja.ioMediator.fileOpen(response.uri, this.openFileCallback.bind(this)); - }else if(!!response && !response.success){ + } else if(!!response && !response.success){ //Todo: restrict directory path to the sandbox, in the dialog itself alert("Unable to create file.\n [Error: Forbidden directory]"); } @@ -313,7 +334,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, switch (doc.extension) { case 'html': case 'html': //Open in designer view - Montage.create(HTMLDocument).initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument.bind(this)); + Montage.create(HTMLDocument).initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument.bind(this), this.webTemplate); break; default: //Open in code view @@ -420,6 +441,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, // Event Detail: Contains the current ActiveDocument _onOpenDocument: { value: function(doc){ + this.webTemplate = false; this.application.ninja.currentDocument = doc; this._hideCurrentDocument(); this.application.ninja.stage.stageView.hideOtherDocuments(doc.uuid); -- cgit v1.2.3