aboutsummaryrefslogtreecommitdiff
path: root/js/mediators
diff options
context:
space:
mode:
authorAnanya Sen2012-02-03 18:04:26 -0800
committerAnanya Sen2012-02-03 18:04:26 -0800
commit45cfffd9261ab1aa714554c584f0d0d8fe627c91 (patch)
tree74968ff98a59c6760cfb0a3854c8181877fdaff1 /js/mediators
parent1daf146c849a0a8dbd2b61b14218c9a39bdee3a7 (diff)
downloadninja-45cfffd9261ab1aa714554c584f0d0d8fe627c91.tar.gz
allow to open html file in design view,
integrated file open with io mediator Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/mediators')
-rw-r--r--js/mediators/io-mediator.js32
1 files changed, 28 insertions, 4 deletions
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js
index 3d75771f..76f78a7d 100644
--- a/js/mediators/io-mediator.js
+++ b/js/mediators/io-mediator.js
@@ -16,12 +16,12 @@ exports.IoMediator = Montage.create(require("montage/ui/component").Component, {
16 // 16 //
17 fileNew: { 17 fileNew: {
18 enumerable: false, 18 enumerable: false,
19 value: function (file, template, callback, callbackScope) { 19 value: function (file, template, callback) {
20 // 20 //
21 21
22 22
23 var returnObj = null; //like {"type": "js", "name": "filename", "source": "test file content", "uri": "/fs/fsd/"} 23 var returnObj = null; //like {"type": "js", "name": "filename", "source": "test file content", "uri": "/fs/fsd/"}
24 callback.call(callbackScope, returnObj); 24 callback.operation.call(callback.thisScope, returnObj);
25 } 25 }
26 }, 26 },
27 //////////////////////////////////////////////////////////////////// 27 ////////////////////////////////////////////////////////////////////
@@ -29,7 +29,23 @@ exports.IoMediator = Montage.create(require("montage/ui/component").Component, {
29 fileOpen: { 29 fileOpen: {
30 enumerable: false, 30 enumerable: false,
31 value: function (file, callback) { 31 value: function (file, callback) {
32 // 32 var response = "", fileContent="", filename="", fileType="js", returnObj=null;
33
34 response = this.application.ninja.coreIoApi.openFile({"uri":file.uri});
35 if((response.success === true) && ((response.status === 200) || (response.status === 304))){
36 fileContent = response.content;
37 }
38
39
40 //TODO : format html content to render in design view
41
42
43 filename = this.getFileNameFromPath(file.uri);
44 if(file.uri.indexOf('.') != -1){
45 fileType = file.uri.substr(file.uri.lastIndexOf('.') + 1);
46 }
47 returnObj = {"type": ""+fileType, "name": ""+filename, "source": fileContent, "uri": file.uri};
48 callback.operation.call(callback.thisScope, returnObj);
33 } 49 }
34 }, 50 },
35 //////////////////////////////////////////////////////////////////// 51 ////////////////////////////////////////////////////////////////////
@@ -47,8 +63,16 @@ exports.IoMediator = Montage.create(require("montage/ui/component").Component, {
47 value: function (file, copy, callback) { 63 value: function (file, copy, callback) {
48 // 64 //
49 } 65 }
50 } 66 },
51 //////////////////////////////////////////////////////////////////// 67 ////////////////////////////////////////////////////////////////////
68 ///// Return the last part of a path (e.g. filename)
69 getFileNameFromPath : {
70 value: function(path) {
71 path = path.replace(/[/\\]$/g,"");
72 path = path.replace(/\\/g,"/");
73 return path.substr(path.lastIndexOf('/') + 1);
74 }
75 }
52 //////////////////////////////////////////////////////////////////// 76 ////////////////////////////////////////////////////////////////////
53}); 77});
54//////////////////////////////////////////////////////////////////////// 78////////////////////////////////////////////////////////////////////////