jquery-hoverIntent-rails 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,27 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+
19
+ # OS generated files #
20
+ ######################
21
+ .DS_Store
22
+ .DS_Store?
23
+ ._*
24
+ .Spotlight-V100
25
+ .Trashes
26
+ ehthumbs.db
27
+ Thumbs.db
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jquery-hoverIntent-rails.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Alrick Deillon
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,33 @@
1
+ # Jquery::HoverIntent::Rails
2
+
3
+ hoverIntent is a plugin that attempts to determine the user's intent... like a crystal ball, only with mouse movement! It is similar to jQuery's hover method. However, instead of calling the handlerIn function immediately, hoverIntent waits until the user's mouse slows down enough before making the call.
4
+
5
+ Why? To delay or prevent the accidental firing of animations or ajax calls. Simple timeouts work for small areas, but if your target area is large it may execute regardless of intent. That's where hoverIntent comes in...
6
+
7
+ More infos : https://github.com/briancherne/jquery-hoverIntent
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'jquery-hoverIntent-rails'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install jquery-hoverIntent-rails
22
+
23
+ ## Usage
24
+
25
+ https://github.com/briancherne/jquery-hoverIntent
26
+
27
+ ## Contributing
28
+
29
+ 1. Fork it
30
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
31
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
32
+ 4. Push to the branch (`git push origin my-new-feature`)
33
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/jquery-hoverIntent-rails/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Alrick Deillon"]
6
+ gem.email = ["alrick.deillon@gmail.com"]
7
+ gem.description = %q{A wrapper for jquery hoverIntent plugin}
8
+ gem.summary = %q{Jquery Hover improved}
9
+ gem.homepage = "https://github.com/curlyb/jquery-hoverIntent-rails"
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 = "jquery-hoverIntent-rails"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Jquery::HoverIntent::Rails::VERSION
17
+ end
@@ -0,0 +1,9 @@
1
+ require "jquery-hoverIntent-rails/version"
2
+
3
+ module Jquery
4
+ module HoverIntent
5
+ module Rails
6
+ class Engine < ::Rails::Engine
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ module Jquery
2
+ module HoverIntent
3
+ module Rails
4
+ VERSION = "0.0.8"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,115 @@
1
+ /*!
2
+ * hoverIntent r7 // 2013.03.11 // jQuery 1.9.1+
3
+ * http://cherne.net/brian/resources/jquery.hoverIntent.html
4
+ *
5
+ * You may use hoverIntent under the terms of the MIT license. Basically that
6
+ * means you are free to use hoverIntent as long as this header is left intact.
7
+ * Copyright 2007, 2013 Brian Cherne
8
+ */
9
+
10
+ /* hoverIntent is similar to jQuery's built-in "hover" method except that
11
+ * instead of firing the handlerIn function immediately, hoverIntent checks
12
+ * to see if the user's mouse has slowed down (beneath the sensitivity
13
+ * threshold) before firing the event. The handlerOut function is only
14
+ * called after a matching handlerIn.
15
+ *
16
+ * // basic usage ... just like .hover()
17
+ * .hoverIntent( handlerIn, handlerOut )
18
+ * .hoverIntent( handlerInOut )
19
+ *
20
+ * // basic usage ... with event delegation!
21
+ * .hoverIntent( handlerIn, handlerOut, selector )
22
+ * .hoverIntent( handlerInOut, selector )
23
+ *
24
+ * // using a basic configuration object
25
+ * .hoverIntent( config )
26
+ *
27
+ * @param handlerIn function OR configuration object
28
+ * @param handlerOut function OR selector for delegation OR undefined
29
+ * @param selector selector OR undefined
30
+ * @author Brian Cherne <brian(at)cherne(dot)net>
31
+ */
32
+ (function($) {
33
+ $.fn.hoverIntent = function(handlerIn,handlerOut,selector) {
34
+
35
+ // default configuration values
36
+ var cfg = {
37
+ interval: 100,
38
+ sensitivity: 7,
39
+ timeout: 0
40
+ };
41
+
42
+ if ( typeof handlerIn === "object" ) {
43
+ cfg = $.extend(cfg, handlerIn );
44
+ } else if ($.isFunction(handlerOut)) {
45
+ cfg = $.extend(cfg, { over: handlerIn, out: handlerOut, selector: selector } );
46
+ } else {
47
+ cfg = $.extend(cfg, { over: handlerIn, out: handlerIn, selector: handlerOut } );
48
+ }
49
+
50
+ // instantiate variables
51
+ // cX, cY = current X and Y position of mouse, updated by mousemove event
52
+ // pX, pY = previous X and Y position of mouse, set by mouseover and polling interval
53
+ var cX, cY, pX, pY;
54
+
55
+ // A private function for getting mouse position
56
+ var track = function(ev) {
57
+ cX = ev.pageX;
58
+ cY = ev.pageY;
59
+ };
60
+
61
+ // A private function for comparing current and previous mouse position
62
+ var compare = function(ev,ob) {
63
+ ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
64
+ // compare mouse positions to see if they've crossed the threshold
65
+ if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) {
66
+ $(ob).off("mousemove.hoverIntent",track);
67
+ // set hoverIntent state to true (so mouseOut can be called)
68
+ ob.hoverIntent_s = 1;
69
+ return cfg.over.apply(ob,[ev]);
70
+ } else {
71
+ // set previous coordinates for next time
72
+ pX = cX; pY = cY;
73
+ // use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
74
+ ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval );
75
+ }
76
+ };
77
+
78
+ // A private function for delaying the mouseOut function
79
+ var delay = function(ev,ob) {
80
+ ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
81
+ ob.hoverIntent_s = 0;
82
+ return cfg.out.apply(ob,[ev]);
83
+ };
84
+
85
+ // A private function for handling mouse 'hovering'
86
+ var handleHover = function(e) {
87
+ // copy objects to be passed into t (required for event object to be passed in IE)
88
+ var ev = jQuery.extend({},e);
89
+ var ob = this;
90
+
91
+ // cancel hoverIntent timer if it exists
92
+ if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); }
93
+
94
+ // if e.type == "mouseenter"
95
+ if (e.type == "mouseenter") {
96
+ // set "previous" X and Y position based on initial entry point
97
+ pX = ev.pageX; pY = ev.pageY;
98
+ // update "current" X and Y position based on mousemove
99
+ $(ob).on("mousemove.hoverIntent",track);
100
+ // start polling interval (self-calling timeout) to compare mouse coordinates over time
101
+ if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );}
102
+
103
+ // else e.type == "mouseleave"
104
+ } else {
105
+ // unbind expensive mousemove event
106
+ $(ob).off("mousemove.hoverIntent",track);
107
+ // if hoverIntent state is true, then call the mouseOut function after the specified delay
108
+ if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );}
109
+ }
110
+ };
111
+
112
+ // listen for mouseenter and mouseleave
113
+ return this.on({'mouseenter.hoverIntent':handleHover,'mouseleave.hoverIntent':handleHover}, cfg.selector);
114
+ };
115
+ })(jQuery);
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jquery-hoverIntent-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.8
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Alrick Deillon
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-07-18 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: A wrapper for jquery hoverIntent plugin
15
+ email:
16
+ - alrick.deillon@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - LICENSE
24
+ - README.md
25
+ - Rakefile
26
+ - jquery-hoverIntent-rails.gemspec
27
+ - lib/jquery-hoverIntent-rails.rb
28
+ - lib/jquery-hoverIntent-rails/version.rb
29
+ - vendor/assets/javascripts/jquery.hoverIntent.js
30
+ homepage: https://github.com/curlyb/jquery-hoverIntent-rails
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.24
51
+ signing_key:
52
+ specification_version: 3
53
+ summary: Jquery Hover improved
54
+ test_files: []
55
+ has_rdoc: