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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aae813c8b10c951941e004958c93e2d6cb6400a3
4
- data.tar.gz: a16dab2b727685ac2837ee3d4502cc1a36f79d91
3
+ metadata.gz: 871ea8e0a86c7350a6ab703368a884b189d5c3d5
4
+ data.tar.gz: 2f694d869701219ebfd408095b55836cce848261
5
5
  SHA512:
6
- metadata.gz: b73adda66a7156965ff9f543f35e838435d2ffa106c2d5fe5f07cbca14669d21de9c8e3ccbd185c54fbab679d4fafc3921321d6fcdfd5b211cc3a3130b6fc836
7
- data.tar.gz: a675dce5d51b508a9cf62aee8eece95641307e308eb89e9f571759018c1e384b4ab8dc0687ece6477d204863b841f7cc5deb1a1bcdc16fe33f2ada5c69422aab
6
+ metadata.gz: 4223b6c2a2f274ff4e8005d5369c22a6f72112709e93f842e9acd6129e2023adc933ecb1764857c135ebb506a3524c3042d722f2a2626d700103fcb0aa3ea101
7
+ data.tar.gz: 21d15389d97ad2a24137e407a74240e3c16f554f6756bb7f6fc343fdb25be9e21f981a7942f86fc6214dee2cbefecc00002294148989916a49e56bdfe55cc2c6
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 John Naegle
1
+ Copyright (c) 2015 John Naegle
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Jquery::Visibility::Rails
2
2
 
3
- This gem packages the jQuery [Visiblity](https://github.com/mathiasbynens/jquery-visibility) plugin for easy use with the Rails 3.1+ asset pipleine.
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.7 by @mathias | MIT license */
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
- ? 'focusin focusout'
9
- : 'focus blur';
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()) != undefined) {
15
+ while ((prefix = prefixes.pop()) !== undefined) {
15
16
  property = (prefix ? prefix + 'H': 'h') + 'idden';
16
- if ($support.pageVisibility = typeof document[property] == 'boolean') {
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 == undefined &&
41
- originalEvent.fromElement == undefined &&
42
- originalEvent.relatedTarget == undefined
50
+ toElement === undefined &&
51
+ originalEvent.fromElement === undefined &&
52
+ originalEvent.relatedTarget === undefined
43
53
  )
44
54
  ) {
45
55
  $event.trigger(
46
- (
47
- property && document[property] || /^(?:blur|focusout)$/.test(type)
48
- ? 'hide'
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));
@@ -1,7 +1,7 @@
1
1
  module Jquery
2
2
  module Visibility
3
3
  module Rails
4
- VERSION = "1.0.7"
4
+ VERSION = "1.0.8"
5
5
  end
6
6
  end
7
7
  end
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.7
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: 2014-06-19 00:00:00.000000000 Z
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.0.3
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: