BigW Consortium Gitlab

Commit e9025c25 by Filipa Lacerda Committed by Jacob Schatz

Improve shortcuts code

parent d9ed9c6d
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
/* global Search */ /* global Search */
/* global Admin */ /* global Admin */
/* global NamespaceSelects */ /* global NamespaceSelects */
/* global ShortcutsDashboardNavigation */
/* global Project */ /* global Project */
/* global ProjectAvatar */ /* global ProjectAvatar */
/* global CompareAutocomplete */ /* global CompareAutocomplete */
...@@ -378,7 +377,6 @@ const ShortcutsBlob = require('./shortcuts_blob'); ...@@ -378,7 +377,6 @@ const ShortcutsBlob = require('./shortcuts_blob');
break; break;
case 'dashboard': case 'dashboard':
case 'root': case 'root':
shortcut_handler = new ShortcutsDashboardNavigation();
new UserCallout(); new UserCallout();
break; break;
case 'groups': case 'groups':
......
/* eslint-disable func-names, space-before-function-paren, no-var, prefer-rest-params, wrap-iife, quotes, prefer-arrow-callback, consistent-return, object-shorthand, no-unused-vars, one-var, one-var-declaration-per-line, no-else-return, comma-dangle, max-len */ /* eslint-disable func-names, space-before-function-paren, no-var, prefer-rest-params, wrap-iife, quotes, prefer-arrow-callback, consistent-return, object-shorthand, no-unused-vars, one-var, one-var-declaration-per-line, no-else-return, comma-dangle, max-len */
/* global Mousetrap, ShortcutsDashboardNavigation */ /* global Mousetrap */
/* global findFileURL */ /* global findFileURL */
import findAndFollowLink from './shortcuts_dashboard_navigation';
(function() { (function() {
var bind = function(fn, me) { return function() { return fn.apply(me, arguments); }; }; var bind = function(fn, me) { return function() { return fn.apply(me, arguments); }; };
...@@ -14,47 +15,27 @@ ...@@ -14,47 +15,27 @@
} }
Mousetrap.bind('?', this.onToggleHelp); Mousetrap.bind('?', this.onToggleHelp);
Mousetrap.bind('s', Shortcuts.focusSearch); Mousetrap.bind('s', Shortcuts.focusSearch);
Mousetrap.bind('f', (function(_this) { Mousetrap.bind('f', (e => this.focusFilter(e)));
return function(e) {
return _this.focusFilter(e);
};
})(this));
const globalDropdownMenu = $('.global-dropdown-menu'); const globalDropdownMenu = $('.global-dropdown-menu');
$('.global-dropdown').on('hide.bs.dropdown', function() { $('.global-dropdown').on('hide.bs.dropdown', () => {
globalDropdownMenu.removeClass('shortcuts'); globalDropdownMenu.toggleClass('shortcuts');
}); });
Mousetrap.bind('n', function() { Mousetrap.bind('n', () => {
globalDropdownMenu.addClass('shortcuts'); globalDropdownMenu.toggleClass('shortcuts');
$('.global-dropdown-toggle').trigger('click'); $('.global-dropdown-toggle').trigger('click');
}); });
Mousetrap.bind('shift+t', function() { Mousetrap.bind('shift+t', () => findAndFollowLink('.shortcuts-todos'));
return ShortcutsDashboardNavigation.findAndFollowLink('.shortcuts-todos'); Mousetrap.bind('shift+a', () => findAndFollowLink('.dashboard-shortcuts-activity'));
}); Mousetrap.bind('shift+i', () => findAndFollowLink('.dashboard-shortcuts-issues'));
Mousetrap.bind('shift+a', function() { Mousetrap.bind('shift+m', () => findAndFollowLink('.dashboard-shortcuts-merge_requests'));
return ShortcutsDashboardNavigation.findAndFollowLink('.dashboard-shortcuts-activity'); Mousetrap.bind('shift+p', () => findAndFollowLink('.dashboard-shortcuts-projects'));
}); Mousetrap.bind('shift+g', () => findAndFollowLink('.dashboard-shortcuts-groups'));
Mousetrap.bind('shift+i', function() { Mousetrap.bind('shift+l', () => findAndFollowLink('.dashboard-shortcuts-milestones'));
return ShortcutsDashboardNavigation.findAndFollowLink('.dashboard-shortcuts-issues'); Mousetrap.bind('shift+s', () => findAndFollowLink('.dashboard-shortcuts-snippets'));
});
Mousetrap.bind('shift+m', function() {
return ShortcutsDashboardNavigation.findAndFollowLink('.dashboard-shortcuts-merge_requests');
});
Mousetrap.bind('shift+p', function() {
return ShortcutsDashboardNavigation.findAndFollowLink('.dashboard-shortcuts-projects');
});
Mousetrap.bind('shift+g', function() {
return ShortcutsDashboardNavigation.findAndFollowLink('.dashboard-shortcuts-groups');
});
Mousetrap.bind('shift+l', function() {
return ShortcutsDashboardNavigation.findAndFollowLink('.dashboard-shortcuts-milestones');
});
Mousetrap.bind('shift+s', function() {
return ShortcutsDashboardNavigation.findAndFollowLink('.dashboard-shortcuts-snippets');
});
Mousetrap.bind(['ctrl+shift+p', 'command+shift+p'], this.toggleMarkdownPreview); Mousetrap.bind(['ctrl+shift+p', 'command+shift+p'], this.toggleMarkdownPreview);
if (typeof findFileURL !== "undefined" && findFileURL !== null) { if (typeof findFileURL !== "undefined" && findFileURL !== null) {
......
/* eslint-disable func-names, space-before-function-paren, max-len, one-var, no-var, no-restricted-syntax, vars-on-top, no-use-before-define, no-param-reassign, new-cap, no-underscore-dangle, wrap-iife, prefer-arrow-callback, consistent-return, no-return-assign */ /**
/* global Mousetrap */ * Helper function that finds the href of the fiven selector and updates the location.
/* global Shortcuts */ *
* @param {String} selector
*/
export default (selector) => {
const link = document.querySelector(selector).getAttribute('href');
require('./shortcuts');
(function() {
var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
this.ShortcutsDashboardNavigation = (function(superClass) {
extend(ShortcutsDashboardNavigation, superClass);
function ShortcutsDashboardNavigation() {
ShortcutsDashboardNavigation.__super__.constructor.call(this);
}
ShortcutsDashboardNavigation.findAndFollowLink = function(selector) {
var link;
link = $(selector).attr('href');
if (link) { if (link) {
return window.location = link; window.location = link;
} }
}; };
return ShortcutsDashboardNavigation;
})(Shortcuts);
}).call(window);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment