add-to-homescreen-rails 2.0.5 → 2.0.6

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.
@@ -2,7 +2,7 @@ module Add
2
2
  module To
3
3
  module Homescreen
4
4
  module Rails
5
- VERSION = "2.0.5"
5
+ VERSION = "2.0.6"
6
6
  end
7
7
  end
8
8
  end
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Add to Homescreen v2.0.5 ~ Copyright (c) 2013 Matteo Spinelli, http://cubiq.org
2
+ * Add to Homescreen v2.0.6 ~ Copyright (c) 2013 Matteo Spinelli, http://cubiq.org
3
3
  * Released under MIT license, http://cubiq.org/license
4
4
  */
5
5
  var addToHome = (function (w) {
@@ -74,7 +74,6 @@ var addToHome = (function (w) {
74
74
  if ( !isIDevice ) return;
75
75
 
76
76
  var now = Date.now(),
77
- title,
78
77
  i;
79
78
 
80
79
  // Merge local with global options
@@ -90,7 +89,7 @@ var addToHome = (function (w) {
90
89
  isSafari = (/Safari/i).test(nav.appVersion) && !(/CriOS/i).test(nav.appVersion);
91
90
  isStandalone = nav.standalone;
92
91
  OSVersion = nav.appVersion.match(/OS (\d+_\d+)/i);
93
- OSVersion = OSVersion[1] ? +OSVersion[1].replace('_', '.') : 0;
92
+ OSVersion = OSVersion && OSVersion[1] ? +OSVersion[1].replace('_', '.') : 0;
94
93
 
95
94
  lastVisit = +w.localStorage.getItem('addToHome');
96
95
 
@@ -116,8 +115,7 @@ var addToHome = (function (w) {
116
115
 
117
116
  var touchIcon = '',
118
117
  platform = nav.platform.split(' ')[0],
119
- language = nav.language.replace('-', '_'),
120
- i, l;
118
+ language = nav.language.replace('-', '_');
121
119
 
122
120
  balloon = document.createElement('div');
123
121
  balloon.id = 'addToHomeScreen';
@@ -134,11 +132,10 @@ var addToHome = (function (w) {
134
132
 
135
133
  if ( options.touchIcon ) {
136
134
  touchIcon = isRetina ?
137
- document.querySelector('head link[rel^=apple-touch-icon][sizes="114x114"],head link[rel^=apple-touch-icon][sizes="144x144"]') :
138
- document.querySelector('head link[rel^=apple-touch-icon][sizes="57x57"],head link[rel^=apple-touch-icon],head link[rel^=apple-touch-icon][sizes="72x72"]');
135
+ document.querySelector('head link[rel^=apple-touch-icon][sizes="114x114"],head link[rel^=apple-touch-icon][sizes="144x144"],head link[rel^=apple-touch-icon]') :
136
+ document.querySelector('head link[rel^=apple-touch-icon][sizes="57x57"],head link[rel^=apple-touch-icon]');
139
137
 
140
138
  if ( touchIcon ) {
141
- alert(touchIcon.href)
142
139
  touchIcon = '<span style="background-image:url(' + touchIcon.href + ')" class="addToHomeTouchIcon"></span>';
143
140
  }
144
141
  }
@@ -238,12 +235,15 @@ var addToHome = (function (w) {
238
235
  clearTimeout( closeTimeout );
239
236
  closeTimeout = null;
240
237
 
238
+ // check if the popup is displayed and prevent errors
239
+ if ( !balloon ) return;
240
+
241
241
  var posY = 0,
242
242
  posX = 0,
243
243
  opacity = '1',
244
244
  duration = '0';
245
245
 
246
- if ( options.closeButton ) balloon.removeEventListener('click', close, false);
246
+ if ( options.closeButton ) balloon.removeEventListener('click', clicked, false);
247
247
  if ( !isIPad && OSVersion >= 6 ) window.removeEventListener('orientationchange', orientationCheck, false);
248
248
 
249
249
  if ( OSVersion < 5 ) {
@@ -258,20 +258,20 @@ var addToHome = (function (w) {
258
258
  if ( isIPad ) {
259
259
  duration = '0.4s';
260
260
  opacity = '0';
261
- posY = posY + 50;
261
+ posY += 50;
262
262
  } else {
263
263
  duration = '0.6s';
264
- posY = posY + balloon.offsetHeight + options.bottomOffset + 50;
264
+ posY += balloon.offsetHeight + options.bottomOffset + 50;
265
265
  }
266
266
  break;
267
267
  case 'bubble':
268
268
  if ( isIPad ) {
269
269
  duration = '0.8s';
270
- posY = posY - balloon.offsetHeight - options.bottomOffset - 50;
270
+ posY -= balloon.offsetHeight + options.bottomOffset + 50;
271
271
  } else {
272
272
  duration = '0.4s';
273
273
  opacity = '0';
274
- posY = posY - 50;
274
+ posY -= 50;
275
275
  }
276
276
  break;
277
277
  default:
@@ -338,4 +338,4 @@ var addToHome = (function (w) {
338
338
  close: close,
339
339
  reset: reset
340
340
  };
341
- })(window);
341
+ })(window);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: add-to-homescreen-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 2.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-13 00:00:00.000000000 Z
12
+ date: 2013-02-14 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Provides the 'Add to Home screen' assets for your Rails application.
15
15
  email:
@@ -47,7 +47,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
47
47
  version: '0'
48
48
  requirements: []
49
49
  rubyforge_project:
50
- rubygems_version: 1.8.24
50
+ rubygems_version: 1.8.25
51
51
  signing_key:
52
52
  specification_version: 3
53
53
  summary: Use 'Add to Home screen' with Rails Asset Pipeline