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 --- .../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 +++++++++++ js/mediators/keyboard-mediator.js | 31 ---------------------- 4 files changed, 39 insertions(+), 31 deletions(-) (limited to 'js') 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); + } }, diff --git a/js/mediators/keyboard-mediator.js b/js/mediators/keyboard-mediator.js index 63dcfa88..fc0d0f6a 100755 --- a/js/mediators/keyboard-mediator.js +++ b/js/mediators/keyboard-mediator.js @@ -245,37 +245,6 @@ exports.KeyboardMediator = Montage.create(Component, { //menuViewManagerModule.MenuViewManager.closeMenu("mainMenuBar"); return; } - - // check for ENTER key - if((evt.keyCode == Keyboard.ENTER) && !(evt.ctrlKey || evt.metaKey)) { - //new file - if((this.application.ninja.newFileController.newFileOptionsNav !== null) - && !this.application.ninja.newFileController.newFileOptionsNav.okButton.hasAttribute("disabled")){ - - this.application.ninja.newFileController.newFileOptionsNav.handleOkButtonAction(); - } - //save as - if((this.application.ninja.newFileController.saveAsDialog !== null) - && !this.application.ninja.newFileController.saveAsDialog.okButton.hasAttribute("disabled")){ - - this.application.ninja.newFileController.saveAsDialog.handleOkButtonAction(); - } - return; - } - //ESC key - if(evt.keyCode === Keyboard.ESCAPE){ - if(this.application.ninja.filePickerController.pickerNavChoices !== null){ - this.application.ninja.filePickerController.pickerNavChoices.handleCancelButtonAction(); - } - if(this.application.ninja.newFileController.newFileOptionsNav !== null){ - this.application.ninja.newFileController.newFileOptionsNav.handleCancelButtonAction(); - } - if(this.application.ninja.newFileController.saveAsDialog !== null){ - this.application.ninja.newFileController.saveAsDialog.handleCancelButtonAction(); - } - return; - } - } }, -- cgit v1.2.3