diff --git a/src/js/_enqueues/admin/application-passwords.js b/src/js/_enqueues/admin/application-passwords.js index b1a20ceb8e..7901ac901b 100644 --- a/src/js/_enqueues/admin/application-passwords.js +++ b/src/js/_enqueues/admin/application-passwords.js @@ -15,7 +15,7 @@ tmplAppPassRow = wp.template( 'application-password-row' ), userId = $( '#user_id' ).val(); - $newAppPassButton.click( function( e ) { + $newAppPassButton.on( 'click', function( e ) { e.preventDefault(); if ( $newAppPassButton.prop( 'aria-disabled' ) ) { diff --git a/src/js/_enqueues/admin/comment.js b/src/js/_enqueues/admin/comment.js index fcf703bf07..d815eee184 100644 --- a/src/js/_enqueues/admin/comment.js +++ b/src/js/_enqueues/admin/comment.js @@ -29,11 +29,11 @@ jQuery(document).ready( function($) { * @param {Event} event The event object. * @return {void} */ - $edittimestamp.click( function( event ) { + $edittimestamp.on( 'click', function( event ) { if ( $timestampdiv.is( ':hidden' ) ) { // Slide down the form and set focus on the first field. $timestampdiv.slideDown( 'fast', function() { - $( 'input, select', $timestampwrap ).first().focus(); + $( 'input, select', $timestampwrap ).first().trigger( 'focus' ); } ); $(this).hide(); } @@ -49,9 +49,9 @@ jQuery(document).ready( function($) { * @return {void} */ - $timestampdiv.find('.cancel-timestamp').click( function( event ) { + $timestampdiv.find('.cancel-timestamp').on( 'click', function( event ) { // Move focus back to the Edit link. - $edittimestamp.show().focus(); + $edittimestamp.show().trigger( 'focus' ); $timestampdiv.slideUp( 'fast' ); $('#mm').val($('#hidden_mm').val()); $('#jj').val($('#hidden_jj').val()); @@ -70,7 +70,7 @@ jQuery(document).ready( function($) { * @param {Event} event The event object. * @return {void} */ - $timestampdiv.find('.save-timestamp').click( function( event ) { // Crazyhorse - multiple OK cancels. + $timestampdiv.find('.save-timestamp').on( 'click', function( event ) { // Crazyhorse - multiple OK cancels. var aa = $('#aa').val(), mm = $('#mm').val(), jj = $('#jj').val(), hh = $('#hh').val(), mn = $('#mn').val(), newD = new Date( aa, mm - 1, jj, hh, mn ); @@ -96,7 +96,7 @@ jQuery(document).ready( function($) { ); // Move focus back to the Edit link. - $edittimestamp.show().focus(); + $edittimestamp.show().trigger( 'focus' ); $timestampdiv.slideUp( 'fast' ); }); }); diff --git a/src/js/_enqueues/admin/common.js b/src/js/_enqueues/admin/common.js index 2a037d81db..f0807f989e 100644 --- a/src/js/_enqueues/admin/common.js +++ b/src/js/_enqueues/admin/common.js @@ -382,7 +382,7 @@ window.columns = { */ init : function() { var that = this; - $('.hide-column-tog', '#adv-settings').click( function() { + $('.hide-column-tog', '#adv-settings').on( 'click', function() { var $t = $(this), column = $t.val(); if ( $t.prop('checked') ) that.checked(column); @@ -500,7 +500,7 @@ window.validateForm = function( form ) { .filter( function() { return $( ':input:visible', this ).val() === ''; } ) .addClass( 'form-invalid' ) .find( ':input:visible' ) - .change( function() { $( this ).closest( '.form-invalid' ).removeClass( 'form-invalid' ); } ) + .on( 'change', function() { $( this ).closest( '.form-invalid' ).removeClass( 'form-invalid' ); } ) .length; }; @@ -571,7 +571,7 @@ window.screenMeta = { this.toggles = $( '#screen-meta-links' ).find( '.show-settings' ); this.page = $('#wpcontent'); - this.toggles.click( this.toggleEvent ); + this.toggles.on( 'click', this.toggleEvent ); }, /** @@ -617,7 +617,7 @@ window.screenMeta = { * @return {void} */ panel.slideDown( 'fast', function() { - panel.focus(); + panel.trigger( 'focus' ); button.addClass( 'screen-meta-active' ).attr( 'aria-expanded', true ); }); @@ -659,7 +659,7 @@ window.screenMeta = { * * @return {void} */ -$('.contextual-help-tabs').delegate('a', 'click', function(e) { +$('.contextual-help-tabs').on( 'click', 'a', function(e) { var link = $(this), panel; @@ -798,7 +798,7 @@ $availableStructureTags.on( 'click', function() { if ( permalinkStructureFocused && $permalinkStructure[0].setSelectionRange ) { newSelectionStart = ( permalinkStructureValue.substr( 0, selectionStart ) + textToAppend ).length; $permalinkStructure[0].setSelectionRange( newSelectionStart, newSelectionStart ); - $permalinkStructure.focus(); + $permalinkStructure.trigger( 'focus' ); } } ); @@ -1302,7 +1302,7 @@ $document.ready( function() { $( this ).closest( 'tr' ).toggleClass( 'is-expanded' ); }); - $('#default-password-nag-no').click( function() { + $('#default-password-nag-no').on( 'click', function() { setUserSetting('default_password_nag', 'hide'); $('div.default-password-nag').hide(); return false; @@ -1315,7 +1315,7 @@ $document.ready( function() { * * @return {void} */ - $('#newcontent').bind('keydown.wpevent_InsertTab', function(e) { + $('#newcontent').on('keydown.wpevent_InsertTab', function(e) { var el = e.target, selStart, selEnd, val, scroll, sel; // After pressing escape key (keyCode: 27), the tab key should tab out of the textarea. @@ -1374,7 +1374,7 @@ $document.ready( function() { * * @return {void} */ - pageInput.closest('form').submit( function() { + pageInput.closest('form').on( 'submit', function() { /* * action = bulk action dropdown at the top of the table */ @@ -1388,7 +1388,7 @@ $document.ready( function() { * * @return {void} */ - $('.search-box input[type="search"], .search-box input[type="submit"]').mousedown(function () { + $('.search-box input[type="search"], .search-box input[type="submit"]').on( 'mousedown', function () { $('select[name^="action"]').val('-1'); }); @@ -1689,7 +1689,7 @@ $document.ready( function() { $wpwrap.toggleClass( 'wp-responsive-open' ); if ( $wpwrap.hasClass( 'wp-responsive-open' ) ) { $(this).find('a').attr( 'aria-expanded', 'true' ); - $( '#adminmenu a:first' ).focus(); + $( '#adminmenu a:first' ).trigger( 'focus' ); } else { $(this).find('a').attr( 'aria-expanded', 'false' ); } @@ -1978,7 +1978,7 @@ $document.ready( function() { $document.on( 'wp-pin-menu wp-window-resized.pin-menu postboxes-columnchange.pin-menu postbox-toggled.pin-menu wp-collapse-menu.pin-menu wp-scroll-start.pin-menu', setPinMenu ); // Set initial focus on a specific element. - $( '.wp-initial-focus' ).focus(); + $( '.wp-initial-focus' ).trigger( 'focus' ); // Toggle update details on update-core.php. $body.on( 'click', '.js-update-details-toggle', function() { diff --git a/src/js/_enqueues/admin/edit-comments.js b/src/js/_enqueues/admin/edit-comments.js index 0dc393ef02..6c9c2520b9 100644 --- a/src/js/_enqueues/admin/edit-comments.js +++ b/src/js/_enqueues/admin/edit-comments.js @@ -445,7 +445,7 @@ window.setCommentsList = function() { a.attr('class', 'vim-z vim-destructive aria-button-if-js'); $('.avatar', el).first().clone().prependTo('#undo-' + id + ' .' + action + '-undo-inside'); - a.click(function( e ){ + a.on( 'click', function( e ){ e.preventDefault(); e.stopPropagation(); // Ticket #35904. list.wpList.del(this); @@ -762,7 +762,7 @@ window.setCommentsList = function() { * @global */ window.theList = $('#the-comment-list').wpList( { alt: '', delBefore: delBefore, dimAfter: dimAfter, delAfter: delAfter, addColor: 'none' } ) - .bind('wpListDelEnd', function(e, s){ + .on('wpListDelEnd', function(e, s){ var wpListsData = $(s.target).attr('data-wp-lists'), id = s.element.replace(/[^0-9]+/g, ''); if ( wpListsData.indexOf(':trash=1') != -1 || wpListsData.indexOf(':spam=1') != -1 ) @@ -793,9 +793,9 @@ window.commentReply = { init : function() { var row = $('#replyrow'); - $( '.cancel', row ).click( function() { return commentReply.revert(); } ); - $( '.save', row ).click( function() { return commentReply.send(); } ); - $( 'input#author-name, input#author-email, input#author-url', row ).keypress( function( e ) { + $( '.cancel', row ).on( 'click', function() { return commentReply.revert(); } ); + $( '.save', row ).on( 'click', function() { return commentReply.send(); } ); + $( 'input#author-name, input#author-email, input#author-url', row ).on( 'keypress', function( e ) { if ( e.which == 13 ) { commentReply.send(); e.preventDefault(); @@ -804,11 +804,11 @@ window.commentReply = { }); // Add events. - $('#the-comment-list .column-comment > p').dblclick(function(){ + $('#the-comment-list .column-comment > p').on( 'dblclick', function(){ commentReply.toggle($(this).parent()); }); - $('#doaction, #post-query-submit').click(function(){ + $('#doaction, #post-query-submit').on( 'click', function(){ if ( $('#the-comment-list #replyrow').length > 0 ) commentReply.close(); }); @@ -831,7 +831,7 @@ window.commentReply = { */ addEvents : function(r) { r.each(function() { - $(this).find('.column-comment > p').dblclick(function(){ + $(this).find('.column-comment > p').on( 'dblclick', function(){ commentReply.toggle($(this).parent()); }); }); @@ -905,7 +905,7 @@ window.commentReply = { .show() .find( '.vim-q' ) .attr( 'aria-expanded', 'false' ) - .focus(); + .trigger( 'focus' ); } ).css( 'backgroundColor', '' ); } @@ -913,7 +913,7 @@ window.commentReply = { if ( 'replyto-comment' === this.act ) { commentRow.find( '.vim-r' ) .attr( 'aria-expanded', 'false' ) - .focus(); + .trigger( 'focus' ); } // Reset the Quicktags buttons. @@ -1032,7 +1032,7 @@ window.commentReply = { else if ( rtop - 20 < scrollTop ) window.scroll(0, rtop - 35); - $('#replycontent').focus().keyup(function(e){ + $('#replycontent').trigger( 'focus' ).on( 'keyup', function(e){ if ( e.which == 27 ) commentReply.revert(); // Close on Escape. }); @@ -1135,7 +1135,8 @@ window.commentReply = { updateCountText( 'span.all-count', 1 ); } - c = $.trim(r.data); // Trim leading whitespaces. + r.data = r.data || ''; + c = r.data.toString().trim(); // Trim leading whitespaces. $(c).hide(); $('#replyrow').after(c); diff --git a/src/js/_enqueues/admin/inline-edit-post.js b/src/js/_enqueues/admin/inline-edit-post.js index 8205963fc3..70c5996496 100644 --- a/src/js/_enqueues/admin/inline-edit-post.js +++ b/src/js/_enqueues/admin/inline-edit-post.js @@ -51,7 +51,7 @@ window.wp = window.wp || {}; * * @return {boolean} The result of revert. */ - qeRow.keyup(function(e){ + qeRow.on( 'keyup', function(e){ // Revert changes if Escape key is pressed. if ( e.which === 27 ) { return inlineEditPost.revert(); @@ -63,7 +63,7 @@ window.wp = window.wp || {}; * * @return {boolean} The result of revert. */ - bulkRow.keyup(function(e){ + bulkRow.on( 'keyup', function(e){ // Revert changes if Escape key is pressed. if ( e.which === 27 ) { return inlineEditPost.revert(); @@ -75,7 +75,7 @@ window.wp = window.wp || {}; * * @return {boolean} The result of revert. */ - $( '.cancel', qeRow ).click( function() { + $( '.cancel', qeRow ).on( 'click', function() { return inlineEditPost.revert(); }); @@ -84,7 +84,7 @@ window.wp = window.wp || {}; * * @return {boolean} The result of save. */ - $( '.save', qeRow ).click( function() { + $( '.save', qeRow ).on( 'click', function() { return inlineEditPost.save(this); }); @@ -93,7 +93,7 @@ window.wp = window.wp || {}; * * @return {boolean} The result of save. */ - $('td', qeRow).keydown(function(e){ + $('td', qeRow).on( 'keydown', function(e){ if ( e.which === 13 && ! $( e.target ).hasClass( 'cancel' ) ) { return inlineEditPost.save(this); } @@ -104,14 +104,14 @@ window.wp = window.wp || {}; * * @return {boolean} The result of revert. */ - $( '.cancel', bulkRow ).click( function() { + $( '.cancel', bulkRow ).on( 'click', function() { return inlineEditPost.revert(); }); /** * Disables the password input field when the private post checkbox is checked. */ - $('#inline-edit .inline-edit-private input[value="private"]').click( function(){ + $('#inline-edit .inline-edit-private input[value="private"]').on( 'click', function(){ var pw = $('input.inline-edit-password-input'); if ( $(this).prop('checked') ) { pw.val('').prop('disabled', true); @@ -139,7 +139,7 @@ window.wp = window.wp || {}; /** * Adds onclick events to the apply buttons. */ - $('#doaction').click(function(e){ + $('#doaction').on( 'click', function(e){ var n; t.whichBulkButtonId = $( this ).attr( 'id' ); @@ -215,7 +215,7 @@ window.wp = window.wp || {}; * * @listens click */ - $('#bulk-titles a').click(function(){ + $('#bulk-titles a').on( 'click', function(){ var id = $(this).attr('id').substr(1); $('table.widefat input[value="' + id + '"]').prop('checked', false); @@ -383,7 +383,7 @@ window.wp = window.wp || {}; } $(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show(); - $('.ptitle', editRow).focus(); + $('.ptitle', editRow).trigger( 'focus' ); return false; }, @@ -434,7 +434,7 @@ window.wp = window.wp || {}; // Move focus back to the Quick Edit button. $( this ) is the row being animated. $( this ).find( '.editinline' ) .attr( 'aria-expanded', 'false' ) - .focus(); + .trigger( 'focus' ); wp.a11y.speak( wp.i18n.__( 'Changes saved.' ) ); }); } else { @@ -481,7 +481,7 @@ window.wp = window.wp || {}; $('#inlineedit').append( $('#bulk-edit') ); // Move focus back to the Bulk Action button that was activated. - $( '#' + inlineEditPost.whichBulkButtonId ).focus(); + $( '#' + inlineEditPost.whichBulkButtonId ).trigger( 'focus' ); } else { // Remove both the inline-editor and its hidden tr siblings. @@ -491,7 +491,7 @@ window.wp = window.wp || {}; // Show the post row and move focus back to the Quick Edit button. $( this.what + id ).show().find( '.editinline' ) .attr( 'aria-expanded', 'false' ) - .focus(); + .trigger( 'focus' ); } } diff --git a/src/js/_enqueues/admin/inline-edit-tax.js b/src/js/_enqueues/admin/inline-edit-tax.js index b49f6c59b1..f8b52d63e7 100644 --- a/src/js/_enqueues/admin/inline-edit-tax.js +++ b/src/js/_enqueues/admin/inline-edit-tax.js @@ -47,7 +47,7 @@ window.inlineEditTax = { * * @param {Object} e The keyup event that has been triggered. */ - row.keyup( function( e ) { + row.on( 'keyup', function( e ) { // 27 = [Escape]. if ( e.which === 27 ) { return inlineEditTax.revert(); @@ -57,21 +57,21 @@ window.inlineEditTax = { /** * Cancels inline editing when clicking the cancel button. */ - $( '.cancel', row ).click( function() { + $( '.cancel', row ).on( 'click', function() { return inlineEditTax.revert(); }); /** * Saves the inline edits when clicking the save button. */ - $( '.save', row ).click( function() { + $( '.save', row ).on( 'click', function() { return inlineEditTax.save(this); }); /** * Saves the inline edits when pressing Enter inside the inline editor. */ - $( 'input, select', row ).keydown( function( e ) { + $( 'input, select', row ).on( 'keydown', function( e ) { // 13 = [Enter]. if ( e.which === 13 ) { return inlineEditTax.save( this ); @@ -81,7 +81,7 @@ window.inlineEditTax = { /** * Saves the inline edits on submitting the inline edit form. */ - $( '#posts-filter input[type="submit"]' ).mousedown( function() { + $( '#posts-filter input[type="submit"]' ).on( 'mousedown', function() { t.revert(); }); }, @@ -143,7 +143,7 @@ window.inlineEditTax = { $(':input[name="slug"]', editRow).val( val ); $(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show(); - $('.ptitle', editRow).eq(0).focus(); + $('.ptitle', editRow).eq(0).trigger( 'focus' ); return false; }, @@ -223,7 +223,7 @@ window.inlineEditTax = { // Move focus back to the Quick Edit button. row.find( '.editinline' ) .attr( 'aria-expanded', 'false' ) - .focus(); + .trigger( 'focus' ); wp.a11y.speak( wp.i18n.__( 'Changes saved.' ) ); }); @@ -268,7 +268,7 @@ window.inlineEditTax = { // Show the taxonomy row and move focus back to the Quick Edit button. $( this.what + id ).show().find( '.editinline' ) .attr( 'aria-expanded', 'false' ) - .focus(); + .trigger( 'focus' ); } }, diff --git a/src/js/_enqueues/admin/media-upload.js b/src/js/_enqueues/admin/media-upload.js index 1a28f36d04..fb620464bb 100644 --- a/src/js/_enqueues/admin/media-upload.js +++ b/src/js/_enqueues/admin/media-upload.js @@ -108,6 +108,6 @@ window.send_to_editor = function( html ) { }; // Add handler to recalculates the ThickBox position when the window is resized. - $(window).resize(function(){ tb_position(); }); + $(window).on( 'resize', function(){ tb_position(); }); })(jQuery); diff --git a/src/js/_enqueues/admin/media.js b/src/js/_enqueues/admin/media.js index e34718b466..97310d2a63 100644 --- a/src/js/_enqueues/admin/media.js +++ b/src/js/_enqueues/admin/media.js @@ -158,13 +158,13 @@ } // Prevents form submission if no post has been selected. - $( '#find-posts-submit' ).click( function( event ) { + $( '#find-posts-submit' ).on( 'click', function( event ) { if ( ! $( '#find-posts-response input[type="radio"]:checked' ).length ) event.preventDefault(); }); // Submits the search query when hitting the enter key in the search input. - $( '#find-posts .find-box-search :input' ).keypress( function( event ) { + $( '#find-posts .find-box-search :input' ).on( 'keypress', function( event ) { if ( 13 == event.which ) { findPosts.send(); return false; @@ -172,13 +172,13 @@ }); // Binds the click event to the search button. - $( '#find-posts-search' ).click( findPosts.send ); + $( '#find-posts-search' ).on( 'click', findPosts.send ); // Binds the close dialog click event. - $( '#find-posts-close' ).click( findPosts.close ); + $( '#find-posts-close' ).on( 'click', findPosts.close ); // Binds the bulk action events to the submit buttons. - $( '#doaction' ).click( function( event ) { + $( '#doaction' ).on( 'click', function( event ) { /* * Handle the bulk action based on its value. diff --git a/src/js/_enqueues/admin/plugin-install.js b/src/js/_enqueues/admin/plugin-install.js index df273b48dd..7ff803519a 100644 --- a/src/js/_enqueues/admin/plugin-install.js +++ b/src/js/_enqueues/admin/plugin-install.js @@ -50,7 +50,7 @@ jQuery( document ).ready( function( $ ) { }); }; - $( window ).resize( function() { + $( window ).on( 'resize', function() { tb_position(); }); @@ -185,7 +185,7 @@ jQuery( document ).ready( function( $ ) { }); /* Plugin install related JS */ - $( '#plugin-information-tabs a' ).click( function( event ) { + $( '#plugin-information-tabs a' ).on( 'click', function( event ) { var tab = $( this ).attr( 'name' ); event.preventDefault(); diff --git a/src/js/_enqueues/admin/post.js b/src/js/_enqueues/admin/post.js index 0c95258348..c2feb8a174 100644 --- a/src/js/_enqueues/admin/post.js +++ b/src/js/_enqueues/admin/post.js @@ -213,7 +213,7 @@ window.wp = window.wp || {}; } wrap.show().find('.currently-editing').text( received.lock_error.text ); - wrap.find('.wp-tab-first').focus(); + wrap.find('.wp-tab-first').trigger( 'focus' ); } } else if ( received.new_lock ) { $('#active_post_lock').val( received.new_lock ); @@ -327,14 +327,14 @@ jQuery(document).ready( function($) { // [Shift] + [Tab] on first tab cycles back to last tab. if ( target.hasClass('wp-tab-first') && e.shiftKey ) { - $(this).find('.wp-tab-last').focus(); + $(this).find('.wp-tab-last').trigger( 'focus' ); e.preventDefault(); // [Tab] on last tab cycles back to first tab. } else if ( target.hasClass('wp-tab-last') && ! e.shiftKey ) { - $(this).find('.wp-tab-first').focus(); + $(this).find('.wp-tab-first').trigger( 'focus' ); e.preventDefault(); } - }).filter(':visible').find('.wp-tab-first').focus(); + }).filter(':visible').find('.wp-tab-first').trigger( 'focus' ); // Set the heartbeat interval to 15 seconds if post lock dialogs are enabled. if ( wp.heartbeat && $('#post-lock-dialog').length ) { @@ -437,7 +437,7 @@ jQuery(document).ready( function($) { if ( editor && ! editor.isHidden() ) { editor.focus(); } else if ( $textarea.length ) { - $textarea.focus(); + $textarea.trigger( 'focus' ); } else { return; } @@ -578,7 +578,7 @@ jQuery(document).ready( function($) { } // @todo Move to jQuery 1.3+, support for multiple hierarchical taxonomies, see wp-lists.js. - $('a', '#' + taxonomy + '-tabs').click( function( e ) { + $('a', '#' + taxonomy + '-tabs').on( 'click', function( e ) { e.preventDefault(); var t = $(this).attr('href'); $(this).parent().addClass('tabs').siblings('li').removeClass('tabs'); @@ -608,8 +608,8 @@ jQuery(document).ready( function($) { }); // After submitting a new taxonomy, re-focus the input field. - $('#' + taxonomy + '-add-submit').click( function() { - $('#new' + taxonomy).focus(); + $('#' + taxonomy + '-add-submit').on( 'click', function() { + $('#new' + taxonomy).trigger( 'focus' ); }); /** @@ -658,11 +658,11 @@ jQuery(document).ready( function($) { }); // Add new taxonomy button toggles input form visibility. - $('#' + taxonomy + '-add-toggle').click( function( e ) { + $('#' + taxonomy + '-add-toggle').on( 'click', function( e ) { e.preventDefault(); $('#' + taxonomy + '-adder').toggleClass( 'wp-hidden-children' ); $('a[href="#' + taxonomy + '-all"]', '#' + taxonomy + '-tabs').click(); - $('#new'+taxonomy).focus(); + $('#new'+taxonomy).trigger( 'focus' ); }); // Sync checked items between "All {taxonomy}" and "Most used" lists. @@ -834,35 +834,35 @@ jQuery(document).ready( function($) { }; // Show the visibility options and hide the toggle button when opened. - $( '#visibility .edit-visibility').click( function( e ) { + $( '#visibility .edit-visibility').on( 'click', function( e ) { e.preventDefault(); if ( $postVisibilitySelect.is(':hidden') ) { updateVisibility(); $postVisibilitySelect.slideDown( 'fast', function() { - $postVisibilitySelect.find( 'input[type="radio"]' ).first().focus(); + $postVisibilitySelect.find( 'input[type="radio"]' ).first().trigger( 'focus' ); } ); $(this).hide(); } }); // Cancel visibility selection area and hide it from view. - $postVisibilitySelect.find('.cancel-post-visibility').click( function( event ) { + $postVisibilitySelect.find('.cancel-post-visibility').on( 'click', function( event ) { $postVisibilitySelect.slideUp('fast'); $('#visibility-radio-' + $('#hidden-post-visibility').val()).prop('checked', true); $('#post_password').val($('#hidden-post-password').val()); $('#sticky').prop('checked', $('#hidden-post-sticky').prop('checked')); $('#post-visibility-display').html(visibility); - $('#visibility .edit-visibility').show().focus(); + $('#visibility .edit-visibility').show().trigger( 'focus' ); updateText(); event.preventDefault(); }); // Set the selected visibility as current. - $postVisibilitySelect.find('.save-post-visibility').click( function( event ) { // Crazyhorse - multiple OK cancels. + $postVisibilitySelect.find('.save-post-visibility').on( 'click', function( event ) { // Crazyhorse - multiple OK cancels. var visibilityLabel = '', selectedVisibility = $postVisibilitySelect.find('input:radio:checked').val(); $postVisibilitySelect.slideUp('fast'); - $('#visibility .edit-visibility').show().focus(); + $('#visibility .edit-visibility').show().trigger( 'focus' ); updateText(); if ( 'public' !== selectedVisibility ) { @@ -886,15 +886,15 @@ jQuery(document).ready( function($) { }); // When the selection changes, update labels. - $postVisibilitySelect.find('input:radio').change( function() { + $postVisibilitySelect.find('input:radio').on( 'change', function() { updateVisibility(); }); // Edit publish time click. - $timestampdiv.siblings('a.edit-timestamp').click( function( event ) { + $timestampdiv.siblings('a.edit-timestamp').on( 'click', function( event ) { if ( $timestampdiv.is( ':hidden' ) ) { $timestampdiv.slideDown( 'fast', function() { - $( 'input, select', $timestampdiv.find( '.timestamp-wrap' ) ).first().focus(); + $( 'input, select', $timestampdiv.find( '.timestamp-wrap' ) ).first().trigger( 'focus' ); } ); $(this).hide(); } @@ -902,8 +902,8 @@ jQuery(document).ready( function($) { }); // Cancel editing the publish time and hide the settings. - $timestampdiv.find('.cancel-timestamp').click( function( event ) { - $timestampdiv.slideUp('fast').siblings('a.edit-timestamp').show().focus(); + $timestampdiv.find('.cancel-timestamp').on( 'click', function( event ) { + $timestampdiv.slideUp('fast').siblings('a.edit-timestamp').show().trigger( 'focus' ); $('#mm').val($('#hidden_mm').val()); $('#jj').val($('#hidden_jj').val()); $('#aa').val($('#hidden_aa').val()); @@ -914,10 +914,10 @@ jQuery(document).ready( function($) { }); // Save the changed timestamp. - $timestampdiv.find('.save-timestamp').click( function( event ) { // Crazyhorse - multiple OK cancels. + $timestampdiv.find('.save-timestamp').on( 'click', function( event ) { // Crazyhorse - multiple OK cancels. if ( updateText() ) { $timestampdiv.slideUp('fast'); - $timestampdiv.siblings('a.edit-timestamp').show().focus(); + $timestampdiv.siblings('a.edit-timestamp').show().trigger( 'focus' ); } event.preventDefault(); }); @@ -937,10 +937,10 @@ jQuery(document).ready( function($) { }); // Post Status edit click. - $postStatusSelect.siblings('a.edit-post-status').click( function( event ) { + $postStatusSelect.siblings('a.edit-post-status').on( 'click', function( event ) { if ( $postStatusSelect.is( ':hidden' ) ) { $postStatusSelect.slideDown( 'fast', function() { - $postStatusSelect.find('select').focus(); + $postStatusSelect.find('select').trigger( 'focus' ); } ); $(this).hide(); } @@ -948,15 +948,15 @@ jQuery(document).ready( function($) { }); // Save the Post Status changes and hide the options. - $postStatusSelect.find('.save-post-status').click( function( event ) { - $postStatusSelect.slideUp( 'fast' ).siblings( 'a.edit-post-status' ).show().focus(); + $postStatusSelect.find('.save-post-status').on( 'click', function( event ) { + $postStatusSelect.slideUp( 'fast' ).siblings( 'a.edit-post-status' ).show().trigger( 'focus' ); updateText(); event.preventDefault(); }); // Cancel Post Status editing and hide the options. - $postStatusSelect.find('.cancel-post-status').click( function( event ) { - $postStatusSelect.slideUp( 'fast' ).siblings( 'a.edit-post-status' ).show().focus(); + $postStatusSelect.find('.cancel-post-status').on( 'click', function( event ) { + $postStatusSelect.slideUp( 'fast' ).siblings( 'a.edit-post-status' ).show().trigger( 'focus' ); $('#post_status').val( $('#hidden_post_status').val() ); updateText(); event.preventDefault(); @@ -997,7 +997,7 @@ jQuery(document).ready( function($) { buttons.html( ' ' ); // Save permalink changes. - buttons.children( '.save' ).click( function() { + buttons.children( '.save' ).on( 'click', function() { var new_slug = $el.children( 'input' ).val(); if ( new_slug == $('#editable-post-name-full').text() ) { @@ -1026,20 +1026,20 @@ jQuery(document).ready( function($) { buttons.html(buttonsOrig); permalink.html(permalinkOrig); real_slug.val(new_slug); - $( '.edit-slug' ).focus(); + $( '.edit-slug' ).trigger( 'focus' ); wp.a11y.speak( __( 'Permalink saved' ) ); } ); }); // Cancel editing of permalink. - buttons.children( '.cancel' ).click( function() { + buttons.children( '.cancel' ).on( 'click', function() { $('#view-post-btn').show(); $el.html(revert_e); buttons.html(buttonsOrig); permalink.html(permalinkOrig); real_slug.val(revert_slug); - $( '.edit-slug' ).focus(); + $( '.edit-slug' ).trigger( 'focus' ); }); // If more than 1/4th of 'full' is '%', make it empty. @@ -1049,7 +1049,7 @@ jQuery(document).ready( function($) { } slug_value = ( c > full.length / 4 ) ? '' : full; - $el.html( '' ).children( 'input' ).keydown( function( e ) { + $el.html( '' ).children( 'input' ).on( 'keydown', function( e ) { var key = e.which; // On [Enter], just save the new slug, don't save the post. if ( 13 === key ) { @@ -1060,9 +1060,9 @@ jQuery(document).ready( function($) { if ( 27 === key ) { buttons.children( '.cancel' ).click(); } - } ).keyup( function() { + } ).on( 'keyup', function() { real_slug.val( this.value ); - }).focus(); + }).trigger( 'focus' ); } $( '#titlediv' ).on( 'click', '.edit-slug', function() { @@ -1154,7 +1154,7 @@ jQuery(document).ready( function($) { height = parseInt( $('#content_ifr').css('height'), 10 ) + toolbarHeight - 28; } else { - $textarea.focus(); + $textarea.trigger( 'focus' ); height = parseInt( $textarea.css('height'), 10 ); } diff --git a/src/js/_enqueues/admin/postbox.js b/src/js/_enqueues/admin/postbox.js index 7ae595e3ef..c4958c126a 100644 --- a/src/js/_enqueues/admin/postbox.js +++ b/src/js/_enqueues/admin/postbox.js @@ -67,9 +67,9 @@ } if ( id ) { - if ( !p.hasClass('closed') && $.isFunction( postboxes.pbshow ) ) { + if ( !p.hasClass('closed') && typeof postboxes.pbshow === 'function' ) { postboxes.pbshow( id ); - } else if ( p.hasClass('closed') && $.isFunction( postboxes.pbhide ) ) { + } else if ( p.hasClass('closed') && typeof postboxes.pbhide === 'function' ) { postboxes.pbhide( id ); } } @@ -267,7 +267,7 @@ /** * @since 2.7.0 */ - $('.postbox .hndle a').click( function(e) { + $('.postbox .hndle a').on( 'click', function(e) { e.stopPropagation(); }); @@ -302,19 +302,19 @@ * * @return {void} */ - $('.hide-postbox-tog').bind('click.postboxes', function() { + $('.hide-postbox-tog').on('click.postboxes', function() { var $el = $(this), boxId = $el.val(), $postbox = $( '#' + boxId ); if ( $el.prop( 'checked' ) ) { $postbox.show(); - if ( $.isFunction( postboxes.pbshow ) ) { + if ( typeof postboxes.pbshow === 'function' ) { postboxes.pbshow( boxId ); } } else { $postbox.hide(); - if ( $.isFunction( postboxes.pbhide ) ) { + if ( typeof postboxes.pbhide === 'function' ) { postboxes.pbhide( boxId ); } } @@ -336,7 +336,7 @@ * * @return {void} */ - $('.columns-prefs input[type="radio"]').bind('click.postboxes', function(){ + $('.columns-prefs input[type="radio"]').on('click.postboxes', function(){ var n = parseInt($(this).val(), 10); if ( n ) { @@ -420,7 +420,7 @@ }); if ( isMobile ) { - $(document.body).bind('orientationchange.postboxes', function(){ postboxes._pb_change(); }); + $(document.body).on('orientationchange.postboxes', function(){ postboxes._pb_change(); }); this._pb_change(); } diff --git a/src/js/_enqueues/admin/privacy-tools.js b/src/js/_enqueues/admin/privacy-tools.js index 0a491addb8..96084dc47d 100644 --- a/src/js/_enqueues/admin/privacy-tools.js +++ b/src/js/_enqueues/admin/privacy-tools.js @@ -56,7 +56,7 @@ jQuery( document ).ready( function( $ ) { }); } - $( '.export-personal-data-handle' ).click( function( event ) { + $( '.export-personal-data-handle' ).on( 'click', function( event ) { var $this = $( this ), $action = $this.parents( '.export-personal-data' ), $requestRow = $this.parents( 'tr' ), @@ -159,7 +159,7 @@ jQuery( document ).ready( function( $ ) { doNextExport( 1, 1 ); }); - $( '.remove-personal-data-handle' ).click( function( event ) { + $( '.remove-personal-data-handle' ).on( 'click', function( event ) { var $this = $( this ), $action = $this.parents( '.remove-personal-data' ), $requestRow = $this.parents( 'tr' ), diff --git a/src/js/_enqueues/admin/site-health.js b/src/js/_enqueues/admin/site-health.js index 9bba750094..1112f9adac 100644 --- a/src/js/_enqueues/admin/site-health.js +++ b/src/js/_enqueues/admin/site-health.js @@ -205,7 +205,7 @@ jQuery( document ).ready( function( $ ) { val = 100; } - pct = ( ( 100 - val ) / 100 ) * c; + pct = ( ( 100 - val ) / 100 ) * c + 'px'; $circle.css( { strokeDashoffset: pct } ); diff --git a/src/js/_enqueues/admin/tags.js b/src/js/_enqueues/admin/tags.js index a0708b3f42..6c4b8b7a2e 100644 --- a/src/js/_enqueues/admin/tags.js +++ b/src/js/_enqueues/admin/tags.js @@ -98,7 +98,7 @@ jQuery(document).ready(function($) { * * @return {boolean} Always returns false to cancel the default event handling. */ - $('#submit').click(function(){ + $('#submit').on( 'click', function(){ var form = $(this).parents('form'); if ( ! validateForm( form ) ) diff --git a/src/js/_enqueues/admin/user-profile.js b/src/js/_enqueues/admin/user-profile.js index 54e331bf1d..df17620f48 100644 --- a/src/js/_enqueues/admin/user-profile.js +++ b/src/js/_enqueues/admin/user-profile.js @@ -108,7 +108,7 @@ $weakRow = $( '.pw-weak' ); $weakCheckbox = $weakRow.find( '.pw-checkbox' ); - $weakCheckbox.change( function() { + $weakCheckbox.on( 'change', function() { $submitButtons.prop( 'disabled', ! $weakCheckbox.prop( 'checked' ) ); } ); @@ -265,12 +265,12 @@ $( '#pass1' ).val( '' ).on( 'input' + ' pwupdate', check_pass_strength ); $('#pass-strength-result').show(); - $('.color-palette').click( function() { + $('.color-palette').on( 'click', function() { $(this).siblings('input[name="admin_color"]').prop('checked', true); }); if ( select.length ) { - $('#first_name, #last_name, #nickname').bind( 'blur.user_profile', function() { + $('#first_name, #last_name, #nickname').on( 'blur.user_profile', function() { var dub = [], inputs = { display_nickname : $('#nickname').val() || '', diff --git a/src/js/_enqueues/admin/widgets.js b/src/js/_enqueues/admin/widgets.js index ed956157eb..d560811511 100644 --- a/src/js/_enqueues/admin/widgets.js +++ b/src/js/_enqueues/admin/widgets.js @@ -36,7 +36,7 @@ window.wpWidgets = { * Toggle the widgets containers when clicked and update the toggle * button `aria-expanded` attribute value. */ - .click( function() { + .on( 'click', function() { var $this = $( this ), $wrap = $this.closest( '.widgets-holder-wrap '), $toggle = $this.find( '.handlediv' ); @@ -101,7 +101,7 @@ window.wpWidgets = { }); // Handle the widgets containers in the left column. - $( '#widgets-left .sidebar-name' ).click( function() { + $( '#widgets-left .sidebar-name' ).on( 'click', function() { var $wrap = $( this ).closest( '.widgets-holder-wrap' ); $wrap @@ -112,7 +112,7 @@ window.wpWidgets = { $document.triggerHandler( 'wp-pin-menu' ); }); - $(document.body).bind('click.widgets-toggle', function(e) { + $(document.body).on('click.widgets-toggle', function(e) { var target = $(e.target), css = {}, widget, inside, targetWidth, widgetWidth, margin, saveButton, widgetId, toggleBtn = target.closest( '.widget' ).find( '.widget-top button.widget-action' ); @@ -419,7 +419,7 @@ window.wpWidgets = { // Area Chooser. $( '#widgets-right .widgets-holder-wrap' ).each( function( index, element ) { var $element = $( element ), - name = $element.find( '.sidebar-name h2' ).text(), + name = $element.find( '.sidebar-name h2' ).text() || '', ariaLabel = $element.find( '.sidebar-name' ).data( 'add-to' ), id = $element.find( '.widgets-sortables' ).attr( 'id' ), li = $( '