aboutsummaryrefslogtreecommitdiff
path: root/js/mediators
diff options
context:
space:
mode:
authorValerio Virgillito2012-05-11 15:00:36 -0700
committerValerio Virgillito2012-05-11 15:00:36 -0700
commitf4c4bc7971a50f9e258d1ac23c70f8ea8cfe5dd6 (patch)
tree297cc2bdd26c5a72bd88edf6d91be8ceef25e98b /js/mediators
parent2b718df00eb9f3a3d2ad269fab533967668988bf (diff)
parent1fb663b5f348fe2ff5ce86a80e8a61be289eba70 (diff)
downloadninja-f4c4bc7971a50f9e258d1ac23c70f8ea8cfe5dd6.tar.gz
Merge branch 'dom-architecture' of github.com:Motorola-Mobility/ninja-internal into dom-architecture
Diffstat (limited to 'js/mediators')
-rw-r--r--js/mediators/io-mediator.js20
1 files changed, 17 insertions, 3 deletions
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js
index dae0f359..0bff1f3b 100644
--- a/js/mediators/io-mediator.js
+++ b/js/mediators/io-mediator.js
@@ -53,14 +53,14 @@ exports.IoMediator = Montage.create(Component, {
53 // 53 //
54 fileNew: { 54 fileNew: {
55 enumerable: false, 55 enumerable: false,
56 value: function (file, template, callback) { 56 value: function (file, url, callback, template) {
57 //Loading template from template URL 57 //Loading template from template URL
58 var xhr = new XMLHttpRequest(), result; 58 var xhr = new XMLHttpRequest(), result;
59 xhr.open("GET", template, false); 59 xhr.open("GET", url, false);
60 xhr.send(); 60 xhr.send();
61 if (xhr.readyState === 4) { 61 if (xhr.readyState === 4) {
62 //Making call to create file, checking for return code 62 //Making call to create file, checking for return code
63 switch (this.fio.newFile({ uri: file, contents: xhr.response })) { 63 switch (this.fio.newFile({ uri: file, contents: parseTemplate(xhr.response, template) })) {
64 case 201: 64 case 201:
65 result = { status: 201, success: true, uri: file }; 65 result = { status: 201, success: true, uri: file };
66 break; 66 break;
@@ -74,6 +74,20 @@ exports.IoMediator = Montage.create(Component, {
74 result = { status: 500, success: false, uri: file }; 74 result = { status: 500, success: false, uri: file };
75 break; 75 break;
76 } 76 }
77 //TODO: Improve template data injection
78 function parseTemplate (content, template) {
79 //
80 if (template.name.toLowerCase() === 'banner') {
81 //Getting dimensions of banner
82 var dimensions = template.id.split('x');
83 dimensions = {width: String(dimensions[0])+'px', height: String(dimensions[1])+'px'};
84 //
85 content = content.replace(/Dimensions@@@/gi, "Dimensions@@@"+template.id);
86 content = content.replace(/ninja-banner {}/gi, "ninja-banner {width: "+dimensions.width+"; height: "+dimensions.height+"}");
87 }
88 //
89 return content;
90 }
77 } else { 91 } else {
78 result = { status: 500, success: false, uri: file }; 92 result = { status: 500, success: false, uri: file };
79 } 93 }