aboutsummaryrefslogtreecommitdiff
path: root/js/io
diff options
context:
space:
mode:
Diffstat (limited to 'js/io')
-rwxr-xr-xjs/io/document/document-controller.js68
-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, 73 insertions, 39 deletions
diff --git a/js/io/document/document-controller.js b/js/io/document/document-controller.js
index 15f026a3..c2a2dab6 100755
--- a/js/io/document/document-controller.js
+++ b/js/io/document/document-controller.js
@@ -87,8 +87,9 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
87 handleExecuteFileOpen: { 87 handleExecuteFileOpen: {
88 value: function(event) { 88 value: function(event) {
89 var pickerSettings = event._event.settings || {}; 89 var pickerSettings = event._event.settings || {};
90 pickerSettings.callback = this.openFileWithURI; 90 pickerSettings.callback = this.openFileWithURI.bind(this);
91 pickerSettings.callbackScope = this; 91 pickerSettings.pickerMode = "read";
92 pickerSettings.inFileMode = true;
92 this.application.ninja.filePickerController.showFilePicker(pickerSettings); 93 this.application.ninja.filePickerController.showFilePicker(pickerSettings);
93 } 94 }
94 }, 95 },
@@ -96,8 +97,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
96 handleExecuteNewFile: { 97 handleExecuteNewFile: {
97 value: function(event) { 98 value: function(event) {
98 var newFileSettings = event._event.settings || {}; 99 var newFileSettings = event._event.settings || {};
99 newFileSettings.callback = this.createNewFile; 100 newFileSettings.callback = this.createNewFile.bind(this);
100 newFileSettings.callbackScope = this;
101 this.application.ninja.newFileController.showNewFileDialog(newFileSettings); 101 this.application.ninja.newFileController.showNewFileDialog(newFileSettings);
102 } 102 }
103 }, 103 },
@@ -132,9 +132,9 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
132 */ 132 */
133 openNewFileCallback:{ 133 openNewFileCallback:{
134 value:function(doc){ 134 value:function(doc){
135 var response = doc || {"uri":"/Users/xhdq84/Documents/test.js", "success":true};//default just for testing 135 var response = doc || null;//default just for testing
136 if(!!response && response.success && !!response.uri){ 136 if(!!response && response.success && !!response.uri){
137 this.application.ninja.ioMediator.fileOpen({"uri":response.uri}, this.openFileCallback.bind(this)); 137 this.application.ninja.ioMediator.fileOpen(response.uri, this.openFileCallback.bind(this));
138 } 138 }
139 } 139 }
140 }, 140 },
@@ -146,25 +146,56 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
146 uri = uriArrayObj.uri[0]; 146 uri = uriArrayObj.uri[0];
147 } 147 }
148 //console.log("URI is: ", uri); 148 //console.log("URI is: ", uri);
149 149 if(!!uri){
150 this.application.ninja.ioMediator.fileOpen({"uri":uri}, this.openFileCallback.bind(this)); 150 this.application.ninja.ioMediator.fileOpen(uri, this.openFileCallback.bind(this));
151 }
151 } 152 }
152 }, 153 },
153 154
154 /** 155 /**
155 * Public method 156 * Public method
156 * doc contains:
157 * type : file type, like js, css, etc
158 * name : file name
159 * source : file content
160 * uri : file uri
161 */ 157 */
162 openFileCallback:{ 158 openFileCallback:{
163 value:function(doc){ 159 value:function(response){
164 this.openDocument(doc); 160 //Return Object Description
161// Object.status (Always presents for handling)
162// 204: File exists (Success)
163// 404: File does not exists (Failure)
164// 500: Unknown (Probably cloud API not running)
165//
166// (Below only present if succesfull 204)
167//
168// Object.content
169// Object.extension
170// Object.name
171// Object.uri
172// Object.creationDate
173// Object.modifiedDate
174// Object.readOnly
175// Object.size
176
177 var fileDetails = {};
178 if(!!response && (response.status === 204)){
179 /**
180 * fileDetails format:
181 * {"type": "js", "name": "test", "source": fileContent, "uri": uri}
182 */
183 fileDetails.type = response.extension;
184 fileDetails.source = response.content;
185 fileDetails.name = response.name;
186 fileDetails.uri = response.uri;
187
188 this.openDocument(fileDetails);
189 }else if(!!response && (response.status === 404)){
190 alert("Unable to open file.\n [Error: File does not exist]");
191 }else if(!!response && (response.status === 500)){
192 alert("Unable to open file.\n Check if Ninja Local Cloud is running.");
193 }else{
194 alert("Unable to open file.");
165 } 195 }
166 },
167 196
197 }
198 },
168 199
169 openProjectWithURI: { 200 openProjectWithURI: {
170 value: function(uri) { 201 value: function(uri) {
@@ -371,7 +402,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
371 this.application.ninja.stage.restoreScroll(); 402 this.application.ninja.stage.restoreScroll();
372 this.application.ninja.stage.hideCanvas(false); 403 this.application.ninja.stage.hideCanvas(false);
373 this.application.ninja.stage.stageView.showRulers(); 404 this.application.ninja.stage.stageView.showRulers();
374 } 405 }else{
406 //hide the iframe when switching to code view
407 document.getElementById("iframeContainer").style.display="none";
408 }
375 } 409 }
376 } 410 }
377 }, 411 },
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</