MediaWiki:Common.js: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 26:
 
/**
* @source [www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL](https://www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL)
* @rev 6
*/
Line 354:
});
 
/* Collapsible inline footnotes ({{footnote}}) — click-triggered POPOVERcard.
Clicking the "note" chip openstoggles the.ed-fn-open; noteALL as a card that floats above thepositioning/visibility
textis in Common.css (CSSa doesfixed thebottom-centre positioningcard);, so the noteJS textjust stays inflips the DOM at all
class — there is nothing to mis-place, so the card can never open to
times, so the bot reads it from the parsed HTML regardless. Behaviour:
one"nothing". One card open at a time; .edoutside-fn-flipclick opensand theEscape card leftward when thedismiss;
dismiss; Enter/Space + aria-expanded for keyboard and screen readers. */The note text
chip sits in the right part of the viewport; outside-click and Escape
stays in the DOM at all times, so the bot reads it from the parsed HTML regardless. Behaviour:*/
dismiss; Enter/Space + aria-expanded for keyboard and screen readers. */
$( function () {
$( '.ed-fn-chip' ).attr( { role: 'button', tabindex: 0, 'aria-expanded': 'false' } );
Line 367:
$( '.ed-fn.ed-fn-open' ).each( function () {
if ( this !== except ) {
$( this ).removeClass( 'ed-fn-open ed-fn-flip' )
.children( '.ed-fn-chip' ).attr( 'aria-expanded', 'false' );
}
Line 382:
closeAll( $fn[ 0 ] );
$fn.toggleClass( 'ed-fn-open', willOpen );
if ( willOpen ) {
// open the card leftward when the chip is in the right 40% of the viewport
var rect = this.getBoundingClientRect();
$fn.toggleClass( 'ed-fn-flip', rect.left > window.innerWidth * 0.6 );
} else {
$fn.removeClass( 'ed-fn-flip' );
}
$( this ).attr( 'aria-expanded', willOpen ? 'true' : 'false' );
} );
 
// click anywhere outside anany .ed-fn, or press Escape, to dismiss
$( document ).on( 'click', function ( e ) {
if ( !$( e.target ).closest( '.ed-fn' ).length ) {