Checkboxradio: Style updates

This commit is contained in:
Alexander Schmitz 2015-09-11 10:48:20 -04:00
parent 6169099229
commit 641c5ed17a
5 changed files with 44 additions and 44 deletions

View File

@ -17,6 +17,6 @@ common.testWidget( "checkboxradio", {
// Callbacks // Callbacks
create: null create: null
} }
}); } );
} ); } );

View File

@ -6,13 +6,13 @@ define( [
module( "Checkboxradio: core" ); module( "Checkboxradio: core" );
test( "Checkbox - Initial class structure", function( assert ) { test( "Checkbox - Initial class structure", function( assert ) {
expect( 2 ); expect( 2 );
var input = $("#check"), var input = $( "#check" ),
label = $("label[for=check]"); label = $( "label[for=check]" );
input.checkboxradio(); input.checkboxradio();
assert.hasClasses( input, "ui-helper-hidden-accessible ui-checkboxradio" ); assert.hasClasses( input, "ui-helper-hidden-accessible ui-checkboxradio" );
assert.hasClasses( label, "ui-button ui-widget ui-checkboxradio-label ui-corner-all" ); assert.hasClasses( label, "ui-button ui-widget ui-checkboxradio-label ui-corner-all" );
}); } );
test( "Radios - Initial class structure", function( assert ) { test( "Radios - Initial class structure", function( assert ) {
expect( 6 ); expect( 6 );
@ -22,11 +22,11 @@ test( "Radios - Initial class structure", function( assert ) {
inputs.checkboxradio(); inputs.checkboxradio();
inputs.each( function() { inputs.each( function() {
assert.hasClasses( this, "ui-helper-hidden-accessible" ); assert.hasClasses( this, "ui-helper-hidden-accessible" );
}); } );
labels.each( function() { labels.each( function() {
assert.hasClasses( this, "ui-button" ); assert.hasClasses( this, "ui-button" );
}); } );
}); } );
asyncTest( "Ensure checked after single click on checkbox label button", function( assert ) { asyncTest( "Ensure checked after single click on checkbox label button", function( assert ) {
expect( 2 ); expect( 2 );
@ -36,17 +36,17 @@ asyncTest( "Ensure checked after single click on checkbox label button", functio
ok( this.checked, "checked ok" ); ok( this.checked, "checked ok" );
assert.hasClasses( label, "ui-state-active" ); assert.hasClasses( label, "ui-state-active" );
}); } );
// Support: Opera // Support: Opera
// Opera doesn't trigger a change event when this is done synchronously. // Opera doesn't trigger a change event when this is done synchronously.
// This seems to be a side effect of another test, but until that can be // This seems to be a side effect of another test, but until that can be
// tracked down, this delay will have to do. // tracked down, this delay will have to do.
setTimeout(function() { setTimeout( function() {
$( "#check2" ).checkboxradio( "widget" ).simulate( "click" ); $( "#check2" ).checkboxradio( "widget" ).simulate( "click" );
start(); start();
}); } );
}); } );
test( "Checkbox creation requires a label, and finds it in all cases", function( assert ) { test( "Checkbox creation requires a label, and finds it in all cases", function( assert ) {
expect( 7 ); expect( 7 );
@ -66,7 +66,7 @@ test( "Checkbox creation requires a label, and finds it in all cases", function(
group.find( "input[type=checkbox]" ).checkboxradio(); group.find( "input[type=checkbox]" ).checkboxradio();
assert.hasClasses( group.find( "label" ), "ui-button" ); assert.hasClasses( group.find( "label" ), "ui-button" );
} ); } );
}); } );
test( "Calling checkboxradio on an unsupported element throws an error", function( assert ) { test( "Calling checkboxradio on an unsupported element throws an error", function( assert ) {
expect( 2 ); expect( 2 );
@ -86,7 +86,7 @@ test( "Calling checkboxradio on an unsupported element throws an error", functio
error, error,
"Proper error thrown" "Proper error thrown"
); );
}); } );
test( "Calling checkboxradio on an input with no label throws an error", function( assert ) { test( "Calling checkboxradio on an input with no label throws an error", function( assert ) {
expect( 1 ); expect( 1 );
var error = new Error( "No label found for checkboxradio widget" ); var error = new Error( "No label found for checkboxradio widget" );
@ -97,6 +97,6 @@ test( "Calling checkboxradio on an input with no label throws an error", functio
error, error,
"Proper error thrown" "Proper error thrown"
); );
}); } );
} ); } );

View File

