Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/mousetrap/plugins/pause/mousetrap-pause.js')
-rw-r--r--node_modules/mousetrap/plugins/pause/mousetrap-pause.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/node_modules/mousetrap/plugins/pause/mousetrap-pause.js b/node_modules/mousetrap/plugins/pause/mousetrap-pause.js
new file mode 100644
index 0000000000..0138b8a85d
--- /dev/null
+++ b/node_modules/mousetrap/plugins/pause/mousetrap-pause.js
@@ -0,0 +1,31 @@
+/**
+ * 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
+ */
+/* global Mousetrap:true */
+(function(Mousetrap) {
+ var _originalStopCallback = Mousetrap.prototype.stopCallback;
+
+ Mousetrap.prototype.stopCallback = function(e, element, combo) {
+ var self = this;
+
+ if (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();
+}) (Mousetrap);