aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.button.js
diff options
context:
space:
mode:
authorAlex Dovenmuehle <adovenmuehle@gmail.com>2011-02-10 22:11:59 -0500
committerScott González <scott.gonzalez@gmail.com>2011-02-10 22:12:56 -0500
commit9191ee3cd806c0e93a2cdf37125ff7b70e738e6b (patch)
tree941b0f51ddab28eac19a509a7805fa1589403d79 /ui/jquery.ui.button.js
parentd14366abcea59b4fb6d0fb1ce48a6ad196ddff3a (diff)
downloadjquery-ui-9191ee3cd806c0e93a2cdf37125ff7b70e738e6b.tar.gz
jquery-ui-9191ee3cd806c0e93a2cdf37125ff7b70e738e6b.zip
Button: Batched class changes to improve performance. Fixes #6934. Button: Batch class changes to improve performance.
(cherry picked from commit 5b104dbcefdfa708d80e8babea0539617167012d)
Diffstat (limited to 'ui/jquery.ui.button.js')
-rw-r--r--ui/jquery.ui.button.js19
1 files changed, 12 insertions, 7 deletions
diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js
index e767fe4e1..a32d3991e 100644
--- a/ui/jquery.ui.button.js
+++ b/ui/jquery.ui.button.js
@@ -290,27 +290,32 @@ $.widget( "ui.button", {
.appendTo( buttonElement.empty() )
.text(),
icons = this.options.icons,
- multipleIcons = icons.primary && icons.secondary;
+ multipleIcons = icons.primary && icons.secondary,
+ buttonClasses = [];
+
if ( icons.primary || icons.secondary ) {
- buttonElement.addClass( "ui-button-text-icon" +
- ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
+ buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
+
if ( icons.primary ) {
buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
}
+
if ( icons.secondary ) {
buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
}
+
if ( !this.options.text ) {
- buttonElement
- .addClass( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" )
- .removeClass( "ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary" );
+ buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
+ buttonElement.removeClass( "ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary" );
+
if ( !this.hasTitle ) {
buttonElement.attr( "title", buttonText );
}
}
} else {
- buttonElement.addClass( "ui-button-text-only" );
+ buttonClasses.push( "ui-button-text-only" );
}
+ buttonElement.addClass( buttonClasses.join( " " ) );
}
});