Improve shortcuts code
This commit is contained in:
parent
d9ed9c6d0d
commit
e9025c25e4
|
@ -24,7 +24,6 @@
|
|||
/* global Search */
|
||||
/* global Admin */
|
||||
/* global NamespaceSelects */
|
||||
/* global ShortcutsDashboardNavigation */
|
||||
/* global Project */
|
||||
/* global ProjectAvatar */
|
||||
/* global CompareAutocomplete */
|
||||
|
@ -378,7 +377,6 @@ const ShortcutsBlob = require('./shortcuts_blob');
|
|||
break;
|
||||
case 'dashboard':
|
||||
case 'root':
|
||||
shortcut_handler = new ShortcutsDashboardNavigation();
|
||||
new UserCallout();
|
||||
break;
|
||||
case 'groups':
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* 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 */
|
||||
import findAndFollowLink from './shortcuts_dashboard_navigation';
|
||||
|
||||
(function() {
|
||||
var bind = function(fn, me) { return function() { return fn.apply(me, arguments); }; };
|
||||
|
@ -14,47 +15,27 @@
|
|||
}
|
||||
Mousetrap.bind('?', this.onToggleHelp);
|
||||
Mousetrap.bind('s', Shortcuts.focusSearch);
|
||||
Mousetrap.bind('f', (function(_this) {
|
||||
return function(e) {
|
||||
return _this.focusFilter(e);
|
||||
};
|
||||
})(this));
|
||||
Mousetrap.bind('f', (e => this.focusFilter(e)));
|
||||
|
||||
const globalDropdownMenu = $('.global-dropdown-menu');
|
||||
|
||||
$('.global-dropdown').on('hide.bs.dropdown', function() {
|
||||
globalDropdownMenu.removeClass('shortcuts');
|
||||
$('.global-dropdown').on('hide.bs.dropdown', () => {
|
||||
globalDropdownMenu.toggleClass('shortcuts');
|
||||
});
|
||||
|
||||
Mousetrap.bind('n', function() {
|
||||
globalDropdownMenu.addClass('shortcuts');
|
||||
Mousetrap.bind('n', () => {
|
||||
globalDropdownMenu.toggleClass('shortcuts');
|
||||
$('.global-dropdown-toggle').trigger('click');
|
||||
});
|
||||
|
||||
Mousetrap.bind('shift+t', function() {
|
||||
return ShortcutsDashboardNavigation.findAndFollowLink('.shortcuts-todos');
|
||||
});
|
||||
Mousetrap.bind('shift+a', function() {
|
||||
return ShortcutsDashboardNavigation.findAndFollowLink('.dashboard-shortcuts-activity');
|
||||
});
|
||||
Mousetrap.bind('shift+i', function() {
|
||||
return ShortcutsDashboardNavigation.findAndFollowLink('.dashboard-shortcuts-issues');
|
||||
});
|
||||
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('shift+t', () => findAndFollowLink('.shortcuts-todos'));
|
||||
Mousetrap.bind('shift+a', () => findAndFollowLink('.dashboard-shortcuts-activity'));
|
||||
Mousetrap.bind('shift+i', () => findAndFollowLink('.dashboard-shortcuts-issues'));
|
||||
Mousetrap.bind('shift+m', () => findAndFollowLink('.dashboard-shortcuts-merge_requests'));
|
||||
Mousetrap.bind('shift+p', () => findAndFollowLink('.dashboard-shortcuts-projects'));
|
||||
Mousetrap.bind('shift+g', () => findAndFollowLink('.dashboard-shortcuts-groups'));
|
||||
Mousetrap.bind('shift+l', () => findAndFollowLink('.dashboard-shortcuts-milestones'));
|
||||
Mousetrap.bind('shift+s', () => findAndFollowLink('.dashboard-shortcuts-snippets'));
|
||||
|
||||
Mousetrap.bind(['ctrl+shift+p', 'command+shift+p'], this.toggleMarkdownPreview);
|
||||
if (typeof findFileURL !== "undefined" && findFileURL !== null) {
|
||||
|
|
|
@ -1,28 +1,12 @@
|
|||
/* 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 */
|
||||
/* global Shortcuts */
|
||||
/**
|
||||
* Helper function that finds the href of the fiven selector and updates the location.
|
||||
*
|
||||
* @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) {
|
||||
return window.location = link;
|
||||
}
|
||||
};
|
||||
|
||||
return ShortcutsDashboardNavigation;
|
||||
})(Shortcuts);
|
||||
}).call(window);
|
||||
if (link) {
|
||||
window.location = link;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue