r106186 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106185‎ | r106186 | r106187 >
Date:12:59, 14 December 2011
Author:amire80
Status:resolved
Tags:
Comment:
An initial fix for bug 33095. By default the right edge of the drop-down menu will now be aligned with the right edge of the "Select font" link (and vice-versa in an RTL environment). A better solution would be to align the left edges, but since the personal links are aligned to the right at the first place, it's a bit trickier - will fix it soon, too.
Modified paths:
  • /trunk/extensions/WebFonts/resources/ext.webfonts.js (modified) (history)

Diff [purge]

Index: trunk/extensions/WebFonts/resources/ext.webfonts.js
@@ -348,17 +348,34 @@
349349 .attr( 'title', mw.msg( 'webfonts-menu-tooltip' ) );
350350 // This is the fonts link
351351 var $li = $( '<li>' ).attr( 'id', 'pt-webfont' ).append( $link );
 352+ var positionFunction, menuSide;
 353+ if ( $( 'body' ).hasClass( 'rtl' ) ) {
 354+ positionFunction = 'append';
 355+ menuSide = 'left';
 356+ }
 357+ else {
 358+ positionFunction = 'prepend';
 359+ menuSide = 'right';
 360+ }
352361 // If RTL, add to the right of top personal links. Else, to the left
353 - var fn = $( 'body' ).hasClass( 'rtl' ) ? 'append' : 'prepend';
354 - $( '#p-personal ul:first' )[fn]( $li );
 362+ $( '#p-personal ul:first' )[positionFunction]( $li );
 363+
355364 $( 'body' ).prepend( $menu );
356365 $li.click( function( event ) {
357 - $menuItemsDiv.css( 'left', $li.offset().left );
358 - if( $menu.hasClass( 'open' ) ){
 366+ var menuOffset;
 367+ if ( $( 'body' ).hasClass( 'rtl' ) ) {
 368+ menuOffset = $li.offset().left;
 369+ }
 370+ else {
 371+ menuOffset = $(window).width() - ( $li.offset().left + $li.outerWidth() );
 372+ }
 373+ $menuItemsDiv.css( menuSide, menuOffset );
 374+
 375+ if( $menu.hasClass( 'open' ) ) {
359376 $menu.removeClass( 'open' );
360 - } else{
 377+ } else {
361378 $( 'div.open' ).removeClass( 'open' );
362 - $menu.addClass( 'open' );
 379+ $menu.addClass( 'open' );
363380 event.stopPropagation();
364381 }
365382 } );

Follow-up revisions

RevisionCommit summaryAuthorDate
r106197Better fix for bug 33095. Making the orientation of the drop-down menu condit...amire8014:08, 14 December 2011

Status & tagging log