Permalink
Browse files

[buttonMarkup] Accept more than just true/false for corners: tl, tr, …

…bl, br, top, left, right, bottom as well
  • Loading branch information...
gabrielschulhof committed Jun 14, 2012
1 parent f1e4913 commit be1e8721fe1605b980db52e231968b719d3992eb
Showing with 18 additions and 3 deletions.
  1. +18 −3 js/jquery.mobile.buttonMarkup.js
@@ -9,6 +9,19 @@ define( [ "jquery", "./jquery.mobile.core", "./jquery.mobile.vmouse" ], function
//>>excludeEnd("jqmBuildExclude");
(function( $, undefined ) {
+var cornerClasses = {
+ "tl": " ui-btn-corner-tl",
+ "tr": " ui-btn-corner-tr",
+ "bl": " ui-btn-corner-bl",
+ "br": " ui-btn-corner-br",
+ "top": " ui-btn-corner-top",
+ "bottom": " ui-btn-corner-bottom",
+ "left": " ui-btn-corner-left",
+ "right": " ui-btn-corner-right"
+};
+cornerClasses[true] = " ui-btn-corner-all";
+cornerClasses[false] = "";
+
$.fn.buttonMarkup = function( options ) {
var $workingSet = this,
mapToDataAttr = function( key, value ) {
@@ -35,7 +48,7 @@ $.fn.buttonMarkup = function( options ) {
// Classes Defined
innerClass = "ui-btn-inner",
textClass = "ui-btn-text",
- buttonClass, iconClass,
+ buttonClass, iconClass, cornerClass,
hover = false,
state = "up",
// Button inner markup
@@ -80,11 +93,13 @@ $.fn.buttonMarkup = function( options ) {
o.theme = $.mobile.getInheritedTheme( el, "c" );
}
+ cornerClass = ( cornerClasses[ o.corners ] ? cornerClasses[ o.corners ] : "" );
+
buttonClass = "ui-btn ";
buttonClass += ( hover ? "ui-btn-hover-" + o.theme : "" );
buttonClass += ( state ? " ui-btn-" + state + "-" + o.theme : "" );
buttonClass += o.shadow ? " ui-shadow" : "";
- buttonClass += o.corners ? " ui-btn-corner-all" : "";
+ buttonClass += cornerClass;
if ( o.mini !== undefined ) {
// Used to control styling in headers/footers, where buttons default to `mini` style.
@@ -115,7 +130,7 @@ $.fn.buttonMarkup = function( options ) {
}
}
- innerClass += o.corners ? " ui-btn-corner-all" : "";
+ innerClass += cornerClass;
if ( o.iconpos && o.iconpos === "notext" && !el.attr( "title" ) ) {
el.attr( "title", el.getEncodedText() );

0 comments on commit be1e872

Please sign in to comment.