From 81ffc4bf1a8106624ebf48ebaee11ccae36dfcaa Mon Sep 17 00:00:00 2001 From: "Eddie Monge Jr." Date: Thu, 8 Mar 2012 12:54:04 -0800 Subject: [PATCH 1/2] Icon class needs specific declaration because its possible to not set it. Save a character, ride a ternary. roundaboutly fixes ui-fullsize class never being applied --- js/jquery.mobile.buttonMarkup.js | 50 ++++++++++++-------------------- 1 file changed, 18 insertions(+), 32 deletions(-) diff --git a/js/jquery.mobile.buttonMarkup.js b/js/jquery.mobile.buttonMarkup.js index 74e9f302088..dd3f0f7b6b1 100644 --- a/js/jquery.mobile.buttonMarkup.js +++ b/js/jquery.mobile.buttonMarkup.js @@ -28,7 +28,8 @@ $.fn.buttonMarkup = function( options ) { // Classes Defined innerClass = "ui-btn-inner", textClass = "ui-btn-text", - buttonClass, iconClass, + iconClass = "", + buttonClass, // Button inner markup buttonInner, buttonText, @@ -63,15 +64,14 @@ $.fn.buttonMarkup = function( options ) { } buttonClass = "ui-btn ui-btn-up-" + o.theme; - - if ( o.inline ) { - buttonClass += " ui-btn-inline"; - } - - if ( o.mini ) { - buttonClass += " ui-mini"; - } else if ( o.mini && o.mini === false ) { - buttonClass += " ui-fullsize"; // Used to control styling in headers/footers, where buttons default to `mini` style. + buttonClass += o.inline ? " ui-btn-inline" : ""; + buttonClass += o.shadow ? " ui-shadow" : ""; + buttonClass += o.iconpos? " ui-btn-icon-" + o.iconpos : ""; + buttonClass += o.corners ? " ui-btn-corner-all" : ""; + + if ( o.mini !== undefined ) { + // Used to control styling in headers/footers, where buttons default to `mini` style. + buttonClass += o.mini ? " ui-mini" : " ui-fullsize"; } if ( o.icon ) { @@ -79,27 +79,13 @@ $.fn.buttonMarkup = function( options ) { o.iconpos = o.iconpos || "left"; iconClass = "ui-icon " + o.icon; - - if ( o.iconshadow ) { - iconClass += " ui-icon-shadow"; - } - } - - if ( o.iconpos ) { - buttonClass += " ui-btn-icon-" + o.iconpos; - - if ( o.iconpos == "notext" && !el.attr( "title" ) ) { - el.attr( "title", el.getEncodedText() ); - } - } - - if ( o.corners ) { - buttonClass += " ui-btn-corner-all"; - innerClass += " ui-btn-corner-all"; + iconClass += o.iconshadow ? " ui-icon-shadow" : ""; } + + innerClass += o.corners ? " ui-btn-corner-all" : ""; - if ( o.shadow ) { - buttonClass += " ui-shadow"; + if ( o.iconpos && o.iconpos === "notext" && !el.attr( "title" ) ) { + el.attr( "title", el.getEncodedText() ); } if (buttonElements) @@ -109,11 +95,11 @@ $.fn.buttonMarkup = function( options ) { buttonInner.className = innerClass; buttonText.className = textClass; - if (!buttonElements) + if ( !buttonElements ) buttonInner.appendChild( buttonText ); if ( buttonIcon ) { buttonIcon.className = iconClass; - if (!(buttonElements && buttonElements.icon)) + if ( !(buttonElements && buttonElements.icon) ) buttonInner.appendChild( buttonIcon ); } @@ -121,7 +107,7 @@ $.fn.buttonMarkup = function( options ) { buttonText.appendChild( e.firstChild ); } - if (!buttonElements) + if ( !buttonElements ) e.appendChild( buttonInner ); // Assign a structure containing the elements of this button to the elements of this button. This From 1ad15e829631b652e42897db3422fb7f5d2f8636 Mon Sep 17 00:00:00 2001 From: "Eddie Monge Jr." Date: Thu, 8 Mar 2012 12:59:34 -0800 Subject: [PATCH 2/2] iconClass didnt need to be set --- js/jquery.mobile.buttonMarkup.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/js/jquery.mobile.buttonMarkup.js b/js/jquery.mobile.buttonMarkup.js index dd3f0f7b6b1..c9f6ba1694b 100644 --- a/js/jquery.mobile.buttonMarkup.js +++ b/js/jquery.mobile.buttonMarkup.js @@ -28,8 +28,7 @@ $.fn.buttonMarkup = function( options ) { // Classes Defined innerClass = "ui-btn-inner", textClass = "ui-btn-text", - iconClass = "", - buttonClass, + buttonClass, iconClass, // Button inner markup buttonInner, buttonText, @@ -65,12 +64,12 @@ $.fn.buttonMarkup = function( options ) { buttonClass = "ui-btn ui-btn-up-" + o.theme; buttonClass += o.inline ? " ui-btn-inline" : ""; - buttonClass += o.shadow ? " ui-shadow" : ""; + buttonClass += o.shadow ? " ui-shadow" : ""; buttonClass += o.iconpos? " ui-btn-icon-" + o.iconpos : ""; buttonClass += o.corners ? " ui-btn-corner-all" : ""; if ( o.mini !== undefined ) { - // Used to control styling in headers/footers, where buttons default to `mini` style. + // Used to control styling in headers/footers, where buttons default to `mini` style. buttonClass += o.mini ? " ui-mini" : " ui-fullsize"; } @@ -88,27 +87,31 @@ $.fn.buttonMarkup = function( options ) { el.attr( "title", el.getEncodedText() ); } - if (buttonElements) - el.removeClass((buttonElements.bcls || "")); + if ( buttonElements ) { + el.removeClass( buttonElements.bcls || "" ); + } el.removeClass( "ui-link" ).addClass( buttonClass ); buttonInner.className = innerClass; buttonText.className = textClass; - if ( !buttonElements ) + if ( !buttonElements ) { buttonInner.appendChild( buttonText ); + } if ( buttonIcon ) { buttonIcon.className = iconClass; - if ( !(buttonElements && buttonElements.icon) ) + if ( !(buttonElements && buttonElements.icon) ) { buttonInner.appendChild( buttonIcon ); + } } while ( e.firstChild && !buttonElements) { buttonText.appendChild( e.firstChild ); } - if ( !buttonElements ) + if ( !buttonElements ) { e.appendChild( buttonInner ); + } // Assign a structure containing the elements of this button to the elements of this button. This // will allow us to recognize this as an already-enhanced button in future calls to buttonMarkup(). @@ -123,8 +126,9 @@ $.fn.buttonMarkup = function( options ) { $.data(e, 'buttonElements', buttonElements); $.data(buttonInner, 'buttonElements', buttonElements); $.data(buttonText, 'buttonElements', buttonElements); - if (buttonIcon) + if (buttonIcon) { $.data(buttonIcon, 'buttonElements', buttonElements); + } } return this;