├── .gitignore ├── LICENSE ├── README.md ├── demo ├── index.html ├── main.css ├── main.less ├── normalize.css └── prism │ ├── prism.css │ └── prism.js ├── jquery.range-min.js ├── jquery.range.css ├── jquery.range.js ├── jquery.range.less └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.codekit 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Nitin Hayaran 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## jQuery plugin to create Range Selector 2 | 3 |  4 | 5 | [Demo and Documentation](http://nitinhayaran.github.io/jRange/demo/) -------------------------------------------------------------------------------- /demo/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |$('.single-slider').jRange({
41 | from: -2.0,
42 | to: 2.0,
43 | step: 0.5,
44 | scale: [-2.0,-1.0,0.0,1.0,2.0],
45 | format: '%s',
46 | width: 300,
47 | showLabels: true,
48 | snap: true
49 | });
50 | $('.range-slider').jRange({
58 | from: 0,
59 | to: 100,
60 | step: 1,
61 | scale: [0,25,50,75,100],
62 | format: '%s',
63 | width: 300,
64 | showLabels: true,
65 | isRange : true
66 | });
67 | To get started you'll have to include jquery.range.js
and jquery.range.css
files in your html file.
<link rel="stylesheet" href="jquery.range.css">
80 | <script src="jquery.range.js"></script>
81 | Later just add an hidden input, where ever you want this slider to be shown.
82 |<input type="hidden" class="slider-input" value="23" />
83 | After this you'll have to intialize this plugin for that input, as shown in the example above
84 | 85 |Options can also be set programatically, by passing an options hash to the jRange method. 88 |
Option | 91 |Override | 92 |Type | 93 |Details | 94 |
---|---|---|---|
from | 97 |Mandatory | 98 |Integer | 99 |Lower bound of slider | 100 |
to | 103 |Mandatory | 104 |Integer | 105 |Upper bound of slider | 106 |
step | 109 |Optional | 110 |Integer | 111 |
112 | Default : 1
113 | amount of increment on each step 114 | |
115 |
scale | 118 |Optional | 119 |Array | 120 |
121 | Array containing label which are shown below the slider. By default its [from, to]. 122 | |
123 |
showLabels | 126 |Optional | 127 |Boolean | 128 |
129 | False, if you'd like to hide label which are shown on top of slider. 130 |Default : true
131 | |
132 |
showScale | 135 |Optional | 136 |Boolean | 137 |
138 | False, if you'd like to hide scale which are shown below the slider. 139 |Default : true
140 | |
141 |
format | 144 |Optional | 145 |String / Function | 146 |
147 | this is used to show label on the pointer 148 |Default : "%s"
149 |
151 | |
157 |
width | 160 |Optional | 161 |Integer | 162 |
163 | Default : 300
164 | |
165 |
theme | 168 |Optional | 169 |String | 170 |
171 | Default : "theme-green"
172 | This is the css class name added to the container. Available themes are "theme-blue", "theme-green". You can also add more themes, just like in |
174 |
isRange | 177 |Optional | 178 |Boolean | 179 |
180 | Default : false
181 | True if this is a range selector. If its a range the value of hidden input will be set comma-seperated, e.g., "25,75" 182 | |
183 |
snap | 186 |Optional | 187 |Boolean | 188 |
189 | Default : false
190 | True to snap slider to step values 191 | |
192 |
disable | 195 |Optional | 196 |Boolean | 197 |
198 | Default : false
199 | True if this is a disable(read only) range selector. You can also change disable status later by calling. 200 |
201 | $('.slider').jRange('disable');
202 | $('.slider').jRange('enable');
203 | $('.slider').jRange('toggleDisable');
204 |
205 | |
206 |
onstatechange | 209 |Optional | 210 |Function | 211 |
212 | This function is called whenever the value is changed by user. This same value is also automatically set for the provided Hidden Input. 213 |For single slider value is without comma, however for a range selector value is comma-seperated. 214 | |
215 |
ondragend | 218 |Optional | 219 |Function | 220 |
221 | ondragend callback. Useful if you want to fire event just once per slider drag. 222 | |
223 |
onbarclicked | 226 |Optional | 227 |Function | 228 |
229 | called when user clicks on the bar 230 | |
231 |
Methods which you can call to dynamically modify current values and range. 237 |
Method | 240 |241 | | 242 | | Description | 243 |
---|---|---|---|
setValue | 246 |247 | | 248 | |
249 | sets the current value of the slider without changing its range, if you want to update the range as well use
251 | $('.slider').jRange('setValue', '10,20');
254 | |
255 |
updateRange | 258 |259 | | 260 | |
261 | 'updateRange' to change (min, max) value and interval after initialized. 262 |
263 | $('.slider').jRange('updateRange', '0,100');
267 | passing second parameter also sets its current value 268 | |
269 |