Skip to content

Commit 523790b

Browse files
committed
Merge pull request jquery#257 from dcneiner/buttonset-rtl
Fixed #6796
2 parents 7e2a704 + 50a4186 commit 523790b

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

tests/unit/button/button_core.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,18 @@ test("buttonset", function() {
6767
ok( set.children("label:eq(2)").is(".ui-button.ui-corner-right:not(.ui-corner-all)") );
6868
});
6969

70+
test("buttonset (rtl)", function() {
71+
var parent = $("#radio1").parent();
72+
// Set to rtl
73+
parent.attr("dir", "rtl");
74+
75+
var set = $("#radio1").buttonset();
76+
ok( set.is(".ui-buttonset") );
77+
same( set.children(".ui-button").length, 3 );
78+
same( set.children("input:radio.ui-helper-hidden-accessible").length, 3 );
79+
ok( set.children("label:eq(0)").is(".ui-button.ui-corner-right:not(.ui-corner-all)") );
80+
ok( set.children("label:eq(1)").is(".ui-button:not(.ui-corner-all)") );
81+
ok( set.children("label:eq(2)").is(".ui-button.ui-corner-left:not(.ui-corner-all)") );
82+
});
83+
7084
})(jQuery);

ui/jquery.ui.button.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,8 @@ $.widget( "ui.buttonset", {
352352
},
353353

354354
refresh: function() {
355+
var ltr = this.element.css( "direction" ) === "ltr";
356+
355357
this.buttons = this.element.find( this.options.items )
356358
.filter( ":ui-button" )
357359
.button( "refresh" )
@@ -364,10 +366,10 @@ $.widget( "ui.buttonset", {
364366
})
365367
.removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
366368
.filter( ":first" )
367-
.addClass( "ui-corner-left" )
369+
.addClass( ltr ? "ui-corner-left" : "ui-corner-right" )
368370
.end()
369371
.filter( ":last" )
370-
.addClass( "ui-corner-right" )
372+
.addClass( ltr ? "ui-corner-right" : "ui-corner-left" )
371373
.end()
372374
.end();
373375
},

0 commit comments

Comments
 (0)