aboutsummaryrefslogtreecommitdiff
path: root/js/io/document
diff options
context:
space:
mode:
authorAnanya Sen2012-02-10 01:55:30 -0800
committerAnanya Sen2012-02-10 01:55:30 -0800
commitad0ee69be3512325ede94738f23597086a141a3e (patch)
tree938c531ee1592e14807fa3d96f439bf8483d9fbc /js/io/document
parent67a5b6a1fb352bdc69ff05297268c27e7e2ba795 (diff)
downloadninja-ad0ee69be3512325ede94738f23597086a141a3e.tar.gz
file open and file new integrated again
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/io/document')
-rwxr-xr-xjs/io/document/document-controller.js57
1 files changed, 47 insertions, 10 deletions
diff --git a/js/io/document/document-controller.js b/js/io/document/document-controller.js
index e36181bf..6f67b57c 100755
--- a/js/io/document/document-controller.js
+++ b/js/io/document/document-controller.js
@@ -78,8 +78,9 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
78 handleExecuteFileOpen: { 78 handleExecuteFileOpen: {
79 value: function(event) { 79 value: function(event) {
80 var pickerSettings = event._event.settings || {}; 80 var pickerSettings = event._event.settings || {};
81 pickerSettings.callback = this.openFileWithURI; 81 pickerSettings.callback = this.openFileWithURI.bind(this);
82 pickerSettings.callbackScope = this; 82 pickerSettings.pickerMode = "read";
83 pickerSettings.inFileMode = true;
83 this.application.ninja.filePickerController.showFilePicker(pickerSettings); 84 this.application.ninja.filePickerController.showFilePicker(pickerSettings);
84 } 85 }
85 }, 86 },
@@ -87,8 +88,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
87 handleExecuteNewFile: { 88 handleExecuteNewFile: {
88 value: function(event) { 89 value: function(event) {
89 var newFileSettings = event._event.settings || {}; 90 var newFileSettings = event._event.settings || {};
90 newFileSettings.callback = this.createNewFile; 91 newFileSettings.callback = this.createNewFile.bind(this);
91 newFileSettings.callbackScope = this;
92 this.application.ninja.newFileController.showNewFileDialog(newFileSettings); 92 this.application.ninja.newFileController.showNewFileDialog(newFileSettings);
93 } 93 }
94 }, 94 },
@@ -123,9 +123,9 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
123 */ 123 */
124 openNewFileCallback:{ 124 openNewFileCallback:{
125 value:function(doc){ 125 value:function(doc){
126 var response = doc || {"uri":"/Users/xhdq84/Documents/test.js", "success":true};//default just for testing 126 var response = doc || null;//default just for testing
127 if(!!response && response.success && !!response.uri){ 127 if(!!response && response.success && !!response.uri){
128 this.application.ninja.ioMediator.fileOpen({"uri":response.uri}, this.openFileCallback.bind(this)); 128 this.application.ninja.ioMediator.fileOpen(response.uri, this.openFileCallback.bind(this));
129 } 129 }
130 } 130 }
131 }, 131 },
@@ -137,8 +137,9 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
137 uri = uriArrayObj.uri[0]; 137 uri = uriArrayObj.uri[0];
138 } 138 }
139 //console.log("URI is: ", uri); 139 //console.log("URI is: ", uri);
140 140 if(!!uri){
141 this.application.ninja.ioMediator.fileOpen({"uri":uri}, this.openFileCallback.bind(this)); 141 this.application.ninja.ioMediator.fileOpen(uri, this.openFileCallback.bind(this));
142 }
142 } 143 }
143 }, 144 },
144 145
@@ -151,8 +152,44 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
151 * uri : file uri 152 * uri : file uri
152 */ 153 */
153 openFileCallback:{ 154 openFileCallback:{
154 value:function(doc){ 155 value:function(response){
155 this.openDocument(doc); 156 //Return Object Description
157// Object.status (Always presents for handling)
158// 204: File exists (Success)
159// 404: File does not exists (Failure)
160// 500: Unknown (Probably cloud API not running)
161//
162// (Below only present if succesfull 204)
163//
164// Object.content
165// Object.extension
166// Object.name
167// Object.uri
168// Object.creationDate
169// Object.modifiedDate
170// Object.readOnly
171// Object.size
172
173 var fileDetails = {};
174 if(!!response && (response.status === 204)){
175 /**
176 * fileDetails format:
177 * {"type": "js", "name": "test", "source": fileContent, "uri": uri}
178 */
179 fileDetails.type = response.extension;
180 fileDetails.source = response.content;
181 fileDetails.name = response.name;
182 fileDetails.uri = response.uri;
183
184 this.openDocument(fileDetails);
185 }else if(!!response && (response.status === 404)){
186 alert("Unable to open file.\n [Error: File does not exist]");
187 }else if(!!response && (response.status === 500)){
188 alert("Unable to open file.\n Check if Ninja Local Cloud is running.");
189 }else{
190 alert("Unable to open file.");
191 }
192
156 } 193 }
157 }, 194 },
158 195