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

28 lines
680 B
JavaScript
Raw Normal View History

2017-08-17 22:00:37 +05:30
/* global Mousetrap */
/* global Shortcuts */
2017-09-10 17:25:29 +05:30
import './shortcuts';
2017-08-17 22:00:37 +05:30
const defaults = {
skipResetBindings: false,
fileBlobPermalinkUrl: null,
};
2017-09-10 17:25:29 +05:30
export default class ShortcutsBlob extends Shortcuts {
2017-08-17 22:00:37 +05:30
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
}
}