aboutsummaryrefslogtreecommitdiff
path: root/js/io
diff options
context:
space:
mode:
Diffstat (limited to 'js/io')
-rwxr-xr-xjs/io/document/document-controller.js57
-rw-r--r--js/io/templates/descriptor.json34
-rw-r--r--js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js8
-rwxr-xr-xjs/io/ui/new-file-dialog/new-file-workflow-controller.js2
4 files changed, 69 insertions, 32 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
diff --git a/js/io/templates/descriptor.json b/js/io/templates/descriptor.json
index 20870934..acc03979 100644
--- a/js/io/templates/descriptor.json
+++ b/js/io/templates/descriptor.json
@@ -6,60 +6,60 @@
6 "name":"Blank File", 6 "name":"Blank File",
7 "uri":"/", 7 "uri":"/",
8 "type":"directory", 8 "type":"directory",
9 "children":["/js/io/templates/files/html.txt", "/js/io/templates/files/files/js.txt", "/js/io/templates/files/css.txt", "/js/io/templates/files/json.txt", "/js/io/templates/files/php.txt", "/js/io/templates/files/pl.txt", "/js/io/templates/files/py.txt", "/js/io/templates/files/rb.txt"] 9 "children":["js/io/templates/files/html.txt", "js/io/templates/files/js.txt", "js/io/templates/files/css.txt", "js/io/templates/files/json.txt", "js/io/templates/files/php.txt", "js/io/templates/files/pl.txt", "js/io/templates/files/py.txt", "js/io/templates/files/rb.txt"]
10 }, 10 },
11 "/js/io/templates/files/html.txt":{ 11 "js/io/templates/files/html.txt":{
12 "name":"HTML", 12 "name":"HTML",
13 "uri":"/js/io/templates/files/html.txt", 13 "uri":"js/io/templates/files/html.txt",
14 "type":"file", 14 "type":"file",
15 "fileExtension":".html", 15 "fileExtension":".html",
16 "children":["defaultTemplate"] 16 "children":["defaultTemplate"]
17 }, 17 },
18 "/js/io/templates/files/files/js.txt":{ 18 "js/io/templates/files/js.txt":{
19 "name":"JavaScript", 19 "name":"JavaScript",
20 "uri":"/js/io/templates/files/files/js.txt", 20 "uri":"js/io/templates/files/js.txt",
21 "type":"file", 21 "type":"file",
22 "fileExtension":".js", 22 "fileExtension":".js",
23 "children":["defaultTemplate"] 23 "children":["defaultTemplate"]
24 }, 24 },
25 "/js/io/templates/files/css.txt":{ 25 "js/io/templates/files/css.txt":{
26 "name":"Cascading Style Sheets", 26 "name":"Cascading Style Sheets",
27 "uri":"/js/io/templates/files/css.txt", 27 "uri":"js/io/templates/files/css.txt",
28 "type":"file", 28 "type":"file",
29 "fileExtension":".css", 29 "fileExtension":".css",
30 "children":["defaultTemplate"] 30 "children":["defaultTemplate"]
31 }, 31 },
32 "/js/io/templates/files/json.txt":{ 32 "js/io/templates/files/json.txt":{
33 "name":"JSON", 33 "name":"JSON",
34 "uri":"/js/io/templates/files/json.txt", 34 "uri":"js/io/templates/files/json.txt",
35 "type":"file", 35 "type":"file",
36 "fileExtension":".json", 36 "fileExtension":".json",
37 "children":["defaultTemplate"] 37 "children":["defaultTemplate"]
38 }, 38 },
39 "/js/io/templates/files/php.txt":{ 39 "js/io/templates/files/php.txt":{
40 "name":"PHP", 40 "name":"PHP",
41 "uri":"/js/io/templates/files/php.txt", 41 "uri":"js/io/templates/files/php.txt",
42 "type":"file", 42 "type":"file",
43 "fileExtension":".php", 43 "fileExtension":".php",
44 "children":["defaultTemplate"] 44 "children":["defaultTemplate"]
45 }, 45 },
46 "/js/io/templates/files/pl.txt":{ 46 "js/io/templates/files/pl.txt":{
47 "name":"Perl", 47 "name":"Perl",
48 "uri":"/js/io/templates/files/pl.txt", 48 "uri":"js/io/templates/files/pl.txt",
49 "type":"file", 49 "type":"file",
50 "fileExtension":".pl", 50 "fileExtension":".pl",
51 "children":["defaultTemplate"] 51 "children":["defaultTemplate"]
52 }, 52 },
53 "/js/io/templates/files/py.txt":{ 53 "js/io/templates/files/py.txt":{
54 "name":"Python", 54 "name":"Python",
55 "uri":"/js/io/templates/files/py.txt", 55 "uri":"js/io/templates/files/py.txt",
56 "type":"file", 56 "type":"file",
57 "fileExtension":".py", 57 "fileExtension":".py",
58 "children":["defaultTemplate"] 58 "children":["defaultTemplate"]
59 }, 59 },
60 "/js/io/templates/files/rb.txt":{ 60 "js/io/templates/files/rb.txt":{
61 "name":"Ruby", 61 "name":"Ruby",
62 "uri":"/js/io/templates/files/rb.txt", 62 "uri":"js/io/templates/files/rb.txt",
63 "type":"file", 63 "type":"file",
64 "fileExtension":".rb", 64 "fileExtension":".rb",
65 "children":["defaultTemplate"] 65 "children":["defaultTemplate"]
diff --git a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js
index bcb9d123..f514b81a 100644
--- a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js
+++ b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js
@@ -230,10 +230,10 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C
230 ){ 230 ){
231 this.error.innerHTML=""; 231 this.error.innerHTML="";
232 //console.log("$$$ new file selections: \n" + selectionlog); 232 //console.log("$$$ new file selections: \n" + selectionlog);
233 if(!!this.newFileModel.callback && !!this.newFileModel.callbackScope){//inform document-controller if save successful 233 if(!!this.newFileModel.callback){//inform document-controller if save successful
234 this.newFileModel.callback.call(this.newFileModel.callbackScope, {"fileTemplateUri":selectedProjectTypeID, 234 this.newFileModel.callback({"fileTemplateUri":selectedProjectTypeID,
235 "newFilePath":newFilePath, 235 "newFilePath":newFilePath,
236 "fileExtension":fileExtension});//document-controller api 236 "fileExtension":fileExtension});//document-controller api
237 }else{ 237 }else{