mousetrap-rails 0.0.7 → 0.0.8
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.
- data/CHANGELOG.md +7 -0
- data/README.md +1 -1
- data/lib/mousetrap-rails/version.rb +1 -1
- data/mousetrap-rails.gemspec +1 -1
- data/vendor/assets/javascripts/mousetrap.js +14 -9
- metadata +6 -6
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Mousetrap::Rails [](http://coderwall.com/kugaevsky) [](
|
1
|
+
# Mousetrap::Rails [](http://coderwall.com/kugaevsky) [](https://travis-ci.org/kugaevsky/mousetrap-rails) [](https://gemnasium.com/kugaevsky/mousetrap-rails) [](https://codeclimate.com/github/kugaevsky/mousetrap-rails)
|
2
2
|
|
3
3
|
[Mousetrap](https://github.com/ccampbell/mousetrap) is a javascript library for handling keyboard shortcuts in your web applications written by [Craig Campbell](http://craig.is/).
|
4
4
|
|
data/mousetrap-rails.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
|
|
19
19
|
|
20
20
|
gem.add_development_dependency 'rails', '~> 3.2.1'
|
21
21
|
gem.add_development_dependency 'sqlite3', '~> 1.3.5'
|
22
|
-
gem.add_development_dependency 'rspec-rails', '~> 2.
|
22
|
+
gem.add_development_dependency 'rspec-rails', '~> 2.12.0'
|
23
23
|
gem.add_development_dependency 'genspec', '~> 0.2.7'
|
24
24
|
gem.add_development_dependency 'sass', '~> 3.2.1'
|
25
25
|
|
@@ -16,7 +16,7 @@
|
|
16
16
|
* Mousetrap is a simple keyboard shortcut library for Javascript with
|
17
17
|
* no external dependencies
|
18
18
|
*
|
19
|
-
* @version 1.2.
|
19
|
+
* @version 1.2.2
|
20
20
|
* @url craig.is/killing/mice
|
21
21
|
*/
|
22
22
|
(function() {
|
@@ -178,7 +178,7 @@
|
|
178
178
|
*
|
179
179
|
* @type {boolean|string}
|
180
180
|
*/
|
181
|
-
|
181
|
+
_sequence_type = false;
|
182
182
|
|
183
183
|
/**
|
184
184
|
* loop through the f keys, f1 to f19 and add them to the map
|
@@ -255,14 +255,14 @@
|
|
255
255
|
* @param {Object} do_not_reset
|
256
256
|
* @returns void
|
257
257
|
*/
|
258
|
-
function _resetSequences(do_not_reset) {
|
258
|
+
function _resetSequences(do_not_reset, max_level) {
|
259
259
|
do_not_reset = do_not_reset || {};
|
260
260
|
|
261
261
|
var active_sequences = false,
|
262
262
|
key;
|
263
263
|
|
264
264
|
for (key in _sequence_levels) {
|
265
|
-
if (do_not_reset[key]) {
|
265
|
+
if (do_not_reset[key] && _sequence_levels[key] > max_level) {
|
266
266
|
active_sequences = true;
|
267
267
|
continue;
|
268
268
|
}
|
@@ -270,7 +270,7 @@
|
|
270
270
|
}
|
271
271
|
|
272
272
|
if (!active_sequences) {
|
273
|
-
|
273
|
+
_sequence_type = false;
|
274
274
|
}
|
275
275
|
}
|
276
276
|
|
@@ -410,6 +410,7 @@
|
|
410
410
|
var callbacks = _getMatches(character, _eventModifiers(e), e),
|
411
411
|
i,
|
412
412
|
do_not_reset = {},
|
413
|
+
max_level = 0,
|
413
414
|
processed_sequence_callback = false;
|
414
415
|
|
415
416
|
// loop through matching callbacks for this key event
|
@@ -423,6 +424,10 @@
|
|
423
424
|
if (callbacks[i].seq) {
|
424
425
|
processed_sequence_callback = true;
|
425
426
|
|
427
|
+
// as we loop through keep track of the max
|
428
|
+
// any sequence at a lower level will be discarded
|
429
|
+
max_level = Math.max(max_level, callbacks[i].level);
|
430
|
+
|
426
431
|
// keep a list of which sequences were matches for later
|
427
432
|
do_not_reset[callbacks[i].seq] = 1;
|
428
433
|
_fireCallback(callbacks[i].callback, e, callbacks[i].combo);
|
@@ -431,7 +436,7 @@
|
|
431
436
|
|
432
437
|
// if there were no sequence matches but we are still here
|
433
438
|
// that means this is a regular match so we should fire that
|
434
|
-
if (!processed_sequence_callback && !
|
439
|
+
if (!processed_sequence_callback && !_sequence_type) {
|
435
440
|
_fireCallback(callbacks[i].callback, e, callbacks[i].combo);
|
436
441
|
}
|
437
442
|
}
|
@@ -439,8 +444,8 @@
|
|
439
444
|
// if you are inside of a sequence and the key you are pressing
|
440
445
|
// is not a modifier key then we should reset all sequences
|
441
446
|
// that were not matched by this key event
|
442
|
-
if (e.type ==
|
443
|
-
_resetSequences(do_not_reset);
|
447
|
+
if (e.type == _sequence_type && !_isModifier(character)) {
|
448
|
+
_resetSequences(do_not_reset, max_level);
|
444
449
|
}
|
445
450
|
}
|
446
451
|
|
@@ -574,7 +579,7 @@
|
|
574
579
|
* @returns void
|
575
580
|
*/
|
576
581
|
var _increaseSequence = function(e) {
|
577
|
-
|
582
|
+
_sequence_type = action;
|
578
583
|
++_sequence_levels[combo];
|
579
584
|
_resetSequenceTimer();
|
580
585
|
},
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mousetrap-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - ~>
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 2.
|
53
|
+
version: 2.12.0
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.
|
61
|
+
version: 2.12.0
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: genspec
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -175,7 +175,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
175
175
|
version: '0'
|
176
176
|
segments:
|
177
177
|
- 0
|
178
|
-
hash: -
|
178
|
+
hash: -3047934806921062666
|
179
179
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
180
180
|
none: false
|
181
181
|
requirements:
|
@@ -184,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
184
|
version: '0'
|
185
185
|
segments:
|
186
186
|
- 0
|
187
|
-
hash: -
|
187
|
+
hash: -3047934806921062666
|
188
188
|
requirements: []
|
189
189
|
rubyforge_project:
|
190
190
|
rubygems_version: 1.8.24
|