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
|
<!doctype html>
<html lang="en">
<head>
<title>Slider Visual Test : Slider vertical range with collision</title>
<link rel="stylesheet" href="../visual.css" type="text/css" />
<link rel="stylesheet" href="../../../themes/base/ui.all.css" type="text/css">
<script type="text/javascript" src="../../../jquery-1.3.1.js"></script>
<script type="text/javascript" src="../../../ui/ui.core.js"></script>
<script type="text/javascript" src="../../../ui/ui.slider.js"></script>
<script type="text/javascript">
$(function() {
//this function checks the slider handles and applies classes to make them visually split a value if they're equal
$.fn.checkCollision = function(){
if( $(this).slider('values', 0) == $(this).slider('values', 1) ){
if( $(this).is('.ui-slider-horizontal') ){
$(this).addClass('ui-slider-horizontal-collision');
$('.ui-slider-handle:eq(0)',this).removeClass('ui-corner-all').addClass('ui-corner-left');
$('.ui-slider-handle:eq(1)',this).removeClass('ui-corner-all').addClass('ui-corner-right');
}
else {
$(this).addClass('ui-slider-vertical-collision');
$('.ui-slider-handle:eq(0)',this).removeClass('ui-corner-all').addClass('ui-corner-bottom');
$('.ui-slider-handle:eq(1)',this).removeClass('ui-corner-all').addClass('ui-corner-top');
}
}
else if( $(this).is('.ui-slider-horizontal-collision, .ui-slider-vertical-collision') ) {
if( $(this).is('.ui-slider-horizontal') ){
$(this).removeClass('ui-slider-horizontal-collision');
$('.ui-slider-handle:eq(0)',this).addClass('ui-corner-all').removeClass('ui-corner-left');
$('.ui-slider-handle:eq(1)',this).addClass('ui-corner-all').removeClass('ui-corner-right');
}
else {
$(this).removeClass('ui-slider-vertical-collision');
$('.ui-slider-handle:eq(0)',this).addClass('ui-corner-all').removeClass('ui-corner-bottom');
$('.ui-slider-handle:eq(1)',this).addClass('ui-corner-all').removeClass('ui-corner-top');
}
}
};
$("#slider-vertical-range").slider({
orientation: 'vertical',
range: true,
values: [25, 75],
slide: $(this).checkCollision
})
.checkCollision();
});
</script>
</head>
<body>
<div id="slider-vertical-range"></div>
</body>
</html>
|