X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/38ca813a0e312e2768e5b9519f0415cd0aa84781..53f4633144ed68c8b8fb5861f992b5489894a940:/wp-admin/js/comment.js diff --git a/wp-admin/js/comment.js b/wp-admin/js/comment.js index 5816ebb1..d194148f 100644 --- a/wp-admin/js/comment.js +++ b/wp-admin/js/comment.js @@ -1 +1,63 @@ -jQuery(document).ready(function(b){var a=b("#timestamp").html();b(".edit-timestamp").click(function(){if(b("#timestampdiv").is(":hidden")){b("#timestampdiv").slideDown("normal");b(".edit-timestamp").hide()}return false});b(".cancel-timestamp").click(function(){b("#timestampdiv").slideUp("normal");b("#mm").val(b("#hidden_mm").val());b("#jj").val(b("#hidden_jj").val());b("#aa").val(b("#hidden_aa").val());b("#hh").val(b("#hidden_hh").val());b("#mn").val(b("#hidden_mn").val());b("#timestamp").html(a);b(".edit-timestamp").show();return false});b(".save-timestamp").click(function(){var g=b("#aa").val(),h=b("#mm").val(),d=b("#jj").val(),c=b("#hh").val(),f=b("#mn").val(),e=new Date(g,h-1,d,c,f);if(e.getFullYear()!=g||(1+e.getMonth())!=h||e.getDate()!=d||e.getMinutes()!=f){b(".timestamp-wrap","#timestampdiv").addClass("form-invalid");return false}else{b(".timestamp-wrap","#timestampdiv").removeClass("form-invalid")}b("#timestampdiv").slideUp("normal");b(".edit-timestamp").show();b("#timestamp").html(commentL10n.submittedOn+" "+b('#mm option[value="'+h+'"]').text()+" "+d+", "+g+" @ "+c+":"+f+" ");return false})}); \ No newline at end of file +/* global postboxes, commentL10n */ +jQuery(document).ready( function($) { + + postboxes.add_postbox_toggles('comment'); + + var $timestampdiv = $('#timestampdiv'), + $timestamp = $( '#timestamp' ), + stamp = $timestamp.html(), + $timestampwrap = $timestampdiv.find( '.timestamp-wrap' ), + $edittimestamp = $timestampdiv.siblings( 'a.edit-timestamp' ); + + $edittimestamp.click( function( event ) { + if ( $timestampdiv.is( ':hidden' ) ) { + $timestampdiv.slideDown( 'fast', function() { + $( 'input, select', $timestampwrap ).first().focus(); + } ); + $(this).hide(); + } + event.preventDefault(); + }); + + $timestampdiv.find('.cancel-timestamp').click( function( event ) { + // 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 ); + event.preventDefault(); + }); + + $timestampdiv.find('.save-timestamp').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 ); + + event.preventDefault(); + + if ( newD.getFullYear() != aa || (1 + newD.getMonth()) != mm || newD.getDate() != jj || newD.getMinutes() != mn ) { + $timestampwrap.addClass( 'form-invalid' ); + return; + } else { + $timestampwrap.removeClass( 'form-invalid' ); + } + + $timestamp.html( + commentL10n.submittedOn + ' ' + + commentL10n.dateFormat + .replace( '%1$s', $( 'option[value="' + mm + '"]', '#mm' ).attr( 'data-text' ) ) + .replace( '%2$s', parseInt( jj, 10 ) ) + .replace( '%3$s', aa ) + .replace( '%4$s', ( '00' + hh ).slice( -2 ) ) + .replace( '%5$s', ( '00' + mn ).slice( -2 ) ) + + ' ' + ); + + // Move focus back to the Edit link. + $edittimestamp.show().focus(); + $timestampdiv.slideUp( 'fast' ); + }); +});