Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Button: Added check to adjust icon position in browsers that do not f…

…ollow the standard box model when displaying buttons (i.e. Firefox). Fixed #5603 - Button with icon not displayed correctly in Firefox when button has css height.
  • Loading branch information...
commit 7c07a565803bc3f7f466b34a5cc2fd8823c3eb93 1 parent 237bbc5
@kborchers authored
Showing with 8 additions and 0 deletions.
  1. +8 −0 ui/jquery.ui.button.js
View
8 ui/jquery.ui.button.js
@@ -336,6 +336,14 @@ $.widget( "ui.button", {
if ( icons.secondary ) {
buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
}
+
+ //Firefox does not follow the standard box model when displaying buttons
+ //so the icon position must be recalculated (see ticket #5603)
+ buttonElement.find( ".ui-icon" ).each( function() {
+ if( buttonElement.height() / parseInt( buttonElement.css( "line-height" ) ) > 2 ) {
+ $( this ).css( "margin-top", ( 0 - ( parseInt( buttonElement.css("line-height") ) * ( ( buttonElement.height() / parseInt( buttonElement.css("line-height") ) / 2 ) ) ) + 8 ) + "px" );
+ }
+ });
if ( !this.options.text ) {
buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
Please sign in to comment.
Something went wrong with that request. Please try again.