@ -20,7 +20,7 @@ asyncTest(
form.get( 0 ).reset(); form.get( 0 ).reset();
setTimeout(function() { setTimeout( function() {
assert.hasClasses( widget, "ui-state-active" ); assert.hasClasses( widget, "ui-state-active" );
start(); start();
}, 1 ); }, 1 );
@ -33,7 +33,7 @@ asyncTest( "Checkbox shows focus when using keyboard navigation", function( asse
label = $( "label[for='check']" ); label = $( "label[for='check']" );
assert.lacksClasses( label, "ui-state-focus" ); assert.lacksClasses( label, "ui-state-focus" );
check.focus(); check.focus();
setTimeout(function() { setTimeout( function() {
assert.hasClasses( label, "ui-state-focus" ); assert.hasClasses( label, "ui-state-focus" );
start(); start();
} ); } );

View File

@ -46,14 +46,14 @@ $.each( [ "checkbox", "radio" ], function( index, value ) {
assert.lacksClasses( icon, "ui-icon-check" ); assert.lacksClasses( icon, "ui-icon-check" );
} }
assert.lacksClasses( widget, "ui-checkboxradio-checked" ); assert.lacksClasses( widget, "ui-checkboxradio-checked" );
}); } );
test( value + ": destroy", function( assert ){ test( value + ": destroy", function( assert ) {
expect( 1 ); expect( 1 );
assert.domEqual( "#" + value + "-method-destroy", function() { assert.domEqual( "#" + value + "-method-destroy", function() {
$( "#" + value + "-method-destroy" ).checkboxradio().checkboxradio( "destroy" ); $( "#" + value + "-method-destroy" ).checkboxradio().checkboxradio( "destroy" );
}); } );
}); } );
test( value + ": disable / enable", function( assert ) { test( value + ": disable / enable", function( assert ) {
expect( 4 ); expect( 4 );
@ -69,9 +69,9 @@ $.each( [ "checkbox", "radio" ], function( index, value ) {
assert.lacksClasses( widget, "ui-state-disabled" ); assert.lacksClasses( widget, "ui-state-disabled" );
strictEqual( input.is( ":disabled" ), false, strictEqual( input.is( ":disabled" ), false,
value + " has disabled prop removed when enable is called" ); value + " has disabled prop removed when enable is called" );
}); } );
test( value + ": widget returns the label", function(){ test( value + ": widget returns the label", function() {
var input = $( "#" + value + "-method-refresh" ), var input = $( "#" + value + "-method-refresh" ),
label = $( "#" + value + "-method-refresh-label" ); label = $( "#" + value + "-method-refresh-label" );
@ -80,7 +80,7 @@ $.each( [ "checkbox", "radio" ], function( index, value ) {
input.checkboxradio(); input.checkboxradio();
strictEqual( input.checkboxradio( "widget" )[ 0 ], label[ 0 ], strictEqual( input.checkboxradio( "widget" )[ 0 ], label[ 0 ],
"widget method returns label" ); "widget method returns label" );
}); } );
} ); } );
@ -92,6 +92,6 @@ test( "Input wrapped in a label preserved on refresh", function() {
input.checkboxradio( "refresh" ); input.checkboxradio( "refresh" );
strictEqual( input.parent()[ 0 ], element[ 0 ], "Input preserved" ); strictEqual( input.parent()[ 0 ], element[ 0 ], "Input preserved" );
}); } );
} ); } );

View File

