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 */ 5var 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: 7000, // 15 seconds before it is automatically destroyed 32 bottomOffset: 14, // Distance of the balloon from bottom 33 expire: 5, // Minutes to wait before showing the popup again (0 = always displayed) 34 message: '', // Customize your message or force a language ('' = automatic) 35 touchIcon: true, // 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>
69æ·»å è³ä¸»å±å¹</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);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.