]> source.dussan.org Git - jquery-ui.git/commitdiff
Button: Added rtl detection so corner classes would properly be applied to buttonsets...
authorDoug Neiner <doug@pixelgraphics.us>
Thu, 12 May 2011 05:51:05 +0000 (01:51 -0400)
committerScott González <scott.gonzalez@gmail.com>
Fri, 13 May 2011 00:44:42 +0000 (20:44 -0400)
(cherry picked from commit 50a4186ef949ecaf7ab4977048160820587218d2)

tests/unit/button/button_core.js
ui/jquery.ui.button.js

index 5b30aa860d1dfb1b8847de995480e3a9fced6a72..692c40320d86db9f63e58cd652edfa06e0b548c4 100644 (file)
@@ -67,4 +67,18 @@ test("buttonset", function() {
        ok( set.children("label:eq(2)").is(".ui-button.ui-corner-right:not(.ui-corner-all)") );
 });
 
+test("buttonset (rtl)", function() {
+       var parent = $("#radio1").parent();
+       // Set to rtl
+       parent.attr("dir", "rtl");
+       
+       var set = $("#radio1").buttonset();
+       ok( set.is(".ui-buttonset") );
+       same( set.children(".ui-button").length, 3 );
+       same( set.children("input:radio.ui-helper-hidden-accessible").length, 3 );
+       ok( set.children("label:eq(0)").is(".ui-button.ui-corner-right:not(.ui-corner-all)") );
+       ok( set.children("label:eq(1)").is(".ui-button:not(.ui-corner-all)") );
+       ok( set.children("label:eq(2)").is(".ui-button.ui-corner-left:not(.ui-corner-all)") );
+});
+
 })(jQuery);
index bc8357c089d348d1dc5ec77767bb3a86e3d3ac25..19b1b416945461504d156750e3c87af5858598f6 100644 (file)
@@ -351,6 +351,8 @@ $.widget( "ui.buttonset", {
        },
        
        refresh: function() {
+               var ltr = this.element.css( "direction" ) === "ltr";
+               
                this.buttons = this.element.find( this.options.items )
                        .filter( ":ui-button" )
                                .button( "refresh" )
@@ -363,10 +365,10 @@ $.widget( "ui.buttonset", {
                        })
                                .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
                                .filter( ":first" )
-                                       .addClass( "ui-corner-left" )
+                                       .addClass( ltr ? "ui-corner-left" : "ui-corner-right" )
                                .end()
                                .filter( ":last" )
-                                       .addClass( "ui-corner-right" )
+                                       .addClass( ltr ? "ui-corner-right" : "ui-corner-left" )
                                .end()
                        .end();
        },