From 93baee020cdf72f99ceea361973a9b2548a46dd2 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 26 Jul 2015 02:26:24 +0000 Subject: [PATCH] Comment status box: Move focus back to Edit link when changing the date. props afercia. fixes #33062. Built from https://develop.svn.wordpress.org/trunk@33422 git-svn-id: http://core.svn.wordpress.org/trunk@33390 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/js/comment.js | 26 ++++++++++++++++---------- wp-admin/js/comment.min.js | 2 +- wp-includes/version.php | 2 +- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/wp-admin/js/comment.js b/wp-admin/js/comment.js index b6490fdc2c..d194148f60 100644 --- a/wp-admin/js/comment.js +++ b/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' ); }); }); diff --git a/wp-admin/js/comment.min.js b/wp-admin/js/comment.min.js index 7336b2cd03..08512640e9 100644 --- a/wp-admin/js/comment.min.js +++ b/wp-admin/js/comment.min.js @@ -1 +1 @@ -jQuery(document).ready(function(a){postboxes.add_postbox_toggles("comment");var b=a("#timestampdiv"),c=a("#timestamp").html();b.siblings("a.edit-timestamp").click(function(c){b.is(":hidden")&&(b.slideDown("fast",function(){a("input, select",b.find(".timestamp-wrap")).first().focus()}),a(this).hide()),c.preventDefault()}),b.find(".cancel-timestamp").click(function(d){b.slideUp("fast").siblings("a.edit-timestamp").show().focus(),a("#mm").val(a("#hidden_mm").val()),a("#jj").val(a("#hidden_jj").val()),a("#aa").val(a("#hidden_aa").val()),a("#hh").val(a("#hidden_hh").val()),a("#mn").val(a("#hidden_mn").val()),a("#timestamp").html(c),d.preventDefault()}),b.find(".save-timestamp").click(function(c){var d=a("#aa").val(),e=a("#mm").val(),f=a("#jj").val(),g=a("#hh").val(),h=a("#mn").val(),i=new Date(d,e-1,f,g,h);return c.preventDefault(),i.getFullYear()!=d||1+i.getMonth()!=e||i.getDate()!=f||i.getMinutes()!=h?void b.find(".timestamp-wrap").addClass("form-invalid"):(b.find(".timestamp-wrap").removeClass("form-invalid"),a("#timestamp").html(commentL10n.submittedOn+" "+commentL10n.dateFormat.replace("%1$s",a('option[value="'+e+'"]',"#mm").attr("data-text")).replace("%2$s",parseInt(f,10)).replace("%3$s",d).replace("%4$s",("00"+g).slice(-2)).replace("%5$s",("00"+h).slice(-2))+" "),b.slideUp("fast"),void b.siblings("a.edit-timestamp").show())})}); \ No newline at end of file +jQuery(document).ready(function(a){postboxes.add_postbox_toggles("comment");var b=a("#timestampdiv"),c=a("#timestamp"),d=c.html(),e=b.find(".timestamp-wrap"),f=b.siblings("a.edit-timestamp");f.click(function(c){b.is(":hidden")&&(b.slideDown("fast",function(){a("input, select",e).first().focus()}),a(this).hide()),c.preventDefault()}),b.find(".cancel-timestamp").click(function(e){f.show().focus(),b.slideUp("fast"),a("#mm").val(a("#hidden_mm").val()),a("#jj").val(a("#hidden_jj").val()),a("#aa").val(a("#hidden_aa").val()),a("#hh").val(a("#hidden_hh").val()),a("#mn").val(a("#hidden_mn").val()),c.html(d),e.preventDefault()}),b.find(".save-timestamp").click(function(d){var g=a("#aa").val(),h=a("#mm").val(),i=a("#jj").val(),j=a("#hh").val(),k=a("#mn").val(),l=new Date(g,h-1,i,j,k);return d.preventDefault(),l.getFullYear()!=g||1+l.getMonth()!=h||l.getDate()!=i||l.getMinutes()!=k?void e.addClass("form-invalid"):(e.removeClass("form-invalid"),c.html(commentL10n.submittedOn+" "+commentL10n.dateFormat.replace("%1$s",a('option[value="'+h+'"]',"#mm").attr("data-text")).replace("%2$s",parseInt(i,10)).replace("%3$s",g).replace("%4$s",("00"+j).slice(-2)).replace("%5$s",("00"+k).slice(-2))+" "),f.show().focus(),void b.slideUp("fast"))})}); \ No newline at end of file diff --git a/wp-includes/version.php b/wp-includes/version.php index ad3104b9bd..7c09bd07a1 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.3-beta4-33421'; +$wp_version = '4.3-beta4-33422'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.