diff options
Diffstat (limited to 'js/mediators')
-rwxr-xr-x | js/mediators/drag-drop-mediator.js | 22 | ||||
-rw-r--r-- | js/mediators/io-mediator.js | 60 |
2 files changed, 41 insertions, 41 deletions
diff --git a/js/mediators/drag-drop-mediator.js b/js/mediators/drag-drop-mediator.js index 7669dcfc..f23ec34c 100755 --- a/js/mediators/drag-drop-mediator.js +++ b/js/mediators/drag-drop-mediator.js | |||
@@ -80,8 +80,8 @@ exports.DragDropMediator = Montage.create(Component, { | |||
80 | 80 | ||
81 | handleDropEvent: { | 81 | handleDropEvent: { |
82 | value: function(e){ | 82 | value: function(e){ |
83 | // | 83 | // |
84 | var i, files = e.dataTransfer.files, position = {x: e.offsetX, y: e.offsetY}, self = this; | 84 | var i, files = e.dataTransfer.files, position = {x: e.offsetX, y: e.offsetY}, self = this; |
85 | 85 | ||
86 | var xferString = e.dataTransfer.getData("text/plain"); | 86 | var xferString = e.dataTransfer.getData("text/plain"); |
87 | if(xferString) { | 87 | if(xferString) { |
@@ -93,17 +93,17 @@ exports.DragDropMediator = Montage.create(Component, { | |||
93 | } | 93 | } |
94 | } | 94 | } |
95 | } | 95 | } |
96 | // | 96 | // |
97 | for (i=0; files[i]; i++) { | 97 | for (i=0; files[i]; i++) { |
98 | if (files[i].type.indexOf('image') !== -1) { | 98 | if (files[i].type.indexOf('image') !== -1) { |
99 | this.application.ninja.ioMediator.createFileFromBinary(files[i], {"addFileToStage" : self.addImageElement.bind(self), "position": position}); | 99 | this.application.ninja.ioMediator.createFileFromBinary(files[i], {"addFileToStage" : self.addImageElement.bind(self), "position": position}); |
100 | 100 | ||
101 | } else { | 101 | } else { |
102 | //TODO: NOT AN IMAGE, HANDLE SPECIAL CASE | 102 | //TODO: NOT AN IMAGE, HANDLE SPECIAL CASE |
103 | } | 103 | } |
104 | } | 104 | } |
105 | //Not sure why return value should be, seemed as false to work | 105 | //Not sure why return value should be, seemed as false to work |
106 | return false; | 106 | return false; |
107 | } | 107 | } |
108 | }, | 108 | }, |
109 | 109 | ||
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index c69cbafa..41944f74 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js | |||
@@ -30,11 +30,11 @@ POSSIBILITY OF SUCH DAMAGE. | |||
30 | 30 | ||
31 | //////////////////////////////////////////////////////////////////////// | 31 | //////////////////////////////////////////////////////////////////////// |
32 | // | 32 | // |
33 | var Montage = require("montage/core/core").Montage, | 33 | var Montage = require("montage/core/core").Montage, |
34 | Component = require("montage/ui/component").Component, | 34 | Component = require("montage/ui/component").Component, |
35 | FileIo = require("js/io/system/fileio").FileIo, | 35 | FileIo = require("js/io/system/fileio").FileIo, |
36 | ProjectIo = require("js/io/system/projectio").ProjectIo, | 36 | ProjectIo = require("js/io/system/projectio").ProjectIo, |
37 | TemplateMediator = require("js/document/mediators/template").TemplateDocumentMediator; | 37 | TemplateMediator = require("js/document/mediators/template").TemplateDocumentMediator; |
38 | //////////////////////////////////////////////////////////////////////// | 38 | //////////////////////////////////////////////////////////////////////// |
39 | // | 39 | // |
40 | exports.IoMediator = Montage.create(Component, { | 40 | exports.IoMediator = Montage.create(Component, { |
@@ -68,11 +68,11 @@ exports.IoMediator = Montage.create(Component, { | |||
68 | //////////////////////////////////////////////////////////////////// | 68 | //////////////////////////////////////////////////////////////////// |
69 | // | 69 | // |
70 | parseToTemplate: { | 70 | parseToTemplate: { |
71 | value: function(content, template) { | 71 | value: function(content, template) { |
72 | // | 72 | // |
73 | if (template.name.toLowerCase() === 'banner' || template.name.toLowerCase() === 'animation') { | 73 | if (template.name.toLowerCase() === 'banner' || template.name.toLowerCase() === 'animation') { |
74 | //Getting dimensions of banner | 74 | //Getting dimensions of banner |
75 | var dimensions = template.id.split('x'); | 75 | var dimensions = template.id.split('x'); |
76 | dimensions = {width: String(dimensions[0])+'px', height: String(dimensions[1])+'px'}; | 76 | dimensions = {width: String(dimensions[0])+'px', height: String(dimensions[1])+'px'}; |
77 | // | 77 | // |
78 | content = content.replace(/Dimensions@@@/gi, "Dimensions@@@"+template.id); | 78 | content = content.replace(/Dimensions@@@/gi, "Dimensions@@@"+template.id); |
@@ -81,7 +81,7 @@ exports.IoMediator = Montage.create(Component, { | |||
81 | } | 81 | } |
82 | // | 82 | // |
83 | return content; | 83 | return content; |
84 | } | 84 | } |
85 | }, | 85 | }, |
86 | //////////////////////////////////////////////////////////////////// | 86 | //////////////////////////////////////////////////////////////////// |
87 | // | 87 | // |
@@ -113,8 +113,8 @@ exports.IoMediator = Montage.create(Component, { | |||
113 | //Sending result to callback if requested for handling | 113 | //Sending result to callback if requested for handling |
114 | if (callback) callback(result); | 114 | if (callback) callback(result); |
115 | //Codes | 115 | //Codes |
116 | // 204: File exists | 400: File exists | 116 | // 204: File exists | 400: File exists |
117 | // 201: File succesfully created | 500: Unknown (Probably cloud API not running) | 117 | // 201: File succesfully created | 500: Unknown (Probably cloud API not running) |
118 | } | 118 | } |
119 | }, | 119 | }, |
120 | //////////////////////////////////////////////////////////////////// | 120 | //////////////////////////////////////////////////////////////////// |
@@ -159,9 +159,9 @@ exports.IoMediator = Montage.create(Component, { | |||
159 | 204: File exists (Success) | 159 | 204: File exists (Success) |
160 | 404: File does not exists (Failure) | 160 | 404: File does not exists (Failure) |
161 | 500: Unknown (Probably cloud API not running) | 161 | 500: Unknown (Probably cloud API not running) |
162 | 162 | ||
163 | (Below only present if succesfull 204) | 163 | (Below only present if succesfull 204) |
164 | 164 | ||
165 | Object.content | 165 | Object.content |
166 | Object.extension | 166 | Object.extension |
167 | Object.name | 167 | Object.name |
@@ -186,9 +186,9 @@ exports.IoMediator = Montage.create(Component, { | |||
186 | case 'html': | 186 | case 'html': |
187 | //Getting content from function to properly handle saving assets (as in external if flagged) | 187 | //Getting content from function to properly handle saving assets (as in external if flagged) |
188 | if (doc.template && (doc.template.type === 'banner' || doc.template.type === 'animation')) { | 188 | if (doc.template && (doc.template.type === 'banner' || doc.template.type === 'animation')) { |
189 | parsedDoc = this.tmplt.parseNinjaTemplateToHtml(true, doc, true, libCopyCallback); | 189 | parsedDoc = this.tmplt.parseNinjaTemplateToHtml(true, doc, true, libCopyCallback); |
190 | } else { | 190 | } else { |
191 | parsedDoc = this.tmplt.parseNinjaTemplateToHtml(true, doc, false, libCopyCallback); | 191 | parsedDoc = this.tmplt.parseNinjaTemplateToHtml(true, doc, false, libCopyCallback); |
192 | } | 192 | } |
193 | break; | 193 | break; |
194 | default: | 194 | default: |
@@ -196,21 +196,21 @@ exports.IoMediator = Montage.create(Component, { | |||
196 | break; | 196 | break; |
197 | } | 197 | } |
198 | if (parsedDoc) { | 198 | if (parsedDoc) { |
199 | //Making call to save file | 199 | //Making call to save file |
200 | save = this.fio.saveFile({uri: doc.file.uri, contents: parsedDoc.content}); | 200 | save = this.fio.saveFile({uri: doc.file.uri, contents: parsedDoc.content}); |
201 | //Checking for callback | 201 | //Checking for callback |
202 | if (callback) callback(save); | 202 | if (callback) callback(save); |
203 | //Checking for libraries, making callback if specified | 203 | //Checking for libraries, making callback if specified |
204 | if (!parsedDoc.libs && libCopyCallback) libCopyCallback(true); | 204 | if (!parsedDoc.libs && libCopyCallback) libCopyCallback(true); |
205 | // | 205 | // |
206 | return {montageId: parsedDoc.montageId, canvasId: parsedDoc.canvasId}; | 206 | return {montageId: parsedDoc.montageId, canvasId: parsedDoc.canvasId}; |
207 | } else { | 207 | } else { |
208 | //Making call to save file | 208 | //Making call to save file |
209 | save = this.fio.saveFile({uri: doc.file.uri, contents: content}); | 209 | save = this.fio.saveFile({uri: doc.file.uri, contents: content}); |
210 | //Checking for callback | 210 | //Checking for callback |
211 | if (callback) callback(save); | 211 | if (callback) callback(save); |
212 | // | 212 | // |
213 | return null; | 213 | return null; |
214 | } | 214 | } |
215 | } | 215 | } |
216 | }, | 216 | }, |