Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 23 additions & 33 deletions js/jquery.mobile.buttonMarkup.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,66 +63,55 @@ $.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 ) {
o.icon = "ui-icon-" + o.icon;
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() );
}
iconClass += o.iconshadow ? " ui-icon-shadow" : "";
}

innerClass += o.corners ? " ui-btn-corner-all" : "";

if ( o.corners ) {
buttonClass += " ui-btn-corner-all";
innerClass += " ui-btn-corner-all";
if ( o.iconpos && o.iconpos === "notext" && !el.attr( "title" ) ) {
el.attr( "title", el.getEncodedText() );
}

if ( o.shadow ) {
buttonClass += " ui-shadow";
if ( buttonElements ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move that if down to line 98 and have:

if ( buttonElements ) {
    el.removeClass( buttonElements.bcls || "" );
} else {
    buttonInner.appendChild( buttonText );
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i didnt know what was in buttonElements.bcls so i was hesitant to move it in case it has ui-link in it

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().
Expand All @@ -137,8 +126,9 @@ $.fn.buttonMarkup = function( options ) {
$.data(e, 'buttonElements', buttonElements);
$.data(buttonInner, 'buttonElements', buttonElements);
$.data(buttonText, 'buttonElements', buttonElements);
if (buttonIcon)
if (buttonIcon) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

$.data(buttonIcon, 'buttonElements', buttonElements);
}
}

return this;
Expand Down