forked from jquery-archive/jquery-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrolgroup.html
More file actions
96 lines (89 loc) · 3.8 KB
/
controlgroup.html
File metadata and controls
96 lines (89 loc) · 3.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery Mobile Button Markup Tester</title>
<link rel="stylesheet" href="../../css/themes/default/jquery.mobile.css" />
<script src="../../js/jquery.tag.inserter.js"></script>
<script src="../../js"></script>
<script>
( function( $, undefined ) {
var counter = 0;
$( document ).bind( "pageinit", function( e ) {
$( "#prepend,#append", e.target ).bind( "click", function( e ) {
counter++;
var widgetType = $( "[name='radio-widget']:checked" ).attr( "id" ),
grp = $( "#controlgroup" ), $el,
action = function() {
var op = $( "[name='radio-op']:checked" ).attr( "id" );
$el[ op ](); grp.controlgroup( "refresh" );
};
if ( widgetType === "link" ) {
$el = $( "<a href='#'>Remove " + counter + "</a>" ).bind( "click", action );
$( "#controlgroup" ).controlgroup( "container" )[ $( this ).attr( "id" ) ]( $el );
$el.buttonMarkup();
} else if ( widgetType === "select" ) {
$el = $( "<label for='widget" + counter + "'>Select " + counter + "</label><select id='widget" + counter + "'><option id='widget" + counter + "' value='default'>Select " + counter + "</option><option value='remove'>Remove</option></select>" );
$( $el[ 1 ] ).bind( "change", action);
$( "#controlgroup" ).controlgroup( "container" )[ $( this ).attr( "id" ) ]( $el );
$( $el[ 1 ] ).selectmenu();
} else {
$el = $( "<label for='widget" + counter + "'>Remove " + counter + "</label><input type='checkbox' id='widget" + counter + "'></input>" );
$( $el[ 1 ] ).bind( "change", action );
$( "#controlgroup" ).controlgroup( "container" )[ $( this ).attr( "id" ) ]( $el );
$( $el[ 1 ] ).checkboxradio();
}
grp.controlgroup( "refresh" );
});
$( "#isHorizontal" ).bind( "change", function( e ) {
$( "#controlgroup" ).controlgroup( "option", "type", ( $( "#isHorizontal" ).is( ":checked" ) ? "horizontal" : "vertical" ) );
});
});
})( jQuery );
</script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>Controlroup Dynamic Modification</h1>
</div>
<div data-role="contents">
<div class="ui-grid-a">
<div class="ui-block-a">
<div data-role="controlgroup" id="controlgroup">
</div>
</div>
<div class="ui-block-b">
<a href="#" id="prepend" data-role="button" data-corners="true" data-inline="true">Prepend</a>
<a href="#" id="append" data-role="button" data-corners="true" data-inline="true">Append</a>
<form action="#" method="get">
<fieldset data-role="controlgroup" data-type="horizontal">
<legend>Widget type</legend>
<input type="radio" name="radio-widget" id="link" value="link" checked="checked" />
<label for="link">Link</label>
<input type="radio" name="radio-widget" id="select" value="select" />
<label for="select">Select</label>
<input type="radio" name="radio-widget" id="checkbox" value="checkbox" />
<label for="checkbox">Checkbox</label>
</fieldset>
<fieldset data-role="controlgroup" data-type="horizontal">
<legend>Operation</legend>
<input type="radio" name="radio-op" id="remove" value="remove" checked="checked" />
<label for="remove">Remove</label>
<input type="radio" name="radio-op" id="hide" value="hide" />
<label for="hide">Hide</label>
<input type="radio" name="radio-op" id="width" value="width" />
<label for="width">Nothing</label>
</fieldset>
<div data-role="fieldcontain">
<input id="isHorizontal" data-inline="true" type="checkbox"></input>
<label for="isHorizontal">Horizontal</label>
</div>
</form>
</div>
</div>
</div>
</div>
</body>
</html>