aboutsummaryrefslogtreecommitdiff
path: root/js/io/ui/save-as-dialog.reel
diff options
context:
space:
mode:
authorAnanya Sen2012-04-17 18:11:55 -0700
committerAnanya Sen2012-04-17 18:11:55 -0700
commit35abad196cc9feb76ef50c1b63032a38233a6d51 (patch)
tree914689c66d4ab6c6e088b571eade0a0e35082916 /js/io/ui/save-as-dialog.reel
parent1f891c58bad0b7746659aa4138001b5ee76d9a0e (diff)
parent616a8532099fec2a15855eac97cd85cb60c4451c (diff)
downloadninja-35abad196cc9feb76ef50c1b63032a38233a6d51.tar.gz
Merge branch 'refs/heads/ninja-internal-master' into Codeview-improvements
Diffstat (limited to 'js/io/ui/save-as-dialog.reel')
-rw-r--r--js/io/ui/save-as-dialog.reel/save-as-dialog.html9
-rw-r--r--js/io/ui/save-as-dialog.reel/save-as-dialog.js96
2 files changed, 60 insertions, 45 deletions
diff --git a/js/io/ui/save-as-dialog.reel/save-as-dialog.html b/js/io/ui/save-as-dialog.reel/save-as-dialog.html
index 374e3d48..453d7a96 100644
--- a/js/io/ui/save-as-dialog.reel/save-as-dialog.html
+++ b/js/io/ui/save-as-dialog.reel/save-as-dialog.html
@@ -18,13 +18,20 @@
18 } 18 }
19 }, 19 },
20 20
21 "newFileName": {
22 "prototype": "montage/ui/textfield.reel",
23 "properties": {
24 "element": {"#": "newFileName"}
25 }
26 },
27
21 "owner":{ 28 "owner":{
22 "module": "js/io/ui/new-file-dialog/new-file-location.reel", 29 "module": "js/io/ui/new-file-dialog/new-file-location.reel",
23 "name": "SaveAsDialog", 30 "name": "SaveAsDialog",
24 "properties": { 31 "properties": {
25 "element": {"#": "saveAsDialog"}, 32 "element": {"#": "saveAsDialog"},
26 "fileInputField": {"@": "fileInputField"}, 33 "fileInputField": {"@": "fileInputField"},
27 "newFileName": {"#": "newFileName"}, 34 "newFileName": {"@": "newFileName"},
28 "error":{"#": "error"}, 35 "error":{"#": "error"},
29 "okButton":{"#": "okButton"}, 36 "okButton":{"#": "okButton"},
30 "cancelButton":{"#": "cancelButton"} 37 "cancelButton":{"#": "cancelButton"}
diff --git a/js/io/ui/save-as-dialog.reel/save-as-dialog.js b/js/io/ui/save-as-dialog.reel/save-as-dialog.js
index c5ed8d33..e2f50ff5 100644
--- a/js/io/ui/save-as-dialog.reel/save-as-dialog.js
+++ b/js/io/ui/save-as-dialog.reel/save-as-dialog.js
@@ -16,13 +16,13 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, {
16 fileName : { 16 fileName : {
17 enumerable: true, 17 enumerable: true,
18 writable: true, 18 writable: true,
19 value: "" 19 value: null
20 }, 20 },
21 21
22 folderUri:{ 22 folderUri:{
23 enumerable: true, 23 enumerable: true,
24 writable: true, 24 writable: true,
25 value: "" 25 value: null
26 }, 26 },
27 27
28 callback : { 28 callback : {
@@ -36,7 +36,12 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, {
36 writable: true, 36 writable: true,
37 value: null 37 value: null
38 }, 38 },
39 39 prepareForDraw: {
40 value: function() {
41 this.newFileName.value = this.fileName;
42 this.fileInputField.newFileDirectory.value = this.folderUri;
43 }
44 },
40 willDraw: { 45 willDraw: {
41 enumerable: false, 46 enumerable: false,
42 value: function() {} 47 value: function() {}
@@ -51,18 +56,16 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, {
51 var self = this; 56 var self = this;
52 this.fileInputField.selectDirectory = true; 57 this.fileInputField.selectDirectory = true;
53 this.fileInputField.pickerName = "saveAsDirectoryPicker"; 58 this.fileInputField.pickerName = "saveAsDirectoryPicker";
54 this.newFileName.value = this.fileName;
55 this.fileInputField.newFileDirectory.value = this.folderUri;
56 59
57 this.newFileName.addEventListener("keyup", function(evt){self.handleNewFileNameOnkeyup(evt);}, false); 60 this.addEventListener("change@newFileName.value", this.handleNewFileNameChange, false);
58 this.newFileName.addEventListener("paste", this, false); 61 this.newFileName.element.addEventListener("keyup", this, false);
59 this.eventManager.addEventListener("newFileDirectorySet", function(evt){self.handleNewFileDirectorySet(evt);}, false); 62 this.eventManager.addEventListener("newFileDirectorySet", function(evt){self.handleNewFileDirectorySet(evt);}, false);
60
61 this.okButton.addEventListener("click", function(evt){self.handleOkButtonAction(evt);}, false); 63 this.okButton.addEventListener("click", function(evt){self.handleOkButtonAction(evt);}, false);
62 this.cancelButton.addEventListener("click", function(evt){self.handleCancelButtonAction(evt);}, false); 64 this.cancelButton.addEventListener("click", function(evt){self.handleCancelButtonAction(evt);}, false);
63 65
64 this.newFileName.focus(); 66 this.eventManager.addEventListener("enterKey", this, false);
65 this.newFileName.select(); 67 this.eventManager.addEventListener("escKey", this, false);
68
66 69
67 this.enableOk(); 70 this.enableOk();
68 71
@@ -80,51 +83,59 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, {
80 } 83 }
81 }, true); 84 }, true);
82 85
86 this.newFileName.element.focus();
87 this.newFileName.element.select();
88
83 } 89 }
84 }, 90 },
85 91
86 handleNewFileDirectorySet:{ 92 handleNewFileDirectorySet:{
87 value:function(evt){ 93 value:function(evt){
88 if(evt.keyCode === 13){ 94 this.folderUri = evt._event.newFileDirectory;
89 if(!this.okButton.hasAttribute("disabled")) this.handleOkButtonAction(evt); 95 if(this.isValidUri(this.folderUri)){
90 }else if(evt.keyCode === 27){ 96 this.enableOk();
91 this.handleCancelButtonAction(evt);
92 }
93 else if(!!evt._event.newFileDirectory){
94 this.folderUri = evt._event.newFileDirectory;
95 if(this.isValidUri(this.folderUri)){
96 this.enableOk();
97 }
98 } 97 }
99 } 98 }
100 }, 99 },
101 100
102 handlePaste:{ 101 handleNewFileNameChange:{
103 value:function(evt){
104 evt.preventDefault();
105 evt.target.value = evt.clipboardData.getData("Text");
106 this.handleNewFileNameOnkeyup(evt);
107 }
108 },
109
110 handleNewFileNameOnkeyup:{
111 value:function(evt){ 102 value:function(evt){
112 this.fileName = this.newFileName.value; 103 this.fileName = this.newFileName.value;
113 if(this.fileName !== ""){ 104 if(this.isValidFileName(this.fileName)){
114 if(this.isValidFileName(this.fileName)){
115 this.enableOk(); 105 this.enableOk();
116 }
117 } 106 }
118 if(evt.keyCode === 13){ 107 }
119 if(!this.okButton.hasAttribute("disabled")){ 108 },
109
110 handleKeyup:{
111 value: function(evt){
112 if(evt.keyCode === 13){
113 if(!this.okButton.hasAttribute("disabled")){
120 this.handleOkButtonAction(evt); 114 this.handleOkButtonAction(evt);
121 } 115 }
122 }else if(evt.keyCode === 27){ 116 }else if(evt.keyCode === 27){
123 this.handleCancelButtonAction(evt); 117 this.handleCancelButtonAction(evt);
118 }
119 }
120 },
121
122 handleEnterKey:{
123 value: function(evt){
124 if((this.application.ninja.newFileController.saveAsDialog !== null)
125 && !this.okButton.hasAttribute("disabled")){
126
127 this.handleOkButtonAction(evt);
124 } 128 }
125 } 129 }
126 }, 130 },
127 131
132 handleEscKey:{
133 value: function(evt){
134 if(this.application.ninja.newFileController.saveAsDialog !== null){
135 this.handleCancelButtonAction(evt);
136 }
137 }
138 },
128 139
129 enableOk:{ 140 enableOk:{
130 value: function(){ 141 value: function(){
@@ -194,10 +205,8 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, {
194 isValidUri:{ 205 isValidUri:{
195 value: function(uri){ 206 value: function(uri){
196 var status= this.application.ninja.coreIoApi.isValidUri(uri); 207 var status= this.application.ninja.coreIoApi.isValidUri(uri);
197 if(uri !== ""){ 208 if((uri !== null) && !status){
198 if(!status){
199 this.showError("! Invalid directory."); 209 this.showError("! Invalid directory.");
200 }
201 } 210 }
202 return status; 211 return status;
203 } 212 }
@@ -205,10 +214,8 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, {
205 isValidFileName:{ 214 isValidFileName:{
206 value: function(fileName){ 215 value: function(fileName){
207 var status = this.validateFileName(fileName); 216 var status = this.validateFileName(fileName);
208 if(fileName !== ""){ 217 if((fileName !== null) && !status){
209 if(!status){