Permalink
Browse files

Update mousetrap.js to 1.4.6

  • Loading branch information...
1 parent 8a6856c commit 5d82ff3b4fc339caabe0254b5f5c9019dd696509 @kugaevsky committed Nov 25, 2013
Showing with 36 additions and 14 deletions.
  1. +36 −14 vendor/assets/javascripts/mousetrap.js
@@ -17,7 +17,7 @@
* Mousetrap is a simple keyboard shortcut library for Javascript with
* no external dependencies
*
- * @version 1.4.5
+ * @version 1.4.6
* @url craig.is/killing/mice
*/
(function(window, document, undefined) {
@@ -403,6 +403,36 @@
}
/**
+ * prevents default for this event
+ *
+ * @param {Event} e
+ * @returns void
+ */
+ function _preventDefault(e) {
+ if (e.preventDefault) {
+ e.preventDefault();
+ return;
+ }
+
+ e.returnValue = false;
+ }
+
+ /**
+ * stops propogation for this event
+ *
+ * @param {Event} e
+ * @returns void
+ */
+ function _stopPropagation(e) {
+ if (e.stopPropagation) {
+ e.stopPropagation();
+ return;
+ }
+
+ e.cancelBubble = true;
+ }
+
+ /**
* actually calls the callback function
*
* if your callback function returns false this will use the jquery
@@ -412,24 +442,16 @@
* @param {Event} e
* @returns void
*/
- function _fireCallback(callback, e, combo) {
+ function _fireCallback(callback, e, combo, sequence) {
// if this event should not happen stop here
- if (Mousetrap.stopCallback(e, e.target || e.srcElement, combo)) {
+ if (Mousetrap.stopCallback(e, e.target || e.srcElement, combo, sequence)) {
return;
}
if (callback(e, combo) === false) {
- if (e.preventDefault) {
- e.preventDefault();
- }
-
- if (e.stopPropagation) {
- e.stopPropagation();
- }
-
- e.returnValue = false;
- e.cancelBubble = true;
+ _preventDefault(e);
+ _stopPropagation(e);
}
}
@@ -481,7 +503,7 @@
// keep a list of which sequences were matches for later
doNotReset[callbacks[i].seq] = 1;
- _fireCallback(callbacks[i].callback, e, callbacks[i].combo);
+ _fireCallback(callbacks[i].callback, e, callbacks[i].combo, callbacks[i].seq);
continue;
}

0 comments on commit 5d82ff3

Please sign in to comment.