From 018a6132d93a73d28bd349122404c236e61cb765 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Mon, 13 Feb 2012 15:03:23 -0800 Subject: Save 'code' view files Added functionality (temp) to save files in code view. --- js/controllers/document-controller.js | 4 +- js/io/document/html-document.js | 7 +++- js/io/document/text-document.js | 65 ++++++++++++++++++++++++-------- js/io/ui/cloudpopup.reel/cloudpopup.html | 2 +- js/mediators/io-mediator.js | 1 + 5 files changed, 58 insertions(+), 21 deletions(-) diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 227b5462..9f9e4757 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -100,10 +100,10 @@ DocumentController = exports.DocumentController = Montage.create(Component, { //////////////////////////////////////////////////////////////////// - //TODO: Improve logic and make functions + //TODO: Check for appropiate structures handleExecuteSave: { value: function(event) { - // + //Text and HTML document classes should return the same save object for fileSave this.application.ninja.ioMediator.fileSave(this.activeDocument.save()); } }, diff --git a/js/io/document/html-document.js b/js/io/document/html-document.js index 99bf4576..dfd8566a 100755 --- a/js/io/document/html-document.js +++ b/js/io/document/html-document.js @@ -471,9 +471,12 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base save: { enumerable: false, value: function () { - //console.log(this._styles, this._stylesheets); //TODO: Add code view logic and also styles for HTML - return {mode: 'html', document: this._userDocument, style: this._styles, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; + if (this.currentView === 'design') { + return {mode: 'html', document: this._userDocument, style: this._styles, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; + } else if(this.currentView === "code"){ + //TODO: Would this get call when we are in code of HTML? + } } } //////////////////////////////////////////////////////////////////// diff --git a/js/io/document/text-document.js b/js/io/document/text-document.js index 81162eba..e149c479 100755 --- a/js/io/document/text-document.js +++ b/js/io/document/text-document.js @@ -4,11 +4,13 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ -var Montage = require("montage/core/core").Montage; -var baseDocumentModule = require("js/io/document/base-document"); - - -var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.BaseDocument, { +//////////////////////////////////////////////////////////////////////// +// +var Montage = require("montage/core/core").Montage, + BaseDocument = require("js/io/document/base-document").BaseDocument; +//////////////////////////////////////////////////////////////////////// +// +var TextDocument = exports.TextDocument = Montage.create(BaseDocument, { // PRIVATE MEMBERS _codeEditor: { value: { @@ -21,7 +23,9 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base _hline: { value: null, enumerable: false }, _textArea: {value: null, enumerable: false }, - + + _userDocument: {value: null, enumerable: false }, + _source: { value: null, enumerable: false}, source: { @@ -65,19 +69,43 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base }, - // PUBLIC METHODS + //////////////////////////////////////////////////////////////////// + // initialize: { - value: function(doc, uuid, textArea, container, callback) { - this.init(doc.name, doc.uri, doc.type, container, uuid); - this.currentView = "code"; - this.textArea = textArea; - -// this._loadContent(); - + value: function(file, uuid, textArea, container, callback) { + // + this._userDocument = file; + // + this.init(file.name, file.uri, file.extension, container, uuid, callback); + // + this.currentView = "code"; + this.textArea = textArea; } }, + //////////////////////////////////////////////////////////////////// + // + save: { + enumerable: false, + value: function () { + //TODO: Improve sequence + this.editor.save(); + return {mode: this._userDocument.extension, document: this._userDocument, content: this.textArea.value}; + } + } + //////////////////////////////////////////////////////////////////// + + + + + + + + + + - // PRIVATE METHODS + /* +// PRIVATE METHODS _loadContent: { value: function() { // Start and AJAX call to load the HTML Document as a String @@ -104,11 +132,15 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base xhr.send(''); } }, +*/ + //////////////////////////////////////////////////////////////////// + /** * public method */ - save:{ + /* +save:{ value:function(){ try{ this.editor.save(); @@ -120,4 +152,5 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base } } } +*/ }); \ No newline at end of file diff --git a/js/io/ui/cloudpopup.reel/cloudpopup.html b/js/io/ui/cloudpopup.reel/cloudpopup.html index 8e65a705..2c1c169a 100755 --- a/js/io/ui/cloudpopup.reel/cloudpopup.html +++ b/js/io/ui/cloudpopup.reel/cloudpopup.html @@ -50,7 +50,7 @@

Install Ninja Cloud App

-

Donec congue lacinia dui, a porttitor lectus condimentum laoreet. Nunc eu ullamcorper orci. Quisque eget odio ac lectus.

+

The Local Cloud App is required to run Ninja. Please download and unzip the file. Start the Local Cloud and copy/paste the server URL into the field above. Click the ‘Test’ button to verify the connection.

diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 35e0ca5a..47069cfb 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -150,6 +150,7 @@ exports.IoMediator = Montage.create(Component, { contents = file.document.content.document.documentElement.outerHTML; break; default: + contents = file.content; break; } // -- cgit v1.2.3