2017-01-10 18:02:20 -05:00
|
|
|
/* 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 */
|
2016-12-14 00:26:26 -05:00
|
|
|
/* global Mousetrap */
|
|
|
|
/* global ShortcutsNavigation */
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2017-05-16 16:51:28 -04:00
|
|
|
import './shortcuts_navigation';
|
2016-07-24 16:45:11 -04:00
|
|
|
|
|
|
|
(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.ShortcutsFindFile = (function(superClass) {
|
|
|
|
extend(ShortcutsFindFile, superClass);
|
|
|
|
|
|
|
|
function ShortcutsFindFile(projectFindFile) {
|
|
|
|
var _oldStopCallback;
|
|
|
|
this.projectFindFile = projectFindFile;
|
|
|
|
ShortcutsFindFile.__super__.constructor.call(this);
|
|
|
|
_oldStopCallback = Mousetrap.stopCallback;
|
|
|
|
Mousetrap.stopCallback = (function(_this) {
|
2016-07-26 23:32:10 -04:00
|
|
|
// override to fire shortcuts action when focus in textbox
|
2016-07-24 16:45:11 -04:00
|
|
|
return function(event, element, combo) {
|
|
|
|
if (element === _this.projectFindFile.inputElement[0] && (combo === 'up' || combo === 'down' || combo === 'esc' || combo === 'enter')) {
|
2016-07-26 23:32:10 -04:00
|
|
|
// when press up/down key in textbox, cusor prevent to move to home/end
|
2016-07-24 16:45:11 -04:00
|
|
|
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;
|
|
|
|
})(ShortcutsNavigation);
|
2017-02-10 01:50:50 -05:00
|
|
|
}).call(window);
|