add-to-homescreen-rails 2.0.4 → 2.0.5

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.4"
5
+ VERSION = "2.0.5"
6
6
  end
7
7
  end
8
8
  end
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Add to Homescreen v2.0.4 ~ Copyright (c) 2012 Matteo Spinelli, http://cubiq.org
2
+ * Add to Homescreen v2.0.5 ~ 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) {
@@ -35,10 +35,12 @@ var addToHome = (function (w) {
35
35
  touchIcon: false, // Display the touch icon
36
36
  arrow: true, // Display the balloon arrow
37
37
  hookOnLoad: true, // Should we hook to onload event? (really advanced usage)
38
+ closeButton: true, // Let the user close the balloon
38
39
  iterations: 100 // Internal/debug use
39
40
  },
40
41
 
41
42
  intl = {
43
+ ar: '<span dir="rtl">قم بتثبيت هذا التطبيق على <span dir="ltr">%device:</span>انقر<span dir="ltr">%icon</span> ،<strong>ثم اضفه الى الشاشة الرئيسية.</strong></span>',
42
44
  ca_es: 'Per instal·lar aquesta aplicació al vostre %device premeu %icon i llavors <strong>Afegir a pantalla d\'inici</strong>.',
43
45
  cs_cz: 'Pro instalaci aplikace na Váš %device, stiskněte %icon a v nabídce <strong>Přidat na plochu</strong>.',
44
46
  da_dk: 'Tilføj denne side til din %device: tryk på %icon og derefter <strong>Føj til hjemmeskærm</strong>.',
@@ -55,14 +57,14 @@ var addToHome = (function (w) {
55
57
  ja_jp: 'このウェブアプリをあなたの%deviceにインストールするには%iconをタップして<strong>ホーム画面に追加</strong>を選んでください。',
56
58
  ko_kr: '%device에 웹앱을 설치하려면 %icon을 터치 후 "홈화면에 추가"를 선택하세요',
57
59
  nb_no: 'Installer denne appen på din %device: trykk på %icon og deretter <strong>Legg til på Hjem-skjerm</strong>',
58
- nl_nl: 'Installeer deze webapp op uw %device: tik %icon en dan <strong>Zet in beginscherm</strong>.',
60
+ nl_nl: 'Installeer deze webapp op uw %device: tik %icon en dan <strong>Voeg toe aan beginscherm</strong>.',
59
61
  pl_pl: 'Aby zainstalować tę aplikacje na %device: naciśnij %icon a następnie <strong>Dodaj jako ikonę</strong>.',
60
- pt_br: 'Instale este web app em seu %device: aperte %icon e selecione <strong>Adicionar à Tela Inicio</strong>.',
62
+ pt_br: 'Instale este aplicativo em seu %device: aperte %icon e selecione <strong>Adicionar à Tela Inicio</strong>.',
61
63
  pt_pt: 'Para instalar esta aplicação no seu %device, prima o %icon e depois o <strong>Adicionar ao ecrã principal</strong>.',
62
64
  ru_ru: 'Установите это веб-приложение на ваш %device: нажмите %icon, затем <strong>Добавить в «Домой»</strong>.',
63
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>.',
64
66
  th_th: 'ติดตั้งเว็บแอพฯ นี้บน %device ของคุณ: แตะ %icon และ <strong>เพิ่มที่หน้าจอโฮม</strong>',
65
- tr_tr: '%device için bu uygulamayı kurduktan sonra %icon simgesine dokunarak <strong>Ana Ekrana Ekle</strong>yin.',
67
+ tr_tr: 'Bu uygulamayı %device\'a eklemek için %icon simgesine sonrasında <strong>Ana Ekrana Ekle</strong> düğmesine basın.',
66
68
  zh_cn: '您可以将此应用程式安装到您的 %device 上。请按 %icon 然后点选<strong>添加至主屏幕</strong>。',
67
69
  zh_tw: '您可以將此應用程式安裝到您的 %device 上。請按 %icon 然後點選<strong>加入主畫面螢幕</strong>。'
68
70
  };
@@ -72,6 +74,7 @@ var addToHome = (function (w) {
72
74
  if ( !isIDevice ) return;
73
75
 
74
76
  var now = Date.now(),
77
+ title,
75
78
  i;
76
79
 
77
80
  // Merge local with global options
@@ -111,10 +114,7 @@ var addToHome = (function (w) {
111
114
 
112
115
  if ( !overrideChecks && ( !isSafari || !isExpired || isSessionActive || isStandalone || !isReturningVisitor ) ) return;
113
116
 
114
- var icons = options.touchIcon ? document.querySelectorAll('head link[rel=apple-touch-icon],head link[rel=apple-touch-icon-precomposed]') : [],
115
- sizes,
116
- touchIcon = '',
117
- closeButton,
117
+ var touchIcon = '',
118
118
  platform = nav.platform.split(' ')[0],
119
119
  language = nav.language.replace('-', '_'),
120
120
  i, l;
@@ -132,37 +132,29 @@ var addToHome = (function (w) {
132
132
  options.message = language in intl ? intl[language] : intl['en_us'];
133
133
  }
134
134
 
135
- // Search for the apple-touch-icon
136
- if ( icons.length ) {
137
- for ( i = 0, l = icons.length; i < l; i++ ) {
138
- sizes = icons[i].getAttribute('sizes');
135
+ if ( options.touchIcon ) {
136
+ 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"]');
139
139
 
140
- if ( sizes ) {
141
- if ( isRetina && sizes == '114x114' ) {
142
- touchIcon = icons[i].href;
143
- break;
144
- }
145
- } else {
146
- touchIcon = icons[i].href;
147
- }
140
+ if ( touchIcon ) {
141
+ alert(touchIcon.href)
142
+ touchIcon = '<span style="background-image:url(' + touchIcon.href + ')" class="addToHomeTouchIcon"></span>';
148
143
  }
149
-
150
- touchIcon = '<span style="background-image:url(' + touchIcon + ')" class="addToHomeTouchIcon"></span>';
151
144
  }
152
145
 
153
146
  balloon.className = (isIPad ? 'addToHomeIpad' : 'addToHomeIphone') + (touchIcon ? ' addToHomeWide' : '');
154
147
  balloon.innerHTML = touchIcon +
155
148
  options.message.replace('%device', platform).replace('%icon', OSVersion >= 4.2 ? '<span class="addToHomeShare"></span>' : '<span class="addToHomePlus">+</span>') +
156
149
  (options.arrow ? '<span class="addToHomeArrow"></span>' : '') +
157
- '<span class="addToHomeClose">\u00D7</span>';
150
+ (options.closeButton ? '<span class="addToHomeClose">\u00D7</span>' : '');
158
151
 
159
152
  document.body.appendChild(balloon);
160
153
 
161
154
  // Add the close action
162
- closeButton = balloon.querySelector('.addToHomeClose');
163
- if ( closeButton ) closeButton.addEventListener('click', clicked, false);
155
+ if ( options.closeButton ) balloon.addEventListener('click', clicked, false);
164
156
 
165
- if ( !isIPad && OSVersion > 5 ) window.addEventListener('orientationchange', orientationCheck, false);
157
+ if ( !isIPad && OSVersion >= 6 ) window.addEventListener('orientationchange', orientationCheck, false);
166
158
 
167
159
  setTimeout(show, options.startDelay);
168
160
  }
@@ -206,7 +198,7 @@ var addToHome = (function (w) {
206
198
  balloon.style.top = startY - balloon.offsetHeight - options.bottomOffset + 'px';
207
199
  } else {
208
200
  balloon.style.left = '50%';
209
- balloon.style.marginLeft = -Math.round(balloon.offsetWidth / 2) - ( w.orientation%180 && OSVersion > 5 ? 40 : 0 ) + 'px';
201
+ balloon.style.marginLeft = -Math.round(balloon.offsetWidth / 2) - ( w.orientation%180 && OSVersion >= 6 ? 40 : 0 ) + 'px';
210
202
  balloon.style.bottom = options.bottomOffset + 'px';
211
203
  }
212
204
 
@@ -249,11 +241,10 @@ var addToHome = (function (w) {
249
241
  var posY = 0,
250
242
  posX = 0,
251
243
  opacity = '1',
252
- duration = '0',
253
- closeButton = balloon.querySelector('.addToHomeClose');
244
+ duration = '0';
254
245
 
255
- if ( closeButton ) closeButton.removeEventListener('click', close, false);
256
- if ( !isIPad && OSVersion > 5 ) window.removeEventListener('orientationchange', orientationCheck, false);
246
+ if ( options.closeButton ) balloon.removeEventListener('click', close, false);
247
+ if ( !isIPad && OSVersion >= 6 ) window.removeEventListener('orientationchange', orientationCheck, false);
257
248
 
258
249
  if ( OSVersion < 5 ) {
259
250
  posY = isIPad ? w.scrollY - startY : w.scrollY + w.innerHeight - startY;
@@ -336,7 +327,7 @@ var addToHome = (function (w) {
336
327
  }
337
328
 
338
329
  function orientationCheck () {
339
- balloon.style.marginLeft = -Math.round(balloon.offsetWidth / 2) - ( w.orientation%180 && OSVersion > 5 ? 40 : 0 ) + 'px';
330
+ balloon.style.marginLeft = -Math.round(balloon.offsetWidth / 2) - ( w.orientation%180 && OSVersion >= 6 ? 40 : 0 ) + 'px';
340
331
  }
341
332
 
342
333
  // Bootstrap!
@@ -6,7 +6,11 @@
6
6
  #addToHomeScreen {
7
7
  z-index:9999;
8
8
  -webkit-user-select:none;
9
+ user-select:none;
9
10
  -webkit-box-sizing:border-box;
11
+ box-sizing:border-box;
12
+ -webkit-touch-callout:none;
13
+ touch-callout:none;
10
14
  width:240px;
11
15
  font-size:15px;
12
16
  padding:12px 14px;
@@ -135,14 +139,19 @@
135
139
  display:block;
136
140
  float:left;
137
141
  -webkit-border-radius:6px;
142
+ border-radius:6px;
138
143
  -webkit-box-shadow:0 1px 3px rgba(0,0,0,0.5),
139
144
  inset 0 0 2px rgba(255,255,255,0.9);
145
+ box-shadow:0 1px 3px rgba(0,0,0,0.5),
146
+ inset 0 0 2px rgba(255,255,255,0.9);
140
147
  background-repeat:no-repeat;
141
148
  width:57px; height:57px;
142
149
  -webkit-background-size:57px 57px;
150
+ background-size:57px 57px;
143
151
  margin:0 12px 0 0;
144
152
  border:1px solid #333;
145
153
  -webkit-background-clip:padding-box;
154
+ background-clip:padding-box;
146
155
  }
147
156
 
148
157
 
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
4
+ version: 2.0.5
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: 2012-10-23 00:00:00.000000000 Z
12
+ date: 2013-02-13 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: