Skip to content

Commit 15cb567

Browse files
dcneinerscottgonzalez
authored andcommitted
Button: Added rtl detection so corner classes would properly be applied to buttonsets. Fixed #6796. jQueryui - buttonset on rtl
(cherry picked from commit 50a4186)
1 parent c8326a4 commit 15cb567

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
@@ -351,6 +351,8 @@ $.widget( "ui.buttonset", {
351351
},
352352

353353
refresh: function() {
354+
var ltr = this.element.css( "direction" ) === "ltr";
355+
354356
this.buttons = this.element.find( this.options.items )
355357
.filter( ":ui-button" )
356358
.button( "refresh" )
@@ -363,10 +365,10 @@ $.widget( "ui.buttonset", {
363365
})
364366
.removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
365367
.filter( ":first" )
366-
.addClass( "ui-corner-left" )
368+
.addClass( ltr ? "ui-corner-left" : "ui-corner-right" )
367369
.end()
368370
.filter( ":last" )
369-
.addClass( "ui-corner-right" )
371+
.addClass( ltr ? "ui-corner-right" : "ui-corner-left" )
370372
.end()
371373
.end();
372374
},

0 commit comments

Comments
 (0)