aboutsummaryrefslogtreecommitdiff
path: root/js/document/views
diff options
context:
space:
mode:
authorValerio Virgillito2012-06-11 17:46:29 -0700
committerValerio Virgillito2012-06-11 17:46:29 -0700
commitb6c88f548c8d3756738e534418732710af733f03 (patch)
treed651ce2811019a3bccfd8be1326762cd2c601316 /js/document/views
parent91123fef348ec54d89005adbc151e816856a6a18 (diff)
parent6854a72504f57903bd5de003e377f2aefb02d0da (diff)
downloadninja-b6c88f548c8d3756738e534418732710af733f03.tar.gz
Merge branch 'refs/heads/master' into montage-v10-integration
Conflicts: js/io/system/ninjalibrary.json js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/document/views')
-rwxr-xr-xjs/document/views/design.js92
1 files changed, 72 insertions, 20 deletions
diff --git a/js/document/views/design.js b/js/document/views/design.js
index f7fbf3c5..1a5b071e 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,13 +24,13 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
23 }, 24 },
24 //////////////////////////////////////////////////////////////////// 25 ////////////////////////////////////////////////////////////////////
25 // 26 //
26 _template: { 27 _viewCallback: {
27 value: null 28 value: null
28 }, 29 },
29 //////////////////////////////////////////////////////////////////// 30 ////////////////////////////////////////////////////////////////////
30 // 31 //
31 _document: { 32 _template: {
32 value: null 33 value: null
33 }, 34 },
34 //////////////////////////////////////////////////////////////////// 35 ////////////////////////////////////////////////////////////////////
35 // 36 //
@@ -52,8 +53,29 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
52 value: null 53 value: null
53 }, 54 },
54 //////////////////////////////////////////////////////////////////// 55 ////////////////////////////////////////////////////////////////////
55 //TODO: Remove usage 56 //
56 model: { 57 _liveNodeList: {
58 value: null
59 },
60 ////////////////////////////////////////////////////////////////////
61 //
62 _webGlHelper: {
63 value: null
64 },
65 ////////////////////////////////////////////////////////////////////
66 //
67 _baseHref: {
68 value: null
69 },
70 ////////////////////////////////////////////////////////////////////
71 //
72 baseHref: {
73 get: function() {return this._baseHref;},
74 set: function(value) {this._baseHref = value;}
75 },
76 ////////////////////////////////////////////////////////////////////
77 //
78 _document: {
57 value: null 79 value: null
58 }, 80 },
59 //////////////////////////////////////////////////////////////////// 81 ////////////////////////////////////////////////////////////////////
@@ -63,11 +85,17 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
63 set: function(value) {this._document = value;} 85 set: function(value) {this._document = value;}
64 }, 86 },
65 //////////////////////////////////////////////////////////////////// 87 ////////////////////////////////////////////////////////////////////
66 // 88 //
67 _liveNodeList: { 89 _documentRoot: {
68 value: null 90 value: null
69 }, 91 },
70 //////////////////////////////////////////////////////////////////// 92 ////////////////////////////////////////////////////////////////////
93 //
94 documentRoot: {
95 get: function() {return this._documentRoot;},
96 set: function(value) {this._documentRoot = value;}
97 },
98 ////////////////////////////////////////////////////////////////////
71 // 99 //
72 getLiveNodeList: { 100 getLiveNodeList: {
73 value: function(useFilter) { 101 value: function(useFilter) {
@@ -104,12 +132,13 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
104 //////////////////////////////////////////////////////////////////// 132 ////////////////////////////////////////////////////////////////////
105 // 133 //
106 render: { 134 render: {
107 value: function (callback, template) { 135 value: function (callback, template, viewCallback) {
108 //TODO: Remove, this is a temp patch for webRequest API gate 136 //TODO: Remove, this is a temp patch for webRequest API gate
109 this.application.ninja.documentController.redirectRequests = false; 137 this.application.ninja.documentController.redirectRequests = false;
110 //Storing callback for dispatch ready 138 //Storing callback for dispatch ready
111 this._callback = callback; 139 this._callback = callback;
112 this._template = template; 140 this._template = template;
141 this._viewCallback = viewCallback;
113 //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
114 this.iframe.addEventListener("load", this.onTemplateLoad.bind(this), false); 143 this.iframe.addEventListener("load", this.onTemplateLoad.bind(this), false);
115 //TODO: Add source parameter and root (optional) 144 //TODO: Add source parameter and root (optional)
@@ -142,7 +171,7 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
142 if (basetag.length) { 171 if (basetag.length) {
143 if (basetag[basetag.length-1].getAttribute && basetag[basetag.length-1].getAttribute('href')) { 172 if (basetag[basetag.length-1].getAttribute && basetag[basetag.length-1].getAttribute('href')) {
144 //Setting base HREF in model 173 //Setting base HREF in model
145 this.model.baseHref = basetag[basetag.length-1].getAttribute('href'); 174 this.baseHref = basetag[basetag.length-1].getAttribute('href');
146 } 175 }
147 } 176 }
148 //Checking to content to be template 177 //Checking to content to be template
@@ -175,7 +204,19 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
175 this.document.body.setAttribute(this.content.document.body.attributes[n].name, this.content.document.body.attributes[n].value); 204 this.document.body.setAttribute(this.content.document.body.attributes[n].name, this.content.document.body.attributes[n].value);
176 } 205 }
177 } 206 }
178 //TODO: Add attribute copying for <HEAD> and <HTML> 207 //Copying attributes to maintain same properties as the <head>
208 for (var m in this.content.document.head.attributes) {
209 if (this.content.document.head.attributes[m].value) {
210 this.document.head.setAttribute(this.content.document.head.attributes[m].name, this.content.document.head.attributes[m].value);
211 }
212 }
213 //Copying attributes to maintain same properties as the <html>
214 var htmlTagMem = this.content.document.getElementsByTagName('html')[0], htmlTagDoc = this.document.getElementsByTagName('html')[0];
215 for (var m in htmlTagMem.attributes) {
216 if (htmlTagMem.attributes[m].value) {
217 htmlTagDoc.setAttribute(htmlTagMem.attributes[m].name, htmlTagMem.attributes[m].value);
218 }
219 }
179 } 220 }
180 } 221 }
181 }, 222 },
@@ -264,6 +305,10 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
264 } 305 }
265 } 306 }
266 } 307 }
308
309 // Assign the modelGenerator reference from the template to our own modelGenerator
310 this.document.modelGenerator = ElementModel.modelGenerator;
311
267 //Checking for script tags then parsing check for montage and webgl 312 //Checking for script tags then parsing check for montage and webgl
268 if (scripttags.length > 0) { 313 if (scripttags.length > 0) {
269 //Checking and initializing webGL 314 //Checking and initializing webGL
@@ -272,23 +317,25 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
272 this.initMontage(scripttags); 317 this.initMontage(scripttags);
273 } else { 318 } else {
274 //Else there is not data to parse 319 //Else there is not data to parse
320 if(this._viewCallback) {
321 this._viewCallback.viewCallback.call(this._viewCallback.context);
322 }
275 } 323 }
276 //TODO: Verify appropiate location for this operation 324 //TODO: Verify appropiate location for this operation
277 if (this._template && this._template.type === 'banner') { 325 if (this._template && this._template.type === 'banner') {
278 this.model.documentRoot = this.document.body.getElementsByTagName('ninja-content')[0]; 326 this.documentRoot = this.document.body.getElementsByTagName('ninja-content')[0];
279 } else { 327 } else {
280 this.model.documentRoot = this.document.body; 328 this.documentRoot = this.document.body;
281 } 329 }
282 //Storing node list for reference (might need to store in the model) 330 //Storing node list for reference (might need to store in the model)
283 this._liveNodeList = this.model.documentRoot.getElementsByTagName('*'); 331 this._liveNodeList = this.documentRoot.getElementsByTagName('*');
284 //Getting list of original nodes 332 //Getting list of original nodes
285 orgNodes = this.document.getElementsByTagName('*'); 333 orgNodes = this.document.getElementsByTagName('*');
286 //TODO: Figure out if this is ideal for identifying nodes created by Ninja 334 //TODO: Figure out if this is ideal for identifying nodes created by Ninja
287 for (var n in orgNodes) { 335 for (var n in orgNodes) {
288 if (orgNodes[n].getAttribute) orgNodes[n].setAttribute('data-ninja-node', 'true'); 336 if (orgNodes[n].getAttribute) orgNodes[n].setAttribute('data-ninja-node', 'true');
289 } 337 }
290 //Initiliazing document model 338
291 document.application.njUtils.makeElementModel(this.model.documentRoot, "Body", "body");
292 //Makign callback if specified 339 //Makign callback if specified
293 if (this._callback) this._callback(); 340 if (this._callback) this._callback();
294 } 341 }
@@ -358,8 +405,6 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
358 value: function (scripttags) { 405 value: function (scripttags) {
359 // 406 //
360 var n, webgldata, fileRead; 407 var n, webgldata, fileRead;
361 //Setting the iFrame property for reference in helper class
362 this.model.webGlHelper.iframe = this.model.views.design.iframe;
363 //Checking for webGL Data 408 //Checking for webGL Data
364 for (var w in scripttags) { 409 for (var w in scripttags) {
365 // 410 //
@@ -385,7 +430,7 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
385 webgldata.data[n] = unescape(webgldata.data[n]); 430 webgldata.data[n] = unescape(webgldata.data[n]);
386 } 431 }
387 //TODO: Improve setter of webGL and reference 432 //TODO: Improve setter of webGL and reference
388 this.model.webGlHelper.glData = webgldata.data; 433 this._webGlHelper.glData = webgldata.data;
389 } 434 }
390 }