debian-mirror-gitlab/app/assets/javascripts/shortcuts_blob.js

30 lines
700 B
JavaScript
Raw Normal View History

2017-08-17 22:00:37 +05:30
/* global Mousetrap */
/* global Shortcuts */
require('./shortcuts');
const defaults = {
skipResetBindings: false,
fileBlobPermalinkUrl: null,
};
class ShortcutsBlob extends Shortcuts {
constructor(opts) {
const options = Object.assign({}, defaults, opts);
super(options.skipResetBindings);
this.options = options;
Mousetrap.bind('y', this.moveToFilePermalink.bind(this));
}
moveToFilePermalink() {
if (this.options.fileBlobPermalinkUrl) {
const hash = gl.utils.getLocationHash();
const hashUrlString = hash ? `#${hash}` : '';
gl.utils.visitUrl(`${this.options.fileBlobPermalinkUrl}${hashUrlString}`);
2016-09-13 17:45:13 +05:30
}
2017-08-17 22:00:37 +05:30
}
}
2016-09-13 17:45:13 +05:30
2017-08-17 22:00:37 +05:30
module.exports = ShortcutsBlob;