[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Summary view] [Print] [Text view]
1 /** 2 * Main JavaScript for the Cite extension. The main purpose of this file 3 * is to add accessibility attributes to the citation links as that can 4 * hardly be done server side (bug 38141). 5 * 6 * @author Marius Hoch <[email protected]> 7 */ 8 ( function ( mw, $ ) { 9 'use strict'; 10 11 mw.hook( 'wikipage.content' ).add( function ( $content ) { 12 var accessibilityLabelOne = mw.msg( 'cite_references_link_accessibility_label' ), 13 accessibilityLabelMany = mw.msg( 'cite_references_link_many_accessibility_label' ); 14 15 $content.find( '.mw-cite-backlink' ).each( function () { 16 var $links = $( this ).find( 'a' ), 17 label; 18 19 if ( $links.length > 1 ) { 20 // This citation is used multiple times. Let's only set the accessibility label on the first link, the 21 // following ones should then be self-explaining. This is needed to make sure this isn't getting 22 // too wordy. 23 label = accessibilityLabelMany; 24 } else { 25 label = accessibilityLabelOne; 26 } 27 28 // We can't use aria-label over here as that's not supported consistently across all screen reader / browser 29 // combinations. We have to use visually hidden spans for the accessibility labels instead. 30 $links.eq( 0 ).prepend( 31 $( '<span>' ) 32 .addClass( 'cite-accessibility-label' ) 33 // Also make sure we have at least one space between the accessibility label and the visual one 34 .text( label + ' ' ) 35 ); 36 } ); 37 } ); 38 } )( mediaWiki, jQuery );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |