Making WordPress.org

Changeset 6400


Ignore:
Timestamp:
01/18/2018 06:36:37 PM (9 years ago)
Author:
obenland
Message:

DevHub: Add a notification for screen readers after voting on a user contributed note

Props keesiemeijer.
Fixes #1819.

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/user-content-voting.php

    r5432 r6400  
    6565                // Only need to enqueue voting-related resources if there are comments to vote on.
    6666                if ( self::user_can_vote() && is_singular() && '0' != get_comments_number() ) {
    67                         wp_register_script( 'wporg-developer-user-notes-voting', get_template_directory_uri() . '/js/user-notes-voting.js', array(), '20160623', true );
     67                        wp_register_script( 'wporg-developer-user-notes-voting', get_template_directory_uri() . '/js/user-notes-voting.js', array( 'wp-a11y' ), '20160623', true );
    6868                        wp_localize_script( 'wporg-developer-user-notes-voting', 'ajaxurl', admin_url( 'admin-ajax.php' ) );
    6969                        wp_enqueue_script( 'wporg-developer-user-notes-voting' );
    … …  
    307307                }
    308308
    309                 echo '<div class="user-note-voting" data-nonce="' . esc_attr( $nonce ) . '">';
     309                echo '<div id="user-note-voting" class="user-note-voting" data-nonce="' . esc_attr( $nonce ) . '">';
    310310
    311311                // Up vote link
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/js/user-notes-voting.js

    r3561 r6400  
    44 */
    55
    6 ( function( $ ) {
    7         $( document ).on( 'click', '.user-note-voting a', function(e) {
    8                 e.preventDefault();
     6( function( $, wp ) {
     7        $( '#user-note-voting' ).on( 'click', '.user-note-voting-up, .user-note-voting-down', function( event ) {
     8                event.preventDefault();
    99
    10                 var item = $(this);
     10                var $item = $( this ),
     11                        comment = $item.closest( '.comment' );
    1112
    12                 $.post(ajaxurl, {
    13                                 action:   "note_vote",
    14                                 comment:  $(this).attr('data-id'),
    15                                 vote:     $(this).attr('data-vote'),
    16                                 _wpnonce: $(this).parent().attr('data-nonce')
    17                         }, function(data) {
    18                                 if ("0" != data) {
    19                                         item.closest('.user-note-voting').replaceWith(data);
     13                $.post(
     14                        ajaxurl,
     15                        {
     16                                action:   'note_vote',
     17                                comment:  $item.attr( 'data-id' ),
     18                                vote:     $item.attr( 'data-vote' ),
     19                                _wpnonce: $item.parent().attr( 'data-nonce' )
     20                        },
     21                        function( data ) {
     22                                if ( '0' !== data ) {
     23                                        $item.closest( '.user-note-voting' ).replaceWith( data );
     24                                        wp.a11y.speak( $( '.user-note-voting-count', comment ).text() );
    2025                                }
    21                         }, "text"
     26                        },
     27                        'text'
    2228                );
     29
    2330                return false;
    24         });
    25 } )( jQuery );
     31        } );
     32} )( window.jQuery, window.wp );
Note: See TracChangeset for help on using the changeset viewer.