aboutsummaryrefslogtreecommitdiff
path: root/js/document/views
diff options
context:
space:
mode:
authorValerio Virgillito2012-06-07 10:51:26 -0700
committerValerio Virgillito2012-06-07 10:51:26 -0700
commitb75fe9369f7caec0351d298f7106c8d59572b440 (patch)
tree8f2f2db6097104e44c8d87e11466d1f3124c7f3a /js/document/views
parent47e0e1f047e83b71c3f86812a45d33904201cc7a (diff)
parent6442dcc0cc4088d28558a9c121c6a91cba3ff078 (diff)
downloadninja-b75fe9369f7caec0351d298f7106c8d59572b440.tar.gz
Merge pull request #275 from mencio/element-model-fixes
Element model fixes and selection fixes
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 }