Skip to content

Checkboxradio: Use new ui-state-checked class in checkboxradio #1712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions tests/unit/checkboxradio/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function assertIcon( checkbox, icon, assert ) {
"ui-icon-background ui-icon-" + icon,
"Icon has proper classes" );
if ( icon === "blank" ) {
assert.lacksClasses( iconElement, "ui-icon-check ui-state-highlight" );
assert.lacksClasses( iconElement, "ui-icon-check ui-state-checked" );
}
}

Expand Down Expand Up @@ -100,7 +100,7 @@ QUnit.test( "icon - default checked", function( assert ) {
assert.expect( 2 );

checkbox.checkboxradio();
assertIcon( checkbox, "check ui-state-highlight", assert );
assertIcon( checkbox, "check ui-state-checked", assert );
} );

QUnit.test( "icon", function( assert ) {
Expand All @@ -111,13 +111,13 @@ QUnit.test( "icon", function( assert ) {
checkbox.prop( "checked", true );

checkbox.checkboxradio();
assertIcon( checkbox, "check ui-state-highlight", assert );
assertIcon( checkbox, "check ui-state-checked", assert );

checkbox.checkboxradio( "option", "icon", false );
assertNoIcon( assert, checkbox );

checkbox.checkboxradio( "option", "icon", true );
assertIcon( checkbox, "check ui-state-highlight", assert );
assertIcon( checkbox, "check ui-state-checked", assert );

checkbox.checkboxradio( "option", "icon", false );
assertNoIcon( assert, checkbox );
Expand Down
4 changes: 4 additions & 0 deletions themes/base/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ a.ui-button:active,
background: #fffa90/*{bgColorHighlight}*/ /*{bgImgUrlHighlight}*/ /*{bgHighlightXPos}*/ /*{bgHighlightYPos}*/ /*{bgHighlightRepeat}*/;
color: #777620/*{fcHighlight}*/;
}
.ui-state-checked {
border: 1px solid #dad55e/*{borderColorHighlight}*/;
background: #fffa90/*{bgColorHighlight}*/;
}
.ui-state-highlight a,
.ui-widget-content .ui-state-highlight a,
.ui-widget-header .ui-state-highlight a {
Expand Down
8 changes: 4 additions & 4 deletions ui/widgets/checkboxradio.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ $.widget( "ui.checkboxradio", [ $.ui.formResetMixin, {

if ( this.options.icon && this.type === "checkbox" ) {

// We add ui-state-highlight to change the icon color
this._toggleClass( this.icon, null, "ui-icon-check ui-state-highlight", checked )
// We add ui-state-checked to change the icon color based on ui-state-highlight colors
Copy link
Member

Choose a reason for hiding this comment

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

I'd drop the reference to ui-state-highlight since that's a ThemeRoller-specific thing.

this._toggleClass( this.icon, null, "ui-icon-check ui-state-checked", checked )
._toggleClass( this.icon, null, "ui-icon-blank", !checked );
}
if ( this.type === "radio" ) {
Expand Down Expand Up @@ -233,14 +233,14 @@ $.widget( "ui.checkboxradio", [ $.ui.formResetMixin, {
}

if ( this.type === "checkbox" ) {
toAdd += checked ? "ui-icon-check ui-state-highlight" : "ui-icon-blank";
toAdd += checked ? "ui-icon-check ui-state-checked" : "ui-icon-blank";
this._removeClass( this.icon, null, checked ? "ui-icon-blank" : "ui-icon-check" );
} else {
toAdd += "ui-icon-blank";
}
this._addClass( this.icon, "ui-checkboxradio-icon", toAdd );
if ( !checked ) {
this._removeClass( this.icon, null, "ui-icon-check ui-state-highlight" );
this._removeClass( this.icon, null, "ui-icon-check ui-state-checked" );
}
this.icon.prependTo( this.label ).after( this.iconSpace );
} else if ( this.icon !== undefined ) {
Expand Down