2018-06-27 22:30:15 -04:00
|
|
|
/**
|
|
|
|
* @output wp-admin/js/comment.js
|
|
|
|
*/
|
|
|
|
|
2020-07-07 14:40:05 -04:00
|
|
|
/* global postboxes */
|
2017-06-15 09:02:40 -04:00
|
|
|
|
|
|
|
/**
|
2017-12-18 09:14:53 -05:00
|
|
|
* Binds to the document ready event.
|
2017-06-15 09:02:40 -04:00
|
|
|
*
|
|
|
|
* @since 2.5.0
|
|
|
|
*
|
|
|
|
* @param {jQuery} $ The jQuery object.
|
|
|
|
*/
|
2021-03-18 15:01:03 -04:00
|
|
|
jQuery( function($) {
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2012-09-03 11:39:06 -04:00
|
|
|
postboxes.add_postbox_toggles('comment');
|
|
|
|
|
2015-07-21 18:09:25 -04:00
|
|
|
var $timestampdiv = $('#timestampdiv'),
|
2015-07-25 22:26:24 -04:00
|
|
|
$timestamp = $( '#timestamp' ),
|
|
|
|
stamp = $timestamp.html(),
|
|
|
|
$timestampwrap = $timestampdiv.find( '.timestamp-wrap' ),
|
|
|
|
$edittimestamp = $timestampdiv.siblings( 'a.edit-timestamp' );
|
2015-07-21 18:09:25 -04:00
|
|
|
|
2017-06-15 09:02:40 -04:00
|
|
|
/**
|
2017-12-18 09:14:53 -05:00
|
|
|
* Adds event that opens the time stamp form if the form is hidden.
|
2017-06-15 09:02:40 -04:00
|
|
|
*
|
|
|
|
* @listens $edittimestamp:click
|
|
|
|
*
|
|
|
|
* @param {Event} event The event object.
|
2019-11-29 13:01:03 -05:00
|
|
|
* @return {void}
|
2017-06-15 09:02:40 -04:00
|
|
|
*/
|
2021-01-22 07:32:03 -05:00
|
|
|
$edittimestamp.on( 'click', function( event ) {
|
2015-07-21 18:09:25 -04:00
|
|
|
if ( $timestampdiv.is( ':hidden' ) ) {
|
2017-06-15 09:02:40 -04:00
|
|
|
// Slide down the form and set focus on the first field.
|
2015-07-21 18:46:24 -04:00
|
|
|
$timestampdiv.slideDown( 'fast', function() {
|
2021-01-22 07:32:03 -05:00
|
|
|
$( 'input, select', $timestampwrap ).first().trigger( 'focus' );
|
2015-07-21 18:46:24 -04:00
|
|
|
} );
|
2015-07-21 18:09:25 -04:00
|
|
|
$(this).hide();
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
2015-07-21 18:09:25 -04:00
|
|
|
event.preventDefault();
|
2012-08-22 20:04:18 -04:00
|
|
|
});
|
|
|
|
|
2017-06-15 09:02:40 -04:00
|
|
|
/**
|
2017-12-18 09:14:53 -05:00
|
|
|
* Resets the time stamp values when the cancel button is clicked.
|
2017-06-15 09:02:40 -04:00
|
|
|
*
|
|
|
|
* @listens .cancel-timestamp:click
|
|
|
|
*
|
|
|
|
* @param {Event} event The event object.
|
2019-11-29 13:01:03 -05:00
|
|
|
* @return {void}
|
2017-06-15 09:02:40 -04:00
|
|
|
*/
|
|
|
|
|
2021-01-22 07:32:03 -05:00
|
|
|
$timestampdiv.find('.cancel-timestamp').on( 'click', function( event ) {
|
2015-07-25 22:26:24 -04:00
|
|
|
// Move focus back to the Edit link.
|
2021-01-22 07:32:03 -05:00
|
|
|
$edittimestamp.show().trigger( 'focus' );
|
2015-07-25 22:26:24 -04:00
|
|
|
$timestampdiv.slideUp( 'fast' );
|
2012-08-22 20:04:18 -04: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-25 22:26:24 -04:00
|
|
|
$timestamp.html( stamp );
|
2015-07-21 18:09:25 -04:00
|
|
|
event.preventDefault();
|
2012-08-22 20:04:18 -04:00
|
|
|
});
|
|
|
|
|
2017-06-15 09:02:40 -04:00
|
|
|
/**
|
2017-12-18 09:14:53 -05:00
|
|
|
* Sets the time stamp values when the ok button is clicked.
|
2017-06-15 09:02:40 -04:00
|
|
|
*
|
|
|
|
* @listens .save-timestamp:click
|
|
|
|
*
|
|
|
|
* @param {Event} event The event object.
|
2019-11-29 13:01:03 -05:00
|
|
|
* @return {void}
|
2017-06-15 09:02:40 -04:00
|
|
|
*/
|
2024-02-11 14:14:19 -05:00
|
|
|
$timestampdiv.find('.save-timestamp').on( 'click', function( event ) { // Crazyhorse branch - multiple OK cancels.
|
2012-08-22 20:04:18 -04: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-21 18:09:25 -04:00
|
|
|
event.preventDefault();
|
|
|
|
|
2012-08-22 20:04:18 -04:00
|
|
|
if ( newD.getFullYear() != aa || (1 + newD.getMonth()) != mm || newD.getDate() != jj || newD.getMinutes() != mn ) {
|
2015-07-25 22:26:24 -04:00
|
|
|
$timestampwrap.addClass( 'form-invalid' );
|
2015-07-21 18:09:25 -04:00
|
|
|
return;
|
2012-08-22 20:04:18 -04:00
|
|
|
} else {
|
2015-07-25 22:26:24 -04:00
|
|
|
$timestampwrap.removeClass( 'form-invalid' );
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
|
|
|
|
2015-07-25 22:26:24 -04:00
|
|
|
$timestamp.html(
|
2020-07-07 14:40:05 -04:00
|
|
|
wp.i18n.__( 'Submitted on:' ) + ' <b>' +
|
|
|
|
/* translators: 1: Month, 2: Day, 3: Year, 4: Hour, 5: Minute. */
|
|
|
|
wp.i18n.__( '%1$s %2$s, %3$s at %4$s:%5$s' )
|
2015-07-21 18:09:25 -04:00
|
|
|
.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-22 20:04:18 -04:00
|
|
|
);
|
2015-07-21 18:09:25 -04:00
|
|
|
|
2015-07-25 22:26:24 -04:00
|
|
|
// Move focus back to the Edit link.
|
2021-01-22 07:32:03 -05:00
|
|
|
$edittimestamp.show().trigger( 'focus' );
|
2015-07-25 22:26:24 -04:00
|
|
|
$timestampdiv.slideUp( 'fast' );
|
2012-08-22 20:04:18 -04:00
|
|
|
});
|
|
|
|
});
|