From e5c0c7f109244d9bafeb91e27b720cb9895914e9 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 6 Apr 2016 16:06:26 +0200 Subject: [PATCH] Fixed shortcuts. --- .../widget/keyboard_shortcuts.coffee | 33 ++++++++++--------- test/browser/keyboard_shortcuts_test.rb | 4 +-- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/app/assets/javascripts/app/controllers/widget/keyboard_shortcuts.coffee b/app/assets/javascripts/app/controllers/widget/keyboard_shortcuts.coffee index f381ed0c6..e7929c663 100644 --- a/app/assets/javascripts/app/controllers/widget/keyboard_shortcuts.coffee +++ b/app/assets/javascripts/app/controllers/widget/keyboard_shortcuts.coffee @@ -31,19 +31,20 @@ class App.KeyboardShortcutWidget extends Spine.Module for area in areas for item in area.content for shortcut in item.shortcuts - modifier = '' - if shortcut.hotkeys - modifier += navigationHotkeys - if shortcut.key - if modifier isnt '' - modifier += '+' - modifier += shortcut.key - if shortcut.callback - @log 'debug', 'bind for', modifier - $(document).bind('keydown', modifier, (e) -> - e.preventDefault() - shortcut.callback() - ) + do (shortcut) => + modifier = '' + if shortcut.hotkeys + modifier += navigationHotkeys + if shortcut.key + if modifier isnt '' + modifier += '+' + modifier += shortcut.key + if shortcut.callback + @log 'debug', 'bind for', modifier + $(document).bind('keydown', modifier, (e) -> + e.preventDefault() + shortcut.callback() + ) App.Event.bind('global-shortcut', (e) -> for area in areas @@ -127,7 +128,7 @@ App.Config.set( hotkeys: true description: 'List of shortcuts' globalEvent: 'list-of-shortcuts' - callback: (e) => + callback: => if @dialog && @dialog.exists() @dialog.close() @dialog = false @@ -135,7 +136,7 @@ App.Config.set( @dialog = new App.KeyboardShortcutModal() } { - key: 'x' + key: 'w' hotkeys: true description: 'Close current tab' globalEvent: 'close-current-tab' @@ -397,7 +398,7 @@ App.Config.set( globalEvent: 'richtext-h3' } { - key: 'w' + key: 'x' hotkeys: true, description: 'Removes any hyperlink' globalEvent: 'richtext-remove-hyperlink' diff --git a/test/browser/keyboard_shortcuts_test.rb b/test/browser/keyboard_shortcuts_test.rb index a2dc7f597..99a194d64 100644 --- a/test/browser/keyboard_shortcuts_test.rb +++ b/test/browser/keyboard_shortcuts_test.rb @@ -75,7 +75,7 @@ class KeyboardShortcutsTest < TestCase ) # close again - shortcut(key: 'x') + shortcut(key: 'w') watch_for_disappear( css: '.active.content', @@ -94,7 +94,7 @@ class KeyboardShortcutsTest < TestCase sleep 5 # close again - shortcut(key: 'x') + shortcut(key: 'w') watch_for_disappear( css: '.active.content', value: ticket1[:number],