forked from hernansartorio/jquery-nice-select
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
180 lines (132 loc) · 6.37 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<title>jQuery Nice Select</title>
<link href='https://fonts.googleapis.com/css?family=Work+Sans:300,400,600&Inconsolata:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="container">
<div class="header">
<h1>jQuery Nice Select</h1>
<p>A lightweight jQuery plugin that replaces native select elements with customizable dropdowns.</p>
<a href="https://github.com/hernansartorio/jquery-nice-select/archive/v1.0.zip" class="button">Download</a>
<a href="https://github.com/hernansartorio/jquery-nice-select" class="button light">View on GitHub</a>
</div>
<h2>Why?</h2>
<p>I tried every similar plugin I could find, but after having a hard time customizing them I decided to build my own.</p>
<h2>Usage</h2>
<p><strong>1.</strong> Include jQuery and the plugin.</p>
<pre><code class="language-html"><script src="path/to/jquery.js"></script>
<script src="path/to/jquery.nice-select.js"></script></code></pre>
<p><strong>2.</strong> Include the plugin styles, either the compiled CSS...</p>
<pre><code class="language-html"><link rel="stylesheet" href="path/to/nice-select.css"></code></pre>
<p>...or, ideally, import the SASS source (if you use SASS) in your main stylesheet for easier customization.</p>
<pre><code class="language-scss">@import 'nice-select';</code></pre>
<p><strong>3.</strong> Finally, initialize the plugin.</p>
<pre><code class="language-js">$(document).ready(function() {
$('select').niceSelect();
});</code></pre>
<p>All done. That will turn this:</p>
<pre><code class="language-html"><select>
<option value="1">Some option</option>
<option value="2">Another option</option>
<option value="3">Potato</option>
</select></code></pre>
<p>...into this:</p>
<div class="box">
<select>
<option value="1">Some option</option>
<option value="2">Another option</option>
<option value="3">Potato</option>
</select>
</div>
<p>For reference, this is the markup structure that was generated above:</p>
<pre><code class="language-html"><div class="nice-select">
<span class="current">Some option</span>
<ul class="list">
<li class="option selected">Some option</li>
<li class="option">Another option</li>
<li class="option">Potato</li>
</ul>
</div></code></pre>
<p>There are no settings (a native select doesn't have settings), although there are a couple of special features, documented below.</p>
<h2>Display text</h2>
<p>You can specify an alternate text for each option, which will be displayed on the dropdown when that option is selected.</p>
<p>Add a <code class="language-html">data-display</code> attribute to the desired options. For example:</p>
<pre><code class="language-html"><select>
<option data-display="Select">Nothing</option>
<option value="1">Some option</option>
<option value="2">Another option</option>
<option value="3">Potato</option>
</select></code></pre>
<div class="box">
<select>
<option data-display="Select">Nothing</option>
<option value="1">Some option</option>
<option value="2">Another option</option>
<option value="3">Potato</option>
</select>
</div>
<h2>Custom classes</h2>
<p>Every class you assign to a select element will be copied to the generated dropdown. That way you can customize different versions of it to your needs just by adding new CSS.</p>
<p>These are some examples included in the plugin stylesheet:</p>
<div class="box">
<label>Wide</label>
<select class="wide">
<option data-display="Select">Nothing</option>
<option value="1">Some option</option>
<option value="2">Another option</option>
<option value="3">Potato</option>
</select>
</div>
<div class="box">
<label class="right">Right</label>
<select class="right">
<option data-display="Select">Nothing</option>
<option value="1">Some option</option>
<option value="2">Another option</option>
<option value="3">Potato</option>
</select>
</div>
<div class="box">
<label>Small</label>
<select class="small">
<option data-display="Select">Nothing</option>
<option value="1">Some option</option>
<option value="2">Another option</option>
<option value="3">Potato</option>
</select>
</div>
<div class="footer">
<h2>Use responsibly</h2>
<p><a href="http://www.lukew.com/ff/entry.asp?1950">Dropdowns should be the UI of last resort.</a></p>
<a href="https://github.com/hernansartorio/jquery-nice-select/archive/v1.0.zip" class="button">Download</a>
<a href="https://github.com/hernansartorio/jquery-nice-select" class="button light">View on GitHub</a>
<div class="credit">
Made by <a href="http://hernansartorio.com/">Hernán Sartorio</a>
</div>
</div>
</div>
<script src="js/jquery.js"></script>
<script src="js/jquery.nice-select.min.js"></script>
<script src="js/fastclick.js"></script>
<script src="js/prism.js"></script>
<script>
$(document).ready(function() {
$('select').niceSelect();
FastClick.attach(document.body);
});
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-64633646-1', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>