forked from olton/Metro-UI-CSS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
slider.php
115 lines (99 loc) · 4.89 KB
/
slider.php
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
<? include("header.php")?>
<div class="page secondary">
<div class="page-header">
<div class="page-header-content">
<h1>Slider<small class="fg-color-red">this component in develop</small></h1>
<a href="/" class="back-button big page-back"></a>
</div>
</div>
<div class="page-region">
<div class="page-region-content">
<div class="grid">
<div class="row">
<div class="span5" style="height: 200px;">
<h2>Horizontal Slider</h2>
<div class="slider" data-param-init-value="0"></div>
<h4>init start value</h4>
<div class="slider" data-param-init-value="35"></div>
<h4>discrete mode (accuracy = 20)</h4>
<div class="slider" data-param-accuracy="20" data-param-init-value="0"></div>
<h4>Event handler</h4>
<div id="slider1" class="slider" data-param-init-value="0"></div>
<p class="tertiary-text">Move marker for see work handler.</p>
<div>
Current value: <span id="slider1_value">0</span>
</div>
<script type="text/javascript">
$(function(){
$("#slider1").on("change", function(e, val){
color = 'green';
if (val > 30) {
color = 'orange';
}
if (val > 70) {
color = 'red';
}
$("#slider1_value").html(val);
$(this).children(".complete").css("background-color", color);
})
})
</script>
</div>
<div class="span5">
<h2>Vertical Slider</h2>
<div class="slider vertical place-left" style="height: 200px;" data-param-accuracy="0" data-param-init-value="30"></div>
<div class="slider vertical place-left" style="height: 200px;" data-param-accuracy="10" data-param-init-value="70"></div>
</div>
</div>
</div>
<div class="span10">
<h3>Component structure</h3>
<pre class="prettyprint linenums">
<div class="slider" data-role="slider">
<div class="complete"></div>
<div class="marker"></div>
</div>
</pre>
<h3>Component definition</h3>
<pre class="prettyprint linenums">
<div class="slider" data-role="slider"></div>
<div class="slider" data-role="slider" data-param-init-value="35"></div>
<div class="slider" data-role="slider" data-param-accuracy="20"></div>
<div class="slider vertical" data-role="slider"></div>
</pre>
<p class="bg-color-red fg-color-white padding5">
For use vertical slider you must set height attribute manually.
</p>
<h3>Params</h3>
<p>
You can set params for slider: <code>data-param-init-value</code> (default: 0) and <code>data-param-accuracy</code> (default: 1). To set discrete mode of slider set accuracy parameter to value different from 1.
</p>
<h3>Events</h3>
<p>
Slider component is supported next events: <code>onchange</code>, <code>onchanged</code>. Event <code>onchange</code> fired while slider position changed. Event <code>onchanged</code> fired when marker stopped.
</p>
<pre class="prettyprint linenums">
$(function(){
$("#slider1").on("change", function(e, val){
// e is event
// val is current value
...
})
$("#slider1").on("changed", function(e, val){
// e is event
// val is current value
...
})
// for retrieve a current value you can call
$("#slider1").data('value');
})
</pre>
<h3>Javascript</h3>
<p>
To use slider component you must include <code>slider.js</code> in head of page.
</p>
</div>
</div>
</div>
</div>
<? include("footer.php")?>