You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
1.2 KiB
JavaScript

5 years ago
(function(){var a={tap:function(f,d){if("ontouchstart" in window){}else{this.tap=this.clickFun;this.clickFun(f,d);return}var e=0,c=0;f.addEventListener("touchstart",function(g){e=g.touches[0].clientX;c=g.touches[0].clientY});f.addEventListener("touchend",function(i){var h=i.changedTouches[0].clientX;var g=i.changedTouches[0].clientY;if(Math.abs(h-e)<5&&Math.abs(g-c)<5){d.call(f,i)}})},clickFun:function(d,c){d.addEventListener("click",function(f){c.call(d,f)})}, isBtn:function(d){ var h=document.getElementsByTagName('html')[0]; while(d!=h && d){ if(d.getAttribute('type') == 'btn' || d.nodeName.toLowerCase()=='a'){ return d; } d=d.parentNode; } return false; } ,touchHover:function(e,f){var d=e.className;f=!f?"press":f;e.className=d+" "+f;document.addEventListener("touchend",c,false);document.addEventListener("touchmove",c,false);function c(){e.className=d;document.removeEventListener("touchmove",c,false);document.removeEventListener("touchend",c,false)}}};var b=document.getElementsByTagName("html")[0];b.addEventListener("touchstart",function(d){var c=d.target;a.touchHover(a.isBtn(c))},false);a.tap(b,function(d){var c=d.target;if(a.isBtn(c)&&a.isBtn(c).getAttribute("href")){window.location=a.isBtn(c).getAttribute("href")}})}());