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 * JavaScript for WikiEditor Dialogs
*/ */
jQuery( document ).ready( function ( $ ) { jQuery( function ( $ ) {
if ( !$.wikiEditor.isSupported( $.wikiEditor.modules.dialogs ) ) { if ( !$.wikiEditor.isSupported( $.wikiEditor.modules.dialogs ) ) {
return; return;
} }

View file

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

View file

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

View file

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

View file

@ -245,7 +245,7 @@
.data( 'tooltip-mode', true ); .data( 'tooltip-mode', true );
} }
} ) } )
.focus( function () { .on( 'focus', function () {
if ( $( this ).val() === $( this ).data( 'tooltip' ) ) { if ( $( this ).val() === $( this ).data( 'tooltip' ) ) {
$( this ) $( this )
.val( '' ) .val( '' )
@ -253,14 +253,14 @@
.data( 'tooltip-mode', false ); .data( 'tooltip-mode', false );
} }
} ) } )
.bind( 'change', function () { .on( 'change', function () {
if ( $( this ).val() !== $( this ).data( 'tooltip' ) ) { if ( $( this ).val() !== $( this ).data( 'tooltip' ) ) {
$( this ) $( this )
.removeClass( 'wikieditor-toolbar-dialog-hint' ) .removeClass( 'wikieditor-toolbar-dialog-hint' )
.data( 'tooltip-mode', false ); .data( 'tooltip-mode', false );
} }
} ) } )
.bind( 'blur', function () { .on( 'blur', function () {
if ( $( this ).val() === '' ) { if ( $( this ).val() === '' ) {
$( this ) $( this )
.addClass( 'wikieditor-toolbar-dialog-hint' ) .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 // 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 // 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 // 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 // $( this ).val() is the old value, before the keypress - Defer this until $( this ).val() has
// been updated // been updated
setTimeout( function () { setTimeout( function () {
@ -300,7 +300,7 @@
} }
}, 0 ); }, 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(), var oldVal = $( this ).val(),
that = this; that = this;
setTimeout( function () { setTimeout( function () {
@ -345,7 +345,7 @@
.children().hide(); .children().hide();
$( '#wikieditor-toolbar-link-int-target' ) $( '#wikieditor-toolbar-link-int-target' )
.bind( 'keyup paste cut', function () { .on( 'keyup paste cut', function () {
var timerID; var timerID;
// Cancel the running timer if applicable // Cancel the running timer if applicable
if ( typeof $( this ).data( 'timerID' ) !== 'undefined' ) { if ( typeof $( this ).data( 'timerID' ) !== 'undefined' ) {
@ -356,7 +356,7 @@
timerID = setTimeout( updateExistence, 120 ); timerID = setTimeout( updateExistence, 120 );
$( this ).data( 'timerID', timerID ); $( this ).data( 'timerID', timerID );
} ) } )
.change( function () { .on( 'change', function () {
// Cancel the running timer if applicable // Cancel the running timer if applicable
if ( typeof $( this ).data( 'timerID' ) !== 'undefined' ) { if ( typeof $( this ).data( 'timerID' ) !== 'undefined' ) {
clearTimeout( $( this ).data( 'timerID' ) ); clearTimeout( $( this ).data( 'timerID' ) );
@ -1250,7 +1250,7 @@
textbox = context.$textarea; textbox = context.$textarea;
$( textbox ) $( textbox )
.bind( 'keypress.srdialog', function ( e ) { .on( 'keypress.srdialog', function ( e ) {
var button; var button;
if ( e.which === 13 ) { if ( e.which === 13 ) {
// Enter // Enter

View file

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