From 3a754133dbc138390503341fd2e9beba3e43aa4b Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 27 Jan 2012 12:05:17 -0800 Subject: Merged old FileIO --- js/controllers/color-controller.js | 0 js/controllers/elements/block-controller.js | 0 js/controllers/elements/canvas-controller.js | 0 js/controllers/elements/component-controller.js | 0 js/controllers/elements/controller-factory.js | 0 js/controllers/elements/element-controller.js | 0 js/controllers/elements/image-controller.js | 0 js/controllers/elements/shapes-controller.js | 0 js/controllers/elements/stage-controller.js | 0 js/controllers/elements/video-controller.js | 0 js/controllers/local-storage-controller.js | 0 js/controllers/selection-controller.js | 0 js/controllers/styles-controller.js | 0 js/controllers/undo-controller.js | 0 14 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 js/controllers/color-controller.js mode change 100644 => 100755 js/controllers/elements/block-controller.js mode change 100644 => 100755 js/controllers/elements/canvas-controller.js mode change 100644 => 100755 js/controllers/elements/component-controller.js mode change 100644 => 100755 js/controllers/elements/controller-factory.js mode change 100644 => 100755 js/controllers/elements/element-controller.js mode change 100644 => 100755 js/controllers/elements/image-controller.js mode change 100644 => 100755 js/controllers/elements/shapes-controller.js mode change 100644 => 100755 js/controllers/elements/stage-controller.js mode change 100644 => 100755 js/controllers/elements/video-controller.js mode change 100644 => 100755 js/controllers/local-storage-controller.js mode change 100644 => 100755 js/controllers/selection-controller.js mode change 100644 => 100755 js/controllers/styles-controller.js mode change 100644 => 100755 js/controllers/undo-controller.js (limited to 'js/controllers') diff --git a/js/controllers/color-controller.js b/js/controllers/color-controller.js old mode 100644 new mode 100755 diff --git a/js/controllers/elements/block-controller.js b/js/controllers/elements/block-controller.js old mode 100644 new mode 100755 diff --git a/js/controllers/elements/canvas-controller.js b/js/controllers/elements/canvas-controller.js old mode 100644 new mode 100755 diff --git a/js/controllers/elements/component-controller.js b/js/controllers/elements/component-controller.js old mode 100644 new mode 100755 diff --git a/js/controllers/elements/controller-factory.js b/js/controllers/elements/controller-factory.js old mode 100644 new mode 100755 diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js old mode 100644 new mode 100755 diff --git a/js/controllers/elements/image-controller.js b/js/controllers/elements/image-controller.js old mode 100644 new mode 100755 diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js old mode 100644 new mode 100755 diff --git a/js/controllers/elements/stage-controller.js b/js/controllers/elements/stage-controller.js old mode 100644 new mode 100755 diff --git a/js/controllers/elements/video-controller.js b/js/controllers/elements/video-controller.js old mode 100644 new mode 100755 diff --git a/js/controllers/local-storage-controller.js b/js/controllers/local-storage-controller.js old mode 100644 new mode 100755 diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js old mode 100644 new mode 100755 diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js old mode 100644 new mode 100755 diff --git a/js/controllers/undo-controller.js b/js/controllers/undo-controller.js old mode 100644 new mode 100755 -- cgit v1.2.3 From 0dca2755c07f9928e9d9b0b7feace48edf969900 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 27 Jan 2012 15:05:27 -0800 Subject: Updated canvas controller to override setProperties so we don't set styles when updating width and height. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/canvas-controller.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'js/controllers') diff --git a/js/controllers/elements/canvas-controller.js b/js/controllers/elements/canvas-controller.js index 7af7e824..21de9879 100755 --- a/js/controllers/elements/canvas-controller.js +++ b/js/controllers/elements/canvas-controller.js @@ -33,5 +33,13 @@ exports.CanvasController = Montage.create(ElementController, { ElementController.setProperty(el, p, value); } } + }, + + setProperties: { + value: function(el, props, index) { + for(var p in props) { + el.elementModel.controller.setProperty(el, p, props[p][index]); + } + } } }); \ No newline at end of file -- cgit v1.2.3 From d26a13de2aca25c36cb35f85604de1ac2b9befbb Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 1 Feb 2012 14:37:30 -0800 Subject: Simple button native widget test. Added a controller, pi and panel code. Signed-off-by: Valerio Virgillito --- js/controllers/elements/component-controller.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'js/controllers') diff --git a/js/controllers/elements/component-controller.js b/js/controllers/elements/component-controller.js index 458e6b46..7a8acb3a 100644 --- a/js/controllers/elements/component-controller.js +++ b/js/controllers/elements/component-controller.js @@ -9,4 +9,27 @@ var Montage = require("montage/core/core").Montage, exports.ComponentController = Montage.create(ElementController, { + getProperty: { + value: function(el, prop) { + switch(prop) { + case "label": + return this.application.ninja.currentDocument.getComponentFromElement(el).label; + break; + default: + return ElementController.getProperty(el, prop); + } + } + }, + + setProperty: { + value: function(el, p, value) { + switch(p) { + case "label": + this.application.ninja.currentDocument.getComponentFromElement(el).label = value; + break; + default: + ElementController.setProperty(el, p, value); + } + } + } }); -- cgit v1.2.3 From dbd3a60478db35b0b12baa2ca54a0712d880951f Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 3 Feb 2012 15:50:35 -0800 Subject: button component using json data Signed-off-by: Valerio Virgillito --- js/controllers/elements/component-controller.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'js/controllers') diff --git a/js/controllers/elements/component-controller.js b/js/controllers/elements/component-controller.js index 7a8acb3a..1b0591be 100644 --- a/js/controllers/elements/component-controller.js +++ b/js/controllers/elements/component-controller.js @@ -15,8 +15,11 @@ exports.ComponentController = Montage.create(ElementController, { case "label": return this.application.ninja.currentDocument.getComponentFromElement(el).label; break; + case "enabled": + return this.application.ninja.currentDocument.getComponentFromElement(el).enabled; + break; default: - return ElementController.getProperty(el, prop); + return ElementController.getProperty(el, prop, true); } } }, @@ -27,6 +30,9 @@ exports.ComponentController = Montage.create(ElementController, { case "label": this.application.ninja.currentDocument.getComponentFromElement(el).label = value; break; + case "enabled": + this.application.ninja.currentDocument.getComponentFromElement(el).enabled = value; + break; default: ElementController.setProperty(el, p, value); } -- cgit v1.2.3 From 47df0aff81c25334b129047bb227ea5015357eda Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 9 Feb 2012 16:22:03 -0800 Subject: Setting defaults and more cleanup Signed-off-by: Valerio Virgillito --- js/controllers/elements/component-controller.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'js/controllers') diff --git a/js/controllers/elements/component-controller.js b/js/controllers/elements/component-controller.js index 1b0591be..33b9b79a 100644 --- a/js/controllers/elements/component-controller.js +++ b/js/controllers/elements/component-controller.js @@ -18,6 +18,12 @@ exports.ComponentController = Montage.create(ElementController, { case "enabled": return this.application.ninja.currentDocument.getComponentFromElement(el).enabled; break; + case "disabled": + return this.application.ninja.currentDocument.getComponentFromElement(el).disabled; + break; + case "value": + return this.application.ninja.currentDocument.getComponentFromElement(el).value; + break; default: return ElementController.getProperty(el, prop, true); } @@ -33,6 +39,12 @@ exports.ComponentController = Montage.create(ElementController, { case "enabled": this.application.ninja.currentDocument.getComponentFromElement(el).enabled = value; break; + case "disabled": + this.application.ninja.currentDocument.getComponentFromElement(el).disabled = value; + break; + case "value": + this.application.ninja.currentDocument.getComponentFromElement(el).value = value; + break; default: ElementController.setProperty(el, p, value); } -- cgit v1.2.3 From 632a5daca17acb774b9344ccc0e9107f1643924c Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 10 Feb 2012 15:29:12 -0800 Subject: File Open Adding the functionality to open a basic file. --- js/controllers/document-controller.js | 440 ++++++++++++++++++++++++++++++++++ 1 file changed, 440 insertions(+) create mode 100755 js/controllers/document-controller.js (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js new file mode 100755 index 00000000..22467b44 --- /dev/null +++ b/js/controllers/document-controller.js @@ -0,0 +1,440 @@ +/* +This file contains proprietary software owned by Motorola Mobility, Inc.
+No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ + +//////////////////////////////////////////////////////////////////////// +// +var Montage = require("montage/core/core").Montage, + Component = require("montage/ui/component").Component, + Uuid = require("montage/core/uuid").Uuid, + HTMLDocument = require("js/io/document/html-document").HTMLDocument, + TextDocument = require("js/io/document/text-document").TextDocument, + DocumentController; +//////////////////////////////////////////////////////////////////////// +// +DocumentController = exports.DocumentController = Montage.create(Component, { + hasTemplate: { + value: false + }, + + _documents: { + value: [] + }, + + _activeDocument: { value: null }, + _iframeCounter: { value: 1, enumerable: false }, + _iframeHolder: { value: null, enumerable: false }, + _textHolder: { value: null, enumerable: false }, + _codeMirrorCounter: {value: 1, enumerable: false}, + + tmpSourceForTesting: { + value: "function CodeMirror(place, givenOptions) {" + + "// Determine effective options based on given values and defaults." + + "var options = {}, defaults = CodeMirror.defaults; }" + }, + + activeDocument: { + get: function() { + return this._activeDocument; + }, + set: function(doc) { + if(this._activeDocument) this._activeDocument.isActive = false; + + if(this._documents.indexOf(doc) === -1) this._documents.push(doc); + + this._activeDocument = doc; + this._activeDocument.isActive = true; + + if(!!this._activeDocument.editor){ + this._activeDocument.editor.focus(); + } + + } + }, + + deserializedFromTemplate: { + value: function() { + this.eventManager.addEventListener("appLoaded", this, false); + this.eventManager.addEventListener("executeFileOpen", this, false); + this.eventManager.addEventListener("executeNewFile", this, false); + this.eventManager.addEventListener("executeSave", this, false); + + this.eventManager.addEventListener("recordStyleChanged", this, false); + + // Temporary testing opening a new file after Ninja has loaded + this.eventManager.addEventListener("executeNewProject", this, false); + } + }, + + handleAppLoaded: { + value: function() { + //this.openDocument({"type": "html"}); + } + }, + + handleExecuteNewProject: { + value: function() { + this.openDocument({"type": "html"}); + } + }, + + handleExecuteFileOpen: { + value: function(event) { + var pickerSettings = event._event.settings || {}; + pickerSettings.callback = this.openFileWithURI.bind(this); + pickerSettings.pickerMode = "read"; + pickerSettings.inFileMode = true; + this.application.ninja.filePickerController.showFilePicker(pickerSettings); + } + }, + + handleExecuteNewFile: { + value: function(event) { + var newFileSettings = event._event.settings || {}; + newFileSettings.callback = this.createNewFile.bind(this); + this.application.ninja.newFileController.showNewFileDialog(newFileSettings); + } + }, + + handleExecuteSave: { + value: function(event) { + this.activeDocument.save(); + } + }, + + createNewFile:{ + value:function(newFileObj){ + //console.log(newFileObj);//contains the template uri and the new file uri + if(!newFileObj) return; + this.application.ninja.ioMediator.fileNew(newFileObj.newFilePath, newFileObj.fileTemplateUri, this.openNewFileCallback.bind(this)); + + if((newFileObj.fileExtension !== ".html") && (newFileObj.fileExtension !== ".htm")){//open code view + + } else { + //open design view + } + } + }, + + /** + * Public method + * doc contains: + * type : file type, like js, css, etc + * name : file name + * source : file content + * uri : file uri + */ + openNewFileCallback:{ + value:function(doc){ + var response = doc || null;//default just for testing + if(!!response && response.success && !!response.uri){ + this.application.ninja.ioMediator.fileOpen(response.uri, this.openFileCallback.bind(this)); + } + } + }, + + openFileWithURI: { + value: function(uriArrayObj) { + var uri = "", fileContent = "", response=null, filename="", fileType="js"; + if(!!uriArrayObj && !!uriArrayObj.uri && (uriArrayObj.uri.length > 0)){ + uri = uriArrayObj.uri[0]; + } + //console.log("URI is: ", uri); + if(!!uri){ + this.application.ninja.ioMediator.fileOpen(uri, this.openFileCallback.bind(this)); + } + } + }, + + //////////////////////////////////////////////////////////////////// + // + openFileCallback:{ + value:function(response){ + //TODO: Add UI to handle error codes, shouldn't be alert windows + if(!!response && (response.status === 204)) { + //Sending full response object + 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)){ + alert("Unable to open file.\n Check if Ninja Local Cloud is running."); + } else{ + alert("Unable to open file."); + } + + } + }, + //////////////////////////////////////////////////////////////////// + // + openDocument: { + value: function(doc) { + // + switch (doc.extension) { + case 'html': case 'html': + //Open in designer view + Montage.create(HTMLDocument).initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument); + break; + default: + //Open in code view + break; + } + + return; + + + + + + var newDoc; + + if(!doc) return false; + + // try { + if (doc.type === 'html' || doc.type === 'htm') { + console.log('hello'); + newDoc = Montage.create(HTMLDocument); + newDoc.initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument); + } else { + newDoc = Montage.create(TextDocument, { + "source": { value: doc.source } + }); + var docUuid = Uuid.generate(); + var textArea = this.application.ninja.stage.stageView.createTextAreaElement(docUuid); + newDoc.initialize(doc, docUuid, textArea, textArea.parentNode); + + // Tmp this will be filled with the real content + newDoc.textArea.value = doc.source; //this.tmpSourceForTesting; + + this.textDocumentOpened(newDoc); + + } + + // } catch (err) { + // console.log("Could not open Document ", err); + // } + } + }, + //////////////////////////////////////////////////////////////////// + + openProjectWithURI: { + value: function(uri) { + console.log("URI is: ", uri); + } + }, + + textDocumentOpened: { + value: function(doc) { + + + + this.application.ninja.stage.stageView.createTextView(doc); + + /* + DocumentManager._hideCurrentDocument(); + stageManagerModule.stageManager._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe + DocumentManager.activeDocument = doc; + + var type; + + switch(doc.documentType) { + case "css" : + type = "css"; + break; + case "js" : + type = "javascript"; + break; + } + + DocumentManager._codeEditor.editor = CodeMirror.fromTextArea(doc.textArea, { + lineNumbers: true, + mode: type, + onCursorActivity: function() { + DocumentManager._codeEditor.editor.setLineClass(DocumentManager._codeEditor.hline, null); + DocumentManager._codeEditor.hline = DocumentManager._codeEditor.editor.setLineClass(DocumentManager._codeEditor.editor.getCursor().line, "activeline"); + } + }); + DocumentManager._codeEditor.hline = DocumentManager._codeEditor.editor.setLineClass(0, "activeline"); + */ + + } + }, + + closeDocument: { + value: function(id) { + if(this.activeDocument.dirtyFlag === true){ + //if file dirty then alert user to save + } + + var doc = this._findDocumentByUUID(id); + this._removeDocumentView(doc.container); + + var closeDocumentIndex = this._findIndexByUUID(id); + this._documents.splice(this._findIndexByUUID(id), 1); + + if(this.activeDocument.uuid === id && this._documents.length > 0) { + var nextDocumentIndex = -1 ; + if((this._documents.length > 0) && (closeDocumentIndex === 0)){ + nextDocumentIndex = 1; + }else if((this._documents.length > 0) && (closeDocumentIndex > 0)){ + nextDocumentIndex = closeDocumentIndex - 1; + } + this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]); + } + } + }, + + // Document has been loaded into the Iframe. Dispatch the event. + // Event Detail: Contains the current ActiveDocument + _onOpenDocument: { + value: function(doc){ + //var data = DocumentManager.activeDocument; + //DocumentManager._hideCurrentDocument(); + + //stageManagerModule.stageManager.toggleCanvas(); + + DocumentController.activeDocument = doc; + + NJevent("onOpenDocument", doc); +// appDelegateModule.MyAppDelegate.onSetActiveDocument(); + + } + }, + + + _onOpenTextDocument: { + value: function(doc) { + this._hideCurrentDocument(); + this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe + this.activeDocument = doc; + + var type; + + switch(doc.documentType) { + case "css" : + type = "css"; + break; + case "js" : + type = "javascript"; + break; + } + + DocumentController._codeEditor.editor = CodeMirror.fromTextArea(doc.textArea, { + lineNumbers: true, + mode: type, + onCursorActivity: function() { + DocumentController._codeEditor.editor.setLineClass(DocumentController._codeEditor.hline, null); + DocumentController._codeEditor.hline = DocumentController._codeEditor.editor.setLineClass(DocumentController._codeEditor.editor.getCursor().line, "activeline"); + } + }); + DocumentController._codeEditor.hline = DocumentController._codeEditor.editor.setLineClass(0, "activeline"); + + } + }, + + /** + * VIEW Related Methods + */ + // PUBLIC + ShowActiveDocument: { + value: function() { + this.activeDocument.iframe.style.opacity = 1.0; + } + }, + + // PRIVATE + _findDocumentByUUID: { + value: function(uuid) { + var len = this._documents.length; + for(var i = 0; i < len; i++) { + if(this._documents[i].uuid === uuid) return this._documents[i]; + } + + return false; + } + }, + + _findIndexByUUID: { + value: function(uuid) { + var len = this._documents.length; + for(var i = 0; i < len; i++) { + if(this._documents[i].uuid === uuid) return i; + } + + return false; + } + }, + + _hideCurrentDocument: { + value: function() { + if(this.activeDocument) { + if(this.activeDocument.currentView === "design"){ + this.application.ninja.stage.saveScroll(); + this.activeDocument.container.parentNode.style["display"] = "none"; + this.application.ninja.stage.hideCanvas(true); + this.application.ninja.stage.stageView.hideRulers(); + } + + this.activeDocument.container.style["display"] = "none"; + } + } + }, + + _showCurrentDocument: { + value: function() { + if(this.activeDocument) { + this.activeDocument.container.style["display"] = "block"; + if(this.activeDocument.currentView === "design"){ + this.activeDocument.container.parentNode.style["display"] = "block"; + this.application.ninja.stage.restoreScroll(); + this.application.ninja.stage.hideCanvas(false); + this.application.ninja.stage.stageView.showRulers(); + }else{ + //hide the iframe when switching to code view + document.getElementById("iframeContainer").style.display="none"; + } + } + } + }, + + _removeDocumentView: { + value: function(node) { + node.parentNode.removeChild(node); + } + }, + + reloadDocumentContent: { + value: function() { + this.activeDocument._window.location.reload(); + } + }, + + /** + * Creates a new iFrame element using a new unique ID for it. Returns the iframe ID. + */ + _createIframeElement: { + value: function() { + var e = document.createElement("iframe"); + e.id = this._createIframeID(); + e.style.border = "none"; + e.style.opacity = 0; + e.height = 1000; + e.width = 2000; + e.src = ""; + + if(!this._iframeHolder) this._iframeHolder = document.getElementById("iframeContainer"); + + this._iframeHolder.appendChild(e); + + return e; + } + }, + + + _createIframeID: { + value: function() { + return "userDocument_" + (this._iframeCounter++); + } + } +}); -- cgit v1.2.3 From c48eeb01bd726895dc577d8b843b2a75883eee07 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Fri, 10 Feb 2012 16:03:52 -0800 Subject: Merge from /joseeight/ninja-internal/tree/FileIO Signed-off-by: Ananya Sen --- js/controllers/document-controller.js | 443 ++++++++++++++++++++++++++++++++++ js/controllers/styles-controller.js | 4 + 2 files changed, 447 insertions(+) create mode 100755 js/controllers/document-controller.js (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js new file mode 100755 index 00000000..a6228a55 --- /dev/null +++ b/js/controllers/document-controller.js @@ -0,0 +1,443 @@ +/* +This file contains proprietary software owned by Motorola Mobility, Inc.
+No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ + +//////////////////////////////////////////////////////////////////////// +// +var Montage = require("montage/core/core").Montage, + Component = require("montage/ui/component").Component, + Uuid = require("montage/core/uuid").Uuid, + HTMLDocument = require("js/io/document/html-document").HTMLDocument, + TextDocument = require("js/io/document/text-document").TextDocument, + DocumentController; +//////////////////////////////////////////////////////////////////////// +// +DocumentController = exports.DocumentController = Montage.create(Component, { + hasTemplate: { + value: false + }, + + _documents: { + value: [] + }, + + _activeDocument: { value: null }, + _iframeCounter: { value: 1, enumerable: false }, + _iframeHolder: { value: null, enumerable: false }, + _textHolder: { value: null, enumerable: false }, + _codeMirrorCounter: {value: 1, enumerable: false}, + + tmpSourceForTesting: { + value: "function CodeMirror(place, givenOptions) {" + + "// Determine effective options based on given values and defaults." + + "var options = {}, defaults = CodeMirror.defaults; }" + }, + + activeDocument: { + get: function() { + return this._activeDocument; + }, + set: function(doc) { + if(this._activeDocument) this._activeDocument.isActive = false; + + if(this._documents.indexOf(doc) === -1) this._documents.push(doc); + + this._activeDocument = doc; + this._activeDocument.isActive = true; + + if(!!this._activeDocument.editor){ + this._activeDocument.editor.focus(); + } + + } + }, + + deserializedFromTemplate: { + value: function() { + this.eventManager.addEventListener("appLoaded", this, false); + this.eventManager.addEventListener("executeFileOpen", this, false); + this.eventManager.addEventListener("executeNewFile", this, false); + this.eventManager.addEventListener("executeSave", this, false); + + this.eventManager.addEventListener("recordStyleChanged", this, false); + + // Temporary testing opening a new file after Ninja has loaded + this.eventManager.addEventListener("executeNewProject", this, false); + } + }, + + handleAppLoaded: { + value: function() { + //this.openDocument({"type": "html"}); + } + }, + + handleExecuteNewProject: { + value: function() { + this.openDocument({"type": "html"}); + } + }, + + handleExecuteFileOpen: { + value: function(event) { + var pickerSettings = event._event.settings || {}; + pickerSettings.callback = this.openFileWithURI.bind(this); + pickerSettings.pickerMode = "read"; + pickerSettings.inFileMode = true; + this.application.ninja.filePickerController.showFilePicker(pickerSettings); + } + }, + + handleExecuteNewFile: { + value: function(event) { + var newFileSettings = event._event.settings || {}; + newFileSettings.callback = this.createNewFile.bind(this); + this.application.ninja.newFileController.showNewFileDialog(newFileSettings); + } + }, + + handleExecuteSave: { + value: function(event) { + this.activeDocument.save(); + } + }, + + createNewFile:{ + value:function(newFileObj){ + //console.log(newFileObj);//contains the template uri and the new file uri + if(!newFileObj) return; + this.application.ninja.ioMediator.fileNew(newFileObj.newFilePath, newFileObj.fileTemplateUri, this.openNewFileCallback.bind(this)); + + if((newFileObj.fileExtension !== ".html") && (newFileObj.fileExtension !== ".htm")){//open code view + + } else { + //open design view + } + } + }, + + /** + * Public method + * doc contains: + * type : file type, like js, css, etc + * name : file name + * source : file content + * uri : file uri + */ + openNewFileCallback:{ + value:function(doc){ + var response = doc || null;//default just for testing + if(!!response && response.success && !!response.uri){ + this.application.ninja.ioMediator.fileOpen(response.uri, this.openFileCallback.bind(this)); + } + } + }, + + openFileWithURI: { + value: function(uriArrayObj) { + var uri = "", fileContent = "", response=null, filename="", fileType="js"; + if(!!uriArrayObj && !!uriArrayObj.uri && (uriArrayObj.uri.length > 0)){ + uri = uriArrayObj.uri[0]; + } + //console.log("URI is: ", uri); + if(!!uri){ + this.application.ninja.ioMediator.fileOpen(uri, this.openFileCallback.bind(this)); + } + } + }, + + //////////////////////////////////////////////////////////////////// + // + openFileCallback:{ + value:function(response){ + //TODO: Add UI to handle error codes, shouldn't be alert windows + if(!!response && (response.status === 204)) { + //Sending full response object + 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)){ + alert("Unable to open file.\n Check if Ninja Local Cloud is running."); + } else{ + alert("Unable to open file."); + } + + } + }, + //////////////////////////////////////////////////////////////////// + // + openDocument: { + value: function(doc) { + // + switch (doc.extension) { + case 'html': case 'html': + //Open in designer view + Montage.create(HTMLDocument).initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument); + break; + default: + //Open in code view + break; + } + + return; + + + + + + var newDoc; + + if(!doc) return false; + + // try { + if (doc.type === 'html' || doc.type === 'htm') { + console.log('hello'); + newDoc = Montage.create(HTMLDocument); + newDoc.initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument); + } else { + newDoc = Montage.create(TextDocument, { + "source": { value: doc.source } + }); + var docUuid = Uuid.generate(); + var textArea = this.application.ninja.stage.stageView.createTextAreaElement(docUuid); + newDoc.initialize(doc, docUuid, textArea, textArea.parentNode); + + // Tmp this will be filled with the real content + newDoc.textArea.value = doc.source; //this.tmpSourceForTesting; + + this.textDocumentOpened(newDoc); + + } + + // } catch (err) { + // console.log("Could not open Document ", err); + // } + } + }, + //////////////////////////////////////////////////////////////////// + + openProjectWithURI: { + value: function(uri) { + console.log("URI is: ", uri); + } + }, + + textDocumentOpened: { + value: function(doc) { + + + + this.application.ninja.stage.stageView.createTextView(doc); + + /* + DocumentManager._hideCurrentDocument(); + stageManagerModule.stageManager._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe + DocumentManager.activeDocument = doc; + + var type; + + switch(doc.documentType) { + case "css" : + type = "css"; + break; + case "js" : + type = "javascript"; + break; + } + + DocumentManager._codeEditor.editor = CodeMirror.fromTextArea(doc.textArea, { + lineNumbers: true, + mode: type, + onCursorActivity: function() { + DocumentManager._codeEditor.editor.setLineClass(DocumentManager._codeEditor.hline, null); + DocumentManager._codeEditor.hline = DocumentManager._codeEditor.editor.setLineClass(DocumentManager._codeEditor.editor.getCursor().line, "activeline"); + } + }); + DocumentManager._codeEditor.hline = DocumentManager._codeEditor.editor.setLineClass(0, "activeline"); + */ + + } + }, + + closeDocument: { + value: function(id) { + if(this.activeDocument.dirtyFlag === true){ + //if file dirty then alert user to save + } + + var doc = this._findDocumentByUUID(id); + this._removeDocumentView(doc.container); + + var closeDocumentIndex = this._findIndexByUUID(id); + this._documents.splice(this._findIndexByUUID(id), 1); + + if(this.activeDocument.uuid === id && this._documents.length > 0) { + var nextDocumentIndex = -1 ; + if((this._documents.length > 0) && (closeDocumentIndex === 0)){ + nextDocumentIndex = 1; + }else if((this._documents.length > 0) && (closeDocumentIndex > 0)){ + nextDocumentIndex = closeDocumentIndex - 1; + } + this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]); + }else{ + //if there are no documents to switch to then just show the iframeContainer + document.getElementById("iframeContainer").style.display="block"; + } + } + }, + + // Document has been loaded into the Iframe. Dispatch the event. + // Event Detail: Contains the current ActiveDocument + _onOpenDocument: { + value: function(doc){ + //var data = DocumentManager.activeDocument; + //DocumentManager._hideCurrentDocument(); + + //stageManagerModule.stageManager.toggleCanvas(); + + DocumentController.activeDocument = doc; + + NJevent("onOpenDocument", doc); +// appDelegateModule.MyAppDelegate.onSetActiveDocument(); + + } + }, + + + _onOpenTextDocument: { + value: function(doc) { + this._hideCurrentDocument(); + this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe + this.activeDocument = doc; + + var type; + + switch(doc.documentType) { + case "css" : + type = "css"; + break; + case "js" : + type = "javascript"; + break; + } + + DocumentController._codeEditor.editor = CodeMirror.fromTextArea(doc.textArea, { + lineNumbers: true, + mode: type, + onCursorActivity: function() { + DocumentController._codeEditor.editor.setLineClass(DocumentController._codeEditor.hline, null); + DocumentController._codeEditor.hline = DocumentController._codeEditor.editor.setLineClass(DocumentController._codeEditor.editor.getCursor().line, "activeline"); + } + }); + DocumentController._codeEditor.hline = DocumentController._codeEditor.editor.setLineClass(0, "activeline"); + + } + }, + + /** + * VIEW Related Methods + */ + // PUBLIC + ShowActiveDocument: { + value: function() { + this.activeDocument.iframe.style.opacity = 1.0; + } + }, + + // PRIVATE + _findDocumentByUUID: { + value: function(uuid) { + var len = this._documents.length; + for(var i = 0; i < len; i++) { + if(this._documents[i].uuid === uuid) return this._documents[i]; + } + + return false; + } + }, + + _findIndexByUUID: { + value: function(uuid) { + var len = this._documents.length; + for(var i = 0; i < len; i++) { + if(this._documents[i].uuid === uuid) return i; + } + + return false; + } + }, + + _hideCurrentDocument: { + value: function() { + if(this.activeDocument) { + if(this.activeDocument.currentView === "design"){ + this.application.ninja.stage.saveScroll(); + this.activeDocument.container.parentNode.style["display"] = "none"; + this.application.ninja.stage.hideCanvas(true); + this.application.ninja.stage.stageView.hideRulers(); + } + + this.activeDocument.container.style["display"] = "none"; + } + } + }, + + _showCurrentDocument: { + value: function() { + if(this.activeDocument) { + this.activeDocument.container.style["display"] = "block"; + if(this.activeDocument.currentView === "design"){ + this.activeDocument.container.parentNode.style["display"] = "block"; + this.application.ninja.stage.restoreScroll(); + this.application.ninja.stage.hideCanvas(false); + this.application.ninja.stage.stageView.showRulers(); + }else{ + //hide the iframe when switching to code view + document.getElementById("iframeContainer").style.display="none"; + } + } + } + }, + + _removeDocumentView: { + value: function(node) { + node.parentNode.removeChild(node); + } + }, + + reloadDocumentContent: { + value: function() { + this.activeDocument._window.location.reload(); + } + }, + + /** + * Creates a new iFrame element using a new unique ID for it. Returns the iframe ID. + */ + _createIframeElement: { + value: function() { + var e = document.createElement("iframe"); + e.id = this._createIframeID(); + e.style.border = "none"; + e.style.opacity = 0; + e.height = 1000; + e.width = 2000; + e.src = ""; + + if(!this._iframeHolder) this._iframeHolder = document.getElementById("iframeContainer"); + + this._iframeHolder.appendChild(e); + + return e; + } + }, + + + _createIframeID: { + value: function() { + return "userDocument_" + (this._iframeCounter++); + } + } +}); diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index 011caec5..44e0e798 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js @@ -181,6 +181,10 @@ var stylesController = exports.StylesController = Montage.create(Component, { rule = stylesheet.rules[index]; ///// attach specificity to rule object + // if rule is css keyframes, return rule and don't attach specificity + if (rule instanceof WebKitCSSKeyframesRule) { + return rule; + } rule[this.CONST.SPECIFICITY_KEY] = this.getSpecificity(rule.selectorText); ///// return the rule we just inserted -- cgit v1.2.3 From f3dc624fa464a79fd8e8cec1ddd16ed2109bda23 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Fri, 10 Feb 2012 16:05:27 -0800 Subject: Revert "Merge from /joseeight/ninja-internal/tree/FileIO" This reverts commit c48eeb01bd726895dc577d8b843b2a75883eee07. Signed-off-by: Ananya Sen --- js/controllers/document-controller.js | 443 ---------------------------------- js/controllers/styles-controller.js | 4 - 2 files changed, 447 deletions(-) delete mode 100755 js/controllers/document-controller.js (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js deleted file mode 100755 index a6228a55..00000000 --- a/js/controllers/document-controller.js +++ /dev/null @@ -1,443 +0,0 @@ -/* -This file contains proprietary software owned by Motorola Mobility, Inc.
-No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
-(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. -
*/ - -//////////////////////////////////////////////////////////////////////// -// -var Montage = require("montage/core/core").Montage, - Component = require("montage/ui/component").Component, - Uuid = require("montage/core/uuid").Uuid, - HTMLDocument = require("js/io/document/html-document").HTMLDocument, - TextDocument = require("js/io/document/text-document").TextDocument, - DocumentController; -//////////////////////////////////////////////////////////////////////// -// -DocumentController = exports.DocumentController = Montage.create(Component, { - hasTemplate: { - value: false - }, - - _documents: { - value: [] - }, - - _activeDocument: { value: null }, - _iframeCounter: { value: 1, enumerable: false }, - _iframeHolder: { value: null, enumerable: false }, - _textHolder: { value: null, enumerable: false }, - _codeMirrorCounter: {value: 1, enumerable: false}, - - tmpSourceForTesting: { - value: "function CodeMirror(place, givenOptions) {" + - "// Determine effective options based on given values and defaults." + - "var options = {}, defaults = CodeMirror.defaults; }" - }, - - activeDocument: { - get: function() { - return this._activeDocument; - }, - set: function(doc) { - if(this._activeDocument) this._activeDocument.isActive = false; - - if(this._documents.indexOf(doc) === -1) this._documents.push(doc); - - this._activeDocument = doc; - this._activeDocument.isActive = true; - - if(!!this._activeDocument.editor){ - this._activeDocument.editor.focus(); - } - - } - }, - - deserializedFromTemplate: { - value: function() { - this.eventManager.addEventListener("appLoaded", this, false); - this.eventManager.addEventListener("executeFileOpen", this, false); - this.eventManager.addEventListener("executeNewFile", this, false); - this.eventManager.addEventListener("executeSave", this, false); - - this.eventManager.addEventListener("recordStyleChanged", this, false); - - // Temporary testing opening a new file after Ninja has loaded - this.eventManager.addEventListener("executeNewProject", this, false); - } - }, - - handleAppLoaded: { - value: function() { - //this.openDocument({"type": "html"}); - } - }, - - handleExecuteNewProject: { - value: function() { - this.openDocument({"type": "html"}); - } - }, - - handleExecuteFileOpen: { - value: function(event) { - var pickerSettings = event._event.settings || {}; - pickerSettings.callback = this.openFileWithURI.bind(this); - pickerSettings.pickerMode = "read"; - pickerSettings.inFileMode = true; - this.application.ninja.filePickerController.showFilePicker(pickerSettings); - } - }, - - handleExecuteNewFile: { - value: function(event) { - var newFileSettings = event._event.settings || {}; - newFileSettings.callback = this.createNewFile.bind(this); - this.application.ninja.newFileController.showNewFileDialog(newFileSettings); - } - }, - - handleExecuteSave: { - value: function(event) { - this.activeDocument.save(); - } - }, - - createNewFile:{ - value:function(newFileObj){ - //console.log(newFileObj);//contains the template uri and the new file uri - if(!newFileObj) return; - this.application.ninja.ioMediator.fileNew(newFileObj.newFilePath, newFileObj.fileTemplateUri, this.openNewFileCallback.bind(this)); - - if((newFileObj.fileExtension !== ".html") && (newFileObj.fileExtension !== ".htm")){//open code view - - } else { - //open design view - } - } - }, - - /** - * Public method - * doc contains: - * type : file type, like js, css, etc - * name : file name - * source : file content - * uri : file uri - */ - openNewFileCallback:{ - value:function(doc){ - var response = doc || null;//default just for testing - if(!!response && response.success && !!response.uri){ - this.application.ninja.ioMediator.fileOpen(response.uri, this.openFileCallback.bind(this)); - } - } - }, - - openFileWithURI: { - value: function(uriArrayObj) { - var uri = "", fileContent = "", response=null, filename="", fileType="js"; - if(!!uriArrayObj && !!uriArrayObj.uri && (uriArrayObj.uri.length > 0)){ - uri = uriArrayObj.uri[0]; - } - //console.log("URI is: ", uri); - if(!!uri){ - this.application.ninja.ioMediator.fileOpen(uri, this.openFileCallback.bind(this)); - } - } - }, - - //////////////////////////////////////////////////////////////////// - // - openFileCallback:{ - value:function(response){ - //TODO: Add UI to handle error codes, shouldn't be alert windows - if(!!response && (response.status === 204)) { - //Sending full response object - 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)){ - alert("Unable to open file.\n Check if Ninja Local Cloud is running."); - } else{ - alert("Unable to open file."); - } - - } - }, - //////////////////////////////////////////////////////////////////// - // - openDocument: { - value: function(doc) { - // - switch (doc.extension) { - case 'html': case 'html': - //Open in designer view - Montage.create(HTMLDocument).initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument); - break; - default: - //Open in code view - break; - } - - return; - - - - - - var newDoc; - - if(!doc) return false; - - // try { - if (doc.type === 'html' || doc.type === 'htm') { - console.log('hello'); - newDoc = Montage.create(HTMLDocument); - newDoc.initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument); - } else { - newDoc = Montage.create(TextDocument, { - "source": { value: doc.source } - }); - var docUuid = Uuid.generate(); - var textArea = this.application.ninja.stage.stageView.createTextAreaElement(docUuid); - newDoc.initialize(doc, docUuid, textArea, textArea.parentNode); - - // Tmp this will be filled with the real content - newDoc.textArea.value = doc.source; //this.tmpSourceForTesting; - - this.textDocumentOpened(newDoc); - - } - - // } catch (err) { - // console.log("Could not open Document ", err); - // } - } - }, - //////////////////////////////////////////////////////////////////// - - openProjectWithURI: { - value: function(uri) { - console.log("URI is: ", uri); - } - }, - - textDocumentOpened: { - value: function(doc) { - - - - this.application.ninja.stage.stageView.createTextView(doc); - - /* - DocumentManager._hideCurrentDocument(); - stageManagerModule.stageManager._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe - DocumentManager.activeDocument = doc; - - var type; - - switch(doc.documentType) { - case "css" : - type = "css"; - break; - case "js" : - type = "javascript"; - break; - } - - DocumentManager._codeEditor.editor = CodeMirror.fromTextArea(doc.textArea, { - lineNumbers: true, - mode: type, - onCursorActivity: function() { - DocumentManager._codeEditor.editor.setLineClass(DocumentManager._codeEditor.hline, null); - DocumentManager._codeEditor.hline = DocumentManager._codeEditor.editor.setLineClass(DocumentManager._codeEditor.editor.getCursor().line, "activeline"); - } - }); - DocumentManager._codeEditor.hline = DocumentManager._codeEditor.editor.setLineClass(0, "activeline"); - */ - - } - }, - - closeDocument: { - value: function(id) { - if(this.activeDocument.dirtyFlag === true){ - //if file dirty then alert user to save - } - - var doc = this._findDocumentByUUID(id); - this._removeDocumentView(doc.container); - - var closeDocumentIndex = this._findIndexByUUID(id); - this._documents.splice(this._findIndexByUUID(id), 1); - - if(this.activeDocument.uuid === id && this._documents.length > 0) { - var nextDocumentIndex = -1 ; - if((this._documents.length > 0) && (closeDocumentIndex === 0)){ - nextDocumentIndex = 1; - }else if((this._documents.length > 0) && (closeDocumentIndex > 0)){ - nextDocumentIndex = closeDocumentIndex - 1; - } - this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]); - }else{ - //if there are no documents to switch to then just show the iframeContainer - document.getElementById("iframeContainer").style.display="block"; - } - } - }, - - // Document has been loaded into the Iframe. Dispatch the event. - // Event Detail: Contains the current ActiveDocument - _onOpenDocument: { - value: function(doc){ - //var data = DocumentManager.activeDocument; - //DocumentManager._hideCurrentDocument(); - - //stageManagerModule.stageManager.toggleCanvas(); - - DocumentController.activeDocument = doc; - - NJevent("onOpenDocument", doc); -// appDelegateModule.MyAppDelegate.onSetActiveDocument(); - - } - }, - - - _onOpenTextDocument: { - value: function(doc) { - this._hideCurrentDocument(); - this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe - this.activeDocument = doc; - - var type; - - switch(doc.documentType) { - case "css" : - type = "css"; - break; - case "js" : - type = "javascript"; - break; - } - - DocumentController._codeEditor.editor = CodeMirror.fromTextArea(doc.textArea, { - lineNumbers: true, - mode: type, - onCursorActivity: function() { - DocumentController._codeEditor.editor.setLineClass(DocumentController._codeEditor.hline, null); - DocumentController._codeEditor.hline = DocumentController._codeEditor.editor.setLineClass(DocumentController._codeEditor.editor.getCursor().line, "activeline"); - } - }); - DocumentController._codeEditor.hline = DocumentController._codeEditor.editor.setLineClass(0, "activeline"); - - } - }, - - /** - * VIEW Related Methods - */ - // PUBLIC - ShowActiveDocument: { - value: function() { - this.activeDocument.iframe.style.opacity = 1.0; - } - }, - - // PRIVATE - _findDocumentByUUID: { - value: function(uuid) { - var len = this._documents.length; - for(var i = 0; i < len; i++) { - if(this._documents[i].uuid === uuid) return this._documents[i]; - } - - return false; - } - }, - - _findIndexByUUID: { - value: function(uuid) { - var len = this._documents.length; - for(var i = 0; i < len; i++) { - if(this._documents[i].uuid === uuid) return i; - } - - return false; - } - }, - - _hideCurrentDocument: { - value: function() { - if(this.activeDocument) { - if(this.activeDocument.currentView === "design"){ - this.application.ninja.stage.saveScroll(); - this.activeDocument.container.parentNode.style["display"] = "none"; - this.application.ninja.stage.hideCanvas(true); - this.application.ninja.stage.stageView.hideRulers(); - } - - this.activeDocument.container.style["display"] = "none"; - } - } - }, - - _showCurrentDocument: { - value: function() { - if(this.activeDocument) { - this.activeDocument.container.style["display"] = "block"; - if(this.activeDocument.currentView === "design"){ - this.activeDocument.container.parentNode.style["display"] = "block"; - this.application.ninja.stage.restoreScroll(); - this.application.ninja.stage.hideCanvas(false); - this.application.ninja.stage.stageView.showRulers(); - }else{ - //hide the iframe when switching to code view - document.getElementById("iframeContainer").style.display="none"; - } - } - } - }, - - _removeDocumentView: { - value: function(node) { - node.parentNode.removeChild(node); - } - }, - - reloadDocumentContent: { - value: function() { - this.activeDocument._window.location.reload(); - } - }, - - /** - * Creates a new iFrame element using a new unique ID for it. Returns the iframe ID. - */ - _createIframeElement: { - value: function() { - var e = document.createElement("iframe"); - e.id = this._createIframeID(); - e.style.border = "none"; - e.style.opacity = 0; - e.height = 1000; - e.width = 2000; - e.src = ""; - - if(!this._iframeHolder) this._iframeHolder = document.getElementById("iframeContainer"); - - this._iframeHolder.appendChild(e); - - return e; - } - }, - - - _createIframeID: { - value: function() { - return "userDocument_" + (this._iframeCounter++); - } - } -}); diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index 44e0e798..011caec5 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js @@ -181,10 +181,6 @@ var stylesController = exports.StylesController = Montage.create(Component, { rule = stylesheet.rules[index]; ///// attach specificity to rule object - // if rule is css keyframes, return rule and don't attach specificity - if (rule instanceof WebKitCSSKeyframesRule) { - return rule; - } rule[this.CONST.SPECIFICITY_KEY] = this.getSpecificity(rule.selectorText); ///// return the rule we just inserted -- cgit v1.2.3 From daa1cb4327ed82e6784e3f1e1e159a9dcc094228 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 10 Feb 2012 16:17:21 -0800 Subject: Adding back file open for code view --- js/controllers/document-controller.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 22467b44..7e2fb599 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -178,6 +178,12 @@ DocumentController = exports.DocumentController = Montage.create(Component, { 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._documentType = doc.extension; + code.textArea.value = doc.content; + this.application.ninja.stage.stageView.createTextView(code); break; } -- cgit v1.2.3 From 5eb38b8bd779c7fb6e59b966135f8d306378f034 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 10 Feb 2012 16:24:36 -0800 Subject: Cleaning up open file in code view --- js/controllers/document-controller.js | 36 +---------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 7e2fb599..7f4feff9 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -181,45 +181,11 @@ DocumentController = exports.DocumentController = Montage.create(Component, { 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._documentType = doc.extension; + code.init(doc.name, doc.uri, doc.extension, null, docuuid); code.textArea.value = doc.content; this.application.ninja.stage.stageView.createTextView(code); break; } - - return; - - - - - - var newDoc; - - if(!doc) return false; - - // try { - if (doc.type === 'html' || doc.type === 'htm') { - console.log('hello'); - newDoc = Montage.create(HTMLDocument); - newDoc.initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument); - } else { - newDoc = Montage.create(TextDocument, { - "source": { value: doc.source } - }); - var docUuid = Uuid.generate(); - var textArea = this.application.ninja.stage.stageView.createTextAreaElement(docUuid); - newDoc.initialize(doc, docUuid, textArea, textArea.parentNode); - - // Tmp this will be filled with the real content - newDoc.textArea.value = doc.source; //this.tmpSourceForTesting; - - this.textDocumentOpened(newDoc); - - } - - // } catch (err) { - // console.log("Could not open Document ", err); - // } } }, //////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From b1fc4f84d92efeaa33ec239b662235c9e8218d0c Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Sun, 12 Feb 2012 16:50:33 -0800 Subject: File Save (HTML only) Added the ability to save an HTML file from design view, need to add CSS detection and saving (of styles in