aboutsummaryrefslogtreecommitdiff
path: root/js/io/ui/save-as-dialog.reel
diff options
context:
space:
mode:
Diffstat (limited to 'js/io/ui/save-as-dialog.reel')
-rw-r--r--js/io/ui/save-as-dialog.reel/save-as-dialog.js50
1 files changed, 47 insertions, 3 deletions
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 c60a92f9..d59d5be1 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
@@ -60,13 +60,36 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, {
60 this.okButton.addEventListener("click", function(evt){self.handleOkButtonAction(evt);}, false); 60 this.okButton.addEventListener("click", function(evt){self.handleOkButtonAction(evt);}, false);
61 this.cancelButton.addEventListener("click", function(evt){self.handleCancelButtonAction(evt);}, false); 61 this.cancelButton.addEventListener("click", function(evt){self.handleCancelButtonAction(evt);}, false);
62 62
63 this.newFileName.focus();
64 this.newFileName.select();
65
63 this.enableOk(); 66 this.enableOk();
67
68 this.element.addEventListener("keyup", function(evt){
69 if(evt.keyCode == 27) {//ESC key
70 if(self.application.ninja.newFileController.saveAsDialog !== null){
71 self.handleCancelButtonAction();
72 }
73 }else if((evt.keyCode == 13) && !(evt.ctrlKey || evt.metaKey)){//ENTER key
74 if((self.application.ninja.newFileController.saveAsDialog !== null)
75 && !self.okButton.hasAttribute("disabled")){
76
77 self.handleOkButtonAction();
78 }
79 }
80 }, true);
81
64 } 82 }
65 }, 83 },
66 84
67 handleNewFileDirectorySet:{ 85 handleNewFileDirectorySet:{
68 value:function(evt){ 86 value:function(evt){
69 if(!!evt._event.newFileDirectory){ 87 if((evt.keyCode === 13) && !this.okButton.hasAttribute("disabled")){
88 this.handleOkButtonAction(evt);
89 }else if(evt.keyCode === 27){
90 this.handleCancelButtonAction(evt);
91 }
92 else if(!!evt._event.newFileDirectory){
70 this.folderUri = evt._event.newFileDirectory; 93 this.folderUri = evt._event.newFileDirectory;
71 if(this.isValidUri(this.folderUri)){ 94 if(this.isValidUri(this.folderUri)){
72 this.enableOk(); 95 this.enableOk();
@@ -83,6 +106,13 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, {
83 this.enableOk(); 106 this.enableOk();
84 } 107 }
85 } 108 }
109 if(evt.keyCode === 13){
110 if(!this.okButton.hasAttribute("disabled")){
111 this.handleOkButtonAction(evt);
112 }
113 }else if(evt.keyCode === 27){
114 this.handleCancelButtonAction(evt);
115 }
86 } 116 }
87 }, 117 },
88 118
@@ -99,7 +129,7 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, {
99 handleCancelButtonAction :{ 129 handleCancelButtonAction :{
100 value:function(evt){ 130 value:function(evt){
101 //clean up memory 131 //clean up memory
102 //this.cleanup(); 132 this.cleanup();
103 133
104 if(this.popup){ 134 if(this.popup){
105 this.popup.hide(); 135 this.popup.hide();
@@ -134,7 +164,7 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, {
134 164
135 if(success){ 165 if(success){
136 //clean up memory 166 //clean up memory
137 //this.cleanup(); 167 this.cleanup();
138 168
139 if(this.popup){ 169 if(this.popup){
140 this.popup.hide(); 170 this.popup.hide();
@@ -227,6 +257,20 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, {
227 } 257 }
228 return status; 258 return status;
229 } 259 }
260 },
261
262 cleanup:{
263 value:function(){
264 var self = this;
265
266 //remove event listener
267 this.newFileName.removeEventListener("keyup", function(evt){self.handleNewFileNameOnkeyup(evt);}, false);
268 this.eventManager.removeEventListener("newFileDirectorySet", function(evt){self.handleNewFileDirectorySet(evt);}, false);
269 this.okButton.removeEventListener("click", function(evt){self.handleOkButtonAction(evt);}, false);
270 this.cancelButton.removeEventListener("click", function(evt){self.handleCancelButtonAction(evt);}, false);
271
272 this.application.ninja.newFileController.saveAsDialog = null;
230 } 273 }
274 }
231 275
232}); \ No newline at end of file 276}); \ No newline at end of file