(js,css) Improve keyboard shortcuts

- Defined some hotkeys in all modules;
- Added generation of cheat sheet.
This commit is contained in:
Francis Lachapelle committed 2016-09-27 16:16:09 -04:00
1 parent 13dd21bebb
commit 57a735753f
21 files changed
+630 -74

No files matched your search

@@ -15,8 +15,6 @@
// Expose controller for eventual popup windows
$window.$mailboxController = vm;
stateMailbox.selectFolder();
vm.service = Mailbox;
vm.accounts = stateAccounts;
vm.account = stateAccount;
@@ -38,6 +36,11 @@
vm.selectAll = selectAll;
vm.unselectMessages = unselectMessages;
stateMailbox.selectFolder();
_registerHotkeys(hotkeys);
// Expunge mailbox when leaving the Mail module
angular.element($window).on('beforeunload', _compactBeforeUnload);
$scope.$on('$destroy', function() {
@@ -57,45 +60,55 @@
$window.document.title = title;
});
_registerHotkeys(hotkeys);
function _registerHotkeys(keys) {
keys.push(sgHotkeys.createHotkey({
key: 'c',
key: l('hotkey_search'),
description: l('Search'),
callback: searchMode
}));
keys.push(sgHotkeys.createHotkey({
key: l('hotkey_compose'),
description: l('Write a new message'),
callback: newMessage
}));
keys.push(sgHotkeys.createHotkey({
key: 'space',
description: l('Toggle item'),
callback: toggleMessageSelection
}));
keys.push(sgHotkeys.createHotkey({
key: 'up',
description: l('View next item'),
callback: _nextMessage,
preventInClass: ['sg-mail-part']
}));
keys.push(sgHotkeys.createHotkey({
key: 'down',
description: l('View previous item'),
callback: _previousMessage,
preventInClass: ['sg-mail-part']
}));
keys.push(sgHotkeys.createHotkey({
key: 'shift+up',
description: l('Add next item to selection'),
callback: _addNextMessageToSelection,
preventInClass: ['sg-mail-part']
}));
keys.push(sgHotkeys.createHotkey({
key: 'shift+down',
description: l('Add previous item to selection'),
callback: _addPreviousMessageToSelection,
preventInClass: ['sg-mail-part']
}));
keys.push(sgHotkeys.createHotkey({
key: 'backspace',
description: l('Delete selected message or folder'),
callback: confirmDeleteSelectedMessages
}));
// Register the hotkeys
_.forEach(hotkeys, function(key) {
_.forEach(keys, function(key) {
sgHotkeys.registerHotkey(key);
});
}
@@ -169,6 +182,9 @@
if (index > -1)
selectMessage(vm.selectedFolder.$messages[index]);
if (vm.selectedFolder.$topIndex > 0)
vm.selectedFolder.$topIndex--;
$event.preventDefault();
return index;
@@ -191,6 +207,9 @@
else
index = -1;
if (vm.selectedFolder.$topIndex < vm.selectedFolder.getLength())
vm.selectedFolder.$topIndex++;
$event.preventDefault();
return index;
@@ -284,10 +303,10 @@
function confirmDeleteSelectedMessages($event) {
var selectedMessages = vm.selectedFolder.$selectedMessages();
if (_.size(selectedMessages) > 0)
Dialog.confirm(l('Warning'),
l('Are you sure you want to delete the selected messages?'),
{ ok: l('Delete') })
if (messageDialog === null && _.size(selectedMessages) > 0)
messageDialog = Dialog.confirm(l('Warning'),
l('Are you sure you want to delete the selected messages?'),
{ ok: l('Delete') })
.then(function() {
var deleteSelectedMessage = vm.selectedFolder.hasSelectedMessage();
vm.selectedFolder.$deleteMessages(selectedMessages).then(function(index) {
@@ -302,6 +321,9 @@
_unselectMessage(deleteSelectedMessage, index);
}
});
})
.finally(function() {
messageDialog = null;
});
$event.preventDefault();
@@ -6,11 +6,12 @@
/**
* @ngInject
*/
MailboxesController.$inject = ['$state', '$timeout', '$window', '$mdDialog', '$mdToast', '$mdMedia', '$mdSidenav', 'sgConstant', 'sgFocus', 'encodeUriFilter', 'Dialog', 'sgSettings', 'Account', 'Mailbox', 'VirtualMailbox', 'User', 'Preferences', 'stateAccounts'];
function MailboxesController($state, $timeout, $window, $mdDialog, $mdToast, $mdMedia, $mdSidenav, sgConstant, focus, encodeUriFilter, Dialog, Settings, Account, Mailbox, VirtualMailbox, User, Preferences, stateAccounts) {
MailboxesController.$inject = ['$scope', '$state', '$timeout', '$window', '$mdDialog', '$mdToast', '$mdMedia', '$mdSidenav', 'sgConstant', 'sgFocus', 'encodeUriFilter', 'Dialog', 'sgSettings', 'sgHotkeys', 'Account', 'Mailbox', 'VirtualMailbox', 'User', 'Preferences', 'stateAccounts'];
function MailboxesController($scope, $state, $timeout, $window, $mdDialog, $mdToast, $mdMedia, $mdSidenav, sgConstant, focus, encodeUriFilter, Dialog, Settings, sgHotkeys, Account, Mailbox, VirtualMailbox, User, Preferences, stateAccounts) {
var vm = this,
account,
mailbox;
mailbox,
hotkeys = [];
vm.service = Mailbox;
vm.accounts = stateAccounts;
@@ -55,12 +56,39 @@
params: []
};
Preferences.ready().then(function() {
vm.showSubscribedOnly = Preferences.defaults.SOGoMailShowSubscribedFoldersOnly;
});
vm.refreshUnseenCount();
_registerHotkeys(hotkeys);
$scope.$on('$destroy', function() {
// Deregister hotkeys
_.forEach(hotkeys, function(key) {
sgHotkeys.deregisterHotkey(key);
});
});
function _registerHotkeys(keys) {
keys.push(sgHotkeys.createHotkey({
key: 'backspace',
description: l('Delete selected message or folder'),
callback: function() {
if (Mailbox.selectedFolder && !Mailbox.selectedFolder.hasSelectedMessage())
confirmDelete(Mailbox.selectedFolder);
}
}));
// Register the hotkeys
_.forEach(keys, function(key) {
sgHotkeys.registerHotkey(key);
});
}
function showAdvancedSearch(path) {
vm.showingAdvancedSearch = true;
vm.search.mailbox = path;
@@ -39,6 +39,8 @@
vm.convertToEvent = convertToEvent;
vm.convertToTask = convertToTask;
_registerHotkeys(hotkeys);
// One-way refresh of the parent window when modifying the message from a popup window.
if ($window.opener) {
// Update the message flags. The message must be displayed in the parent window.
@@ -100,8 +102,6 @@
});
});
_registerHotkeys(hotkeys);
function _registerHotkeys(keys) {
keys.push(sgHotkeys.createHotkey({
@@ -114,7 +114,7 @@
}));
// Register the hotkeys
_.forEach(hotkeys, function(key) {
_.forEach(keys, function(key) {
sgHotkeys.registerHotkey(key);
});
}