From cdaeb7e05e4d59832b9896f6995e0163e3decf50 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Mon, 16 Jul 2012 14:48:47 -0700 Subject: New: Adding switch view method Added a method to switch views from code and design. (Code is not currently supported) --- js/document/models/base.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'js/document/models/base.js') diff --git a/js/document/models/base.js b/js/document/models/base.js index c7e2de69..a9bbd6db 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -91,6 +91,8 @@ exports.BaseDocumentModel = Montage.create(Component, { _selection: { value: [] }, + //////////////////////////////////////////////////////////////////// + // domContainer: { value: null }, @@ -120,7 +122,8 @@ exports.BaseDocumentModel = Montage.create(Component, { libs: { value: null }, - + //////////////////////////////////////////////////////////////////// + // _mObjects: { value: [] }, @@ -138,6 +141,23 @@ exports.BaseDocumentModel = Montage.create(Component, { switchViewTo: { value: function (view) { // + switch (view) { + case 'design': + // + if (this.views.design) this.views.design.show(); + if (this.views.code) this.views.code.hide(); + this.currentView = this.views.design; + break; + case 'code': + // + if (this.views.code) this.views.code.show(); + if (this.views.design) this.views.design.hide(); + this.currentView = this.views.code; + break; + default: + //Error + break; + } } }, //////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 791e1633e2c08543e236b0d25b5edd9aec2a003b Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 24 Jul 2012 14:42:04 -0700 Subject: New: Adding logic to insert code view save method(s) --- js/document/models/base.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'js/document/models/base.js') diff --git a/js/document/models/base.js b/js/document/models/base.js index a9bbd6db..85a0414f 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -253,8 +253,10 @@ exports.BaseDocumentModel = Montage.create(Component, { this.libs.canvas = true; } } + } else if (this.currentView === this.views.code) { + //TODO: Add save logic for code view } else { - //TODO: Add logic to save code view data + //TODO: Error handle } } }, @@ -294,8 +296,10 @@ exports.BaseDocumentModel = Montage.create(Component, { this.libs.canvas = true; } } + } else if (this.currentView === this.views.code) { + //TODO: Add save logic for code view } else { - //TODO: Add logic to save code view data + //TODO: Error handle } } -- cgit v1.2.3 From db4f235dc9fd6f2242dee481d2f377005cf23596 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 24 Jul 2012 16:56:52 -0700 Subject: adding a viewIdentifier to the model to enable design/code switch Todo: - Cleanup and remove listeners - Finish stage reload - Add remaining bindings. Signed-off-by: Valerio Virgillito --- js/document/models/base.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'js/document/models/base.js') diff --git a/js/document/models/base.js b/js/document/models/base.js index 85a0414f..c44123c3 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -88,6 +88,21 @@ exports.BaseDocumentModel = Montage.create(Component, { }, //////////////////////////////////////////////////////////////////// // + _currentViewIdentifier: { + value: "" + }, + //////////////////////////////////////////////////////////////////// + // + currentViewIdentifier: { + get: function() { + return this._currentViewIdentifier; + }, + set: function(value) { + this._currentViewIdentifier = value; + } + }, + //////////////////////////////////////////////////////////////////// + // _selection: { value: [] }, -- cgit v1.2.3 From 7fa0c53c14e9029d2e3960cc81edf91592fd1768 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 25 Jul 2012 12:26:20 -0700 Subject: added save for code view, fixed code view editor bug, reuse code editor options component in document bar Signed-off-by: Ananya Sen Conflicts: js/document/views/design-code.js Signed-off-by: Ananya Sen --- js/document/models/base.js | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'js/document/models/base.js') diff --git a/js/document/models/base.js b/js/document/models/base.js index c44123c3..a73b8b20 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -236,6 +236,8 @@ exports.BaseDocumentModel = Montage.create(Component, { // save: { value: function (callback, libCopyCallback) { + var self = this; + //TODO: Implement on demand logic if (this.needsSave) { //Save @@ -270,6 +272,15 @@ exports.BaseDocumentModel = Montage.create(Component, { } } else if (this.currentView === this.views.code) { //TODO: Add save logic for code view + //save to textarea + self.views.code.editor.save(); + //save to disk + this.application.ninja.ioMediator.fileSave({ + mode: 'html-text', + file: self.file, + content:self.views.code.textArea.value + }, this.handleSaved.bind({callback: callback, model: this})); + } else { //TODO: Error handle } -- cgit v1.2.3 From aada5dbc179c06f2eb04db1d5651bb48bf32ec82 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 31 Jul 2012 13:26:48 -0700 Subject: Fix: Enabling preview from code view Added a temp patch to enable preview from code view when viewing HTML document (with design view). This does not save external assets, so CSS and components will not be saved. --- js/document/models/base.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'js/document/models/base.js') diff --git a/js/document/models/base.js b/js/document/models/base.js index a73b8b20..d51806b2 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -323,7 +323,8 @@ exports.BaseDocumentModel = Montage.create(Component, { } } } else if (this.currentView === this.views.code) { - //TODO: Add save logic for code view + //TODO: Add save logic for code view (this is a temp patch) + this.save(libCopyCallback); } else { //TODO: Error handle } -- cgit v1.2.3