diff --git a/service/test/functional/features/keyboard_shortcuts_to_compose.feature b/service/test/functional/features/keyboard_shortcuts_to_compose.feature
deleted file mode 100644
index 092620752..000000000
--- a/service/test/functional/features/keyboard_shortcuts_to_compose.feature
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Copyright (c) 2014 ThoughtWorks, Inc.
-#
-# Pixelated is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Pixelated is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with Pixelated. If not, see .
-
-@wip
-Feature: Using keyboard shortcuts to compose and send a mail
- As a user of pixelated
- I want to use keyboard shortcuts
- So I can compose mails
-
- Scenario: User composes a mail and sends it using shortcuts
- When I use a shortcut to compose a message with
- | subject | body |
- | Pixelated rocks! | You should definitely use it. Cheers, User. |
- And for the 'To' field I enter 'pixelated@friends.org'
- And I use a shortcut to send it
- When I select the tag 'sent'
- And I open the first mail in the mail list
- Then I see that the subject reads 'Pixelated rocks!'
- Then I see that the body reads 'You should definitely use it. Cheers, User.'
-
diff --git a/service/test/functional/features/steps/compose.py b/service/test/functional/features/steps/compose.py
index 4ebc66648..67b1bd518 100644
--- a/service/test/functional/features/steps/compose.py
+++ b/service/test/functional/features/steps/compose.py
@@ -13,11 +13,9 @@
#
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see .
-from behave import when
-from selenium.webdriver.common.action_chains import ActionChains
-from selenium.webdriver.common.keys import Keys
from time import sleep
+from behave import when
from common import *
@@ -31,16 +29,6 @@ def impl(context):
fill_by_css_selector(context, 'textarea#text-box', row['body'])
-@when('I use a shortcut to compose a message with')
-def compose_with_shortcut(context):
- body = context.browser.find_element_by_tag_name('body')
- body.send_keys('c')
-
- for row in context.table:
- fill_by_css_selector(context, 'input#subject', row['subject'])
- fill_by_css_selector(context, 'textarea#text-box', row['body'])
-
-
@when("for the '{recipients_field}' field I enter '{to_type}'")
def enter_address_impl(context, recipients_field, to_type):
_enter_recipient(context, recipients_field, to_type + "\n")
@@ -59,11 +47,6 @@ def send_impl(context):
send_button.click()
-@when('I use a shortcut to send it')
-def send_with_shortcut(context):
- ActionChains(context.browser).key_down(Keys.CONTROL).send_keys(Keys.ENTER).key_up(Keys.CONTROL).perform()
-
-
@when(u'I toggle the cc and bcc fields')
def collapse_cc_bcc_fields(context):
cc_and_bcc_chevron = wait_until_element_is_visible_by_locator(context, (By.CSS_SELECTOR, '#cc-bcc-collapse'))
diff --git a/web-ui/app/js/page/default.js b/web-ui/app/js/page/default.js
index 747617d5a..ecaedfd81 100644
--- a/web-ui/app/js/page/default.js
+++ b/web-ui/app/js/page/default.js
@@ -52,8 +52,7 @@ define(
'page/version',
'page/unread_count_title',
'page/pix_logo',
- 'helpers/browser',
- 'page/shortcuts'
+ 'helpers/browser'
],
function (
@@ -93,8 +92,7 @@ define(
version,
unreadCountTitle,
pixLogo,
- browser,
- shortcuts) {
+ browser) {
'use strict';
function initialize(path) {
@@ -139,8 +137,6 @@ define(
pixLogo.attachTo(document);
- shortcuts.attachTo(document);
-
$.ajaxSetup({headers: {'X-XSRF-TOKEN': browser.getCookie('XSRF-TOKEN')}});
});
}
diff --git a/web-ui/app/js/page/events.js b/web-ui/app/js/page/events.js
index af1ccdd04..68a6aad1e 100644
--- a/web-ui/app/js/page/events.js
+++ b/web-ui/app/js/page/events.js
@@ -109,8 +109,7 @@ define(function () {
results: 'search:results',
empty: 'search:empty',
highlightResults: 'search:highlightResults',
- resetHighlight: 'search:resetHighlight',
- focus: 'search:focus'
+ resetHighlight: 'search:resetHighlight'
},
feedback: {
submit: 'feedback:submit',
diff --git a/web-ui/app/js/page/shortcuts.js b/web-ui/app/js/page/shortcuts.js
deleted file mode 100644
index 48be57b48..000000000
--- a/web-ui/app/js/page/shortcuts.js
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (c) 2014 ThoughtWorks, Inc.
- *
- * Pixelated is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Pixelated is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with Pixelated. If not, see .
- */
-
-define([
- 'flight/lib/component',
- 'page/events'
- ],
- function (defineComponent, events) {
- 'use strict';
-
- return defineComponent(shortcuts);
-
- function shortcuts() {
- this.after('initialize', function () {
- this.on(document, 'keydown', _.bind(onKeydown, this));
- });
-
- var composeBoxId = 'compose-box';
- var keyCodes = {
- ESC: 27,
- C: 67,
- ENTER: 13,
- FORWARD_SLASH: 191,
- S: 83
- };
- var modifierKeys = {
- META: "META",
- CTRL: "CTRL"
- };
-
- // make constants public
- this.keyCodes = keyCodes;
- this.composeBoxId = composeBoxId;
-
- function onKeydown(event) {
- tryGlobalKeyEvents(event, _.bind(triggerOnDocument, this));
-
- if (composeBoxIsShown()) {
- tryMailCompositionKeyEvents(event, _.bind(triggerOnDocument, this));
- } else {
- tryMailHandlingKeyEvents(event, _.bind(triggerOnDocument, this));
- }
- }
-
- function triggerOnDocument(event) {
- this.trigger(document, event);
- }
-
- function tryGlobalKeyEvents(event, triggerFunc) {
- var globalKeyEvents = {};
- globalKeyEvents[keyCodes.ESC] = events.dispatchers.rightPane.openNoMessageSelected;
-
- if (!globalKeyEvents.hasOwnProperty(event.which)) {
- return;
- }
-
- event.preventDefault();
- return triggerFunc(globalKeyEvents[event.which]);
- }
-
- function tryMailCompositionKeyEvents(event, triggerFunc) {
- var mailCompositionKeyEvents = {};
- 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;
- }
-
- event.preventDefault();
- return triggerFunc(mailCompositionKeyEvents[modifierKey(event) + event.which]);
- }
-
- function tryMailHandlingKeyEvents(event, triggerFunc) {
- 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;
- }
-
- 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;
- }
- return modifierKey;
- }
-
- function isTriggeredOnInputField(element) {
- return $(element).is('input') || $(element).is('textarea');
- }
-
- function composeBoxIsShown() {
- return $('#' + composeBoxId).length;
- }
- }
- });
diff --git a/web-ui/app/js/search/search_trigger.js b/web-ui/app/js/search/search_trigger.js
index 662242c0f..2aff027ca 100644
--- a/web-ui/app/js/search/search_trigger.js
+++ b/web-ui/app/js/search/search_trigger.js
@@ -68,10 +68,6 @@ define(
}
};
- this.focus = function () {
- this.select('input').focus();
- };
-
this.after('initialize', function () {
this.render();
this.on(this.select('form'), 'submit', this.search);
@@ -79,7 +75,6 @@ define(
this.on(this.select('input'), 'blur', this.showSearchTermsAndPlaceHolder);
this.on(document, events.ui.tag.selected, this.clearInput);
this.on(document, events.ui.tag.select, this.clearInput);
- this.on(document, events.search.focus, this.focus);
});
}
}
diff --git a/web-ui/test/spec/page/shortcuts.spec.js b/web-ui/test/spec/page/shortcuts.spec.js
deleted file mode 100644
index 284079ec4..000000000
--- a/web-ui/test/spec/page/shortcuts.spec.js
+++ /dev/null
@@ -1,123 +0,0 @@
-describeComponent('page/shortcuts', function () {
- 'use strict';
-
- beforeEach(function () {
- this.setupComponent();
- });
-
- describe('global shortcuts', function () {
- it('triggers openNoMessageSelected when [Esc] is pressed', function () {
- var eventSpy = spyOnEvent(document, Pixelated.events.dispatchers.rightPane.openNoMessageSelected);
-
- $(document).trigger(keydownEvent(this.component.keyCodes.ESC));
-
- expect(eventSpy).toHaveBeenTriggeredOn(document);
- });
- });
-
- describe('mail list shortcuts', function () {
- function shortcutEventAndTriggeredEventSpy() {
- return [
- {
- eventSpy: spyOnEvent(document, Pixelated.events.dispatchers.rightPane.openComposeBox),
- shortcutEvent: keydownEvent(this.component.keyCodes.C)
- },
- {
- eventSpy: spyOnEvent(document, Pixelated.events.search.focus),
- shortcutEvent: keydownEvent(this.component.keyCodes.FORWARD_SLASH)
- },
- {
- eventSpy: spyOnEvent(document, Pixelated.events.search.focus),
- shortcutEvent: keydownEvent(this.component.keyCodes.S)
- }
- ];
- }
-
- it('are triggered when no input or textarea is focused', function () {
- shortcutEventAndTriggeredEventSpy.call(this).forEach(function (args) {
- var eventSpy = args.eventSpy;
-
- $(document).trigger(args.shortcutEvent);
-
- expect(eventSpy).toHaveBeenTriggeredOn(document);
- });
- });
-
- it('are not triggered when an input is focused', function () {
- _.each(shortcutEventAndTriggeredEventSpy.call(this), function (args) {
- this.$node.append('');
- var eventSpy = args.eventSpy;
-
- this.$node.find('input').trigger(args.shortcutEvent);
-
- expect(eventSpy).not.toHaveBeenTriggeredOn(document);
- }, this);
- });
-
- it('are not triggered when a textarea is focused', function () {
- _.each(shortcutEventAndTriggeredEventSpy.call(this), function (args) {
- this.$node.append('');
- var eventSpy = args.eventSpy;
-
- this.$node.find('textarea').trigger(args.shortcutEvent);
-
- expect(eventSpy).not.toHaveBeenTriggeredOn(document);
- }, this);
- });
-
- it('are not triggered when the composeBox is opened', function () {
- _.each(shortcutEventAndTriggeredEventSpy.call(this), function (args) {
- addComposeBox.call(this);
- var eventSpy = args.eventSpy;
-
- $(document).trigger(args.shortcutEvent);
-
- expect(eventSpy).not.toHaveBeenTriggeredOn(document);
- }, this);
- });
- });
-
- describe('mail composition shortcuts', function () {
- it('triggers ui.mail.send when [Ctrl] + [Enter] is pressed and compose box is open', function () {
- addComposeBox.call(this);
- var eventSpy = spyOnEvent(document, Pixelated.events.ui.mail.send);
-
- $(document).trigger(jQuery.Event('keydown', {ctrlKey: true, which: this.component.keyCodes.ENTER}));
-
- expect(eventSpy).toHaveBeenTriggeredOn(document);
- });
-
- it('triggers ui.mail.send when [Meta] + [Enter] is pressed and compose box is open', function () {
- addComposeBox.call(this);
- var eventSpy = spyOnEvent(document, Pixelated.events.ui.mail.send);
-
- $(document).trigger(jQuery.Event('keydown', {metaKey: true, which: this.component.keyCodes.ENTER}));
-
- expect(eventSpy).toHaveBeenTriggeredOn(document);
- });
-
- it('does not trigger ui.mail.send when [Ctrl] + [Enter] is pressed and compose box is closed', function () {
- var eventSpy = spyOnEvent(document, Pixelated.events.ui.mail.send);
-
- $(document).trigger(jQuery.Event('keydown', {ctrlKey: true, which: this.component.keyCodes.ENTER}));
-
- expect(eventSpy).not.toHaveBeenTriggeredOn(document);
- });
-
- it('does not trigger ui.mail.send when [Meta] + [Enter] is pressed and compose box is closed', function () {
- var eventSpy = spyOnEvent(document, Pixelated.events.ui.mail.send);
-
- $(document).trigger(jQuery.Event('keydown', {metaKey: true, which: this.component.keyCodes.ENTER}));
-
- expect(eventSpy).not.toHaveBeenTriggeredOn(document);
- });
- });
-
- function keydownEvent(code) {
- return jQuery.Event('keydown', {which: code});
- }
-
- function addComposeBox() {
- this.$node.append($('
', {id: this.component.composeBoxId}));
- }
-});
diff --git a/web-ui/test/spec/search/search_trigger.spec.js b/web-ui/test/spec/search/search_trigger.spec.js
index 12026966d..6ba474891 100644
--- a/web-ui/test/spec/search/search_trigger.spec.js
+++ b/web-ui/test/spec/search/search_trigger.spec.js
@@ -49,9 +49,5 @@ describeComponent('search/search_trigger', function () {
expect(self.component.select('input').val()).toBe('');
});
- it('should focus search input field on focus event', function () {
- $(document).trigger(Pixelated.events.search.focus);
- expect($(document.activeElement)).toEqual(this.component.select('input'));
- });
});