(bug 24692) Make the padding support RTL languages
authorAmir E. Aharoni <amir.aharoni@mail.huji.ac.il>
Fri, 21 Dec 2012 22:41:15 +0000 (00:41 +0200)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 25 Dec 2012 10:26:07 +0000 (10:26 +0000)
Change-Id: I5be38f001dcc13a57e213fdbb505f05623070af3

resources/jquery/jquery.arrowSteps.js

index 488d106..a1fd679 100644 (file)
  */
 ( function ( $ ) {
        $.fn.arrowSteps = function () {
-               var $steps, width, arrowWidth;
+               var $steps, width, arrowWidth,
+                       paddingSide = $( 'body' ).hasClass( 'rtl' ) ? 'padding-left' : 'padding-right';
+
                this.addClass( 'arrowSteps' );
                $steps = this.find( 'li' );
 
                width = parseInt( 100 / $steps.length, 10 );
                $steps.css( 'width', width + '%' );
 
-               // every step except the last one has an arrow at the right hand side. Also add in the padding
-               // for the calculated arrow width.
+               // Every step except the last one has an arrow pointing forward:
+               // at the right hand side in LTR languages, and at the left hand side in RTL.
+               // Also add in the padding for the calculated arrow width.
                arrowWidth = parseInt( this.outerHeight(), 10 );
                $steps.filter( ':not(:last-child)' ).addClass( 'arrow' )
-                     .find( 'div' ).css( 'padding-right', arrowWidth.toString() + 'px' );
+                     .find( 'div' ).css( paddingSide, arrowWidth.toString() + 'px' );
 
                this.data( 'arrowSteps', $steps );
                return this;