Skip to content

Commit

Permalink
Button: Added rtl detection so corner classes would properly be appli…
Browse files Browse the repository at this point in the history
…ed to buttonsets. Fixed #6796. jQueryui - buttonset on rtl

(cherry picked from commit 50a4186)
  • Loading branch information
dcneiner authored and scottgonzalez committed May 13, 2011
1 parent c8326a4 commit 15cb567
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
14 changes: 14 additions & 0 deletions tests/unit/button/button_core.js
Expand Up @@ -67,4 +67,18 @@ test("buttonset", function() {
ok( set.children("label:eq(2)").is(".ui-button.ui-corner-right:not(.ui-corner-all)") ); 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); })(jQuery);
6 changes: 4 additions & 2 deletions ui/jquery.ui.button.js
Expand Up @@ -351,6 +351,8 @@ $.widget( "ui.buttonset", {
}, },


refresh: function() { refresh: function() {
var ltr = this.element.css( "direction" ) === "ltr";

this.buttons = this.element.find( this.options.items ) this.buttons = this.element.find( this.options.items )
.filter( ":ui-button" ) .filter( ":ui-button" )
.button( "refresh" ) .button( "refresh" )
Expand All @@ -363,10 +365,10 @@ $.widget( "ui.buttonset", {
}) })
.removeClass( "ui-corner-all ui-corner-left ui-corner-right" ) .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
.filter( ":first" ) .filter( ":first" )
.addClass( "ui-corner-left" ) .addClass( ltr ? "ui-corner-left" : "ui-corner-right" )
.end() .end()
.filter( ":last" ) .filter( ":last" )
.addClass( "ui-corner-right" ) .addClass( ltr ? "ui-corner-right" : "ui-corner-left" )
.end() .end()
.end(); .end();
}, },
Expand Down

0 comments on commit 15cb567

Please sign in to comment.