All files / platform/core/src/utils/hotkeys pausePlugin.js

38.46% Statements 5/13
0% Branches 0/1
25% Functions 1/4
38.46% Lines 5/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33                34x   34x                   34x         34x         34x    
/**
 * adds a pause and unpause method to Mousetrap
 * this allows you to enable or disable keyboard shortcuts
 * without having to reset Mousetrap and rebind everything
 *
 * https://github.com/ccampbell/mousetrap/blob/master/plugins/pause/mousetrap-pause.js
 */
export default function pausePlugin(Mousetrap) {
  var _originalStopCallback = Mousetrap.prototype.stopCallback;
 
  Mousetrap.prototype.stopCallback = function (e, element, combo) {
    var self = this;
 
    Iif (self.paused) {
      return true;
    }
 
    return _originalStopCallback.call(self, e, element, combo);
  };
 
  Mousetrap.prototype.pause = function () {
    var self = this;
    self.paused = true;
  };
 
  Mousetrap.prototype.unpause = function () {
    var self = this;
    self.paused = false;
  };
 
  Mousetrap.init();
}