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 = $( '
  • ' ), @@ -428,7 +428,7 @@ window.wpWidgets = { 'aria-pressed': 'false', 'class': 'widgets-chooser-button', 'aria-label': ariaLabel - } ).text( $.trim( name ) ); + } ).text( name.toString().trim() ); li.append( button ); diff --git a/src/js/_enqueues/lib/ajax-response.js b/src/js/_enqueues/lib/ajax-response.js index a6fdb3ba8d..ed343a6709 100644 --- a/src/js/_enqueues/lib/ajax-response.js +++ b/src/js/_enqueues/lib/ajax-response.js @@ -66,5 +66,5 @@ window.wpAjax = jQuery.extend( { // Basic form validation. jQuery(document).ready( function($){ - $('form.validate').submit( function() { return wpAjax.validateForm( $(this) ); } ); + $('form.validate').on( 'submit', function() { return wpAjax.validateForm( $(this) ); } ); }); diff --git a/src/js/_enqueues/lib/color-picker.js b/src/js/_enqueues/lib/color-picker.js index 83e7dc663e..6f3d1ce5a5 100644 --- a/src/js/_enqueues/lib/color-picker.js +++ b/src/js/_enqueues/lib/color-picker.js @@ -232,7 +232,7 @@ * * @since 3.5.0 */ - self.toggler.click( function(){ + self.toggler.on( 'click', function(){ if ( self.toggler.hasClass( 'wp-picker-open' ) ) { self.close(); } else { @@ -250,7 +250,7 @@ * * @return {void} */ - self.element.change( function( event ) { + self.element.on( 'change', function( event ) { var me = $( this ), val = me.val(); @@ -272,7 +272,7 @@ * * @return {void} */ - self.button.click( function( event ) { + self.button.on( 'click', function( event ) { var me = $( this ); if ( me.hasClass( 'wp-picker-clear' ) ) { self.element.val( '' ); diff --git a/src/js/_enqueues/lib/link.js b/src/js/_enqueues/lib/link.js index 1dfc1204e1..736485c095 100644 --- a/src/js/_enqueues/lib/link.js +++ b/src/js/_enqueues/lib/link.js @@ -54,14 +54,14 @@ inputs.queryNoticeTextHint = inputs.queryNotice.find( '.query-notice-hint' ); // Bind event handlers. - inputs.dialog.keydown( wpLink.keydown ); - inputs.dialog.keyup( wpLink.keyup ); - inputs.submit.click( function( event ) { + inputs.dialog.on( 'keydown', wpLink.keydown ); + inputs.dialog.on( 'keyup', wpLink.keyup ); + inputs.submit.on( 'click', function( event ) { event.preventDefault(); wpLink.update(); }); - inputs.close.add( inputs.backdrop ).add( '#wp-link-cancel button' ).click( function( event ) { + inputs.close.add( inputs.backdrop ).add( '#wp-link-cancel button' ).on( 'click', function( event ) { event.preventDefault(); wpLink.close(); }); @@ -625,7 +625,7 @@ this.change( search ); this.refresh(); - $( '#wp-link .query-results, #wp-link #link-selector' ).scroll( function() { + $( '#wp-link .query-results, #wp-link #link-selector' ).on( 'scroll', function() { self.maybeLoad(); }); element.on( 'click', 'li', function( event ) { diff --git a/src/js/_enqueues/lib/nav-menu.js b/src/js/_enqueues/lib/nav-menu.js index f6752916d5..03da8bc65b 100644 --- a/src/js/_enqueues/lib/nav-menu.js +++ b/src/js/_enqueues/lib/nav-menu.js @@ -390,7 +390,7 @@ thisItem.shiftHorizontally( 1 ); break; } - $this.focus(); + $this.trigger( 'focus' ); api.registerChange(); api.refreshKeyboardAccessibility(); api.refreshAdvancedAccessibility(); @@ -572,7 +572,7 @@ break; } // Put focus back on same menu item. - $( '#edit-' + thisItemData['menu-item-db-id'] ).focus(); + $( '#edit-' + thisItemData['menu-item-db-id'] ).trigger( 'focus' ); return false; }); }); @@ -608,7 +608,7 @@ // Hide fields. api.menuList.hideAdvancedMenuItemFields(); - $('.hide-postbox-tog').click(function () { + $('.hide-postbox-tog').on( 'click', function () { var hidden = $( '.accordion-container li.accordion-section' ).filter(':hidden').map(function() { return this.id; }).get().join(','); $.post(ajaxurl, { action: 'closed-postboxes', @@ -809,7 +809,7 @@ }, initManageLocations : function () { - $('#menu-locations-wrap form').submit(function(){ + $('#menu-locations-wrap form').on( 'submit', function(){ window.onbeforeunload = null; }); $('.menu-location-menus select').on('change', function () { @@ -823,7 +823,7 @@ attachMenuEditListeners : function() { var that = this; - $('#update-nav-menu').bind('click', function(e) { + $('#update-nav-menu').on('click', function(e) { if ( e.target && e.target.className ) { if ( -1 != e.target.className.indexOf('item-edit') ) { return that.eventOnClickEditLink(e.target); @@ -852,7 +852,7 @@ } }, 500 ) ); - $('#add-custom-links input[type="text"]').keypress(function(e){ + $('#add-custom-links input[type="text"]').on( 'keypress', function(e){ $('#customlinkdiv').removeClass('form-invalid'); if ( e.keyCode === 13 ) { @@ -867,7 +867,7 @@ * When a navigation menu is saved, store a JSON representation of all form data * in a single input to avoid PHP `max_input_vars` limitations. See #14134. */ - $( '#update-nav-menu' ).submit( function() { + $( '#update-nav-menu' ).on( 'submit', function() { var navMenuData = $( '#update-nav-menu' ).serializeArray(); $( '[name="nav-menu-data"]' ).val( JSON.stringify( navMenuData ) ); }); @@ -877,7 +877,7 @@ var loc = $('#nav-menu-theme-locations'), params = {}; params.action = 'menu-locations-save'; params['menu-settings-column-nonce'] = $('#menu-settings-column-nonce').val(); - loc.find('input[type="submit"]').click(function() { + loc.find('input[type="submit"]').on( 'click', function() { loc.find('select').each(function() { params[this.name] = $(this).val(); }); @@ -947,9 +947,13 @@ }, addCustomLink : function( processMethod ) { - var url = $('#custom-menu-item-url').val().trim(), + var url = $('#custom-menu-item-url').val().toString(), label = $('#custom-menu-item-name').val(); + if ( '' !== url ) { + url = url.trim(); + } + processMethod = processMethod || api.addMenuItemToBottom; if ( '' === url || 'https://' == url || 'http://' == url ) { @@ -999,7 +1003,8 @@ $.post( ajaxurl, params, function(menuMarkup) { var ins = $('#menu-instructions'); - menuMarkup = $.trim( menuMarkup ); // Trim leading whitespaces. + menuMarkup = menuMarkup || ''; + menuMarkup = menuMarkup.toString().trim(); // Trim leading whitespaces. processMethod(menuMarkup, params); // Make it stand out a bit more visually, by adding a fadeIn. @@ -1043,7 +1048,7 @@ }, attachUnsavedChangesListener : function() { - $('#menu-management input, #menu-management select, #menu-management, #menu-management textarea, .menu-location-menus select').change(function(){ + $('#menu-management input, #menu-management select, #menu-management, #menu-management textarea, .menu-location-menus select').on( 'change', function(){ api.registerChange(); }); @@ -1063,7 +1068,7 @@ }, attachTabsPanelListeners : function() { - $('#menu-settings-column').bind('click', function(e) { + $('#menu-settings-column').on('click', function(e) { var selectAreaMatch, selectAll, panelId, wrapper, items, target = $(e.target); @@ -1083,7 +1088,7 @@ target.parent().addClass('tabs'); // Select the search bar. - $('.quick-search', wrapper).focus(); + $('.quick-search', wrapper).trigger( 'focus' ); // Hide controls in the search tab if no items found. if ( ! wrapper.find( '.tabs-panel-active .menu-item-title' ).length ) { diff --git a/src/js/_enqueues/vendor/plupload/wp-plupload.js b/src/js/_enqueues/vendor/plupload/wp-plupload.js index 7ac790ec00..809a624776 100644 --- a/src/js/_enqueues/vendor/plupload/wp-plupload.js +++ b/src/js/_enqueues/vendor/plupload/wp-plupload.js @@ -70,7 +70,7 @@ window.wp = window.wp || {}; // Proxy all methods so this always refers to the current instance. for ( key in this ) { - if ( $.isFunction( this[ key ] ) ) { + if ( typeof this[ key ] === 'function' ) { this[ key ] = $.proxy( this[ key ], this ); } } @@ -284,7 +284,7 @@ window.wp = window.wp || {}; } // 'dragenter' doesn't fire correctly, simulate it with a limited 'dragover'. - dropzone.bind( 'dragover.wp-uploader', function() { + dropzone.on( 'dragover.wp-uploader', function() { if ( timer ) { clearTimeout( timer ); } @@ -297,7 +297,7 @@ window.wp = window.wp || {}; active = true; }); - dropzone.bind('dragleave.wp-uploader, drop.wp-uploader', function() { + dropzone.on('dragleave.wp-uploader, drop.wp-uploader', function() { /* * Using an instant timer prevents the drag-over class * from being quickly removed and re-added when elements @@ -440,7 +440,7 @@ window.wp = window.wp || {}; if ( pluploadError.code === plupload[ key ] ) { message = Uploader.errorMap[ key ]; - if ( _.isFunction( message ) ) { + if ( typeof message === 'function' ) { message = message( pluploadError.file, pluploadError ); } diff --git a/src/js/_enqueues/wp/customize/base.js b/src/js/_enqueues/wp/customize/base.js index e6aeb8b641..a088c34386 100644 --- a/src/js/_enqueues/wp/customize/base.js +++ b/src/js/_enqueues/wp/customize/base.js @@ -501,7 +501,7 @@ window.wp = window.wp || {}; dfd = $.Deferred(); // If the last argument is a callback, bind it to .done(). - if ( $.isFunction( ids[ ids.length - 1 ] ) ) { + if ( typeof ids[ ids.length - 1 ] === 'function' ) { dfd.done( ids.pop() ); } @@ -609,7 +609,7 @@ window.wp = window.wp || {}; }; this.bind( this.update ); - this.element.bind( this.events, this.refresh ); + this.element.on( this.events, this.refresh ); }, find: function( selector ) { diff --git a/src/js/_enqueues/wp/customize/controls.js b/src/js/_enqueues/wp/customize/controls.js index 32a8a87cfa..45122597f0 100644 --- a/src/js/_enqueues/wp/customize/controls.js +++ b/src/js/_enqueues/wp/customize/controls.js @@ -1342,10 +1342,10 @@ template = wp.template( 'customize-' + container.containerType + '-default' ); } if ( template && container.container ) { - return $.trim( template( _.extend( + return template( _.extend( { id: container.id }, container.params - ) ) ); + ) ).toString().trim(); } return '
  • '; @@ -1597,7 +1597,7 @@ sectionTitle.attr( 'tabindex', '-1' ); backBtn.attr( 'tabindex', '0' ); - backBtn.focus(); + backBtn.trigger( 'focus' ); content.css( 'top', '' ); container.scrollTop( 0 ); @@ -1645,7 +1645,7 @@ backBtn.attr( 'tabindex', '-1' ); sectionTitle.attr( 'tabindex', '0' ); - sectionTitle.focus(); + sectionTitle.trigger( 'focus' ); content.css( 'top', '' ); if ( args.completeCallback ) { @@ -2734,7 +2734,7 @@ backBtn.attr( 'tabindex', '-1' ); sectionTitle.attr( 'tabindex', '0' ); - sectionTitle.focus(); + sectionTitle.trigger( 'focus' ); content.css( 'top', '' ); if ( args.completeCallback ) { @@ -4485,7 +4485,7 @@ y = control.settings.y.get(); inputValue = String( x ) + ' ' + String( y ); radioInput = control.container.find( 'input[name="background-position"][value="' + inputValue + '"]' ); - radioInput.click(); + radioInput.trigger( 'click' ); } ); control.settings.x.bind( updateRadios ); control.settings.y.bind( updateRadios ); @@ -5452,7 +5452,7 @@ controls = section.controls(); controlIndex = controls.indexOf( control ); if ( controls.length === controlIndex + 1 ) { - $( '#customize-footer-actions .collapse-sidebar' ).focus(); + $( '#customize-footer-actions .collapse-sidebar' ).trigger( 'focus' ); } else { controls[ controlIndex + 1 ].container.find( ':focusable:first' ).focus(); } @@ -6336,7 +6336,7 @@ } ) ); } ); previewFrame.container.append( form ); - form.submit(); + form.trigger( 'submit' ); form.remove(); // No need to keep the form around after submitted. } @@ -7081,7 +7081,7 @@ // Restore focus if there was a reflow and there was an active (focused) element. if ( wasReflowed && activeElement ) { - activeElement.focus(); + activeElement.trigger( 'focus' ); } api.trigger( 'pane-contents-reflowed' ); }, api ); @@ -8397,10 +8397,10 @@ } // Button bindings. - saveBtn.click( function( event ) { + saveBtn.on( 'click', function( event ) { api.previewer.save(); event.preventDefault(); - }).keydown( function( event ) { + }).on( 'keydown', function( event ) { if ( 9 === event.which ) { // Tab. return; } @@ -8410,7 +8410,7 @@ event.preventDefault(); }); - closeBtn.keydown( function( event ) { + closeBtn.on( 'keydown', function( event ) { if ( 9 === event.which ) { // Tab. return; } @@ -8752,7 +8752,8 @@ if ( title.length ) { api( 'blogname', function( setting ) { var updateTitle = function() { - title.text( $.trim( setting() ) || api.l10n.untitledBlogName ); + var blogTitle = setting() || ''; + title.text( blogTitle.toString().trim() || api.l10n.untitledBlogName ); }; setting.bind( updateTitle ); updateTitle(); diff --git a/src/js/_enqueues/wp/customize/nav-menus.js b/src/js/_enqueues/wp/customize/nav-menus.js index 1ae1f3435c..a9033dbd27 100644 --- a/src/js/_enqueues/wp/customize/nav-menus.js +++ b/src/js/_enqueues/wp/customize/nav-menus.js @@ -226,7 +226,7 @@ }); // Load available items if it looks like we'll need them. - api.panel( 'nav_menus' ).container.bind( 'expanded', function() { + api.panel( 'nav_menus' ).container.on( 'expanded', function() { if ( ! self.rendered ) { self.initList(); self.rendered = true; @@ -234,7 +234,7 @@ }); // Load more items. - this.sectionContent.scroll( function() { + this.sectionContent.on( 'scroll', function() { var totalHeight = self.$el.find( '.accordion-section.open .available-menu-items-list' ).prop( 'scrollHeight' ), visibleHeight = self.$el.find( '.accordion-section.open' ).height(); @@ -827,7 +827,7 @@ */ ready: function() { var panel = this; - panel.container.find( '.hide-column-tog' ).click( function() { + panel.container.find( '.hide-column-tog' ).on( 'click', function() { panel.saveManageColumnsState(); }); @@ -3421,7 +3421,7 @@ function displayNavMenuName( name ) { name = name || ''; name = wp.sanitize.stripTagsAndEncodeText( name ); // Remove any potential tags from name. - name = $.trim( name ); + name = name.toString().trim(); return name || api.Menus.data.l10n.unnamed; } diff --git a/src/js/_enqueues/wp/dashboard.js b/src/js/_enqueues/wp/dashboard.js index 1929388d55..cd44854e26 100644 --- a/src/js/_enqueues/wp/dashboard.js +++ b/src/js/_enqueues/wp/dashboard.js @@ -40,7 +40,7 @@ jQuery(document).ready( function($) { } // Hide the welcome panel when the dismiss button or close button is clicked. - $('.welcome-panel-close, .welcome-panel-dismiss a', welcomePanel).click( function(e) { + $('.welcome-panel-close, .welcome-panel-dismiss a', welcomePanel).on( 'click', function(e) { e.preventDefault(); welcomePanel.addClass('hidden'); updateWelcomePanel( 0 ); @@ -48,7 +48,7 @@ jQuery(document).ready( function($) { }); // Set welcome panel visibility based on Welcome Option checkbox value. - welcomePanelHide.click( function() { + welcomePanelHide.on( 'click', function() { welcomePanel.toggleClass('hidden', ! this.checked ); updateWelcomePanel( this.checked ? 1 : 0 ); }); @@ -136,7 +136,7 @@ jQuery(document).ready( function($) { // Enable the submit buttons. $( '#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]' ).prop( 'disabled' , false ); - t = $('#quick-press').submit( function( e ) { + t = $('#quick-press').on( 'submit', function( e ) { e.preventDefault(); // Show a spinner. @@ -172,7 +172,7 @@ jQuery(document).ready( function($) { } ); // Change the QuickPost action to the publish value. - $('#publish').click( function() { act.val( 'post-quickpress-publish' ); } ); + $('#publish').on( 'click', function() { act.val( 'post-quickpress-publish' ); } ); $('#quick-press').on( 'click focusin', function() { wpActiveEditor = 'content'; diff --git a/src/js/_enqueues/wp/password-strength-meter.js b/src/js/_enqueues/wp/password-strength-meter.js index 867a3f6602..506088b038 100644 --- a/src/js/_enqueues/wp/password-strength-meter.js +++ b/src/js/_enqueues/wp/password-strength-meter.js @@ -32,7 +32,7 @@ window.wp = window.wp || {}; * @return {number} The password strength score. */ meter : function( password1, disallowedList, password2 ) { - if ( ! $.isArray( disallowedList ) ) + if ( ! Array.isArray( disallowedList ) ) disallowedList = [ disallowedList.toString() ]; if (password1 != password2 && password2 && password2.length > 0) diff --git a/src/js/_enqueues/wp/theme-plugin-editor.js b/src/js/_enqueues/wp/theme-plugin-editor.js index cffbc69637..511d46f164 100644 --- a/src/js/_enqueues/wp/theme-plugin-editor.js +++ b/src/js/_enqueues/wp/theme-plugin-editor.js @@ -101,7 +101,7 @@ wp.themePluginEditor = (function( $ ) { // Reveal the modal and set focus on the go back button. component.warning .removeClass( 'hidden' ) - .find( '.file-editor-warning-go-back' ).focus(); + .find( '.file-editor-warning-go-back' ).trigger( 'focus' ); // Get the links and buttons within the modal. component.warningTabbables = component.warning.find( 'a, button' ); // Attach event handlers. diff --git a/src/js/_enqueues/wp/theme.js b/src/js/_enqueues/wp/theme.js index 9a81a893b4..2e0445c5df 100644 --- a/src/js/_enqueues/wp/theme.js +++ b/src/js/_enqueues/wp/theme.js @@ -73,7 +73,7 @@ themes.view.Appearance = wp.Backbone.View.extend({ this.SearchView = options.SearchView ? options.SearchView : themes.view.Search; // Bind to the scroll event and throttle // the results from this.scroller. - this.window.bind( 'scroll', _.throttle( this.scroller, 300 ) ); + this.window.on( 'scroll', _.throttle( this.scroller, 300 ) ); }, // Main render control. @@ -550,7 +550,7 @@ themes.view.Theme = wp.Backbone.View.extend({ // Render and append. preview.render(); this.setNavButtonsState(); - $( '.next-theme' ).focus(); + $( '.next-theme' ).trigger( 'focus' ); }) .listenTo( preview, 'theme:previous', function() { @@ -580,7 +580,7 @@ themes.view.Theme = wp.Backbone.View.extend({ // Render and append. preview.render(); this.setNavButtonsState(); - $( '.previous-theme' ).focus(); + $( '.previous-theme' ).trigger( 'focus' ); }); this.listenTo( preview, 'preview:close', function() { @@ -602,7 +602,7 @@ themes.view.Theme = wp.Backbone.View.extend({ .addClass( 'disabled' ) .prop( 'disabled', true ); - nextThemeButton.focus(); + nextThemeButton.trigger( 'focus' ); } // Disable next if the next model is undefined. @@ -611,7 +611,7 @@ themes.view.Theme = wp.Backbone.View.extend({ .addClass( 'disabled' ) .prop( 'disabled', true ); - previousThemeButton.focus(); + previousThemeButton.trigger( 'focus' ); } }, @@ -705,7 +705,7 @@ themes.view.Details = wp.Backbone.View.extend({ // Set initial focus on the primary action control. _.delay( function() { - $( '.theme-overlay' ).focus(); + $( '.theme-overlay' ).trigger( 'focus' ); }, 100 ); // Constrain tabbing within the modal. @@ -716,10 +716,10 @@ themes.view.Details = wp.Backbone.View.extend({ // Check for the Tab key. if ( 9 === event.which ) { if ( $firstFocusable[0] === event.target && event.shiftKey ) { - $lastFocusable.focus(); + $lastFocusable.trigger( 'focus' ); event.preventDefault(); } else if ( $lastFocusable[0] === event.target && ! event.shiftKey ) { - $firstFocusable.focus(); + $firstFocusable.trigger( 'focus' ); event.preventDefault(); } } @@ -764,7 +764,7 @@ themes.view.Details = wp.Backbone.View.extend({ // Return focus to the theme div. if ( themes.focusedTheme ) { - themes.focusedTheme.focus(); + themes.focusedTheme.trigger( 'focus' ); } }); } @@ -952,7 +952,7 @@ themes.view.Preview = themes.view.Details.extend({ // Return focus to the theme div. if ( themes.focusedTheme ) { - themes.focusedTheme.focus(); + themes.focusedTheme.trigger( 'focus' ); } }).removeClass( 'iframe-ready' ); @@ -2049,7 +2049,7 @@ themes.RunInstaller = { // The `search` route event. The router populates the input field. themes.router.on( 'route:search', function() { - $( '.wp-filter-search' ).focus().trigger( 'keyup' ); + $( '.wp-filter-search' ).trigger( 'focus' ).trigger( 'keyup' ); }); this.extraRoutes(); @@ -2101,7 +2101,7 @@ jQuery(document).ready( function($) { adminbar_height = parseInt( $('#wpadminbar').css('height'), 10 ); } - if ( tbWindow.size() ) { + if ( tbWindow.length >= 1 ) { tbWindow.width( W - 50 ).height( H - 45 - adminbar_height ); $('#TB_iframeContent').width( W - 50 ).height( H - 75 - adminbar_height ); tbWindow.css({'margin-left': '-' + parseInt( ( ( W - 50 ) / 2 ), 10 ) + 'px'}); @@ -2111,5 +2111,5 @@ jQuery(document).ready( function($) { } }; - $(window).resize(function(){ tb_position(); }); + $(window).on( 'resize', function(){ tb_position(); }); }); diff --git a/src/js/_enqueues/wp/updates.js b/src/js/_enqueues/wp/updates.js index e7454c0eab..bbb52a66a3 100644 --- a/src/js/_enqueues/wp/updates.js +++ b/src/js/_enqueues/wp/updates.js @@ -1552,7 +1552,7 @@ if ( -1 !== _.indexOf( themes.disabled, response.slug ) ) { themes.disabled = _.without( themes.disabled, response.slug ); if ( themes.disabled.length ) { - $views.find( '.disabled .count' ).text( '(' + themes.disabled.length + ')' ); + $views.find( '.disabled .count' ).text( '(' + themes.disabled.length + ')' ); } else { $views.find( '.disabled' ).remove(); } @@ -1566,7 +1566,7 @@ $views.find( '.auto-update-enabled' ).remove(); } } - + if ( -1 !== _.indexOf( themes['auto-update-disabled'], response.slug ) ) { themes['auto-update-disabled'] = _.without( themes['auto-update-disabled'], response.slug ); if ( themes['auto-update-disabled'].length ) { @@ -2045,7 +2045,7 @@ */ $filesystemForm.on( 'change', 'input[name="connection_type"]', function() { $( '#ssh-keys' ).toggleClass( 'hidden', ( 'ssh' !== $( this ).val() ) ); - } ).change(); + } ).trigger( 'change' ); /** * Handles events after the credential modal was closed. @@ -2765,7 +2765,7 @@ } try { - message = $.parseJSON( originalEvent.data ); + message = JSON.parse( originalEvent.data ); } catch ( e ) { return; } diff --git a/src/js/_enqueues/wp/widgets/custom-html.js b/src/js/_enqueues/wp/widgets/custom-html.js index 92c832bd9b..58b3842a23 100644 --- a/src/js/_enqueues/wp/widgets/custom-html.js +++ b/src/js/_enqueues/wp/widgets/custom-html.js @@ -446,9 +446,15 @@ wp.customHtmlWidgets = ( function( $ ) { }); // Accessibility mode. - $( window ).on( 'load', function() { + if ( document.readyState === 'complete' ) { + // Page is fully loaded. component.setupAccessibleMode(); - }); + } else { + // Page is still loading. + $( window ).on( 'load', function() { + component.setupAccessibleMode(); + }); + } }); }; diff --git a/src/js/_enqueues/wp/widgets/media.js b/src/js/_enqueues/wp/widgets/media.js index c53344133f..6f8beda739 100644 --- a/src/js/_enqueues/wp/widgets/media.js +++ b/src/js/_enqueues/wp/widgets/media.js @@ -1320,9 +1320,15 @@ wp.mediaWidgets = ( function( $ ) { }); // Accessibility mode. - $( window ).on( 'load', function() { + if ( document.readyState === 'complete' ) { + // Page is fully loaded. component.setupAccessibleMode(); - }); + } else { + // Page is still loading. + $( window ).on( 'load', function() { + component.setupAccessibleMode(); + }); + } }); }; diff --git a/src/js/media/views/focus-manager.js b/src/js/media/views/focus-manager.js index 64461c16f9..d79961b05b 100644 --- a/src/js/media/views/focus-manager.js +++ b/src/js/media/views/focus-manager.js @@ -69,7 +69,7 @@ var FocusManager = wp.media.View.extend(/** @lends wp.media.view.FocusManager.pr * @return {void} */ focus: function() { - this.$( '.media-modal' ).focus(); + this.$( '.media-modal' ).trigger( 'focus' ); }, /** diff --git a/src/js/media/views/frame/edit-attachments.js b/src/js/media/views/frame/edit-attachments.js index a2e1749dc1..1351a31083 100644 --- a/src/js/media/views/frame/edit-attachments.js +++ b/src/js/media/views/frame/edit-attachments.js @@ -94,7 +94,7 @@ EditAttachments = MediaFrame.extend(/** @lends wp.media.view.MediaFrame.EditAtta // Remove the keydown event. $( 'body' ).off( 'keydown.media-modal' ); // Move focus back to the original item in the grid if possible. - $( 'li.attachment[data-id="' + this.model.get( 'id' ) +'"]' ).focus(); + $( 'li.attachment[data-id="' + this.model.get( 'id' ) +'"]' ).trigger( 'focus' ); this.resetRoute(); }, this ) ); @@ -232,7 +232,7 @@ EditAttachments = MediaFrame.extend(/** @lends wp.media.view.MediaFrame.EditAtta * @param {string} which A CSS selector to target the button to focus. */ focusNavButton: function( which ) { - $( which ).focus(); + $( which ).trigger( 'focus' ); }, getCurrentIndex: function() { diff --git a/src/js/media/views/modal.js b/src/js/media/views/modal.js index d06bf9b599..f7afb014b9 100644 --- a/src/js/media/views/modal.js +++ b/src/js/media/views/modal.js @@ -115,7 +115,7 @@ Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ } // Set initial focus on the content instead of this view element, to avoid page scrolling. - this.$( '.media-modal' ).focus(); + this.$( '.media-modal' ).trigger( 'focus' ); // Hide the page content from assistive technologies. this.focusManager.setAriaHiddenOnBodyChildren( $el ); @@ -136,7 +136,7 @@ Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ $( 'body' ).removeClass( 'modal-open' ); // Hide modal and remove restricted media modal tab focus once it's closed. - this.$el.hide().undelegate( 'keydown' ); + this.$el.hide().off( 'keydown' ); /* * Make visible again to assistive technologies all body children that diff --git a/src/wp-admin/export.php b/src/wp-admin/export.php index a0c76a35b4..51acc7ed3c 100644 --- a/src/wp-admin/export.php +++ b/src/wp-admin/export.php @@ -29,7 +29,7 @@ function export_add_js() { var form = $('#export-filters'), filters = form.find('.export-filters'); filters.hide(); - form.find('input:radio').change(function() { + form.find('input:radio').on( 'change', function() { filters.slideUp('fast'); switch ( $(this).val() ) { case 'attachment': $('#attachment-filters').slideDown(); break; diff --git a/src/wp-admin/includes/ms.php b/src/wp-admin/includes/ms.php index 9eb2b709d9..5cfe1f43b5 100644 --- a/src/wp-admin/includes/ms.php +++ b/src/wp-admin/includes/ms.php @@ -1001,7 +1001,7 @@ function network_settings_add_js() { button' ).addClass( 'toggle-on' ); container.find( '.current-menu-ancestor > .sub-menu' ).addClass( 'toggled-on' ); - container.find( '.dropdown-toggle' ).click( function( e ) { + container.find( '.dropdown-toggle' ).on( 'click', function( e ) { var _this = $( this ); e.preventDefault(); _this.toggleClass( 'toggle-on' ); diff --git a/src/wp-content/themes/twentyfourteen/js/functions.js b/src/wp-content/themes/twentyfourteen/js/functions.js index 2235330981..557cc9f87b 100644 --- a/src/wp-content/themes/twentyfourteen/js/functions.js +++ b/src/wp-content/themes/twentyfourteen/js/functions.js @@ -147,12 +147,12 @@ onResizeARIA(); } ); - _window.load( function() { + _window.on( 'load', function() { var footerSidebar, isCustomizeSelectiveRefresh = ( 'undefined' !== typeof wp && wp.customize && wp.customize.selectiveRefresh ); // Arrange footer widgets vertically. - if ( $.isFunction( $.fn.masonry ) ) { + if ( typeof $.fn.masonry === 'function' ) { footerSidebar = $( '#footer-sidebar' ); footerSidebar.masonry( { itemSelector: '.widget', diff --git a/src/wp-content/themes/twentyseventeen/assets/js/global.js b/src/wp-content/themes/twentyseventeen/assets/js/global.js index b6322de44d..9b4db2353b 100644 --- a/src/wp-content/themes/twentyseventeen/assets/js/global.js +++ b/src/wp-content/themes/twentyseventeen/assets/js/global.js @@ -26,7 +26,7 @@ resizeTimer; // Ensure the sticky navigation doesn't cover current focused links. - $( 'a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, [tabindex], [contenteditable]', '.site-content-contain' ).filter( ':visible' ).focus( function() { + $( 'a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, [tabindex], [contenteditable]', '.site-content-contain' ).filter( ':visible' ).on( 'focus', function() { if ( $navigation.hasClass( 'site-navigation-fixed' ) ) { var windowScrollTop = $( window ).scrollTop(), fixedNavHeight = $navigation.height(), @@ -197,7 +197,7 @@ navigationOuterHeight = 0; } - $menuScrollDown.click( function( e ) { + $menuScrollDown.on( 'click', function( e ) { e.preventDefault(); $( window ).scrollTo( '#primary', { duration: 600, @@ -228,13 +228,13 @@ }); // Also want to make sure the navigation is where it should be on resize. - $( window ).resize( function() { + $( window ).on( 'resize', function() { setNavProps(); setTimeout( adjustScrollClass, 500 ); }); } - $( window ).resize( function() { + $( window ).on( 'resize', function() { clearTimeout( resizeTimer ); resizeTimer = setTimeout( function() { belowEntryMetaClass( 'blockquote.alignleft, blockquote.alignright' ); diff --git a/src/wp-content/themes/twentyseventeen/assets/js/navigation.js b/src/wp-content/themes/twentyseventeen/assets/js/navigation.js index f0fd65249a..4c0560239c 100644 --- a/src/wp-content/themes/twentyseventeen/assets/js/navigation.js +++ b/src/wp-content/themes/twentyseventeen/assets/js/navigation.js @@ -26,7 +26,7 @@ // Set the active submenu initial state. container.find( '.current-menu-ancestor > .sub-menu' ).addClass( 'toggled-on' ); - container.find( '.dropdown-toggle' ).click( function( e ) { + container.find( '.dropdown-toggle' ).on( 'click', function( e ) { var _this = $( this ), screenReaderSpan = _this.find( '.screen-reader-text' ); diff --git a/src/wp-content/themes/twentysixteen/js/functions.js b/src/wp-content/themes/twentysixteen/js/functions.js index a15af117cb..d7aed1bde9 100644 --- a/src/wp-content/themes/twentysixteen/js/functions.js +++ b/src/wp-content/themes/twentysixteen/js/functions.js @@ -28,7 +28,7 @@ // Add menu items with submenus to aria-haspopup="true". container.find( '.menu-item-has-children' ).attr( 'aria-haspopup', 'true' ); - container.find( '.dropdown-toggle' ).click( function( e ) { + container.find( '.dropdown-toggle' ).on( 'click', function( e ) { var _this = $( this ), screenReaderSpan = _this.find( '.screen-reader-text' ); diff --git a/src/wp-content/themes/twentythirteen/js/functions.js b/src/wp-content/themes/twentythirteen/js/functions.js index 1b18180c20..4b1102ebe9 100644 --- a/src/wp-content/themes/twentythirteen/js/functions.js +++ b/src/wp-content/themes/twentythirteen/js/functions.js @@ -123,7 +123,7 @@ */ $( function() { var columnWidth, widgetArea; - if ( ! $.isFunction( $.fn.masonry ) ) { + if ( typeof $.fn.masonry !== 'function' ) { return; } columnWidth = body.is( '.sidebar' ) ? 228 : 245; @@ -164,4 +164,4 @@ } ); } } ); -} )( jQuery ); \ No newline at end of file +} )( jQuery );