diff options
author | Valerio Virgillito | 2012-06-05 21:40:44 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-06-05 21:40:44 -0700 |
commit | e28eb9158a50d7e6d97dbc68066e591ac600c241 (patch) | |
tree | 1615affe62374ae67eaecb8b1966a2f464559dfa /js/document/views | |
parent | d7555c35b357e28a1e1ccc1c4edc4fe04d2b139a (diff) | |
download | ninja-e28eb9158a50d7e6d97dbc68066e591ac600c241.tar.gz |
removing all model creators.
The elementModel is now a getter that will create a new model when needed.
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/document/views')
-rwxr-xr-x | js/document/views/design.js | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/js/document/views/design.js b/js/document/views/design.js index f7fbf3c5..0e42dcc2 100755 --- a/js/document/views/design.js +++ b/js/document/views/design.js | |||
@@ -7,7 +7,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
7 | //////////////////////////////////////////////////////////////////////// | 7 | //////////////////////////////////////////////////////////////////////// |
8 | // | 8 | // |
9 | var Montage = require("montage/core/core").Montage, | 9 | var Montage = require("montage/core/core").Montage, |
10 | BaseDocumentView = require("js/document/views/base").BaseDocumentView; | 10 | BaseDocumentView = require("js/document/views/base").BaseDocumentView, |
11 | ElementModel = require("js/models/element-model"); | ||
11 | //////////////////////////////////////////////////////////////////////// | 12 | //////////////////////////////////////////////////////////////////////// |
12 | // | 13 | // |
13 | exports.DesignDocumentView = Montage.create(BaseDocumentView, { | 14 | exports.DesignDocumentView = Montage.create(BaseDocumentView, { |
@@ -22,6 +23,11 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
22 | value: null | 23 | value: null |
23 | }, | 24 | }, |
24 | //////////////////////////////////////////////////////////////////// | 25 | //////////////////////////////////////////////////////////////////// |
26 | // | ||
27 | _viewCallback: { | ||
28 | value: null | ||
29 | }, | ||
30 | //////////////////////////////////////////////////////////////////// | ||
25 | // | 31 | // |
26 | _template: { | 32 | _template: { |
27 | value: null | 33 | value: null |
@@ -104,12 +110,13 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
104 | //////////////////////////////////////////////////////////////////// | 110 | //////////////////////////////////////////////////////////////////// |
105 | // | 111 | // |
106 | render: { | 112 | render: { |
107 | value: function (callback, template) { | 113 | value: function (callback, template, viewCallback) { |
108 | //TODO: Remove, this is a temp patch for webRequest API gate | 114 | //TODO: Remove, this is a temp patch for webRequest API gate |
109 | this.application.ninja.documentController.redirectRequests = false; | 115 | this.application.ninja.documentController.redirectRequests = false; |
110 | //Storing callback for dispatch ready | 116 | //Storing callback for dispatch ready |
111 | this._callback = callback; | 117 | this._callback = callback; |
112 | this._template = template; | 118 | this._template = template; |
119 | this._viewCallback = viewCallback; | ||
113 | //Adding listener to know when template is loaded to then load user content | 120 | //Adding listener to know when template is loaded to then load user content |
114 | this.iframe.addEventListener("load", this.onTemplateLoad.bind(this), false); | 121 | this.iframe.addEventListener("load", this.onTemplateLoad.bind(this), false); |
115 | //TODO: Add source parameter and root (optional) | 122 | //TODO: Add source parameter and root (optional) |
@@ -264,6 +271,10 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
264 | } | 271 | } |
265 | } | 272 | } |
266 | } | 273 | } |
274 | |||
275 | // Assign the modelGenerator reference from the template to our own modelGenerator | ||
276 | this.document.modelGenerator = ElementModel.modelGenerator; | ||
277 | |||
267 | //Checking for script tags then parsing check for montage and webgl | 278 | //Checking for script tags then parsing check for montage and webgl |
268 | if (scripttags.length > 0) { | 279 | if (scripttags.length > 0) { |
269 | //Checking and initializing webGL | 280 | //Checking and initializing webGL |
@@ -272,6 +283,9 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
272 | this.initMontage(scripttags); | 283 | this.initMontage(scripttags); |
273 | } else { | 284 | } else { |
274 | //Else there is not data to parse | 285 | //Else there is not data to parse |
286 | if(this._viewCallback) { | ||
287 | this._viewCallback.viewCallback.call(this._viewCallback.context); | ||
288 | } | ||
275 | } | 289 | } |
276 | //TODO: Verify appropiate location for this operation | 290 | //TODO: Verify appropiate location for this operation |
277 | if (this._template && this._template.type === 'banner') { | 291 | if (this._template && this._template.type === 'banner') { |
@@ -287,8 +301,9 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
287 | for (var n in orgNodes) { | 301 | for (var n in orgNodes) { |
288 | if (orgNodes[n].getAttribute) orgNodes[n].setAttribute('data-ninja-node', 'true'); | 302 | if (orgNodes[n].getAttribute) orgNodes[n].setAttribute('data-ninja-node', 'true'); |
289 | } | 303 | } |
290 | //Initiliazing document model | 304 | |
291 | document.application.njUtils.makeElementModel(this.model.documentRoot, "Body", "body"); | 305 | |
306 | |||
292 | //Makign callback if specified | 307 | //Makign callback if specified |
293 | if (this._callback) this._callback(); | 308 | if (this._callback) this._callback(); |
294 | } | 309 | } |
@@ -395,6 +410,7 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
395 | // | 410 | // |
396 | initMontage: { | 411 | initMontage: { |
397 | value: function (scripttags) { | 412 | value: function (scripttags) { |
413 | var self = this; | ||
398 | // | 414 | // |
399 | this.iframe.contentWindow.document.body.addEventListener('mjsTemplateReady', function () { | 415 | this.iframe.contentWindow.document.body.addEventListener('mjsTemplateReady', function () { |
400 | //Initializing template with user's seriliazation | 416 | //Initializing template with user's seriliazation |
@@ -406,6 +422,12 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
406 | //Forcing draw on components | 422 | //Forcing draw on components |
407 | template._deserializer._objects[c].needsDraw = true; | 423 | template._deserializer._objects[c].needsDraw = true; |
408 | } | 424 | } |
425 | |||
426 | // Now call the view callback | ||
427 | if(self._viewCallback) { | ||
428 | self._viewCallback.viewCallback.call(self._viewCallback.context); | ||
429 | } | ||
430 | |||
409 | }); | 431 | }); |
410 | }.bind(this), false); | 432 | }.bind(this), false); |
411 | } | 433 | } |