aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--assets/canvas-runtime.js32
-rwxr-xr-xjs/document/document-html.js17
-rwxr-xr-xjs/document/models/base.js2
-rwxr-xr-xjs/document/views/design.js13
-rw-r--r--js/io/system/ninjalibrary.json2
-rw-r--r--js/mediators/io-mediator.js149
6 files changed, 166 insertions, 49 deletions
diff --git a/assets/canvas-runtime.js b/assets/canvas-runtime.js
index eeafaab6..9bf22313 100644
--- a/assets/canvas-runtime.js
+++ b/assets/canvas-runtime.js
@@ -8,9 +8,37 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
8var NinjaCvsRt = NinjaCvsRt || {}; 8var NinjaCvsRt = NinjaCvsRt || {};
9 9
10/////////////////////////////////////////////////////////////////////// 10///////////////////////////////////////////////////////////////////////
11//Loading webGL/canvas data on window load
12window.addEventListener('load', loadCanvasData, false);
13//Load data function (on document loaded)
14function loadCanvasData (e) {
15 //Cleaning up events
16 window.removeEventListener('load', loadCanvasData, false);
17 //Getting tag with data, MUST contain attribute
18 var xhr, tag = document.querySelectorAll(['script[data-ninja-canvas-lib]'])[0];
19 //Checking for data to be external file
20 if (tag.getAttribute('data-ninja-canvas-json') !== null) {
21 //Loading JSON data
22 xhr = new XMLHttpRequest();
23 xhr.open("GET", tag.getAttribute('data-ninja-canvas-json'), false);
24 xhr.send();
25 //Checking for data
26 if (xhr.readyState === 4) {
27 //Calling method to initialize all webGL/canvas(es)
28 NinjaCvsRt.initWebGl(document.body, tag.getAttribute('data-ninja-canvas-libpath'), xhr.response);
29 } else {
30 //TODO: Add error for users
31 }
32 } else {//Data in document itself
33 //Calling method to initialize all webGL/canvas(es)
34 NinjaCvsRt.initWebGl(document.body, tag.getAttribute('data-ninja-canvas-libpath'), document.querySelectorAll(['script[data-ninja-canvas]'])[0].innerHTML);
35 }
36}
37
38///////////////////////////////////////////////////////////////////////
11//Loading webGL/canvas data 39//Loading webGL/canvas data
12NinjaCvsRt.initWebGl = function (rootElement, directory) { 40NinjaCvsRt.initWebGl = function (rootElement, directory, data) {
13 var cvsDataMngr, ninjaWebGlData = JSON.parse((document.querySelectorAll(['script[data-ninja-webgl]'])[0].innerHTML.replace('(', '')).replace(')', '')); 41 var cvsDataMngr, ninjaWebGlData = JSON.parse((data.replace('(', '')).replace(')', ''));
14 if (ninjaWebGlData && ninjaWebGlData.data) { 42 if (ninjaWebGlData && ninjaWebGlData.data) {
15 for (var n=0; ninjaWebGlData.data[n]; n++) { 43 for (var n=0; ninjaWebGlData.data[n]; n++) {
16 ninjaWebGlData.data[n] = unescape(ninjaWebGlData.data[n]); 44 ninjaWebGlData.data[n] = unescape(ninjaWebGlData.data[n]);
diff --git a/js/document/document-html.js b/js/document/document-html.js
index bb391793..d6b4ba95 100755
--- a/js/document/document-html.js
+++ b/js/document/document-html.js
@@ -125,9 +125,10 @@ exports.HtmlDocument = Montage.create(Component, {
125 // 125 //
126 closeDocument: { 126 closeDocument: {
127 value: function (context, callback) { 127 value: function (context, callback) {
128 //Closing document and getting outcome
128 var closed = this.model.close(null); 129 var closed = this.model.close(null);
129 130 //Making callback if specified
130 callback.call(context, this); 131 if (callback) callback.call(context, this);
131 } 132 }
132 }, 133 },
133 //////////////////////////////////////////////////////////////////// 134 ////////////////////////////////////////////////////////////////////
@@ -139,6 +140,7 @@ exports.HtmlDocument = Montage.create(Component, {
139 //this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing; 140 //this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing;
140 141
141 // Serialize the current scroll position 142 // Serialize the current scroll position
143 //TODO: Move these properties to the design view class
142 this.model.scrollLeft = this.application.ninja.stage._scrollLeft; 144 this.model.scrollLeft = this.application.ninja.stage._scrollLeft;
143 this.model.scrollTop = this.application.ninja.stage._scrollTop; 145 this.model.scrollTop = this.application.ninja.stage._scrollTop;
144 this.model.userContentLeft = this.application.ninja.stage._userContentLeft; 146 this.model.userContentLeft = this.application.ninja.stage._userContentLeft;
@@ -146,6 +148,7 @@ exports.HtmlDocument = Montage.create(Component, {
146 148
147 149
148 // Serialize the selection 150 // Serialize the selection
151 //TODO: Move this property to the design view class
149 this.model.selection = this.application.ninja.selectedElements.slice(0); 152 this.model.selection = this.application.ninja.selectedElements.slice(0);
150 this.draw3DGrid = this.application.ninja.appModel.show3dGrid; 153 this.draw3DGrid = this.application.ninja.appModel.show3dGrid;
151 154
@@ -153,9 +156,8 @@ exports.HtmlDocument = Montage.create(Component, {
153 // TODO: Save the montage undo queue 156 // TODO: Save the montage undo queue
154 157
155 // Pause the videos 158 // Pause the videos
159 //TODO: Move these to be handled on the show/hide methods in the view
156 this.model.views.design.pauseVideos(); 160 this.model.views.design.pauseVideos();
157
158// this.model.isActive = false;
159 } 161 }
160 }, 162 },
161 //////////////////////////////////////////////////////////////////// 163 ////////////////////////////////////////////////////////////////////
@@ -167,18 +169,21 @@ exports.HtmlDocument = Montage.create(Component, {
167 //this.application.ninja.stage.drawUtils.gridVerticalSpacing = this.gridVerticalSpacing; 169 //this.application.ninja.stage.drawUtils.gridVerticalSpacing = this.gridVerticalSpacing;
168 170
169 // Deserialize the current scroll position 171 // Deserialize the current scroll position
172 //TODO: Move these properties to the design view class
170 this.application.ninja.stage._scrollLeft = this.model.scrollLeft; 173 this.application.ninja.stage._scrollLeft = this.model.scrollLeft;
171 this.application.ninja.stage._scrollTop = this.model.scrollTop; 174 this.application.ninja.stage._scrollTop = this.model.scrollTop;
172 this.application.ninja.stage._userContentLeft = this.model.userContentLeft; 175 this.application.ninja.stage._userContentLeft = this.model.userContentLeft;
173 this.application.ninja.stage._userContentTop = this.model.userContentTop; 176 this.application.ninja.stage._userContentTop = this.model.userContentTop;
174 177
178 //TODO: Move this property to the design view class
175 this.application.ninja.selectedElements = this.model.selection.slice(0); 179 this.application.ninja.selectedElements = this.model.selection.slice(0);
176 180
177 this.application.ninja.appModel.show3dGrid = this.draw3DGrid; 181 this.application.ninja.appModel.show3dGrid = this.draw3DGrid;
178 182
179 // Serialize the undo 183 // Serialize the undo
180 // TODO: Save the montage undo queue 184 // TODO: Save the montage undo queue
181 185
186 //TODO: Move this to the document controller
182 this.model.isActive = true; 187 this.model.isActive = true;
183 } 188 }
184 } 189 }
diff --git a/js/document/models/base.js b/js/document/models/base.js
index c99e36c7..6d9d2e89 100755
--- a/js/document/models/base.js
+++ b/js/document/models/base.js
@@ -100,7 +100,7 @@ exports.BaseDocumentModel = Montage.create(Component, {
100 } 100 }
101 break; 101 break;
102 default: 102 default:
103 if (this.template.type === 'banner' || this.template.type === 'animation') { 103 if (this.template && (this.template.type === 'banner' || this.template.type === 'animation')) {
104 window.open('/js/document/templates/preview/banner.html?width='+this.template.size.width+'&height='+this.template.size.height+'&url='+this.url); 104 window.open('/js/document/templates/preview/banner.html?width='+this.template.size.width+'&height='+this.template.size.height+'&url='+this.url);
105 } else { 105 } else {
106 window.open(this.url); 106 window.open(this.url);
diff --git a/js/document/views/design.js b/js/document/views/design.js
index 3f58650e..b3887fdf 100755
--- a/js/document/views/design.js
+++ b/js/document/views/design.js
@@ -324,7 +324,7 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
324 initWebGl: { 324 initWebGl: {
325 value: function (scripttags) { 325 value: function (scripttags) {
326 // 326 //
327 var n, webgldata; 327 var n, webgldata, fileRead;
328 //Setting the iFrame property for reference in helper class 328 //Setting the iFrame property for reference in helper class
329 this.model.webGlHelper.iframe = this.model.views.design.iframe; 329 this.model.webGlHelper.iframe = this.model.views.design.iframe;
330 //Checking for webGL Data 330 //Checking for webGL Data
@@ -333,9 +333,18 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
333 webgldata = null; 333 webgldata = null;
334 //Checking for tags with webGL data 334 //Checking for tags with webGL data
335 if (scripttags[w].getAttribute) { 335 if (scripttags[w].getAttribute) {
336 if (scripttags[w].getAttribute('data-ninja-webgl') !== null) { 336 if (scripttags[w].getAttribute('data-ninja-canvas') !== null) {
337 //TODO: Add logic to handle more than one data tag 337 //TODO: Add logic to handle more than one data tag
338 webgldata = JSON.parse((scripttags[w].innerHTML.replace("(", "")).replace(")", "")); 338 webgldata = JSON.parse((scripttags[w].innerHTML.replace("(", "")).replace(")", ""));
339 } else if (scripttags[w].getAttribute('data-ninja-canvas-json') !== null) {
340 //TODO: Add check for hardcoded URL
341 fileRead = this.application.ninja.ioMediator.fio.readFile({uri: this.application.ninja.documentController.documentHackReference.root+scripttags[w].getAttribute('data-ninja-canvas-json')});
342 //
343 if (fileRead.status === 204) {
344 webgldata = JSON.parse((fileRead.file.content.replace("(", "")).replace(")", ""));
345 } else {
346 //Error
347 }
339 } 348 }
340 //Checking for webGL data and building data array 349 //Checking for webGL data and building data array
341 if (webgldata && webgldata.data) { 350 if (webgldata && webgldata.data) {
diff --git a/js/io/system/ninjalibrary.json b/js/io/system/ninjalibrary.json
index 041e7ed7..5c1eb875 100644
--- a/js/io/system/ninjalibrary.json
+++ b/js/io/system/ninjalibrary.json
@@ -1,6 +1,6 @@
1{ 1{
2 "libraries": [ 2 "libraries": [
3 {"name": "Montage", "path": "/node_modules/descriptor.json", "version": "0.10.0.0"}, 3 {"name": "Montage", "path": "/node_modules/descriptor.json", "version": "0.10.0.0"},
4 {"name": "RDGE", "path": "/assets/descriptor.json", "version": "0.5.6.0"} 4 {"name": "RDGE", "path": "/assets/descriptor.json", "version": "0.5.7.0"}
5 ] 5 ]
6} \ No newline at end of file 6} \ No newline at end of file
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js
index ade27728..e9ed86d7 100644
--- a/js/mediators/io-mediator.js
+++ b/js/mediators/io-mediator.js
@@ -203,6 +203,59 @@ exports.IoMediator = Montage.create(Component, {
203 }, 203 },
204 //////////////////////////////////////////////////////////////////// 204 ////////////////////////////////////////////////////////////////////
205 // 205 //
206 getDataDirectory: {
207 value: function (path) {
208 //TODO: Implement user overwrite
209 return this._getUserDirectory(path+'data/');
210 }
211 },
212 ////////////////////////////////////////////////////////////////////
213 //
214 getNinjaDirectory: {
215 value: function (path) {
216 //TODO: Implement user overwrite
217 return this._getUserDirectory(this.getDataDirectory(path)+'ninja/');
218 }
219 },
220 ////////////////////////////////////////////////////////////////////
221 //
222 getCanvasDirectory: {
223 value: function (path) {
224 //TODO: Implement user overwrite
225 return this._getUserDirectory(this.getNinjaDirectory(path)+'canvas/');
226 }