;(function($,window,documnet){
function registerLongPressEvent(target,cbk,timeInterval) {
var timer;
var evt = document.createEvent('Event');
evt .initEvent('longPress', true, true);
target.addEventListener('mousedown', function() {
timer=setTimeout(function(){
target.dispatchEvent(evt);
},timeInterval);
}, false);
target.addEventListener('mouseup', function() {
clearTimeout(timer);
}, false);
target.addEventListener('longPress',cbk, false);
}
$.fn.addEvent=function(name,cbk){
return this.each(function(){
var $this=$(this);
cbk=cbk||function(){};
switch (name){
case 'longPress':
registerLongPressEvent($this[0],cbk,1000);
break;
default:
break;
}
});
}
$.fn.longPress=function(cbk){
return this.each(function(){
var $this=$(this);
cbk=cbk||function(){};
registerLongPressEvent($this[0],cbk,1000);
});
}
})(jQuery,window,document,undefined);