forked from Swizec/checkbox-field
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
190 lines (168 loc) · 7.21 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Checkbox-field</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- Le styles -->
<link href="css/bootstrap.css" rel="stylesheet">
<style type="text/css">
body {
padding-top: 60px;
padding-bottom: 40px;
}
</style>
<link href="css/bootstrap-responsive.css" rel="stylesheet">
<link href="css/prettify.css" type="text/css" rel="stylesheet">
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- Le fav and touch icons -->
<link rel="shortcut icon" href="ico/favicon.ico">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="ico/apple-touch-icon-57-precomposed.png">
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="#">Checkbox-field</a>
<div class="nav-collapse">
<ul class="nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="http://swizec.com">My blog :)</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<div class="container">
<!-- Main hero unit for a primary marketing message or call to action -->
<div class="hero-unit">
<h1>Checkbox-field</h1>
<p>A simple javascript thing that turns ugly multiselects into shiny checkbox fields, using Backbone, Handlebars and jQuery.</p>
<p>Finally a way to select multiple things that users can understand and you can easily work with!</p>
<p><a class="btn btn-primary btn-large" href="https://github.com/Swizec/checkbox-field">View on Github »</a></p>
<p>
<iframe src="http://markdotto.github.com/github-buttons/github-btn.html?user=Swizec&repo=checkbox-field&type=fork&count=true"
allowtransparency="true" frameborder="0" scrolling="0" width="110px" height="20px"></iframe>
<iframe src="http://markdotto.github.com/github-buttons/github-btn.html?user=Swizec&repo=checkbox-field&type=watch&count=true"
allowtransparency="true" frameborder="0" scrolling="0" width="110px" height="20px"></iframe>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="Swizec">Tweet</a>
</p>
</div>
<div id="checkbox-template" style="display:none">
<div style="display:inline-block; width: 100px ">
<input type="checkbox" id="checkbox_{{id}}" />
<label for="checkbox_{{id}}" style="display: inline">{{label}}</label>
</div>
</div>
<!-- Example row of columns -->
<div class="row">
<a name="example"></a>
<div class="span4">
<h2>Vanilla multiselect</h2>
<select id="vanilla" multiple="1">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
<option value="4">Option 4</option>
</select>
<p>A multiselect field is the most confusing HTML widget ever envisioned. Everybody gets confused by them.</p>
</div>
<div class="span4">
<h2>Many checkboxes</h2>
<p id="checkboxes">
</p>
<p id="select_all">
</p>
<p>A bunch of checkboxes look better, but they are difficult for the backend developer to handle.</p>
</div>
<div class="span4">
<h2>Checkbox-field</h2>
<p>
<select id="example" multiple="1">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
<option value="4">Option 4</option>
</select>
</p>
<p>Combining the two gives us the best of both worlds. Users see a field of checkboxes and they are submitted as a single form field. </p>
</div>
</div>
<div class="row">
<div class="span7">
<h2>How to Use</h2>
<p>Using checkbox-field is just calling a function! Or you can customise it a little bit.</p>
<pre class="prettyprint linenums">
$("#my_selector").checkboxField();
// there are also some options
$("#my_selector").checkboxField({
// a handlebars template for the checkboxes (default: #checkbox-template)
template: "#checkbox-template",
// placeholder for checkboxes (default: one is created)
checkboxes: null,
// hide the original multiselect or not (default: yup)
hide: true
// display "select all" (default: true)
show_select_all: true
// labels for select_all control
select_all: "Select all",
deselect_all: "Deselect all"
});
</pre>
</div>
<div class="span5">
<h2>Installation</h2>
<p><ol>
<li><a href="https://github.com/Swizec/checkbox-field">Download checkbox-field</a></li>
<li>Get <a href="http://backbonejs.org/">Backbone</a></li>
<li>Get <a href="http://handlebarsjs.com/">Handlebars</a></li>
<li>Insert this HTML somewhere
<pre class="prettyprint linenums">
<div id="checkbox-template"
style="display:none">
<div style="display:inline-block">
<input type="checkbox"
id="checkbox_{{id}}" />
<label for="checkbox_{{id}}">
{{label}}
</label>
</div>
</div>
</pre>
</li>
<li>That's it! Ready to use :)</li>
</ol></p>
</div>
</div>
<hr>
<footer>
<p><a href="http://twitter.com/Swizec">@Swizec</a> created this in Ljubljana with love, 2012</p>
</footer>
</div> <!-- /container -->
<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src="js/prettify.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/handlebars.js"></script>
<script src="js/underscore-min.js"></script>
<script src="js/backbone-min.js"></script>
<script src="src/checkbox-field.js"></script>
<script src="js/main.js"></script>
</body>
</html>