diff options
author | Valerio Virgillito | 2012-05-18 15:43:30 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-05-18 15:43:30 -0700 |
commit | 1056a45e0cbf92d578324ce70b8a17183320e64b (patch) | |
tree | 826a7149a65b5160e1c6bf64d33aef2f126b1d00 /js/document | |
parent | 66edf78c7e5df11218ef733686965beab05c7c7d (diff) | |
parent | d878aa470074d5698a316512b513949fa22073f2 (diff) | |
download | ninja-1056a45e0cbf92d578324ce70b8a17183320e64b.tar.gz |
Merge pull request #246 from joseeight/Document
Fixing Save Logic
Diffstat (limited to 'js/document')
-rwxr-xr-x | js/document/models/base.js | 18 | ||||
-rwxr-xr-x | js/document/views/design.js | 29 |
2 files changed, 31 insertions, 16 deletions
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/document/views/design.js b/js/document/views/design.js index 2ccb82d1..bd8c25ec 100755 --- a/js/document/views/design.js +++ b/js/document/views/design.js | |||
@@ -184,8 +184,7 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
184 | this._bodyFragment = null; | 184 | this._bodyFragment = null; |
185 | //Calling standard method to finish opening document | 185 | //Calling standard method to finish opening document |
186 | this.bodyContentLoaded(null); | 186 | this.bodyContentLoaded(null); |
187 | 187 | //TODO: Move this to be set via the controller | |
188 | // TODO: Clean up this code | ||
189 | this.application.ninja.stage.documentOffsetLeft = parseInt((this.document.body.scrollWidth - this._template.size.width)/2); | 188 | this.application.ninja.stage.documentOffsetLeft = parseInt((this.document.body.scrollWidth - this._template.size.width)/2); |
190 | this.application.ninja.stage.documentOffsetTop = parseInt((this.document.body.scrollHeight - this._template.size.height)/2); | 189 | this.application.ninja.stage.documentOffsetTop = parseInt((this.document.body.scrollHeight - this._template.size.height)/2); |
191 | } | 190 | } |
@@ -243,17 +242,15 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
243 | } | 242 | } |
244 | } | 243 | } |
245 | } | 244 | } |
246 | //Checking and initializing webGL | 245 | //Checking for script tags then parsing check for montage and webgl |
247 | if (scripttags.length > 0) { | 246 | if (scripttags.length > 0) { |
247 | //Checking and initializing webGL | ||
248 | this.initWebGl(scripttags); | 248 | this.initWebGl(scripttags); |
249 | } //Else there is not data to parse | 249 | //Checking and initializing Montage |
250 | 250 | this.initMontage(scripttags); | |
251 | 251 | } else { | |
252 | 252 | //Else there is not data to parse | |
253 | //TODO: Load Montage Components (blocking) | 253 | } |
254 | //this.initMontage(); | ||
255 | |||
256 | |||
257 | //Makign callback if specified | 254 | //Makign callback if specified |
258 | if (this._callback) this._callback(); | 255 | if (this._callback) this._callback(); |
259 | } | 256 | } |
@@ -350,8 +347,14 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
350 | //////////////////////////////////////////////////////////////////// | 347 | //////////////////////////////////////////////////////////////////// |
351 | // | 348 | // |
352 | initMontage: { | 349 | initMontage: { |
353 | value: function () { | 350 | value: function (scripttags) { |
354 | //initWithDocument(window.document) instantiateWithOwnerAndDocument(null, window.document) | 351 | // |
352 | this.iframe.contentWindow.document.body.addEventListener('mjsTemplateReady', function () { | ||
353 | //Initializing template with user's seriliazation | ||
354 | var template = this.iframe.contentWindow.mjsTemplate.create(); | ||
355 | template.initWithDocument(this.iframe.contentWindow.document); | ||
356 | template.instantiateWithOwnerAndDocument(null, this.iframe.contentWindow.document, function (e){/*Nothing just a required extra parameter*/}); | ||
357 | }.bind(this), false); | ||
355 | } | 358 | } |
356 | }, | 359 | }, |
357 | //////////////////////////////////////////////////////////////////// | 360 | //////////////////////////////////////////////////////////////////// |