Replace deprecated jQuery bind() and size()

> JQMIGRATE: jQuery.fn.bind() is deprecated
> JQMIGRATE: jQuery.fn.size() is deprecated; use the .length property

Note that bind() is not removed in v3, merely deprecated.
Even after the jQuery Migrate phase, it will continue to work.

size() was removed in v3 and works only during the Migrate phase.

https://api.jquery.com/size/
https://api.jquery.com/bind/
https://jquery.com/upgrade-guide/3.0/

Bug: T124742
Change-Id: I6bbd8f829ecf987228c6a5abd32c84e4e088a9bd
This commit is contained in:
Timo Tijhof 2016-11-21 18:22:13 -08:00
parent 841b7b22d6
commit 7769baa56e
6 changed files with 15 additions and 15 deletions

View file

@ -1,7 +1,7 @@
/*
* JavaScript for WikiEditor Dialogs
*/
jQuery( document ).ready( function ( $ ) {
jQuery( function ( $ ) {
if ( !$.wikiEditor.isSupported( $.wikiEditor.modules.dialogs ) ) {
return;
}

View file

@ -1,7 +1,7 @@
/*
* JavaScript for WikiEditor Preview module
*/
jQuery( document ).ready( function ( $ ) {
jQuery( function ( $ ) {
// Add preview module
$( 'textarea#wpTextbox1' ).wikiEditor( 'addModule', 'preview' );
} );

View file

@ -1,7 +1,7 @@
/*
* JavaScript for WikiEditor Publish module
*/
jQuery( document ).ready( function ( $ ) {
jQuery( function ( $ ) {
// Add publish module
$( '#wpTextbox1' ).wikiEditor( 'addModule', 'publish' );
} );

View file

@ -1,7 +1,7 @@
/*
* JavaScript for WikiEditor Toolbar
*/
jQuery( document ).ready( function ( $ ) {
jQuery( function ( $ ) {
if ( !$.wikiEditor.isSupported( $.wikiEditor.modules.toolbar ) ) {
$( '.wikiEditor-oldToolbar' ).show();
return;

View file

@ -245,7 +245,7 @@
.data( 'tooltip-mode', true );
}
} )
.focus( function () {
.on( 'focus', function () {
if ( $( this ).val() === $( this ).data( 'tooltip' ) ) {
$( this )
.val( '' )
@ -253,14 +253,14 @@
.data( 'tooltip-mode', false );
}
} )
.bind( 'change', function () {
.on( 'change', function () {
if ( $( this ).val() !== $( this ).data( 'tooltip' ) ) {
$( this )
.removeClass( 'wikieditor-toolbar-dialog-hint' )
.data( 'tooltip-mode', false );
}
} )
.bind( 'blur', function () {
.on( 'blur', function () {
if ( $( this ).val() === '' ) {
$( this )
.addClass( 'wikieditor-toolbar-dialog-hint' )
@ -272,7 +272,7 @@
// Automatically copy the value of the internal link page title field to the link text field unless the
// user has changed the link text field - this is a convenience thing since most link texts are going to
// be the the same as the page title - Also change the internal/external radio button accordingly
$( '#wikieditor-toolbar-link-int-target' ).bind( 'change keydown paste cut', function () {
$( '#wikieditor-toolbar-link-int-target' ).on( 'change keydown paste cut', function () {
// $( this ).val() is the old value, before the keypress - Defer this until $( this ).val() has
// been updated
setTimeout( function () {
@ -300,7 +300,7 @@
}
}, 0 );
} );
$( '#wikieditor-toolbar-link-int-text' ).bind( 'change keydown paste cut', function () {
$( '#wikieditor-toolbar-link-int-text' ).on( 'change keydown paste cut', function () {
var oldVal = $( this ).val(),
that = this;
setTimeout( function () {
@ -345,7 +345,7 @@
.children().hide();
$( '#wikieditor-toolbar-link-int-target' )
.bind( 'keyup paste cut', function () {
.on( 'keyup paste cut', function () {
var timerID;
// Cancel the running timer if applicable
if ( typeof $( this ).data( 'timerID' ) !== 'undefined' ) {
@ -356,7 +356,7 @@
timerID = setTimeout( updateExistence, 120 );
$( this ).data( 'timerID', timerID );
} )
.change( function () {
.on( 'change', function () {
// Cancel the running timer if applicable
if ( typeof $( this ).data( 'timerID' ) !== 'undefined' ) {
clearTimeout( $( this ).data( 'timerID' ) );
@ -1250,7 +1250,7 @@
textbox = context.$textarea;
$( textbox )
.bind( 'keypress.srdialog', function ( e ) {
.on( 'keypress.srdialog', function ( e ) {
var button;
if ( e.which === 13 ) {
// Enter

View file

@ -141,7 +141,7 @@
// animation, otherwise just change height (breaking any ongoing animation)
$divSections = context.modules.toolbar.$toolbar.find( 'div.sections' );
$visibleSection = $divSections.find( '.section-visible' );
if ( $visibleSection.size() ) {
if ( $visibleSection.length ) {
if ( smooth ) {
$divSections.animate( { height: $visibleSection.outerHeight() }, 'fast' );
} else {
@ -308,7 +308,7 @@
option, optionLabel;
if ( 'filters' in tool ) {
for ( i = 0; i < tool.filters.length; i++ ) {
if ( $( tool.filters[ i ] ).size() === 0 ) {
if ( $( tool.filters[ i ] ).length === 0 ) {
return null;
}
}
@ -769,7 +769,7 @@
var $section;
s.$sections.append( $.wikiEditor.modules.toolbar.fn.buildSection( s.context, s.id, s.config ) );
$section = s.$sections.find( '.section-visible' );
if ( $section.size() ) {
if ( $section.length ) {
$sections.animate( { height: $section.outerHeight() }, $section.outerHeight() * 2, function () {
context.fn.trigger( 'resize' );
} );