Making WordPress.org

Changeset 6494


Ignore:
Timestamp:
01/31/2018 11:37:14 PM (7 years ago)
Author:
obenland
Message:

Plugins: Encode faq title rather than rolling my own

Props ocean90.
Closes #3319.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/js/section-faq.js

    r6285 r6494  
    11( function( $ ) {
    22    var questions = $( 'dt', '#faq' );
    3     var hash      = window.location.hash.replace( /[^a-z0-9-#]/gi, '' );
    43
    54    questions
     
    1110            // If there is no ID, create our own.
    1211            if ( ! id ) {
    13                 id = '#' + $question.text().toLowerCase().replace( /[^\w\s]/gi, '' ).replace( /\s/gi, '-' );
     12                id = '#' + encodeURIComponent( $question.text().toLowerCase() );
    1413                $question.attr( 'id', id );
    1514            }
     
    3635            } ).next( 'dd' ).slideToggle( 200 );
    3736
    38             if ( hash ) {
     37            if ( window.location.hash ) {
    3938                window.scrollTo( 0, $question.offset().top );
    4039            }
    4140        } );
    4241
    43     if ( hash ) {
    44         questions.find( '[href="' + hash + '"]' ).trigger( 'click' );
     42    if ( window.location.hash ) {
     43        questions.find( '[href="' + window.location.hash + '"]' ).trigger( 'click' );
    4544    }
    4645} )( jQuery );
Note: See TracChangeset for help on using the changeset viewer.