JS: in event callbacks replace the very outdated `return false` with `preventDefault()`.

Props adamsilverstein.
Fixes #18590.

git-svn-id: https://develop.svn.wordpress.org/trunk@34977 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2015-10-09 01:26:46 +00:00
parent c010db6ae4
commit 5a55add794
7 changed files with 35 additions and 34 deletions

View File

@ -67,7 +67,8 @@ jQuery(document).ready( function($) {
$( '#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]' ).prop( 'disabled' , false );
t = $('#quick-press').submit( function() {
t = $('#quick-press').submit( function( e ) {
e.preventDefault();
$('#dashboard_quick_press #publishing-action .spinner').show();
$('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').prop('disabled', true);
@ -87,8 +88,6 @@ jQuery(document).ready( function($) {
latestPost.css('background', 'none');
}, 1000);
}
return false;
} );
$('#publish').click( function() { act.val( 'post-quickpress-publish' ); } );

View File

@ -284,13 +284,13 @@ setCommentsList = function() {
a.attr('class', 'vim-z vim-destructive');
$('.avatar', el).first().clone().prependTo('#undo-' + id + ' .' + action + '-undo-inside');
a.click(function(){
a.click(function( e ){
e.preventDefault();
list.wpList.del(this);
$('#undo-' + id).css( {backgroundColor:'#ceb'} ).fadeOut(350, function(){
$(this).remove();
$('#comment-' + id).css('backgroundColor', '').fadeIn(300, function(){ $(this).show(); });
});
return false;
});
}
@ -854,7 +854,10 @@ $(document).ready(function(){
setCommentsList();
commentReply.init();
$(document).delegate('span.delete a.delete', 'click', function(){return false;});
$(document).on( 'click', 'span.delete a.delete', function( e ) {
e.preventDefault();
});
if ( typeof $.table_hotkeys != 'undefined' ) {
make_hotkeys_redirect = function(which) {

View File

@ -38,33 +38,33 @@ jQuery(document).ready(function($) {
});
};
$('#asc').click( function() {
$('#asc').click( function( e ) {
e.preventDefault();
desc = false;
sortIt();
return false;
});
$('#desc').click( function() {
$('#desc').click( function( e ) {
e.preventDefault();
desc = true;
sortIt();
return false;
});
$('#clear').click( function() {
$('#clear').click( function( e ) {
e.preventDefault();
clearAll(1);
return false;
});
$('#showall').click( function() {
$('#showall').click( function( e ) {
e.preventDefault();
$('#sort-buttons span a').toggle();
$('a.describe-toggle-on').hide();
$('a.describe-toggle-off, table.slidetoggle').show();
$('img.pinkynail').toggle(false);
return false;
});
$('#hideall').click( function() {
$('#hideall').click( function( e ) {
e.preventDefault();
$('#sort-buttons span a').toggle();
$('a.describe-toggle-on').show();
$('a.describe-toggle-off, table.slidetoggle').hide();
$('img.pinkynail').toggle(true);
return false;
});
// initialize sortable

View File

@ -48,9 +48,9 @@ inlineEditPost = {
});
// add events
$('#the-list').on('click', 'a.editinline', function(){
$('#the-list').on( 'click', 'a.editinline', function( e ) {
e.preventDefault();
inlineEditPost.edit(this);
return false;
});
$('#bulk-edit').find('fieldset:first').after(

View File

@ -38,15 +38,14 @@ jQuery( document ).ready( function( $ ) {
tb_position();
});
$( '.plugin-card, .plugins .plugin-version-author-uri' ).on( 'click', 'a.thickbox', function() {
$( '.plugin-card, .plugins .plugin-version-author-uri' ).on( 'click', 'a.thickbox', function( e ) {
e.preventDefault();
tb_click.call(this);
$('#TB_title').css({'background-color':'#23282d','color':'#cfcfcf'});
$('#TB_ajaxWindowTitle').html( '<strong>' + plugininstallL10n.plugin_information + '</strong>&nbsp;' + $(this).data( 'title' ) );
$('#TB_iframeContent').attr( 'title', plugininstallL10n.plugin_information + ' ' + $(this).data( 'title' ) );
$('#TB_closeWindowButton').focus();
return false;
});
/* Plugin install related JS */

View File

@ -432,7 +432,8 @@ jQuery(document).ready( function($) {
settingName = 'cats';
// TODO: move to jQuery 1.3+, support for multiple hierarchical taxonomies, see wp-lists.js
$('a', '#' + taxonomy + '-tabs').click( function(){
$('a', '#' + taxonomy + '-tabs').click( function( e ) {
e.preventDefault();
var t = $(this).attr('href');
$(this).parent().addClass('tabs').siblings('li').removeClass('tabs');
$('#' + taxonomy + '-tabs').siblings('.tabs-panel').hide();
@ -441,7 +442,6 @@ jQuery(document).ready( function($) {
deleteUserSetting( settingName );
else
setUserSetting( settingName, 'pop' );
return false;
});
if ( getUserSetting( settingName ) )
@ -483,11 +483,11 @@ jQuery(document).ready( function($) {
addAfter: catAddAfter
});
$('#' + taxonomy + '-add-toggle').click( function() {
$('#' + taxonomy + '-add-toggle').click( function( e ) {
e.preventDefault();
$('#' + taxonomy + '-adder').toggleClass( 'wp-hidden-children' );
$('a[href="#' + taxonomy + '-all"]', '#' + taxonomy + '-tabs').click();
$('#new'+taxonomy).focus();
return false;
});
$('#' + taxonomy + 'checklist, #' + taxonomy + 'checklist-pop').on( 'click', 'li.popular-category > label input[type="checkbox"]', function() {
@ -608,7 +608,8 @@ jQuery(document).ready( function($) {
return true;
};
$( '#visibility .edit-visibility').click( function () {
$( '#visibility .edit-visibility').click( function( e ) {
e.preventDefault();
if ( $postVisibilitySelect.is(':hidden') ) {
updateVisibility();
$postVisibilitySelect.slideDown( 'fast', function() {
@ -616,7 +617,6 @@ jQuery(document).ready( function($) {
} );
$(this).hide();
}
return false;
});
$postVisibilitySelect.find('.cancel-post-visibility').click( function( event ) {
@ -742,11 +742,12 @@ jQuery(document).ready( function($) {
revert_e = e.html();
buttons.html('<button type="button" class="save button button-small">'+postL10n.ok+'</button> <a class="cancel" href="#">'+postL10n.cancel+'</a>');
buttons.children('.save').click(function() {
buttons.children('.save').click( function( e ) {
var new_slug = e.children('input').val();
e.preventDefault();
if ( new_slug == $('#editable-post-name-full').text() ) {
buttons.children('.cancel').click();
return false;
return;
}
$.post(ajaxurl, {
action: 'sample-permalink',
@ -768,17 +769,16 @@ jQuery(document).ready( function($) {
real_slug.val(new_slug);
$( '.edit-slug' ).focus();
});
return false;
});
buttons.children('.cancel').click(function() {
buttons.children('.cancel').click( function( e ) {
e.preventDefault();
$('#view-post-btn').show();
e.html(revert_e);
buttons.html(buttonsOrig);
permalink.html(permalinkOrig);
real_slug.val(revert_slug);
$( '.edit-slug' ).focus();
return false;
});
for ( i = 0; i < full.length; ++i ) {

View File

@ -56,10 +56,10 @@ var postboxes;
e.stopPropagation();
});
$( '.postbox a.dismiss' ).bind( 'click.postboxes', function() {
$( '.postbox a.dismiss' ).on( 'click.postboxes', function( e ) {
var hide_id = $(this).parents('.postbox').attr('id') + '-hide';
e.preventDefault();
$( '#' + hide_id ).prop('checked', false).triggerHandler('click');
return false;
});
$('.hide-postbox-tog').bind('click.postboxes', function() {