(event)
| 10 | } |
| 11 | |
| 12 | function tripleHandler(event) |
| 13 | { |
| 14 | var $elem = jQuery(this); |
| 15 | |
| 16 | // Merge the defaults and any user defined settings. |
| 17 | settings = jQuery.extend({}, defaults, event.data); |
| 18 | |
| 19 | // Get current values, or 0 if they don't yet exist. |
| 20 | var clicks = $elem.data("triclick_clicks") || 0; |
| 21 | var start = $elem.data("triclick_start") || 0; |
| 22 | |
| 23 | // If first click, register start time. |
| 24 | if (clicks === 0) { start = event.timeStamp; } |
| 25 | |
| 26 | // If we have a start time, check it's within limit |
| 27 | if (start != 0 |
| 28 | && event.timeStamp > start + settings.threshold) |
| 29 | { |
| 30 | // Tri-click failed, took too long. |
| 31 | clicks = 0; |
| 32 | start = event.timeStamp; |
| 33 | } |
| 34 | |
| 35 | // Increment counter, and do finish action. |
| 36 | clicks += 1; |
| 37 | if (clicks === 3) |
| 38 | { |
| 39 | clicks = 0; |
| 40 | start = 0; |
| 41 | event.type = "tripleclick"; |
| 42 | |
| 43 | // Let jQuery handle the triggering of "tripleclick" event handlers |
| 44 | if (jQuery.event.handle === undefined) { |
| 45 | jQuery.event.dispatch.apply(this, arguments); |
| 46 | } |
| 47 | else { |
| 48 | // for jQuery before 1.9 |
| 49 | jQuery.event.handle.apply(this, arguments); |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | // Update object data |
| 54 | $elem.data("triclick_clicks", clicks); |
| 55 | $elem.data("triclick_start", start); |
| 56 | } |
| 57 | |
| 58 | var tripleclick = $.event.special.tripleclick = |
| 59 | { |
nothing calls this directly
no outgoing calls
no test coverage detected