2017-01-25 22:13:01 -05:00
|
|
|
/* global Mousetrap */
|
|
|
|
/* global Shortcuts */
|
|
|
|
|
2017-05-16 16:51:28 -04:00
|
|
|
import './shortcuts';
|
2017-01-25 22:13:01 -05:00
|
|
|
|
|
|
|
const defaults = {
|
|
|
|
skipResetBindings: false,
|
|
|
|
fileBlobPermalinkUrl: null,
|
|
|
|
};
|
|
|
|
|
2017-05-16 18:06:34 -04:00
|
|
|
export default class ShortcutsBlob extends Shortcuts {
|
2017-01-25 22:13:01 -05:00
|
|
|
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}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|