aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers')
-rwxr-xr-xjs/controllers/document-controller.js30
1 files changed, 26 insertions, 4 deletions
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,
10 Component = require("montage/ui/component").Component, 10 Component = require("montage/ui/component").Component,
11 Uuid = require("montage/core/uuid").Uuid, 11 Uuid = require("montage/core/uuid").Uuid,
12 HTMLDocument = require("js/document/html-document").HTMLDocument, 12 HTMLDocument = require("js/document/html-document").HTMLDocument,
13 TextDocument = require("js/document/text-document").TextDocument, 13 TextDocument = require("js/document/text-document").TextDocument;
14 DocumentController;
15//////////////////////////////////////////////////////////////////////// 14////////////////////////////////////////////////////////////////////////
16// 15//
17var DocumentController = exports.DocumentController = Montage.create(Component, { 16var DocumentController = exports.DocumentController = Montage.create(Component, {
@@ -19,6 +18,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
19 value: false 18 value: false
20 }, 19 },
21 20
21 webTemplate: {
22 value: false
23 },
24
22 _documents: { 25 _documents: {
23 value: [] 26 value: []
24 }, 27 },
@@ -65,6 +68,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
65 this.eventManager.addEventListener("styleSheetDirty", this, false); 68 this.eventManager.addEventListener("styleSheetDirty", this, false);
66 69
67 this.eventManager.addEventListener("addComponentFirstDraw", this, false); 70 this.eventManager.addEventListener("addComponentFirstDraw", this, false);
71
72 // Temporary add listeners for the new stage templates
73 this.eventManager.addEventListener("executeWebpageOpen", this, false);
74 this.eventManager.addEventListener("executeNewWebpage", this, false);
68 } 75 }
69 }, 76 },
70 77
@@ -130,6 +137,20 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
130 } 137 }
131 }, 138 },
132 139
140 handleExecuteWebpageOpen: {
141 value: function(event) {
142 this.webTemplate = true;
143 this.handleExecuteFileOpen(event);
144 }
145 },
146
147 handleExecuteNewWebpage: {
148 value: function(event) {
149 this.webTemplate = true;
150 this.handleExecuteNewFile(event);
151 }
152 },
153
133 handleExecuteNewFile: { 154 handleExecuteNewFile: {
134 value: function(event) { 155 value: function(event) {
135 var newFileSettings = event._event.settings || {}; 156 var newFileSettings = event._event.settings || {};
@@ -235,7 +256,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
235 this.creatingNewFile = true;//flag for timeline to identify new file flow 256 this.creatingNewFile = true;//flag for timeline to identify new file flow
236 257
237 this.application.ninja.ioMediator.fileOpen(response.uri, this.openFileCallback.bind(this)); 258 this.application.ninja.ioMediator.fileOpen(response.uri, this.openFileCallback.bind(this));
238 }else if(!!response && !response.success){ 259 } else if(!!response && !response.success){
239 //Todo: restrict directory path to the sandbox, in the dialog itself 260 //Todo: restrict directory path to the sandbox, in the dialog itself
240 alert("Unable to create file.\n [Error: Forbidden directory]"); 261 alert("Unable to create file.\n [Error: Forbidden directory]");
241 } 262 }
@@ -313,7 +334,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
313 switch (doc.extension) { 334 switch (doc.extension) {
314 case 'html': case 'html': 335 case 'html': case 'html':
315 //Open in designer view 336 //Open in designer view
316 Montage.create(HTMLDocument).initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument.bind(this)); 337 Montage.create(HTMLDocument).initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument.bind(this), this.webTemplate);
317 break; 338 break;
318 default: 339 default:
319 //Open in code view 340 //Open in code view
@@ -420,6 +441,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
420 // Event Detail: Contains the current ActiveDocument 441 // Event Detail: Contains the current ActiveDocument
421 _onOpenDocument: { 442 _onOpenDocument: {
422 value: function(doc){ 443 value: function(doc){
444 this.webTemplate = false;
423 this.application.ninja.currentDocument = doc; 445 this.application.ninja.currentDocument = doc;
424 this._hideCurrentDocument(); 446 this._hideCurrentDocument();
425 this.application.ninja.stage.stageView.hideOtherDocuments(doc.uuid); 447 this.application.ninja.stage.stageView.hideOtherDocuments(doc.uuid);