aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rwxr-xr-xjs/io/document/document-controller.js31
-rwxr-xr-xjs/io/system/coreioapi.js8
-rw-r--r--js/io/templates/descriptor.json64
-rwxr-xr-xjs/io/ui/new-file-dialog/new-file-location.reel/new-file-location.css7
-rwxr-xr-xjs/io/ui/new-file-dialog/new-file-location.reel/new-file-location.html10
-rwxr-xr-xjs/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.css4
-rwxr-xr-xjs/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.html2
-rw-r--r--js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js70
-rwxr-xr-xjs/io/ui/new-file-dialog/new-file-workflow-controller.js37
-rwxr-xr-xjs/io/ui/new-file-dialog/new-file-workflow-model.js101
-rw-r--r--js/io/ui/save-as-dialog.reel/save-as-dialog.js22
11 files changed, 195 insertions, 161 deletions
diff --git a/js/io/document/document-controller.js b/js/io/document/document-controller.js
index d7a19e35..7cc0eeeb 100755
--- a/js/io/document/document-controller.js
+++ b/js/io/document/document-controller.js
@@ -15,7 +15,6 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
15var Montage = require("montage/core/core").Montage, 15var Montage = require("montage/core/core").Montage,
16 Component = require("montage/ui/component").Component, 16 Component = require("montage/ui/component").Component,
17 Uuid = require("montage/core/uuid").Uuid, 17 Uuid = require("montage/core/uuid").Uuid,
18 //nj= ("js/lib/NJUtils.js").NJUtils,
19 HTMLDocument = require("js/io/document/html-document").HTMLDocument, 18 HTMLDocument = require("js/io/document/html-document").HTMLDocument,
20 TextDocument = require("js/io/document/text-document").TextDocument; 19 TextDocument = require("js/io/document/text-document").TextDocument;
21 20
@@ -71,8 +70,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
71 deserializedFromTemplate: { 70 deserializedFromTemplate: {
72 value: function() { 71 value: function() {
73 this.eventManager.addEventListener("appLoaded", this, false); 72 this.eventManager.addEventListener("appLoaded", this, false);
74
75 this.eventManager.addEventListener("executeFileOpen", this, false); 73 this.eventManager.addEventListener("executeFileOpen", this, false);
74 this.eventManager.addEventListener("executeNewFile", this, false);
76 } 75 }
77 }, 76 },
78 77
@@ -93,6 +92,21 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
93 } 92 }
94 }, 93 },
95 94
95 handleExecuteNewFile: {
96 value: function(event) {
97 var newFileSettings = event._event.settings || {};
98 newFileSettings.callback = this.createNewFile;
99 newFileSettings.callbackScope = this;
100 this.application.ninja.newFileController.showNewFileDialog(newFileSettings);
101 }
102 },
103
104 createNewFile:{
105 value:function(newFileObj){
106 //console.log(newFileObj);
107 }
108 },
109
96 openFileWithURI: { 110 openFileWithURI: {
97 value: function(uriArrayObj) { 111 value: function(uriArrayObj) {
98 var uri = "", fileContent = "", response=null, filename="", fileType="js"; 112 var uri = "", fileContent = "", response=null, filename="", fileType="js";
@@ -108,7 +122,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
108 } 122 }
109 123
110 //console.log("$$$ "+uri+"\n content = \n\n\n"+ fileContent+"\n\n\n"); 124 //console.log("$$$ "+uri+"\n content = \n\n\n"+ fileContent+"\n\n\n");
111 filename = nj.getFileNameFromPath(uri); 125 filename = this.getFileNameFromPath(uri);
112 if(uri.indexOf('.') != -1){ 126 if(uri.indexOf('.') != -1){
113 fileType = uri.substr(uri.lastIndexOf('.') + 1); 127 fileType = uri.substr(uri.lastIndexOf('.') + 1);
114 } 128 }
@@ -415,5 +429,14 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
415 value: function() { 429 value: function() {
416 return "userDocument_" + (this._iframeCounter++); 430 return "userDocument_" + (this._iframeCounter++);
417 } 431 }
418 } 432 },
433
434 ///// Return the last part of a path (e.g. filename)
435 getFileNameFromPath : {
436 value: function(path) {
437 path = path.replace(/[/\\]$/g,"");
438 path = path.replace(/\\/g,"/");
439 return path.substr(path.lastIndexOf('/') + 1);
440 }
441 }
419}); \ No newline at end of file 442}); \ No newline at end of file
diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js
index 99f46fd7..5379cbfc 100755
--- a/js/io/system/coreioapi.js
+++ b/js/io/system/coreioapi.js
@@ -1086,7 +1086,7 @@ exports.CoreIoApi = Montage.create(Component, {
1086 * check if the file exists 1086 * check if the file exists
1087 */ 1087 */
1088 checkFileExists:{ 1088 checkFileExists:{
1089 value: function(fileUri, folderUri, fileType){ 1089 value: function(fileName, folderUri, fileType){
1090 var uri = "", response=null, status=true; 1090 var uri = "", response=null, status=true;
1091 1091
1092 //prepare absolute uri 1092 //prepare absolute uri
@@ -1094,9 +1094,11 @@ exports.CoreIoApi = Montage.create(Component, {
1094 folderUri = folderUri + "/"; 1094 folderUri = folderUri + "/";
1095 } 1095 }
1096 1096
1097 //todo:add file extension check if fileType present 1097 if(!!fileType && (fileName.lastIndexOf(fileType) !== (fileName.length - fileType.length))){
1098 fileName = fileName+fileType;
1099 }
1098 1100
1099 uri = ""+folderUri+fileUri; 1101 uri = ""+folderUri+fileName;
1100 1102
1101 response = this.fileExists({"uri":uri}); 1103 response = this.fileExists({"uri":uri});
1102 if(!!response && response.success && (response.status === 204)){ 1104 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/