Index: trunk/extensions/WebFonts/resources/ext.webfonts.js |
— | — | @@ -349,38 +349,32 @@ |
350 | 350 | |
351 | 351 | // This is the fonts link |
352 | 352 | var $li = $( '<li>' ).attr( 'id', 'pt-webfont' ).append( $link ); |
353 | | - var positionFunction; |
354 | | - if ( $( 'body' ).hasClass( 'rtl' ) ) { |
355 | | - positionFunction = 'append'; |
356 | | - } |
357 | | - else { |
358 | | - positionFunction = 'prepend'; |
359 | | - } |
| 353 | + |
| 354 | + var rtlEnv = $( 'body' ).hasClass( 'rtl' ); |
| 355 | + |
360 | 356 | // If RTL, add to the right of top personal links. Else, to the left |
| 357 | + var positionFunction = rtlEnv ? 'append' : 'prepend'; |
361 | 358 | $( '#p-personal ul:first' )[positionFunction]( $li ); |
362 | 359 | |
363 | 360 | $( 'body' ).prepend( $menu ); |
364 | 361 | $li.click( function( event ) { |
365 | 362 | var menuSide, menuOffset, distanceToEdge; |
366 | 363 | |
367 | | - if ( $( 'body' ).hasClass( 'rtl' ) ) { |
| 364 | + if ( rtlEnv ) { |
368 | 365 | distanceToEdge = $li.outerWidth() + $li.offset().left; |
369 | 366 | if ( $menuItemsDiv.outerWidth() > distanceToEdge ) { |
370 | 367 | menuSide = 'left'; |
371 | 368 | menuOffset = $li.offset().left; |
372 | | - } |
373 | | - else { |
| 369 | + } else { |
374 | 370 | menuSide = 'right'; |
375 | 371 | menuOffset = $(window).width() - distanceToEdge; |
376 | 372 | } |
377 | | - } |
378 | | - else { |
| 373 | + } else { |
379 | 374 | distanceToEdge = $(window).width() - $li.offset().left; |
380 | 375 | if ( $menuItemsDiv.outerWidth() > distanceToEdge ) { |
381 | 376 | menuSide = 'right'; |
382 | 377 | menuOffset = distanceToEdge - $li.outerWidth(); |
383 | | - } |
384 | | - else { |
| 378 | + } else { |
385 | 379 | menuSide = 'left'; |
386 | 380 | menuOffset = $li.offset().left; |
387 | 381 | } |
— | — | @@ -390,8 +384,7 @@ |
391 | 385 | |
392 | 386 | if ( $menu.hasClass( 'open' ) ) { |
393 | 387 | $menu.removeClass( 'open' ); |
394 | | - } |
395 | | - else { |
| 388 | + } else { |
396 | 389 | $( 'div.open' ).removeClass( 'open' ); |
397 | 390 | $menu.addClass( 'open' ); |
398 | 391 | event.stopPropagation(); |