vendor/assets/javascripts/mousetrap.js in mousetrap-rails-0.0.12 vs vendor/assets/javascripts/mousetrap.js in mousetrap-rails-1.4.6
- old
+ new
@@ -15,11 +15,11 @@
* limitations under the License.
*
* 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) {
/**
@@ -401,37 +401,59 @@
return modifiers;
}
/**
+ * 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
* convention - prevent default and stop propogation on the event
*
* @param {Function} callback
* @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);
}
}
/**
* handles a character key event
@@ -479,10 +501,10 @@
processedSequenceCallback = true;
// 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;
}
// if there were no sequence matches but we are still here
// that means this is a regular match so we should fire that