mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 06:39:48 +00:00
f90e4d7419
* Started on hotkeys * Tweaks * Changed tab color * Persist sidebarWidth to workspace * Tweaks * Switched to Mousetrap
44 lines
997 B
JavaScript
44 lines
997 B
JavaScript
/**
|
|
* adds a bindGlobal method to Mousetrap that allows you to
|
|
* bind specific keyboard shortcuts that will still work
|
|
* inside a text input field
|
|
*
|
|
* usage:
|
|
* Mousetrap.bindGlobal('ctrl+s', _saveChanges);
|
|
*/
|
|
/* global Mousetrap:true */
|
|
module.exports = function(MT) {
|
|
var _globalCallbacks = {};
|
|
var _originalStopCallback = MT.prototype.stopCallback;
|
|
|
|
MT.prototype.stopCallback = function(e, element, combo, sequence) {
|
|
var self = this;
|
|
|
|
if (self.paused) {
|
|
return true;
|
|
}
|
|
|
|
if (_globalCallbacks[combo] || _globalCallbacks[sequence]) {
|
|
return false;
|
|
}
|
|
|
|
return _originalStopCallback.call(self, e, element, combo);
|
|
};
|
|
|
|
MT.prototype.bindGlobal = function(keys, callback, action) {
|
|
var self = this;
|
|
self.bind(keys, callback, action);
|
|
|
|
if (keys instanceof Array) {
|
|
for (var i = 0; i < keys.length; i++) {
|
|
_globalCallbacks[keys[i]] = true;
|
|
}
|
|
return;
|
|
}
|
|
|
|
_globalCallbacks[keys] = true;
|
|
};
|
|
|
|
MT.init();
|
|
};
|