summaryrefslogtreecommitdiff
path: root/resources/jquery/jquery.delayedBind.js
diff options
context:
space:
mode:
Diffstat (limited to 'resources/jquery/jquery.delayedBind.js')
-rw-r--r--resources/jquery/jquery.delayedBind.js29
1 files changed, 16 insertions, 13 deletions
diff --git a/resources/jquery/jquery.delayedBind.js b/resources/jquery/jquery.delayedBind.js
index d84ee267..5d32b6b0 100644
--- a/resources/jquery/jquery.delayedBind.js
+++ b/resources/jquery/jquery.delayedBind.js
@@ -1,4 +1,4 @@
-(function( $ ) {
+( function ( $ ) {
/**
* Function that escapes spaces in event names. This is needed because
* "_delayedBind-foo bar-1000" refers to two events
@@ -18,25 +18,26 @@ $.fn.extend( {
* @param data Data to pass to the event handler (optional)
* @param callback Function to call
*/
- delayedBind: function( timeout, event, data, callback ) {
- if ( arguments.length == 3 ) {
+ delayedBind: function ( timeout, event, data, callback ) {
+ if ( arguments.length === 3 ) {
// Shift optional parameter down
callback = data;
data = undefined;
}
var encEvent = encodeEvent( event );
- return this.each( function() {
+ return this.each( function () {
var that = this;
// Bind the top half
// Do this only once for every (event, timeout) pair
if ( !( $(this).data( '_delayedBindBound-' + encEvent + '-' + timeout ) ) ) {
$(this).data( '_delayedBindBound-' + encEvent + '-' + timeout, true );
- $(this).bind( event, function() {
+ $(this).bind( event, function () {
var timerID = $(this).data( '_delayedBindTimerID-' + encEvent + '-' + timeout );
// Cancel the running timer
- if ( typeof timerID != 'undefined' )
+ if ( timerID !== null ) {
clearTimeout( timerID );
- timerID = setTimeout( function() {
+ }
+ timerID = setTimeout( function () {
$(that).trigger( '_delayedBind-' + encEvent + '-' + timeout );
}, timeout );
$(this).data( '_delayedBindTimerID-' + encEvent + '-' + timeout, timerID );
@@ -51,23 +52,25 @@ $.fn.extend( {
/**
* Cancel the timers for delayed events on the selected elements.
*/
- delayedBindCancel: function( timeout, event ) {
+ delayedBindCancel: function ( timeout, event ) {
var encEvent = encodeEvent( event );
- return this.each( function() {
+ return this.each( function () {
var timerID = $(this).data( '_delayedBindTimerID-' + encEvent + '-' + timeout );
- if ( typeof timerID != 'undefined' )
+ if ( timerID !== null ) {
clearTimeout( timerID );
+ }
} );
},
/**
* Unbind an event bound with delayedBind()
*/
- delayedBindUnbind: function( timeout, event, callback ) {
+ delayedBindUnbind: function ( timeout, event, callback ) {
var encEvent = encodeEvent( event );
- return this.each( function() {
+ return this.each( function () {
$(this).unbind( '_delayedBind-' + encEvent + '-' + timeout, callback );
} );
}
} );
-} )( jQuery ); \ No newline at end of file
+
+}( jQuery ) );