From 2557f463c1cfe2d0dd8ea187c184755bd141dab4 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 22 Mar 2012 10:38:44 -0700 Subject: IKNINJA-1302 : For File>New and File>SaveAll dialogs, 'ESC' key now triggers Cancel button and 'Enter' key now triggers OK button. For File picker, the 'ESC' now triggers the Cancel button. Signed-off-by: Ananya Sen Conflicts: js/io/ui/new-file-dialog/new-file-workflow-controller.js Signed-off-by: Ananya Sen --- js/io/ui/save-as-dialog.reel/save-as-dialog.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'js/io/ui/save-as-dialog.reel') 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..98749106 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 @@ -83,6 +83,11 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { this.enableOk(); } } + if(evt.keyCode === 13){ + if(!this.okButton.hasAttribute("disabled")){ + this.handleOkButtonAction(evt); + } + } } }, @@ -99,7 +104,7 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { handleCancelButtonAction :{ value:function(evt){ //clean up memory - //this.cleanup(); + this.cleanup(); if(this.popup){ this.popup.hide(); @@ -134,7 +139,7 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { if(success){ //clean up memory - //this.cleanup(); + this.cleanup(); if(this.popup){ this.popup.hide(); @@ -227,6 +232,20 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { } return status; } + }, + + cleanup:{ + value:function(){ + var self = this; + + //remove event listener + this.newFileName.removeEventListener("keyup", function(evt){self.handleNewFileNameOnkeyup(evt);}, false); + this.eventManager.removeEventListener("newFileDirectorySet", function(evt){self.handleNewFileDirectorySet(evt);}, false); + this.okButton.removeEventListener("click", function(evt){self.handleOkButtonAction(evt);}, false); + this.cancelButton.removeEventListener("click", function(evt){self.handleCancelButtonAction(evt);}, false); + + this.application.ninja.newFileController.saveAsDialog = null; } + } }); \ No newline at end of file -- cgit v1.2.3 From 5b0ff2b7347d158876c366c51988a94570dda18b Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 22 Mar 2012 10:43:54 -0700 Subject: IKNINJA-1302 : more fix Signed-off-by: Ananya Sen --- js/io/ui/save-as-dialog.reel/save-as-dialog.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'js/io/ui/save-as-dialog.reel') 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 98749106..4d07ca66 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 @@ -66,7 +66,10 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { handleNewFileDirectorySet:{ value:function(evt){ - if(!!evt._event.newFileDirectory){ + if((evt.keyCode === 13) && !this.okButton.hasAttribute("disabled")){ + this.handleOkButtonAction(evt); + } + else if(!!evt._event.newFileDirectory){ this.folderUri = evt._event.newFileDirectory; if(this.isValidUri(this.folderUri)){ this.enableOk(); -- cgit v1.2.3 From 7a7ac1d6479155760d99b7ecdf5a8d1f63e25f24 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 22 Mar 2012 10:46:39 -0700 Subject: IKNINJA-1361: autofocus and auto-select file name on open of new file and save as dialog Signed-off-by: Ananya Sen --- js/io/ui/save-as-dialog.reel/save-as-dialog.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'js/io/ui/save-as-dialog.reel') 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 4d07ca66..1910f30d 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,6 +60,9 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { this.okButton.addEventListener("click", function(evt){self.handleOkButtonAction(evt);}, false); this.cancelButton.addEventListener("click", function(evt){self.handleCancelButtonAction(evt);}, false); + this.newFileName.focus(); + this.newFileName.select(); + this.enableOk(); } }, -- cgit v1.2.3 From 87cf1d7d899bb60581d5e5c6c7ba678620c7148e Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 22 Mar 2012 11:46:04 -0700 Subject: IKNINJA-1302 : close on ESC even if text field is focussed Signed-off-by: Ananya Sen --- js/io/ui/save-as-dialog.reel/save-as-dialog.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'js/io/ui/save-as-dialog.reel') 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 1910f30d..dfaac1aa 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 @@ -71,6 +71,8 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { value:function(evt){ if((evt.keyCode === 13) && !this.okButton.hasAttribute("disabled")){ this.handleOkButtonAction(evt); + }else if(evt.keyCode === 27){ + this.handleCancelButtonAction(evt); } else if(!!evt._event.newFileDirectory){ this.folderUri = evt._event.newFileDirectory; @@ -93,6 +95,8 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { if(!this.okButton.hasAttribute("disabled")){ this.handleOkButtonAction(evt); } + }else if(evt.keyCode === 27){ + this.handleCancelButtonAction(evt); } } }, -- cgit v1.2.3 From 80ceeffeb3dd3227008714b8b56383f9556ff409 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 22 Mar 2012 14:49:17 -0700 Subject: KNINJA-1302 : refactored fixed as per request Signed-off-by: Ananya Sen --- js/io/ui/save-as-dialog.reel/save-as-dialog.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'js/io/ui/save-as-dialog.reel') 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 dfaac1aa..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 @@ -64,6 +64,21 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { this.newFileName.select(); this.enableOk(); + + this.element.addEventListener("keyup", function(evt){ + if(evt.keyCode == 27) {//ESC key + if(self.application.ninja.newFileController.saveAsDialog !== null){ + self.handleCancelButtonAction(); + } + }else if((evt.keyCode == 13) && !(evt.ctrlKey || evt.metaKey)){//ENTER key + if((self.application.ninja.newFileController.saveAsDialog !== null) + && !self.okButton.hasAttribute("disabled")){ + + self.handleOkButtonAction(); + } + } + }, true); + } }, -- cgit v1.2.3