2015-07-21 01:39:24 +02:00
|
|
|
/* global postboxes, commentL10n */
|
2012-08-23 02:04:18 +02:00
|
|
|
jQuery(document).ready( function($) {
|
|
|
|
|
2012-09-03 17:39:06 +02:00
|
|
|
postboxes.add_postbox_toggles('comment');
|
|
|
|
|
2015-07-22 00:09:25 +02:00
|
|
|
var $timestampdiv = $('#timestampdiv'),
|
2015-07-26 04:26:24 +02:00
|
|
|
$timestamp = $( '#timestamp' ),
|
|
|
|
stamp = $timestamp.html(),
|
|
|
|
$timestampwrap = $timestampdiv.find( '.timestamp-wrap' ),
|
|
|
|
$edittimestamp = $timestampdiv.siblings( 'a.edit-timestamp' );
|
2015-07-22 00:09:25 +02:00
|
|
|
|
2015-07-26 04:26:24 +02:00
|
|
|
$edittimestamp.click( function( event ) {
|
2015-07-22 00:09:25 +02:00
|
|
|
if ( $timestampdiv.is( ':hidden' ) ) {
|
2015-07-22 00:46:24 +02:00
|
|
|
$timestampdiv.slideDown( 'fast', function() {
|
2015-07-26 04:26:24 +02:00
|
|
|
$( 'input, select', $timestampwrap ).first().focus();
|
2015-07-22 00:46:24 +02:00
|
|
|
} );
|
2015-07-22 00:09:25 +02:00
|
|
|
$(this).hide();
|
2012-08-23 02:04:18 +02:00
|
|
|
}
|
2015-07-22 00:09:25 +02:00
|
|
|
event.preventDefault();
|
2012-08-23 02:04:18 +02:00
|
|
|
});
|
|
|
|
|
2015-07-22 00:09:25 +02:00
|
|
|
$timestampdiv.find('.cancel-timestamp').click( function( event ) {
|
2015-07-26 04:26:24 +02:00
|
|
|
// Move focus back to the Edit link.
|
|
|
|
$edittimestamp.show().focus();
|
|
|
|
$timestampdiv.slideUp( 'fast' );
|
2012-08-23 02:04:18 +02:00
|
|
|
$('#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());
|
2015-07-26 04:26:24 +02:00
|
|
|
$timestamp.html( stamp );
|
2015-07-22 00:09:25 +02:00
|
|
|
event.preventDefault();
|
2012-08-23 02:04:18 +02:00
|
|
|
});
|
|
|
|
|
2015-07-22 00:09:25 +02:00
|
|
|
$timestampdiv.find('.save-timestamp').click( function( event ) { // crazyhorse - multiple ok cancels
|
2012-08-23 02:04:18 +02:00
|
|
|
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 );
|
|
|
|
|
2015-07-22 00:09:25 +02:00
|
|
|
event.preventDefault();
|
|
|
|
|
2012-08-23 02:04:18 +02:00
|
|
|
if ( newD.getFullYear() != aa || (1 + newD.getMonth()) != mm || newD.getDate() != jj || newD.getMinutes() != mn ) {
|
2015-07-26 04:26:24 +02:00
|
|
|
$timestampwrap.addClass( 'form-invalid' );
|
2015-07-22 00:09:25 +02:00
|
|
|
return;
|
2012-08-23 02:04:18 +02:00
|
|
|
} else {
|
2015-07-26 04:26:24 +02:00
|
|
|
$timestampwrap.removeClass( 'form-invalid' );
|
2012-08-23 02:04:18 +02:00
|
|
|
}
|
|
|
|
|
2015-07-26 04:26:24 +02:00
|
|
|
$timestamp.html(
|
2012-08-23 02:04:18 +02:00
|
|
|
commentL10n.submittedOn + ' <b>' +
|
2015-07-22 00:09:25 +02:00
|
|
|
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 ) ) +
|
|
|
|
'</b> '
|
2012-08-23 02:04:18 +02:00
|
|
|
);
|
2015-07-22 00:09:25 +02:00
|
|
|
|
2015-07-26 04:26:24 +02:00
|
|
|
// Move focus back to the Edit link.
|
|
|
|
$edittimestamp.show().focus();
|
|
|
|
$timestampdiv.slideUp( 'fast' );
|
2012-08-23 02:04:18 +02:00
|
|
|
});
|
|
|
|
});
|