forked from kosmikko/bootstrap-checkbox-tree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·140 lines (130 loc) · 4.5 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<link href="http://twitter.github.com/bootstrap/assets/js/google-code-prettify/prettify.css" rel="stylesheet">
<link href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" rel="stylesheet">
<link href="http://twitter.github.com/bootstrap/assets/css/bootstrap-responsive.css" rel="stylesheet">
<link rel="stylesheet/less" href="css/bootstrap-checkbox-tree.less" type="text/css" />
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap-checkbox-tree.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/less.js/1.3.0/less-1.3.0.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
var cbTree = $('.checkbox-tree').checkboxTree({
checkChildren : true,
singleBranchOpen: true,
openBranches: ['.liverpool', '.chelsea']
});
$('#tree-expand').on('click', function(e) {
cbTree.expandAll();
});
$('#tree-collapse').on('click', function(e) {
cbTree.collapseAll();
});
$('#tree-default').on('click', function(e) {
cbTree.defaultExpand();
});
$('#tree-select-all').on('click', function(e) {
cbTree.checkAll();
});
$('#tree-deselect-all').on('click', function(e) {
cbTree.uncheckAll();
});
$('.checkbox-tree').on('checkboxTicked', function(e) {
var checkedCbs = $(e.currentTarget).find("input[type='checkbox']:checked");
console.log('checkbox tick', checkedCbs.length);
});
});
</script>
<title>Collapsible Checkbox Tree example</title>
</head>
<body>
<div class="container">
<div class="page-header"><h1>Collapsible Checkbox Tree</h1></div>
<div class="row">
<div class="span8">
<h2>Example</h2>
<form action="" method="post" class="well">
<ul class="checkbox-tree root">
<li>
<input type="checkbox" name="" checked="checked" />
<label>Manchester United</label>
<ul class="manu">
<li>
<input type="checkbox" name="" />
<label>Ryan Giggs</label>
</li>
<li>
<input type="checkbox" name="" />
<label>Paul Scholes</label>
</li>
<li>
<input type="checkbox" name="" />
<label>Wayne Rooney</label>
</li>
</ul>
</li>
<li>
<input type="checkbox" name="" />
<label>Chelsea</label>
<ul class="chelsea">
<li>
<input type="checkbox" name="" />
<label>Joe Cole</label>
</li>
<li>
<input type="checkbox" name="" />
<label>Frank Lampard</label>
</li>
<li>
<input type="checkbox" name="" />
<label>Didier Drogba</label>
</li>
<li>
<input type="checkbox" name="" />
<label>John Terry</label>
</li>
</ul>
</li>
<li>
<input type="checkbox" name="" />
<label>Liverpool</label>
<ul class="liverpool">
<li>
<input type="checkbox" name="" />
<label>Fernando Torres</label>
</li>
<li>
<input type="checkbox" name="" />
<label>Steven Gerrard</label>
</li>
</ul>
</li>
</ul>
</form>
<div class="btn-group" data-toggle="buttons-radio">
<button id="tree-expand" class="btn">Expand All</button>
<button id="tree-collapse" class="btn">Collapse All</button>
<button id="tree-default" class="btn">Default</button>
</div>
<p></p>
<div class="btn-group">
<button id="tree-select-all" class="btn">Select all</button>
<button id="tree-deselect-all" class="btn">Deselect all</button>
</div>
</div>
</div>
<hr>
<div class="row">
<div class="span12">
<h2>Usage</h2>
<pre class='prettyprint'>
$('.checkbox-tree').checkboxTree({
checkChildren : true
});
</pre>
</div>
</div>
</div>
</body>
</html>