added SingleDoubleClick

This commit is contained in:
jeena 2013-04-14 13:51:36 +02:00
parent be8a0c63e3
commit bb5b38fb4f

View file

@ -0,0 +1,30 @@
define([
"jquery"
],
function(jQuery) {
// Author: Jacek Becela
// Source: http://gist.github.com/399624
// License: MIT
jQuery.fn.single_double_click = function(single_click_callback, double_click_callback, timeout) {
return this.each(function(){
var clicks = 0, self = this;
jQuery(this).click(function(event){
clicks++;
if (clicks == 1) {
setTimeout(function(){
if(clicks == 1) {
single_click_callback.call(self, event);
} else {
double_click_callback.call(self, event);
}
clicks = 0;
}, timeout || 300);
}
});
});
}
})