diff options
Diffstat (limited to 'js/document')
-rwxr-xr-x | js/document/document-html.js | 10 | ||||
-rwxr-xr-x | js/document/helpers/webgl-helper.js | 14 | ||||
-rwxr-xr-x | js/document/models/html.js | 23 | ||||
-rwxr-xr-x | js/document/templates/banner/index.html | 24 | ||||
-rwxr-xr-x | js/document/templates/html/index.html | 27 | ||||
-rwxr-xr-x | js/document/views/design.js | 30 |
6 files changed, 86 insertions, 42 deletions
diff --git a/js/document/document-html.js b/js/document/document-html.js index 33a41a8e..4a8d5d41 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js | |||
@@ -88,7 +88,7 @@ exports.HtmlDocument = Montage.create(Component, { | |||
88 | //Adding observer to know when template is ready | 88 | //Adding observer to know when template is ready |
89 | this._observer = new WebKitMutationObserver(this.handleTemplateReady.bind(this)); | 89 | this._observer = new WebKitMutationObserver(this.handleTemplateReady.bind(this)); |
90 | this._observer.observe(this.model.views.design.document.head, {childList: true}); | 90 | this._observer.observe(this.model.views.design.document.head, {childList: true}); |
91 | }.bind(this), template); | 91 | }.bind(this), template, {viewCallback: this.handleViewReady, context: this}); |
92 | } else { | 92 | } else { |
93 | //TODO: Identify default view (probably code) | 93 | //TODO: Identify default view (probably code) |
94 | } | 94 | } |
@@ -101,10 +101,14 @@ exports.HtmlDocument = Montage.create(Component, { | |||
101 | //Removing observer, only needed on initial load | 101 | //Removing observer, only needed on initial load |
102 | this._observer.disconnect(); | 102 | this._observer.disconnect(); |
103 | this._observer = null; | 103 | this._observer = null; |
104 | //Making callback after view is loaded | ||
105 | this.loaded.callback.call(this.loaded.context, this); | ||
106 | } | 104 | } |
107 | }, | 105 | }, |
106 | handleViewReady: { | ||
107 | value: function() { | ||
108 | //Making callback after view is loaded | ||
109 | this.loaded.callback.call(this.loaded.context, this); | ||
110 | } | ||
111 | }, | ||
108 | //////////////////////////////////////////////////////////////////// | 112 | //////////////////////////////////////////////////////////////////// |
109 | // | 113 | // |
110 | closeDocument: { | 114 | 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 9aa0d27e..a367f95f 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js | |||
@@ -64,31 +64,8 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { | |||
64 | }, | 64 | }, |
65 | //////////////////////////////////////////////////////////////////// | 65 | //////////////////////////////////////////////////////////////////// |
66 | // | 66 | // |
67 | userComponents: { | ||
68 | value: {} | ||
69 | }, | ||
70 | //////////////////////////////////////////////////////////////////// | ||
71 | // | ||
72 | documentRoot: { | 67 | documentRoot: { |
73 | value: null | 68 | value: null |
74 | }, | ||
75 | //////////////////////////////////////////////////////////////////// | ||
76 | //Add a reference to a component instance to the userComponents hash using the element UUID | ||
77 | setComponentInstance: { | ||
78 | value: function(instance, el) { | ||
79 | this.userComponents[el.uuid] = instance; | ||
80 | } | ||
81 | }, | ||
82 | //////////////////////////////////////////////////////////////////// | ||
83 | //Returns the component instance obj from the element | ||
84 | getComponentFromElement: { | ||
85 | value: function(el) { | ||
86 | if(el) { | ||
87 | if(el.uuid) return this.userComponents[el.uuid]; | ||
88 | } else { | ||
89 | return null; | ||
90 | } | ||
91 | } | ||
92 | } | 69 | } |
93 | //////////////////////////////////////////////////////////////////// | 70 | //////////////////////////////////////////////////////////////////// |
94 | //////////////////////////////////////////////////////////////////// | 71 | //////////////////////////////////////////////////////////////////// |
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 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, { | |||
< |