1 line
No EOL
1.3 KiB
JavaScript
1 line
No EOL
1.3 KiB
JavaScript
(function(f){var l=f.fn.click;f.fn.click=function q(x,w){if(!w){return l.apply(this,arguments)}return f(this).data(t,x||null).bind(b,w)};f.fn.longclick=function n(){var w=[].splice.call(arguments,0),x=w.pop(),z=w.pop(),y=f(this).data(t,z||null);return x?y.click(z,x):y.trigger(b)};f.longclick={duration:600};f.event.special.longclick={setup:function(x,w){if(!(/iphone|ipad|ipod/i).test(navigator.userAgent)){f(this).bind(d,s).bind([a,c,h,i].join(" "),o).bind(v,q)}else{j(this).bind(r,s).bind([e,u,p].join(" "),o).bind(v,q).css({WebkitUserSelect:"none"})}},teardown:function(w){f(this).unbind(m)}};function j(w){f.each("touchstart touchmove touchend touchcancel".split(/ /),function x(y,z){w.addEventListener(z,function A(B){f(w).trigger(z)},false)});return f(w)}function s(y){if(f(this).data(g)){return}var x=this,w=arguments;f(this).data(k,false).data(g,setTimeout(z,f(this).data(t)||f.longclick.duration));function z(){f(x).data(k,true);y.type=b;jQuery.event.handle.apply(x,w)}}function o(w){f(this).data(g,clearTimeout(f(this).data(g))||null)}function q(w){if(f(this).data(k)){return w.stopImmediatePropagation()||false}}var b="longclick",m="."+b,d="mousedown"+m,v="click"+m,a="mousemove"+m,c="mouseup"+m,h="mouseout"+m,i="contextmenu"+m,r="touchstart"+m,e="touchend"+m,u="touchmove"+m,p="touchcancel"+m,t="duration"+m,g="timer"+m,k="fired"+m})(jQuery); |