Skip to content
This repository has been archived by the owner on Jan 2, 2020. It is now read-only.

Commit

Permalink
Adhere to Jshint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
treppo committed Jul 25, 2016
1 parent 0b04cf0 commit dd08974
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
26 changes: 19 additions & 7 deletions web-ui/app/js/page/shortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -78,30 +80,40 @@ 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]);
}

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;
}

Expand Down
6 changes: 1 addition & 5 deletions web-ui/test/spec/page/shortcuts.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
{
Expand Down Expand Up @@ -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});
}
Expand Down

0 comments on commit dd08974

Please sign in to comment.