-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdeep-link.min.js
21 lines (21 loc) · 3.48 KB
/
deep-link.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*!
* visibly - v0.7 Page Visibility API Polyfill
* http://github.com/addyosmani
* Copyright (c) 2011-2014 Addy Osmani
* Dual licensed under the MIT and GPL licenses.
*
* Methods supported:
* visibly.onVisible(callback)
* visibly.onHidden(callback)
* visibly.hidden()
* visibly.visibilityState()
* visibly.visibilitychange(callback(state));
*/
!function(){window.visibly={q:document,p:void 0,prefixes:["webkit","ms","o","moz","khtml"],props:["VisibilityState","visibilitychange","Hidden"],m:["focus","blur"],visibleCallbacks:[],hiddenCallbacks:[],genericCallbacks:[],_callbacks:[],cachedPrefix:"",fn:null,onVisible:function(i){"function"==typeof i&&this.visibleCallbacks.push(i)},onHidden:function(i){"function"==typeof i&&this.hiddenCallbacks.push(i)},getPrefix:function(){if(!this.cachedPrefix)for(var i=0;b=this.prefixes[i++];)if(b+this.props[2]in this.q)return this.cachedPrefix=b,this.cachedPrefix},visibilityState:function(){return this._getProp(0)},hidden:function(){return this._getProp(2)},visibilitychange:function(i){"function"==typeof i&&this.genericCallbacks.push(i);var t=this.genericCallbacks.length;if(t)if(this.cachedPrefix)for(;t--;)this.genericCallbacks[t].call(this,this.visibilityState());else for(;t--;)this.genericCallbacks[t].call(this,arguments[0])},isSupported:function(){return this._getPropName(2)in this.q},_getPropName:function(i){return""==this.cachedPrefix?this.props[i].substring(0,1).toLowerCase()+this.props[i].substring(1):this.cachedPrefix+this.props[i]},_getProp:function(i){return this.q[this._getPropName(i)]},_execute:function(i){if(i){this._callbacks=1==i?this.visibleCallbacks:this.hiddenCallbacks;for(var t=this._callbacks.length;t--;)this._callbacks[t]()}},_visible:function(){window.visibly._execute(1),window.visibly.visibilitychange.call(window.visibly,"visible")},_hidden:function(){window.visibly._execute(2),window.visibly.visibilitychange.call(window.visibly,"hidden")},_nativeSwitch:function(){this[this._getProp(2)?"_hidden":"_visible"]()},_listen:function(){try{this.isSupported()?this.q.addEventListener(this._getPropName(1),function(){window.visibly._nativeSwitch.apply(window.visibly,arguments)},1):this.q.addEventListener?(window.addEventListener(this.m[0],this._visible,1),window.addEventListener(this.m[1],this._hidden,1)):this.q.attachEvent&&(this.q.attachEvent("onfocusin",this._visible),this.q.attachEvent("onfocusout",this._hidden))}catch(i){}},init:function(){this.getPrefix(),this._listen()}},this.visibly.init()}(),/*!
* Deep-link.js
* https://timseverien.com/projects/deep-link/
*
* Copyright 2014
* Released under MIT license
*/
function(){"use strict";for(var i=1200,t={android:{store_prefix:"https://play.google.com/store/apps/details?id=",test:/Android/i},iOS:{store_prefix:"https://itunes.apple.com/en/app/id",test:/iPhone|iPad|iPod/i}},e=function(){var i;for(i in t)if(navigator.userAgent.match(t[i].test))return i},n=function(){return(new Date).getTime()},s=function(i){window.location.href=i},a=function(a){var o,r,c=e(),h=a.getAttribute("href"),l=a.getAttribute("data-app-"+c)||a.getAttribute("data-app"),d=a.getAttribute("data-store-"+c)||a.getAttribute("data-store");l&&(h||a.setAttribute("href",l),c&&l?a.onclick=function(e){e.preventDefault(),e.stopImmediatePropagation();var a,u=n();o=!0,r=setTimeout(function(){if(o&&r){var e=n();o=!1,r=null,e-u>=2*i||(d?s(t[c].store_prefix+d):h&&s(h))}},i),a=s(l)}:h&&"#"!==h||(a.style.display="none"),visibly.onHidden(function(){o&&r&&(r=clearInterval(r),o=!1)}))},o=document.getElementsByTagName("a"),r=o.length;r--;)a(o[r])}();