Commit 299da4ca authored by Phil Hughes's avatar Phil Hughes

Remove shortcut JS classes from global namespace

parent 5843a43c
/* eslint-disable func-names, space-before-function-paren, no-var, prefer-arrow-callback, wrap-iife, no-shadow, consistent-return, one-var, one-var-declaration-per-line, camelcase, default-case, no-new, quotes, no-duplicate-case, no-case-declarations, no-fallthrough, max-len */ /* eslint-disable func-names, space-before-function-paren, no-var, prefer-arrow-callback, wrap-iife, no-shadow, consistent-return, one-var, one-var-declaration-per-line, camelcase, default-case, no-new, quotes, no-duplicate-case, no-case-declarations, no-fallthrough, max-len */
/* global ProjectSelect */ /* global ProjectSelect */
/* global ShortcutsNavigation */
/* global IssuableIndex */ /* global IssuableIndex */
/* global ShortcutsIssuable */
/* global Milestone */ /* global Milestone */
/* global IssuableForm */ /* global IssuableForm */
/* global LabelsSelect */ /* global LabelsSelect */
...@@ -31,10 +29,7 @@ import CILintEditor from './ci_lint_editor'; ...@@ -31,10 +29,7 @@ import CILintEditor from './ci_lint_editor';
/* global ProjectImport */ /* global ProjectImport */
import Labels from './labels'; import Labels from './labels';
import LabelManager from './label_manager'; import LabelManager from './label_manager';
/* global Shortcuts */
/* global ShortcutsFindFile */
/* global Sidebar */ /* global Sidebar */
/* global ShortcutsWiki */
import CommitsList from './commits'; import CommitsList from './commits';
import Issue from './issue'; import Issue from './issue';
...@@ -83,6 +78,10 @@ import { ajaxGet, convertPermissionToBoolean } from './lib/utils/common_utils'; ...@@ -83,6 +78,10 @@ import { ajaxGet, convertPermissionToBoolean } from './lib/utils/common_utils';
import AjaxLoadingSpinner from './ajax_loading_spinner'; import AjaxLoadingSpinner from './ajax_loading_spinner';
import GlFieldErrors from './gl_field_errors'; import GlFieldErrors from './gl_field_errors';
import GLForm from './gl_form'; import GLForm from './gl_form';
import Shortcuts from './shortcuts';
import ShortcutsNavigation from './shortcuts_navigation';
import ShortcutsFindFile from './shortcuts_find_file';
import ShortcutsIssuable from './shortcuts_issuable';
import U2FAuthenticate from './u2f/authenticate'; import U2FAuthenticate from './u2f/authenticate';
import Members from './members'; import Members from './members';
import memberExpirationDate from './member_expiration_date'; import memberExpirationDate from './member_expiration_date';
......
...@@ -21,15 +21,6 @@ window._ = _; ...@@ -21,15 +21,6 @@ window._ = _;
window.Dropzone = Dropzone; window.Dropzone = Dropzone;
window.Sortable = Sortable; window.Sortable = Sortable;
// shortcuts
import './shortcuts';
import './shortcuts_blob';
import './shortcuts_dashboard_navigation';
import './shortcuts_navigation';
import './shortcuts_find_file';
import './shortcuts_issuable';
import './shortcuts_network';
// templates // templates
import './templates/issuable_template_selector'; import './templates/issuable_template_selector';
import './templates/issuable_template_selectors'; import './templates/issuable_template_selectors';
......
/* eslint-disable func-names, space-before-function-paren, prefer-arrow-callback, quotes, no-var, vars-on-top, camelcase, comma-dangle, consistent-return, max-len */ /* eslint-disable func-names, space-before-function-paren, prefer-arrow-callback, quotes, no-var, vars-on-top, camelcase, comma-dangle, consistent-return, max-len */
/* global ShortcutsNetwork */
import ShortcutsNetwork from '../shortcuts_network';
import Network from './network'; import Network from './network';
$(function() { $(function() {
......
/* 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 */
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
import Mousetrap from 'mousetrap'; import Mousetrap from 'mousetrap';
import findAndFollowLink from './shortcuts_dashboard_navigation'; import findAndFollowLink from './shortcuts_dashboard_navigation';
(function() { const defaultStopCallback = Mousetrap.stopCallback;
this.Shortcuts = (function() { Mousetrap.stopCallback = (e, element, combo) => {
function Shortcuts(skipResetBindings) { if (['ctrl+shift+p', 'command+shift+p'].indexOf(combo) !== -1) {
this.onToggleHelp = this.onToggleHelp.bind(this); return false;
this.enabledHelp = []; }
if (!skipResetBindings) {
Mousetrap.reset(); return defaultStopCallback(e, element, combo);
} };
Mousetrap.bind('?', this.onToggleHelp);
Mousetrap.bind('s', Shortcuts.focusSearch); export default class Shortcuts {
Mousetrap.bind('f', (e => this.focusFilter(e))); constructor(skipResetBindings) {
Mousetrap.bind('p b', this.onTogglePerfBar); this.onToggleHelp = this.onToggleHelp.bind(this);
this.enabledHelp = [];
const findFileURL = document.body.dataset.findFile; if (!skipResetBindings) {
Mousetrap.reset();
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) {
Mousetrap.bind('t', function() {
return gl.utils.visitUrl(findFileURL);
});
}
} }
Mousetrap.bind('?', this.onToggleHelp);
Mousetrap.bind('s', Shortcuts.focusSearch);
Mousetrap.bind('f', this.focusFilter.bind(this));
Mousetrap.bind('p b', Shortcuts.onTogglePerfBar);
Shortcuts.prototype.onToggleHelp = function(e) { const findFileURL = document.body.dataset.findFile;
e.preventDefault();
return Shortcuts.toggleHelp(this.enabledHelp); 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'], Shortcuts.toggleMarkdownPreview);
Shortcuts.prototype.onTogglePerfBar = function(e) { if (typeof findFileURL !== 'undefined' && findFileURL !== null) {
Mousetrap.bind('t', () => {
gl.utils.visitUrl(findFileURL);
});
}
$(document).on('click.more_help', '.js-more-help-button', function clickMoreHelp(e) {
$(this).remove();
$('.hidden-shortcut').show();
e.preventDefault(); e.preventDefault();
const performanceBarCookieName = 'perf_bar_enabled'; });
if (Cookies.get(performanceBarCookieName) === 'true') { }
Cookies.remove(performanceBarCookieName, { path: '/' });
} else { onToggleHelp(e) {
Cookies.set(performanceBarCookieName, 'true', { path: '/' }); e.preventDefault();
} Shortcuts.toggleHelp(this.enabledHelp);
gl.utils.refreshCurrentPage(); }
};
static onTogglePerfBar(e) {
Shortcuts.prototype.toggleMarkdownPreview = function(e) { e.preventDefault();
// Check if short-cut was triggered while in Write Mode const performanceBarCookieName = 'perf_bar_enabled';
const $target = $(e.target); if (Cookies.get(performanceBarCookieName) === 'true') {
const $form = $target.closest('form'); Cookies.remove(performanceBarCookieName, { path: '/' });
} else {
if ($target.hasClass('js-note-text')) { Cookies.set(performanceBarCookieName, 'true', { path: '/' });
$('.js-md-preview-button', $form).focus(); }
} gl.utils.refreshCurrentPage();
return $(document).triggerHandler('markdown-preview:toggle', [e]); }
};
static toggleMarkdownPreview(e) {
Shortcuts.toggleHelp = function(location) { // Check if short-cut was triggered while in Write Mode
var $modal; const $target = $(e.target);
$modal = $('#modal-shortcuts'); const $form = $target.closest('form');
if ($modal.length) {
$modal.modal('toggle'); if ($target.hasClass('js-note-text')) {
return; $('.js-md-preview-button', $form).focus();
} }
return $.ajax({ $(document).triggerHandler('markdown-preview:toggle', [e]);
url: gon.shortcuts_path, }
dataType: 'script',
success: function(e) { static toggleHelp(location) {
var i, l, len, results; const $modal = $('#modal-shortcuts');
if (location && location.length > 0) {
results = []; if ($modal.length) {
for (i = 0, len = location.length; i < len; i += 1) { $modal.modal('toggle');
l = location[i]; }
results.push($(l).show());
} $.ajax({
return results; url: gon.shortcuts_path,
} else { dataType: 'script',
$('.hidden-shortcut').show(); success() {
return $('.js-more-help-button').remove(); if (location && location.length > 0) {
const results = [];
for (let i = 0, len = location.length; i < len; i += 1) {
results.push($(location[i]).show());
} }
return results;
} }
});
}; $('.hidden-shortcut').show();
return $('.js-more-help-button').remove();
Shortcuts.prototype.focusFilter = function(e) { },
if (this.filterInput == null) { });
this.filterInput = $('input[type=search]', '.nav-controls'); }
}
this.filterInput.focus(); focusFilter(e) {
return e.preventDefault(); if (!this.filterInput) {
}; this.filterInput = $('input[type=search]', '.nav-controls');
}
Shortcuts.focusSearch = function(e) { this.filterInput.focus();
$('#search').focus(); e.preventDefault();
return e.preventDefault(); }
};
static focusSearch(e) {
return Shortcuts; $('#search').focus();
})(); e.preventDefault();
}
$(document).on('click.more_help', '.js-more-help-button', function(e) { }
$(this).remove();
$('.hidden-shortcut').show();
return e.preventDefault();
});
Mousetrap.stopCallback = (function() {
var defaultStopCallback;
defaultStopCallback = Mousetrap.stopCallback;
return function(e, element, combo) {
// allowed shortcuts if textarea, input, contenteditable are focused
if (['ctrl+shift+p', 'command+shift+p'].indexOf(combo) !== -1) {
return false;
} else {
return defaultStopCallback.apply(this, arguments);
}
};
})();
}).call(window);
/* global Mousetrap */ /* global Mousetrap */
/* global Shortcuts */
import './shortcuts'; import Shortcuts from './shortcuts';
const defaults = { const defaults = {
skipResetBindings: false, skipResetBindings: false,
......
/* 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 */
/* global Mousetrap */ /* global Mousetrap */
/* global ShortcutsNavigation */
import './shortcuts_navigation'; import ShortcutsNavigation from './shortcuts_navigation';
(function() { export default class ShortcutsFindFile extends ShortcutsNavigation {
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; }, constructor(projectFindFile) {
hasProp = {}.hasOwnProperty; super();
this.ShortcutsFindFile = (function(superClass) { const oldStopCallback = Mousetrap.stopCallback;
extend(ShortcutsFindFile, superClass); this.projectFindFile = projectFindFile;
function ShortcutsFindFile(projectFindFile) { Mousetrap.stopCallback = (e, element, combo) => {
var _oldStopCallback; if (
this.projectFindFile = projectFindFile; element === this.projectFindFile.inputElement[0] &&
ShortcutsFindFile.__super__.constructor.call(this); (combo === 'up' || combo === 'down' || combo === 'esc' || combo === 'enter')
_oldStopCallback = Mousetrap.stopCallback; ) {
Mousetrap.stopCallback = (function(_this) { // when press up/down key in textbox, cusor prevent to move to home/end
// override to fire shortcuts action when focus in textbox event.preventDefault();
return function(event, element, combo) { return false;
if (element === _this.projectFindFile.inputElement[0] && (combo === 'up' || combo === 'down' || combo === 'esc' || combo === 'enter')) { }
// when press up/down key in textbox, cusor prevent to move to home/end
event.preventDefault();
return false;
}
return _oldStopCallback(event, element, combo);
};
})(this);
Mousetrap.bind('up', this.projectFindFile.selectRowUp);
Mousetrap.bind('down', this.projectFindFile.selectRowDown);
Mousetrap.bind('esc', this.projectFindFile.goToTree);
Mousetrap.bind('enter', this.projectFindFile.goToBlob);
}
return ShortcutsFindFile; return oldStopCallback(e, element, combo);
})(ShortcutsNavigation); };
}).call(window);
Mousetrap.bind('up', this.projectFindFile.selectRowUp);
Mousetrap.bind('down', this.projectFindFile.selectRowDown);
Mousetrap.bind('esc', this.projectFindFile.goToTree);
Mousetrap.bind('enter', this.projectFindFile.goToBlob);
}
}
/* eslint-disable func-names, space-before-function-paren, max-len, no-var, one-var, no-restricted-syntax, vars-on-top, no-use-before-define, no-param-reassign, new-cap, no-underscore-dangle, wrap-iife, one-var-declaration-per-line, quotes, prefer-arrow-callback, consistent-return, prefer-template, no-mixed-operators */
/* global Mousetrap */ /* global Mousetrap */
/* global ShortcutsNavigation */
/* global sidebar */ /* global sidebar */
import _ from 'underscore'; import _ from 'underscore';
import 'mousetrap'; import 'mousetrap';
import './shortcuts_navigation'; import ShortcutsNavigation from './shortcuts_navigation';
(function() { export default class ShortcutsIssuable extends ShortcutsNavigation {
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; }, constructor(isMergeRequest) {
hasProp = {}.hasOwnProperty; super();
this.ShortcutsIssuable = (function(superClass) { this.$replyField = isMergeRequest ? $('.js-main-target-form #note_note') : $('.js-main-target-form .js-vue-comment-form');
extend(ShortcutsIssuable, superClass); this.editBtn = document.querySelector('.issuable-edit');
function ShortcutsIssuable(isMergeRequest) { Mousetrap.bind('a', () => ShortcutsIssuable.openSidebarDropdown('assignee'));
ShortcutsIssuable.__super__.constructor.call(this); Mousetrap.bind('m', () => ShortcutsIssuable.openSidebarDropdown('milestone'));
Mousetrap.bind('a', this.openSidebarDropdown.bind(this, 'assignee')); Mousetrap.bind('l', () => ShortcutsIssuable.openSidebarDropdown('labels'));
Mousetrap.bind('m', this.openSidebarDropdown.bind(this, 'milestone')); Mousetrap.bind('r', this.replyWithSelectedText.bind(this));
Mousetrap.bind('r', (function(_this) { Mousetrap.bind('e', this.editIssue.bind(this));
return function() {
_this.replyWithSelectedText(isMergeRequest); if (isMergeRequest) {
return false; this.enabledHelp.push('.hidden-shortcut.merge_requests');
}; } else {
})(this)); this.enabledHelp.push('.hidden-shortcut.issues');
Mousetrap.bind('e', (function(_this) {
return function() {
_this.editIssue();
return false;
};
})(this));
Mousetrap.bind('l', this.openSidebarDropdown.bind(this, 'labels'));
if (isMergeRequest) {
this.enabledHelp.push('.hidden-shortcut.merge_requests');
} else {
this.enabledHelp.push('.hidden-shortcut.issues');
}
} }
}
replyWithSelectedText() {
const documentFragment = window.gl.utils.getSelectedFragment();
if (!documentFragment) {
this.$replyField.focus();
return false;
}
const el = window.gl.CopyAsGFM.transformGFMSelection(documentFragment.cloneNode(true));
const selected = window.gl.CopyAsGFM.nodeToGFM(el);
ShortcutsIssuable.prototype.replyWithSelectedText = function(isMergeRequest) { if (selected.trim() === '') {
var quote, documentFragment, el, selected, separator;
let replyField;
if (isMergeRequest) {
replyField = $('.js-main-target-form #note_note');
} else {
replyField = $('.js-main-target-form .js-vue-comment-form');
}
documentFragment = window.gl.utils.getSelectedFragment();
if (!documentFragment) {
replyField.focus();
return;
}
el = window.gl.CopyAsGFM.transformGFMSelection(documentFragment.cloneNode(true));
selected = window.gl.CopyAsGFM.nodeToGFM(el);
if (selected.trim() === "") {
return;
}
quote = _.map(selected.split("\n"), function(val) {
return ("> " + val).trim() + "\n";
});
// If replyField already has some content, add a newline before our quote
separator = replyField.val().trim() !== "" && "\n\n" || '';
replyField.val(function(a, current) {
return current + separator + quote.join('') + "\n";
});
// Trigger autosave
replyField.trigger('input').trigger('change');
// Trigger autosize
var event = document.createEvent('Event');
event.initEvent('autosize:update', true, false);
replyField.get(0).dispatchEvent(event);
// Focus the input field
return replyField.focus();
};
ShortcutsIssuable.prototype.editIssue = function() {
var $editBtn;
$editBtn = $('.issuable-edit');
// Need to click the element as on issues, editing is inline
// on merge request, editing is on a different page
$editBtn.get(0).click();
};
ShortcutsIssuable.prototype.openSidebarDropdown = function(name) {
sidebar.openDropdown(name);
return false; return false;
}; }
const quote = _.map(selected.split('\n'), val => `> ${val.trim()}\n`);
// If replyField already has some content, add a newline before our quote
const separator = (this.$replyField.val().trim() !== '' && '\n\n') || '';
this.$replyField.val((a, current) => `${current}${separator}${quote.join('')}\n`)
.trigger('input')
.trigger('change');
// Trigger autosize
const event = document.createEvent('Event');
event.initEvent('autosize:update', true, false);
this.$replyField.get(0).dispatchEvent(event);
// Focus the input field
this.$replyField.focus();
return false;
}
editIssue() {
// Need to click the element as on issues, editing is inline
// on merge request, editing is on a different page
this.editBtn.click();
return false;
}
return ShortcutsIssuable; static openSidebarDropdown(name) {
})(ShortcutsNavigation); sidebar.openDropdown(name);
}).call(window); return false;
}
}
/* eslint-disable func-names, space-before-function-paren, max-len, no-var, one-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 Mousetrap */
/* global Shortcuts */
import findAndFollowLink from './shortcuts_dashboard_navigation'; import findAndFollowLink from './shortcuts_dashboard_navigation';
import './shortcuts'; import Shortcuts from './shortcuts';
(function() { export default class ShortcutsNavigation extends Shortcuts {
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; }, constructor() {
hasProp = {}.hasOwnProperty; super();
this.ShortcutsNavigation = (function(superClass) { Mousetrap.bind('g p', () => findAndFollowLink('.shortcuts-project'));
extend(ShortcutsNavigation, superClass); Mousetrap.bind('g e', () => findAndFollowLink('.shortcuts-project-activity'));
Mousetrap.bind('g f', () => findAndFollowLink('.shortcuts-tree'));
Mousetrap.bind('g c', () => findAndFollowLink('.shortcuts-commits'));
Mousetrap.bind('g j', () => findAndFollowLink('.shortcuts-builds'));
Mousetrap.bind('g n', () => findAndFollowLink('.shortcuts-network'));
Mousetrap.bind('g d', () => findAndFollowLink('.shortcuts-repository-charts'));
Mousetrap.bind('g i', () => findAndFollowLink('.shortcuts-issues'));
Mousetrap.bind('g b', () => findAndFollowLink('.shortcuts-issue-boards'));
Mousetrap.bind('g m', () => findAndFollowLink('.shortcuts-merge_requests'));
Mousetrap.bind('g t', () => findAndFollowLink('.shortcuts-todos'));
Mousetrap.bind('g w', () => findAndFollowLink('.shortcuts-wiki'));
Mousetrap.bind('g s', () => findAndFollowLink('.shortcuts-snippets'));
Mousetrap.bind('i', () => findAndFollowLink('.shortcuts-new-issue'));
function ShortcutsNavigation() { this.enabledHelp.push('.hidden-shortcut.project');
ShortcutsNavigation.__super__.constructor.call(this); }
Mousetrap.bind('g p', () => findAndFollowLink('.shortcuts-project')); }
Mousetrap.bind('g e', () => findAndFollowLink('.shortcuts-project-activity'));
Mousetrap.bind('g f', () => findAndFollowLink('.shortcuts-tree'));
Mousetrap.bind('g c', () => findAndFollowLink('.shortcuts-commits'));
Mousetrap.bind('g j', () => findAndFollowLink('.shortcuts-builds'));
Mousetrap.bind('g n', () => findAndFollowLink('.shortcuts-network'));
Mousetrap.bind('g d', () => findAndFollowLink('.shortcuts-repository-charts'));
Mousetrap.bind('g i', () => findAndFollowLink('.shortcuts-issues'));
Mousetrap.bind('g b', () => findAndFollowLink('.shortcuts-issue-boards'));
Mousetrap.bind('g m', () => findAndFollowLink('.shortcuts-merge_requests'));
Mousetrap.bind('g t', () => findAndFollowLink('.shortcuts-todos'));
Mousetrap.bind('g w', () => findAndFollowLink('.shortcuts-wiki'));
Mousetrap.bind('g s', () => findAndFollowLink('.shortcuts-snippets'));
Mousetrap.bind('i', () => findAndFollowLink('.shortcuts-new-issue'));
this.enabledHelp.push('.hidden-shortcut.project');
}
return ShortcutsNavigation;
})(Shortcuts);
}).call(window);
/* eslint-disable func-names, space-before-function-paren, max-len, no-var, one-var, no-restricted-syntax, vars-on-top, no-use-before-define, no-param-reassign, new-cap, no-underscore-dangle, wrap-iife, max-len */
/* global Mousetrap */ /* global Mousetrap */
/* global ShortcutsNavigation */ import ShortcutsNavigation from './shortcuts_navigation';
import './shortcuts_navigation'; export default class ShortcutsNetwork extends ShortcutsNavigation {
constructor(graph) {
super();
(function() { Mousetrap.bind(['left', 'h'], graph.scrollLeft);
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; }, Mousetrap.bind(['right', 'l'], graph.scrollRight);
hasProp = {}.hasOwnProperty; Mousetrap.bind(['up', 'k'], graph.scrollUp);
Mousetrap.bind(['down', 'j'], graph.scrollDown);
Mousetrap.bind(['shift+up', 'shift+k'], graph.scrollTop);
Mousetrap.bind(['shift+down', 'shift+j'], graph.scrollBottom);
this.ShortcutsNetwork = (function(superClass) { this.enabledHelp.push('.hidden-shortcut.network');
extend(ShortcutsNetwork, superClass); }
}
function ShortcutsNetwork(graph) {
this.graph = graph;
ShortcutsNetwork.__super__.constructor.call(this);
Mousetrap.bind(['left', 'h'], this.graph.scrollLeft);
Mousetrap.bind(['right', 'l'], this.graph.scrollRight);
Mousetrap.bind(['up', 'k'], this.graph.scrollUp);
Mousetrap.bind(['down', 'j'], this.graph.scrollDown);
Mousetrap.bind(['shift+up', 'shift+k'], this.graph.scrollTop);
Mousetrap.bind(['shift+down', 'shift+j'], this.graph.scrollBottom);
this.enabledHelp.push('.hidden-shortcut.network');
}
return ShortcutsNetwork;
})(ShortcutsNavigation);
}).call(window);
/* eslint-disable class-methods-use-this */ /* eslint-disable class-methods-use-this */
/* global Mousetrap */ /* global Mousetrap */
/* global ShortcutsNavigation */
import ShortcutsNavigation from './shortcuts_navigation';
import findAndFollowLink from './shortcuts_dashboard_navigation'; import findAndFollowLink from './shortcuts_dashboard_navigation';
export default class ShortcutsWiki extends ShortcutsNavigation { export default class ShortcutsWiki extends ShortcutsNavigation {
......
/* global ShortcutsIssuable */
import '~/copy_as_gfm'; import '~/copy_as_gfm';
import '~/shortcuts_issuable'; import ShortcutsIssuable from '~/shortcuts_issuable';
describe('ShortcutsIssuable', () => { describe('ShortcutsIssuable', () => {
const fixtureName = 'merge_requests/diff_comment.html.raw'; const fixtureName = 'merge_requests/diff_comment.html.raw';
......
/* global Shortcuts */ import Shortcuts from '~/shortcuts';
describe('Shortcuts', () => { describe('Shortcuts', () => {
const fixtureName = 'merge_requests/diff_comment.html.raw'; const fixtureName = 'merge_requests/diff_comment.html.raw';
const createEvent = (type, target) => $.Event(type, { const createEvent = (type, target) => $.Event(type, {
......
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