mousetrap-rails 0.0.10 → 0.0.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 510a6cd6f40ef2ba974a305bdf77d11292a13d3c
4
- data.tar.gz: 4e080a4551b296c562d79807d0fbe9a38ee43798
3
+ metadata.gz: 51c1d6cf86a69c1b00cd4fb2b6f0f078b780cee0
4
+ data.tar.gz: a1193c616141eb56dd86283e6307ab7d27576c17
5
5
  SHA512:
6
- metadata.gz: f7779a4ade4fb6ee4ad7871bb7bbd2eac1396fcb5282bf1225d5629f9b5a0d7513544ce1178c257f4d4662f4e760ea2b6dfffbdd9a352bb61fc48cc2fc8bce7c
7
- data.tar.gz: 988ed39f05e62f268ad3f88f47a2f5f6909951956cc6017b9a68fd5b715a43b2effed1f78fabb8308b1471aa4b0d03e8ec4c168a258279ad1f62370d0b0a9f62
6
+ metadata.gz: ab650c2ee1e6c05554c810cc1b68e0c3eee7f9964dc824bd05fb9bc6a380d093bd75607594046d69eccc535f78de4fd4cd1c0714c7e74b7afc9d8ebaa1cb2b4b
7
+ data.tar.gz: 6f7aede7bfd66c11b2818d2ad7fb9e2d4ab12611fdf91babd6b28ca97b4a55f7b14595066ed6aac76d4bc78286ba521e4b8a0aa2910e5d50edd60ae1f5e191cb
data/.travis.yml CHANGED
@@ -1,4 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
4
3
  - 1.9.2
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - ruby-head
7
+ - rbx-19mode
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## v0.0.12.wip
2
+
3
+ * [] Add moustrap extensions generator
4
+
5
+ ## v0.0.11
6
+
7
+ * add update mousetrap.js rake task
8
+ * update mousetrap.js to 1.4.4
9
+
1
10
  ## v0.0.10
2
11
 
3
12
  * update mousetrap.js to 1.4.1
data/README.md CHANGED
@@ -108,6 +108,12 @@ You can display key binding hints near links with `data-keybinding` attribute by
108
108
 
109
109
  Please submit all pull requests against latest `*.wip` branch. If your pull request contains new features, you **must** include relevant tests.
110
110
 
111
+ You can easily update mousetrap.js library via rake task.
112
+
113
+ ```bash
114
+ $ rake mousetrap:update
115
+ ```
116
+
111
117
  Thanks in advance!
112
118
 
113
119
 
data/Rakefile CHANGED
@@ -3,3 +3,15 @@ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
  task :default => :spec
6
+
7
+ namespace :mousetrap do
8
+ desc "Update Mousetrap javascript library from https://raw.github.com/ccampbell/mousetrap/master/mousetrap.js"
9
+ task :update do
10
+ ORIGIN_URL = "https://raw.github.com/ccampbell/mousetrap/master/mousetrap.js"
11
+ FILE_PATH = "vendor/assets/javascripts/mousetrap.js"
12
+ puts "Updating Mousetrap.js library from origin"
13
+ puts "#{ORIGIN_URL} -> #{FILE_PATH}\n\n"
14
+ system 'wget', ORIGIN_URL, "-O", FILE_PATH
15
+ puts "Mousetrap.js updated!"
16
+ end
17
+ end
@@ -2,16 +2,20 @@ module Mousetrap
2
2
 
3
3
  # Mousetrap rails generators module
4
4
  module Generators
5
+
6
+ # Install generator implementation
5
7
  class InstallGenerator < ::Rails::Generators::Base
6
8
  desc "Copy Mousetrap default files"
7
9
  source_root File.expand_path('../templates', __FILE__)
8
10
 
9
- # Copy keybindings scripts to assets folder
11
+ # Copy keybindings scripts to assets folder. This coffescript file
12
+ # provides unobtrusive way to use HTML5 data attributes for
13
+ # binding click and focus events to DOM elements.
10
14
  def copy_mousetrap
11
15
  copy_file "keybindings.js.coffee", "app/assets/javascripts/keybindings.js.coffee"
12
16
  end
13
17
 
14
- # Inject moustrap scripts to application.js
18
+ # Inject mousetrap scripts to manifest file `application.js`
15
19
  def add_javascript_assets
16
20
  if File.exist?('app/assets/javascripts/application.js')
