mousetrapjs 0.1.3.2 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/mousetrapjs/version.rb +1 -1
- data/vendor/assets/javascripts/mousetrap.js +38 -13
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e244036ef071e3d6222f608a02a948661138a11
|
4
|
+
data.tar.gz: a1ca76a8c83b8df9cce0ab86d3538591dd4c5e56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d09f19f0fbb6d71efc1cfe9a324bec24a7ece344d05f948770fb19c1b370deaab8899cf257595dbdde6161ae560546b3b602ef2a7f884ded80eda41a0b914da9
|
7
|
+
data.tar.gz: 117a6788596f94ab0513fbfb12a61699abd52ddf62acf5189d0f59cd38ee5fec6e99edd79b5de8b05b1d106faff6f40b493dc88f01584dc76cf38042e7597706
|
data/lib/mousetrapjs/version.rb
CHANGED
@@ -17,7 +17,7 @@
|
|
17
17
|
* Mousetrap is a simple keyboard shortcut library for Javascript with
|
18
18
|
* no external dependencies
|
19
19
|
*
|
20
|
-
* @version 1.
|
20
|
+
* @version 1.4.0
|
21
21
|
* @url craig.is/killing/mice
|
22
22
|
*/
|
23
23
|
(function() {
|
@@ -125,7 +125,8 @@
|
|
125
125
|
'option': 'alt',
|
126
126
|
'command': 'meta',
|
127
127
|
'return': 'enter',
|
128
|
-
'escape': 'esc'
|
128
|
+
'escape': 'esc',
|
129
|
+
'mod': /Mac|iPod|iPhone|iPad/.test(navigator.platform) ? 'meta' : 'ctrl'
|
129
130
|
},
|
130
131
|
|
131
132
|
/**
|
@@ -275,14 +276,14 @@
|
|
275
276
|
* @param {Object} doNotReset
|
276
277
|
* @returns void
|
277
278
|
*/
|
278
|
-
function _resetSequences(doNotReset
|
279
|
+
function _resetSequences(doNotReset) {
|
279
280
|
doNotReset = doNotReset || {};
|
280
281
|
|
281
282
|
var activeSequences = false,
|
282
283
|
key;
|
283
284
|
|
284
285
|
for (key in _sequenceLevels) {
|
285
|
-
if (doNotReset[key]
|
286
|
+
if (doNotReset[key]) {
|
286
287
|
activeSequences = true;
|
287
288
|
continue;
|
288
289
|
}
|
@@ -434,6 +435,13 @@
|
|
434
435
|
maxLevel = 0,
|
435
436
|
processedSequenceCallback = false;
|
436
437
|
|
438
|
+
// Calculate the maxLevel for sequences so we can only execute the longest callback sequence
|
439
|
+
for (i = 0; i < callbacks.length; ++i) {
|
440
|
+
if (callbacks[i].seq) {
|
441
|
+
maxLevel = Math.max(maxLevel, callbacks[i].level);
|
442
|
+
}
|
443
|
+
}
|
444
|
+
|
437
445
|
// loop through matching callbacks for this key event
|
438
446
|
for (i = 0; i < callbacks.length; ++i) {
|
439
447
|
|
@@ -443,11 +451,20 @@
|
|
443
451
|
// callback for matching g cause otherwise you can only ever
|
444
452
|
// match the first one
|
445
453
|
if (callbacks[i].seq) {
|
446
|
-
processedSequenceCallback = true;
|
447
454
|
|
448
|
-
//
|
449
|
-
//
|
450
|
-
|
455
|
+
// only fire callbacks for the maxLevel to prevent
|
456
|
+
// subsequences from also firing
|
457
|
+
//
|
458
|
+
// for example 'a option b' should not cause 'option b' to fire
|
459
|
+
// even though 'option b' is part of the other sequence
|
460
|
+
//
|
461
|
+
// any sequences that do not match here will be discarded
|
462
|
+
// below by the _resetSequences call
|
463
|
+
if (callbacks[i].level != maxLevel) {
|
464
|
+
continue;
|
465
|
+
}
|
466
|
+
|
467
|
+
processedSequenceCallback = true;
|
451
468
|
|
452
469
|
// keep a list of which sequences were matches for later
|
453
470
|
doNotReset[callbacks[i].seq] = 1;
|
@@ -457,16 +474,24 @@
|
|
457
474
|
|
458
475
|
// if there were no sequence matches but we are still here
|
459
476
|
// that means this is a regular match so we should fire that
|
460
|
-
if (!processedSequenceCallback
|
477
|
+
if (!processedSequenceCallback) {
|
461
478
|
_fireCallback(callbacks[i].callback, e, callbacks[i].combo);
|
462
479
|
}
|
463
480
|
}
|
464
481
|
|
465
|
-
// if
|
466
|
-
//
|
467
|
-
// that were not matched by this
|
482
|
+
// if the key you pressed matches the type of sequence without
|
483
|
+
// being a modifier (ie "keyup" or "keypress") then we should
|
484
|
+
// reset all sequences that were not matched by this event
|
485
|
+
//
|
486
|
+
// this is so, for example, if you have the sequence "h a t" and you
|
487
|
+
// type "h e a r t" it does not match. in this case the "e" will
|
488
|
+
// cause the sequence to reset
|
489
|
+
//
|
490
|
+
// modifier keys are ignored because you can have a sequence
|
491
|
+
// that contains modifiers such as "enter ctrl+space" and in most
|
492
|
+
// cases the modifier key will be pressed before the next key
|
468
493
|
if (e.type == _sequenceType && !_isModifier(character)) {
|
469
|
-
_resetSequences(doNotReset
|
494
|
+
_resetSequences(doNotReset);
|
470
495
|
}
|
471
496
|
}
|
472
497
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mousetrapjs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luiz Eduardo Kowalski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Gem for Mousetrap, a simple library for handling keyboard shortcuts in
|
14
14
|
Javascript
|
@@ -46,7 +46,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
46
46
|
version: '0'
|
47
47
|
requirements: []
|
48
48
|
rubyforge_project:
|
49
|
-
rubygems_version: 2.0.
|
49
|
+
rubygems_version: 2.0.3
|
50
50
|
signing_key:
|
51
51
|
specification_version: 4
|
52
52
|
summary: Mousetrap is a simple library for handling keyboard shortcuts in Javascript
|