1 /* global postboxes, commentL10n */
2 jQuery(document).ready( function($) {
4 postboxes.add_postbox_toggles('comment');
6 var $timestampdiv = $('#timestampdiv'),
7 $timestamp = $( '#timestamp' ),
8 stamp = $timestamp.html(),
9 $timestampwrap = $timestampdiv.find( '.timestamp-wrap' ),
10 $edittimestamp = $timestampdiv.siblings( 'a.edit-timestamp' );
12 $edittimestamp.click( function( event ) {
13 if ( $timestampdiv.is( ':hidden' ) ) {
14 $timestampdiv.slideDown( 'fast', function() {
15 $( 'input, select', $timestampwrap ).first().focus();
19 event.preventDefault();
22 $timestampdiv.find('.cancel-timestamp').click( function( event ) {
23 // Move focus back to the Edit link.
24 $edittimestamp.show().focus();
25 $timestampdiv.slideUp( 'fast' );
26 $('#mm').val($('#hidden_mm').val());
27 $('#jj').val($('#hidden_jj').val());
28 $('#aa').val($('#hidden_aa').val());
29 $('#hh').val($('#hidden_hh').val());
30 $('#mn').val($('#hidden_mn').val());
31 $timestamp.html( stamp );
32 event.preventDefault();
35 $timestampdiv.find('.save-timestamp').click( function( event ) { // crazyhorse - multiple ok cancels
36 var aa = $('#aa').val(), mm = $('#mm').val(), jj = $('#jj').val(), hh = $('#hh').val(), mn = $('#mn').val(),
37 newD = new Date( aa, mm - 1, jj, hh, mn );
39 event.preventDefault();
41 if ( newD.getFullYear() != aa || (1 + newD.getMonth()) != mm || newD.getDate() != jj || newD.getMinutes() != mn ) {
42 $timestampwrap.addClass( 'form-invalid' );
45 $timestampwrap.removeClass( 'form-invalid' );
49 commentL10n.submittedOn + ' <b>' +
50 commentL10n.dateFormat
51 .replace( '%1$s', $( 'option[value="' + mm + '"]', '#mm' ).attr( 'data-text' ) )
52 .replace( '%2$s', parseInt( jj, 10 ) )
53 .replace( '%3$s', aa )
54 .replace( '%4$s', ( '00' + hh ).slice( -2 ) )
55 .replace( '%5$s', ( '00' + mn ).slice( -2 ) ) +
59 // Move focus back to the Edit link.
60 $edittimestamp.show().focus();
61 $timestampdiv.slideUp( 'fast' );