External Libraries: Further fix jQuery deprecations in WordPress core.

Follow-up to [50001], [50270], [50367], [50383], [50410], [50420], [50429].

Props Clorith.
See #51812.

git-svn-id: https://develop.svn.wordpress.org/trunk@50547 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2021-03-18 18:59:34 +00:00
parent 4af708c3b8
commit e467e6867e
42 changed files with 120 additions and 110 deletions

View File

@ -11,7 +11,7 @@
*
* @param {jQuery} $ The jQuery object.
*/
jQuery(document).ready( function($) {
jQuery( function($) {
postboxes.add_postbox_toggles('comment');

View File

@ -483,7 +483,7 @@ window.columns = {
}
};
$document.ready(function(){columns.init();});
$( function() { columns.init(); } );
/**
* Validates that the required form fields are not empty.
@ -802,7 +802,7 @@ $availableStructureTags.on( 'click', function() {
}
} );
$document.ready( function() {
$( function() {
var checks, first, last, checked, sliced, mobileEvent, transitionTimeout, focusedRowActions,
lastClicked = false,
pageInput = $('input.current-page'),
@ -1706,7 +1706,7 @@ $document.ready( function() {
});
self.trigger();
$document.on( 'wp-window-resized.wp-responsive', $.proxy( this.trigger, this ) );
$document.on( 'wp-window-resized.wp-responsive', this.trigger.bind( this ) );
// This needs to run later as UI Sortable may be initialized later on $(document).ready().
$window.on( 'load.wp-responsive', this.maybeDisableSortables );
@ -1889,7 +1889,7 @@ $document.ready( function() {
$( '.aria-button-if-js' ).attr( 'role', 'button' );
}
$( document ).ajaxComplete( function() {
$( document ).on( 'ajaxComplete', function() {
aria_button_if_js();
});
@ -2008,7 +2008,7 @@ $document.ready( function() {
*
* @since 5.5.0
*/
$document.ready( function( $ ) {
$( function( $ ) {
var $overwrite, $warning;
if ( ! $body.hasClass( 'update-php' ) ) {

View File

@ -12,7 +12,7 @@
* @requires jQuery
*/
(function($) {
$(document).ready(function() {
$( function() {
var frame,
bgImage = $( '#custom-background-image' );

View File

@ -1225,7 +1225,7 @@ window.commentReply = {
}
};
$(document).ready(function(){
$( function(){
var make_hotkeys_redirect, edit_comment, toggle_all, make_bulk;
setCommentsList();

View File

@ -516,10 +516,16 @@ window.wp = window.wp || {};
}
};
$( document ).ready( function(){ inlineEditPost.init(); } );
$( function() { inlineEditPost.init(); } );
// Show/hide locks on posts.
$( document ).on( 'heartbeat-tick.wp-check-locked-posts', function( e, data ) {
$( function() {
// Set the heartbeat interval to 15 seconds.
if ( typeof wp !== 'undefined' && wp.heartbeat ) {
wp.heartbeat.interval( 15 );
}
}).on( 'heartbeat-tick.wp-check-locked-posts', function( e, data ) {
var locked = data['wp-check-locked-posts'] || {};
$('#the-list tr').each( function(i, el) {
@ -560,12 +566,6 @@ $( document ).on( 'heartbeat-tick.wp-check-locked-posts', function( e, data ) {
if ( check.length ) {
data['wp-check-locked-posts'] = check;
}
}).ready( function() {
// Set the heartbeat interval to 15 seconds.
if ( typeof wp !== 'undefined' && wp.heartbeat ) {
wp.heartbeat.interval( 15 );
}
});
})( jQuery, window.wp );

View File

@ -289,6 +289,6 @@ window.inlineEditTax = {
}
};
$(document).ready(function(){inlineEditTax.init();});
$( function() { inlineEditTax.init(); } );
})( jQuery, window.wp );

View File

@ -4,7 +4,7 @@
/* global postboxes, deleteUserSetting, setUserSetting, getUserSetting */
jQuery(document).ready( function($) {
jQuery( function($) {
var newCat, noSyncChecks = false, syncChecks, catAddAfter;
@ -81,7 +81,11 @@ jQuery(document).ready( function($) {
$(s.what + ' response_data', r).each( function() {
var t = $($(this).text());
t.find( 'label' ).each( function() {
var th = $(this), val = th.find('input').val(), id = th.find('input')[0].id, name = $.trim( th.text() ), o;
var th = $(this),
val = th.find('input').val(),
id = th.find('input')[0].id,
name = th.text().trim(),
o;
$('#' + id).on( 'change', syncChecks );
o = $( '<option value="' + parseInt( val, 10 ) + '"></option>' ).text( name );
} );

View File

@ -140,7 +140,7 @@
*
* @return {void}
*/
$( document ).ready( function() {
$( function() {
var settings, $mediaGridWrap = $( '#wp-media-grid' );
// Opens a manage media frame into the grid.

View File

@ -6,7 +6,7 @@
/* global tb_click, tb_remove, tb_position */
jQuery( document ).ready( function( $ ) {
jQuery( function( $ ) {
var tbWindow,
$iframeBody,

View File

@ -260,7 +260,9 @@ window.wp = window.wp || {};
timeout = window.setTimeout( function(){ check = true; }, 300000 );
}
$(document).on( 'heartbeat-send.wp-refresh-nonces', function( e, data ) {
$( function() {
schedule();
}).on( 'heartbeat-send.wp-refresh-nonces', function( e, data ) {
var post_id,
$authCheck = $('#wp-auth-check-wrap');
@ -286,15 +288,13 @@ window.wp = window.wp || {};
if ( nonces.heartbeatNonce )
window.heartbeatSettings.nonce = nonces.heartbeatNonce;
}
}).ready( function() {
schedule();
});
}(jQuery));
/**
* All post and postbox controls and functionality.
*/
jQuery(document).ready( function($) {
jQuery( function($) {
var stamp, visibility, $submitButtons, updateVisibility, updateText,
$textarea = $('#content'),
$document = $(document),
@ -661,7 +661,7 @@ jQuery(document).ready( function($) {
$('#' + taxonomy + '-add-toggle').on( 'click', function( e ) {
e.preventDefault();
$('#' + taxonomy + '-adder').toggleClass( 'wp-hidden-children' );
$('a[href="#' + taxonomy + '-all"]', '#' + taxonomy + '-tabs').click();
$('a[href="#' + taxonomy + '-all"]', '#' + taxonomy + '-tabs').trigger( 'click' );
$('#new'+taxonomy).trigger( 'focus' );
});

View File

@ -5,7 +5,7 @@
*/
// Privacy request action handling.
jQuery( document ).ready( function( $ ) {
jQuery( function( $ ) {
var __ = wp.i18n.__,
copiedNoticeTimeout;

View File

@ -6,7 +6,7 @@
/* global ajaxurl, ClipboardJS, SiteHealth, wp */
jQuery( document ).ready( function( $ ) {
jQuery( function( $ ) {
var __ = wp.i18n.__,
_n = wp.i18n._n,

View File

@ -27,7 +27,8 @@
// Trim the values and ensure they are unique.
$.each( array, function( key, val ) {
val = $.trim( val );
val = val || '';
val = val.trim();
if ( val && $.inArray( val, out ) === -1 ) {
out.push( val );
@ -96,7 +97,8 @@
// Sanitize the current tags and push them as if they're new tags.
$.each( current_tags, function( key, val ) {
val = $.trim( val );
val = val || '';
val = val.trim();
if ( val ) {
new_tags.push( val );
}
@ -148,7 +150,8 @@
$.each( current_tags, function( key, val ) {
var listItem, xbutton;
val = $.trim( val );
val = val || '';
val = val.trim();
if ( ! val )
return;

View File

@ -9,7 +9,7 @@
/* global ajaxurl, wpAjax, showNotice, validateForm */
jQuery(document).ready(function($) {
jQuery( function($) {
var addingTerm = false;

View File

@ -319,7 +319,7 @@
}
}
$(document).ready( function() {
$( function() {
var $colorpicker, $stylesheet, user_id, current_user_id,
select = $( '#display_name' ),
current_name = select.val(),
@ -374,7 +374,7 @@
return;
}
var display_name = $.trim( this.value ) || current_name;
var display_name = this.value.trim() || current_name;
greeting.text( display_name );
} );
@ -466,7 +466,7 @@
* to avoid double clicking the button to retrieve the first generated password.
* See ticket #39638.
*/
$( document ).ready( function() {
$( function() {
if ( $( '.reset-pass-submit' ).length ) {
$( '.reset-pass-submit button.wp-generate-pw' ).trigger( 'click' );
}

View File

@ -741,7 +741,7 @@ window.wpWidgets = {
}
};
$document.ready( function(){ wpWidgets.init(); } );
$( function(){ wpWidgets.init(); } );
})(jQuery);

View File

@ -4,7 +4,7 @@
* @deprecated 3.5.0
* @output wp-admin/js/xfn.js
*/
jQuery( document ).ready(function( $ ) {
jQuery( function( $ ) {
$( '#link_rel' ).prop( 'readonly', true );
$( '#linkxfndiv input' ).on( 'click keyup', function() {
var isMe = $( '#me' ).is( ':checked' ), inputs = '';

View File

@ -31,7 +31,7 @@
( function( $ ){
$( document ).ready( function () {
$( function () {
// Expand/Collapse accordion sections on click.
$( '.accordion-container' ).on( 'click keydown', '.accordion-section-title', function( e ) {

View File

@ -65,6 +65,6 @@ window.wpAjax = jQuery.extend( {
}, wpAjax || { noPerm: 'Sorry, you are not allowed to do that.', broken: 'Something went wrong.' } );
// Basic form validation.
jQuery(document).ready( function($){
jQuery( function($){
$('form.validate').on( 'submit', function() { return wpAjax.validateForm( $(this) ); } );
});

View File

@ -144,15 +144,7 @@
* @param {Object} e The heartbeat-tick event that has been triggered.
* @param {Object} data Response data.
*/
$( document ).on( 'heartbeat-tick.wp-auth-check', function( e, data ) {
if ( 'wp-auth-check' in data ) {
if ( ! data['wp-auth-check'] && wrap.hasClass( 'hidden' ) && ! tempHidden ) {
show();
} else if ( data['wp-auth-check'] && ! wrap.hasClass( 'hidden' ) ) {
hide();
}
}
}).ready( function() {
$( function() {
/**
* Hides the authentication form popup when the close icon is clicked.
@ -166,6 +158,14 @@
hide();
setShowTimeout();
});
}).on( 'heartbeat-tick.wp-auth-check', function( e, data ) {
if ( 'wp-auth-check' in data ) {
if ( ! data['wp-auth-check'] && wrap.hasClass( 'hidden' ) && ! tempHidden ) {
show();
} else if ( data['wp-auth-check'] && ! wrap.hasClass( 'hidden' ) ) {
hide();
}
}
});
}(jQuery));

View File

@ -101,7 +101,7 @@
}
// Bind the close event.
self.close = $.proxy( self.close, self );
self.close = self.close.bind( self );
self.initialValue = el.val();
@ -277,7 +277,7 @@
if ( me.hasClass( 'wp-picker-clear' ) ) {
self.element.val( '' );
self.toggler.css( 'backgroundColor', '' );
if ( $.isFunction( self.options.clear ) ) {
if ( typeof self.options.clear === 'function' ) {
self.options.clear.call( this, event );
}
} else if ( me.hasClass( 'wp-picker-default' ) ) {

View File

@ -4,7 +4,7 @@
/* global unescape, getUserSetting, setUserSetting, wpgallery, tinymce */
jQuery(document).ready(function($) {
jQuery( function($) {
var gallerySortable, gallerySortableInit, sortIt, clearAll, w, desc = false;
gallerySortableInit = function() {

View File

@ -93,7 +93,7 @@
// If URL wasn't corrected last time and doesn't start with http:, https:, ? # or /, prepend http://.
correctURL: function () {
var url = $.trim( inputs.url.val() );
var url = inputs.url.val().trim();
if ( url && correctedURL !== url && ! /^(?:[a-z]+:|#|\?|\.|\/)/.test( url ) ) {
inputs.url.val( 'http://' + url );
@ -238,7 +238,7 @@
linkText = linkNode.text();
href = linkNode.attr( 'href' );
if ( ! $.trim( linkText ) ) {
if ( ! linkText.trim() ) {
linkText = text || '';
}
@ -312,7 +312,7 @@
wpLink.correctURL();
return {
href: $.trim( inputs.url.val() ),
href: inputs.url.val().trim(),
target: inputs.openInNewTab.prop( 'checked' ) ? '_blank' : null
};
},
@ -425,7 +425,7 @@
if ( ! $link.length ) {
editor.execCommand( 'mceInsertLink', false, { href: '_wp_link_placeholder', 'data-wp-temp-link': 1 } );
$link = editor.$( 'a[data-wp-temp-link="1"]' ).removeAttr( 'data-wp-temp-link' );
hasText = $.trim( $link.text() );
hasText = $link.text().trim();
}
if ( ! $link.length ) {
@ -483,7 +483,8 @@
}
}
selection = $.trim( selection );
selection = selection || '';
selection = selection.trim();
if ( selection && emailRegexp.test( selection ) ) {
// Selection is email address.
@ -797,5 +798,5 @@
}
});
$( document ).ready( wpLink.init );
$( wpLink.init );
})( jQuery, window.wpLinkL10n, window.wp );

View File

@ -1331,7 +1331,7 @@
};
$(document).ready(function() {
$( function() {
wpNavMenu.init();

View File

@ -57,7 +57,7 @@ window.edToolbar = function(){};
var t, i, DOMContentLoaded, _tryReady;
if ( typeof jQuery !== 'undefined' ) {
jQuery(document).ready(func);
jQuery( func );
} else {
t = _domReady;
t.funcs = [];

View File

@ -14,7 +14,7 @@
(function( $ ) {
var id = ( typeof current_site_id !== 'undefined' ) ? '&site_id=' + current_site_id : '';
$(document).ready( function() {
$( function() {
var position = { offset: '0, -1' };
if ( typeof isRtl !== 'undefined' && isRtl ) {
position.my = 'right top';

View File

@ -582,7 +582,7 @@ window.autosave = function() {
* Don't run if the post type supports neither 'editor' (textarea#content) nor 'excerpt'.
*/
if ( checkStorage() && blog_id && ( $('#content').length || $('#excerpt').length ) ) {
$document.ready( run );
$( run );
}
return {
@ -798,7 +798,9 @@ window.autosave = function() {
*
* @return {void}
*/
$document.on( 'heartbeat-send.autosave', function( event, data ) {
$( function() {
_schedule();
}).on( 'heartbeat-send.autosave', function( event, data ) {
var autosaveData = save();
if ( autosaveData ) {
@ -848,8 +850,6 @@ window.autosave = function() {
}).on( 'heartbeat-connection-restored.autosave', function() {
$('#lost-connection-notice').hide();
enableButtons();
}).ready( function() {
_schedule();
});
return {
@ -873,7 +873,10 @@ window.autosave = function() {
*
* @return {void}
*/
$document.on( 'tinymce-editor-init.autosave', function( event, editor ) {
$( function() {
// Set the initial compare string in case TinyMCE is not used or not loaded first.
setInitialCompare();
}).on( 'tinymce-editor-init.autosave', function( event, editor ) {
// Reset the initialCompare data after the TinyMCE instances have been initialized.
if ( 'content' === editor.id || 'excerpt' === editor.id ) {
window.setTimeout( function() {
@ -881,9 +884,6 @@ window.autosave = function() {
setInitialCompare();
}, 1000 );
}
}).ready( function() {
// Set the initial compare string in case TinyMCE is not used or not loaded first.
setInitialCompare();
});
return {

View File

@ -197,7 +197,7 @@ window.wp = window.wp || {};
$.extend( this, options || {} );
this.set = $.proxy( this.set, this );
this.set = this.set.bind( this );
},
/*
@ -734,7 +734,7 @@ window.wp = window.wp || {};
* This will prevent every Messenger's receive function from being
* unbound when calling $.off( 'message', this.receive );
*/
this.receive = $.proxy( this.receive, this );
this.receive = this.receive.bind( this );
this.receive.guid = $.guid++;
$( window ).on( 'message', this.receive );

View File

@ -289,7 +289,7 @@
collection.focusContainer.focus();
}
} else if ( collection.previousActiveElement ) {
$( collection.previousActiveElement ).focus();
$( collection.previousActiveElement ).trigger( 'focus' );
collection.previousActiveElement = null;
}
@ -1592,7 +1592,7 @@
if ( args.unchanged ) {
expand = args.completeCallback;
} else {
expand = $.proxy( function() {
expand = function() {
section._animateChangeExpanded( function() {
sectionTitle.attr( 'tabindex', '-1' );
backBtn.attr( 'tabindex', '0' );
@ -1609,7 +1609,7 @@
content.addClass( 'open' );
overlay.addClass( 'section-open' );
api.state( 'expandedSection' ).set( section );
}, this );
}.bind( this );
}
if ( ! args.allowMultiple ) {
@ -2696,12 +2696,12 @@
if ( args.unchanged ) {
expand = args.completeCallback;
} else {
expand = $.proxy( function() {
expand = function() {
section._animateChangeExpanded( function() {
sectionTitle.attr( 'tabindex', '-1' );
backBtn.attr( 'tabindex', '0' );
backBtn.focus();
backBtn.trigger( 'focus' );
content.css( 'top', '' );
container.scrollTop( 0 );
@ -2711,7 +2711,7 @@
} );
content.addClass( 'open' );
}, this );
}.bind( this );
}
if ( section.panel() ) {
@ -2956,7 +2956,7 @@
topPanel.attr( 'tabindex', '-1' );
backBtn.attr( 'tabindex', '0' );
backBtn.focus();
backBtn.trigger( 'focus' );
accordionSection.css( 'top', '' );
container.scrollTop( 0 );
@ -3874,9 +3874,9 @@
control.container.toggleClass( 'has-notifications', 0 !== notifications.length );
control.container.toggleClass( 'has-error', hasError );
container.empty().append( $.trim(
control.notificationsTemplate( { notifications: notifications, altNotice: Boolean( control.altNotice ) } )
) );
container.empty().append(
control.notificationsTemplate( { notifications: notifications, altNotice: Boolean( control.altNotice ) } ).trim()
);
},
/**

View File

@ -218,7 +218,7 @@
// Clear the search results and trigger an `input` event to fire a new search.
this.$clearResults.on( 'click', function() {
self.$search.val( '' ).focus().trigger( 'input' );
self.$search.val( '' ).trigger( 'focus' ).trigger( 'input' );
} );
this.$el.on( 'input', '#custom-menu-item-name.invalid, #custom-menu-item-url.invalid', function() {
@ -446,7 +446,7 @@
self.pages[ name ] = -1;
return;
} else if ( ( 'post_type:page' === name ) && ( ! availableMenuItemContainers[ name ].hasClass( 'open' ) ) ) {
availableMenuItemContainers[ name ].find( '.accordion-section-title > button' ).click();
availableMenuItemContainers[ name ].find( '.accordion-section-title > button' ).trigger( 'click' );
}
typeItems = new api.Menus.AvailableItemCollection( typeItems ); // @todo Why is this collection created and then thrown away?
self.collection.add( typeItems.models );
@ -644,7 +644,7 @@
return;
}
if ( '' === $.trim( itemName.val() ) ) {
if ( '' === itemName.val().trim() ) {
itemName.addClass( 'invalid' );
itemName.focus();
return;
@ -716,7 +716,7 @@
this.$el.find( '.selected' ).removeClass( 'selected' );
this.$search.focus();
this.$search.trigger( 'focus' );
},
// Closes the panel.
@ -1879,7 +1879,7 @@
// Ensure that whitespace is trimmed on blur so placeholder can be shown.
control.container.find( '.edit-menu-item-title' ).on( 'blur', function() {
$( this ).val( $.trim( $( this ).val() ) );
$( this ).val( $( this ).val().trim() );
} );
titleEl = control.container.find( '.menu-item-title' );
@ -1888,7 +1888,8 @@
if ( ! item ) {
return;
}
trimmedTitle = $.trim( item.title );
item.title = item.title || '';
trimmedTitle = item.title.trim();
titleText = trimmedTitle || item.original_title || api.Menus.data.l10n.untitled;

View File

@ -195,7 +195,7 @@
// Clear the search results and trigger an `input` event to fire a new search.
this.$clearResults.on( 'click', function() {
self.$search.val( '' ).focus().trigger( 'input' );
self.$search.val( '' ).trigger( 'focus' ).trigger( 'input' );
} );
// Close the panel if the URL in the preview changes.
@ -365,7 +365,7 @@
this.collection.doSearch( '' );
if ( ! api.settings.browser.mobile ) {
this.$search.focus();
this.$search.trigger( 'focus' );
}
},
@ -421,9 +421,9 @@
this.select( selected );
if ( selected ) {
selected.focus();
selected.trigger( 'focus' );
} else {
this.$search.focus();
this.$search.trigger( 'focus' );
}
return;
@ -818,7 +818,7 @@
if ( event.type === 'keypress' && ( event.which !== 13 && event.which !== 32 ) ) {
return;
}
$( this ).focus();
$( this ).trigger( 'focus' );
if ( $( this ).is( '.move-widget' ) ) {
self.toggleWidgetMoveArea();
@ -839,7 +839,7 @@
wp.a11y.speak( l10n.widgetMovedDown );
}
$( this ).focus(); // Re-focus after the container was moved.
$( this ).trigger( 'focus' ); // Re-focus after the container was moved.
}
} );
@ -1103,7 +1103,7 @@
if ( input.is( ':radio, :checkbox' ) ) {
input.prop( 'checked', state );
} else if ( input.is( 'select[multiple]' ) ) {
if ( ! $.isArray( state ) ) {
if ( ! Array.isArray( state ) ) {
state = [];
} else {
// Make sure all state items are strings since the DOM value is a string.
@ -2089,7 +2089,7 @@
widgetNumber = widget.get( 'multi_number' );
}
controlHtml = $.trim( $( '#widget-tpl-' + widget.get( 'id' ) ).html() );
controlHtml = $( '#widget-tpl-' + widget.get( 'id' ) ).html().trim();
if ( widget.get( 'is_multi' ) ) {
controlHtml = controlHtml.replace( /<[^<>]+>/g, function( m ) {
return m.replace( /__i__|%i%/g, widgetNumber );

View File

@ -12,7 +12,7 @@ window.communityEventsData = window.communityEventsData || {};
*
* @since 2.7.0
*/
jQuery(document).ready( function($) {
jQuery( function($) {
var welcomePanel = $( '#welcome-panel' ),
welcomePanelHide = $('#wp_welcome_panel-hide'),
updateWelcomePanel;
@ -328,7 +328,7 @@ jQuery( function( $ ) {
* @return {void}
*/
$container.on( 'submit', '.community-events-form', function( event ) {
var location = $.trim( $( '#community-events-location' ).val() );
var location = $( '#community-events-location' ).val().trim();
event.preventDefault();

View File

@ -1178,7 +1178,7 @@ window.wp = window.wp || {};
}
if ( $ ) {
$( document ).ready( init );
$( init );
} else if ( document.addEventListener ) {
document.addEventListener( 'DOMContentLoaded', init, false );
window.addEventListener( 'load', init, false );

View File

@ -234,7 +234,7 @@
window.setInterval( checkUserActivity, 30000 );
// Start one tick after DOM ready.
$document.ready( function() {
$( function() {
settings.lastTick = time();
scheduleNextTick();
});

View File

@ -12,7 +12,7 @@ wp.svgPainter = ( function( $, window, document, undefined ) {
colorscheme = {},
elements = [];
$(document).ready( function() {
$( function() {
// Detection for browser SVG capability.
if ( document.implementation.hasFeature( 'http://www.w3.org/TR/SVG11/feature#Image', '1.1' ) ) {
$( document.body ).removeClass( 'no-svg' ).addClass( 'svg' );

View File

@ -328,7 +328,7 @@ wp.themePluginEditor = (function( $ ) {
* @return {void}
*/
codeEditorSettings.onTabPrevious = function() {
$( '#templateside' ).find( ':tabbable' ).last().focus();
$( '#templateside' ).find( ':tabbable' ).last().trigger( 'focus' );
};
/**
@ -339,7 +339,7 @@ wp.themePluginEditor = (function( $ ) {
* @return {void}
*/
codeEditorSettings.onTabNext = function() {
$( '#template' ).find( ':tabbable:not(.CodeMirror-code)' ).first().focus();
$( '#template' ).find( ':tabbable:not(.CodeMirror-code)' ).first().trigger( 'focus' );
};
/**

View File

@ -2061,7 +2061,7 @@ themes.RunInstaller = {
};
// Ready...
$( document ).ready(function() {
$( function() {
if ( themes.isInstall ) {
themes.RunInstaller.init();
} else {
@ -2089,7 +2089,7 @@ $( document ).ready(function() {
})( jQuery );
// Align theme browser thickbox.
jQuery(document).ready( function($) {
jQuery( function($) {
window.tb_position = function() {
var tbWindow = $('#TB_window'),
width = $(window).width(),

View File

@ -1803,7 +1803,7 @@
$( 'body' ).removeClass( 'modal-open' );
if ( wp.updates.$elToReturnFocusToFromCredentialsModal ) {
wp.updates.$elToReturnFocusToFromCredentialsModal.focus();
wp.updates.$elToReturnFocusToFromCredentialsModal.trigger( 'focus' );
}
};

View File

@ -551,13 +551,13 @@ wp.mediaWidgets = ( function( $ ) {
// Update the title.
control.$el.on( 'input change', '.title', function updateTitle() {
control.model.set({
title: $.trim( $( this ).val() )
title: $( this ).val().trim()
});
});
// Update link_url attribute.
control.$el.on( 'input change', '.link', function updateLinkUrl() {
var linkUrl = $.trim( $( this ).val() ), linkType = 'custom';
var linkUrl = $( this ).val().trim(), linkType = 'custom';
if ( control.selectedAttachment.get( 'linkUrl' ) === linkUrl || control.selectedAttachment.get( 'link' ) === linkUrl ) {
linkType = 'post';
} else if ( control.selectedAttachment.get( 'url' ) === linkUrl ) {

View File

@ -57,7 +57,8 @@ EmbedUrl = View.extend(/** @lends wp.media.view.EmbedUrl.prototype */{
},
url: function( event ) {
this.model.set( 'url', $.trim( event.target.value ) );
var url = event.target.value || '';
this.model.set( 'url', url.trim() );
}
});

View File

@ -133,7 +133,7 @@ Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{
}
// Pause current audio/video even after closing the modal.
$( '.mejs-pause button' ).click();
$( '.mejs-pause button' ).trigger( 'click' );
// Enable page scrolling.
$( 'body' ).removeClass( 'modal-open' );
@ -155,7 +155,7 @@ Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{
// Fallback to the admin page main element.
$( '#wpbody-content' )
.attr( 'tabindex', '-1' )
.focus();
.trigger( 'focus' );
}
this.propagate('close');

View File

@ -134,7 +134,7 @@ UploaderInline = View.extend(/** @lends wp.media.view.UploaderInline.prototype *
this.controller.$uploaderToggler
.attr( 'aria-expanded', 'false' )
// Move focus back to the toggle button when closing the uploader.
.focus();
.trigger( 'focus' );
}
}