| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 | 
							- // XXX There is no reason to define these shortcuts globally, they should be
 
- // attached to a template (most of them will go in the `board` template).
 
- function getHoveredCardId() {
 
-   const card = $('.js-minicard:hover').get(0);
 
-   if (!card) return null;
 
-   return Blaze.getData(card)._id;
 
- }
 
- function getSelectedCardId() {
 
-   return Session.get('selectedCard') || getHoveredCardId();
 
- }
 
- Mousetrap.bind('?', () => {
 
-   FlowRouter.go('shortcuts');
 
- });
 
- Mousetrap.bind('w', () => {
 
-   if (Sidebar.isOpen() && Sidebar.getView() === 'home') {
 
-     Sidebar.toggle();
 
-   } else {
 
-     Sidebar.setView();
 
-   }
 
- });
 
- Mousetrap.bind('q', () => {
 
-   const currentBoardId = Session.get('currentBoard');
 
-   const currentUserId = Meteor.userId();
 
-   if (currentBoardId && currentUserId) {
 
-     Filter.members.toggle(currentUserId);
 
-   }
 
- });
 
- Mousetrap.bind('x', () => {
 
-   if (Filter.isActive()) {
 
-     Filter.reset();
 
-   }
 
- });
 
- Mousetrap.bind('f', () => {
 
-   if (Sidebar.isOpen() && Sidebar.getView() === 'filter') {
 
-     Sidebar.toggle();
 
-   } else {
 
-     Sidebar.setView('filter');
 
-   }
 
- });
 
- Mousetrap.bind('/', () => {
 
-   if (Sidebar.isOpen() && Sidebar.getView() === 'search') {
 
-     Sidebar.toggle();
 
-   } else {
 
-     Sidebar.setView('search');
 
-   }
 
- });
 
- Mousetrap.bind(['down', 'up'], (evt, key) => {
 
-   if (!Utils.getCurrentCardId()) {
 
-     return;
 
-   }
 
-   const nextFunc = key === 'down' ? 'next' : 'prev';
 
-   const nextCard = $('.js-minicard.is-selected')
 
-     [nextFunc]('.js-minicard')
 
-     .get(0);
 
-   if (nextCard) {
 
-     const nextCardId = Blaze.getData(nextCard)._id;
 
-     Utils.goCardId(nextCardId);
 
-   }
 
- });
 
- Mousetrap.bind('space', evt => {
 
-   const cardId = getSelectedCardId();
 
-   if (!cardId) {
 
-     return;
 
-   }
 
-   const currentUserId = Meteor.userId();
 
-   if (currentUserId === null) {
 
-     return;
 
-   }
 
-   if (Meteor.user().isBoardMember()) {
 
-     const card = Cards.findOne(cardId);
 
-     card.toggleMember(currentUserId);
 
-     // We should prevent scrolling in card when spacebar is clicked
 
-     // This should do it according to Mousetrap docs, but it doesn't
 
-     evt.preventDefault();
 
-   }
 
- });
 
- Mousetrap.bind('c', evt => {
 
-   const cardId = getSelectedCardId();
 
-   if (!cardId) {
 
-     return;
 
-   }
 
-   const currentUserId = Meteor.userId();
 
-   if (currentUserId === null) {
 
-     return;
 
-   }
 
-   if (
 
-     Meteor.user().isBoardMember() &&
 
-     !Meteor.user().isCommentOnly() &&
 
-     !Meteor.user().isWorker()
 
-   ) {
 
-     const card = Cards.findOne(cardId);
 
-     card.archive();
 
-     // We should prevent scrolling in card when spacebar is clicked
 
-     // This should do it according to Mousetrap docs, but it doesn't
 
-     evt.preventDefault();
 
-   }
 
- });
 
- Template.keyboardShortcuts.helpers({
 
-   mapping: [
 
-     {
 
-       keys: ['w'],
 
-       action: 'shortcut-toggle-sidebar',
 
-     },
 
-     {
 
-       keys: ['q'],
 
-       action: 'shortcut-filter-my-cards',
 
-     },
 
-     {
 
-       keys: ['f'],
 
-       action: 'shortcut-toggle-filterbar',
 
-     },
 
-     {
 
-       keys: ['/'],
 
-       action: 'shortcut-toggle-searchbar',
 
-     },
 
-     {
 
-       keys: ['x'],
 
-       action: 'shortcut-clear-filters',
 
-     },
 
-     {
 
-       keys: ['?'],
 
-       action: 'shortcut-show-shortcuts',
 
-     },
 
-     {
 
-       keys: ['ESC'],
 
-       action: 'shortcut-close-dialog',
 
-     },
 
-     {
 
-       keys: ['@'],
 
-       action: 'shortcut-autocomplete-members',
 
-     },
 
-     {
 
-       keys: ['SPACE'],
 
-       action: 'shortcut-assign-self',
 
-     },
 
-     {
 
-       keys: ['c'],
 
-       action: 'archive-card',
 
-     },
 
-   ],
 
- });
 
 
  |