aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-05-18 15:23:15 -0700
committerJose Antonio Marquez2012-05-18 15:23:15 -0700
commitd878aa470074d5698a316512b513949fa22073f2 (patch)
tree826a7149a65b5160e1c6bf64d33aef2f126b1d00
parent615ec16fb7e3f7da9f0718a26d8242682ab1f588 (diff)
downloadninja-d878aa470074d5698a316512b513949fa22073f2.tar.gz
Fixing save logic
Moved dirty marker clearing code to model.
-rwxr-xr-xjs/controllers/document-controller.js15
-rwxr-xr-xjs/document/models/base.js18
-rw-r--r--js/mediators/io-mediator.js1
3 files changed, 24 insertions, 10 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index f1523d87..cf618360 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -145,18 +145,19 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
145 value: function(event) { 145 value: function(event) {
146 // 146 //
147 if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ 147 if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){
148 // 148 //Currently we don't need a callback handler
149 this.activeDocument.model.save(this.testCallback.bind(this)); //this.fileSaveResult.bind(this) 149 //this.activeDocument.model.save(this.saveExecuted.bind(this));
150 this.activeDocument.model.save();
150 } else { 151 } else {
151 //Error: 152 //Error: cloud not available and/or no active document
152 } 153 }
153 } 154 }
154 }, 155 },
155 testCallback: { 156 ////////////////////////////////////////////////////////////////////
157 //
158 saveExecuted: {
156 value: function (value) { 159 value: function (value) {
157 console.log(value); 160 //File saved, any callbacks or events should go here
158 //TODO: Move this to the model.save()
159 this.activeDocument.model.needsSave = false;
160 } 161 }
161 }, 162 },
162 //////////////////////////////////////////////////////////////////// 163 ////////////////////////////////////////////////////////////////////
diff --git a/js/document/models/base.js b/js/document/models/base.js
index df341b2f..c99e36c7 100755
--- a/js/document/models/base.js
+++ b/js/document/models/base.js
@@ -151,7 +151,7 @@ exports.BaseDocumentModel = Montage.create(Component, {
151 head: this.views.design.iframe.contentWindow.document.head, 151 head: this.views.design.iframe.contentWindow.document.head,
152 body: this.views.design.iframe.contentWindow.document.body, 152 body: this.views.design.iframe.contentWindow.document.body,
153 mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator 153 mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator
154 }, callback.bind(this)); 154 }, this.handleSaved.bind({callback: callback, model: this}));
155 } else { 155 } else {
156 //TODO: Add logic to save code view data 156 //TODO: Add logic to save code view data
157 } 157 }
@@ -180,7 +180,7 @@ exports.BaseDocumentModel = Montage.create(Component, {
180 head: this.views.design.iframe.contentWindow.document.head, 180 head: this.views.design.iframe.contentWindow.document.head,
181 body: this.views.design.iframe.contentWindow.document.body, 181 body: this.views.design.iframe.contentWindow.document.body,
182 mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator 182 mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator
183 }, callback.bind(this)); 183 }, this.handleSaved.bind({callback: callback, model: this}));
184 } else { 184 } else {
185 //TODO: Add logic to save code view data 185 //TODO: Add logic to save code view data
186 } 186 }
@@ -190,7 +190,7 @@ exports.BaseDocumentModel = Montage.create(Component, {
190 //////////////////////////////////////////////////////////////////// 190 ////////////////////////////////////////////////////////////////////
191 // 191 //
192 saveAs: { 192 saveAs: {
193 value: function () { 193 value: function (callback) {
194 // 194 //
195 if (this.needsSave) { 195 if (this.needsSave) {
196 //Save current file on memory 196 //Save current file on memory
@@ -201,6 +201,18 @@ exports.BaseDocumentModel = Montage.create(Component, {
201 }, 201 },
202 //////////////////////////////////////////////////////////////////// 202 ////////////////////////////////////////////////////////////////////
203 // 203 //
204 handleSaved: {
205 value: function (result) {
206 //
207 if (result.status === 204) {
208 this.model.needsSave = false;
209 }
210 //
211 if (this.callback) this.callback(result);
212 }
213 },
214 ////////////////////////////////////////////////////////////////////
215 //
204 close: { 216 close: {
205 value: function (view, callback) { 217 value: function (view, callback) {
206 //Outcome of close (pending on save logic) 218 //Outcome of close (pending on save logic)
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js
index c506e186..ade27728 100644
--- a/js/mediators/io-mediator.js
+++ b/js/mediators/io-mediator.js
@@ -557,6 +557,7 @@ function loadWebGL (e) {\n\
557 mjslibtag = template.file.content.document.createElement('script'); 557 mjslibtag = template.file.content.document.createElement('script');
558 mjslibtag.setAttribute('type', 'text/javascript'); 558 mjslibtag.setAttribute('type', 'text/javascript');
559 mjslibtag.setAttribute('src', mjsDirName + '/montage/montage.js'); 559 mjslibtag.setAttribute('src', mjsDirName + '/montage/montage.js');
560 mjslibtag.setAttribute('data-package', '.');
560 mjslibtag.setAttribute('data-mjs-lib', 'true'); 561 mjslibtag.setAttribute('data-mjs-lib', 'true');
561 if (ninjaWrapper) { 562 if (ninjaWrapper) {
562 template.file.content.document.body.getElementsByTagName('ninja-content')[0].appendChild(mjslibtag); 563 template.file.content.document.body.getElementsByTagName('ninja-content')[0].appendChild(mjslibtag);