Fix JQMIGRATE warnings in jQuery Mobile

jQuery Mobile 1.5 is supposed to be compatible with jQuery 3, but it isn't...

* Replace .bind() calls with .on()
* Replace .unbind() calls with .off()

Bug: T165816
Change-Id: I79639fd9ae8e6e785f93191273147866e52c4ed1
isekai
Bartosz Dziewoński 8 years ago
parent fc5b4be51c
commit f11212f7bd

@ -1,3 +1,7 @@
// Custom hacks:
// * Replaced .bind() calls with .on() for compatibility with jQuery 3
// * Replaced .unbind() calls with .off() for compatibility with jQuery 3
/*
* jQuery Mobile v1.4.5
* http://jquerymobile.com
@ -366,14 +370,14 @@ function getSpecialEventObject( eventType ) {
activeDocHandlers[ eventType ] = ( activeDocHandlers[ eventType ] || 0 ) + 1;
if ( activeDocHandlers[ eventType ] === 1 ) {
$document.bind( realType, mouseEventCallback );
$document.on( realType, mouseEventCallback );
}
// Some browsers, like Opera Mini, won't dispatch mouse/click events
// for elements unless they actually have handlers registered on them.
// To get around this, we register dummy handlers on the elements.
$( this ).bind( realType, dummyMouseHandler );
$( this ).on( realType, dummyMouseHandler );
// For now, if event capture is not supported, we rely on mouse handlers.
if ( eventCaptureSupported ) {
@ -383,8 +387,8 @@ function getSpecialEventObject( eventType ) {
activeDocHandlers[ "touchstart" ] = ( activeDocHandlers[ "touchstart" ] || 0) + 1;
if ( activeDocHandlers[ "touchstart" ] === 1 ) {
$document.bind( "touchstart", handleTouchStart )
.bind( "touchend", handleTouchEnd )
$document.on( "touchstart", handleTouchStart )
.on( "touchend", handleTouchEnd )
// On touch platforms, touching the screen and then dragging your finger
// causes the window content to scroll after some distance threshold is
@ -396,8 +400,8 @@ function getSpecialEventObject( eventType ) {
// we need to watch both scroll and touchmove events to figure out whether
// or not a scroll happenens before the touchend event is fired.
.bind( "touchmove", handleTouchMove )
.bind( "scroll", handleScroll );
.on( "touchmove", handleTouchMove )
.on( "scroll", handleScroll );
}
}
},
@ -409,7 +413,7 @@ function getSpecialEventObject( eventType ) {
--activeDocHandlers[ eventType ];
if ( !activeDocHandlers[ eventType ] ) {
$document.unbind( realType, mouseEventCallback );
$document.off( realType, mouseEventCallback );
}
if ( eventCaptureSupported ) {
@ -419,10 +423,10 @@ function getSpecialEventObject( eventType ) {
--activeDocHandlers[ "touchstart" ];
if ( !activeDocHandlers[ "touchstart" ] ) {
$document.unbind( "touchstart", handleTouchStart )
.unbind( "touchmove", handleTouchMove )
.unbind( "touchend", handleTouchEnd )
.unbind( "scroll", handleScroll );
$document.off( "touchstart", handleTouchStart )
.off( "touchmove", handleTouchMove )
.off( "touchend", handleTouchEnd )
.off( "scroll", handleScroll );
}
}
@ -440,7 +444,7 @@ function getSpecialEventObject( eventType ) {
// Unregister the dummy event handler.
$this.unbind( realType, dummyMouseHandler );
$this.off( realType, dummyMouseHandler );
// If this is the last virtual mouse binding on the
// element, remove the binding data from the element.
@ -552,7 +556,7 @@ if ( eventCaptureSupported ) {
"scrollstart scrollstop" ).split( " " ), function( i, name ) {
$.fn[ name ] = function( fn ) {
return fn ? this.bind( name, fn ) : this.trigger( name );
return fn ? this.on( name, fn ) : this.trigger( name );
};
// jQuery < 1.8
@ -589,7 +593,7 @@ if ( eventCaptureSupported ) {
}
// iPhone triggers scroll after a small delay; use touchmove instead
$this.bind( scrollEvent, function( event ) {
$this.on( scrollEvent, function( event ) {
if ( !$.event.special.scrollstart.enabled ) {
return;
@ -606,7 +610,7 @@ if ( eventCaptureSupported ) {
});
},
teardown: function() {
$( this ).unbind( scrollEvent );
$( this ).off( scrollEvent );
}
};
@ -619,7 +623,7 @@ if ( eventCaptureSupported ) {
$this = $( thisObject ),
isTaphold = false;
$this.bind( "vmousedown", function( event ) {
$this.on( "vmousedown", function( event ) {
isTaphold = false;
if ( event.which && event.which !== 1 ) {
return false;
@ -635,9 +639,9 @@ if ( eventCaptureSupported ) {
function clearTapHandlers() {
clearTapTimer();
$this.unbind( "vclick", clickHandler )
.unbind( "vmouseup", clearTapTimer );
$document.unbind( "vmousecancel", clearTapHandlers );
$this.off( "vclick", clickHandler )
.off( "vmouseup", clearTapTimer );
$document.off( "vmousecancel", clearTapHandlers );
}
function clickHandler( event ) {
@ -652,9 +656,9 @@ if ( eventCaptureSupported ) {
}
}
$this.bind( "vmouseup", clearTapTimer )
.bind( "vclick", clickHandler );
$document.bind( "vmousecancel", clearTapHandlers );
$this.on( "vmouseup", clearTapTimer )
.on( "vclick", clickHandler );
$document.on( "vmousecancel", clearTapHandlers );
timer = setTimeout( function() {
if ( !$.event.special.tap.emitTapOnTaphold ) {
@ -665,8 +669,8 @@ if ( eventCaptureSupported ) {
});
},
teardown: function() {
$( this ).unbind( "vmousedown" ).unbind( "vclick" ).unbind( "vmouseup" );
$document.unbind( "vmousecancel" );
$( this ).off( "vmousedown" ).off( "vclick" ).off( "vmouseup" );
$document.off( "vmousecancel" );
}
};
@ -850,10 +854,10 @@ if ( eventCaptureSupported ) {
$.event.special[ event ] = {
setup: function() {
$( this ).bind( sourceEvent, $.noop );
$( this ).on( sourceEvent, $.noop );
},
teardown: function() {
$( this ).unbind( sourceEvent );
$( this ).off( sourceEvent );
}
};
});

Loading…
Cancel
Save