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/document-controller.js') 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 From e085f15bcef9f84d9a8d39e4b2a1fe2ee73c3f29 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 19 Apr 2012 14:20:17 -0700 Subject: typo fix Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index e56c3e31..1fcdf6d0 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -332,7 +332,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.documentHackReference = doc; // switch (doc.extension) { - case 'html': case 'html': + case 'html': //Open in designer view Montage.create(HTMLDocument).initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument.bind(this), this.webTemplate); break; -- cgit v1.2.3 From c62273126004f057de40ce91ecda5606643f4c92 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 20 Apr 2012 16:37:47 -0700 Subject: reverting old template to current working status. New template work. Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 38 +++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) (limited to 'js/controllers/document-controller.js') 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, Uuid = require("montage/core/uuid").Uuid, HTMLDocument = require("js/document/html-document").HTMLDocument, TextDocument = require("js/document/text-document").TextDocument; + + // New Document Objects +var Document = require("js/document/document-html").HtmlDocument; //////////////////////////////////////////////////////////////////////// // var DocumentController = exports.DocumentController = Montage.create(Component, { @@ -289,7 +292,12 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.isNewFilePath = false;//reset path identifier flag //Sending full response object - this.openDocument(response); + // TODO: Unify those 2 methods. Using if/else for the new template + if(this.webTemplate) { + this.openWebDocument(response); + } else { + this.openDocument(response); + } } else if (!!response && (response.status === 404)){ alert("Unable to open file.\n [Error: File does not exist]"); } else if (!!response && (response.status === 500)){ @@ -334,7 +342,31 @@ var DocumentController = exports.DocumentController = Montage.create(Component, switch (doc.extension) { case 'html': //Open in designer view - Montage.create(HTMLDocument).initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument.bind(this), this.webTemplate); + Montage.create(HTMLDocument).initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument.bind(this)); + break; + default: + //Open in code view + var code = Montage.create(TextDocument, {"source": {value: doc.content}}), docuuid = Uuid.generate(), textArea; + textArea = this.application.ninja.stage.stageView.createTextAreaElement(docuuid); + code.initialize(doc, docuuid, textArea, textArea.parentNode); + //code.init(doc.name, doc.uri, doc.extension, null, docuuid); + code.textArea.value = doc.content; + this.application.ninja.stage.stageView.createTextView(code); + break; + } + } + }, + openWebDocument: { + value: function(doc) { + // TODO: HACKS to remove + this.documentHackReference = doc; + document.getElementById("iframeContainer").style.overflow = "hidden"; + // + switch (doc.extension) { + case 'html': + //Open in designer view + this._hackRootFlag = false; + Montage.create(Document).init(doc, this, this._onOpenDocument); break; default: //Open in code view @@ -453,8 +485,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this._showCurrentDocument(); NJevent("onOpenDocument", doc); -// appDelegateModule.MyAppDelegate.onSetActiveDocument(); - } }, -- cgit v1.2.3 From 3f8f224170937d498d3a03c706494408a6b4bf1d Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Mon, 23 Apr 2012 13:47:35 -0700 Subject: Temporary fix for the PI and Stage when opening the new template. Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index a7aa0de6..4be0767a 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -473,7 +473,6 @@ 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); @@ -482,7 +481,11 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.activeDocument = doc; - this._showCurrentDocument(); + if(!this.webTemplate) { + this._showCurrentDocument(); + } + + this.webTemplate = false; NJevent("onOpenDocument", doc); } @@ -578,7 +581,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.application.ninja.stage.stageView.showRulers(); }else{ //hide the iframe when switching to code view - document.getElementById("iframeContainer").style.display="none"; + document.getElementById("iframeContainer").style.display = "none"; } } } -- cgit v1.2.3