diff options
author | Ananya Sen | 2012-02-02 17:45:22 -0800 |
---|---|---|
committer | Ananya Sen | 2012-02-02 17:45:22 -0800 |
commit | 6890662caba94598675679f40dbb725301c93e98 (patch) | |
tree | d1e3ded939e41a2b484a4c98b48e3b3976a71c63 /js/io | |
parent | 476a25e8a662270dfe5b37c560e4235f02b146e4 (diff) | |
download | ninja-6890662caba94598675679f40dbb725301c93e98.tar.gz |
integrated new file dialog with the template descriptor.json and document-controller.js
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/io')
10 files changed, 146 insertions, 152 deletions
diff --git a/js/io/document/document-controller.js b/js/io/document/document-controller.js index 8ce43dcc..dd62b40b 100755 --- a/js/io/document/document-controller.js +++ b/js/io/document/document-controller.js | |||
@@ -71,8 +71,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
71 | deserializedFromTemplate: { | 71 | deserializedFromTemplate: { |
72 | value: function() { | 72 | value: function() { |
73 | this.eventManager.addEventListener("appLoaded", this, false); | 73 | this.eventManager.addEventListener("appLoaded", this, false); |
74 | |||
75 | this.eventManager.addEventListener("executeFileOpen", this, false); | 74 | this.eventManager.addEventListener("executeFileOpen", this, false); |
75 | this.eventManager.addEventListener("executeNewFile", this, false); | ||
76 | } | 76 | } |
77 | }, | 77 | }, |
78 | 78 | ||
@@ -93,6 +93,21 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
93 | } | 93 | } |
94 | }, | 94 | }, |
95 | 95 | ||
96 | handleExecuteNewFile: { | ||
97 | value: function(event) { | ||
98 | var newFileSettings = event._event.settings || {}; | ||
99 | newFileSettings.callback = this.createNewFile; | ||
100 | newFileSettings.callbackScope = this; | ||
101 | this.application.ninja.newFileController.showNewFileDialog(newFileSettings); | ||
102 | } | ||
103 | }, | ||
104 | |||
105 | createNewFile:{ | ||
106 | value:function(newFileObj){ | ||
107 | //console.log(newFileObj); | ||
108 | } | ||
109 | }, | ||
110 | |||
96 | openFileWithURI: { | 111 | openFileWithURI: { |
97 | value: function(uriArrayObj) { | 112 | value: function(uriArrayObj) { |
98 | var uri = "", fileContent = "", response=null, filename="", fileType="js"; | 113 | var uri = "", fileContent = "", response=null, filename="", fileType="js"; |
diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js index f0ca568f..e448d981 100755 --- a/js/io/system/coreioapi.js +++ b/js/io/system/coreioapi.js | |||
@@ -1009,7 +1009,7 @@ exports.CoreIoApi = Montage.create(Component, { | |||
1009 | * check if the file exists | 1009 | * check if the file exists |
1010 | */ | 1010 | */ |
1011 | checkFileExists:{ | 1011 | checkFileExists:{ |
1012 | value: function(fileUri, folderUri, fileType){ | 1012 | value: function(fileName, folderUri, fileType){ |
1013 | var uri = "", response=null, status=true; | 1013 | var uri = "", response=null, status=true; |
1014 | 1014 | ||
1015 | //prepare absolute uri | 1015 | //prepare absolute uri |
@@ -1017,9 +1017,11 @@ exports.CoreIoApi = Montage.create(Component, { | |||
1017 | folderUri = folderUri + "/"; | 1017 | folderUri = folderUri + "/"; |
1018 | } | 1018 | } |
1019 | 1019 | ||
1020 | //todo:add file extension check if fileType present | 1020 | if(!!fileType && (fileName.lastIndexOf(fileType) !== (fileName.length - fileType.length))){ |
1021 | fileName = fileName+fileType; | ||
1022 | } | ||
1021 | 1023 | ||
1022 | uri = ""+folderUri+fileUri; | 1024 | uri = ""+folderUri+fileName; |
1023 | 1025 | ||
1024 | response = this.fileExists({"uri":uri}); | 1026 | response = this.fileExists({"uri":uri}); |
1025 | if(!!response && response.success && (response.status === 204)){ | 1027 | if(!!response && response.success && (response.status === 204)){ |
diff --git a/js/io/templates/descriptor.json b/js/io/templates/descriptor.json index 3d8391c5..d8fb7da4 100644 --- a/js/io/templates/descriptor.json +++ b/js/io/templates/descriptor.json | |||
@@ -1,51 +1,73 @@ | |||
1 | { | 1 | { |
2 | "categories":{ | 2 | "categories":{ |
3 | "children":["newFile"] | 3 | "children":["/"] |
4 | }, | 4 | }, |
5 | "newFile":{ | 5 | "/":{ |
6 | "name":"Blank Template", | 6 | "name":"Blank File", |
7 | "uri":"/", | 7 | "uri":"/", |
8 | "type":"directory", | 8 | "type":"directory", |
9 | "children":["html", "js", "css", "json", "php", "pl", "py", "rb"] | 9 | "children":["files/html.txt", "files/js.txt", "files/css.txt", "files/json.txt", "files/php.txt", "files/pl.txt", "files/py.txt", "files/rb.txt"] |
10 | }, | 10 | }, |
11 | "html":{ | 11 | "files/html.txt":{ |
12 | "name":"HTML", | 12 | "name":"HTML", |
13 | "uri":"files/html.txt", | 13 | "uri":"files/html.txt", |
14 | "type":"file" | 14 | "type":"file", |
15 | "fileExtension":".html", | ||
16 | "children":["defaultTemplate"] | ||
15 | }, | 17 | }, |
16 | "js":{ | 18 | "files/js.txt":{ |
17 | "name":"JavaScript", | 19 | "name":"JavaScript", |
18 | "uri":"files/js.txt", | 20 | "uri":"files/js.txt", |
19 | "type":"file" | 21 | "type":"file", |
22 | "fileExtension":".js", | ||
23 | "children":["defaultTemplate"] | ||
20 | }, | 24 | }, |
21 | "css":{ | 25 | "files/css.txt":{ |
22 | "name":"Cascading Style Sheets", | 26 | "name":"Cascading Style Sheets", |
23 | "uri":"files/css.txt", | 27 | "uri":"files/css.txt", |
24 | "type":"file" | 28 | "type":"file", |
29 | "fileExtension":".css", | ||
30 | "children":["defaultTemplate"] | ||
25 | }, | 31 | }, |
26 | "json":{ | 32 | "files/json.txt":{ |
27 | "name":"JSON", | 33 | "name":"JSON", |
28 | "uri":"files/json.txt", | 34 | "uri":"files/json.txt", |
29 | "type":"file" | 35 | "type":"file", |
36 | "fileExtension":".json", | ||
37 | "children":["defaultTemplate"] | ||
30 | }, | 38 | }, |
31 | "php":{ | 39 | "files/php.txt":{ |
32 | "name":"PHP", | 40 | "name":"PHP", |
33 | "uri":"files/php.txt", | 41 | "uri":"files/php.txt", |
34 | "type":"file" | 42 | "type":"file", |
43 | "fileExtension":".php", | ||
44 | "children":["defaultTemplate"] | ||
35 | }, | 45 | }, |
36 | "pl":{ | 46 | "files/pl.txt":{ |
37 | "name":"Perl", | 47 | "name":"Perl", |
38 | "uri":"files/pl.txt", | 48 | "uri":"files/pl.txt", |
39 | "type":"file" | 49 | "type":"file", |
50 | "fileExtension":".pl", | ||
51 | "children":["defaultTemplate"] | ||
40 | }, | 52 | }, |
41 | "py":{ | 53 | "files/py.txt":{ |
42 | "name":"Python", | 54 | "name":"Python", |
43 | "uri":"files/py.txt", | 55 | "uri":"files/py.txt", |
44 | "type":"file" | 56 | "type":"file", |
57 | "fileExtension":".py", | ||
58 | "children":["defaultTemplate"] | ||
45 | }, | 59 | }, |
46 | "rb":{ | 60 | "files/rb.txt":{ |
47 | "name":"Ruby", | 61 | "name":"Ruby", |
48 | "uri":"files/rb.txt", | 62 | "uri":"files/rb.txt", |
49 | "type":"file" | 63 | "type":"file", |
50 | } | 64 | "fileExtension":".rb", |
65 | "children":["defaultTemplate"] | ||
66 | }, | ||
67 | "defaultTemplate":{ | ||
68 | "name": "Basic", | ||
69 | "uri": "defaultTemplate", | ||
70 | "type":"file" | ||
71 | } | ||
72 | |||
51 | } \ No newline at end of file | 73 | } \ No newline at end of file |
diff --git a/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.css b/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.css index 7f11c225..092ca626 100755 --- a/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.css +++ b/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.css | |||
@@ -5,7 +5,7 @@ | |||
5 | </copyright> */ | 5 | </copyright> */ |
6 | 6 | ||
7 | .newfileLocation .newFileName{ | 7 | .newfileLocation .newFileName{ |
8 | width:70%; | 8 | width:65%; |
9 | margin-left:5px; | 9 | margin-left:5px; |
10 | } | 10 | } |
11 | 11 | ||
@@ -49,7 +49,7 @@ | |||
49 | } | 49 | } |
50 | 50 | ||
51 | .newfileLocation .nameText{ | 51 | .newfileLocation .nameText{ |
52 | margin-right:31px; | 52 | margin-right:28px; |
53 | } | 53 | } |
54 | 54 | ||
55 | .newfileLocation .hottextunit{ | 55 | .newfileLocation .hottextunit{ |
@@ -57,3 +57,6 @@ | |||
57 | display: inline; | 57 | display: inline; |
58 | } | 58 | } |
59 | 59 | ||
60 | .newfileLocation .fileExtension{ | ||
61 | color:#d7d7d7; | ||
62 | } | ||
diff --git a/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.html b/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.html index d7fbc235..8c0327eb 100755 --- a/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.html +++ b/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.html | |||
@@ -76,14 +76,18 @@ | |||
76 | <div class="template"></div> | 76 | <div class="template"></div> |
77 | </div> | 77 | </div> |
78 | <div class="locationSelection"> |