Permalink
Browse files

Button: Removed ui-button-text-icon class. Added ui-button-text-icon-…

…primary and ui-button-text-icon-secondary classes. Fixed #5382 - Button: specifying only a secondary icon for the button widget locates the icon on the left
  • Loading branch information...
1 parent e815e7c commit 202ddd0c58933e80b60373690412d2103b60388b @rdworth rdworth committed May 26, 2010
Showing with 67 additions and 39 deletions.
  1. +56 −25 tests/static/button/default.html
  2. +3 −3 tests/visual/button/button.html
  3. +5 −8 themes/base/jquery.ui.button.css
  4. +3 −3 ui/jquery.ui.button.js
@@ -23,24 +23,34 @@ <h2>Using button elements</h2>
</button>
<button class="ui-button ui-button-icon-only ui-widget ui-state-default ui-corner-all" title="Button">
- <span class="ui-button-icon-primary ui-icon ui-icon-locked"></span>
- <span class="ui-button-text">Button</span>
+ <span class="ui-button-icon-primary ui-icon ui-icon-gear"></span>
+ <span class="ui-button-text">Primary icon</span>
</button>
-
- <button class="ui-button ui-button-text-icon ui-widget ui-state-default ui-corner-all">
- <span class="ui-button-icon-primary ui-icon ui-icon-locked"></span>
- <span class="ui-button-text">Button</span>
+
+ <button class="ui-button ui-button-icon-only ui-widget ui-state-default ui-corner-all" title="Button">
+ <span class="ui-button-text">Secondary icon</span>
+ <span class="ui-button-icon-secondary ui-icon ui-icon-triangle-1-s"></span>
+ </button>
+
+ <button class="ui-button ui-button-text-icon-primary ui-widget ui-state-default ui-corner-all">
+ <span class="ui-button-icon-primary ui-icon ui-icon-gear"></span>
+ <span class="ui-button-text">Primary icon</span>
+ </button>
+
+ <button class="ui-button ui-button-text-icon-secondary ui-widget ui-state-default ui-corner-all">
+ <span class="ui-button-text">Secondary icon</span>
+ <span class="ui-button-icon-secondary ui-icon ui-icon-triangle-1-s"></span>
</button>
<button class="ui-button ui-button-text-icons ui-widget ui-state-default ui-corner-all">
<span class="ui-button-icon-primary ui-icon ui-icon-gear"></span>
- <span class="ui-button-text">Button</span>
+ <span class="ui-button-text">Both icons</span>
<span class="ui-button-icon-secondary ui-icon ui-icon-triangle-1-s"></span>
</button>
<button class="ui-button ui-button-icons-only ui-widget ui-state-default ui-corner-all">
<span class="ui-button-icon-primary ui-icon ui-icon-gear"></span>
- <span class="ui-button-text">Button</span>
+ <span class="ui-button-text">No text</span>
<span class="ui-button-icon-secondary ui-icon ui-icon-triangle-1-s"></span>
</button>
</div>
@@ -53,24 +63,34 @@ <h2>Using anchor elements</h2>
</a>
<a href="#" class="ui-button ui-button-icon-only ui-widget ui-state-default ui-corner-all" title="Button">
- <span class="ui-button-icon-primary ui-icon ui-icon-locked"></span>
- <span class="ui-button-text">Button</span>
+ <span class="ui-button-icon-primary ui-icon ui-icon-gear"></span>
+ <span class="ui-button-text">Primary icon</span>
</a>
- <a href="#" class="ui-button ui-button-text-icon ui-widget ui-state-default ui-corner-all">
- <span class="ui-button-icon-primary ui-icon ui-icon-locked"></span>
- <span class="ui-button-text">Button</span>
+ <a href="#" class="ui-button ui-button-icon-only ui-widget ui-state-default ui-corner-all" title="Button">
+ <span class="ui-button-text">Secondary icon</span>
+ <span class="ui-button-icon-secondary ui-icon ui-icon-triangle-1-s"></span>
+ </a>
+
+ <a href="#" class="ui-button ui-button-text-icon-primary ui-widget ui-state-default ui-corner-all">
+ <span class="ui-button-icon-primary ui-icon ui-icon-gear"></span>
+ <span class="ui-button-text">Primary icon</span>
+ </a>
+
+ <a href="#" class="ui-button ui-button-text-icon-secondary ui-widget ui-state-default ui-corner-all">
+ <span class="ui-button-text">Secondary icon</span>
+ <span class="ui-button-icon-secondary ui-icon ui-icon-triangle-1-s"></span>
</a>
<a href="#" class="ui-button ui-button-text-icons ui-widget ui-state-default ui-corner-all">
<span class="ui-button-icon-primary ui-icon ui-icon-gear"></span>
- <span class="ui-button-text">Button</span>
+ <span class="ui-button-text">Both icons</span>
<span class="ui-button-icon-secondary ui-icon ui-icon-triangle-1-s"></span>
</a>
<a href="#" class="ui-button ui-button-icons-only ui-widget ui-state-default ui-corner-all">
<span class="ui-button-icon-primary ui-icon ui-icon-gear"></span>
- <span class="ui-button-text">Button</span>
+ <span class="ui-button-text">No text</span>
<span class="ui-button-icon-secondary ui-icon ui-icon-triangle-1-s"></span>
</a>
</div>
@@ -85,24 +105,34 @@ <h2>Using label elements (used when proxying to radio or check inputs)</h2>
</label>
<label class="ui-button ui-button-icon-only ui-widget ui-state-default ui-corner-all" title="Button">
- <span class="ui-button-icon-primary ui-icon ui-icon-locked"></span>
- <span class="ui-button-text">Button</span>
+ <span class="ui-button-icon-primary ui-icon ui-icon-gear"></span>
+ <span class="ui-button-text">Primary icon</span>
</label>
- <label class="ui-button ui-button-text-icon ui-widget ui-state-default ui-corner-all">
- <span class="ui-button-icon-primary ui-icon ui-icon-locked"></span>
- <span class="ui-button-text">Button</span>
+ <label class="ui-button ui-button-icon-only ui-widget ui-state-default ui-corner-all" title="Button">
+ <span class="ui-button-text">Secondary icon</span>
+ <span class="ui-button-icon-secondary ui-icon ui-icon-triangle-1-s"></span>
+ </label>
+
+ <label class="ui-button ui-button-text-icon-primary ui-widget ui-state-default ui-corner-all">
+ <span class="ui-button-icon-primary ui-icon ui-icon-gear"></span>
+ <span class="ui-button-text">Primary icon</span>
+ </label>
+
+ <label class="ui-button ui-button-text-icon-secondary ui-widget ui-state-default ui-corner-all">
+ <span class="ui-button-text">Secondary icon</span>
+ <span class="ui-button-icon-secondary ui-icon ui-icon-triangle-1-s"></span>
</label>
<label class="ui-button ui-button-text-icons ui-widget ui-state-default ui-corner-all">
<span class="ui-button-icon-primary ui-icon ui-icon-gear"></span>
- <span class="ui-button-text">Button</span>
+ <span class="ui-button-text">Both icons</span>
<span class="ui-button-icon-secondary ui-icon ui-icon-triangle-1-s"></span>
</label>
<label class="ui-button ui-button-icons-only ui-widget ui-state-default ui-corner-all">
<span class="ui-button-icon-primary ui-icon ui-icon-gear"></span>
- <span class="ui-button-text">Button</span>
+ <span class="ui-button-text">No text</span>
<span class="ui-button-icon-secondary ui-icon ui-icon-triangle-1-s"></span>
</label>
</div>
@@ -111,9 +141,10 @@ <h2>Using label elements (used when proxying to radio or check inputs)</h2>
<h2>Button Sets</h2>
<div class="ui-buttonset">
- <button class="ui-button ui-button-text-only ui-widget ui-state-default ui-corner-left"><span class="ui-button-text">Simple button</span></button>
- <button class="ui-button ui-button-text-only ui-widget ui-state-default"><span class="ui-button-text">Simple button</span></button>
- <button class="ui-button ui-button-text-only ui-widget ui-state-default ui-corner-right"><span class="ui-button-text">Simple button</span></button>
+ <button class="ui-button ui-button-text-only ui-widget ui-state-default ui-corner-left"><span class="ui-button-text">First</span></button>
+ <button class="ui-button ui-button-text-only ui-widget ui-state-default"><span class="ui-button-text">Middle</span></button>
+ <button class="ui-button ui-button-text-only ui-widget ui-state-default"><span class="ui-button-text">Middle</span></button>
+ <button class="ui-button ui-button-text-only ui-widget ui-state-default ui-corner-right"><span class="ui-button-text">Last</span></button>
</div>
@@ -58,9 +58,9 @@
<div>
With icon
<button class="{button:{icons:{primary:'ui-icon-locked'},text:false}}">Button with icon only</button>
- <button class="{button:{icons:{primary:'ui-icon-locked'}}}">Button with icon on the left</button>
- <button class="{button:{icons:{primary:'ui-icon-gear',secondary:'ui-icon-triangle-1-s'}}}">Button with two icons</button>
- <button class="{button:{icons:{secondary:'ui-icon-triangle-1-s'}}}">Button with text and secondary icon</button>
+ <button class="{button:{icons:{primary:'ui-icon-locked'}}}">Primary icon</button>
+ <button class="{button:{icons:{secondary:'ui-icon-triangle-1-s'}}}">Secondary icon</button>
+ <button class="{button:{icons:{primary:'ui-icon-gear',secondary:'ui-icon-triangle-1-s'}}}">Both icons</button>
<button class="{button:{icons:{primary:'ui-icon-gear',secondary:'ui-icon-triangle-1-s'},text:false}}">Button with two icons and no text</button>
</div>
</div>
@@ -11,15 +11,17 @@ button.ui-button-icons-only { width: 3.7em; }
.ui-button .ui-button-text { display: block; line-height: 1.4; }
.ui-button-text-only .ui-button-text { padding: .4em 1em; }
.ui-button-icon-only .ui-button-text, .ui-button-icons-only .ui-button-text { padding: .4em; text-indent: -9999999px; }
-.ui-button-text-icon .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 1em .4em 2.1em; }
+.ui-button-text-icon-primary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 1em .4em 2.1em; }
+.ui-button-text-icon-secondary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 2.1em .4em 1em; }
.ui-button-text-icons .ui-button-text { padding-left: 2.1em; padding-right: 2.1em; }
/* no icon support for input elements, provide padding by default */
input.ui-button { padding: .4em 1em; }
/*button icon element(s) */
-.ui-button-icon-only .ui-icon, .ui-button-text-icon .ui-icon, .ui-button-text-icons .ui-icon, .ui-button-icons-only .ui-icon { position: absolute; top: 50%; margin-top: -8px; }
+.ui-button-icon-only .ui-icon, .ui-button-text-icon-primary .ui-icon, .ui-button-text-icon-secondary .ui-icon, .ui-button-text-icons .ui-icon, .ui-button-icons-only .ui-icon { position: absolute; top: 50%; margin-top: -8px; }
.ui-button-icon-only .ui-icon { left: 50%; margin-left: -8px; }
-.ui-button-text-icon .ui-button-icon-primary, .ui-button-text-icons .ui-button-icon-primary, .ui-button-icons-only .ui-button-icon-primary { left: .5em; }
+.ui-button-text-icon-primary .ui-button-icon-primary, .ui-button-text-icons .ui-button-icon-primary, .ui-button-icons-only .ui-button-icon-primary { left: .5em; }
+.ui-button-text-icon-secondary .ui-button-icon-secondary, .ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; }
.ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; }
/*button sets*/
@@ -28,8 +30,3 @@ input.ui-button { padding: .4em 1em; }
/* workarounds */
button.ui-button::-moz-focus-inner { border: 0; padding: 0; } /* reset extra padding in Firefox */
-
-
-
-
-
View
@@ -16,7 +16,7 @@
var lastActive,
baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
stateClasses = "ui-state-hover ui-state-active ",
- typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon ui-button-text-only",
+ typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",
formResetHandler = function( event ) {
$( ":ui-button", event.target.form ).each(function() {
var inst = $( this ).data( "button" );
@@ -288,7 +288,7 @@ $.widget( "ui.button", {
multipleIcons = icons.primary && icons.secondary;
if ( icons.primary || icons.secondary ) {
buttonElement.addClass( "ui-button-text-icon" +
- ( multipleIcons ? "s" : "" ) );
+ ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
if ( icons.primary ) {
buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
}
@@ -298,7 +298,7 @@ $.widget( "ui.button", {
if ( !this.options.text ) {
buttonElement
.addClass( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" )
- .removeClass( "ui-button-text-icons ui-button-text-icon" );
+ .removeClass( "ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary" );
if ( !this.hasTitle ) {
buttonElement.attr( "title", buttonText );
}

1 comment on commit 202ddd0

Please sign in to comment.