aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers')
-rwxr-xr-xjs/controllers/document-controller.js38
1 files changed, 34 insertions, 4 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index 1fcdf6d0..a7aa0de6 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -11,6 +11,9 @@ var Montage = require("montage/core/core").Montage,
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
15 // New Document Objects
16var Document = require("js/document/document-html").HtmlDocument;
14//////////////////////////////////////////////////////////////////////// 17////////////////////////////////////////////////////////////////////////
15// 18//
16var DocumentController = exports.DocumentController = Montage.create(Component, { 19var DocumentController = exports.DocumentController = Montage.create(Component, {
@@ -289,7 +292,12 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
289 this.isNewFilePath = false;//reset path identifier flag 292 this.isNewFilePath = false;//reset path identifier flag
290 293
291 //Sending full response object 294 //Sending full response object
292 this.openDocument(response); 295 // TODO: Unify those 2 methods. Using if/else for the new template
296 if(this.webTemplate) {
297 this.openWebDocument(response);
298 } else {
299 this.openDocument(response);
300 }
293 } else if (!!response && (response.status === 404)){ 301 } else if (!!response && (response.status === 404)){
294 alert("Unable to open file.\n [Error: File does not exist]"); 302 alert("Unable to open file.\n [Error: File does not exist]");
295 } else if (!!response && (response.status === 500)){ 303 } else if (!!response && (response.status === 500)){
@@ -334,7 +342,31 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
334 switch (doc.extension) { 342 switch (doc.extension) {
335 case 'html': 343 case 'html':
336 //Open in designer view 344 //Open in designer view
337 Montage.create(HTMLDocument).initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument.bind(this), this.webTemplate); 345 Montage.create(HTMLDocument).initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument.bind(this));
346 break;
347 default:
348 //Open in code view
349 var code = Montage.create(TextDocument, {"source": {value: doc.content}}), docuuid = Uuid.generate(), textArea;
350 textArea = this.application.ninja.stage.stageView.createTextAreaElement(docuuid);
351 code.initialize(doc, docuuid, textArea, textArea.parentNode);
352 //code.init(doc.name, doc.uri, doc.extension, null, docuuid);
353 code.textArea.value = doc.content;
354 this.application.ninja.stage.stageView.createTextView(code);
355 break;
356 }
357 }
358 },
359 openWebDocument: {
360 value: function(doc) {
361 // TODO: HACKS to remove
362 this.documentHackReference = doc;
363 document.getElementById("iframeContainer").style.overflow = "hidden";
364 //
365 switch (doc.extension) {
366 case 'html':
367 //Open in designer view
368 this._hackRootFlag = false;
369 Montage.create(Document).init(doc, this, this._onOpenDocument);
338 break; 370 break;
339 default: 371 default:
340 //Open in code view 372 //Open in code view
@@ -453,8 +485,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
453 this._showCurrentDocument(); 485 this._showCurrentDocument();
454 486
455 NJevent("onOpenDocument", doc); 487 NJevent("onOpenDocument", doc);
456// appDelegateModule.MyAppDelegate.onSetActiveDocument();
457
458 } 488 }
459 }, 489 },
460 490