Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit f880900

Browse files
committed
Example optimizations
1 parent 5790026 commit f880900

File tree

1 file changed

+46
-44
lines changed

1 file changed

+46
-44
lines changed

example/index.html

Lines changed: 46 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,23 @@ <h2>Comparison to native element</h2>
4242
<br>
4343

4444
<div>
45-
<h2>Negative example</h2>
45+
<h2>Negative attributes</h2>
4646
<input type="range" min="-20" max="20" data-rangeslider>
4747
<output></output>
4848
</div>
4949

5050
<br>
5151
<br>
5252

53+
<div>
54+
<h2>Floating point boundaries</h2>
55+
<input type="range" min="10" max="11" step="0.1" value="10.2" data-rangeslider>
56+
<output></output>
57+
</div>
58+
59+
<br>
60+
<br>
61+
5362
<div>
5463
<h2><code>value="0"</code></h2>
5564
<input type="range" value="0" data-rangeslider>
@@ -80,15 +89,6 @@ <h2>Programmatic value changes</h2>
8089
<br>
8190
<br>
8291

83-
<div>
84-
<h2>Floating point boundaries</h2>
85-
<input type="range" min="10" max="11" step="0.1" value="10.2" data-rangeslider>
86-
<output></output>
87-
</div>
88-
89-
<br>
90-
<br>
91-
9292
<div id="js-example-destroy">
9393
<h2>Destroy a plugin instance</h2>
9494
<input type="range" min="10" max="1000" step="10" value="500" data-rangeslider>
@@ -100,51 +100,53 @@ <h2>Destroy a plugin instance</h2>
100100
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
101101
<script src="../dist/rangeslider.min.js"></script>
102102
<script>
103-
$(function() {
104-
105-
var $document = $(document),
106-
selector = '[data-rangeslider]',
107-
$input = $(selector);
103+
$(function() {
108104

109-
$document.on('change', 'input[type="range"]', function(e) {
110-
var value = e.target.value,
111-
output = e.target.parentNode.getElementsByTagName('output')[0];
112-
output.innerHTML = value;
113-
});
105+
var $document = $(document),
106+
selector = '[data-rangeslider]',
107+
$input = $(selector);
114108

115-
$input.rangeslider({
116-
117-
// Deactivate the feature detection
118-
polyfill: false,
109+
// Example functionality to demonstrate a value feedback
110+
$document.on('change', 'input[type="range"]', function(e) {
111+
var value = e.target.value,
112+
output = e.target.parentNode.getElementsByTagName('output')[0];
113+
output.innerHTML = value;
114+
});
119115

120-
// Callback function
121-
onInit: function() {},
116+
// Example functionality to demonstrate programmatic value changes
117+
$document.on('click', '#js-example-change-value button', function(e) {
118+
var $inputRange = $('input[type="range"]', e.target.parentNode),
119+
value = $('input[type="number"]', e.target.parentNode)[0].value;
122120

123-
// Callback function
124-
onSlide: function(position, value) {},
121+
$inputRange.val(value).change();
122+
});
125123

126-
// Callback function
127-
onSlideEnd: function(position) {}
124+
// Example functionality to demonstrate destroy functionality
125+
$document
126+
.on('click', '#js-example-destroy button[data-behaviour="destroy"]', function(e) {
127+
$('input[type="range"]', e.target.parentNode).rangeslider('destroy');
128+
})
129+
.on('click', '#js-example-destroy button[data-behaviour="initialize"]', function(e) {
130+
$('input[type="range"]', e.target.parentNode).rangeslider({ polyfill: false });
128131
});
129132

130-
// Example functionality to demonstrate programmatic value changes
131-
$document.on('click', '#js-example-change-value button', function(e) {
132-
var $inputRange = $('input[type="range"]', e.target.parentNode),
133-
value = $('input[type="number"]', e.target.parentNode)[0].value;
133+
// Basic rangeslider initialization
134+
$input.rangeslider({
134135

135-
$inputRange.val(value).change();
136-
});
136+
// Deactivate the feature detection
137+
polyfill: false,
138+
139+
// Callback function
140+
onInit: function() {},
137141

138-
// Example functionality to demonstrate destroy functionality
139-
$document
140-
.on('click', '#js-example-destroy button[data-behaviour="destroy"]', function(e) {
141-
$('input[type="range"]', e.target.parentNode).rangeslider('destroy');
142-
})
143-
.on('click', '#js-example-destroy button[data-behaviour="initialize"]', function(e) {
144-
$('input[type="range"]', e.target.parentNode).rangeslider({ polyfill: false });
145-
});
142+
// Callback function
143+
onSlide: function(position, value) {},
146144

145+
// Callback function
146+
onSlideEnd: function(position) {}
147147
});
148+
149+
});
148150
</script>
149151
</body>
150152
</html>

0 commit comments

Comments
 (0)