aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/document-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers/document-controller.js')
-rwxr-xr-xjs/controllers/document-controller.js65
1 files changed, 24 insertions, 41 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index f6b850b2..86b1d057 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -13,7 +13,8 @@ var Montage = require("montage/core/core").Montage,
13 TextDocument = require("js/document/text-document").TextDocument; 13 TextDocument = require("js/document/text-document").TextDocument;
14 14
15 // New Document Objects 15 // New Document Objects
16var Document = require("js/document/document-html").HtmlDocument; 16var Document_HTML = require("js/document/document-html").HtmlDocument;
17var Document_Text = require("js/document/document-text").TextDocument;
17//////////////////////////////////////////////////////////////////////// 18////////////////////////////////////////////////////////////////////////
18// 19//
19var DocumentController = exports.DocumentController = Montage.create(Component, { 20var DocumentController = exports.DocumentController = Montage.create(Component, {
@@ -321,32 +322,30 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
321 322
322 //////////////////////////////////////////////////////////////////// 323 ////////////////////////////////////////////////////////////////////
323 openDocument: { 324 openDocument: {
324 value: function(doc) { 325 value: function(file) {
325 var template, dimensions; 326 var template, dimensions;
326 if (doc.content.body.indexOf('Ninja-Banner Dimensions@@@') !== -1) { 327
327 dimensions = (doc.content.body.split('Ninja-Banner Dimensions@@@'))[1].split('-->')[0].split('x');
328 dimensions = {width: parseInt(dimensions[0]), height: parseInt(dimensions[1])};
329 template = {type: 'banner', size: dimensions};
330 }
331 // TODO: HACKS to remove 328 // TODO: HACKS to remove
332 this.documentHackReference = doc; 329 this.documentHackReference = file;
333 document.getElementById("iframeContainer").style.overflow = "hidden"; 330 document.getElementById("iframeContainer").style.overflow = "hidden";
334 // 331 //
335 switch (doc.extension) { 332 switch (file.extension) {
336 case 'html': 333 case 'html':
334
335 if (file.content.body.indexOf('Ninja-Banner Dimensions@@@') !== -1) {
336 dimensions = (file.content.body.split('Ninja-Banner Dimensions@@@'))[1].split('-->')[0].split('x');
337 dimensions = {width: parseInt(dimensions[0]), height: parseInt(dimensions[1])};
338 template = {type: 'banner', size: dimensions};
339 }
340
337 //Open in designer view 341 //Open in designer view
338 this._hackRootFlag = false; 342 this._hackRootFlag = false;
339 Montage.create(Document).init(doc, this, this._onOpenDocument, 'design', template); 343 Montage.create(Document_HTML).init(file, this, this._onOpenDocument, 'design', template);
340 break; 344 break;
341 default: 345 default:
342 //Open in code view 346 //Open in code view
343 var code = Montage.create(TextDocument, {"source": {value: doc.content}}), docuuid = Uuid.generate(), textArea; 347 Montage.create(Document_Text).init(file, this, this._onOpenTextDocument, 'code');
344 textArea = this.application.ninja.stage.stageView.createTextAreaElement(docuuid); 348 break;
345 code.initialize(doc, docuuid, textArea, textArea.parentNode);
346 //code.init(doc.name, doc.uri, doc.extension, null, docuuid);
347 code.textArea.value = doc.content;
348 this.application.ninja.stage.stageView.createTextView(code);
349 break;
350 } 349 }
351 } 350 }
352 }, 351 },
@@ -513,9 +512,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
513 _onOpenTextDocument: { 512 _onOpenTextDocument: {
514 value: function(doc) { 513 value: function(doc) {
515 if(this.activeDocument) { 514 if(this.activeDocument) {
515
516 if(this.activeDocument.currentView === "design"){ 516 if(this.activeDocument.currentView === "design"){
517 this.activeDocument.saveAppState(); 517 this.activeDocument.saveAppState();
518 this.activeDocument.container.parentNode.style["display"] = "none"; 518 this.activeDocument.parentContainer.style["display"] = "none";
519 this.application.ninja.stage.hideCanvas(true); 519 this.application.ninja.stage.hideCanvas(true);
520 this.application.ninja.stage.stageView.hideRulers(); 520 this.application.ninja.stage.stageView.hideRulers();
521 } 521 }
@@ -525,28 +525,11 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
525 525
526 this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe 526 this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe
527 this.activeDocument = doc; 527 this.activeDocument = doc;
528 528 //hide the iframe when switching to code view
529 var type; 529 document.getElementById("iframeContainer").style.display = "none";
530 530 doc.model.views.code.showCodeViewBar(true);
531 switch(doc.documentType) { 531 this.application.ninja.codeEditorController.applySettings();
532 case "css" : 532 doc.model.views.code.collapseAllPanels();
533 type = "css";
534 break;
535 case "js" :
536 type = "javascript";
537 break;
538 }
539
540 DocumentController._codeEditor.editor = CodeMirror.fromTextArea(doc.textArea, {
541 lineNumbers: true,
542 mode: type,
543 onCursorActivity: function() {
544 DocumentController._codeEditor.editor.setLineClass(DocumentController._codeEditor.hline, null);
545 DocumentController._codeEditor.hline = DocumentController._codeEditor.editor.setLineClass(DocumentController._codeEditor.editor.getCursor().line, "activeline");
546 }
547 });
548 DocumentController._codeEditor.hline = DocumentController._codeEditor.editor.setLineClass(0, "activeline");
549
550 } 533 }
551 }, 534 },
552 535