aboutsummaryrefslogtreecommitdiff
path: root/js/document/views
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-06-07 11:28:25 -0700
committerJose Antonio Marquez2012-06-07 11:28:25 -0700
commit7d1a564a8fd246c621f674b5521554fbfc058281 (patch)
treed1be340a099e318db8113b651ba45c3d4c00f3a5 /js/document/views
parent0efbbf8287517b755be1774f6aa49947bed50a0d (diff)
parentb75fe9369f7caec0351d298f7106c8d59572b440 (diff)
downloadninja-7d1a564a8fd246c621f674b5521554fbfc058281.tar.gz
Merge branch 'refs/heads/Ninja-Internal' into FileIO
Diffstat (limited to 'js/document/views')
-rwxr-xr-xjs/document/views/design.js28
1 files changed, 24 insertions, 4 deletions
diff --git a/js/document/views/design.js b/js/document/views/design.js
index 5af24546..3d11e138 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//
9var Montage = require("montage/core/core").Montage, 9var 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//
13exports.DesignDocumentView = Montage.create(BaseDocumentView, { 14exports.DesignDocumentView = Montage.create(BaseDocumentView, {
@@ -23,6 +24,11 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
23 }, 24 },
24 //////////////////////////////////////////////////////////////////// 25 ////////////////////////////////////////////////////////////////////
25 // 26 //
27 _viewCallback: {
28 value: null
29 },
30 ////////////////////////////////////////////////////////////////////
31 //
26 _template: { 32 _template: {
27 value: null 33 value: null
28 }, 34 },
@@ -126,12 +132,13 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
126 //////////////////////////////////////////////////////////////////// 132 ////////////////////////////////////////////////////////////////////
127 // 133 //
128 render: { 134 render: {
129 value: function (callback, template) { 135 value: function (callback, template, viewCallback) {
130 //TODO: Remove, this is a temp patch for webRequest API gate 136 //TODO: Remove, this is a temp patch for webRequest API gate
131 this.application.ninja.documentController.redirectRequests = false; 137 this.application.ninja.documentController.redirectRequests = false;
132 //Storing callback for dispatch ready 138 //Storing callback for dispatch ready
133 this._callback = callback; 139 this._callback = callback;
134 this._template = template; 140 this._template = template;
141 this._viewCallback = viewCallback;
135 //Adding listener to know when template is loaded to then load user content 142 //Adding listener to know when template is loaded to then load user content
136 this.iframe.addEventListener("load", this.onTemplateLoad.bind(this), false); 143 this.iframe.addEventListener("load", this.onTemplateLoad.bind(this), false);
137 //TODO: Add source parameter and root (optional) 144 //TODO: Add source parameter and root (optional)
@@ -286,6 +293,10 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
286 } 293 }
287 } 294 }
288 } 295 }
296
297 // Assign the modelGenerator reference from the template to our own modelGenerator
298 this.document.modelGenerator = ElementModel.modelGenerator;
299
289 //Checking for script tags then parsing check for montage and webgl 300 //Checking for script tags then parsing check for montage and webgl
290 if (scripttags.length > 0) { 301 if (scripttags.length > 0) {
291 //Checking and initializing webGL 302 //Checking and initializing webGL
@@ -294,6 +305,9 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
294 this.initMontage(scripttags); 305 this.initMontage(scripttags);
295 } else { 306 } else {
296 //Else there is not data to parse 307 //Else there is not data to parse
308 if(this._viewCallback) {
309 this._viewCallback.viewCallback.call(this._viewCallback.context);
310 }
297 } 311 }
298 //TODO: Verify appropiate location for this operation 312 //TODO: Verify appropiate location for this operation
299 if (this._template && this._template.type === 'banner') { 313 if (this._template && this._template.type === 'banner') {
@@ -309,8 +323,7 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
309 for (var n in orgNodes) { 323 for (var n in orgNodes) {
310 if (orgNodes[n].getAttribute) orgNodes[n].setAttribute('data-ninja-node', 'true'); 324 if (orgNodes[n].getAttribute) orgNodes[n].setAttribute('data-ninja-node', 'true');
311 } 325 }
312 //Initiliazing document model 326
313 document.application.njUtils.makeElementModel(this.documentRoot, "Body", "body");
314 //Makign callback if specified 327 //Makign callback if specified
315 if (this._callback) this._callback(); 328 if (this._callback) this._callback();
316 } 329 }
@@ -415,6 +428,7 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
415 // 428 //
416 initMontage: { 429 initMontage: {
417 value: function (scripttags) { 430 value: function (scripttags) {
431 var self = this;
418 // 432 //
419 this.iframe.contentWindow.document.body.addEventListener('mjsTemplateReady', function () { 433 this.iframe.contentWindow.document.body.addEventListener('mjsTemplateReady', function () {
420 //Initializing template with user's seriliazation 434 //Initializing template with user's seriliazation
@@ -426,6 +440,12 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
426 //Forcing draw on components 440 //Forcing draw on components
427 template._deserializer._objects[c].needsDraw = true; 441 template._deserializer._objects[c].needsDraw = true;
428 } 442 }
443
444 // Now call the view callback
445 if(self._viewCallback) {
446 self._viewCallback.viewCallback.call(self._viewCallback.context);
447 }
448
429 }); 449 });
430 }.bind(this), false); 450 }.bind(this), false);
431 } 451 }