diff options
Diffstat (limited to 'js')
26 files changed, 1503 insertions, 153 deletions
diff --git a/js/components/ui/tree-basic/treeItem.reel/treeItem.js b/js/components/ui/tree-basic/treeItem.reel/treeItem.js index a67dad43..13e278e9 100755 --- a/js/components/ui/tree-basic/treeItem.reel/treeItem.js +++ b/js/components/ui/tree-basic/treeItem.reel/treeItem.js | |||
@@ -107,8 +107,8 @@ exports.TreeItem = Montage.create(Component, { | |||
107 | //icon or text click sends selection event | 107 | //icon or text click sends selection event |
108 | var contentEls = this.element.querySelectorAll(".atreeItemContent"); | 108 | var contentEls = this.element.querySelectorAll(".atreeItemContent"); |
109 | for(var i=0;i<contentEls.length;i++){ | 109 | for(var i=0;i<contentEls.length;i++){ |
110 | contentEls[i].addEventListener("click", function(evt){that.handleTreeItemContentClick(evt);}, false); | 110 | contentEls[i].addEventListener("click", function(evt){that.handleTreeItemContentClick(evt);}, true); |
111 | contentEls[i].addEventListener("dblclick", function(evt){that.handleTreeItemContentDblclick(evt);}, false); | 111 | contentEls[i].addEventListener("dblclick", function(evt){that.handleTreeItemContentDblclick(evt);}, true); |
112 | } | 112 | } |
113 | 113 | ||
114 | this.element.addEventListener("mouseover", function(evt){that.handleTreeItemMouseover(evt);}, false); | 114 | this.element.addEventListener("mouseover", function(evt){that.handleTreeItemMouseover(evt);}, false); |
@@ -123,7 +123,7 @@ exports.TreeItem = Montage.create(Component, { | |||
123 | if(this.treeItemData.modifiedDate){this.metadata = this.metadata + "<br />" + "Modified date: "+ this.formatTimestamp(this.treeItemData.modifiedDate);} | 123 | if(this.treeItemData.modifiedDate){this.metadata = this.metadata + "<br />" + "Modified date: "+ this.formatTimestamp(this.treeItemData.modifiedDate);} |
124 | 124 | ||
125 | if((this.treeItemData.type === "directory") && (this.expandAfterDraw === true)){ | 125 | if((this.treeItemData.type === "directory") && (this.expandAfterDraw === true)){ |
126 | this.toggleContent(this.treeArrow); | 126 | this.expand(this.treeArrow); |
127 | } | 127 | } |
128 | if(this.treeItemData.uri === this.highlightedUri){ | 128 | if(this.treeItemData.uri === this.highlightedUri){ |
129 | this.itemName.classList.add("selected"); | 129 | this.itemName.classList.add("selected"); |
@@ -171,6 +171,35 @@ exports.TreeItem = Montage.create(Component, { | |||
171 | } | 171 | } |
172 | }, | 172 | }, |
173 | 173 | ||
174 | expand:{ | ||
175 | writable:false, | ||
176 | enumerable:true, | ||
177 | value:function(el){ | ||
178 | //if children already drawn then just hide/show | ||
179 | if(this.element.getElementsByTagName("ul").length > 0){ | ||
180 | var theParent = this.element.getElementsByTagName("ul")[0].parentNode; | ||
181 | if(theParent.classList.contains("hideTree")){//collapsed | ||
182 | theParent.classList.remove("hideTree");//expand | ||
183 | el.innerHTML = "▼"; | ||
184 | } | ||
185 | } | ||
186 | //else send event to draw the children | ||
187 | else{ | ||
188 | var treeClickEvent = document.createEvent("Events"); | ||
189 | treeClickEvent.initEvent("drawTree", false, false); | ||
190 | treeClickEvent.uri = this.treeItemData.uri; | ||
191 | treeClickEvent.uriType = this.treeItemData.type; | ||
192 | var divEl = document.createElement("div"); | ||
193 | this.element.appendChild(divEl); | ||
194 | treeClickEvent.subTreeContainer = divEl; | ||
195 | this.element.dispatchEvent(treeClickEvent); | ||
196 | |||
197 | el.innerHTML = "▼"; | ||
198 | } | ||
199 | } | ||
200 | }, | ||
201 | |||
202 | |||
174 | /** | 203 | /** |
175 | * Event Listeners | 204 | * Event Listeners |
176 | */ | 205 | */ |
diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 9b0e638a..53cca029 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js | |||
@@ -112,6 +112,15 @@ exports.SelectionController = Montage.create(Component, { | |||
112 | if(!this._isDocument) { | 112 | if(!this._isDocument) { |
113 | if(this.findSelectedElement(event.detail) !== -1) { | 113 | if(this.findSelectedElement(event.detail) !== -1) { |
114 | this.executeSelectElement(); | 114 | this.executeSelectElement(); |
115 | var element = event.detail; | ||
116 | if (element) { | ||
117 | if (element.elementModel) { | ||
118 | if (element.elementModel.shapeModel) { | ||
119 | if (element.elementModel.shapeModel.GLWorld) | ||
120 | element.elementModel.shapeModel.GLWorld.clearTree(); | ||
121 | } | ||
122 | } | ||
123 | } | ||
115 | } | 124 | } |
116 | } | 125 | } |
117 | } | 126 | } |
diff --git a/js/document/html-document.js b/js/document/html-document.js index be1f89e2..aa57d848 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js | |||
@@ -9,7 +9,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
9 | var Montage = require("montage/core/core").Montage, | 9 | var Montage = require("montage/core/core").Montage, |
10 | TextDocument = require("js/document/text-document").TextDocument, | 10 | TextDocument = require("js/document/text-document").TextDocument, |
11 | NJUtils = require("js/lib/NJUtils").NJUtils, | 11 | NJUtils = require("js/lib/NJUtils").NJUtils, |
12 | GLWorld = require("js/lib/drawing/world").World; | 12 | GLWorld = require("js/lib/drawing/world").World, |
13 | MaterialsModel = require("js/models/materials-model").MaterialsModel; | ||
13 | //////////////////////////////////////////////////////////////////////// | 14 | //////////////////////////////////////////////////////////////////////// |
14 | // | 15 | // |
15 | exports.HTMLDocument = Montage.create(TextDocument, { | 16 | exports.HTMLDocument = Montage.create(TextDocument, { |
@@ -193,12 +194,9 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
193 | var elt = this.iframe.contentWindow.document.getElementById("UserContent"); | 194 | var elt = this.iframe.contentWindow.document.getElementById("UserContent"); |
194 | // | 195 | // |
195 | if (elt) { | 196 | if (elt) { |
196 | this._glData = []; | 197 | var matLib = MaterialsModel.exportMaterials(); |
197 | //if (path) { | 198 | this._glData = [matLib]; |
198 | //this.collectGLData(elt, this._glData, path); | 199 | this.collectGLData(elt, this._glData ); |
199 | //} else { | ||
200 | this.collectGLData(elt, this._glData ); | ||
201 | //} | ||
202 | } else { | 200 | } else { |
203 | this._glData = null | 201 | this._glData = null |
204 | } | 202 | } |
@@ -219,29 +217,74 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
219 | */ | 217 | */ |
220 | 218 | ||
221 | // /* | 219 | // /* |
220 | // get the data for the next canvas | ||
222 | var importStr = value[i]; | 221 | var importStr = value[i]; |
223 | var startIndex = importStr.indexOf( "id: " ); | 222 | |
224 | if (startIndex >= 0) { | 223 | // determine if it is the new (JSON) or old style format |
225 | var endIndex = importStr.indexOf( "\n", startIndex ); | 224 | var id = null; |
226 | if (endIndex > 0) { | 225 | var jObj = null; |
227 | var id = importStr.substring( startIndex+4, endIndex ); | 226 | var index = importStr.indexOf( ';' ); |
228 | if (id) { | 227 | if ((importStr[0] === 'v') && (index < 24)) |
229 | var canvas = this.findCanvasWithID( id, elt ); | 228 | { |
230 | if (canvas) { | 229 | // JSON format. pull off the |
231 | if (!canvas.elementModel) { | 230 | importStr = importStr.substr( index+1 ); |
232 | NJUtils.makeElementModel(canvas, "Canvas", "shape", true); | 231 | jObj = jObj = JSON.parse( importStr ); |
233 | } | 232 | id = jObj.id; |
234 | if (canvas.elementModel) { | 233 | } |
235 | if (canvas.elementModel.shapeModel.GLWorld) { | 234 | else |
236 | canvas.elementModel.shapeModel.GLWorld.clearTree(); | 235 | { |
237 | } | 236 | // at this point the data could be either the materials library or |
238 | var index = importStr.indexOf( "webGL: " ); | 237 | // an old style world. We can determine which by converting the string |
239 | var useWebGL = (index >= 0) | 238 | // to an object via JSON.parse. That operation will fail if the string |
240 | var world = new GLWorld( canvas, useWebGL ); | 239 | // is an old style world. |
241 | world.import( importStr ); | 240 | var matLibStr = 'materialLibrary;'; |
242 | this.buildShapeModel( canvas.elementModel, world ); | 241 | index = importStr.indexOf( matLibStr ); |
243 | } | 242 | if (index == 0) |
243 | { | ||
244 | importStr = importStr.substr( matLibStr.length ); | ||
245 | var matLibObj = JSON.parse( importStr ); | ||
246 | MaterialsModel.importMaterials( matLibObj ); | ||
247 | } | ||
248 | else | ||
249 | { | ||
250 | var startIndex = importStr.indexOf( "id: " ); | ||
251 | if (startIndex >= 0) { | ||
252 | var endIndex = importStr.indexOf( "\n", startIndex ); | ||
253 | if (endIndex > 0) | ||
254 | id = importStr.substring( startIndex+4, endIndex ); | ||
255 | } | ||
256 | } | ||
257 | } | ||
258 | |||