]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/js/comment.js
WordPress 4.3
[autoinstalls/wordpress.git] / wp-admin / js / comment.js
index ac65c92fa7880c9366d5baee2fb179d0b1433c57..d194148f60d704f947d93d098a30844bd23070cb 100644 (file)
@@ -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(){b("#timestampdiv").slideUp("normal");b(".edit-timestamp").show();b("#timestamp").html(commentL10n.submittedOn+" <b>"+b("#mm option[value="+b("#mm").val()+"]").text()+" "+b("#jj").val()+", "+b("#aa").val()+" @ "+b("#hh").val()+":"+b("#mn").val()+"</b> ");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 + ' <b>' +
+                       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> '
+               );
+
+               // Move focus back to the Edit link.
+               $edittimestamp.show().focus();
+               $timestampdiv.slideUp( 'fast' );
+       });
+});