add-to-homescreen-rails 2.0 → 2.0.1

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.
data/README.md CHANGED
@@ -17,7 +17,7 @@ In your Gemfile, add:
17
17
 
18
18
  ```ruby
19
19
  group :assets do
20
- gem 'add-to-home-screen-rails'
20
+ gem 'add-to-homescreen-rails'
21
21
  end
22
22
  ```
23
23
 
@@ -1,11 +1,6 @@
1
1
  require "add-to-homescreen-rails/version"
2
2
 
3
- module Add
4
- module To
5
- module Homescreen
6
- module Rails
7
- # Your code goes here...
8
- end
9
- end
3
+ module AddToHomescreenRails
4
+ class Engine < ::Rails::Engine
10
5
  end
11
6
  end
@@ -2,7 +2,7 @@ module Add
2
2
  module To
3
3
  module Homescreen
4
4
  module Rails
5
- VERSION = "2.0"
5
+ VERSION = "2.0.1"
6
6
  end
7
7
  end
8
8
  end
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Add to Homescreen v2.0 ~ Copyright (c) 2012 Matteo Spinelli, http://cubiq.org
2
+ * Add to Homescreen v2.0.1 ~ Copyright (c) 2012 Matteo Spinelli, http://cubiq.org
3
3
  * Released under MIT license, http://cubiq.org/license
4
4
  */
5
5
  var addToHome = (function (w) {
@@ -12,6 +12,7 @@ var addToHome = (function (w) {
12
12
  OSVersion,
13
13
  startX = 0,
14
14
  startY = 0,
15
+ lastVisit = 0,
15
16
  isExpired,
16
17
  isSessionActive,
17
18
  isReturningVisitor,
@@ -39,7 +40,8 @@ var addToHome = (function (w) {
39
40
 
40
41
  intl = {
41
42
  ca_es: 'Per instal·lar aquesta aplicació al vostre %device premeu %icon i llavors <strong>Afegir a pantalla d\'inici</strong>.',
42
- da_dk: 'Tilføj denne side til din %device: tryk %icon og derefter <strong>Tilføj til hjemmeskærm</strong>.',
43
+ cs_cz: 'Pro instalaci aplikace na Váš %device, stiskněte %icon a v nabídce <strong>Přidat na plochu</strong>.',
44
+ da_dk: 'Tilføj denne side til din %device: tryk på %icon og derefter <strong>Føj til hjemmeskærm</strong>.',
43
45
  de_de: 'Installieren Sie diese App auf Ihrem %device: %icon antippen und dann <strong>Zum Home-Bildschirm</strong>.',
44
46
  el_gr: 'Εγκαταστήσετε αυτήν την Εφαρμογή στήν συσκευή σας %device: %icon μετά πατάτε <strong>Προσθήκη σε Αφετηρία</strong>.',
45
47
  en_us: 'Install this web app on your %device: tap %icon and then <strong>Add to Home Screen</strong>.',
@@ -59,7 +61,7 @@ var addToHome = (function (w) {
59
61
  ru_ru: 'Установите это веб-приложение на ваш %device: нажмите %icon, затем <strong>Добавить в «Домой»</strong>.',
60
62
  sv_se: 'Lägg till denna webbapplikation på din %device: tryck på %icon och därefter <strong>Lägg till på hemskärmen</strong>.',
61
63
  th_th: 'ติดตั้งเว็บแอพฯ นี้บน %device ของคุณ: แตะ %icon และ <strong>เพิ่มที่หน้าจอโฮม</strong>',
62
- tr_tr: '%device için bu uygulamayı kurduktan sonra %icon simgesine dokunarak <strong>Ev Ekranına Ekle</strong>yin.',
64
+ tr_tr: '%device için bu uygulamayı kurduktan sonra %icon simgesine dokunarak <strong>Ana Ekrana Ekle</strong>yin.',
63
65
  zh_cn: '您可以将此应用程式安装到您的 %device 上。请按 %icon 然后点选<strong>添加至主屏幕</strong>。',
64
66
  zh_tw: '您可以將此應用程式安裝到您的 %device 上。請按 %icon 然後點選<strong>加入主畫面螢幕</strong>。'
65
67
  };
@@ -68,11 +70,12 @@ var addToHome = (function (w) {
68
70
  // Preliminary check, prevents all further checks to be performed on iDevices only
69
71
  if ( !isIDevice ) return;
70
72
 
71
- var now = Date.now();
73
+ var now = Date.now(),
74
+ i;
72
75
 
73
76
  // Merge local with global options
74
77
  if (w.addToHomeConfig) {
75
- for ( var i in w.addToHomeConfig ) {
78
+ for ( i in w.addToHomeConfig ) {
76
79
  options[i] = w.addToHomeConfig[i];
77
80
  }
78
81
  }
@@ -86,12 +89,15 @@ var addToHome = (function (w) {
86
89
  OSVersion = nav.appVersion.match(/OS (\d+_\d+)/i);
87
90
  OSVersion = OSVersion[1] ? +OSVersion[1].replace('_', '.') : 0;
88
91
 
89
- isExpired = +w.localStorage.getItem('addToHome') || now;
92
+ lastVisit = +w.localStorage.getItem('addToHome');
93
+
90
94
  isSessionActive = w.sessionStorage.getItem('addToHomeSession');
91
- isReturningVisitor = !options.returningVisitor || ( isExpired && isExpired + 28*24*60*60*1000 > now ); // You are considered a "returning visitor" if you access the site more than once/month
95
+ isReturningVisitor = options.returningVisitor ? lastVisit && lastVisit + 28*24*60*60*1000 > now : true;
96
+
97
+ if ( !lastVisit ) lastVisit = now;
92
98
 
93
99
  // If it is expired we need to reissue a new balloon
94
- isExpired = ( !options.expire || isExpired <= now );
100
+ isExpired = isReturningVisitor && lastVisit <= now;
95
101
 
96
102
  if ( options.hookOnLoad ) w.addEventListener('load', loaded, false);
97
103
  else if ( !options.hookOnLoad && options.autostart ) loaded();
@@ -100,11 +106,10 @@ var addToHome = (function (w) {
100
106
  function loaded () {
101
107
  w.removeEventListener('load', loaded, false);
102
108
 
103
- if ( !overrideChecks && (!isSafari || !isExpired || isSessionActive || isStandalone || !isReturningVisitor) ) return;
109
+ if ( !isReturningVisitor ) w.localStorage.setItem('addToHome', Date.now());
110
+ else if ( options.expire && isExpired ) w.localStorage.setItem('addToHome', Date.now() + options.expire * 60000);
104
111
 
105
- if ( options.expire || options.returningVisitor ) {
106
- w.localStorage.setItem('addToHome', Date.now() + options.expire * 60000);
107
- }
112
+ if ( !overrideChecks && ( !isSafari || !isExpired || isSessionActive || isStandalone || !isReturningVisitor ) ) return;
108
113
 
109
114
  var icons = options.touchIcon ? document.querySelectorAll('head link[rel=apple-touch-icon],head link[rel=apple-touch-icon-precomposed]') : [],
110
115
  sizes,
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'
4
+ version: 2.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -20,7 +20,6 @@ extra_rdoc_files: []
20
20
  files:
21
21
  - .gitignore
22
22
  - Gemfile
23
- - LICENSE.txt
24
23
  - README.md
25
24
  - Rakefile
26
25
  - add-to-homescreen-rails.gemspec
@@ -1,22 +0,0 @@
1
- Copyright (c) 2012 RogerE
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.