mousetrapjs 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +30 -0
- data/Rakefile +1 -0
- data/lib/mousetrapjs/version.rb +3 -0
- data/lib/mousetrapjs.rb +6 -0
- data/mousetrapjs.gemspec +17 -0
- data/vendor/assets/javascripts/mousetrap.js +7 -0
- metadata +54 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Luiz Eduardo Kowalski
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# MousetrapJS
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
gem 'mousetrapjs'
|
8
|
+
|
9
|
+
And then execute:
|
10
|
+
|
11
|
+
$ bundle
|
12
|
+
|
13
|
+
Or install it yourself as:
|
14
|
+
|
15
|
+
$ gem install mousetrapjs
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
You know
|
20
|
+
```
|
21
|
+
//= require mousetrap
|
22
|
+
```
|
23
|
+
|
24
|
+
## Contributing
|
25
|
+
|
26
|
+
1. Fork it
|
27
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
28
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
29
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
30
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'rake'
|
data/lib/mousetrapjs.rb
ADDED
data/mousetrapjs.gemspec
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/mousetrapjs/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Luiz Eduardo Kowalski"]
|
6
|
+
gem.email = ["luizeduardokowalski@gmail.com"]
|
7
|
+
gem.description = %q{Gem for mousetrap js lib}
|
8
|
+
gem.summary = %q{Gem for mousetrap js lib}
|
9
|
+
gem.homepage = "http://facebook.com/luizkowalski"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "mousetrapjs"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Mousetrapjs::VERSION
|
17
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/* mousetrap v1.1 craig.is/killing/mice */
|
2
|
+
window.Mousetrap=function(){function m(a,e,b){if(a.addEventListener)return a.addEventListener(e,b,!1);a.attachEvent("on"+e,b)}function s(a){return"keypress"!=a.type&&h[a.which]?h[a.which]:"keypress"==a.type?String.fromCharCode(a.which):String.fromCharCode(a.which).toLowerCase()}function n(a){var a=a||{},e=!1,b;for(b in i)a[b]?e=!0:i[b]=0;e||(k=!1)}function t(a,e,b,c,z){var g,d,f=[];if(!j[a])return[];"keyup"==b&&o(a)&&(e=[a]);for(g=0;g<j[a].length;++g)if(d=j[a][g],!(d.seq&&i[d.seq]!=d.level)&&b==d.action&&
|
3
|
+
("keypress"===b||e.sort().join(",")===d.modifiers.sort().join(",")))c&&d.combo==z&&j[a].splice(g,1),f.push(d);return f}function p(a){a.which="number"==typeof a.which?a.which:a.keyCode;var e=s(a);if(e)if("keyup"===a.type&&q===e)q=!1;else{var b=a.target||a.srcElement,c=b.tagName;if(!(-1<(" "+b.className+" ").indexOf(" mousetrap ")?0:"INPUT"==c||"SELECT"==c||"TEXTAREA"==c)){b=[];a.shiftKey&&b.push("shift");a.altKey&&b.push("alt");a.ctrlKey&&b.push("ctrl");a.metaKey&&b.push("meta");for(var b=t(e,b,a.type),
|
4
|
+
f={},g=!1,c=0;c<b.length;++c)b[c].seq?(g=!0,f[b[c].seq]=1,b[c].callback(a)):!g&&!k&&b[c].callback(a);a.type==k&&!o(e)&&n(f)}}}function o(a){return"shift"==a||"ctrl"==a||"alt"==a||"meta"==a}function u(a,e,b){if(!b){if(!l){l={};for(var c in h)95<c&&112>c||h.hasOwnProperty(c)&&(l[h[c]]=c)}b=l[a]?"keydown":"keypress"}"keypress"===b&&e.length&&(b="keydown");return b}function A(a,e,b,c){i[a]=0;c||(c=u(e[0],[]));var f=function(){k=c;++i[a];clearTimeout(v);v=setTimeout(n,1E3)},g=function(a){b(a);"keyup"!==
|
5
|
+
c&&(q=s(a));setTimeout(n,10)},d;for(d=0;d<e.length;++d)w(e[d],d<e.length-1?f:g,c,a,d)}function w(a,e,b,c,f){var a=a.replace(/\s+/g," "),g=a.split(" "),d,h,i=[];if(1<g.length)return A(a,g,e,b);h="+"===a?["+"]:a.split("+");for(g=0;g<h.length;++g)d=h[g],x[d]&&(d=x[d]),b&&("keypress"!=b&&y[d])&&(d=y[d],i.push("shift")),o(d)&&i.push(d);b=u(d,i,b);j[d]||(j[d]=[]);t(d,i,b,!c,a);j[d][c?"unshift":"push"]({callback:e,modifiers:i,action:b,seq:c,level:f,combo:a})}for(var h={8:"backspace",9:"tab",13:"enter",16:"shift",
|
6
|
+
17:"ctrl",18:"alt",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",46:"del",91:"meta",93:"meta",224:"meta",106:"*",107:"+",109:"-",110:".",111:"/",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},y={"~":"`","!":"1","@":"2","#":"3",$:"4","%":"5","^":"6","&":"7","*":"8","(":"9",")":"0",_:"-","+":"=",":":";",'"':"'","<":",",">":".","?":"/","|":"\\"},x={option:"alt",command:"meta","return":"enter",
|
7
|
+
escape:"esc"},l,j={},r={},i={},v,q=!1,k=!1,f=1;20>f;++f)h[111+f]="f"+f;for(f=96;106>f;++f)h[f]=f-96;m(document,"keydown",p);m(document,"keyup",p);m(document,"keypress",p);return{bind:function(a,e,b){for(var c=a instanceof Array?a:[a],f=0;f<c.length;++f)w(c[f],e,b);r[a+":"+b]=e},trigger:function(a,e){r[a+":"+e]()},reset:function(){j={};r={}}}}();
|
metadata
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mousetrapjs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Luiz Eduardo Kowalski
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-07-09 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Gem for mousetrap js lib
|
15
|
+
email:
|
16
|
+
- luizeduardokowalski@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- Gemfile
|
23
|
+
- LICENSE
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- lib/mousetrapjs.rb
|
27
|
+
- lib/mousetrapjs/version.rb
|
28
|
+
- mousetrapjs.gemspec
|
29
|
+
- vendor/assets/javascripts/mousetrap.js
|
30
|
+
homepage: http://facebook.com/luizkowalski
|
31
|
+
licenses: []
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
require_paths:
|
35
|
+
- lib
|
36
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ! '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
requirements: []
|
49
|
+
rubyforge_project:
|
50
|
+
rubygems_version: 1.8.23
|
51
|
+
signing_key:
|
52
|
+
specification_version: 3
|
53
|
+
summary: Gem for mousetrap js lib
|
54
|
+
test_files: []
|