diff --git a/web-ui/app/js/page/shortcuts.js b/web-ui/app/js/page/shortcuts.js index b3b9c408e..fe505802e 100644 --- a/web-ui/app/js/page/shortcuts.js +++ b/web-ui/app/js/page/shortcuts.js @@ -60,14 +60,16 @@ define([ var self = this; return function (event) { self.trigger(document, event); - } + }; } function tryGlobalKeyEvents(event, triggerFunc) { var globalKeyEvents = {}; globalKeyEvents[keyCodes.ESC] = events.dispatchers.rightPane.openNoMessageSelected; - if (!globalKeyEvents.hasOwnProperty(event.which)) return; + if (!globalKeyEvents.hasOwnProperty(event.which)) { + return; + } triggerFunc(globalKeyEvents[event.which]); event.preventDefault(); @@ -78,21 +80,27 @@ define([ mailCompositionKeyEvents[modifierKeys.CTRL + keyCodes.ENTER] = events.ui.mail.send; mailCompositionKeyEvents[modifierKeys.META + keyCodes.ENTER] = events.ui.mail.send; - if (!mailCompositionKeyEvents.hasOwnProperty(modifierKey(event) + event.which)) return; + if (!mailCompositionKeyEvents.hasOwnProperty(modifierKey(event) + event.which)) { + return; + } event.preventDefault(); return triggerFunc(mailCompositionKeyEvents[modifierKey(event) + event.which]); } function tryMailHandlingKeyEvents(event, triggerFunc) { - if (isTriggeredOnInputField(event.target)) return; + if (isTriggeredOnInputField(event.target)) { + return; + } var mailHandlingKeyEvents = {}; mailHandlingKeyEvents[keyCodes.S] = events.search.focus; mailHandlingKeyEvents[keyCodes.FORWARD_SLASH] = events.search.focus; mailHandlingKeyEvents[keyCodes.C] = events.dispatchers.rightPane.openComposeBox; - if (!mailHandlingKeyEvents.hasOwnProperty(event.which)) return; + if (!mailHandlingKeyEvents.hasOwnProperty(event.which)) { + return; + } event.preventDefault(); return triggerFunc(mailHandlingKeyEvents[event.which]); @@ -100,8 +108,12 @@ define([ function modifierKey(event) { var modifierKey = ""; - if (event.ctrlKey === true) modifierKey = modifierKeys.CTRL; - if (event.metaKey === true) modifierKey = modifierKeys.META; + if (event.ctrlKey === true) { + modifierKey = modifierKeys.CTRL; + } + if (event.metaKey === true) { + modifierKey = modifierKeys.META; + } return modifierKey; } diff --git a/web-ui/test/spec/page/shortcuts.spec.js b/web-ui/test/spec/page/shortcuts.spec.js index d621f122a..8e3578157 100644 --- a/web-ui/test/spec/page/shortcuts.spec.js +++ b/web-ui/test/spec/page/shortcuts.spec.js @@ -19,7 +19,7 @@ describeComponent('page/shortcuts', function () { function shortcutEventAndTriggeredEventSpy() { return [ { - eventSpy: openComposeBoxEventSpy(), + eventSpy: spyOnEvent(document, Pixelated.events.dispatchers.rightPane.openComposeBox), shortcutEvent: keydownEvent(this.component.keyCodes.C) }, { @@ -116,10 +116,6 @@ describeComponent('page/shortcuts', function () { }); }); - function openComposeBoxEventSpy() { - return spyOnEvent(document, Pixelated.events.dispatchers.rightPane.openComposeBox); - } - function keydownEvent(code) { return jQuery.Event('keydown', {which: code}); }