aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rwxr-xr-xjs/components/layout/document-bar.reel/document-bar.js13
-rwxr-xr-xjs/document/document-html.js18
-rwxr-xr-xjs/document/mediators/template.js12
3 files changed, 26 insertions, 17 deletions
diff --git a/js/components/layout/document-bar.reel/document-bar.js b/js/components/layout/document-bar.reel/document-bar.js
index f5e61a18..77f05bc1 100755
--- a/js/components/layout/document-bar.reel/document-bar.js
+++ b/js/components/layout/document-bar.reel/document-bar.js
@@ -238,7 +238,18 @@ exports.DocumentBar = Montage.create(Component, {
238 iBtn.setAttribute('class', 'inactive'); 238 iBtn.setAttribute('class', 'inactive');
239 aBtn.removeAttribute('class'); 239 aBtn.removeAttribute('class');
240 //TODO: Add document parsing to reload view 240 //TODO: Add document parsing to reload view
241 this._currentDocument.reloadView(view, this.fileTemplate); 241 this._currentDocument.reloadView(view, this.fileTemplate, {
242 mode: 'html',
243 libs: this._currentDocument.model.libs,
244 file: this._currentDocument.model.file,
245 webgl: this._currentDocument.model.webGlHelper.glData,
246 styles: this._currentDocument.model.getStyleSheets(),
247 template: this._currentDocument.fileTemplate,
248 document: this._currentDocument.model.views.design.iframe.contentWindow.document,
249 head: this._currentDocument.model.views.design.iframe.contentWindow.document.head,
250 body: this._currentDocument.model.views.design.iframe.contentWindow.document.body,
251 mjsTemplateCreator: this._currentDocument.model.views.design.iframe.contentWindow.mjsTemplateCreator
252 });
242 } 253 }
243 } 254 }
244 }, 255 },
diff --git a/js/document/document-html.js b/js/document/document-html.js
index 569b6d8b..81a8912b 100755
--- a/js/document/document-html.js
+++ b/js/document/document-html.js
@@ -135,8 +135,7 @@ exports.HtmlDocument = Montage.create(Component, {
135 //////////////////////////////////////////////////////////////////// 135 ////////////////////////////////////////////////////////////////////
136 //TODO: Make into one method to use here and one init 136 //TODO: Make into one method to use here and one init
137 reloadView: { 137 reloadView: {
138 value: function (view, template) { 138 value: function (view, template, doc) {
139 var content;
140 // 139 //
141 this.model.parentContainer.removeChild(this.model.views.design.iframe); 140 this.model.parentContainer.removeChild(this.model.views.design.iframe);
142 //Initiliazing views and hiding 141 //Initiliazing views and hiding
@@ -167,14 +166,13 @@ exports.HtmlDocument = Montage.create(Component, {
167 this._observer.observe(this.model.views.design.document.head, {childList: true}); 166 this._observer.observe(this.model.views.design.document.head, {childList: true});
168 }.bind(this), template, {viewCallback: this.handleViewReady, context: this}); 167 }.bind(this), template, {viewCallback: this.handleViewReady, context: this});
169 } else if(view === 'code'){ 168 } else if(view === 'code'){
170 169 //TODO: Add logic to handle external changed files
171 170 //Checking for template type and not saving external data
172 //TODO: Parse in memory document through template to get current document 171 if (doc.template && (doc.template.type === 'banner' || doc.template.type === 'animation')) {
173 content = '<html><head>'+this.model.file.content.head+'</head><body>'+this.model.file.content.body+'</body></html>';//dummy 172 this.model.views.code.load(this.application.ninja.ioMediator.tmplt.parseNinjaTemplateToHtml(false, doc, true, null).content);
174 173 } else {
175 174 this.model.views.code.load(this.application.ninja.ioMediator.tmplt.parseNinjaTemplateToHtml(false, doc, false, null).content);
176 // 175 }
177 this.model.views.code.load(content);
178 //Setting current view object to code 176 //Setting current view object to code
179 this.currentView = 'code'; 177 this.currentView = 'code';
180 this.model.currentView = this.model.views.code; 178 this.model.currentView = this.model.views.code;
diff --git a/js/document/mediators/template.js b/js/document/mediators/template.js
index 4065f471..c68cfe72 100755
--- a/js/document/mediators/template.js
+++ b/js/document/mediators/template.js
@@ -47,7 +47,7 @@ exports.TemplateDocumentMediator = Montage.create(Component, {
47 // 47 //
48 getAppTemplatesUrlRegEx: { 48 getAppTemplatesUrlRegEx: {
49 value: function () { 49 value: function () {
50 var regex = new RegExp(chrome.extension.getURL(this.application.ninja.currentDocument.model.views.design.iframe.src.split(chrome.extension.getURL('/'))[1]).replace(/\//gi, '\\\/'), 'gi'); 50 var regex = new RegExp(chrome.extension.getURL(this.application.ninja.currentDocument.model.views.design.document.baseURI.split(chrome.extension.getURL('/'))[1]).replace(/\//gi, '\\\/'), 'gi');
51 return regex; 51 return regex;
52 } 52 }
53 }, 53 },
@@ -326,7 +326,7 @@ exports.TemplateDocumentMediator = Montage.create(Component, {
326 } 326 }
327 } 327 }
328 } 328 }
329 } else if (template.css) { 329 } else if (template.css && saveExternalData) {
330 //Getting all style and link tags 330 //Getting all style and link tags
331 var styleCounter = 0, 331 var styleCounter = 0,
332 docStyles = template.file.content.document.getElementsByTagName('style'), 332 docStyles = template.file.content.document.getElementsByTagName('style'),
@@ -480,7 +480,7 @@ exports.TemplateDocumentMediator = Montage.create(Component, {
480 //Copy webGL library if needed 480 //Copy webGL library if needed
481 for (var i in this.application.ninja.coreIoApi.ninjaLibrary.libs) { 481 for (var i in this.application.ninja.coreIoApi.ninjaLibrary.libs) {
482 //Checking for RDGE library to be available 482 //Checking for RDGE library to be available
483 if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'RDGE') { 483 if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'RDGE' && saveExternalData) {
484 rdgeDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name + this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase(); 484 rdgeDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name + this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase();
485 rdgeVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version; 485 rdgeVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version;
486 this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.file.root, rdgeDirName, function(result) {libsobserver.canvasCopied = result; this.libCopied(libsobserver);}.bind(this)); 486 this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.file.root, rdgeDirName, function(result) {libsobserver.canvasCopied = result; this.libCopied(libsobserver);}.bind(this));
@@ -564,7 +564,7 @@ exports.TemplateDocumentMediator = Montage.create(Component, {
564 webgllibtag.setAttribute('data-ninja-canvas-json', this.application.ninja.coreIoApi.rootUrl+'/'+cvsDataFileUrl); 564 webgllibtag.setAttribute('data-ninja-canvas-json', this.application.ninja.coreIoApi.rootUrl+'/'+cvsDataFileUrl);
565 webgllibtag.setAttribute('data-ninja-canvas-libpath', rdgeDirName); 565 webgllibtag.setAttribute('data-ninja-canvas-libpath', rdgeDirName);
566 // 566 //
567 if (cvsDataFileCheck.status === 404 || cvsDataFileCheck.status === 204) { 567 if (saveExternalData && (cvsDataFileCheck.status === 404 || cvsDataFileCheck.status === 204)) {
568 //Saving file 568 //Saving file
569 cvsDataFileOperation = this.application.ninja.ioMediator.fio.saveFile({uri: cvsDataFilePath, contents: json}); 569 cvsDataFileOperation = this.application.ninja.ioMediator.fio.saveFile({uri: cvsDataFilePath, contents: json});
570 } else { 570 } else {
@@ -592,13 +592,13 @@ exports.TemplateDocumentMediator = Montage.create(Component, {
592 592
593 593
594 //TODO: Make proper Montage method 594 //TODO: Make proper Montage method
595 595 var mjsDirName, mjsVersion;
596 //Checking for Montage 596 //Checking for Montage
597 if (mJsSerialization) { 597 if (mJsSerialization) {
598 //Copy Montage library if needed 598 //Copy Montage library if needed
599 for (var i in this.application.ninja.coreIoApi.ninjaLibrary.libs) { 599 for (var i in this.application.ninja.coreIoApi.ninjaLibrary.libs) {
600 //Checking for Montage library to be available 600 //Checking for Montage library to be available
601 if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'Montage') { 601 if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'Montage' && saveExternalData) {
602 mjsDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name + this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase(); 602 mjsDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name + this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase();
603 mjsVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version; 603 mjsVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version;
604 this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.file.root, mjsDirName, function(result) {libsobserver.montageCopied = result; this.libCopied(libsobserver);}.bind(this)); 604 this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.file.root, mjsDirName, function(result) {libsobserver.montageCopied = result; this.libCopied(libsobserver);}.bind(this));