[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 /** 2 * @output wp-admin/js/comment.js 3 */ 4 5 /* global postboxes */ 6 7 /** 8 * Binds to the document ready event. 9 * 10 * @since 2.5.0 11 * 12 * @param {jQuery} $ The jQuery object. 13 */ 14 jQuery( function($) { 15 16 postboxes.add_postbox_toggles('comment'); 17 18 var $timestampdiv = $('#timestampdiv'), 19 $timestamp = $( '#timestamp' ), 20 stamp = $timestamp.html(), 21 $timestampwrap = $timestampdiv.find( '.timestamp-wrap' ), 22 $edittimestamp = $timestampdiv.siblings( 'a.edit-timestamp' ); 23 24 /** 25 * Adds event that opens the time stamp form if the form is hidden. 26 * 27 * @listens $edittimestamp:click 28 * 29 * @param {Event} event The event object. 30 * @return {void} 31 */ 32 $edittimestamp.on( 'click', function( event ) { 33 if ( $timestampdiv.is( ':hidden' ) ) { 34 // Slide down the form and set focus on the first field. 35 $timestampdiv.slideDown( 'fast', function() { 36 $( 'input, select', $timestampwrap ).first().trigger( 'focus' ); 37 } ); 38 $(this).hide(); 39 } 40 event.preventDefault(); 41 }); 42 43 /** 44 * Resets the time stamp values when the cancel button is clicked. 45 * 46 * @listens .cancel-timestamp:click 47 * 48 * @param {Event} event The event object. 49 * @return {void} 50 */ 51 52 $timestampdiv.find('.cancel-timestamp').on( 'click', function( event ) { 53 // Move focus back to the Edit link. 54 $edittimestamp.show().trigger( 'focus' ); 55 $timestampdiv.slideUp( 'fast' ); 56 $('#mm').val($('#hidden_mm').val()); 57 $('#jj').val($('#hidden_jj').val()); 58 $('#aa').val($('#hidden_aa').val()); 59 $('#hh').val($('#hidden_hh').val()); 60 $('#mn').val($('#hidden_mn').val()); 61 $timestamp.html( stamp ); 62 event.preventDefault(); 63 }); 64 65 /** 66 * Sets the time stamp values when the ok button is clicked. 67 * 68 * @listens .save-timestamp:click 69 * 70 * @param {Event} event The event object. 71 * @return {void} 72 */ 73 $timestampdiv.find('.save-timestamp').on( 'click', function( event ) { // Crazyhorse branch - multiple OK cancels. 74 var aa = $('#aa').val(), mm = $('#mm').val(), jj = $('#jj').val(), hh = $('#hh').val(), mn = $('#mn').val(), 75 newD = new Date( aa, mm - 1, jj, hh, mn ); 76 77 event.preventDefault(); 78 79 if ( newD.getFullYear() != aa || (1 + newD.getMonth()) != mm || newD.getDate() != jj || newD.getMinutes() != mn ) { 80 $timestampwrap.addClass( 'form-invalid' ); 81 return; 82 } else { 83 $timestampwrap.removeClass( 'form-invalid' ); 84 } 85 86 $timestamp.html( 87 wp.i18n.__( 'Submitted on:' ) + ' <b>' + 88 /* translators: 1: Month, 2: Day, 3: Year, 4: Hour, 5: Minute. */ 89 wp.i18n.__( '%1$s %2$s, %3$s at %4$s:%5$s' ) 90 .replace( '%1$s', $( 'option[value="' + mm + '"]', '#mm' ).attr( 'data-text' ) ) 91 .replace( '%2$s', parseInt( jj, 10 ) ) 92 .replace( '%3$s', aa ) 93 .replace( '%4$s', ( '00' + hh ).slice( -2 ) ) 94 .replace( '%5$s', ( '00' + mn ).slice( -2 ) ) + 95 '</b> ' 96 ); 97 98 // Move focus back to the Edit link. 99 $edittimestamp.show().trigger( 'focus' ); 100 $timestampdiv.slideUp( 'fast' ); 101 }); 102 });
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Thu Nov 21 08:20:01 2024 | Cross-referenced by PHPXref |