17
21
  insert_into_file "app/assets/javascripts/application.js", "//= require mousetrap\n", :after => "jquery_ujs\n"
@@ -20,7 +24,7 @@ module Mousetrap
20
24
  end
21
25
  end
22
26
 
23
- # Inject moustrap styles to application.css
27
+ # Inject mousetrap styles to manifest file `application.css`
24
28
  def add_css_assets
25
29
  if File.exist?('app/assets/stylesheets/application.css')
26
30
  insert_into_file "app/assets/stylesheets/application.css", "*= require mousetrap\n ", :before => "*= require_tree ."
@@ -24,7 +24,7 @@ $ ->
24
24
  window.mouseTrapRails =
25
25
  showOnLoad: false # Show/hide hotkey hints by default (on page load). Mostly for debugging purposes.
26
26
  toggleKeys: 'alt+shift+h' # Keys combo to toggle hints visibility.
27
- keysShown: false
27
+ keysShown: false # State of hotkey hints
28
28
  toggleHints: ->
29
29
  $('a[data-keybinding]').each (i, el) ->
30
30
  $el = $(el)
@@ -1,5 +1,5 @@
1
1
  module Mousetrap
2
2
  module Rails
3
- VERSION = "0.0.10"
3
+ VERSION = "0.0.11"
4
4
  end
5
5
  end
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
19
 
20
- gem.signing_key = '/Users/nick/.ssh/gem-private_key.pem'
20
+ # gem.signing_key = '/Users/nick/.ssh/gem-private_key.pem'
21
21
  gem.cert_chain = ['gem-public_cert.pem']
22
22
 
23
23
  gem.add_development_dependency 'rails', '~> 3.2.12'
data/spec/spec_helper.rb CHANGED
@@ -24,12 +24,12 @@ RSpec.configure do |config|
24
24
  # config.mock_with :rr
25
25
 
26
26
  # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
27
- config.fixture_path = "#{::Rails.root}/spec/fixtures"
27
+ # config.fixture_path = "#{::Rails.root}/spec/fixtures"
28
28
 
29
29
  # If you're not using ActiveRecord, or you'd prefer not to run each of your
30
30
  # examples within a transaction, remove the following line or assign false
31
31
  # instead of true.
32
- config.use_transactional_fixtures = true
32
+ config.use_transactional_fixtures = false
33
33
 
34
34
  # If true, the base class of anonymous controllers will be inferred
35
35
  # automatically. This will be the default behavior in future versions of
@@ -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.4.1
20
+ * @version 1.4.4
21
21
  * @url craig.is/killing/mice
22
22
  */
