|
| 1 | +<!doctype html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="utf-8"> |
| 5 | + <title>jQuery UI Checkboxradio - Product Selector</title> |
| 6 | + <link rel="stylesheet" href="../../themes/base/all.css"> |
| 7 | + <script src="../../external/jquery/jquery.js"></script> |
| 8 | + <script src="../../ui/core.js"></script> |
| 9 | + <script src="../../ui/widget.js"></script> |
| 10 | + <script src="../../ui/checkboxradio.js"></script> |
| 11 | + <script src="../../ui/controlgroup.js"></script> |
| 12 | + <link rel="stylesheet" href="../demos.css"> |
| 13 | + <script> |
| 14 | + $(function() { |
| 15 | + $( "input" ).checkboxradio(); |
| 16 | + $( "[name='shape']").on( "change", function(){ |
| 17 | + $( ".shape" ).removeClass( "circle pill square rectangle" ) |
| 18 | + .addClass( $( this ).val() ); |
| 19 | + }); |
| 20 | + $( ".toggle" ).on( "change", function(){ |
| 21 | + if ( $( this ).is( ".brand-toggle" ) ) { |
| 22 | + var checked = $( this ).is( ":checked" ), |
| 23 | + value = $( "[name='brand']" ).filter( ":checked" ).attr( "data-" + this.id ) |
| 24 | + $( ".shape" ).css( this.id, checked ? value : "" ); |
| 25 | + } else { |
| 26 | + $( ".shape" ).toggleClass( this.id, $( this ).is( ":checked") ); |
| 27 | + } |
| 28 | + }); |
| 29 | + $( "[name='brand']").on( "change", function(){ |
| 30 | + $( "input" ).filter( ":checked" ).not( this ).trigger( "change" ); |
| 31 | + }); |
| 32 | + $( "input" ).filter( ":checked" ).trigger( "change" ); |
| 33 | + $( ".shape-bar, .brand" ).controlgroup(); |
| 34 | + $( ".toggles" ).controlgroup({ |
| 35 | + direction: "vertical" |
| 36 | + }); |
| 37 | + }); |
| 38 | + </script> |
| 39 | + <style> |
| 40 | + .shape { |
| 41 | + margin-left: 4em; |
| 42 | + margin-top: 2.5em; |
| 43 | + height: 8em; |
| 44 | + width: 8em; |
| 45 | + box-shadow: 4px 4px 8px; |
| 46 | + color: #ccc; |
| 47 | + background-repeat: no-repeat; |
| 48 | + background-size: 90%; |
| 49 | + background-position: 50%; |
| 50 | + } |
| 51 | + .circle, .pill { |
| 52 | + border-radius: 8em; |
| 53 | + } |
| 54 | + .pill, .rectangle { |
| 55 | + width: 16em; |
| 56 | + } |
| 57 | + .square, .circle { |
| 58 | + margin-left: 9em; |
| 59 | + } |
| 60 | + .border { |
| 61 | + border: 2px solid #333333; |
| 62 | + } |
| 63 | + .toggles { |
| 64 | + width: 200px; |
| 65 | + } |
| 66 | + .toggle-wrap, .shape { |
| 67 | + display: inline-block; |
| 68 | + vertical-align: top; |
| 69 | + } |
| 70 | + .controls { |
| 71 | + background: #ccc; |
| 72 | + padding: 1em; |
| 73 | + display: inline-block; |
| 74 | + } |
| 75 | + </style> |
| 76 | +</head> |
| 77 | +<body> |
| 78 | +<div class="controls"> |
| 79 | + <div class="brand-wrap"> |
| 80 | + <h3>1.) Select a brand</h3> |
| 81 | + <div class="brand"> |
| 82 | + <label for="brand-jquery">jQuery</label> |
| 83 | + <input data-background-color="#0769AD" data-color="#7ACEF4" data-background-image="url(images/jquery.png)" type="radio" name="brand" id="brand-jquery"> |
| 84 | + <label for="brand-jquery-ui">jQuery UI</label> |
| 85 | + <input data-background-color="#B24926" data-color="#FAA523" data-background-image="url(images/jquery-ui.png)" type="radio" name="brand" id="brand-jquery-ui" checked> |
| 86 | + <label for="brand-jquery-mobile">jQuery Mobile</label> |
| 87 | + <input data-background-color="#108040" data-color="#3EB249" data-background-image="url(images/jquery-mobile.png)" type="radio" name="brand" id="brand-jquery-mobile"> |
| 88 | + <label for="brand-sizzle">Sizzle</label> |
| 89 | + <input data-background-color="#9A1B1E" data-color="#FAA523" data-background-image="url(images/sizzle.png)" type="radio" name="brand" id="brand-sizzle"> |
| 90 | + <label for="brand-qunit">QUnit</label> |
| 91 | + <input data-background-color="#390F39" data-color="#9C3493" data-background-image="url(images/qunit.png)" type="radio" name="brand" id="brand-qunit"> |
| 92 | + </div> |
| 93 | + </div> |
| 94 | + <div class="shape-wrap"> |
| 95 | + <h3>2.) Select a shape</h3> |
| 96 | + <div class="shape-bar"> |
| 97 | + <label for="shape-circle">Circle</label> |
| 98 | + <input type="radio" name="shape" id="shape-circle" value="circle" checked> |
| 99 | + <label for="shape-square">Square</label> |
| 100 | + <input type="radio" name="shape" id="shape-square" value="square"> |
| 101 | + <label for="shape-pill">Pill</label> |
| 102 | + <input type="radio" name="shape" id="shape-pill" value="pill"> |
| 103 | + <label for="shape-rectangle">Rectangle</label> |
| 104 | + <input type="radio" name="shape" id="shape-rectangle" value="rectangle"> |
| 105 | + </div> |
| 106 | + </div> |
| 107 | + <div class="toggle-wrap"> |
| 108 | + <h3>3.) Customize</h3> |
| 109 | + <div class="toggles"> |
| 110 | + <label for="color">Shadow</label> |
| 111 | + <input class="toggle brand-toggle" type="checkbox" name="color" id="color"> |
| 112 | + <label for="border">Border</label> |
| 113 | + <input class="toggle" type="checkbox" name="border" id="border"> |
| 114 | + <label for="background-color">Background</label> |
| 115 | + <input class="toggle brand-toggle" type="checkbox" name="background-color" id="background-color" checked> |
| 116 | + <label for="background-image">Background Image</label> |
| 117 | + <input class="toggle brand-toggle" type="checkbox" name="background-image" id="background-image" checked> |
| 118 | + </div> |
| 119 | + </div> |
| 120 | + <div class="shape circle background jquery-ui"></div> |
| 121 | +</div> |
| 122 | + |
| 123 | +<div class="demo-description"> |
| 124 | +<p>Using two sets of radio buttons, as horizontal controlgroups, and one group of checkboxes, as a vertical controlgroup, to implement a product selector.</p> |
| 125 | +</div> |
| 126 | +</body> |
| 127 | +</html> |
0 commit comments