diff options
Diffstat (limited to 'js')
18 files changed, 227 insertions, 25 deletions
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index b0db1b6a..21321f6d 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js | |||
@@ -106,7 +106,17 @@ var stylesController = exports.StylesController = Montage.create(Component, { | |||
106 | this.defaultStylesheet = this.getSheetFromElement(this.CONST.DEFAULT_SHEET_ID); | 106 | this.defaultStylesheet = this.getSheetFromElement(this.CONST.DEFAULT_SHEET_ID); |
107 | 107 | ||
108 | this.userStyleSheets = nj.toArray(document.model.views.design.document.styleSheets).filter(function(sheet) { | 108 | this.userStyleSheets = nj.toArray(document.model.views.design.document.styleSheets).filter(function(sheet) { |
109 | return sheet !== this._stageStylesheet; | 109 | if(sheet === this._stageStylesheet) { return false; } |
110 | |||
111 | var media = sheet.ownerNode.getAttribute('media'); | ||
112 | |||
113 | ///// If the media attribute contains a query, we'll watch for changes in media | ||
114 | if(/\([0-9A-Za-z-: ]+\)/.test(media)) { | ||
115 | this.watchMedia(media); | ||
116 | } | ||
117 | |||
118 | return true; | ||
119 | |||
110 | }, this); | 120 | }, this); |
111 | 121 | ||
112 | this.initializeRootStyles(); | 122 | this.initializeRootStyles(); |
@@ -115,6 +125,33 @@ var stylesController = exports.StylesController = Montage.create(Component, { | |||
115 | }, | 125 | }, |
116 | enumerable : false | 126 | enumerable : false |
117 | }, | 127 | }, |
128 | |||
129 | _mediaList : { | ||
130 | value: [] | ||
131 | }, | ||
132 | |||
133 | watchMedia : { | ||
134 | value: function(mediaQuery, doc) { | ||
135 | var _doc = doc || this._currentDocument.model.views.design.document; | ||
136 | |||
137 | ///// Set a listener for media changes | ||
138 | _doc.defaultView.matchMedia(mediaQuery).addListener(function(e) { | ||
139 | this.handleMediaChange(e); | ||
140 | }.bind(this)); | ||
141 | } | ||
142 | }, | ||
143 | |||
144 | handleMediaChange : { | ||
145 | value: function(query) { | ||
146 | this._clearCache(); | ||
147 | |||
148 | NJevent('mediaChange', { | ||
149 | query: query, | ||
150 | source: "stylesController" | ||
151 | }); | ||
152 | } | ||
153 | }, | ||
154 | |||
118 | userStyleSheets : { | 155 | userStyleSheets : { |
119 | value : null | 156 | value : null |
120 | }, | 157 | }, |
@@ -1440,7 +1477,8 @@ var stylesController = exports.StylesController = Montage.create(Component, { | |||
1440 | rel : 'stylesheet', | 1477 | rel : 'stylesheet', |
1441 | id : id || "", | 1478 | id : id || "", |
1442 | media : 'screen', | 1479 | media : 'screen', |
1443 | title : 'Temp' | 1480 | title : 'Temp', |
1481 | 'data-ninja-node' : 'true' | ||
1444 | }); | 1482 | }); |
1445 | 1483 | ||
1446 | doc.head.appendChild(sheetElement); | 1484 | doc.head.appendChild(sheetElement); |
@@ -1467,6 +1505,9 @@ var stylesController = exports.StylesController = Montage.create(Component, { | |||
1467 | sheetEl.disabled = true; | 1505 | sheetEl.disabled = true; |
1468 | this.userStyleSheets.splice(this.userStyleSheets.indexOf(sheet), 1); | 1506 | this.userStyleSheets.splice(this.userStyleSheets.indexOf(sheet), 1); |
1469 | 1507 | ||
1508 | ///// Make sure cached rules from this stylesheet are not used | ||
1509 | this._clearCache(); | ||
1510 | |||
1470 | ///// Check to see if we're removing the default style sheet | 1511 | ///// Check to see if we're removing the default style sheet |
1471 | if(sheet === this._defaultStylesheet) { | 1512 | if(sheet === this._defaultStylesheet) { |
1472 | sheetCount = this.userStyleSheets.length; | 1513 | sheetCount = this.userStyleSheets.length; |
@@ -1475,6 +1516,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { | |||
1475 | 1516 | ||
1476 | ///// Mark for removal for i/o | 1517 | ///// Mark for removal for i/o |
1477 | sheetEl.setAttribute('data-ninja-remove', 'true'); | 1518 | sheetEl.setAttribute('data-ninja-remove', 'true'); |
1519 | sheetEl.removeAttribute('data-ninja-node'); | ||
1478 | 1520 | ||
1479 | NJevent('removeStyleSheet', sheet); | 1521 | NJevent('removeStyleSheet', sheet); |
1480 | } | 1522 | } |
@@ -1504,6 +1546,18 @@ var stylesController = exports.StylesController = Montage.create(Component, { | |||
1504 | } | 1546 | } |
1505 | }, | 1547 | }, |
1506 | 1548 | ||
1549 | setMediaAttribute : { | ||
1550 | value: function(sheet, mediaString) { | ||
1551 | if(sheet.media.mediaText === mediaString) { return false; } | ||
1552 | |||
1553 | sheet.ownerNode.setAttribute('media', mediaString); | ||
1554 | |||
1555 | this._clearCache(); | ||
1556 | |||
1557 | this.styleSheetModified(sheet); | ||
1558 | } | ||
1559 | }, | ||
1560 | |||
1507 | ///// Style Sheet Modified | 1561 | ///// Style Sheet Modified |
1508 | ///// Method to call whenever a stylesheet change is made | 1562 | ///// Method to call whenever a stylesheet change is made |
1509 | ///// Dispatches an event, and keeps list of dirty style sheets | 1563 | ///// Dispatches an event, and keeps list of dirty style sheets |
@@ -1521,6 +1575,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { | |||
1521 | ///// If the sheet doesn't already exist in the list of modified | 1575 | ///// If the sheet doesn't already exist in the list of modified |
1522 | ///// sheets, dispatch dirty event and add the sheet to the list | 1576 | ///// sheets, dispatch dirty event and add the sheet to the list |
1523 | if(sheetSearch.length === 0) { | 1577 | if(sheetSearch.length === 0) { |
1578 | NJevent('styleSheetDirty', eventData); | ||
1524 | this.dirtyStyleSheets.push({ | 1579 | this.dirtyStyleSheets.push({ |
1525 | document : sheet.ownerNode.ownerDocument, | 1580 | document : sheet.ownerNode.ownerDocument, |
1526 | stylesheet : sheet | 1581 | stylesheet : sheet |
diff --git a/js/helper-classes/RDGE/src/core/script/MeshManager.js b/js/helper-classes/RDGE/src/core/script/MeshManager.js index 4ff95cc4..f0600793 100755 --- a/js/helper-classes/RDGE/src/core/script/MeshManager.js +++ b/js/helper-classes/RDGE/src/core/script/MeshManager.js | |||
@@ -201,11 +201,31 @@ RDGE.MeshManager.prototype.onLoaded = function (meshName) { | |||
201 | }; | 201 | }; |
202 | 202 | ||
203 | RDGE.MeshManager.prototype.exportJSON = function () { | 203 | RDGE.MeshManager.prototype.exportJSON = function () { |
204 | |||
204 | for (var m in this.modelMap) { | 205 | for (var m in this.modelMap) { |
205 | this.modelMap[m].primitive.built = false; | 206 | this.modelMap[m].primitive.built = false; |
206 | } | 207 | } |
207 | 208 | ||
208 | return JSON.stringify(this.modelMap); | 209 | function replacer(key, value) { |
210 | if (key === "bufferStreams") | ||
211 | { | ||
212 | var nStreams = value.length; | ||
213 | for (iStream=0; iStream<nStreams; iStream++) | ||
214 | { | ||
215 | var arr = value[iStream]; | ||
216 | var n = arr.length; | ||
217 | for (var i=0; i<n; i++) | ||
218 | { | ||
219 | var val = arr[i]; | ||
220 | arr[i] = val.toFixed ? Number(val.toFixed(4)) : val; | ||
221 | } | ||
222 | } | ||
223 | } | ||
224 | |||
225 | return value; | ||
226 | } | ||
227 | |||
228 | return JSON.stringify(this.modelMap, replacer); | ||
209 | }; | 229 | }; |
210 | 230 | ||
211 | RDGE.MeshManager.prototype.importJSON = function (jsonMeshExport) { | 231 | RDGE.MeshManager.prototype.importJSON = function (jsonMeshExport) { |
diff --git a/js/helper-classes/RDGE/src/core/script/renderer.js b/js/helper-classes/RDGE/src/core/script/renderer.js index 889cd62e..52158514 100755 --- a/js/helper-classes/RDGE/src/core/script/renderer.js +++ b/js/helper-classes/RDGE/src/core/script/renderer.js | |||
@@ -363,6 +363,8 @@ RDGE._renderer = function (canvas) { | |||
363 | if (mips === undefined) | 363 | if (mips === undefined) |
364 | mips = true; | 364 | mips = true; |
365 | 365 | ||
366 | //console.log( "createTexture " + url + ", unloadedCount: " + this.unloadedTextureCount + ", world " + RDGE.globals.engine.getContext().renderer._world._worldCount ); | ||
367 | |||
366 | if (texture) { | 368 | if (texture) { |
367 | texture.image = new Image(); | 369 | texture.image = new Image(); |
368 | texture.image.src = url; | 370 | texture.image.src = url; |
@@ -380,7 +382,7 @@ RDGE._renderer = function (canvas) { | |||
380 | texture.image.onerror = function () { | 382 | texture.image.onerror = function () { |
381 | this.context.renderer.unloadedTextureCount--; | 383 | this.context.renderer.unloadedTextureCount--; |
382 | if (texture.callback) texture.callback(texture); | 384 | if (texture.callback) texture.callback(texture); |
383 | //console.log( "Error loading texture: " + texture.image.src ); | 385 | console.log( "Error loading texture: " + texture.image.src ); |
384 | if (this.context.renderer.unloadedTextureCount < 0) | 386 | if (this.context.renderer.unloadedTextureCount < 0) |
385 | console.log("more textures loaded then created..."); | 387 | console.log("more textures loaded then created..."); |
386 | }; | 388 | }; |
diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js index cfb7ef07..bca9b05b 100755 --- a/js/lib/NJUtils.js +++ b/js/lib/NJUtils.js | |||
@@ -241,6 +241,7 @@ exports.NJUtils = Montage.create(Component, { | |||