| 21627 |
kshitij.so |
1 |
<!DOCTYPE html>
|
|
|
2 |
<html>
|
|
|
3 |
<head>
|
|
|
4 |
<title>jQuery Knob demo</title>
|
|
|
5 |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
|
|
|
6 |
<script src="js/jquery.knob.js"></script>
|
|
|
7 |
<script src="js/jquery.jqcanvas.js"></script>
|
|
|
8 |
<script>
|
|
|
9 |
$(function() {
|
|
|
10 |
|
|
|
11 |
$(".knob").knob({
|
|
|
12 |
/*change : function (value) {
|
|
|
13 |
//console.log("change : " + value);
|
|
|
14 |
},
|
|
|
15 |
release : function (value) {
|
|
|
16 |
console.log("release : " + value);
|
|
|
17 |
},
|
|
|
18 |
cancel : function () {
|
|
|
19 |
console.log("cancel : " + this.value);
|
|
|
20 |
},*/
|
|
|
21 |
draw : function () {
|
|
|
22 |
|
|
|
23 |
// "tron" case
|
|
|
24 |
if(this.$.data('skin') == 'tron') {
|
|
|
25 |
|
|
|
26 |
var a = this.angle(this.cv) // Angle
|
|
|
27 |
, sa = this.startAngle // Previous start angle
|
|
|
28 |
, sat = this.startAngle // Start angle
|
|
|
29 |
, ea // Previous end angle
|
|
|
30 |
, eat = sat + a // End angle
|
|
|
31 |
, r = 1;
|
|
|
32 |
|
|
|
33 |
this.g.lineWidth = this.lineWidth;
|
|
|
34 |
|
|
|
35 |
this.o.cursor
|
|
|
36 |
&& (sat = eat - 0.3)
|
|
|
37 |
&& (eat = eat + 0.3);
|
|
|
38 |
|
|
|
39 |
if (this.o.displayPrevious) {
|
|
|
40 |
ea = this.startAngle + this.angle(this.v);
|
|
|
41 |
this.o.cursor
|
|
|
42 |
&& (sa = ea - 0.3)
|
|
|
43 |
&& (ea = ea + 0.3);
|
|
|
44 |
this.g.beginPath();
|
|
|
45 |
this.g.strokeStyle = this.pColor;
|
|
|
46 |
this.g.arc(this.xy, this.xy, this.radius - this.lineWidth, sa, ea, false);
|
|
|
47 |
this.g.stroke();
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
this.g.beginPath();
|
|
|
51 |
this.g.strokeStyle = r ? this.o.fgColor : this.fgColor ;
|
|
|
52 |
this.g.arc(this.xy, this.xy, this.radius - this.lineWidth, sat, eat, false);
|
|
|
53 |
this.g.stroke();
|
|
|
54 |
|
|
|
55 |
this.g.lineWidth = 2;
|
|
|
56 |
this.g.beginPath();
|
|
|
57 |
this.g.strokeStyle = this.o.fgColor;
|
|
|
58 |
this.g.arc( this.xy, this.xy, this.radius - this.lineWidth + 1 + this.lineWidth * 2 / 3, 0, 2 * Math.PI, false);
|
|
|
59 |
this.g.stroke();
|
|
|
60 |
|
|
|
61 |
return false;
|
|
|
62 |
}
|
|
|
63 |
}
|
|
|
64 |
});
|
|
|
65 |
|
|
|
66 |
// Example of infinite knob, iPod click wheel
|
|
|
67 |
var v, up=0,down=0,i=0
|
|
|
68 |
,$idir = $("div.idir")
|
|
|
69 |
,$ival = $("div.ival")
|
|
|
70 |
,incr = function() { i++; $idir.show().html("+").fadeOut(); $ival.html(i); }
|
|
|
71 |
,decr = function() { i--; $idir.show().html("-").fadeOut(); $ival.html(i); };
|
|
|
72 |
$("input.infinite").knob(
|
|
|
73 |
{
|
|
|
74 |
min : 0
|
|
|
75 |
, max : 20
|
|
|
76 |
, stopper : false
|
|
|
77 |
, change : function () {
|
|
|
78 |
if(v > this.cv){
|
|
|
79 |
if(up){
|
|
|
80 |
decr();
|
|
|
81 |
up=0;
|
|
|
82 |
}else{up=1;down=0;}
|
|
|
83 |
} else {
|
|
|
84 |
if(v < this.cv){
|
|
|
85 |
if(down){
|
|
|
86 |
incr();
|
|
|
87 |
down=0;
|
|
|
88 |
}else{down=1;up=0;}
|
|
|
89 |
}
|
|
|
90 |
}
|
|
|
91 |
v = this.cv;
|
|
|
92 |
}
|
|
|
93 |
});
|
|
|
94 |
});
|
|
|
95 |
</script>
|
|
|
96 |
<style>
|
|
|
97 |
body{
|
|
|
98 |
padding: 0;
|
|
|
99 |
margin: 0px 50px;
|
|
|
100 |
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
|
|
101 |
font-weight: 300;
|
|
|
102 |
text-rendering: optimizelegibility;
|
|
|
103 |
}
|
|
|
104 |
p{font-size: 30px; line-height: 30px}
|
|
|
105 |
div.demo{text-align: center; width: 280px; float: left}
|
|
|
106 |
div.demo > p{font-size: 20px}
|
|
|
107 |
</style>
|
|
|
108 |
</head>
|
|
|
109 |
<body>
|
|
|
110 |
<div style="width:100%;font-size:40px;letter-spacing:-8px;line-height:40px;">
|
|
|
111 |
<h1>jQuery Knob</h1>
|
|
|
112 |
</div>
|
|
|
113 |
<div>
|
|
|
114 |
<p>Nice, downward compatible, touchable, jQuery dial. <a href="http://flattr.com/thing/674900/jQuery-Knob" target="_blank"><img src="http://api.flattr.com/button/flattr-badge-large.png" alt="Flattr this" title="Flattr this" border="0" /></a></p>
|
|
|
115 |
<p style="font-size: 20px">* implemented interactions : mouse click and wheel mouse, keyboard (on focus) and fingers (touch events)</p>
|
|
|
116 |
</div>
|
|
|
117 |
<div class="demo">
|
|
|
118 |
<p>× Disable display input</p>
|
|
|
119 |
<pre>
|
|
|
120 |
data-width="100"
|
|
|
121 |
data-displayInput=false
|
|
|
122 |
</pre>
|
|
|
123 |
<input class="knob" data-width="100" data-displayInput=false value="35">
|
|
|
124 |
</div>
|
|
|
125 |
<div class="demo">
|
|
|
126 |
<p>× 'cursor' mode</p>
|
|
|
127 |
<pre>
|
|
|
128 |
data-width="150"
|
|
|
129 |
data-cursor=true
|
|
|
130 |
data-thickness=.3
|
|
|
131 |
data-fgColor="#222222"
|
|
|
132 |
</pre>
|
|
|
133 |
<input class="knob" data-width="150" data-cursor=true data-fgColor="#222222" data-thickness=.3 value="29">
|
|
|
134 |
</div>
|
|
|
135 |
<div class="demo" >
|
|
|
136 |
<p>× Display previous value</p>
|
|
|
137 |
<pre>
|
|
|
138 |
data-displayPrevious=true
|
|
|
139 |
data-min="-100"
|
|
|
140 |
</pre>
|
|
|
141 |
<input class="knob" data-width="200" data-min="-100" data-displayPrevious=true value="44">
|
|
|
142 |
</div>
|
|
|
143 |
<div style="clear:both"></div>
|
|
|
144 |
<div class="demo">
|
|
|
145 |
<p>× Angle offset</p>
|
|
|
146 |
<pre>
|
|
|
147 |
data-angleOffset=90
|
|
|
148 |
</pre>
|
|
|
149 |
<input class="knob" data-angleOffset=90 value="35">
|
|
|
150 |
</div>
|
|
|
151 |
<div class="demo">
|
|
|
152 |
<p>× Angle offset and arc</p>
|
|
|
153 |
<pre>
|
|
|
154 |
data-fgColor="#66CC66"
|
|
|
155 |
data-angleOffset=-125
|
|
|
156 |
data-angleArc=250
|
|
|
157 |
</pre>
|
|
|
158 |
<input class="knob" data-angleOffset=-125 data-angleArc=250 data-fgColor="#66EE66" value="35">
|
|
|
159 |
</div>
|
|
|
160 |
<div class="demo" >
|
|
|
161 |
<p>× 5-digit values</p>
|
|
|
162 |
<pre>
|
|
|
163 |
data-min="-15000"
|
|
|
164 |
data-max="15000"
|
|
|
165 |
</pre>
|
|
|
166 |
<input class="knob" data-min="-15000" data-max="15000" value="-11000">
|
|
|
167 |
</div>
|
|
|
168 |
<div style="clear:both"></div>
|
|
|
169 |
<div style="text-align: center">
|
|
|
170 |
<p style="font-size: 20px">× Overloaded 'draw' method</p>
|
|
|
171 |
</div>
|
|
|
172 |
<div style="background-color: #222; height: 340px">
|
|
|
173 |
<div class="demo" style="background-color:#222; color:#FFF;">
|
|
|
174 |
<pre>
|
|
|
175 |
data-width="75"
|
|
|
176 |
data-fgColor="#ffec03"
|
|
|
177 |
data-skin="tron"
|
|
|
178 |
data-thickness=".2"
|
|
|
179 |
data-displayPrevious=true
|
|
|
180 |
</pre>
|
|
|
181 |
<input class="knob" data-width="75" data-displayPrevious=true data-fgColor="#ffec03" data-skin="tron" data-cursor=true value="75" data-thickness=".2">
|
|
|
182 |
</div>
|
|
|
183 |
<div class="demo" style="background-color:#222; color:#FFF;">
|
|
|
184 |
<pre>
|
|
|
185 |
data-width="150"
|
|
|
186 |
data-fgColor="#ffec03"
|
|
|
187 |
data-skin="tron"
|
|
|
188 |
data-thickness=".2"
|
|
|
189 |
data-displayPrevious=true
|
|
|
190 |
</pre>
|
|
|
191 |
<input class="knob" data-width="150" data-displayPrevious=true data-fgColor="#ffec03" data-skin="tron" data-thickness=".2" value="75">
|
|
|
192 |
</div>
|
|
|
193 |
<div class="demo" style="background-color:#222; color:#FFF;">
|
|
|
194 |
<pre>
|
|
|
195 |
data-width="150"
|
|
|
196 |
data-fgColor="#C0ffff"
|
|
|
197 |
data-skin="tron"
|
|
|
198 |
data-thickness=".1"
|
|
|
199 |
data-angleOffset="180"
|
|
|
200 |
</pre>
|
|
|
201 |
<input class="knob" data-width="150" data-angleOffset="180" data-fgColor="#C0ffff" data-skin="tron" data-thickness=".1" value="35">
|
|
|
202 |
</div>
|
|
|
203 |
</div>
|
|
|
204 |
<div style="clear:both"></div>
|
|
|
205 |
<div class="demo">
|
|
|
206 |
<p>× Readonly</p>
|
|
|
207 |
<pre>
|
|
|
208 |
data-thickness=".4"
|
|
|
209 |
data-fgColor="chartreuse"
|
|
|
210 |
data-readOnly=true
|
|
|
211 |
</pre>
|
|
|
212 |
<input class="knob" data-fgColor="chartreuse" data-thickness=".4" data-readOnly=true value="22">
|
|
|
213 |
</div>
|
|
|
214 |
<div class="demo">
|
|
|
215 |
<p>× Dynamic</p>
|
|
|
216 |
<pre>
|
|
|
217 |
data-width="200"
|
|
|
218 |
</pre>
|
|
|
219 |
<input type="button" onclick="$('.knob-dyn').knob();" value="knobify!">
|
|
|
220 |
<input type="text" class="knob-dyn" data-width="200" data-cursor=true value="56">
|
|
|
221 |
<pre>
|
|
|
222 |
data-width="50"
|
|
|
223 |
data-cursor=true
|
|
|
224 |
</pre>
|
|
|
225 |
<input type="button" onclick="$('.knob-dyn2').knob();" value="knobify!">
|
|
|
226 |
<input type="text" class="knob-dyn2" data-width="50" data-thickness=".4" value="56">
|
|
|
227 |
</div>
|
|
|
228 |
<div class="demo" style="height:440px;width:300px">
|
|
|
229 |
<p>× Infinite || iPod click wheel</p>
|
|
|
230 |
<div style="float:left;width:180px;height:320px;padding:20px;background-color:#EEEEEE;text-align:center;">
|
|
|
231 |
<pre>
|
|
|
232 |
data-width="150"
|
|
|
233 |
data-cursor=true
|
|
|
234 |
data-thickness=".5"
|
|
|
235 |
data-fgColor="#AAAAAA"
|
|
|
236 |
data-bgColor="#FFFFFF"
|
|
|
237 |
data-displayInput="false"
|
|
|
238 |
+ some code
|
|
|
239 |
</pre>
|
|
|
240 |
<input class="infinite" data-width="150" data-thickness=".5" data-fgColor="#AAAAAA" data-bgColor="#FFFFFF" data-displayInput="false" data-cursor=true>
|
|
|
241 |
</div>
|
|
|
242 |
<div style="float:left;margin-top:200px;">
|
|
|
243 |
<div class="ival" style="width:80px;text-align:center;font-size:50px;color:#AAA">0</div>
|
|
|
244 |
<div class="idir" style="width:80px;text-align:center;font-size:50px;"></div>
|
|
|
245 |
</div>
|
|
|
246 |
</div>
|
|
|
247 |
<div style="clear:both"></div>
|
|
|
248 |
<div id="big" class="demo" style="height:800px;width:100%">
|
|
|
249 |
<p>× Big !</p>
|
|
|
250 |
<pre>
|
|
|
251 |
data-width="700"
|
|
|
252 |
</pre>
|
|
|
253 |
<input class="knob" data-min="-100" data-max="100" data-width="700" data-height="700" data-thickness=".3" data-cursor=true>
|
|
|
254 |
</div>
|
|
|
255 |
<div style="clear:both"></div>
|
|
|
256 |
<div style="padding:30px; margin-top:30px;">
|
|
|
257 |
<p style="font-size:20px;">jQuery Knob is © 2012 Anthony Terrien and dual licensed under the MIT or GPL licenses.</p>
|
|
|
258 |
</div>
|
|
|
259 |
<div style="border: 0 none; position: absolute; right: 0; top: 0;"><a href="https://github.com/aterrien" target="_blank"><img src="../i/github-ribbon.png" style="border: 0 none;"></a></div>
|
|
|
260 |
<script type="text/javascript">
|
|
|
261 |
var _gaq = _gaq || [];
|
|
|
262 |
_gaq.push(['_setAccount', 'UA-3008949-6']);
|
|
|
263 |
_gaq.push(['_trackPageview']);
|
|
|
264 |
</script>
|
|
|
265 |
<script type="text/javascript">
|
|
|
266 |
(function() {
|
|
|
267 |
var ga = document.createElement('script');
|
|
|
268 |
ga.type = 'text/javascript';
|
|
|
269 |
ga.async = true;
|
|
|
270 |
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
|
|
271 |
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
|
|
|
272 |
})();
|
|
|
273 |
</script>
|
|
|
274 |
</body>
|
|
|
275 |
</html>
|