aboutsummaryrefslogtreecommitdiff
path: root/js/mediators
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-06-04 11:58:53 -0700
committerJose Antonio Marquez2012-06-04 11:58:53 -0700
commit3f9cbffd7986cc5f42720ba38ca82c6424ba8916 (patch)
tree43e4bad7f1daf19b63ae227e82d7e8df376fc2dd /js/mediators
parentb6c6c194d4768cf03adee55e8ebe53428cbea2a1 (diff)
downloadninja-3f9cbffd7986cc5f42720ba38ca82c6424ba8916.tar.gz
Adding lib copy blocking to preview
This fixes an issue with launching preview before libraries were copied, hence, first time run would fail. Need to add a feedback screen for this process.
Diffstat (limited to 'js/mediators')
-rw-r--r--js/mediators/io-mediator.js41
1 files changed, 22 insertions, 19 deletions
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js
index 4535cad6..c5ec951e 100644
--- a/js/mediators/io-mediator.js
+++ b/js/mediators/io-mediator.js
@@ -43,6 +43,24 @@ exports.IoMediator = Montage.create(Component, {
43 }, 43 },
44 //////////////////////////////////////////////////////////////////// 44 ////////////////////////////////////////////////////////////////////
45 // 45 //
46 parseToTemplate: {
47 value: function(content, template) {
48 //
49 if (template.name.toLowerCase() === 'banner' || template.name.toLowerCase() === 'animation') {
50 //Getting dimensions of banner
51 var dimensions = template.id.split('x');
52 dimensions = {width: String(dimensions[0])+'px', height: String(dimensions[1])+'px'};
53 //
54 content = content.replace(/Dimensions@@@/gi, "Dimensions@@@"+template.id);
55 content = content.replace(/ninja-banner {}/gi, "ninja-banner {overflow: visible; width: "+dimensions.width+"; height: "+dimensions.height+"}");
56 content = content.replace(/ninja-content-wrapper {}/gi, "ninja-content-wrapper {overflow: hidden; width: "+dimensions.width+"; height: "+dimensions.height+"}");
57 }
58 //
59 return content;
60 }
61 },
62 ////////////////////////////////////////////////////////////////////
63 //
46 fileNew: { 64 fileNew: {
47 value: function (file, url, callback, template) { 65 value: function (file, url, callback, template) {
48 //Loading template from template URL 66 //Loading template from template URL
@@ -51,7 +69,7 @@ exports.IoMediator = Montage.create(Component, {
51 xhr.send(); 69 xhr.send();
52 if (xhr.readyState === 4) { 70 if (xhr.readyState === 4) {
53 //Making call to create file, checking for return code 71 //Making call to create file, checking for return code
54 switch (this.fio.newFile({ uri: file, contents: parseTemplate(xhr.response, template) })) { 72 switch (this.fio.newFile({ uri: file, contents: this.parseToTemplate(xhr.response, template) })) {
55 case 201: 73 case 201:
56 result = { status: 201, success: true, uri: file }; 74 result = { status: 201, success: true, uri: file };
57 break; 75 break;
@@ -65,21 +83,6 @@ exports.IoMediator = Montage.create(Component, {
65 result = { status: 500, success: false, uri: file }; 83 result = { status: 500, success: false, uri: file };
66 break; 84 break;
67 } 85 }
68 //TODO: Improve template data injection
69 function parseTemplate (content, template) {
70 //
71 if (template.name.toLowerCase() === 'banner' || template.name.toLowerCase() === 'animation') {
72 //Getting dimensions of banner
73 var dimensions = template.id.split('x');
74 dimensions = {width: String(dimensions[0])+'px', height: String(dimensions[1])+'px'};
75 //
76 content = content.replace(/Dimensions@@@/gi, "Dimensions@@@"+template.id);
77 content = content.replace(/ninja-banner {}/gi, "ninja-banner {overflow: visible; width: "+dimensions.width+"; height: "+dimensions.height+"}");
78 content = content.replace(/ninja-content-wrapper {}/gi, "ninja-content-wrapper {overflow: hidden; width: "+dimensions.width+"; height: "+dimensions.height+"}");
79 }
80 //
81 return content;
82 }
83 } else { 86 } else {
84 result = { status: 500, success: false, uri: file }; 87 result = { status: 500, success: false, uri: file };
85 } 88 }
@@ -151,7 +154,7 @@ exports.IoMediator = Montage.create(Component, {
151 //////////////////////////////////////////////////////////////////// 154 ////////////////////////////////////////////////////////////////////
152 // 155 //
153 fileSave: { 156 fileSave: {
154 value: function (doc, callback) { 157 value: function (doc, callback, libCopyCallback) {
155 // 158 //
156 var contents, save; 159 var contents, save;
157 // 160 //
@@ -159,9 +162,9 @@ exports.IoMediator = Montage.create(Component, {
159 case 'html': 162 case 'html':
160 //Getting content from function to properly handle saving assets (as in external if flagged) 163 //Getting content from function to properly handle saving assets (as in external if flagged)
161 if (doc.template && (doc.template.type === 'banner' || doc.template.type === 'animation')) { 164 if (doc.template && (doc.template.type === 'banner' || doc.template.type === 'animation')) {
162 contents = this.tmplt.parseNinjaTemplateToHtml(doc, true); 165 contents = this.tmplt.parseNinjaTemplateToHtml(doc, true, libCopyCallback);
163 } else { 166 } else {
164 contents = this.tmplt.parseNinjaTemplateToHtml(doc); 167 contents = this.tmplt.parseNinjaTemplateToHtml(doc, false, libCopyCallback);
165 } 168 }
166 break; 169 break;
167 default: 170 default: