jquery-visibility-rails 1.0.7 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +19 -1
- data/app/assets/javascripts/jquery-visibility.js +24 -14
- data/lib/jquery/visibility/rails/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 871ea8e0a86c7350a6ab703368a884b189d5c3d5
|
4
|
+
data.tar.gz: 2f694d869701219ebfd408095b55836cce848261
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4223b6c2a2f274ff4e8005d5369c22a6f72112709e93f842e9acd6129e2023adc933ecb1764857c135ebb506a3524c3042d722f2a2626d700103fcb0aa3ea101
|
7
|
+
data.tar.gz: 21d15389d97ad2a24137e407a74240e3c16f554f6756bb7f6fc343fdb25be9e21f981a7942f86fc6214dee2cbefecc00002294148989916a49e56bdfe55cc2c6
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Jquery::Visibility::Rails
|
2
2
|
|
3
|
-
This gem packages the jQuery
|
3
|
+
This gem packages the [jQuery Visiblity](https://github.com/mathiasbynens/jquery-visibility) plugin for easy use with the Rails 3.1+ asset pipleine.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -18,6 +18,24 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
+
Add this to your application.js.erb
|
22
|
+
|
23
|
+
//= require jquery-visibility
|
24
|
+
|
25
|
+
Add event handlers for the page becoming visible or hidden:
|
26
|
+
|
27
|
+
$(function() {
|
28
|
+
$(document).on({
|
29
|
+
'show.visibility': function() {
|
30
|
+
console.log('The page gained visibility');
|
31
|
+
},
|
32
|
+
'hide.visibility': function() {
|
33
|
+
console.log('The page lost visibility');
|
34
|
+
}
|
35
|
+
});
|
36
|
+
});
|
37
|
+
|
38
|
+
|
21
39
|
|
22
40
|
## Contributing
|
23
41
|
|
@@ -1,24 +1,34 @@
|
|
1
|
-
/*! http://mths.be/visibility v1.0.
|
1
|
+
/*! http://mths.be/visibility v1.0.8 by @mathias | MIT license */
|
2
2
|
;(function(window, document, $, undefined) {
|
3
|
+
"use strict";
|
3
4
|
|
4
5
|
var prefix;
|
5
6
|
var property;
|
6
7
|
// In Opera, `'onfocusin' in document == true`, hence the extra `hasFocus` check to detect IE-like behavior
|
7
|
-
var eventName = 'onfocusin' in document && 'hasFocus' in document
|
8
|
-
|
9
|
-
|
8
|
+
var eventName = 'onfocusin' in document && 'hasFocus' in document ?
|
9
|
+
'focusin focusout' :
|
10
|
+
'focus blur';
|
10
11
|
var prefixes = ['webkit', 'o', 'ms', 'moz', ''];
|
11
12
|
var $support = $.support;
|
12
13
|
var $event = $.event;
|
13
14
|
|
14
|
-
while ((prefix = prefixes.pop())
|
15
|
+
while ((prefix = prefixes.pop()) !== undefined) {
|
15
16
|
property = (prefix ? prefix + 'H': 'h') + 'idden';
|
16
|
-
|
17
|
+
$support.pageVisibility = document[property] !== undefined;
|
18
|
+
if ($support.pageVisibility) {
|
17
19
|
eventName = prefix + 'visibilitychange';
|
18
20
|
break;
|
19
21
|
}
|
20
22
|
}
|
21
23
|
|
24
|
+
// normalize to and update document hidden property
|
25
|
+
function updateState() {
|
26
|
+
if (property !== 'hidden') {
|
27
|
+
document.hidden = $support.pageVisibility ? document[property] : undefined;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
updateState();
|
31
|
+
|
22
32
|
$(/blur$/.test(eventName) ? window : document).on(eventName, function(event) {
|
23
33
|
var type = event.type;
|
24
34
|
var originalEvent = event.originalEvent;
|
@@ -37,19 +47,19 @@
|
|
37
47
|
// to check the `relatedTarget` property instead.
|
38
48
|
if (
|
39
49
|
!/^focus./.test(type) || (
|
40
|
-
toElement
|
41
|
-
originalEvent.fromElement
|
42
|
-
originalEvent.relatedTarget
|
50
|
+
toElement === undefined &&
|
51
|
+
originalEvent.fromElement === undefined &&
|
52
|
+
originalEvent.relatedTarget === undefined
|
43
53
|
)
|
44
54
|
) {
|
45
55
|
$event.trigger(
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
: 'show'
|
50
|
-
) + '.visibility'
|
56
|
+
property && document[property] || /^(?:blur|focusout)$/.test(type) ?
|
57
|
+
'hide' :
|
58
|
+
'show'
|
51
59
|
);
|
52
60
|
}
|
61
|
+
// and update the current state
|
62
|
+
updateState();
|
53
63
|
});
|
54
64
|
|
55
65
|
}(this, document, jQuery));
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jquery-visibility-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Naegle
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -74,9 +74,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
74
|
version: '0'
|
75
75
|
requirements: []
|
76
76
|
rubyforge_project:
|
77
|
-
rubygems_version: 2.
|
77
|
+
rubygems_version: 2.4.5
|
78
78
|
signing_key:
|
79
79
|
specification_version: 4
|
80
80
|
summary: Provides the jquery-visiblity library
|
81
81
|
test_files: []
|
82
|
-
has_rdoc:
|