keyboard.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // XXX There is no reason to define these shortcuts globally, they should be
  2. // attached to a template (most of them will go in the `board` template).
  3. Mousetrap.bind('?', () => {
  4. FlowRouter.go('shortcuts');
  5. });
  6. Mousetrap.bind('w', () => {
  7. Sidebar.toogle();
  8. });
  9. Mousetrap.bind('q', () => {
  10. const currentBoardId = Session.get('currentBoard');
  11. const currentUserId = Meteor.userId();
  12. if (currentBoardId && currentUserId) {
  13. Filter.members.toogle(currentUserId);
  14. }
  15. });
  16. Mousetrap.bind('x', () => {
  17. if (Filter.isActive()) {
  18. Filter.reset();
  19. }
  20. });
  21. Mousetrap.bind(['down', 'up'], (evt, key) => {
  22. if (!Session.get('currentCard')) {
  23. return;
  24. }
  25. const nextFunc = (key === 'down' ? 'next' : 'prev');
  26. const nextCard = $('.js-minicard.is-selected')[nextFunc]('.js-minicard').get(0);
  27. if (nextCard) {
  28. const nextCardId = Blaze.getData(nextCard)._id;
  29. Utils.goCardId(nextCardId);
  30. }
  31. });
  32. Template.keyboardShortcuts.helpers({
  33. mapping: [{
  34. keys: ['W'],
  35. action: 'shortcut-toogle-sidebar',
  36. }, {
  37. keys: ['Q'],
  38. action: 'shortcut-filter-my-cards',
  39. }, {
  40. keys: ['X'],
  41. action: 'shortcut-clear-filters',
  42. }, {
  43. keys: ['?'],
  44. action: 'shortcut-show-shortcuts',
  45. }, {
  46. keys: ['ESC'],
  47. action: 'shortcut-close-dialog',
  48. }, {
  49. keys: ['@'],
  50. action: 'shortcut-autocomplete-members',
  51. }, {
  52. keys: [':'],
  53. action: 'shortcut-autocomplete-emojies',
  54. }],
  55. });