diff options
author | Richard D. Worth <rdworth@gmail.com> | 2010-05-26 15:08:37 -0400 |
---|---|---|
committer | Richard D. Worth <rdworth@gmail.com> | 2010-05-26 15:08:37 -0400 |
commit | 202ddd0c58933e80b60373690412d2103b60388b (patch) | |
tree | e22001e7001c0f9ca65de46801cc0eb2fbcf80f8 | |
parent | e815e7c1e49632651052e80e2360fde1a43b0f80 (diff) | |
download | jquery-ui-202ddd0c58933e80b60373690412d2103b60388b.tar.gz jquery-ui-202ddd0c58933e80b60373690412d2103b60388b.zip |
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
-rw-r--r-- | tests/static/button/default.html | 81 | ||||
-rw-r--r-- | tests/visual/button/button.html | 6 | ||||
-rw-r--r-- | themes/base/jquery.ui.button.css | 13 | ||||
-rw-r--r-- | ui/jquery.ui.button.js | 6 |
4 files changed, 67 insertions, 39 deletions
diff --git a/tests/static/button/default.html b/tests/static/button/default.html index a2c35a4ad..e0e005090 100644 --- a/tests/static/button/default.html +++ b/tests/static/button/default.html @@ -23,24 +23,34 @@ </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 @@ </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 @@ </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>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> diff --git a/tests/visual/button/button.html b/tests/visual/button/button.html index 7575eadf1..de0bb3ab9 100644 --- a/tests/visual/button/button.html +++ b/tests/visual/button/button.html @@ -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> diff --git a/themes/base/jquery.ui.button.css b/themes/base/jquery.ui.button.css index 47777a428..efe1ec03e 100644 --- a/themes/base/jquery.ui.button.css +++ b/themes/base/jquery.ui.button.css @@ -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 */ - - - - - diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js index 83f14f4c9..8176c3321 100644 --- a/ui/jquery.ui.button.js +++ b/ui/jquery.ui.button.js @@ -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 ); } |