forked from jquery-archive/jquery-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
158 lines (122 loc) · 6.42 KB
/
index.php
File metadata and controls
158 lines (122 loc) · 6.42 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Dynamic controlgroup - jQuery Mobile Demos</title>
<link rel="shortcut icon" href="../favicon.ico">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,700">
<link rel="stylesheet" href="../../css/themes/default/jquery.mobile.css">
<link rel="stylesheet" href="../_assets/css/jqm-demos.css">
<script src="../../external/jquery/jquery.js"></script>
<script src="../_assets/js/"></script>
<script src="../../js/"></script>
<script>
( function( $, undefined ) {
var counter = 0;
$( document ).bind( "pagecreate", function( e ) {
$( "#prepend, #append", e.target ).on( "click", function( e ) {
counter++;
var widgetType = $( "[name='radio-widget']:checked" ).attr( "id" ),
group = $( "#my-controlgroup" ),
$el,
action = function() {
var action = $( "[name='radio-action']:checked" ).attr( "id" );
if ( $( $el[1] ).is( "select" ) && action === "hide" ) {
$el = $( $el[1] ).parents( ".ui-select" );
}
$el[ action ]();
group.controlgroup( "refresh" );
};
if ( widgetType === "link" ) {
$el = $( "<a href='#'>Link " + counter + "</a>" ).bind( "click", action );
$( "#my-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 value='option1'>Select " + counter + "</option><option value='option2'>Select option</option></select>" );
$( $el[ 1 ] ).bind( "change", action);
$( "#my-controlgroup" ).controlgroup( "container" )[ $( this ).attr( "id" ) ]( $el );
$( $el[ 1 ] ).selectmenu();
} else {
$el = $( "<label for='widget" + counter + "'>Checkbox " + counter + "</label><input type='checkbox' id='widget" + counter + "'></input>" );
$( $el[ 1 ] ).bind( "change", action );
$( "#my-controlgroup" ).controlgroup( "container" )[ $( this ).attr( "id" ) ]( $el );
$( $el[ 1 ] ).checkboxradio();
}
group.controlgroup( "refresh" );
});
$( "[name='radio-orientation']" ).bind( "change", function( e ) {
$( "#my-controlgroup" ).controlgroup( "option", "type", ( $( "#isHorizontal" ).is( ":checked" ) ? "horizontal" : "vertical" ) );
});
});
})( jQuery );
</script>
</head>
<body>
<div data-role="page" class="jqm-demos">
<div data-role="header" class="jqm-header">
<h2><a href="../" title="jQuery Mobile Demos home"><img src="../_assets/img/jquery-logo.png" alt="jQuery Mobile"></a></h2>
<p><span class="jqm-version"></span> Demos</p>
<a href="#" class="jqm-navmenu-link ui-btn ui-btn-icon-notext ui-corner-all ui-icon-bars ui-nodisc-icon ui-alt-icon ui-btn-left">Menu</a>
<a href="#" class="jqm-search-link ui-btn ui-btn-icon-notext ui-corner-all ui-icon-search ui-nodisc-icon ui-alt-icon ui-btn-right">Search</a>
</div><!-- /header -->
<div role="main" class="ui-content jqm-content">
<h1>Dynamic controlgroup</h1>
<p>This demo shows how you can dynamically make changes to a controlgroup.</p>
<div data-demo-html="true" data-demo-js="true">
<form>
<div class="ui-body ui-body-d ui-corner-all">
<p>Controlgroup...</p>
<div data-role="controlgroup" id="my-controlgroup"><!-- items will be injected here --></div>
</div>
</form>
<div class="ui-field-contain">
<label for="prepend">Add item</label>
<button id="prepend" data-mini="true" data-inline="true">Prepend</button>
<label for="append" class="ui-hidden-accessible">Action</label>
<button id="append" data-mini="true" data-inline="true">Append</button>
</div>
<form action="#" method="get">
<div class="ui-field-contain">
<fieldset data-role="controlgroup" data-type="horizontal" data-mini="true">
<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>
</div>
<div class="ui-field-contain">
<fieldset data-role="controlgroup" data-type="horizontal" data-mini="true">
<legend>Action<br><small>on click/change</small></legend>
<input type="radio" name="radio-action" id="remove" value="remove" checked="checked">
<label for="remove">Remove</label>
<input type="radio" name="radio-action" id="hide" value="hide">
<label for="hide">Hide</label>
<input type="radio" name="radio-action" id="width" value="width">
<label for="width">Nothing</label>
</fieldset>
</div>
<div class="ui-field-contain">
<fieldset data-role="controlgroup" data-type="horizontal" data-mini="true">
<legend>Switch orientation</legend>
<input type="radio" name="radio-orientation" id="isVertical" value="isVertical" checked="checked">
<label for="isVertical">Vertical</label>
<input type="radio" name="radio-orientation" id="isHorizontal" value="isHorizontal">
<label for="isHorizontal">Horizontal</label>
</fieldset>
</div>
</form>
</div><!--/demo-html -->
</div><!-- /content -->
<?php include( '../jqm-navmenu.php' ); ?>
<div data-role="footer" data-position="fixed" data-tap-toggle="false" class="jqm-footer">
<p>jQuery Mobile Demos version <span class="jqm-version"></span></p>
<p>Copyright 2014 The jQuery Foundation</p>
</div><!-- /footer -->
<?php include( '../jqm-search.php' ); ?>
</div><!-- /page -->
</body>
</html>