Making WordPress.org

Ticket #1819: 1819.2.patch

File 1819.2.patch, 2.0 KB (added by keesiemeijer, 9 years ago)

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

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

     
    6464        public static function scripts_and_styles() {
    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' );
    7070                }
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/js/user-notes-voting.js

     
    88                e.preventDefault();
    99
    1010                var item = $(this);
     11                var comment = item.closest( '.comment' );
    1112
    1213                $.post(ajaxurl, {
    1314                                action:   "note_vote",
     
    1718                        }, function(data) {
    1819                                if ("0" != data) {
    1920                                        item.closest('.user-note-voting').replaceWith(data);
     21                                        var updated_count = $( '.user-note-voting-count', comment ).text();
     22
     23                                        if ( updated_count.length && ( wp.a11y !== undefined ) ) {
     24                                                wp.a11y.speak( updated_count );
     25                                        }
    2026                                }
    2127                        }, "text"
    2228                );