diff options
Diffstat (limited to 'js/document/views/design.js')
-rwxr-xr-x | js/document/views/design.js | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/js/document/views/design.js b/js/document/views/design.js index 2ccb82d1..b3887fdf 100755 --- a/js/document/views/design.js +++ b/js/document/views/design.js | |||
@@ -64,6 +64,11 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
64 | }, | 64 | }, |
65 | //////////////////////////////////////////////////////////////////// | 65 | //////////////////////////////////////////////////////////////////// |
66 | // | 66 | // |
67 | propertiesPanel: { | ||
68 | value: null | ||
69 | }, | ||
70 | //////////////////////////////////////////////////////////////////// | ||
71 | // | ||
67 | initialize: { | 72 | initialize: { |
68 | value: function (parent) { | 73 | value: function (parent) { |
69 | //Creating iFrame for view | 74 | //Creating iFrame for view |
@@ -184,8 +189,7 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
184 | this._bodyFragment = null; | 189 | this._bodyFragment = null; |
185 | //Calling standard method to finish opening document | 190 | //Calling standard method to finish opening document |
186 | this.bodyContentLoaded(null); | 191 | this.bodyContentLoaded(null); |
187 | 192 | //TODO: Move this to be set via the controller | |
188 | // TODO: Clean up this code | ||
189 | this.application.ninja.stage.documentOffsetLeft = parseInt((this.document.body.scrollWidth - this._template.size.width)/2); | 193 | this.application.ninja.stage.documentOffsetLeft = parseInt((this.document.body.scrollWidth - this._template.size.width)/2); |
190 | this.application.ninja.stage.documentOffsetTop = parseInt((this.document.body.scrollHeight - this._template.size.height)/2); | 194 | this.application.ninja.stage.documentOffsetTop = parseInt((this.document.body.scrollHeight - this._template.size.height)/2); |
191 | } | 195 | } |
@@ -243,17 +247,15 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
243 | } | 247 | } |
244 | } | 248 | } |
245 | } | 249 | } |
246 | //Checking and initializing webGL | 250 | //Checking for script tags then parsing check for montage and webgl |
247 | if (scripttags.length > 0) { | 251 | if (scripttags.length > 0) { |
252 | //Checking and initializing webGL | ||
248 | this.initWebGl(scripttags); | 253 | this.initWebGl(scripttags); |
249 | } //Else there is not data to parse | 254 | //Checking and initializing Montage |
250 | 255 | this.initMontage(scripttags); | |
251 | 256 | } else { | |
252 | 257 | //Else there is not data to parse | |
253 | //TODO: Load Montage Components (blocking) | 258 | } |
254 | //this.initMontage(); | ||
255 | |||
256 | |||
257 | //Makign callback if specified | 259 | //Makign callback if specified |
258 | if (this._callback) this._callback(); | 260 | if (this._callback) this._callback(); |
259 | } | 261 | } |
@@ -322,7 +324,7 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
322 | initWebGl: { | 324 | initWebGl: { |
323 | value: function (scripttags) { | 325 | value: function (scripttags) { |
324 | // | 326 | // |
325 | var n, webgldata; | 327 | var n, webgldata, fileRead; |
326 | //Setting the iFrame property for reference in helper class | 328 | //Setting the iFrame property for reference in helper class |
327 | this.model.webGlHelper.iframe = this.model.views.design.iframe; | 329 | this.model.webGlHelper.iframe = this.model.views.design.iframe; |
328 | //Checking for webGL Data | 330 | //Checking for webGL Data |
@@ -331,9 +333,18 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
331 | webgldata = null; | 333 | webgldata = null; |
332 | //Checking for tags with webGL data | 334 | //Checking for tags with webGL data |
333 | if (scripttags[w].getAttribute) { | 335 | if (scripttags[w].getAttribute) { |
334 | if (scripttags[w].getAttribute('data-ninja-webgl') !== null) { | 336 | if (scripttags[w].getAttribute('data-ninja-canvas') !== null) { |
335 | //TODO: Add logic to handle more than one data tag | 337 | //TODO: Add logic to handle more than one data tag |
336 | 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 | } | ||
337 | } | 348 | } |
338 | //Checking for webGL data and building data array | 349 | //Checking for webGL data and building data array |
339 | if (webgldata && webgldata.data) { | 350 | if (webgldata && webgldata.data) { |
@@ -350,8 +361,14 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
350 | //////////////////////////////////////////////////////////////////// | 361 | //////////////////////////////////////////////////////////////////// |
351 | // | 362 | // |
352 | initMontage: { | 363 | initMontage: { |
353 | value: function () { | 364 | value: function (scripttags) { |
354 | //initWithDocument(window.document) instantiateWithOwnerAndDocument(null, window.document) | 365 | // |
366 | this.iframe.contentWindow.document.body.addEventListener('mjsTemplateReady', function () { | ||
367 | //Initializing template with user's seriliazation | ||
368 | var template = this.iframe.contentWindow.mjsTemplate.create(); | ||
369 | template.initWithDocument(this.iframe.contentWindow.document); | ||
370 | template.instantiateWithOwnerAndDocument(null, this.iframe.contentWindow.document, function (e){/*Nothing just a required extra parameter*/}); | ||
371 | }.bind(this), false); | ||
355 | } | 372 | } |
356 | }, | 373 | }, |
357 | //////////////////////////////////////////////////////////////////// | 374 | //////////////////////////////////////////////////////////////////// |