add-to-homescreen-rails 2.0.11 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/app/assets/javascripts/addtohomescreen.js +552 -0
- data/app/assets/stylesheets/addtohomescreen.css +236 -0
- data/lib/add-to-homescreen-rails/version.rb +1 -1
- metadata +5 -5
- data/app/assets/javascripts/add2home.js +0 -344
- data/app/assets/stylesheets/add2home.css +0 -180
@@ -0,0 +1,236 @@
|
|
1
|
+
.ath-viewport * {
|
2
|
+
-webkit-box-sizing: border-box;
|
3
|
+
-moz-box-sizing: border-box;
|
4
|
+
box-sizing: border-box;
|
5
|
+
}
|
6
|
+
|
7
|
+
.ath-viewport {
|
8
|
+
position: relative;
|
9
|
+
z-index: 2147483641;
|
10
|
+
|
11
|
+
-webkit-tap-highlight-color: rgba(0,0,0,0);
|
12
|
+
-webkit-touch-callout: none;
|
13
|
+
-webkit-user-select: none;
|
14
|
+
-moz-user-select: none;
|
15
|
+
-ms-user-select: none;
|
16
|
+
user-select: none;
|
17
|
+
-webkit-text-size-adjust: none;
|
18
|
+
-moz-text-size-adjust: none;
|
19
|
+
-ms-text-size-adjust: none;
|
20
|
+
-o-text-size-adjust: none;
|
21
|
+
text-size-adjust: none;
|
22
|
+
}
|
23
|
+
|
24
|
+
.ath-modal {
|
25
|
+
background: rgba(0,0,0,0.6);
|
26
|
+
}
|
27
|
+
|
28
|
+
.ath-mandatory {
|
29
|
+
background: #000;
|
30
|
+
}
|
31
|
+
|
32
|
+
.ath-container {
|
33
|
+
position: absolute;
|
34
|
+
z-index: 2147483641;
|
35
|
+
padding: 0.7em 0.6em;
|
36
|
+
width: 18em;
|
37
|
+
|
38
|
+
background: #eee;
|
39
|
+
background-size: 100% auto;
|
40
|
+
|
41
|
+
box-shadow: 0 0.2em 0 #d1d1d1;
|
42
|
+
|
43
|
+
font-family: sans-serif;
|
44
|
+
font-size: 15px;
|
45
|
+
line-height: 1.5em;
|
46
|
+
text-align: center;
|
47
|
+
}
|
48
|
+
|
49
|
+
.ath-ios.ath-phone {
|
50
|
+
bottom: 1.8em;
|
51
|
+
left: 50%;
|
52
|
+
margin-left: -9em;
|
53
|
+
}
|
54
|
+
|
55
|
+
.ath-ios7.ath-tablet {
|
56
|
+
left: 0.7em;
|
57
|
+
top: 1.8em;
|
58
|
+
}
|
59
|
+
|
60
|
+
.ath-ios6.ath-tablet {
|
61
|
+
left: 5em;
|
62
|
+
top: 1.8em;
|
63
|
+
}
|
64
|
+
|
65
|
+
.ath-android {
|
66
|
+
right: 1.5em;
|
67
|
+
top: 1.8em;
|
68
|
+
}
|
69
|
+
|
70
|
+
/* close icon */
|
71
|
+
.ath-container:before {
|
72
|
+
content: '×';
|
73
|
+
position: relative;
|
74
|
+
display: block;
|
75
|
+
float: right;
|
76
|
+
margin: -0.3em -0.25em 0 0.1em;
|
77
|
+
background-color: rgba(255,255,255,0.7);
|
78
|
+
width: 1.2em;
|
79
|
+
height: 1.2em;
|
80
|
+
text-align: center;
|
81
|
+
overflow: hidden;
|
82
|
+
font-size: 2.3em;
|
83
|
+
color: #a33;
|
84
|
+
z-index: 2147483642;
|
85
|
+
}
|
86
|
+
|
87
|
+
.ath-container.ath-icon:before {
|
88
|
+
position: absolute;
|
89
|
+
top: 0;
|
90
|
+
right: 0;
|
91
|
+
margin: 0;
|
92
|
+
float: none;
|
93
|
+
}
|
94
|
+
|
95
|
+
.ath-mandatory .ath-container:before {
|
96
|
+
display: none;
|
97
|
+
}
|
98
|
+
|
99
|
+
.ath-android:before {
|
100
|
+
line-height: 1.2em;
|
101
|
+
}
|
102
|
+
|
103
|
+
.ath-ios:before {
|
104
|
+
line-height: 1em;
|
105
|
+
}
|
106
|
+
|
107
|
+
.ath-container.ath-android:before {
|
108
|
+
float: left;
|
109
|
+
margin: -0.3em 0.1em 0 -0.2em;
|
110
|
+
}
|
111
|
+
|
112
|
+
.ath-container.ath-android.ath-icon:before {
|
113
|
+
position: absolute;
|
114
|
+
right: auto;
|
115
|
+
left: 0;
|
116
|
+
margin: 0;
|
117
|
+
float: none;
|
118
|
+
}
|
119
|
+
|
120
|
+
|
121
|
+
/* applied only if the application icon is shown */
|
122
|
+
.ath-container.ath-icon {
|
123
|
+
|
124
|
+
}
|
125
|
+
|
126
|
+
.ath-action-icon {
|
127
|
+
display: inline-block;
|
128
|
+
vertical-align: middle;
|
129
|
+
background-position: 50%;
|
130
|
+
background-repeat: no-repeat;
|
131
|
+
text-indent: -9999em;
|
132
|
+
overflow: hidden;
|
133
|
+
}
|
134
|
+
|
135
|
+
.ath-android .ath-action-icon {
|
136
|
+
width: 1.2em;
|
137
|
+
height: 1.8em;
|
138
|
+
background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADUAAADcBAMAAAAig/QJAAAAA3NCSVQICAjb4U/gAAAACXBIWXMAAFtDAABbQwH5xg68AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAB5QTFRFAAAA////cXFxaWlp////ZmZmnJycoaGhpqam////1D9b6wAAAAV0Uk5TAAgJERExZxYzAAAAYklEQVRYw+3WoQ2AUBAE0SsBOiBUQEIDCArA4FFoHBaJxNItFYz/x5+xz282VmwJTdM0rRzbsS1e7Pm9zdgUVn491rkFmqZpSezEjqo/Sos1HoAEjdjgFmiapiWxG7tq/igfnYteFlnOWZEAAAAASUVORK5CYII=);
|
139
|
+
background-size: auto 100%;
|
140
|
+
}
|
141
|
+
|
142
|
+
.ath-ios7 .ath-action-icon {
|
143
|
+
width: 1.6em;
|
144
|
+
height: 1.6em;
|
145
|
+
background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAACtCAYAAAB7l7tOAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAABa5AAAWuQBuyxkRwAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAZoSURBVHja7d1ZbFRlGIfxzxVwl809goLgghrRoEaNSzQagrsRt8QYgzEG443SOQNSA0Q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
|
146
|
+
margin-top: -0.3em;
|
147
|
+
background-size: auto 100%;
|
148
|
+
}
|
149
|
+
|
150
|
+
.ath-ios6 .ath-action-icon {
|
151
|
+
width: 1.8em;
|
152
|
+
height: 1.8em;
|
153
|
+
background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJAAAAB0CAQAAADAmnOnAAAAAnNCSVQICFXsRgQAAAAJcEhZcwAAWwEAAFsBAXkZiFwAAAAZdEVYdFNvZnR3YXJlAHd3dy5pbmtzY2FwZS5vcmeb7jwaAAAGaklEQVR42u3cfUxVZRwH8O8FRERRfNfKt4zM2UzNMszZFPMPW5KWzizJ0JJWitOU3mYs54ZuNRk6zblSaebUnKllSpopaRorJiqmtjRNK4sNEBR5+fbH45ELwrnn5Tnn3gPP7/cv9/7O/eyc5zyvAF6PrlgAFTrRHcQmtFIQekDEYXRRFA3GzP4gCOI39FcaDcQ7g24BEUUYrTz0gIhKvKZE9IAIIhNhSkUPiNiGaOWiB0Tko4eS0QMi/sQQZaMHRJRivNLRAyKqkKZ89IAIYg1aKCDq5l60U0D6WYDeCkg/r2KEAtLPG5iqgPSzBukKKFB+ikgFpJ+56KyA9PMcHjBXYYwjGRmyQMR/GGWmAqVnNV4N4TuIICowPXhA1ZgR0o+Y6Yk1uTyVeD7E26Da3GpsYk0iTwQ3kSS5nbLboAj0wnBMwGwsRhaysRO5yEMe8iJP2bjig+joIlALbhE86xguCWUgXkYmduMMbjrQVhLEWfRzCagldwmelfTZhOmM8ViGXJQ7hFI3iwK906SUieLXgifTFs9DeA/HUOMKjP87LdlhoFb8RvB8ZJHHhxHIxEWXYfzzY0Q4BtSG3wueDyzhxCAFvwSRJuA7zeYXx/CQ4LEy/3sPlqMkBHBEHkN36UBt+YPgWWgapzfWoiJkcERewECpQB2YR5I1nG/6PbUcN0IMR2QJxhkEWsi0gPkjSVYzxRROS6SjLCRxGplYa+QPq2goqjnTFM8wFIQwjpZZCJcDVMmppu6dTNf7OFbzEDoFAKrcx5y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AC2eeElsKE+F66EBdWOuyXkeF4EYT7LCzZanPtBoXtXmeTrJriAD6AmW8SkgWEC3W541bCm/ggygRxiPIMWSB1cInAqTRyJcnw8KUrD7rXmewY5VaAJA++W3PE0JKMPUPE8MEpoXkLnBcBL+wqpmBWQiemIXCCqghiIcadoxvvYbFFD9GIDDtb9s3EkF5B9RyKj7jy0UkH+MvnNBXAFp0QEbGjoCqoC0mNPwL1NACshYhKUqIN2YvFEB6ca0LxSQAlJACkgBKSAFpICsADXdVEAKSAEpIAWkgBSQAlJACkgBKaDgA41hc8vUXHM3UPOLVQpIAbkH9D87oz0rvnJrOgAAAABJRU5ErkJggg==);
|
154
|
+
margin-bottom: 0.4em;
|
155
|
+
background-size: 100% auto;
|
156
|
+
}
|
157
|
+
|
158
|
+
.ath-container p {
|
159
|
+
margin: 0;
|
160
|
+
padding: 0;
|
161
|
+
position: relative;
|
162
|
+
z-index: 2147483642;
|
163
|
+
text-shadow: 0 0.1em 0 #fff;
|
164
|
+
font-size: 1.1em;
|
165
|
+
}
|
166
|
+
|
167
|
+
.ath-ios.ath-phone:after {
|
168
|
+
content: '';
|
169
|
+
background: #eee;
|
170
|
+
position: absolute;
|
171
|
+
width: 2em;
|
172
|
+
height: 2em;
|
173
|
+
bottom: -0.9em;
|
174
|
+
left: 50%;
|
175
|
+
margin-left: -1em;
|
176
|
+
-webkit-transform: scaleX(0.9) rotate(45deg);
|
177
|
+
transform: scaleX(0.9) rotate(45deg);
|
178
|
+
box-shadow: 0.2em 0.2em 0 #d1d1d1;
|
179
|
+
}
|
180
|
+
|
181
|
+
.ath-ios.ath-tablet:after {
|
182
|
+
content: '';
|
183
|
+
background: #eee;
|
184
|
+
position: absolute;
|
185
|
+
width: 2em;
|
186
|
+
height: 2em;
|
187
|
+
top: -0.9em;
|
188
|
+
left: 50%;
|
189
|
+
margin-left: -1em;
|
190
|
+
-webkit-transform: scaleX(0.9) rotate(45deg);
|
191
|
+
transform: scaleX(0.9) rotate(45deg);
|
192
|
+
z-index: 2147483641;
|
193
|
+
}
|
194
|
+
|
195
|
+
.ath-android:after {
|
196
|
+
content: '';
|
197
|
+
background: #eee;
|
198
|
+
background: -webkit-linear-gradient(-45deg, rgba(238,238,238,0) 0%,rgba(238,238,238,0) 50%,rgba(238,238,238,1) 50%,rgba(238,238,238,1) 100%);
|
199
|
+
position: absolute;
|
200
|
+
width: 2em;
|
201
|
+
height: 2em;
|
202
|
+
top: -1.5em;
|
203
|
+
right: 0;
|
204
|
+
}
|
205
|
+
|
206
|
+
.ath-application-icon {
|
207
|
+
position: relative;
|
208
|
+
padding: 0;
|
209
|
+
border: 0;
|
210
|
+
margin: 0 auto 0.2em auto;
|
211
|
+
height: 6em;
|
212
|
+
width: 6em;
|
213
|
+
z-index: 2147483642;
|
214
|
+
}
|
215
|
+
|
216
|
+
/* OS specific classes */
|
217
|
+
.ath-container.ath-ios .ath-application-icon {
|
218
|
+
border-radius: 1em;
|
219
|
+
box-shadow: 0 0.2em 0.4em rgba(0,0,0,0.3),
|
220
|
+
inset 0 0.07em 0 rgba(255,255,255,0.5);
|
221
|
+
margin: 0 auto 0.4em auto;
|
222
|
+
}
|
223
|
+
|
224
|
+
@media only screen and (orientation: landscape) {
|
225
|
+
.ath-container.ath-phone {
|
226
|
+
width: 24em;
|
227
|
+
}
|
228
|
+
|
229
|
+
.ath-ios.ath-phone {
|
230
|
+
margin-left: -12em;
|
231
|
+
}
|
232
|
+
|
233
|
+
.ath-ios6:after {
|
234
|
+
left: 39%;
|
235
|
+
}
|
236
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: add-to-homescreen-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RogerE
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Provides the 'Add to Home screen' assets for your Rails application.
|
14
14
|
email:
|
@@ -22,8 +22,8 @@ files:
|
|
22
22
|
- README.md
|
23
23
|
- Rakefile
|
24
24
|
- add-to-homescreen-rails.gemspec
|
25
|
-
- app/assets/javascripts/
|
26
|
-
- app/assets/stylesheets/
|
25
|
+
- app/assets/javascripts/addtohomescreen.js
|
26
|
+
- app/assets/stylesheets/addtohomescreen.css
|
27
27
|
- lib/add-to-homescreen-rails.rb
|
28
28
|
- lib/add-to-homescreen-rails/version.rb
|
29
29
|
homepage: https://github.com/RogerE/add-to-homescreen-rails
|
@@ -45,7 +45,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
45
45
|
version: '0'
|
46
46
|
requirements: []
|
47
47
|
rubyforge_project:
|
48
|
-
rubygems_version: 2.1.
|
48
|
+
rubygems_version: 2.1.11
|
49
49
|
signing_key:
|
50
50
|
specification_version: 4
|
51
51
|
summary: Use 'Add to Home screen' with Rails Asset Pipeline
|
@@ -1,344 +0,0 @@
|
|
1
|
-
/*!
|
2
|
-
* Add to Homescreen v2.0.11 ~ Copyright (c) 2013 Matteo Spinelli, http://cubiq.org
|
3
|
-
* Released under MIT license, http://cubiq.org/license
|
4
|
-
*/
|
5
|
-
var addToHome = (function (w) {
|
6
|
-
var nav = w.navigator,
|
7
|
-
isIDevice = 'platform' in nav && (/iphone|ipod|ipad/gi).test(nav.platform),
|
8
|
-
isIPad,
|
9
|
-
isRetina,
|
10
|
-
isSafari,
|
11
|
-
isStandalone,
|
12
|
-
OSVersion,
|
13
|
-
startX = 0,
|
14
|
-
startY = 0,
|
15
|
-
lastVisit = 0,
|
16
|
-
isExpired,
|
17
|
-
isSessionActive,
|
18
|
-
isReturningVisitor,
|
19
|
-
balloon,
|
20
|
-
overrideChecks,
|
21
|
-
|
22
|
-
positionInterval,
|
23
|
-
closeTimeout,
|
24
|
-
|
25
|
-
options = {
|
26
|
-
autostart: true, // Automatically open the balloon
|
27
|
-
returningVisitor: false, // Show the balloon to returning visitors only (setting this to true is highly recommended)
|
28
|
-
animationIn: 'drop', // drop || bubble || fade
|
29
|
-
animationOut: 'fade', // drop || bubble || fade
|
30
|
-
startDelay: 2000, // 2 seconds from page load before the balloon appears
|
31
|
-
lifespan: 15000, // 15 seconds before it is automatically destroyed
|
32
|
-
bottomOffset: 14, // Distance of the balloon from bottom
|
33
|
-
expire: 0, // Minutes to wait before showing the popup again (0 = always displayed)
|
34
|
-
message: '', // Customize your message or force a language ('' = automatic)
|
35
|
-
touchIcon: false, // Display the touch icon
|
36
|
-
arrow: true, // Display the balloon arrow
|
37
|
-
hookOnLoad: true, // Should we hook to onload event? (really advanced usage)
|
38
|
-
closeButton: true, // Let the user close the balloon
|
39
|
-
iterations: 100 // Internal/debug use
|
40
|
-
},
|
41
|
-
|
42
|
-
intl = {
|
43
|
-
ar: '<span dir="rtl">قم بتثبيت هذا التطبيق على <span dir="ltr">%device:</span>انقر<span dir="ltr">%icon</span> ،<strong>ثم اضفه الى الشاشة الرئيسية.</strong></span>',
|
44
|
-
ca_es: 'Per instal·lar aquesta aplicació al vostre %device premeu %icon i llavors <strong>Afegir a pantalla d\'inici</strong>.',
|
45
|
-
cs_cz: 'Pro instalaci aplikace na Váš %device, stiskněte %icon a v nabídce <strong>Přidat na plochu</strong>.',
|
46
|
-
da_dk: 'Tilføj denne side til din %device: tryk på %icon og derefter <strong>Føj til hjemmeskærm</strong>.',
|
47
|
-
de_de: 'Installieren Sie diese App auf Ihrem %device: %icon antippen und dann <strong>Zum Home-Bildschirm</strong>.',
|
48
|
-
el_gr: 'Εγκαταστήσετε αυτήν την Εφαρμογή στήν συσκευή σας %device: %icon μετά πατάτε <strong>Προσθήκη σε Αφετηρία</strong>.',
|
49
|
-
en_us: 'Install this web app on your %device: tap %icon and then <strong>Add to Home Screen</strong>.',
|
50
|
-
es_es: 'Para instalar esta app en su %device, pulse %icon y seleccione <strong>Añadir a pantalla de inicio</strong>.',
|
51
|
-
fi_fi: 'Asenna tämä web-sovellus laitteeseesi %device: paina %icon ja sen jälkeen valitse <strong>Lisää Koti-valikkoon</strong>.',
|
52
|
-
fr_fr: 'Ajoutez cette application sur votre %device en cliquant sur %icon, puis <strong>Ajouter à l\'écran d\'accueil</strong>.',
|
53
|
-
he_il: '<span dir="rtl">התקן אפליקציה זו על ה-%device שלך: הקש %icon ואז <strong>הוסף למסך הבית</strong>.</span>',
|
54
|
-
hr_hr: 'Instaliraj ovu aplikaciju na svoj %device: klikni na %icon i odaberi <strong>Dodaj u početni zaslon</strong>.',
|
55
|
-
hu_hu: 'Telepítse ezt a web-alkalmazást az Ön %device-jára: nyomjon a %icon-ra majd a <strong>Főképernyőhöz adás</strong> gombra.',
|
56
|
-
it_it: 'Installa questa applicazione sul tuo %device: premi su %icon e poi <strong>Aggiungi a Home</strong>.',
|
57
|
-
ja_jp: 'このウェブアプリをあなたの%deviceにインストールするには%iconをタップして<strong>ホーム画面に追加</strong>を選んでください。',
|
58
|
-
ko_kr: '%device에 웹앱을 설치하려면 %icon을 터치 후 "홈화면에 추가"를 선택하세요',
|
59
|
-
nb_no: 'Installer denne appen på din %device: trykk på %icon og deretter <strong>Legg til på Hjem-skjerm</strong>',
|
60
|
-
nl_nl: 'Installeer deze webapp op uw %device: tik %icon en dan <strong>Voeg toe aan beginscherm</strong>.',
|
61
|
-
pl_pl: 'Aby zainstalować tę aplikacje na %device: naciśnij %icon a następnie <strong>Dodaj jako ikonę</strong>.',
|
62
|
-
pt_br: 'Instale este aplicativo em seu %device: aperte %icon e selecione <strong>Adicionar à Tela Inicio</strong>.',
|
63
|
-
pt_pt: 'Para instalar esta aplicação no seu %device, prima o %icon e depois em <strong>Adicionar ao ecrã principal</strong>.',
|
64
|
-
ru_ru: 'Установите это веб-приложение на ваш %device: нажмите %icon, затем <strong>Добавить в «Домой»</strong>.',
|
65
|
-
sv_se: 'Lägg till denna webbapplikation på din %device: tryck på %icon och därefter <strong>Lägg till på hemskärmen</strong>.',
|
66
|
-
th_th: 'ติดตั้งเว็บแอพฯ นี้บน %device ของคุณ: แตะ %icon และ <strong>เพิ่มที่หน้าจอโฮม</strong>',
|
67
|
-
tr_tr: 'Bu uygulamayı %device\'a eklemek için %icon simgesine sonrasında <strong>Ana Ekrana Ekle</strong> düğmesine basın.',
|
68
|
-
uk_ua: 'Встановіть цей веб сайт на Ваш %device: натисніть %icon, а потім <strong>На початковий екран</strong>.',
|
69
|
-
zh_cn: '您可以将此应用程式安装到您的 %device 上。请按 %icon 然后点选<strong>添加至主屏幕</strong>。',
|
70
|
-
zh_tw: '您可以將此應用程式安裝到您的 %device 上。請按 %icon 然後點選<strong>加入主畫面螢幕</strong>。'
|
71
|
-
};
|
72
|
-
|
73
|
-
function init () {
|
74
|
-
// Preliminary check, all further checks are performed on iDevices only
|
75
|
-
if ( !isIDevice ) return;
|
76
|
-
|
77
|
-
var now = Date.now(),
|
78
|
-
i;
|
79
|
-
|
80
|
-
// Merge local with global options
|
81
|
-
if ( w.addToHomeConfig ) {
|
82
|
-
for ( i in w.addToHomeConfig ) {
|
83
|
-
options[i] = w.addToHomeConfig[i];
|
84
|
-
}
|
85
|
-
}
|
86
|
-
if ( !options.autostart ) options.hookOnLoad = false;
|
87
|
-
|
88
|
-
isIPad = (/ipad/gi).test(nav.platform);
|
89
|
-
isRetina = w.devicePixelRatio && w.devicePixelRatio > 1;
|
90
|
-
isSafari = (/Safari/i).test(nav.appVersion) && !(/CriOS/i).test(nav.appVersion);
|
91
|
-
isStandalone = nav.standalone;
|
92
|
-
OSVersion = nav.appVersion.match(/OS (\d+_\d+)/i);
|
93
|
-
OSVersion = OSVersion && OSVersion[1] ? +OSVersion[1].replace('_', '.') : 0;
|
94
|
-
|
95
|
-
lastVisit = +w.localStorage.getItem('addToHome');
|
96
|
-
|
97
|
-
isSessionActive = w.sessionStorage.getItem('addToHomeSession');
|
98
|
-
isReturningVisitor = options.returningVisitor ? lastVisit && lastVisit + 28*24*60*60*1000 > now : true;
|
99
|
-
|
100
|
-
if ( !lastVisit ) lastVisit = now;
|
101
|
-
|
102
|
-
// If it is expired we need to reissue a new balloon
|
103
|
-
isExpired = isReturningVisitor && lastVisit <= now;
|
104
|
-
|
105
|
-
if ( options.hookOnLoad ) w.addEventListener('load', loaded, false);
|
106
|
-
else if ( !options.hookOnLoad && options.autostart ) loaded();
|
107
|
-
}
|
108
|
-
|
109
|
-
function loaded () {
|
110
|
-
w.removeEventListener('load', loaded, false);
|
111
|
-
|
112
|
-
if ( !isReturningVisitor ) w.localStorage.setItem('addToHome', Date.now());
|
113
|
-
else if ( options.expire && isExpired ) w.localStorage.setItem('addToHome', Date.now() + options.expire * 60000);
|
114
|
-
|
115
|
-
if ( !overrideChecks && ( !isSafari || !isExpired || isSessionActive || isStandalone || !isReturningVisitor ) ) return;
|
116
|
-
|
117
|
-
var touchIcon = '',
|
118
|
-
platform = nav.platform.split(' ')[0],
|
119
|
-
language = nav.language.replace('-', '_');
|
120
|
-
|
121
|
-
balloon = document.createElement('div');
|
122
|
-
balloon.id = 'addToHomeScreen';
|
123
|
-
balloon.style.cssText += 'left:-9999px;-webkit-transition-property:-webkit-transform,opacity;-webkit-transition-duration:0;-webkit-transform:translate3d(0,0,0);position:' + (OSVersion < 5 ? 'absolute' : 'fixed');
|
124
|
-
|
125
|
-
// Localize message
|
126
|
-
if ( options.message in intl ) { // You may force a language despite the user's locale
|
127
|
-
language = options.message;
|
128
|
-
options.message = '';
|
129
|
-
}
|
130
|
-
if ( options.message === '' ) { // We look for a suitable language (defaulted to en_us)
|
131
|
-
options.message = language in intl ? intl[language] : intl['en_us'];
|
132
|
-
}
|
133
|
-
|
134
|
-
if ( options.touchIcon ) {
|
135
|
-
touchIcon = isRetina ?
|
136
|
-
document.querySelector('head link[rel^=apple-touch-icon][sizes="114x114"],head link[rel^=apple-touch-icon][sizes="144x144"],head link[rel^=apple-touch-icon]') :
|
137
|
-
document.querySelector('head link[rel^=apple-touch-icon][sizes="57x57"],head link[rel^=apple-touch-icon]');
|
138
|
-
|
139
|
-
if ( touchIcon ) {
|
140
|
-
touchIcon = '<span style="background-image:url(' + touchIcon.href + ')" class="addToHomeTouchIcon"></span>';
|
141
|
-
}
|
142
|
-
}
|
143
|
-
|
144
|
-
balloon.className = (OSVersion >=7 ? 'addToHomeIOS7 ' : '') + (isIPad ? 'addToHomeIpad' : 'addToHomeIphone') + (touchIcon ? ' addToHomeWide' : '');
|
145
|
-
balloon.innerHTML = touchIcon +
|
146
|
-
options.message.replace('%device', platform).replace('%icon', OSVersion >= 4.2 ? '<span class="addToHomeShare"></span>' : '<span class="addToHomePlus">+</span>') +
|
147
|
-
(options.arrow ? '<span class="addToHomeArrow"' + (OSVersion >= 7 && isIPad && touchIcon ? ' style="margin-left:-32px"' : '') + '></span>' : '') +
|
148
|
-
(options.closeButton ? '<span class="addToHomeClose">\u00D7</span>' : '');
|
149
|
-
|
150
|
-
document.body.appendChild(balloon);
|
151
|
-
|
152
|
-
// Add the close action
|
153
|
-
if ( options.closeButton ) balloon.addEventListener('click', clicked, false);
|
154
|
-
|
155
|
-
if ( !isIPad && OSVersion >= 6 ) window.addEventListener('orientationchange', orientationCheck, false);
|
156
|
-
|
157
|
-
setTimeout(show, options.startDelay);
|
158
|
-
}
|
159
|
-
|
160
|
-
function show () {
|
161
|
-
var duration,
|
162
|
-
iPadXShift = 208;
|
163
|
-
|
164
|
-
// Set the initial position
|
165
|
-
if ( isIPad ) {
|
166
|
-
if ( OSVersion < 5 ) {
|
167
|
-
startY = w.scrollY;
|
168
|
-
startX = w.scrollX;
|
169
|
-
} else if ( OSVersion < 6 ) {
|
170
|
-
iPadXShift = 160;
|
171
|
-
} else if ( OSVersion >= 7 ) {
|
172
|
-
iPadXShift = 143;
|
173
|
-
}
|
174
|
-
|
175
|
-
balloon.style.top = startY + options.bottomOffset + 'px';
|
176
|
-
balloon.style.left = Math.max(startX + iPadXShift - Math.round(balloon.offsetWidth / 2), 9) + 'px';
|
177
|
-
|
178
|
-
switch ( options.animationIn ) {
|
179
|
-
case 'drop':
|
180
|
-
duration = '0.6s';
|
181
|
-
balloon.style.webkitTransform = 'translate3d(0,' + -(w.scrollY + options.bottomOffset + balloon.offsetHeight) + 'px,0)';
|
182
|
-
break;
|
183
|
-
case 'bubble':
|
184
|
-
duration = '0.6s';
|
185
|
-
balloon.style.opacity = '0';
|
186
|
-
balloon.style.webkitTransform = 'translate3d(0,' + (startY + 50) + 'px,0)';
|
187
|
-
break;
|
188
|
-
default:
|
189
|
-
duration = '1s';
|
190
|
-
balloon.style.opacity = '0';
|
191
|
-
}
|
192
|
-
} else {
|
193
|
-
startY = w.innerHeight + w.scrollY;
|
194
|
-
|
195
|
-
if ( OSVersion < 5 ) {
|
196
|
-
startX = Math.round((w.innerWidth - balloon.offsetWidth) / 2) + w.scrollX;
|
197
|
-
balloon.style.left = startX + 'px';
|
198
|
-
balloon.style.top = startY - balloon.offsetHeight - options.bottomOffset + 'px';
|
199
|
-
} else {
|
200
|
-
balloon.style.left = '50%';
|
201
|
-
balloon.style.marginLeft = -Math.round(balloon.offsetWidth / 2) - ( w.orientation%180 && OSVersion >= 6 && OSVersion < 7 ? 40 : 0 ) + 'px';
|
202
|
-
balloon.style.bottom = options.bottomOffset + 'px';
|
203
|
-
}
|
204
|
-
|
205
|
-
switch (options.animationIn) {
|
206
|
-
case 'drop':
|
207
|
-
duration = '1s';
|
208
|
-
balloon.style.webkitTransform = 'translate3d(0,' + -(startY + options.bottomOffset) + 'px,0)';
|
209
|
-
break;
|
210
|
-
case 'bubble':
|
211
|
-
duration = '0.6s';
|
212
|
-
balloon.style.webkitTransform = 'translate3d(0,' + (balloon.offsetHeight + options.bottomOffset + 50) + 'px,0)';
|
213
|
-
break;
|
214
|
-
default:
|
215
|
-
duration = '1s';
|
216
|
-
balloon.style.opacity = '0';
|
217
|
-
}
|
218
|
-
}
|
219
|
-
|
220
|
-
balloon.offsetHeight; // repaint trick
|
221
|
-
balloon.style.webkitTransitionDuration = duration;
|
222
|
-
balloon.style.opacity = '1';
|
223
|
-
balloon.style.webkitTransform = 'translate3d(0,0,0)';
|
224
|
-
balloon.addEventListener('webkitTransitionEnd', transitionEnd, false);
|
225
|
-
|
226
|
-
closeTimeout = setTimeout(close, options.lifespan);
|
227
|
-
}
|
228
|
-
|
229
|
-
function manualShow (override) {
|
230
|
-
if ( !isIDevice || balloon ) return;
|
231
|
-
|
232
|
-
overrideChecks = override;
|
233
|
-
loaded();
|
234
|
-
}
|
235
|
-
|
236
|
-
function close () {
|
237
|
-
clearInterval( positionInterval );
|
238
|
-
clearTimeout( closeTimeout );
|
239
|
-
closeTimeout = null;
|
240
|
-
|
241
|
-
// check if the popup is displayed and prevent errors
|
242
|
-
if ( !balloon ) return;
|
243
|
-
|
244
|
-
var posY = 0,
|
245
|
-
posX = 0,
|
246
|
-
opacity = '1',
|
247
|
-
duration = '0';
|
248
|
-
|
249
|
-
if ( options.closeButton ) balloon.removeEventListener('click', clicked, false);
|
250
|
-
if ( !isIPad && OSVersion >= 6 ) window.removeEventListener('orientationchange', orientationCheck, false);
|
251
|
-
|
252
|
-
if ( OSVersion < 5 ) {
|
253
|
-
posY = isIPad ? w.scrollY - startY : w.scrollY + w.innerHeight - startY;
|
254
|
-
posX = isIPad ? w.scrollX - startX : w.scrollX + Math.round((w.innerWidth - balloon.offsetWidth)/2) - startX;
|
255
|
-
}
|
256
|
-
|
257
|
-
balloon.style.webkitTransitionProperty = '-webkit-transform,opacity';
|
258
|
-
|
259
|
-
switch ( options.animationOut ) {
|
260
|
-
case 'drop':
|
261
|
-
if ( isIPad ) {
|
262
|
-
duration = '0.4s';
|
263
|
-
opacity = '0';
|
264
|
-
posY += 50;
|
265
|
-
} else {
|
266
|
-
duration = '0.6s';
|
267
|
-
posY += balloon.offsetHeight + options.bottomOffset + 50;
|
268
|
-
}
|
269
|
-
break;
|
270
|
-
case 'bubble':
|
271
|
-
if ( isIPad ) {
|
272
|
-
duration = '0.8s';
|
273
|
-
posY -= balloon.offsetHeight + options.bottomOffset + 50;
|
274
|
-
} else {
|
275
|
-
duration = '0.4s';
|
276
|
-
opacity = '0';
|
277
|
-
posY -= 50;
|
278
|
-
}
|
279
|
-
break;
|
280
|
-
default:
|
281
|
-
duration = '0.8s';
|
282
|
-
opacity = '0';
|
283
|
-
}
|
284
|
-
|
285
|
-
balloon.addEventListener('webkitTransitionEnd', transitionEnd, false);
|
286
|
-
balloon.style.opacity = opacity;
|
287
|
-
balloon.style.webkitTransitionDuration = duration;
|
288
|
-
balloon.style.webkitTransform = 'translate3d(' + posX + 'px,' + posY + 'px,0)';
|
289
|
-
}
|
290
|
-
|
291
|
-
|
292
|
-
function clicked () {
|
293
|
-
w.sessionStorage.setItem('addToHomeSession', '1');
|
294
|
-
isSessionActive = true;
|
295
|
-
close();
|
296
|
-
}
|
297
|
-
|
298
|
-
function transitionEnd () {
|
299
|
-
balloon.removeEventListener('webkitTransitionEnd', transitionEnd, false);
|
300
|
-
|
301
|
-
balloon.style.webkitTransitionProperty = '-webkit-transform';
|
302
|
-
balloon.style.webkitTransitionDuration = '0.2s';
|
303
|
-
|
304
|
-
// We reached the end!
|
305
|
-
if ( !closeTimeout ) {
|
306
|
-
balloon.parentNode.removeChild(balloon);
|
307
|
-
balloon = null;
|
308
|
-
return;
|
309
|
-
}
|
310
|
-
|
311
|
-
// On iOS 4 we start checking the element position
|
312
|
-
if ( OSVersion < 5 && closeTimeout ) positionInterval = setInterval(setPosition, options.iterations);
|
313
|
-
}
|
314
|
-
|
315
|
-
function setPosition () {
|
316
|
-
var matrix = new WebKitCSSMatrix(w.getComputedStyle(balloon, null).webkitTransform),
|
317
|
-
posY = isIPad ? w.scrollY - startY : w.scrollY + w.innerHeight - startY,
|
318
|
-
posX = isIPad ? w.scrollX - startX : w.scrollX + Math.round((w.innerWidth - balloon.offsetWidth) / 2) - startX;
|
319
|
-
|
320
|
-
// Screen didn't move
|
321
|
-
if ( posY == matrix.m42 && posX == matrix.m41 ) return;
|
322
|
-
|
323
|
-
balloon.style.webkitTransform = 'translate3d(' + posX + 'px,' + posY + 'px,0)';
|
324
|
-
}
|
325
|
-
|
326
|
-
// Clear local and session storages (this is useful primarily in development)
|
327
|
-
function reset () {
|
328
|
-
w.localStorage.removeItem('addToHome');
|
329
|
-
w.sessionStorage.removeItem('addToHomeSession');
|
330
|
-
}
|
331
|
-
|
332
|
-
function orientationCheck () {
|
333
|
-
balloon.style.marginLeft = -Math.round(balloon.offsetWidth / 2) - ( w.orientation%180 && OSVersion >= 6 && OSVersion < 7 ? 40 : 0 ) + 'px';
|
334
|
-
}
|
335
|
-
|
336
|
-
// Bootstrap!
|
337
|
-
init();
|
338
|
-
|
339
|
-
return {
|
340
|
-
show: manualShow,
|
341
|
-
close: close,
|
342
|
-
reset: reset
|
343
|
-
};
|
344
|
-
})(window);
|