23
23
  (function() {
@@ -174,6 +174,13 @@
174
174
  */
175
175
  _ignoreNextKeyup = false,
176
176
 
177
+ /**
178
+ * temporary state where we will ignore the next keypress
179
+ *
180
+ * @type {boolean}
181
+ */
182
+ _ignoreNextKeypress = false,
183
+
177
184
  /**
178
185
  * are we currently inside of a sequence?
179
186
  * type of action ("keyup" or "keydown" or "keypress") or false
@@ -239,6 +246,12 @@
239
246
  character = character.toLowerCase();
240
247
  }
241
248
 
249
+ // String.fromCharCode(32) for spacebar returns " " for the
250
+ // character name, make sure it matches the mousetrap name
251
+ if (character == ' ') {
252
+ return 'space';
253
+ }
254
+
242
255
  return character;
243
256
  }
244
257
 
@@ -496,9 +509,22 @@
496
509
  // modifier keys are ignored because you can have a sequence
497
510
  // that contains modifiers such as "enter ctrl+space" and in most
498
511
  // cases the modifier key will be pressed before the next key
499
- if (e.type == _nextExpectedAction && !_isModifier(character)) {
512
+ //
513
+ // also if you have a sequence such as "ctrl+b a" then pressing the
514
+ // "b" key will trigger a "keypress" and a "keydown"
515
+ //
516
+ // the "keydown" is expected when there is a modifier, but the
517
+ // "keypress" ends up matching the _nextExpectedAction since it occurs
518
+ // after and that causes the sequence to reset
519
+ //
520
+ // we ignore keypresses in a sequence that directly follow a keydown
521
+ // for the same character
522
+ var ignoreThisKeypress = e.type == 'keypress' && _ignoreNextKeypress;
523
+ if (e.type == _nextExpectedAction && !_isModifier(character) && !ignoreThisKeypress) {
500
524
  _resetSequences(doNotReset);
501
525
  }
526
+
527
+ _ignoreNextKeypress = processedSequenceCallback && e.type == 'keydown';
502
528
  }
503
529
 
504
530
  /**
@@ -522,7 +548,8 @@
522
548
  return;
523
549
  }
524
550
 
525
- if (e.type == 'keyup' && _ignoreNextKeyup == character) {
551
+ // need to use === for the character check because the character can be 0
552
+ if (e.type == 'keyup' && _ignoreNextKeyup === character) {
526
553
  _ignoreNextKeyup = false;
527
554
  return;
528
555
  }
metadata CHANGED
@@ -1,35 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mousetrap-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Kugaevsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
- - |
12
- -----BEGIN CERTIFICATE-----
13
- MIIDMDCCAhigAwIBAgIBADANBgkqhkiG9w0BAQUFADA+MQ0wCwYDVQQDDARuaWNr
14
- MRkwFwYKCZImiZPyLGQBGRYJa3VnYWV2c2t5MRIwEAYKCZImiZPyLGQBGRYCcnUw
15
- HhcNMTMwMTMxMTgxMjMwWhcNMTQwMTMxMTgxMjMwWjA+MQ0wCwYDVQQDDARuaWNr
16
- MRkwFwYKCZImiZPyLGQBGRYJa3VnYWV2c2t5MRIwEAYKCZImiZPyLGQBGRYCcnUw
17
- ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC3SS01rsI5N3EUG3bSnfI2
18
- pr4Exx9gKCBS5IxV7Ot+pQ2psIiWoenaS4fS2fsmvle92ClEx3NbUqnxxGDES0Eb
19
- FkNHyAH9VwO36vS0loNv/Ox2sSaleUNV3JdvcP1Gm3xGtn9KWNcpuAwPfMl5BSYg
20
- K4WU8zIkbLlwmrO6h85IYZrDwqghb6OCOwhb56d4byjoJE25brUxETxGVdsuVCDr
21
- EQroS+D2BiMAEdwJcn/PepMx3lt+teZrjUoei5UXIcnZ28UYSnmXjXnkySlPXzRV
22
- siLwUMAgGu665huUE5S8idW7ohSHTJv/kH98BoiWi7gi9HFMz4OJMMeR5rZk76Ql
23
- AgMBAAGjOTA3MAkGA1UdEwQCMAAwHQYDVR0OBBYEFCdIKkB9lZ+com0wLBhLQDWe
24
- YnbvMAsGA1UdDwQEAwIEsDANBgkqhkiG9w0BAQUFAAOCAQEANOubFddpzMXJflPv
25
- vXXnWXYvZK2etSxzwewXXOhcbzwSxdU0T4NbKcrlhlFbjUDh/xF4Qzc1dB9OFG9r
26
- ffIUKv0JtEyGM/mOaISsNp+oYUlXxXLNOsX8LT1r+337tQ627GoX/Z0RL5u8Mz6Q
27
- KZUJhGQKNnIp6Rkz6sp4Zh2aqTLt8BDEA86kO+0v4LaVLqFEmLTypf7C568RTYlm
28
- N8LaREQMM5YdvCIYWs5C6iNRVaDhT8bkuWNhtBis0H7YFAfsW1rn9np8OQ7nY2az
29
- 8dNQrBlKzc/RLwGGFT1gjzVlIb7/xtNdMdJQ6JwyljSJ70PbKAAzgBRdDLPt9BWt
30
- 3AH9mw==
31
- -----END CERTIFICATE-----
32
- date: 2013-06-02 00:00:00.000000000 Z
11
+ - gem-public_cert.pem
12
+ date: 2013-07-08 00:00:00.000000000 Z
33
13
  dependencies:
34
14
  - !ruby/object:Gem::Dependency
35
15
  name: rails
checksums.yaml.gz.sig DELETED
@@ -1,3 +0,0 @@
1
- ��)
2
- ���� �i�y
3
- ���I�Y���D�Ub�A�s���=����?R+V='\B��wakp;��򊖯#���K������pS���V�W���� �$��얡�1M?]qگ��J�F8 �S�Zg�F�d�أ��^ >H's\d5#Ova�i<oә�jl_��>��%U�0Z�e�軸���縿/��#��tu�.ۦrn����2y=��/�BF�/dB���J��:YO�<lw� 2�:h?w5��-�-[�
data.tar.gz.sig DELETED
Binary file
metadata.gz.sig DELETED
Binary file