pcapr-local 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/LICENSE.txt +20 -0
- data/README.md +64 -0
- data/Rakefile +57 -0
- data/VERSION +1 -0
- data/bin/pcap2par +49 -0
- data/bin/startpcapr +40 -0
- data/bin/stoppcapr +33 -0
- data/bin/xtractr +5 -0
- data/lib/environment.rb +106 -0
- data/lib/exe/xtractr +0 -0
- data/lib/mu/pcap.rb +110 -0
- data/lib/mu/pcap/ethernet.rb +148 -0
- data/lib/mu/pcap/header.rb +75 -0
- data/lib/mu/pcap/io_pair.rb +67 -0
- data/lib/mu/pcap/io_wrapper.rb +76 -0
- data/lib/mu/pcap/ip.rb +61 -0
- data/lib/mu/pcap/ipv4.rb +257 -0
- data/lib/mu/pcap/ipv6.rb +148 -0
- data/lib/mu/pcap/packet.rb +104 -0
- data/lib/mu/pcap/pkthdr.rb +155 -0
- data/lib/mu/pcap/reader.rb +61 -0
- data/lib/mu/pcap/reader/http_family.rb +170 -0
- data/lib/mu/pcap/sctp.rb +367 -0
- data/lib/mu/pcap/sctp/chunk.rb +123 -0
- data/lib/mu/pcap/sctp/chunk/data.rb +134 -0
- data/lib/mu/pcap/sctp/chunk/init.rb +100 -0
- data/lib/mu/pcap/sctp/chunk/init_ack.rb +68 -0
- data/lib/mu/pcap/sctp/parameter.rb +110 -0
- data/lib/mu/pcap/sctp/parameter/ip_address.rb +48 -0
- data/lib/mu/pcap/stream_packetizer.rb +72 -0
- data/lib/mu/pcap/tcp.rb +505 -0
- data/lib/mu/pcap/udp.rb +69 -0
- data/lib/mu/scenario/pcap.rb +164 -0
- data/lib/mu/scenario/pcap/fields.rb +50 -0
- data/lib/mu/scenario/pcap/rtp.rb +71 -0
- data/lib/pcapr_local.rb +159 -0
- data/lib/pcapr_local/config.rb +336 -0
- data/lib/pcapr_local/db.rb +197 -0
- data/lib/pcapr_local/scanner.rb +250 -0
- data/lib/pcapr_local/server.rb +178 -0
- data/lib/pcapr_local/www/favicon.ico +0 -0
- data/lib/pcapr_local/www/favicon.png +0 -0
- data/lib/pcapr_local/www/home/index.html +138 -0
- data/lib/pcapr_local/www/static/image/16x16/Cancel.png +0 -0
- data/lib/pcapr_local/www/static/image/16x16/Cancel.png.1 +0 -0
- data/lib/pcapr_local/www/static/image/16x16/Download.png +0 -0
- data/lib/pcapr_local/www/static/image/16x16/Folder3.png +0 -0
- data/lib/pcapr_local/www/static/image/16x16/Full Size.png +0 -0
- data/lib/pcapr_local/www/static/image/16x16/Minus.png +0 -0
- data/lib/pcapr_local/www/static/image/16x16/Plus.png +0 -0
- data/lib/pcapr_local/www/static/image/16x16/Search.png +0 -0
- data/lib/pcapr_local/www/static/image/16x16/User.png +0 -0
- data/lib/pcapr_local/www/static/image/48x48/Phone.png +0 -0
- data/lib/pcapr_local/www/static/image/48x48/Video.png +0 -0
- data/lib/pcapr_local/www/static/image/bar-orange.gif +0 -0
- data/lib/pcapr_local/www/static/image/beta.png +0 -0
- data/lib/pcapr_local/www/static/image/bg.png +0 -0
- data/lib/pcapr_local/www/static/image/blockquote.png +0 -0
- data/lib/pcapr_local/www/static/image/body-bg.png +0 -0
- data/lib/pcapr_local/www/static/image/body-h3.png +0 -0
- data/lib/pcapr_local/www/static/image/body-hl1-bg.png +0 -0
- data/lib/pcapr_local/www/static/image/body-hl1-h3.png +0 -0
- data/lib/pcapr_local/www/static/image/body-hl1-readmore.png +0 -0
- data/lib/pcapr_local/www/static/image/body-hl2-bg.png +0 -0
- data/lib/pcapr_local/www/static/image/body-hl2-h3.png +0 -0
- data/lib/pcapr_local/www/static/image/body-hl2-readmore.png +0 -0
- data/lib/pcapr_local/www/static/image/body-hl3-bg.png +0 -0
- data/lib/pcapr_local/www/static/image/body-hl3-h3.png +0 -0
- data/lib/pcapr_local/www/static/image/body-hl3-readmore.png +0 -0
- data/lib/pcapr_local/www/static/image/body-hl4-bg.png +0 -0
- data/lib/pcapr_local/www/static/image/body-hl4-h3.png +0 -0
- data/lib/pcapr_local/www/static/image/body-hl4-readmore.png +0 -0
- data/lib/pcapr_local/www/static/image/body-hl5-h3.png +0 -0
- data/lib/pcapr_local/www/static/image/body-hl6-h3.png +0 -0
- data/lib/pcapr_local/www/static/image/body-hl7-h3.png +0 -0
- data/lib/pcapr_local/www/static/image/body-hl8-h3.png +0 -0
- data/lib/pcapr_local/www/static/image/body-readmore.png +0 -0
- data/lib/pcapr_local/www/static/image/bottom-bg.png +0 -0
- data/lib/pcapr_local/www/static/image/bottom-l.png +0 -0
- data/lib/pcapr_local/www/static/image/bottom-r.png +0 -0
- data/lib/pcapr_local/www/static/image/btn-search.png +0 -0
- data/lib/pcapr_local/www/static/image/bullet-1.png +0 -0
- data/lib/pcapr_local/www/static/image/bullet-2.png +0 -0
- data/lib/pcapr_local/www/static/image/bullet-3.png +0 -0
- data/lib/pcapr_local/www/static/image/bullet-4.png +0 -0
- data/lib/pcapr_local/www/static/image/bullet-5.png +0 -0
- data/lib/pcapr_local/www/static/image/bullet-6.png +0 -0
- data/lib/pcapr_local/www/static/image/bullet-7.png +0 -0
- data/lib/pcapr_local/www/static/image/bullet-hl1.png +0 -0
- data/lib/pcapr_local/www/static/image/bullet-hl2.png +0 -0
- data/lib/pcapr_local/www/static/image/bullet-hl3.png +0 -0
- data/lib/pcapr_local/www/static/image/bullet-hl4.png +0 -0
- data/lib/pcapr_local/www/static/image/bullet-pathway.png +0 -0
- data/lib/pcapr_local/www/static/image/bullet-section1.png +0 -0
- data/lib/pcapr_local/www/static/image/bullet-section2.png +0 -0
- data/lib/pcapr_local/www/static/image/collapsed.gif +0 -0
- data/lib/pcapr_local/www/static/image/crosslink.png +0 -0
- data/lib/pcapr_local/www/static/image/expanded.gif +0 -0
- data/lib/pcapr_local/www/static/image/favicon.ico +0 -0
- data/lib/pcapr_local/www/static/image/favicon.png +0 -0
- data/lib/pcapr_local/www/static/image/icon-author.png +0 -0
- data/lib/pcapr_local/www/static/image/icon-created.png +0 -0
- data/lib/pcapr_local/www/static/image/p-expand.gif +0 -0
- data/lib/pcapr_local/www/static/image/pcapr-logo.png +0 -0
- data/lib/pcapr_local/www/static/image/powered-by.png +0 -0
- data/lib/pcapr_local/www/static/image/section1-bg.png +0 -0
- data/lib/pcapr_local/www/static/image/section1-h3.png +0 -0
- data/lib/pcapr_local/www/static/image/section1-readmore.png +0 -0
- data/lib/pcapr_local/www/static/image/section2-bg.png +0 -0
- data/lib/pcapr_local/www/static/image/section2-h3.png +0 -0
- data/lib/pcapr_local/www/static/image/section2-readmore.png +0 -0
- data/lib/pcapr_local/www/static/image/status-alert.png +0 -0
- data/lib/pcapr_local/www/static/image/status-download.png +0 -0
- data/lib/pcapr_local/www/static/image/status-info.png +0 -0
- data/lib/pcapr_local/www/static/image/status-note.png +0 -0
- data/lib/pcapr_local/www/static/image/tab-round.png +0 -0
- data/lib/pcapr_local/www/static/image/throbber.gif +0 -0
- data/lib/pcapr_local/www/static/image/user.jpg +0 -0
- data/lib/pcapr_local/www/static/script/closet/async.js +421 -0
- data/lib/pcapr_local/www/static/script/closet/closet.api.js +241 -0
- data/lib/pcapr_local/www/static/script/closet/closet.folders.js +94 -0
- data/lib/pcapr_local/www/static/script/closet/closet.js +187 -0
- data/lib/pcapr_local/www/static/script/closet/closet.mr.js +219 -0
- data/lib/pcapr_local/www/static/script/closet/closet.options.js +359 -0
- data/lib/pcapr_local/www/static/script/closet/closet.quantity.js +73 -0
- data/lib/pcapr_local/www/static/script/closet/closet.render.js +205 -0
- data/lib/pcapr_local/www/static/script/closet/closet.report.js +86 -0
- data/lib/pcapr_local/www/static/script/closet/closet.reports.http.js +135 -0
- data/lib/pcapr_local/www/static/script/closet/closet.reports.overview.js +163 -0
- data/lib/pcapr_local/www/static/script/closet/closet.reports.sip.js +159 -0
- data/lib/pcapr_local/www/static/script/closet/closet.reports.tcp.js +72 -0
- data/lib/pcapr_local/www/static/script/closet/closet.reports.visualize.js +263 -0
- data/lib/pcapr_local/www/static/script/closet/closet.util.js +40 -0
- data/lib/pcapr_local/www/static/script/jquery/jquery-1.4.2.min.js +154 -0
- data/lib/pcapr_local/www/static/script/jquery/jquery-ui.js +10921 -0
- data/lib/pcapr_local/www/static/script/jquery/jquery.flot.js +2123 -0
- data/lib/pcapr_local/www/static/script/jquery/jquery.flot.selection.js +184 -0
- data/lib/pcapr_local/www/static/script/jquery/jquery.flot.stack.js +184 -0
- data/lib/pcapr_local/www/static/script/jquery/jquery.form.js +643 -0
- data/lib/pcapr_local/www/static/script/jquery/jquery.jsonp.min.js +3 -0
- data/lib/pcapr_local/www/static/script/jquery/jquery.menu.js +142 -0
- data/lib/pcapr_local/www/static/script/jquery/jquery.suggest.js +308 -0
- data/lib/pcapr_local/www/static/script/jquery/jquery.ui.core.js +203 -0
- data/lib/pcapr_local/www/static/script/jquery/jquery.ui.slider.js +629 -0
- data/lib/pcapr_local/www/static/script/jquery/jquery.ui.sortable.js +1055 -0
- data/lib/pcapr_local/www/static/script/jquery/jquery.ui.widget.js +236 -0
- data/lib/pcapr_local/www/static/script/json2.js +481 -0
- data/lib/pcapr_local/www/static/script/sammy/plugins/sammy.cache.js +115 -0
- data/lib/pcapr_local/www/static/script/sammy/plugins/sammy.template.js +117 -0
- data/lib/pcapr_local/www/static/script/sammy/sammy.js +1696 -0
- data/lib/pcapr_local/www/static/script/tipsy/jquery.tipsy.js +104 -0
- data/lib/pcapr_local/www/static/style/c3p0.css +116 -0
- data/lib/pcapr_local/www/static/style/jquery.suggest.css +27 -0
- data/lib/pcapr_local/www/static/style/page.css +1113 -0
- data/lib/pcapr_local/www/static/style/tipsy.css +7 -0
- data/lib/pcapr_local/www/templates/browse.services.template +10 -0
- data/lib/pcapr_local/www/templates/browse.template +77 -0
- data/lib/pcapr_local/www/templates/flows.template +38 -0
- data/lib/pcapr_local/www/templates/pcap.template +63 -0
- data/lib/pcapr_local/www/templates/sip.calls.template +35 -0
- data/lib/pcapr_local/www/templates/statistics.template +6 -0
- data/lib/pcapr_local/xtractr.rb +179 -0
- data/lib/pcapr_local/xtractr/instance.rb +172 -0
- data/pcapr-local.gemspec +297 -0
- data/test/mu/pcap/reader/tc_http_family.rb +251 -0
- data/test/mu/pcap/tc_ethernet.rb +71 -0
- data/test/mu/pcap/tc_header.rb +56 -0
- data/test/mu/pcap/tc_ipv4.rb +103 -0
- data/test/mu/pcap/tc_ipv6.rb +83 -0
- data/test/mu/pcap/tc_packet.rb +44 -0
- data/test/mu/pcap/tc_pair.rb +58 -0
- data/test/mu/pcap/tc_pkthdr.rb +33 -0
- data/test/mu/pcap/tc_reader.rb +76 -0
- data/test/mu/pcap/tc_tcp.rb +426 -0
- data/test/mu/pcap/tc_udp.rb +33 -0
- data/test/mu/pcap/tc_wrapper.rb +80 -0
- data/test/mu/scenario/pcap/tc_fields.rb +67 -0
- data/test/mu/scenario/pcap/tc_rtp.rb +135 -0
- data/test/mu/scenario/sip_signalled_call_1.pcap +0 -0
- data/test/mu/scenario/tc_pcap.rb +190 -0
- data/test/mu/scenario/test_data/arp.pcap +0 -0
- data/test/mu/scenario/test_data/dns.pcap +0 -0
- data/test/mu/scenario/test_data/http-v6.pcap +0 -0
- data/test/mu/scenario/test_data/http.pcap +0 -0
- data/test/mu/scenario/test_data/http_chunked.pcap +0 -0
- data/test/mu/scenario/test_data/http_deflate.pcap +0 -0
- data/test/mu/scenario/test_data/httpauth3.pcap +0 -0
- data/test/mu/scenario/test_data/icmp.pcap +0 -0
- data/test/mu/scenario/test_data/sip_signalled_call_1.pcap +0 -0
- data/test/mu/tc_pcap.rb +39 -0
- data/test/mu/testcase.rb +86 -0
- data/test/pcapr_local/arp.pcap +0 -0
- data/test/pcapr_local/data.js +3 -0
- data/test/pcapr_local/http_chunked.pcap +0 -0
- data/test/pcapr_local/tc_api.rb +181 -0
- data/test/pcapr_local/test.tgz +0 -0
- data/test/pcapr_local/test_scanner.rb +241 -0
- data/test/pcapr_local/test_xtractr.rb +219 -0
- data/test/pcapr_local/testcase.rb +107 -0
- data/test/test_export_to_scenario.sh +25 -0
- data/test/test_pcapr_local.rb +29 -0
- metadata +450 -0
@@ -0,0 +1,203 @@
|
|
1
|
+
/*!
|
2
|
+
* jQuery UI 1.8
|
3
|
+
*
|
4
|
+
* Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
|
5
|
+
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
6
|
+
* and GPL (GPL-LICENSE.txt) licenses.
|
7
|
+
*
|
8
|
+
* http://docs.jquery.com/UI
|
9
|
+
*/
|
10
|
+
;jQuery.ui || (function($) {
|
11
|
+
|
12
|
+
//Helper functions and ui object
|
13
|
+
$.ui = {
|
14
|
+
version: "1.8",
|
15
|
+
|
16
|
+
// $.ui.plugin is deprecated. Use the proxy pattern instead.
|
17
|
+
plugin: {
|
18
|
+
add: function(module, option, set) {
|
19
|
+
var proto = $.ui[module].prototype;
|
20
|
+
for(var i in set) {
|
21
|
+
proto.plugins[i] = proto.plugins[i] || [];
|
22
|
+
proto.plugins[i].push([option, set[i]]);
|
23
|
+
}
|
24
|
+
},
|
25
|
+
call: function(instance, name, args) {
|
26
|
+
var set = instance.plugins[name];
|
27
|
+
if(!set || !instance.element[0].parentNode) { return; }
|
28
|
+
|
29
|
+
for (var i = 0; i < set.length; i++) {
|
30
|
+
if (instance.options[set[i][0]]) {
|
31
|
+
set[i][1].apply(instance.element, args);
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
35
|
+
},
|
36
|
+
|
37
|
+
contains: function(a, b) {
|
38
|
+
return document.compareDocumentPosition
|
39
|
+
? a.compareDocumentPosition(b) & 16
|
40
|
+
: a !== b && a.contains(b);
|
41
|
+
},
|
42
|
+
|
43
|
+
hasScroll: function(el, a) {
|
44
|
+
|
45
|
+
//If overflow is hidden, the element might have extra content, but the user wants to hide it
|
46
|
+
if ($(el).css('overflow') == 'hidden') { return false; }
|
47
|
+
|
48
|
+
var scroll = (a && a == 'left') ? 'scrollLeft' : 'scrollTop',
|
49
|
+
has = false;
|
50
|
+
|
51
|
+
if (el[scroll] > 0) { return true; }
|
52
|
+
|
53
|
+
// TODO: determine which cases actually cause this to happen
|
54
|
+
// if the element doesn't have the scroll set, see if it's possible to
|
55
|
+
// set the scroll
|
56
|
+
el[scroll] = 1;
|
57
|
+
has = (el[scroll] > 0);
|
58
|
+
el[scroll] = 0;
|
59
|
+
return has;
|
60
|
+
},
|
61
|
+
|
62
|
+
isOverAxis: function(x, reference, size) {
|
63
|
+
//Determines when x coordinate is over "b" element axis
|
64
|
+
return (x > reference) && (x < (reference + size));
|
65
|
+
},
|
66
|
+
|
67
|
+
isOver: function(y, x, top, left, height, width) {
|
68
|
+
//Determines when x, y coordinates is over "b" element
|
69
|
+
return $.ui.isOverAxis(y, top, height) && $.ui.isOverAxis(x, left, width);
|
70
|
+
},
|
71
|
+
|
72
|
+
keyCode: {
|
73
|
+
BACKSPACE: 8,
|
74
|
+
CAPS_LOCK: 20,
|
75
|
+
COMMA: 188,
|
76
|
+
CONTROL: 17,
|
77
|
+
DELETE: 46,
|
78
|
+
DOWN: 40,
|
79
|
+
END: 35,
|
80
|
+
ENTER: 13,
|
81
|
+
ESCAPE: 27,
|
82
|
+
HOME: 36,
|
83
|
+
INSERT: 45,
|
84
|
+
LEFT: 37,
|
85
|
+
NUMPAD_ADD: 107,
|
86
|
+
NUMPAD_DECIMAL: 110,
|
87
|
+
NUMPAD_DIVIDE: 111,
|
88
|
+
NUMPAD_ENTER: 108,
|
89
|
+
NUMPAD_MULTIPLY: 106,
|
90
|
+
NUMPAD_SUBTRACT: 109,
|
91
|
+
PAGE_DOWN: 34,
|
92
|
+
PAGE_UP: 33,
|
93
|
+
PERIOD: 190,
|
94
|
+
RIGHT: 39,
|
95
|
+
SHIFT: 16,
|
96
|
+
SPACE: 32,
|
97
|
+
TAB: 9,
|
98
|
+
UP: 38
|
99
|
+
}
|
100
|
+
};
|
101
|
+
|
102
|
+
//jQuery plugins
|
103
|
+
$.fn.extend({
|
104
|
+
_focus: $.fn.focus,
|
105
|
+
focus: function(delay, fn) {
|
106
|
+
return typeof delay === 'number'
|
107
|
+
? this.each(function() {
|
108
|
+
var elem = this;
|
109
|
+
setTimeout(function() {
|
110
|
+
$(elem).focus();
|
111
|
+
(fn && fn.call(elem));
|
112
|
+
}, delay);
|
113
|
+
})
|
114
|
+
: this._focus.apply(this, arguments);
|
115
|
+
},
|
116
|
+
|
117
|
+
enableSelection: function() {
|
118
|
+
return this
|
119
|
+
.attr('unselectable', 'off')
|
120
|
+
.css('MozUserSelect', '')
|
121
|
+
.unbind('selectstart.ui');
|
122
|
+
},
|
123
|
+
|
124
|
+
disableSelection: function() {
|
125
|
+
return this
|
126
|
+
.attr('unselectable', 'on')
|
127
|
+
.css('MozUserSelect', 'none')
|
128
|
+
.bind('selectstart.ui', function() { return false; });
|
129
|
+
},
|
130
|
+
|
131
|
+
scrollParent: function() {
|
132
|
+
var scrollParent;
|
133
|
+
if(($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
|
134
|
+
scrollParent = this.parents().filter(function() {
|
135
|
+
return (/(relative|absolute|fixed)/).test($.curCSS(this,'position',1)) && (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
|
136
|
+
}).eq(0);
|
137
|
+
} else {
|
138
|
+
scrollParent = this.parents().filter(function() {
|
139
|
+
return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
|
140
|
+
}).eq(0);
|
141
|
+
}
|
142
|
+
|
143
|
+
return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent;
|
144
|
+
},
|
145
|
+
|
146
|
+
zIndex: function(zIndex) {
|
147
|
+
if (zIndex !== undefined) {
|
148
|
+
return this.css('zIndex', zIndex);
|
149
|
+
}
|
150
|
+
|
151
|
+
if (this.length) {
|
152
|
+
var elem = $(this[0]), position, value;
|
153
|
+
while (elem.length && elem[0] !== document) {
|
154
|
+
// Ignore z-index if position is set to a value where z-index is ignored by the browser
|
155
|
+
// This makes behavior of this function consistent across browsers
|
156
|
+
// WebKit always returns auto if the element is positioned
|
157
|
+
position = elem.css('position');
|
158
|
+
if (position == 'absolute' || position == 'relative' || position == 'fixed')
|
159
|
+
{
|
160
|
+
// IE returns 0 when zIndex is not specified
|
161
|
+
// other browsers return a string
|
162
|
+
// we ignore the case of nested elements with an explicit value of 0
|
163
|
+
// <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
|
164
|
+
value = parseInt(elem.css('zIndex'));
|
165
|
+
if (!isNaN(value) && value != 0) {
|
166
|
+
return value;
|
167
|
+
}
|
168
|
+
}
|
169
|
+
elem = elem.parent();
|
170
|
+
}
|
171
|
+
}
|
172
|
+
|
173
|
+
return 0;
|
174
|
+
}
|
175
|
+
});
|
176
|
+
|
177
|
+
|
178
|
+
//Additional selectors
|
179
|
+
$.extend($.expr[':'], {
|
180
|
+
data: function(elem, i, match) {
|
181
|
+
return !!$.data(elem, match[3]);
|
182
|
+
},
|
183
|
+
|
184
|
+
focusable: function(element) {
|
185
|
+
var nodeName = element.nodeName.toLowerCase(),
|
186
|
+
tabIndex = $.attr(element, 'tabindex');
|
187
|
+
return (/input|select|textarea|button|object/.test(nodeName)
|
188
|
+
? !element.disabled
|
189
|
+
: 'a' == nodeName || 'area' == nodeName
|
190
|
+
? element.href || !isNaN(tabIndex)
|
191
|
+
: !isNaN(tabIndex))
|
192
|
+
// the element and all of its ancestors must be visible
|
193
|
+
// the browser may report that the area is hidden
|
194
|
+
&& !$(element)['area' == nodeName ? 'parents' : 'closest'](':hidden').length;
|
195
|
+
},
|
196
|
+
|
197
|
+
tabbable: function(element) {
|
198
|
+
var tabIndex = $.attr(element, 'tabindex');
|
199
|
+
return (isNaN(tabIndex) || tabIndex >= 0) && $(element).is(':focusable');
|
200
|
+
}
|
201
|
+
});
|
202
|
+
|
203
|
+
})(jQuery);
|
@@ -0,0 +1,629 @@
|
|
1
|
+
/*
|
2
|
+
* jQuery UI Slider 1.8
|
3
|
+
*
|
4
|
+
* Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
|
5
|
+
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
6
|
+
* and GPL (GPL-LICENSE.txt) licenses.
|
7
|
+
*
|
8
|
+
* http://docs.jquery.com/UI/Slider
|
9
|
+
*
|
10
|
+
* Depends:
|
11
|
+
* jquery.ui.core.js
|
12
|
+
* jquery.ui.mouse.js
|
13
|
+
* jquery.ui.widget.js
|
14
|
+
*/
|
15
|
+
|
16
|
+
(function($) {
|
17
|
+
|
18
|
+
// number of pages in a slider
|
19
|
+
// (how many times can you page up/down to go through the whole range)
|
20
|
+
var numPages = 5;
|
21
|
+
|
22
|
+
$.widget("ui.slider", $.ui.mouse, {
|
23
|
+
widgetEventPrefix: "slide",
|
24
|
+
options: {
|
25
|
+
animate: false,
|
26
|
+
distance: 0,
|
27
|
+
max: 100,
|
28
|
+
min: 0,
|
29
|
+
orientation: 'horizontal',
|
30
|
+
range: false,
|
31
|
+
step: 1,
|
32
|
+
value: 0,
|
33
|
+
values: null
|
34
|
+
},
|
35
|
+
_create: function() {
|
36
|
+
|
37
|
+
var self = this, o = this.options;
|
38
|
+
this._keySliding = false;
|
39
|
+
this._mouseSliding = false;
|
40
|
+
this._animateOff = true;
|
41
|
+
this._handleIndex = null;
|
42
|
+
this._detectOrientation();
|
43
|
+
this._mouseInit();
|
44
|
+
|
45
|
+
this.element
|
46
|
+
.addClass("ui-slider"
|
47
|
+
+ " ui-slider-" + this.orientation
|
48
|
+
+ " ui-widget"
|
49
|
+
+ " ui-widget-content"
|
50
|
+
+ " ui-corner-all");
|
51
|
+
|
52
|
+
if (o.disabled) {
|
53
|
+
this.element.addClass('ui-slider-disabled ui-disabled');
|
54
|
+
}
|
55
|
+
|
56
|
+
this.range = $([]);
|
57
|
+
|
58
|
+
if (o.range) {
|
59
|
+
|
60
|
+
if (o.range === true) {
|
61
|
+
this.range = $('<div></div>');
|
62
|
+
if (!o.values) o.values = [this._valueMin(), this._valueMin()];
|
63
|
+
if (o.values.length && o.values.length != 2) {
|
64
|
+
o.values = [o.values[0], o.values[0]];
|
65
|
+
}
|
66
|
+
} else {
|
67
|
+
this.range = $('<div></div>');
|
68
|
+
}
|
69
|
+
|
70
|
+
this.range
|
71
|
+
.appendTo(this.element)
|
72
|
+
.addClass("ui-slider-range");
|
73
|
+
|
74
|
+
if (o.range == "min" || o.range == "max") {
|
75
|
+
this.range.addClass("ui-slider-range-" + o.range);
|
76
|
+
}
|
77
|
+
|
78
|
+
// note: this isn't the most fittingly semantic framework class for this element,
|
79
|
+
// but worked best visually with a variety of themes
|
80
|
+
this.range.addClass("ui-widget-header");
|
81
|
+
|
82
|
+
}
|
83
|
+
|
84
|
+
if ($(".ui-slider-handle", this.element).length == 0)
|
85
|
+
$('<a href="#"></a>')
|
86
|
+
.appendTo(this.element)
|
87
|
+
.addClass("ui-slider-handle");
|
88
|
+
|
89
|
+
if (o.values && o.values.length) {
|
90
|
+
while ($(".ui-slider-handle", this.element).length < o.values.length)
|
91
|
+
$('<a href="#"></a>')
|
92
|
+
.appendTo(this.element)
|
93
|
+
.addClass("ui-slider-handle");
|
94
|
+
}
|
95
|
+
|
96
|
+
this.handles = $(".ui-slider-handle", this.element)
|
97
|
+
.addClass("ui-state-default"
|
98
|
+
+ " ui-corner-all");
|
99
|
+
|
100
|
+
this.handle = this.handles.eq(0);
|
101
|
+
|
102
|
+
this.handles.add(this.range).filter("a")
|
103
|
+
.click(function(event) {
|
104
|
+
event.preventDefault();
|
105
|
+
})
|
106
|
+
.hover(function() {
|
107
|
+
if (!o.disabled) {
|
108
|
+
$(this).addClass('ui-state-hover');
|
109
|
+
}
|
110
|
+
}, function() {
|
111
|
+
$(this).removeClass('ui-state-hover');
|
112
|
+
})
|
113
|
+
.focus(function() {
|
114
|
+
if (!o.disabled) {
|
115
|
+
$(".ui-slider .ui-state-focus").removeClass('ui-state-focus'); $(this).addClass('ui-state-focus');
|
116
|
+
} else {
|
117
|
+
$(this).blur();
|
118
|
+
}
|
119
|
+
})
|
120
|
+
.blur(function() {
|
121
|
+
$(this).removeClass('ui-state-focus');
|
122
|
+
});
|
123
|
+
|
124
|
+
this.handles.each(function(i) {
|
125
|
+
$(this).data("index.ui-slider-handle", i);
|
126
|
+
});
|
127
|
+
|
128
|
+
this.handles.keydown(function(event) {
|
129
|
+
|
130
|
+
var ret = true;
|
131
|
+
|
132
|
+
var index = $(this).data("index.ui-slider-handle");
|
133
|
+
|
134
|
+
if (self.options.disabled)
|
135
|
+
return;
|
136
|
+
|
137
|
+
switch (event.keyCode) {
|
138
|
+
case $.ui.keyCode.HOME:
|
139
|
+
case $.ui.keyCode.END:
|
140
|
+
case $.ui.keyCode.PAGE_UP:
|
141
|
+
case $.ui.keyCode.PAGE_DOWN:
|
142
|
+
case $.ui.keyCode.UP:
|
143
|
+
case $.ui.keyCode.RIGHT:
|
144
|
+
case $.ui.keyCode.DOWN:
|
145
|
+
case $.ui.keyCode.LEFT:
|
146
|
+
ret = false;
|
147
|
+
if (!self._keySliding) {
|
148
|
+
self._keySliding = true;
|
149
|
+
$(this).addClass("ui-state-active");
|
150
|
+
self._start(event, index);
|
151
|
+
}
|
152
|
+
break;
|
153
|
+
}
|
154
|
+
|
155
|
+
var curVal, newVal, step = self._step();
|
156
|
+
if (self.options.values && self.options.values.length) {
|
157
|
+
curVal = newVal = self.values(index);
|
158
|
+
} else {
|
159
|
+
curVal = newVal = self.value();
|
160
|
+
}
|
161
|
+
|
162
|
+
switch (event.keyCode) {
|
163
|
+
case $.ui.keyCode.HOME:
|
164
|
+
newVal = self._valueMin();
|
165
|
+
break;
|
166
|
+
case $.ui.keyCode.END:
|
167
|
+
newVal = self._valueMax();
|
168
|
+
break;
|
169
|
+
case $.ui.keyCode.PAGE_UP:
|
170
|
+
newVal = curVal + ((self._valueMax() - self._valueMin()) / numPages);
|
171
|
+
break;
|
172
|
+
case $.ui.keyCode.PAGE_DOWN:
|
173
|
+
newVal = curVal - ((self._valueMax() - self._valueMin()) / numPages);
|
174
|
+
break;
|
175
|
+
case $.ui.keyCode.UP:
|
176
|
+
case $.ui.keyCode.RIGHT:
|
177
|
+
if(curVal == self._valueMax()) return;
|
178
|
+
newVal = curVal + step;
|
179
|
+
break;
|
180
|
+
case $.ui.keyCode.DOWN:
|
181
|
+
case $.ui.keyCode.LEFT:
|
182
|
+
if(curVal == self._valueMin()) return;
|
183
|
+
newVal = curVal - step;
|
184
|
+
break;
|
185
|
+
}
|
186
|
+
|
187
|
+
self._slide(event, index, newVal);
|
188
|
+
|
189
|
+
return ret;
|
190
|
+
|
191
|
+
}).keyup(function(event) {
|
192
|
+
|
193
|
+
var index = $(this).data("index.ui-slider-handle");
|
194
|
+
|
195
|
+
if (self._keySliding) {
|
196
|
+
self._keySliding = false;
|
197
|
+
self._stop(event, index);
|
198
|
+
self._change(event, index);
|
199
|
+
$(this).removeClass("ui-state-active");
|
200
|
+
}
|
201
|
+
|
202
|
+
});
|
203
|
+
|
204
|
+
this._refreshValue();
|
205
|
+
|
206
|
+
this._animateOff = false;
|
207
|
+
|
208
|
+
},
|
209
|
+
|
210
|
+
destroy: function() {
|
211
|
+
|
212
|
+
this.handles.remove();
|
213
|
+
this.range.remove();
|
214
|
+
|
215
|
+
this.element
|
216
|
+
.removeClass("ui-slider"
|
217
|
+
+ " ui-slider-horizontal"
|
218
|
+
+ " ui-slider-vertical"
|
219
|
+
+ " ui-slider-disabled"
|
220
|
+
+ " ui-widget"
|
221
|
+
+ " ui-widget-content"
|
222
|
+
+ " ui-corner-all")
|
223
|
+
.removeData("slider")
|
224
|
+
.unbind(".slider");
|
225
|
+
|
226
|
+
this._mouseDestroy();
|
227
|
+
|
228
|
+
return this;
|
229
|
+
},
|
230
|
+
|
231
|
+
_mouseCapture: function(event) {
|
232
|
+
|
233
|
+
var o = this.options;
|
234
|
+
|
235
|
+
if (o.disabled)
|
236
|
+
return false;
|
237
|
+
|
238
|
+
this.elementSize = {
|
239
|
+
width: this.element.outerWidth(),
|
240
|
+
height: this.element.outerHeight()
|
241
|
+
};
|
242
|
+
this.elementOffset = this.element.offset();
|
243
|
+
|
244
|
+
var position = { x: event.pageX, y: event.pageY };
|
245
|
+
var normValue = this._normValueFromMouse(position);
|
246
|
+
|
247
|
+
var distance = this._valueMax() - this._valueMin() + 1, closestHandle;
|
248
|
+
var self = this, index;
|
249
|
+
this.handles.each(function(i) {
|
250
|
+
var thisDistance = Math.abs(normValue - self.values(i));
|
251
|
+
if (distance > thisDistance) {
|
252
|
+
distance = thisDistance;
|
253
|
+
closestHandle = $(this);
|
254
|
+
index = i;
|
255
|
+
}
|
256
|
+
});
|
257
|
+
|
258
|
+
// workaround for bug #3736 (if both handles of a range are at 0,
|
259
|
+
// the first is always used as the one with least distance,
|
260
|
+
// and moving it is obviously prevented by preventing negative ranges)
|
261
|
+
if(o.range == true && this.values(1) == o.min) {
|
262
|
+
closestHandle = $(this.handles[++index]);
|
263
|
+
}
|
264
|
+
|
265
|
+
this._start(event, index);
|
266
|
+
this._mouseSliding = true;
|
267
|
+
|
268
|
+
self._handleIndex = index;
|
269
|
+
|
270
|
+
closestHandle
|
271
|
+
.addClass("ui-state-active")
|
272
|
+
.focus();
|
273
|
+
|
274
|
+
var offset = closestHandle.offset();
|
275
|
+
var mouseOverHandle = !$(event.target).parents().andSelf().is('.ui-slider-handle');
|
276
|
+
this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
|
277
|
+
left: event.pageX - offset.left - (closestHandle.width() / 2),
|
278
|
+
top: event.pageY - offset.top
|
279
|
+
- (closestHandle.height() / 2)
|
280
|
+
- (parseInt(closestHandle.css('borderTopWidth'),10) || 0)
|
281
|
+
- (parseInt(closestHandle.css('borderBottomWidth'),10) || 0)
|
282
|
+
+ (parseInt(closestHandle.css('marginTop'),10) || 0)
|
283
|
+
};
|
284
|
+
|
285
|
+
normValue = this._normValueFromMouse(position);
|
286
|
+
this._slide(event, index, normValue);
|
287
|
+
this._animateOff = true;
|
288
|
+
return true;
|
289
|
+
|
290
|
+
},
|
291
|
+
|
292
|
+
_mouseStart: function(event) {
|
293
|
+
return true;
|
294
|
+
},
|
295
|
+
|
296
|
+
_mouseDrag: function(event) {
|
297
|
+
|
298
|
+
var position = { x: event.pageX, y: event.pageY };
|
299
|
+
var normValue = this._normValueFromMouse(position);
|
300
|
+
|
301
|
+
this._slide(event, this._handleIndex, normValue);
|
302
|
+
|
303
|
+
return false;
|
304
|
+
|
305
|
+
},
|
306
|
+
|
307
|
+
_mouseStop: function(event) {
|
308
|
+
|
309
|
+
this.handles.removeClass("ui-state-active");
|
310
|
+
this._mouseSliding = false;
|
311
|
+
this._stop(event, this._handleIndex);
|
312
|
+
this._change(event, this._handleIndex);
|
313
|
+
this._handleIndex = null;
|
314
|
+
this._clickOffset = null;
|
315
|
+
|
316
|
+
this._animateOff = false;
|
317
|
+
return false;
|
318
|
+
|
319
|
+
},
|
320
|
+
|
321
|
+
_detectOrientation: function() {
|
322
|
+
this.orientation = this.options.orientation == 'vertical' ? 'vertical' : 'horizontal';
|
323
|
+
},
|
324
|
+
|
325
|
+
_normValueFromMouse: function(position) {
|
326
|
+
|
327
|
+
var pixelTotal, pixelMouse;
|
328
|
+
if ('horizontal' == this.orientation) {
|
329
|
+
pixelTotal = this.elementSize.width;
|
330
|
+
pixelMouse = position.x - this.elementOffset.left - (this._clickOffset ? this._clickOffset.left : 0);
|
331
|
+
} else {
|
332
|
+
pixelTotal = this.elementSize.height;
|
333
|
+
pixelMouse = position.y - this.elementOffset.top - (this._clickOffset ? this._clickOffset.top : 0);
|
334
|
+
}
|
335
|
+
|
336
|
+
var percentMouse = (pixelMouse / pixelTotal);
|
337
|
+
if (percentMouse > 1) percentMouse = 1;
|
338
|
+
if (percentMouse < 0) percentMouse = 0;
|
339
|
+
if ('vertical' == this.orientation)
|
340
|
+
percentMouse = 1 - percentMouse;
|
341
|
+
|
342
|
+
var valueTotal = this._valueMax() - this._valueMin(),
|
343
|
+
valueMouse = percentMouse * valueTotal,
|
344
|
+
valueMouseModStep = valueMouse % this.options.step,
|
345
|
+
normValue = this._valueMin() + valueMouse - valueMouseModStep;
|
346
|
+
|
347
|
+
if (valueMouseModStep > (this.options.step / 2))
|
348
|
+
normValue += this.options.step;
|
349
|
+
|
350
|
+
// Since JavaScript has problems with large floats, round
|
351
|
+
// the final value to 5 digits after the decimal point (see #4124)
|
352
|
+
return parseFloat(normValue.toFixed(5));
|
353
|
+
|
354
|
+
},
|
355
|
+
|
356
|
+
_start: function(event, index) {
|
357
|
+
var uiHash = {
|
358
|
+
handle: this.handles[index],
|
359
|
+
value: this.value()
|
360
|
+
};
|
361
|
+
if (this.options.values && this.options.values.length) {
|
362
|
+
uiHash.value = this.values(index);
|
363
|
+
uiHash.values = this.values();
|
364
|
+
}
|
365
|
+
this._trigger("start", event, uiHash);
|
366
|
+
},
|
367
|
+
|
368
|
+
_slide: function(event, index, newVal) {
|
369
|
+
|
370
|
+
var handle = this.handles[index];
|
371
|
+
|
372
|
+
if (this.options.values && this.options.values.length) {
|
373
|
+
|
374
|
+
var otherVal = this.values(index ? 0 : 1);
|
375
|
+
|
376
|
+
if ((this.options.values.length == 2 && this.options.range === true) &&
|
377
|
+
((index == 0 && newVal > otherVal) || (index == 1 && newVal < otherVal))){
|
378
|
+
newVal = otherVal;
|
379
|
+
}
|
380
|
+
|
381
|
+
if (newVal != this.values(index)) {
|
382
|
+
var newValues = this.values();
|
383
|
+
newValues[index] = newVal;
|
384
|
+
// A slide can be canceled by returning false from the slide callback
|
385
|
+
var allowed = this._trigger("slide", event, {
|
386
|
+
handle: this.handles[index],
|
387
|
+
value: newVal,
|
388
|
+
values: newValues
|
389
|
+
});
|
390
|
+
var otherVal = this.values(index ? 0 : 1);
|
391
|
+
if (allowed !== false) {
|
392
|
+
this.values(index, newVal, true);
|
393
|
+
}
|
394
|
+
}
|
395
|
+
|
396
|
+
} else {
|
397
|
+
|
398
|
+
if (newVal != this.value()) {
|
399
|
+
// A slide can be canceled by returning false from the slide callback
|
400
|
+
var allowed = this._trigger("slide", event, {
|
401
|
+
handle: this.handles[index],
|
402
|
+
value: newVal
|
403
|
+
});
|
404
|
+
if (allowed !== false) {
|
405
|
+
this.value(newVal);
|
406
|
+
}
|
407
|
+
|
408
|
+
}
|
409
|
+
|
410
|
+
}
|
411
|
+
|
412
|
+
},
|
413
|
+
|
414
|
+
_stop: function(event, index) {
|
415
|
+
var uiHash = {
|
416
|
+
handle: this.handles[index],
|
417
|
+
value: this.value()
|
418
|
+
};
|
419
|
+
if (this.options.values && this.options.values.length) {
|
420
|
+
uiHash.value = this.values(index);
|
421
|
+
uiHash.values = this.values();
|
422
|
+
}
|
423
|
+
this._trigger("stop", event, uiHash);
|
424
|
+
},
|
425
|
+
|
426
|
+
_change: function(event, index) {
|
427
|
+
if (!this._keySliding && !this._mouseSliding) {
|
428
|
+
var uiHash = {
|
429
|
+
handle: this.handles[index],
|
430
|
+
value: this.value()
|
431
|
+
};
|
432
|
+
if (this.options.values && this.options.values.length) {
|
433
|
+
uiHash.value = this.values(index);
|
434
|
+
uiHash.values = this.values();
|
435
|
+
}
|
436
|
+
this._trigger("change", event, uiHash);
|
437
|
+
}
|
438
|
+
},
|
439
|
+
|
440
|
+
value: function(newValue) {
|
441
|
+
|
442
|
+
if (arguments.length) {
|
443
|
+
this.options.value = this._trimValue(newValue);
|
444
|
+
this._refreshValue();
|
445
|
+
this._change(null, 0);
|
446
|
+
}
|
447
|
+
|
448
|
+
return this._value();
|
449
|
+
|
450
|
+
},
|
451
|
+
|
452
|
+
values: function(index, newValue) {
|
453
|
+
|
454
|
+
if (arguments.length > 1) {
|
455
|
+
this.options.values[index] = this._trimValue(newValue);
|
456
|
+
this._refreshValue();
|
457
|
+
this._change(null, index);
|
458
|
+
}
|
459
|
+
|
460
|
+
if (arguments.length) {
|
461
|
+
if ($.isArray(arguments[0])) {
|
462
|
+
var vals = this.options.values, newValues = arguments[0];
|
463
|
+
for (var i = 0, l = vals.length; i < l; i++) {
|
464
|
+
vals[i] = this._trimValue(newValues[i]);
|
465
|
+
this._change(null, i);
|
466
|
+
}
|
467
|
+
this._refreshValue();
|
468
|
+
} else {
|
469
|
+
if (this.options.values && this.options.values.length) {
|
470
|
+
return this._values(index);
|
471
|
+
} else {
|
472
|
+
return this.value();
|
473
|
+
}
|
474
|
+
}
|
475
|
+
} else {
|
476
|
+
return this._values();
|
477
|
+
}
|
478
|
+
|
479
|
+
},
|
480
|
+
|
481
|
+
_setOption: function(key, value) {
|
482
|
+
|
483
|
+
var i,
|
484
|
+
valsLength = 0;
|
485
|
+
if ( jQuery.isArray(this.options.values) ) {
|
486
|
+
valsLength = this.options.values.length;
|
487
|
+
};
|
488
|
+
|
489
|
+
$.Widget.prototype._setOption.apply(this, arguments);
|
490
|
+
|
491
|
+
switch (key) {
|
492
|
+
case 'disabled':
|
493
|
+
if (value) {
|
494
|
+
this.handles.filter(".ui-state-focus").blur();
|
495
|
+
this.handles.removeClass("ui-state-hover");
|
496
|
+
this.handles.attr("disabled", "disabled");
|
497
|
+
this.element.addClass("ui-disabled");
|
498
|
+
} else {
|
499
|
+
this.handles.removeAttr("disabled");
|
500
|
+
this.element.removeClass("ui-disabled");
|
501
|
+
}
|
502
|
+
case 'orientation':
|
503
|
+
|
504
|
+
this._detectOrientation();
|
505
|
+
|
506
|
+
this.element
|
507
|
+
.removeClass("ui-slider-horizontal ui-slider-vertical")
|
508
|
+
.addClass("ui-slider-" + this.orientation);
|
509
|
+
this._refreshValue();
|
510
|
+
break;
|
511
|
+
case 'value':
|
512
|
+
this._animateOff = true;
|
513
|
+
this._refreshValue();
|
514
|
+
this._change(null, 0);
|
515
|
+
this._animateOff = false;
|
516
|
+
break;
|
517
|
+
case 'values':
|
518
|
+
this._animateOff = true;
|
519
|
+
this._refreshValue();
|
520
|
+
for (i = 0; i < valsLength; i++) {
|
521
|
+
this._change(null, i);
|
522
|
+
}
|
523
|
+
this._animateOff = false;
|
524
|
+
break;
|
525
|
+
}
|
526
|
+
|
527
|
+
},
|
528
|
+
|
529
|
+
_step: function() {
|
530
|
+
var step = this.options.step;
|
531
|
+
return step;
|
532
|
+
},
|
533
|
+
|
534
|
+
_value: function() {
|
535
|
+
//internal value getter
|
536
|
+
// _value() returns value trimmed by min and max
|
537
|
+
var val = this.options.value;
|
538
|
+
val = this._trimValue(val);
|
539
|
+
|
540
|
+
return val;
|
541
|
+
},
|
542
|
+
|
543
|
+
_values: function(index) {
|
544
|
+
//internal values getter
|
545
|
+
// _values() returns array of values trimmed by min and max
|
546
|
+
// _values(index) returns single value trimmed by min and max
|
547
|
+
|
548
|
+
if (arguments.length) {
|
549
|
+
var val = this.options.values[index];
|
550
|
+
val = this._trimValue(val);
|
551
|
+
|
552
|
+
return val;
|
553
|
+
} else {
|
554
|
+
// .slice() creates a copy of the array
|
555
|
+
// this copy gets trimmed by min and max and then returned
|
556
|
+
var vals = this.options.values.slice();
|
557
|
+
for (var i = 0, l = vals.length; i < l; i++) {
|
558
|
+
vals[i] = this._trimValue(vals[i]);
|
559
|
+
}
|
560
|
+
|
561
|
+
return vals;
|
562
|
+
}
|
563
|
+
|
564
|
+
},
|
565
|
+
|
566
|
+
_trimValue: function(val) {
|
567
|
+
if (val < this._valueMin()) val = this._valueMin();
|
568
|
+
if (val > this._valueMax()) val = this._valueMax();
|
569
|
+
|
570
|
+
return val;
|
571
|
+
},
|
572
|
+
|
573
|
+
_valueMin: function() {
|
574
|
+
var valueMin = this.options.min;
|
575
|
+
return valueMin;
|
576
|
+
},
|
577
|
+
|
578
|
+
_valueMax: function() {
|
579
|
+
var valueMax = this.options.max;
|
580
|
+
return valueMax;
|
581
|
+
},
|
582
|
+
|
583
|
+
_refreshValue: function() {
|
584
|
+
|
585
|
+
var oRange = this.options.range, o = this.options, self = this;
|
586
|
+
var animate = (!this._animateOff) ? o.animate : false;
|
587
|
+
|
588
|
+
if (this.options.values && this.options.values.length) {
|
589
|
+
var vp0, vp1;
|
590
|
+
this.handles.each(function(i, j) {
|
591
|
+
var valPercent = (self.values(i) - self._valueMin()) / (self._valueMax() - self._valueMin()) * 100;
|
592
|
+
var _set = {}; _set[self.orientation == 'horizontal' ? 'left' : 'bottom'] = valPercent + '%';
|
593
|
+
$(this).stop(1,1)[animate ? 'animate' : 'css'](_set, o.animate);
|
594
|
+
if (self.options.range === true) {
|
595
|
+
if (self.orientation == 'horizontal') {
|
596
|
+
(i == 0) && self.range.stop(1,1)[animate ? 'animate' : 'css']({ left: valPercent + '%' }, o.animate);
|
597
|
+
(i == 1) && self.range[animate ? 'animate' : 'css']({ width: (valPercent - lastValPercent) + '%' }, { queue: false, duration: o.animate });
|
598
|
+
} else {
|
599
|
+
(i == 0) && self.range.stop(1,1)[animate ? 'animate' : 'css']({ bottom: (valPercent) + '%' }, o.animate);
|
600
|
+
(i == 1) && self.range[animate ? 'animate' : 'css']({ height: (valPercent - lastValPercent) + '%' }, { queue: false, duration: o.animate });
|
601
|
+
}
|
602
|
+
}
|
603
|
+
lastValPercent = valPercent;
|
604
|
+
});
|
605
|
+
} else {
|
606
|
+
var value = this.value(),
|
607
|
+
valueMin = this._valueMin(),
|
608
|
+
valueMax = this._valueMax(),
|
609
|
+
valPercent = valueMax != valueMin
|
610
|
+
? (value - valueMin) / (valueMax - valueMin) * 100
|
611
|
+
: 0;
|
612
|
+
var _set = {}; _set[self.orientation == 'horizontal' ? 'left' : 'bottom'] = valPercent + '%';
|
613
|
+
this.handle.stop(1,1)[animate ? 'animate' : 'css'](_set, o.animate);
|
614
|
+
|
615
|
+
(oRange == "min") && (this.orientation == "horizontal") && this.range.stop(1,1)[animate ? 'animate' : 'css']({ width: valPercent + '%' }, o.animate);
|
616
|
+
(oRange == "max") && (this.orientation == "horizontal") && this.range[animate ? 'animate' : 'css']({ width: (100 - valPercent) + '%' }, { queue: false, duration: o.animate });
|
617
|
+
(oRange == "min") && (this.orientation == "vertical") && this.range.stop(1,1)[animate ? 'animate' : 'css']({ height: valPercent + '%' }, o.animate);
|
618
|
+
(oRange == "max") && (this.orientation == "vertical") && this.range[animate ? 'animate' : 'css']({ height: (100 - valPercent) + '%' }, { queue: false, duration: o.animate });
|
619
|
+
}
|
620
|
+
|
621
|
+
}
|
622
|
+
|
623
|
+
});
|
624
|
+
|
625
|
+
$.extend($.ui.slider, {
|
626
|
+
version: "1.8"
|
627
|
+
});
|
628
|
+
|
629
|
+
})(jQuery);
|