aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorValerio Virgillito2012-05-22 14:47:17 -0700
committerValerio Virgillito2012-05-22 14:47:17 -0700
commitb3e85f609f704d668c8022c53418f8056bc71260 (patch)
tree122197204fff1b8adccfc089d6e6869e8c310550 /js
parent9b6da637d9654727426c6d78f17e3804bbd84ce5 (diff)
parentc5dad8ddc94b2e1c80565dfee072bda88e8880da (diff)
downloadninja-b3e85f609f704d668c8022c53418f8056bc71260.tar.gz
Merge pull request #250 from joseeight/Document
Montage components mapping & External data webGL support
Diffstat (limited to 'js')
-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
5 files changed, 136 insertions, 47 deletions
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 }
227 },
228 ////////////////////////////////////////////////////////////////////
229 //
230 _getUserDirectory: {
231 value: function (path) {
232 //Checking for data directory
233 var check = this.application.ninja.coreIoApi.fileExists({uri: path}), directory;
234 //Creating directory if doesn't exists
235 switch (check.status) {
236 case 204: //Exists
237 directory = path;
238 break;
239 case 404: //Doesn't exists
240 directory = this.application.ninja.coreIoApi.createDirectory({uri: path});
241 //Checking for success
242 if (directory.status === 201) {
243 directory = path;
244 } else {
245 //Error
246 directory = null;
247 }
248 break;
249 default: //Error
250 directory = null;
251 break;
252 }
253 //Returning the path to the directory on disk (null for any error)
254 return directory;
255 }
256 },
257 ////////////////////////////////////////////////////////////////////
258 //
206 parseHtmlToNinjaTemplate: { 259 parseHtmlToNinjaTemplate: {
207 enumerable: false, 260 enumerable: false,
208 value: function (html) { 261 value: function (html) {
@@ -406,20 +459,19 @@ exports.IoMediator = Montage.create(Component, {
406 } 459 }
407 } 460 }
408 // 461 //
409 var matchingtags = [], scripts = template.file.content.document.getElementsByTagName('script'), webgltag, webgljstag, webgllibtag, webglrdgetag, mjstag, mjslibtag;