Changeset 1846
- Timestamp:
- 08/24/2015 07:33:54 PM (9 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/parsed-content.php
r1063 r1846 123 123 <?php esc_attr_e( 'Detach Ticket', 'wporg' ); ?> 124 124 </a> 125 <span class="spinner"></span> 125 126 </span> 126 127 <div id="ticket_status"> 127 <span class="spinner"></span>128 128 <span class="ticket_info_icon <?php echo $ticket ? 'dashicons dashicons-external' : ''; ?>"></span> 129 129 <span id="wporg_ticket_info"><em><?php echo $ticket_message; ?></em></span> … … 167 167 wp_enqueue_script( 'wporg-parsed-content', get_template_directory_uri() . '/js/parsed-content.js', array( 'jquery', 'utils' ), '20140826', true ); 168 168 169 wp_localize_script( 'wporg-parsed-content', 'wporg ', array(169 wp_localize_script( 'wporg-parsed-content', 'wporgParsedContent', array( 170 170 'ajaxURL' => admin_url( 'admin-ajax.php' ), 171 171 'searchText' => __( 'Searching ...', 'wporg' ), 172 'retryText' => __( 'Invalid ticket number, please try again.', 'wporg' ) 172 173 ) ); 173 174 } … … 216 217 217 218 // Can haz success. 218 $message =array(219 ' type' => 'success',220 ' message' => $link,221 ) ;219 wp_send_json_success( array( 220 'message' => $link, 221 'new_nonce' => wp_create_nonce( 'wporg-attach-ticket' ) 222 ) ); 222 223 223 224 } else { 224 225 // Ticket number is invalid. 225 $message = array( 226 'type' => 'invalid', 227 'message' => __( 'Invalid ticket number.', 'wporg' ), 228 ); 229 } 230 231 // Slap on a new nonce for repeat offenders. 232 $message['new_nonce'] = wp_create_nonce( 'wporg-attach-ticket' ); 233 234 die( json_encode( $message ) ); 226 wp_send_json_error( array( 227 'message' => __( 'Invalid ticket number.', 'wporg' ), 228 'new_nonce' => wp_create_nonce( 'wporg-attach-ticket' ) 229 ) ); 230 } 231 232 die( 0 ); 235 233 } 236 234 … … 249 247 && delete_post_meta( $post_id, 'wporg_ticket_title' ) 250 248 ) { 251 $message = array( 252 'type' => 'success', 253 'message' => __( 'Ticket detached.', 'wporg' ) 254 ); 249 // Success! 250 wp_send_json_success( array( 251 'message' => __( 'Ticket detached.', 'wporg' ), 252 'new_nonce' => wp_create_nonce( 'wporg-detach-ticket' ) 253 ) ); 254 255 255 } else { 256 256 // Still attached. 257 $message = array( 258 'type' => 'failure', 259 'message' => __( 'Ticket still attached.', 'wporg' ) 260 ); 261 } 262 263 // Slap on a new nonce for repeat offenders. 264 $message['new_nonce'] = wp_create_nonce( 'wporg-detach-ticket' ); 265 266 die( json_encode( $message ) ); 257 wp_send_json_error( array( 258 'message' => __( 'Ticket still attached.', 'wporg' ), 259 'new_nonce' => wp_create_nonce( 'wporg-detach-ticket' ) 260 ) ); 261 } 262 263 die( 0 ); 267 264 } 268 265 -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/js/parsed-content.js
r942 r1846 8 8 detachButton = $( '#wporg_ticket_detach' ), 9 9 ticketInfo = $( '#wporg_ticket_info' ), 10 spinner = $( ' #ticket_status .spinner' );10 spinner = $( '.attachment_controls .spinner' ); 11 11 12 12 var handleTicket = function( event ) { … … 16 16 attachAction = 'attach' == event.data.action; 17 17 18 spinner. css( 'display', 'inline-block' );18 spinner.addClass( 'is-active' ); 19 19 20 // Searching ... text. 20 21 if ( attachAction ) { 21 ticketInfo.text( wporg .searchText );22 ticketInfo.text( wporgParsedContent.searchText ); 22 23 } 23 24 24 var data = { 25 action: attachAction ? 'wporg_attach_ticket' : 'wporg_detach_ticket', 25 var request = wp.ajax.post( attachAction ? 'wporg_attach_ticket' : 'wporg_detach_ticket', { 26 26 ticket: ticketNumber.val(), 27 27 nonce: $this.data( 'nonce' ), 28 28 post_id: $this.data( 'id' ) 29 } ;29 } ); 30 30 31 $.post( wporg.ajaxURL, data, function( resp ) { 31 // Success. 32 request.done( function( response ) { 32 33 // Refresh the nonce. 33 $this.data( 'nonce', resp .new_nonce );34 $this.data( 'nonce', response.new_nonce ); 34 35 35 spinner.hide(); 36 // Hide or show the parsed content boxes. 37 $( '.wporg_parsed_content' ).each( function() { 38 attachAction ? $(this).show() : $(this).hide(); 39 }); 36 40 37 // Update the ticket info text 38 ticketInfo.html( resp.message ).show(); 41 $( '.wporg_parsed_readonly' ).each( function() { 42 attachAction ? $(this).hide() : $(this).show(); 43 }); 39 44 40 // Handle the response. 41 if ( resp.type && 'success' == resp.type ) { 42 // Hide or show the parsed content boxes. 43 $( '.wporg_parsed_content' ).each( function() { 44 attachAction ? $(this).show() : $(this).hide(); 45 }); 45 var otherButton = attachAction ? detachButton : attachButton; 46 46 47 $( '.wporg_parsed_readonly' ).each( function() {48 attachAction ? $(this).hide() : $(this).show();49 });47 // Toggle the buttons. 48 $this.hide(); 49 otherButton.css( 'display', 'inline-block' ); 50 50 51 var otherButton = attachAction ? detachButton : attachButton; 51 // Update the ticket info text. 52 ticketInfo.html( response.message ).show(); 52 53 53 // Toggle the buttons. 54 $this.hide(); 55 otherButton.css( 'display', 'inline-block' ); 56 57 // Clear the ticket number when detaching. 58 if ( ! attachAction ) { 59 ticketNumber.val( '' ); 60 } 61 62 // Set or unset the ticket link icon. 63 $( '.ticket_info_icon' ).toggleClass( 'dashicons dashicons-external', attachAction ); 64 65 // Set the ticket number to readonly when a ticket is attached. 66 attachAction ? ticketNumber.prop( 'readonly', 'readonly' ) : ticketNumber.removeAttr( 'readonly' ); 67 } else { 68 ticketInfo.text( wporg.retryText ); 54 // Clear the ticket number when detaching. 55 if ( ! attachAction ) { 56 ticketNumber.val( '' ); 69 57 } 70 58 71 }, 'json' ); 59 spinner.removeClass( 'is-active' ); 60 61 // Set or unset the ticket link icon. 62 $( '.ticket_info_icon' ).toggleClass( 'dashicons dashicons-external', attachAction ); 63 64 // Set the ticket number to readonly when a ticket is attached. 65 attachAction ? ticketNumber.prop( 'readonly', 'readonly' ) : ticketNumber.removeAttr( 'readonly' ); 66 } ); 67 68 // Error. 69 request.fail( function( response ) { 70 // Refresh the nonce. 71 $this.data( 'nonce', response.new_nonce ); 72 73 // Retry text. 74 ticketInfo.text( wporgParsedContent.retryText ); 75 76 spinner.removeClass( 'is-active' ); 77 } ); 72 78 }; 73 79 -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/scss/admin.scss
r1057 r1846 11 11 } 12 12 13 #ticket_status .spinner {13 .attachment_controls .spinner { 14 14 position: relative; 15 margin-top: 3px; 15 16 bottom: 4px; 16 17 float: none; -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/stylesheets/admin.css
r1057 r1846 10 10 } 11 11 12 #ticket_status .spinner {12 .attachment_controls .spinner { 13 13 position: relative; 14 margin-top: 3px; 14 15 bottom: 4px; 15 16 float: none;
Note: See TracChangeset
for help on using the changeset viewer.