-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Button icon span #1216
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
Button icon span #1216
Changes from 1 commit
d0d24a1
cf6e119
747635a
b408636
d344b50
d903e1a
6591ad1
b782bfc
19c6b9e
3223c29
01c54ec
fe00326
35564dd
0d71cbf
995a855
f55d4ce
1e225e7
d566fec
1ccec99
8d64f1f
21afafd
661ce0e
d3b0f85
0fead84
9b7dbc6
234aeb1
06455ac
320e2ec
c485bc5
4ab74f1
bad64ec
d95139e
b865d59
baf108e
841abaf
48c7481
dae9466
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,30 +8,71 @@ | |
| <script src="../../ui/core.js"></script> | ||
| <script src="../../ui/widget.js"></script> | ||
| <script src="../../ui/button.js"></script> | ||
| <script src="../../ui/checkboxradio.js"></script> | ||
| <link rel="stylesheet" href="../demos.css"> | ||
| <script> | ||
| $(function() { | ||
| $( "#check" ).button(); | ||
| $( "#format" ).buttonset(); | ||
| $( "form input" ).checkboxradio(); | ||
|
|
||
| $(".controls input, .controls select").on( "change", function(){ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whitespace. For the text input, |
||
| var option = $( this ).attr( "name" ), | ||
| value = $( this ).val(); | ||
|
|
||
| if( $( this ).attr( "type" ) === "checkbox" ) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd use
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or |
||
| if( $( this ).is(":checked") ) { | ||
| value = true; | ||
| } else { | ||
| value = false; | ||
| } | ||
| } | ||
| $( "form input" ).checkboxradio( "option", option, value ); | ||
| }); | ||
| $( "#create" ).click( function(){ | ||
| $( "form input" ).checkboxradio(); | ||
| }); | ||
| $( "#destroy" ).click( function(){ | ||
| $( "form input" ).checkboxradio( "destroy" ); | ||
| }); | ||
| $( "#enable" ).click( function(){ | ||
| $( "form input" ).checkboxradio( "enable"); | ||
| }); | ||
| $( "#disable" ).click( function(){ | ||
| $( "form input" ).checkboxradio( "disable" ); | ||
| }); | ||
| $( "#refresh" ).click( function(){ | ||
| $( "form input" ).checkboxradio( "refresh" ); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This stuff could be refactored, using |
||
| }); | ||
| }); | ||
| </script> | ||
| <style> | ||
| #format { margin-top: 2em; } | ||
| </style> | ||
| </head> | ||
| <body> | ||
|
|
||
| <input type="checkbox" id="check" /><label for="check">Toggle</label> | ||
|
|
||
| <div id="format"> | ||
| <input type="checkbox" id="check1" /><label for="check1">B</label> | ||
| <input type="checkbox" id="check2" /><label for="check2">I</label> | ||
| <input type="checkbox" id="check3" /><label for="check3">U</label> | ||
| <div class="demo-description"> | ||
| css for new checkbox widget | ||
| </div> | ||
| <div class="controls"> | ||
| <button id="create">Create</button> | ||
| <button id="destroy">Destroy</button> | ||
| <button id="enable">Enable</button> | ||
| <button id="disable">Disable</button> | ||
| <button id="refresh">Refresh</button> | ||
| <input type="checkbox" id="icon" name="icon"><label for="icon">Icon</label> | ||
| <input type="checkbox" id="disabled" name="disabled"><label for="disabled">Disabled</label> | ||
| <input type="text" id="label" name="label"><label for="label">Label</label> | ||
| </div> | ||
| <form> | ||
|
|
||
| <div class="demo-description"> | ||
| <p>A checkbox is styled as a toggle button with the button widget. The label element associated with the checkbox is used for the button text.</p> | ||
| <p>This demo also demonstrates three checkboxes styled as a button set by calling <code>.buttonset()</code> on a common container.</p> | ||
| <input type="checkbox" id="checkbox-1" /> | ||
| <label for="checkbox-1">Checkbox widget sample</label> | ||
| <label for="checkbox-2">Checkbox widget sample<input type="checkbox" id="checkbox-2" /></label> | ||
|
|
||
| <input type="radio" id="radio-1" name="radio"/> | ||
| <label for="radio-1">Radio widget sample</label> | ||
| <label for="radio-2">Radio widget sample 2<input type="radio" id="radio-2"/></label> | ||
| <button type="reset">Reset</button> | ||
| </form> | ||
| </div> | ||
| </body> | ||
| </html> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,7 +43,7 @@ test("text false without icon", function() { | |
| $("#button").button({ | ||
| text: false | ||
| }); | ||
| ok( $("#button").is(".ui-button-text-only:not(.ui-button-icon-only)") ); | ||
| ok( $("#button").is(":not(.ui-button-icon-only)") ); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's rewrite this test to something like this: equal( $("#button").attr( "class" ), "..." );
|
||
|
|
||
| $("#button").button("destroy"); | ||
| }); | ||
|
|
@@ -52,9 +52,7 @@ test("text false with icon", function() { | |
| expect( 1 ); | ||
| $("#button").button({ | ||
| text: false, | ||
| icons: { | ||
| primary: "iconclass" | ||
| } | ||
| icon: "iconclass" | ||
| }); | ||
| ok( $("#button").is(".ui-button-icon-only:not(.ui-button-text):has(span.ui-icon.iconclass)") ); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above, let's look at the class and be specific. Also applies to all the other ok/is tests in here. |
||
|
|
||
|
|
@@ -100,12 +98,9 @@ test("icons", function() { | |
| expect( 1 ); | ||
| $("#button").button({ | ||
| text: false, | ||
| icons: { | ||
| primary: "iconclass", | ||
| secondary: "iconclass2" | ||
| } | ||
| icon: "iconclass" | ||
| }); | ||
| ok( $("#button").is(":has(span.ui-icon.ui-button-icon-primary.iconclass):has(span.ui-icon.ui-button-icon-secondary.iconclass2)") ); | ||
| ok( $("#button").is(":has(span.ui-icon.iconclass)") ); | ||
|
|
||
| $("#button").button("destroy"); | ||
| }); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Store this selection and reuse it below.