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 --- .../file-picker/picker-navigator.reel/picker-navigator.js | 9 +++++++++ .../new-file-options-navigator.js | 15 +++++++++++++++ js/io/ui/save-as-dialog.reel/save-as-dialog.js | 15 +++++++++++++++ 3 files changed, 39 insertions(+) (limited to 'js/io/ui') diff --git a/js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js b/js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js index 3cf6fc5a..945b0301 100644 --- a/js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js +++ b/js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js @@ -261,8 +261,17 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { this.okButton.addEventListener("click", function(evt){that.handleOkButtonAction(evt);}, false); this.cancelButton.addEventListener("click", function(evt){that.handleCancelButtonAction(evt);}, false); + this.element.addEventListener("keyup", function(evt){ + if(evt.keyCode == 27) { + if(that.application.ninja.filePickerController.pickerNavChoices !== null){ + that.handleCancelButtonAction(); + } + } + }, true); + //ready to show picker now this.element.style.visibility = "visible"; + this.element.focus(); } }, diff --git a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js index ecee7c1d..18556bc5 100644 --- a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js +++ b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js @@ -130,6 +130,21 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C this.okButton.addEventListener("click", function(evt){that.handleOkButtonAction(evt);}, false); this.cancelButton.addEventListener("click", function(evt){that.handleCancelButtonAction(evt);}, false); + + this.element.addEventListener("keyup", function(evt){ + if(evt.keyCode == 27) {//ESC key + if(that.application.ninja.newFileController.newFileOptionsNav !== null){ + that.handleCancelButtonAction(); + } + }else if((evt.keyCode == 13) && !(evt.ctrlKey || evt.metaKey)){//ENTER key + if((that.application.ninja.newFileController.newFileOptionsNav !== null) + && !that.okButton.hasAttribute("disabled")){ + + that.handleOkButtonAction(); + } + } + }, true); + } }, 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