diff options
author | Nivesh Rajbhandari | 2012-05-18 17:12:53 -0700 |
---|---|---|
committer | Nivesh Rajbhandari | 2012-05-18 17:12:53 -0700 |
commit | 8a15ac2b4a7d528d04c73bf6d9c6e724d8c6ac50 (patch) | |
tree | 345d582d72c2064e6e4ebbd23cbb7bb6c81e96df /js/document | |
parent | ca70f18a62a2a2b5670be132361e3a3f5907d920 (diff) | |
parent | e7c288fe8f5d3a9e5c9f0eb0a045c6c195a0e7b8 (diff) | |
download | ninja-8a15ac2b4a7d528d04c73bf6d9c6e724d8c6ac50.tar.gz |
Merge branch 'refs/heads/dom-architecture-master' into Dom-Architecture
Diffstat (limited to 'js/document')
-rwxr-xr-x | js/document/document-html.js | 11 | ||||
-rwxr-xr-x | js/document/models/base.js | 18 | ||||
-rwxr-xr-x | js/document/models/html.js | 17 | ||||
-rwxr-xr-x | js/document/views/design.js | 34 |
4 files changed, 62 insertions, 18 deletions
diff --git a/js/document/document-html.js b/js/document/document-html.js index 0037c94d..983da966 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js | |||
@@ -139,7 +139,11 @@ exports.HtmlDocument = Montage.create(Component, { | |||
139 | //this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing; | 139 | //this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing; |
140 | 140 | ||
141 | // Serialize the current scroll position | 141 | // Serialize the current scroll position |
142 | // TODO: Implement | 142 | this.model.scrollLeft = this.application.ninja.stage._scrollLeft; |
143 | this.model.scrollTop = this.application.ninja.stage._scrollTop; | ||
144 | this.model.userContentLeft = this.application.ninja.stage._userContentLeft; | ||
145 | this.model.userContentTop = this.application.ninja.stage._userContentTop; | ||
146 | |||
143 | 147 | ||
144 | // Serialize the selection | 148 | // Serialize the selection |
145 | this.model.selection = this.application.ninja.selectedElements.slice(0); | 149 | this.model.selection = this.application.ninja.selectedElements.slice(0); |
@@ -163,7 +167,10 @@ exports.HtmlDocument = Montage.create(Component, { | |||
163 | //this.application.ninja.stage.drawUtils.gridVerticalSpacing = this.gridVerticalSpacing; | 167 | //this.application.ninja.stage.drawUtils.gridVerticalSpacing = this.gridVerticalSpacing; |
164 | 168 | ||
165 | // Deserialize the current scroll position | 169 | // Deserialize the current scroll position |
166 | // TODO: Implement | 170 | this.application.ninja.stage._scrollLeft = this.model.scrollLeft; |
171 | this.application.ninja.stage._scrollTop = this.model.scrollTop; | ||
172 | this.application.ninja.stage._userContentLeft = this.model.userContentLeft; | ||
173 | this.application.ninja.stage._userContentTop = this.model.userContentTop; | ||
167 | 174 | ||
168 | this.application.ninja.selectedElements = this.model.selection.slice(0); | 175 | this.application.ninja.selectedElements = this.model.selection.slice(0); |
169 | 176 | ||
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/models/html.js b/js/document/models/html.js index 67457863..a97b4b5a 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js | |||
@@ -28,6 +28,23 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { | |||
28 | value: false | 28 | value: false |
29 | }, | 29 | }, |
30 | //////////////////////////////////////////////////////////////////// | 30 | //////////////////////////////////////////////////////////////////// |
31 | // | ||
32 | scrollLeft: { | ||
33 | value: null | ||
34 | }, | ||
35 | |||
36 | scrollTop: { | ||
37 | value: null | ||
38 | }, | ||
39 | |||
40 | userContentLeft: { | ||
41 | value: null | ||
42 | }, | ||
43 | |||
44 | userContentTop: { | ||
45 | value: null | ||
46 | }, | ||
47 | //////////////////////////////////////////////////////////////////// | ||
31 | // | 48 | // |
32 | baseHref: { | 49 | baseHref: { |
33 | value: null | 50 | value: null |
diff --git a/js/document/views/design.js b/js/document/views/design.js index 2ccb82d1..3f58650e 100755 --- a/js/document/views/design.js +++ b/js/document/views/design.js | |||
@@ -64,6 +64,11 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
64 | }, | 64 | }, |
65 | //////////////////////////////////////////////////////////////////// | 65 | //////////////////////////////////////////////////////////////////// |
66 | // | 66 | // |
67 | propertiesPanel: { | ||
68 | value: null | ||
69 | }, | ||
70 | //////////////////////////////////////////////////////////////////// | ||
71 | // | ||
67 | initialize: { | 72 | initialize: { |
68 | value: function (parent) { | 73 | value: function (parent) { |
69 | //Creating iFrame for view | 74 | //Creating iFrame for view |
@@ -184,8 +189,7 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
184 | this._bodyFragment = null; | 189 | this._bodyFragment = null; |
185 | //Calling standard method to finish opening document | 190 | //Calling standard method to finish opening document |
186 | this.bodyContentLoaded(null); | 191 | this.bodyContentLoaded(null); |
187 | 192 | //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); | 193 | 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); | 194 | this.application.ninja.stage.documentOffsetTop = parseInt((this.document.body.scrollHeight - this._template.size.height)/2); |
191 | } | 195 | } |
@@ -243,17 +247,15 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
243 | } | 247 | } |
244 | } | 248 | } |
245 | } | 249 | } |
246 | //Checking and initializing webGL | 250 | //Checking for script tags then parsing check for montage and webgl |
247 | if (scripttags.length > 0) { | 251 | if (scripttags.length > 0) { |
252 | //Checking and initializing webGL | ||
248 | this.initWebGl(scripttags); | 253 | this.initWebGl(scripttags); |
249 | } //Else there is not data to parse | 254 | //Checking and initializing Montage |
250 | 255 | this.initMontage(scripttags); | |
251 | 256 | } else { | |
252 | 257 | //Else there is not data to parse | |
253 | //TODO: Load Montage Components (blocking) | 258 | } |
254 | //this.initMontage(); | ||
255 | |||
256 | |||
257 | //Makign callback if specified | 259 | //Makign callback if specified |
258 | if (this._callback) this._callback(); | 260 | if (this._callback) this._callback(); |
259 | } | 261 | } |
@@ -350,8 +352,14 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
350 | //////////////////////////////////////////////////////////////////// | 352 | //////////////////////////////////////////////////////////////////// |
351 | // | 353 | // |
352 | initMontage: { | 354 | initMontage: { |
353 | value: function () { | 355 | value: function (scripttags) { |
354 | //initWithDocument(window.document) instantiateWithOwnerAndDocument(null, window.document) | 356 | // |
357 | this.iframe.contentWindow.document.body.addEventListener('mjsTemplateReady', function () { | ||
358 | //Initializing template with user's seriliazation | ||
359 | var template = this.iframe.contentWindow.mjsTemplate.create(); | ||
360 | template.initWithDocument(this.iframe.contentWindow.document); | ||
361 | template.instantiateWithOwnerAndDocument(null, this.iframe.contentWindow.document, function (e){/*Nothing just a required extra parameter*/}); | ||
362 | }.bind(this), false); | ||
355 | } | 363 | } |
356 | }, | 364 | }, |
357 | //////////////////////////////////////////////////////////////////// | 365 | //////////////////////////////////////////////////////////////////// |