From bb5b38fb4f8b762a279e55ec95004cec61f31637 Mon Sep 17 00:00:00 2001 From: jeena Date: Sun, 14 Apr 2013 13:51:36 +0200 Subject: [PATCH] added SingleDoubleClick --- WebKit/scripts/lib/SingleDoubleClick.js | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 WebKit/scripts/lib/SingleDoubleClick.js diff --git a/WebKit/scripts/lib/SingleDoubleClick.js b/WebKit/scripts/lib/SingleDoubleClick.js new file mode 100644 index 0000000..4577ddb --- /dev/null +++ b/WebKit/scripts/lib/SingleDoubleClick.js @@ -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); + } + }); + }); +} + +}) \ No newline at end of file