aboutsummaryrefslogtreecommitdiff
path: root/js/document
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
parent0efbbf8287517b755be1774f6aa49947bed50a0d (diff)
parentb75fe9369f7caec0351d298f7106c8d59572b440 (diff)
downloadninja-7d1a564a8fd246c621f674b5521554fbfc058281.tar.gz
Merge branch 'refs/heads/Ninja-Internal' into FileIO
Diffstat (limited to 'js/document')
-rwxr-xr-xjs/document/document-html.js10
-rwxr-xr-xjs/document/helpers/webgl-helper.js14
-rwxr-xr-xjs/document/models/html.js23
-rwxr-xr-xjs/document/templates/banner/index.html24
-rwxr-xr-xjs/document/templates/html/index.html27
-rwxr-xr-xjs/document/views/design.js28
6 files changed, 84 insertions, 42 deletions
diff --git a/js/document/document-html.js b/js/document/document-html.js
index c9acd2e0..04565753 100755
--- a/js/document/document-html.js
+++ b/js/document/document-html.js
@@ -90,7 +90,7 @@ exports.HtmlDocument = Montage.create(Component, {
90 //Adding observer to know when template is ready 90 //Adding observer to know when template is ready
91 this._observer = new WebKitMutationObserver(this.handleTemplateReady.bind(this)); 91 this._observer = new WebKitMutationObserver(this.handleTemplateReady.bind(this));
92 this._observer.observe(this.model.views.design.document.head, {childList: true}); 92 this._observer.observe(this.model.views.design.document.head, {childList: true});
93 }.bind(this), template); 93 }.bind(this), template, {viewCallback: this.handleViewReady, context: this});
94 } else { 94 } else {
95 //TODO: Identify default view (probably code) 95 //TODO: Identify default view (probably code)
96 } 96 }
@@ -103,10 +103,14 @@ exports.HtmlDocument = Montage.create(Component, {
103 //Removing observer, only needed on initial load 103 //Removing observer, only needed on initial load
104 this._observer.disconnect(); 104 this._observer.disconnect();
105 this._observer = null; 105 this._observer = null;
106 //Making callback after view is loaded
107 this.loaded.callback.call(this.loaded.context, this);
108 } 106 }
109 }, 107 },
108 handleViewReady: {
109 value: function() {
110 //Making callback after view is loaded
111 this.loaded.callback.call(this.loaded.context, this);
112 }
113 },
110 //////////////////////////////////////////////////////////////////// 114 ////////////////////////////////////////////////////////////////////
111 // 115 //
112 closeDocument: { 116 closeDocument: {
diff --git a/js/document/helpers/webgl-helper.js b/js/document/helpers/webgl-helper.js
index 84ddc547..6d9ced14 100755
--- a/js/document/helpers/webgl-helper.js
+++ b/js/document/helpers/webgl-helper.js
@@ -40,7 +40,7 @@ exports.webGlDocumentHelper = Montage.create(Component, {
40 if (elt) { 40 if (elt) {
41 var matLib = MaterialsModel.exportMaterials(); 41 var matLib = MaterialsModel.exportMaterials();
42 this._glData = [matLib]; 42 this._glData = [matLib];
43 this.collectGLData(elt, this._glData ); 43 this.collectGLData(this.iframe.contentWindow.document, this._glData );
44 } else { 44 } else {
45 this._glData = null 45 this._glData = null
46 } 46 }
@@ -97,10 +97,6 @@ exports.webGlDocumentHelper = Montage.create(Component, {
97 // 97 //
98 if (canvas) { 98 if (canvas) {
99 // 99 //
100 if (!canvas.elementModel) {
101 NJUtils.makeElementModel(canvas, "Canvas", "shape", true);
102 }
103 //
104 if (canvas.elementModel) { 100 if (canvas.elementModel) {
105 if (canvas.elementModel.shapeModel.GLWorld) { 101 if (canvas.elementModel.shapeModel.GLWorld) {
106 canvas.elementModel.shapeModel.GLWorld.clearTree(); 102 canvas.elementModel.shapeModel.GLWorld.clearTree();
@@ -194,6 +190,13 @@ exports.webGlDocumentHelper = Montage.create(Component, {
194 // 190 //
195 collectGLData: { 191 collectGLData: {
196 value: function( elt, dataArray ) { 192 value: function( elt, dataArray ) {
193 Array.prototype.slice.call(elt.querySelectorAll('[data-RDGE-id]'),0).forEach(function(glCanvas) {
194 dataArray.push(glCanvas.elementModel.shapeModel.GLWorld.exportJSON());
195 });
196
197 // Removing the old loop that went through all the elements.
198 // TODO: Remove the following code once QE has tested it.
199/*
197 // 200 //
198 var i, data, nKids, child; 201 var i, data, nKids, child;
199 // 202 //
@@ -209,6 +212,7 @@ exports.webGlDocumentHelper = Montage.create(Component, {
209 this.collectGLData( child, dataArray ); 212 this.collectGLData( child, dataArray );
210 } 213 }
211 } 214 }
215 */
212 } 216 }
213 } 217 }
214 //////////////////////////////////////////////////////////////////// 218 ////////////////////////////////////////////////////////////////////
diff --git a/js/document/models/html.js b/js/document/models/html.js
index 0f88229d..6bdc6546 100755
--- a/js/document/models/html.js
+++ b/js/document/models/html.js
@@ -73,29 +73,6 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, {
73 value: null 73 value: null
74 }, 74 },
75 //////////////////////////////////////////////////////////////////// 75 ////////////////////////////////////////////////////////////////////
76 //
77 userComponents: {
78 value: {}
79 },
80 ////////////////////////////////////////////////////////////////////
81 //Add a reference to a component instance to the userComponents hash using the element UUID
82 setComponentInstance: {
83 value: function(instance, el) {
84 this.userComponents[el.uuid] = instance;
85 }
86 },
87 ////////////////////////////////////////////////////////////////////
88 //Returns the component instance obj from the element
89 getComponentFromElement: {
90 value: function(el) {
91 if(el) {
92 if(el.uuid) return this.userComponents[el.uuid];
93 } else {
94 return null;
95 }
96 }
97 }
98 ////////////////////////////////////////////////////////////////////
99 //////////////////////////////////////////////////////////////////// 76 ////////////////////////////////////////////////////////////////////
100}); 77});
101//////////////////////////////////////////////////////////////////////// 78////////////////////////////////////////////////////////////////////////
diff --git a/js/document/templates/banner/index.html b/js/document/templates/banner/index.html
index f1ee3d98..08a998e5 100755
--- a/js/document/templates/banner/index.html
+++ b/js/document/templates/banner/index.html
@@ -74,9 +74,27 @@
74 </style> 74 </style>
75 75
76 <script type="text/javascript" data-ninja-template="true"> 76 <script type="text/javascript" data-ninja-template="true">
77 function getElement(x,y) { 77
78 return document.elementFromPoint(x,y); 78 function getElement(x,y) {
79 } 79 return document.elementFromPoint(x,y);
80 }
81
82 var njmodelGet = function njmodelGet() {
83 return (this.hasOwnProperty("_model") ? this._model: document.modelGenerator.call(this));
84 };
85
86 Object.defineProperty(Object.prototype, "_model", {
87 enumerable: false,
88 value: null,
89 writable: true
90 });
91
92 Object.defineProperty(Object.prototype, "elementModel", {
93 configurable: true,
94 get: njmodelGet,
95 set: function() {
96 }
97 });
80 </script> 98 </script>
81 99
82 <!-- TODO: Determine if loading Montage is always needed or if it could be done author-time or on file open --> 100 <!-- TODO: Determine if loading Montage is always needed or if it could be done author-time or on file open -->
diff --git a/js/document/templates/html/index.html b/js/document/templates/html/index.html
index 70187900..c74a7251 100755
--- a/js/document/templates/html/index.html
+++ b/js/document/templates/html/index.html
@@ -57,13 +57,32 @@
57 57
58 .nj-element-highlight { 58 .nj-element-highlight {
59 outline: 4px solid #ff0000; 59 outline: 4px solid #ff0000;
60 } 60 }
61 </style> 61 </style>
62 62
63 <script type="text/javascript" data-ninja-template="true"> 63 <script type="text/javascript" data-ninja-template="true">
64 function getElement(x,y) { 64
65 return document.elementFromPoint(x,y); 65 function getElement(x,y) {
66 } 66 return document.elementFromPoint(x,y);
67 }
68
69 var njmodelGet = function njmodelGet() {
70 return (this.hasOwnProperty("_model") ? this._model: document.modelGenerator.call(this));
71 };
72
73 Object.defineProperty(Object.prototype, "_model", {
74 enumerable: false,
75 value: null,
76 writable: true
77 });
78
79 Object.defineProperty(Object.prototype, "elementModel", {
80 configurable: true,
81 get: njmodelGet,
82 set: function() {
83 }
84 });
85
67 </script> 86 </script>
68 87
69 <script type="text/javascript" data-package="../app" src="../../../../node_modules/montage/montage.js" data-ninja-template="true"></script> 88 <script type="text/javascript" data-package="../app" src="../../../../node_modules/montage/montage.js" data-ninja-template="true"></script>
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.crea