Skip to content

Commit 8ce4ad9

Browse files
committed
Archived copy of docs
1 parent 71115d9 commit 8ce4ad9

File tree

3 files changed

+119
-17
lines changed

3 files changed

+119
-17
lines changed

README.md

+119-17
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,129 @@
1-
jQuery Simple Slider: Unobtrusive Numerical Slider
2-
==================================================
1+
# jQuery Simple Slider: Unobtrusive Numerical Slider
32

4-
SimpleSlider is a jQuery plugin for turning your text inputs into draggable
5-
numerical sliders.
3+
## Overview
64

7-
It has no external dependencies other than jQuery, and you don't need to write
8-
a single line of JavaScript to get it to work.
5+
Simple Slider is a jQuery plugin which allows your users to select a value
6+
from a numerical range by simply dragging a slider.
97

8+
## Features
109

11-
How to Use
12-
-----------
10+
- Configurable without editing any JavaScript
11+
- No external dependencies, apart from jQuery
12+
- Compact size, only 4kb
13+
- Unobtrusive JavaScript, activate using `data-slider="true"` on any input
14+
- Easy to skin/style purely in css, no images required
15+
- Slider value goes directly into your input element, for easy use in normal html forms
16+
- Supports both pre-defined values and a continous ranges
17+
- Supports smooth sliding and snap-to-value sliding
18+
- Supports highlighting the slider background when dragging
1319

14-
Include the javascript file in your page:
20+
## Screenshots
1521

16-
<script src="simple-slider.js"></script>
17-
18-
Turn your text input into a slider:
22+
![Default Slider](budget-slider.jpg)
1923

20-
<input type="text" data-slider="true">
24+
The slider's default style, as used to select a budget on [Bugsnag](https://bugsnag.com).
2125

26+
![Volume Slider](volume-slider.jpg)
2227

23-
Documentation, Features and Demos
24-
---------------------------------
25-
Full details and documentation can be found on the project page here:
28+
A slider using the volume style.
2629

27-
<http://loopj.com/jquery-simple-slider/>
30+
## Installation
31+
32+
Include jQuery and the Simple Slider JavaScript and CSS files on your page,
33+
then activate Simple Slider on your text input using the `data-slider` attribute:
34+
35+
```html
36+
<!-- Include jQuery -->
37+
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
38+
39+
<!-- Include Simple Slider JavaScript and CSS -->
40+
<script src="yourfiles/simple-slider.js"></script>
41+
<link href="yourfiles/simple-slider.css" rel="stylesheet" type="text/css" />
42+
43+
<!-- Activate Simple Slider on your input -->
44+
<input type="text" data-slider="true">
45+
```
46+
47+
You can also manually turn any text input into a Simple Slider in JavaScript
48+
as follows:
49+
50+
```javascript
51+
$("#my-input").simpleSlider();
52+
```
53+
54+
## Getting Slider Values
55+
56+
The value the user selects with the slider is immediately available inside the
57+
`value` attribute of the text input you attached the slider to. This means you
58+
can include Simple Slider in your HTML forms and the the selected value will
59+
automatically be send to your server when the form is submitted.
60+
61+
If you would like to get the slider's value using javascript, you can register
62+
for the `slider:changed` event:
63+
64+
```javascript
65+
$("#my-input").bind("slider:changed", function (event, data) {
66+
// The currently selected value of the slider
67+
alert(data.value);
68+
69+
// The value as a ratio of the slider (between 0 and 1)
70+
alert(data.ratio);
71+
});
72+
```
73+
74+
## Configuration
75+
76+
You can configure Simple Slider by either using `data-slider-*` unobtrusive javascript settings, or by passing in a configuration object when initializing the plugin manually.
77+
78+
| Setting | Description | Example |
79+
| ------- | ----------- | ------- |
80+
| `data-slider-range` | The range representing the start and end of the slider. | `data-slider-range="10,1000"` |
81+
| `data-slider-step` | The interval to move when dragging the slider. | `data-slider-step="100"` |
82+
| `data-slider-snap` | Setting this to true makes the slider snap to each step when dragging, otherwise dragging will be continuous. | `data-slider-snap="true"` |
83+
| `data-slider-values` | A pre-defined list of values to allow sliding for. | `data-slider-values="0,100,500,800,2000"` |
84+
| `data-slider-equal-steps` | Setting this to true makes the spacing between each always value equal when used with `data-slider-values`. | `data-slider-equal-steps="true"` |
85+
| `data-slider-theme` | The CSS theme to use when rendering this slider. Setting this value adds a suffix to the CSS class of the slider. | `data-slider-theme="volume"` |
86+
| `data-slider-highlight` | Boolean for if we should highlight the background of the slider as it it dragged. | `data-slider-highlight="true"` |
87+
88+
## Events
89+
90+
You can bind to the following jQuery events using `bind`, for example:
91+
92+
```javascript
93+
$("#my-input").bind("slider:ready", function (event, data) {
94+
alert("Slider is ready to use");
95+
});
96+
```
97+
98+
| Event | Description |
99+
| ----- | ----------- |
100+
| `slider:ready` | Fired when the slider is loaded and attached to your input field. |
101+
| `slider:changed` | Fired when the value of your slider changes. |
102+
103+
All Simple Slider events pass 2 parameters into your function, `event` and
104+
`data`. `event` is a regular jQuery event object. `data` contains the
105+
following properties:
106+
107+
| Property | Description |
108+
| -------- | ----------- |
109+
| `value` | The current value of the slider. |
110+
| `ratio` | How far, as a percentage, the slider is from start to end (0 - 1). |
111+
| `el` | The generated outer HTML element representing the slider. |
112+
113+
## Methods
114+
115+
| Method | Description |
116+
| ------ | ----------- |
117+
| `selector.simpleSlider("setValue", value)` | Sets the value of the slider. |
118+
| `selector.simpleSlider("setRatio", ratio)` | Sets the ratio (see above) of the slider. |
119+
120+
## Reporting Bugs or Feature Requests
121+
122+
Please report any bugs or feature requests on the github issues page for this
123+
project here:
124+
125+
<https://github.com/loopj/jquery-simple-slider/issues>
126+
127+
## License
128+
129+
Simple Slider is released under the MIT license.

budget-slider.jpg

5.44 KB
Loading

volume-slider.jpg

2.38 KB
Loading

0 commit comments

Comments
 (0)