added SingleDoubleClick
This commit is contained in:
parent
be8a0c63e3
commit
bb5b38fb4f
1 changed files with 30 additions and 0 deletions
30
WebKit/scripts/lib/SingleDoubleClick.js
Normal file
30
WebKit/scripts/lib/SingleDoubleClick.js
Normal 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);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
})
|
Reference in a new issue