From 67f74ea9c1af48869384305fe71f7117e0faa0fc Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 26 Jul 2015 02:25:43 +0000 Subject: [PATCH] Comment status box: Move focus back to Edit link when changing the date. props afercia. fixes #33062. git-svn-id: https://develop.svn.wordpress.org/trunk@33422 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/comment.js | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/wp-admin/js/comment.js b/src/wp-admin/js/comment.js index b6490fdc2c..d194148f60 100644 --- a/src/wp-admin/js/comment.js +++ b/src/wp-admin/js/comment.js @@ -4,12 +4,15 @@ jQuery(document).ready( function($) { postboxes.add_postbox_toggles('comment'); var $timestampdiv = $('#timestampdiv'), - stamp = $('#timestamp').html(); + $timestamp = $( '#timestamp' ), + stamp = $timestamp.html(), + $timestampwrap = $timestampdiv.find( '.timestamp-wrap' ), + $edittimestamp = $timestampdiv.siblings( 'a.edit-timestamp' ); - $timestampdiv.siblings('a.edit-timestamp').click( function( event ) { + $edittimestamp.click( function( event ) { if ( $timestampdiv.is( ':hidden' ) ) { $timestampdiv.slideDown( 'fast', function() { - $( 'input, select', $timestampdiv.find( '.timestamp-wrap' ) ).first().focus(); + $( 'input, select', $timestampwrap ).first().focus(); } ); $(this).hide(); } @@ -17,13 +20,15 @@ jQuery(document).ready( function($) { }); $timestampdiv.find('.cancel-timestamp').click( function( event ) { - $timestampdiv.slideUp('fast').siblings('a.edit-timestamp').show().focus(); + // Move focus back to the Edit link. + $edittimestamp.show().focus(); + $timestampdiv.slideUp( 'fast' ); $('#mm').val($('#hidden_mm').val()); $('#jj').val($('#hidden_jj').val()); $('#aa').val($('#hidden_aa').val()); $('#hh').val($('#hidden_hh').val()); $('#mn').val($('#hidden_mn').val()); - $('#timestamp').html(stamp); + $timestamp.html( stamp ); event.preventDefault(); }); @@ -34,13 +39,13 @@ jQuery(document).ready( function($) { event.preventDefault(); if ( newD.getFullYear() != aa || (1 + newD.getMonth()) != mm || newD.getDate() != jj || newD.getMinutes() != mn ) { - $timestampdiv.find('.timestamp-wrap').addClass('form-invalid'); + $timestampwrap.addClass( 'form-invalid' ); return; } else { - $timestampdiv.find('.timestamp-wrap').removeClass('form-invalid'); + $timestampwrap.removeClass( 'form-invalid' ); } - $('#timestamp').html( + $timestamp.html( commentL10n.submittedOn + ' ' + commentL10n.dateFormat .replace( '%1$s', $( 'option[value="' + mm + '"]', '#mm' ).attr( 'data-text' ) ) @@ -51,7 +56,8 @@ jQuery(document).ready( function($) { ' ' ); - $timestampdiv.slideUp('fast'); - $timestampdiv.siblings('a.edit-timestamp').show(); + // Move focus back to the Edit link. + $edittimestamp.show().focus(); + $timestampdiv.slideUp( 'fast' ); }); });