@ -22,9 +22,9 @@ function assertEnabled( checkbox, assert ) {
test( "disabled", function( assert ) { test( "disabled", function( assert ) {
var checkbox = $( "#checkbox-option-disabled" ); var checkbox = $( "#checkbox-option-disabled" );
expect( 6 ); expect( 6 );
checkbox.checkboxradio({ checkbox.checkboxradio( {
disabled: true disabled: true
}); } );
assertDisabled( checkbox, assert ); assertDisabled( checkbox, assert );
@ -33,7 +33,7 @@ test( "disabled", function( assert ) {
checkbox.checkboxradio( "option", "disabled", true ); checkbox.checkboxradio( "option", "disabled", true );
assertDisabled( checkbox, assert ); assertDisabled( checkbox, assert );
}); } );
test( "disabled - prop true on init", function( assert ) { test( "disabled - prop true on init", function( assert ) {
expect( 2 ); expect( 2 );
var checkbox = $( "#checkbox-option-disabled" ); var checkbox = $( "#checkbox-option-disabled" );
@ -42,17 +42,17 @@ test( "disabled - prop true on init", function( assert ) {
checkbox.checkboxradio(); checkbox.checkboxradio();
assertDisabled( checkbox, assert ); assertDisabled( checkbox, assert );
}); } );
test( "disabled - explicit null value, checks the DOM", function( assert ) { test( "disabled - explicit null value, checks the DOM", function( assert ) {
expect( 2 ); expect( 2 );
var checkbox = $( "#checkbox-option-disabled" ); var checkbox = $( "#checkbox-option-disabled" );
checkbox.prop( "disabled", true ); checkbox.prop( "disabled", true );
checkbox.checkboxradio({ checkbox.checkboxradio( {
disabled: null disabled: null
}); } );
assertDisabled( checkbox, assert ); assertDisabled( checkbox, assert );
}); } );
function assertNoIcon( checkbox ) { function assertNoIcon( checkbox ) {
strictEqual( checkbox.checkboxradio( "widget" ).find( "span.ui-icon" ).length, 0, strictEqual( checkbox.checkboxradio( "widget" ).find( "span.ui-icon" ).length, 0,
@ -73,9 +73,9 @@ test( "icon - false on init", function() {
expect( 1 ); expect( 1 );
checkbox.checkboxradio({ icon: false }); checkbox.checkboxradio( { icon: false } );
assertNoIcon( checkbox ); assertNoIcon( checkbox );
}); } );
test( "icon - default unchecked", function( assert ) { test( "icon - default unchecked", function( assert ) {
var checkbox = $( "#checkbox-option-icon" ); var checkbox = $( "#checkbox-option-icon" );
@ -84,8 +84,8 @@ test( "icon - default unchecked", function( assert ) {
checkbox.checkboxradio(); checkbox.checkboxradio();
assertIcon( checkbox, false, assert ); assertIcon( checkbox, false, assert );
}); } );
test( "icon", function( assert ){ test( "icon", function( assert ) {
var checkbox = $( "#checkbox-option-icon" ); var checkbox = $( "#checkbox-option-icon" );
expect( 8 ); expect( 8 );
@ -108,7 +108,7 @@ test( "icon", function( assert ){
checkbox.checkboxradio( "option", "icon", true ); checkbox.checkboxradio( "option", "icon", true );
assertIcon( checkbox, false, assert ); assertIcon( checkbox, false, assert );
}); } );
test( "label - default", function() { test( "label - default", function() {
var checkbox = $( "#checkbox-option-label" ), var checkbox = $( "#checkbox-option-label" ),
@ -122,12 +122,12 @@ test( "label - default", function() {
"checkbox label", "When no value passed on create text from dom is used for option" ); "checkbox label", "When no value passed on create text from dom is used for option" );
strictEqual( widget.text(), strictEqual( widget.text(),
" checkbox label", "When no value passed on create text from dom is used in dom" ); " checkbox label", "When no value passed on create text from dom is used in dom" );
}); } );
test( "label - explicit value", function() { test( "label - explicit value", function() {
expect( 5 ); expect( 5 );
var checkbox = $( "#checkbox-option-label" ).checkboxradio({ var checkbox = $( "#checkbox-option-label" ).checkboxradio( {
label: "foo" label: "foo"
}), } ),
widget = checkbox.checkboxradio( "widget" ), widget = checkbox.checkboxradio( "widget" ),
icon = widget.find( ".ui-icon" ), icon = widget.find( ".ui-icon" ),
iconSpace = widget.find( ".ui-checkboxradio-icon-space" ); iconSpace = widget.find( ".ui-checkboxradio-icon-space" );
@ -142,7 +142,7 @@ test( "label - explicit value", function() {
"Icon space is preserved when label is set on init when wrapped in label" ); "Icon space is preserved when label is set on init when wrapped in label" );
strictEqual( $( "#checkbox-option-label" ).length, 1, strictEqual( $( "#checkbox-option-label" ).length, 1,
"Element is preserved when label is set on init when wrapped in label" ); "Element is preserved when label is set on init when wrapped in label" );
}); } );
test( "label - explicit null value", function() { test( "label - explicit null value", function() {
var checkbox = $( "#checkbox-option-label" ), var checkbox = $( "#checkbox-option-label" ),
@ -153,16 +153,16 @@ test( "label - explicit null value", function() {
// We are testing the default here because the default null is a special value which means to check // We are testing the default here because the default null is a special value which means to check
// the DOM, so we need to make sure this happens correctly checking the options should never return // the DOM, so we need to make sure this happens correctly checking the options should never return
// null. It should always be true or false // null. It should always be true or false
checkbox.checkboxradio({ checkbox.checkboxradio( {
label: null label: null
}); } );
widget = checkbox.checkboxradio( "widget" ); widget = checkbox.checkboxradio( "widget" );
strictEqual( checkbox.checkboxradio( "option", "label" ), strictEqual( checkbox.checkboxradio( "option", "label" ),
"checkbox label", "When null is passed on create text from dom is used for option" ); "checkbox label", "When null is passed on create text from dom is used for option" );
strictEqual( widget.text(), strictEqual( widget.text(),
" checkbox label", "When null is passed on create text from dom is used in dom" ); " checkbox label", "When null is passed on create text from dom is used in dom" );
}); } );
test( "label", function() { test( "label", function() {
var checkbox = $( "#checkbox-option-label" ), var checkbox = $( "#checkbox-option-label" ),
@ -184,6 +184,6 @@ test( "label", function() {
strictEqual( widget.text(), strictEqual( widget.text(),
" bar", "When null is passed text from dom is used in dom" ); " bar", "When null is passed text from dom is used in dom" );
}); } );
} ); } );