14
if ((typeof jQuery === 'undefined' || !jQuery) && typeof define === "function" && define.amd) {
15
define(["jquery"], function (jQuery) {
16
return factory(jQuery, document, window, navigator);
18
} else if ((typeof jQuery === 'undefined' || !jQuery) && typeof exports === "object") {
19
factory(require("jquery"), document, window, navigator);
21
factory(jQuery, document, window, navigator);
23
} (function ($, document, window, navigator, undefined) {
32
var is_old_ie = (function () {
33
var n = navigator.userAgent,
36
if (n.search(r) > 0) {
37
v = r.exec(n).toString();
40
$("html").addClass("lt-ie9");
46
if (!Function.prototype.bind) {
47
Function.prototype.bind = function bind(that) {
52
if (typeof target != "function") {
53
throw new TypeError();
56
var args = slice.call(arguments, 1),
59
if (this instanceof bound) {
62
F.prototype = target.prototype;
65
var result = target.apply(
67
args.concat(slice.call(arguments))
69
if (Object(result) === result) {
78
args.concat(slice.call(arguments))
88
if (!Array.prototype.indexOf) {
89
Array.prototype.indexOf = function(searchElement, fromIndex) {
92
throw new TypeError('"this" is null or not defined');
95
var len = O.length >>> 0;
99
var n = +fromIndex || 0;
100
if (Math.abs(n) === Infinity) {
106
k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
108
if (k in O && O[k] === searchElement) {
123
'<span class="irs">' +
124
'<span class="irs-line" tabindex="0"></span>' +
125
'<span class="irs-min">0</span><span class="irs-max">1</span>' +
126
'<span class="irs-from">0</span><span class="irs-to">0</span><span class="irs-single">0</span>' +
128
'<span class="irs-grid"></span>';
131
'<span class="irs-bar irs-bar--single"></span>' +
132
'<span class="irs-shadow shadow-single"></span>' +
133
'<span class="irs-handle single"><i></i><i></i><i></i></span>';
136
'<span class="irs-bar"></span>' +
137
'<span class="irs-shadow shadow-from"></span>' +
138
'<span class="irs-shadow shadow-to"></span>' +
139
'<span class="irs-handle from"><i></i><i></i><i></i></span>' +
140
'<span class="irs-handle to"><i></i><i></i><i></i></span>';
143
'<span class="irs-disable-mask"></span>';
158
var IonRangeSlider = function (input, options, plugin_count) {
159
this.VERSION = "2.3.1";
161
this.plugin_count = plugin_count;
162
this.current_plugin = 0;
167
this.old_min_interval = null;
169
this.dragging = false;
170
this.force_redraw = false;
171
this.no_diapason = false;
172
this.has_tab_index = true;
174
this.is_update = false;
175
this.is_start = true;
176
this.is_finish = false;
177
this.is_active = false;
178
this.is_resize = false;
179
this.is_click = false;
181
options = options || {};
186
body: $(document.body),
269
var $inp = this.$cache.input,
270
val = $inp.prop("value"),
271
config, config_from_data, prop;
286
drag_interval: false,
301
prettify_enabled: true,
302
prettify_separator: " ",
321
values_separator: " — ",
323
input_values_separator: ";",
339
if ($inp[0].nodeName !== "INPUT") {
340
console && console.warn && console.warn("Base element should be <input>!", $inp[0]);
346
skin: $inp.data("skin"),
347
type: $inp.data("type"),
349
min: $inp.data("min"),
350
max: $inp.data("max"),
351
from: $inp.data("from"),
353
step: $inp.data("step"),
355
min_interval: $inp.data("minInterval"),
356
max_interval: $inp.data("maxInterval"),
357
drag_interval: $inp.data("dragInterval"),
359
values: $inp.data("values"),
361
from_fixed: $inp.data("fromFixed"),
362
from_min: $inp.data("fromMin"),
363
from_max: $inp.data("fromMax"),
364
from_shadow: $inp.data("fromShadow"),
366
to_fixed: $inp.data("toFixed"),
367
to_min: $inp.data("toMin"),
368
to_max: $inp.data("toMax"),
369
to_shadow: $inp.data("toShadow"),
371
prettify_enabled: $inp.data("prettifyEnabled"),
372
prettify_separator: $inp.data("prettifySeparator"),
374
force_edges: $inp.data("forceEdges"),
376
keyboard: $inp.data("keyboard"),
378
grid: $inp.data("grid"),
379
grid_margin: $inp.data("gridMargin"),
380
grid_num: $inp.data("gridNum"),
381
grid_snap: $inp.data("gridSnap"),
383
hide_min_max: $inp.data("hideMinMax"),
384
hide_from_to: $inp.data("hideFromTo"),
386
prefix: $inp.data("prefix"),
387
postfix: $inp.data("postfix"),
388
max_postfix: $inp.data("maxPostfix"),
389
decorate_both: $inp.data("decorateBoth"),
390
values_separator: $inp.data("valuesSeparator"),
392
input_values_separator: $inp.data("inputValuesSeparator"),
394
disable: $inp.data("disable"),
395
block: $inp.data("block"),
397
extra_classes: $inp.data("extraClasses"),
399
config_from_data.values = config_from_data.values && config_from_data.values.split(",");
401
for (prop in config_from_data) {
402
if (config_from_data.hasOwnProperty(prop)) {
403
if (config_from_data[prop] === undefined || config_from_data[prop] === "") {
404
delete config_from_data[prop];
411
if (val !== undefined && val !== "") {
412
val = val.split(config_from_data.input_values_separator || options.input_values_separator || ";");
414
if (val[0] && val[0] == +val[0]) {
417
if (val[1] && val[1] == +val[1]) {
421
if (options && options.values && options.values.length) {
422
config.from = val[0] && options.values.indexOf(val[0]);
423
config.to = val[1] && options.values.indexOf(val[1]);
425
config.from = val[0] && +val[0];
426
config.to = val[1] && +val[1];
433
$.extend(config, options);
437
$.extend(config, config_from_data);
438
this.options = config;
443
this.update_check = {};
450
input: this.$cache.input,
453
min: this.options.min,
454
max: this.options.max,
456
from: this.options.from,
470
IonRangeSlider.prototype = {
477
init: function (is_update) {
478
this.no_diapason = false;
479
this.coords.p_step = this.convertToPercent(this.options.step, true);
481
this.target = "base";
488
this.force_redraw = true;
494
this.force_redraw = true;
507
append: function () {
508
var container_html = '<span class="irs irs--' + this.options.skin + ' js-irs-' + this.plugin_count + ' ' + this.options.extra_classes + '"></span>';
509
this.$cache.input.before(container_html);
510
this.$cache.input.prop("readonly", true);
511
this.$cache.cont = this.$cache.input.prev();
512
this.result.slider = this.$cache.cont;
514
this.$cache.cont.html(base_html);
515
this.$cache.rs = this.$cache.cont.find(".irs");
516
this.$cache.min = this.$cache.cont.find(".irs-min");
517
this.$cache.max = this.$cache.cont.find(".irs-max");
518
this.$cache.from = this.$cache.cont.find(".irs-from");
519
this.$cache.to = this.$cache.cont.find(".irs-to");
520
this.$cache.single = this.$cache.cont.find(".irs-single");
521
this.$cache.line = this.$cache.cont.find(".irs-line");
522
this.$cache.grid = this.$cache.cont.find(".irs-grid");
524
if (this.options.type === "single") {
525
this.$cache.cont.append(single_html);
526
this.$cache.bar = this.$cache.cont.find(".irs-bar");
527
this.$cache.edge = this.$cache.cont.find(".irs-bar-edge");
528
this.$cache.s_single = this.$cache.cont.find(".single");
529
this.$cache.from[0].style.visibility = "hidden";
530
this.$cache.to[0].style.visibility = "hidden";
531
this.$cache.shad_single = this.$cache.cont.find(".shadow-single");
533
this.$cache.cont.append(double_html);
534
this.$cache.bar = this.$cache.cont.find(".irs-bar");
535
this.$cache.s_from = this.$cache.cont.find(".from");
536
this.$cache.s_to = this.$cache.cont.find(".to");
537
this.$cache.shad_from = this.$cache.cont.find(".shadow-from");
538
this.$cache.shad_to = this.$cache.cont.find(".shadow-to");
540
this.setTopHandler();
543
if (this.options.hide_from_to) {
544
this.$cache.from[0].style.display = "none";
545
this.$cache.to[0].style.display = "none";
546
this.$cache.single[0].style.display = "none";
551
if (this.options.disable) {
552
this.appendDisableMask();
553
this.$cache.input[0].disabled = true;
555
this.$cache.input[0].disabled = false;
556
this.removeDisableMask();
561
if (!this.options.disable) {
562
if (this.options.block) {
563
this.appendDisableMask();
565
this.removeDisableMask();
569
if (this.options.drag_interval) {
570
this.$cache.bar[0].style.cursor = "ew-resize";
578
setTopHandler: function () {
579
var min = this.options.min,
580
max = this.options.max,
581
from = this.options.from,
582
to = this.options.to;
584
if (from > min && to === max) {
585
this.$cache.s_from.addClass("type_last");
586
} else if (to < max) {
587
this.$cache.s_to.addClass("type_last");
597
changeLevel: function (target) {
600
this.coords.p_gap = this.toFixed(this.coords.p_pointer - this.coords.p_single_fake);
601
this.$cache.s_single.addClass("state_hover");
604
this.coords.p_gap = this.toFixed(this.coords.p_pointer - this.coords.p_from_fake);
605
this.$cache.s_from.addClass("state_hover");
606
this.$cache.s_from.addClass("type_last");
607
this.$cache.s_to.removeClass("type_last");
610
this.coords.p_gap = this.toFixed(this.coords.p_pointer - this.coords.p_to_fake);
611
this.$cache.s_to.addClass("state_hover");
612
this.$cache.s_to.addClass("type_last");
613
this.$cache.s_from.removeClass("type_last");
616
this.coords.p_gap_left = this.toFixed(this.coords.p_pointer - this.coords.p_from_fake);
617
this.coords.p_gap_right = this.toFixed(this.coords.p_to_fake - this.coords.p_pointer);
618
this.$cache.s_to.removeClass("type_last");
619
this.$cache.s_from.removeClass("type_last");
628
appendDisableMask: function () {
629
this.$cache.cont.append(disable_html);
630
this.$cache.cont.addClass("irs-disabled");
637
removeDisableMask: function () {
638
this.$cache.cont.remove(".irs-disable-mask");
639
this.$cache.cont.removeClass("irs-disabled");
646
remove: function () {
647
this.$cache.cont.remove();
648
this.$cache.cont = null;
650
this.$cache.line.off("keydown.irs_" + this.plugin_count);
652
this.$cache.body.off("touchmove.irs_" + this.plugin_count);
653
this.$cache.body.off("mousemove.irs_" + this.plugin_count);
655
this.$cache.win.off("touchend.irs_" + this.plugin_count);
656
this.$cache.win.off("mouseup.irs_" + this.plugin_count);
659
this.$cache.body.off("mouseup.irs_" + this.plugin_count);
660
this.$cache.body.off("mouseleave.irs_" + this.plugin_count);
663
this.$cache.grid_labels = [];
664
this.coords.big = [];
665
this.coords.big_w = [];
666
this.coords.big_p = [];
667
this.coords.big_x = [];
669
cancelAnimationFrame(this.raf_id);
675
bindEvents: function () {
676
if (this.no_diapason) {
680
this.$cache.body.on("touchmove.irs_" + this.plugin_count, this.pointerMove.bind(this));
681
this.$cache.body.on("mousemove.irs_" + this.plugin_count, this.pointerMove.bind(this));
683
this.$cache.win.on("touchend.irs_" + this.plugin_count, this.pointerUp.bind(this));
684
this.$cache.win.on("mouseup.irs_" + this.plugin_count, this.pointerUp.bind(this));
686
this.$cache.line.on("touchstart.irs_" + this.plugin_count, this.pointerClick.bind(this, "click"));
687
this.$cache.line.on("mousedown.irs_" + this.plugin_count, this.pointerClick.bind(this, "click"));
689
this.$cache.line.on("focus.irs_" + this.plugin_count, this.pointerFocus.bind(this));
691
if (this.options.drag_interval && this.options.type === "double") {
692
this.$cache.bar.on("touchstart.irs_" + this.plugin_count, this.pointerDown.bind(this, "both"));
693
this.$cache.bar.on("mousedown.irs_" + this.plugin_count, this.pointerDown.bind(this, "both"));
695
this.$cache.bar.on("touchstart.irs_" + this.plugin_count, this.pointerClick.bind(this, "click"));
696
this.$cache.bar.on("mousedown.irs_" + this.plugin_count, this.pointerClick.bind(this, "click"));
699
if (this.options.type === "single") {
700
this.$cache.single.on("touchstart.irs_" + this.plugin_count, this.pointerDown.bind(this, "single"));
701
this.$cache.s_single.on("touchstart.irs_" + this.plugin_count, this.pointerDown.bind(this, "single"));
702
this.$cache.shad_single.on("touchstart.irs_" + this.plugin_count, this.pointerClick.bind(this, "click"));
704
this.$cache.single.on("mousedown.irs_" + this.plugin_count, this.pointerDown.bind(this, "single"));
705
this.$cache.s_single.on("mousedown.irs_" + this.plugin_count, this.pointerDown.bind(this, "single"));
706
this.$cache.edge.on("mousedown.irs_" + this.plugin_count, this.pointerClick.bind(this, "click"));
707
this.$cache.shad_single.on("mousedown.irs_" + this.plugin_count, this.pointerClick.bind(this, "click"));
709
this.$cache.single.on("touchstart.irs_" + this.plugin_count, this.pointerDown.bind(this, null));
710
this.$cache.single.on("mousedown.irs_" + this.plugin_count, this.pointerDown.bind(this, null));
712
this.$cache.from.on("touchstart.irs_" + this.plugin_count, this.pointerDown.bind(this, "from"));
713
this.$cache.s_from.on("touchstart.irs_" + this.plugin_count, this.pointerDown.bind(this, "from"));
714
this.$cache.to.on("touchstart.irs_" + this.plugin_count, this.pointerDown.bind(this, "to"));
715
this.$cache.s_to.on("touchstart.irs_" + this.plugin_count, this.pointerDown.bind(this, "to"));
716
this.$cache.shad_from.on("touchstart.irs_" + this.plugin_count, this.pointerClick.bind(this, "click"));
717
this.$cache.shad_to.on("touchstart.irs_" + this.plugin_count, this.pointerClick.bind(this, "click"));
719
this.$cache.from.on("mousedown.irs_" + this.plugin_count, this.pointerDown.bind(this, "from"));
720
this.$cache.s_from.on("mousedown.irs_" + this.plugin_count, this.pointerDown.bind(this, "from"));
721
this.$cache.to.on("mousedown.irs_" + this.plugin_count, this.pointerDown.bind(this, "to"));
722
this.$cache.s_to.on("mousedown.irs_" + this.plugin_count, this.pointerDown.bind(this, "to"));
723
this.$cache.shad_from.on("mousedown.irs_" + this.plugin_count, this.pointerClick.bind(this, "click"));
724
this.$cache.shad_to.on("mousedown.irs_" + this.plugin_count, this.pointerClick.bind(this, "click"));
727
if (this.options.keyboard) {
728
this.$cache.line.on("keydown.irs_" + this.plugin_count, this.key.bind(this, "keyboard"));
732
this.$cache.body.on("mouseup.irs_" + this.plugin_count, this.pointerUp.bind(this));
733
this.$cache.body.on("mouseleave.irs_" + this.plugin_count, this.pointerUp.bind(this));
742
pointerFocus: function (e) {
747
if (this.options.type === "single") {
748
$handle = this.$cache.single;
750
$handle = this.$cache.from;
753
x = $handle.offset().left;
754
x += ($handle.width() / 2) - 1;
756
this.pointerClick("single", {preventDefault: function () {}, pageX: x});
766
pointerMove: function (e) {
767
if (!this.dragging) {
771
var x = e.pageX || e.originalEvent.touches && e.originalEvent.touches[0].pageX;
772
this.coords.x_pointer = x - this.coords.x_gap;
783
pointerUp: function (e) {
784
if (this.current_plugin !== this.plugin_count) {
788
if (this.is_active) {
789
this.is_active = false;
794
this.$cache.cont.find(".state_hover").removeClass("state_hover");
796
this.force_redraw = true;
799
$("*").prop("unselectable", false);
803
this.restoreOriginalMinInterval();
806
if ($.contains(this.$cache.cont[0], e.target) || this.dragging) {
810
this.dragging = false;
820
pointerDown: function (target, e) {
822
var x = e.pageX || e.originalEvent.touches && e.originalEvent.touches[0].pageX;
823
if (e.button === 2) {
827
if (target === "both") {
828
this.setTempMinInterval();
832
target = this.target || "from";
835
this.current_plugin = this.plugin_count;
836
this.target = target;
838
this.is_active = true;
839
this.dragging = true;
841
this.coords.x_gap = this.$cache.rs.offset().left;
842
this.coords.x_pointer = x - this.coords.x_gap;
844
this.calcPointerPercent();
845
this.changeLevel(target);
848
$("*").prop("unselectable", true);
851
this.$cache.line.trigger("focus");
863
pointerClick: function (target, e) {
865
var x = e.pageX || e.originalEvent.touches && e.originalEvent.touches[0].pageX;
866
if (e.button === 2) {
870
this.current_plugin = this.plugin_count;
871
this.target = target;
873
this.is_click = true;
874
this.coords.x_gap = this.$cache.rs.offset().left;
875
this.coords.x_pointer = +(x - this.coords.x_gap).toFixed();
877
this.force_redraw = true;
880
this.$cache.line.trigger("focus");
890
key: function (target, e) {
891
if (this.current_plugin !== this.plugin_count || e.altKey || e.ctrlKey || e.shiftKey || e.metaKey) {
901
this.moveByKey(false);
909
this.moveByKey(true);
921
moveByKey: function (right) {
922
var p = this.coords.p_pointer;
923
var p_step = (this.options.max - this.options.min) / 100;
924
p_step = this.options.step / p_step;
932
this.coords.x_pointer = this.toFixed(this.coords.w_rs / 100 * p);
941
setMinMax: function () {
946
if (this.options.hide_min_max) {
947
this.$cache.min[0].style.display = "none";
948
this.$cache.max[0].style.display = "none";
952
if (this.options.values.length) {
953
this.$cache.min.html(this.decorate(this.options.p_values[this.options.min]));
954
this.$cache.max.html(this.decorate(this.options.p_values[this.options.max]));
956
var min_pretty = this._prettify(this.options.min);
957
var max_pretty = this._prettify(this.options.max);
959
this.result.min_pretty = min_pretty;
960
this.result.max_pretty = max_pretty;
962
this.$cache.min.html(this.decorate(min_pretty, this.options.min));
963
this.$cache.max.html(this.decorate(max_pretty, this.options.max));
966
this.labels.w_min = this.$cache.min.outerWidth(false);
967
this.labels.w_max = this.$cache.max.outerWidth(false);
974
setTempMinInterval: function () {
975
var interval = this.result.to - this.result.from;
977
if (this.old_min_interval === null) {
978
this.old_min_interval = this.options.min_interval;
981
this.options.min_interval = interval;
987
restoreOriginalMinInterval: function () {
988
if (this.old_min_interval !== null) {
989
this.options.min_interval = this.old_min_interval;
990
this.old_min_interval = null;
1004
calc: function (update) {
1005
if (!this.options) {
1011
if (this.calc_count === 10 || update) {
1012
this.calc_count = 0;
1013
this.coords.w_rs = this.$cache.rs.outerWidth(false);
1015
this.calcHandlePercent();
1018
if (!this.coords.w_rs) {
1022
this.calcPointerPercent();
1023
var handle_x = this.getHandleX();
1026
if (this.target === "both") {
1027
this.coords.p_gap = 0;
1028
handle_x = this.getHandleX();
1031
if (this.target === "click") {
1032
this.coords.p_gap = this.coords.p_handle / 2;
1033
handle_x = this.getHandleX();
1035
if (this.options.drag_interval) {
1036
this.target = "both_one";
1038
this.target = this.chooseHandle(handle_x);
1042
switch (this.target) {
1044
var w = (this.options.max - this.options.min) / 100,
1045
f = (this.result.from - this.options.min) / w,
1046
t = (this.result.to - this.options.min) / w;
1048
this.coords.p_single_real = this.toFixed(f);
1049
this.coords.p_from_real = this.toFixed(f);
1050
this.coords.p_to_real = this.toFixed(t);
1052
this.coords.p_single_real = this.checkDiapason(this.coords.p_single_real, this.options.from_min, this.options.from_max);
1053
this.coords.p_from_real = this.checkDiapason(this.coords.p_from_real, this.options.from_min, this.options.from_max);
1054
this.coords.p_to_real = this.checkDiapason(this.coords.p_to_real, this.options.to_min, this.options.to_max);
1056
this.coords.p_single_fake = this.convertToFakePercent(this.coords.p_single_real);
1057
this.coords.p_from_fake = this.convertToFakePercent(this.coords.p_from_real);
1058
this.coords.p_to_fake = this.convertToFakePercent(this.coords.p_to_real);
1065
if (this.options.from_fixed) {
1069
this.coords.p_single_real = this.convertToRealPercent(handle_x);
1070
this.coords.p_single_real = this.calcWithStep(this.coords.p_single_real);
1071
this.coords.p_single_real = this.checkDiapason(this.coords.p_single_real, this.options.from_min, this.options.from_max);
1073
this.coords.p_single_fake = this.convertToFakePercent(this.coords.p_single_real);
1078
if (this.options.from_fixed) {
1082
this.coords.p_from_real = this.convertToRealPercent(handle_x);
1083
this.coords.p_from_real = this.calcWithStep(this.coords.p_from_real);
1084
if (this.coords.p_from_real > this.coords.p_to_real) {
1085
this.coords.p_from_real = this.coords.p_to_real;
1087
this.coords.p_from_real = this.checkDiapason(this.coords.p_from_real, this.options.from_min, this.options.from_max);
1088
this.coords.p_from_real = this.checkMinInterval(this.coords.p_from_real, this.coords.p_to_real, "from");
1089
this.coords.p_from_real = this.checkMaxInterval(this.coords.p_from_real, this.coords.p_to_real, "from");
1091
this.coords.p_from_fake = this.convertToFakePercent(this.coords.p_from_real);
1096
if (this.options.to_fixed) {
1100
this.coords.p_to_real = this.convertToRealPercent(handle_x);
1101
this.coords.p_to_real = this.calcWithStep(this.coords.p_to_real);
1102
if (this.coords.p_to_real < this.coords.p_from_real) {
1103
this.coords.p_to_real = this.coords.p_from_real;
1105
this.coords.p_to_real = this.checkDiapason(this.coords.p_to_real, this.options.to_min, this.options.to_max);
1106
this.coords.p_to_real = this.checkMinInterval(this.coords.p_to_real, this.coords.p_from_real, "to");
1107
this.coords.p_to_real = this.checkMaxInterval(this.coords.p_to_real, this.coords.p_from_real, "to");
1109
this.coords.p_to_fake = this.convertToFakePercent(this.coords.p_to_real);
1114
if (this.options.from_fixed || this.options.to_fixed) {
1118
handle_x = this.toFixed(handle_x + (this.coords.p_handle * 0.001));
1120
this.coords.p_from_real = this.convertToRealPercent(handle_x) - this.coords.p_gap_left;
1121
this.coords.p_from_real = this.calcWithStep(this.coords.p_from_real);
1122
this.coords.p_from_real = this.checkDiapason(this.coords.p_from_real, this.options.from_min, this.options.from_max);
1123
this.coords.p_from_real = this.checkMinInterval(this.coords.p_from_real, this.coords.p_to_real, "from");
1124
this.coords.p_from_fake = this.convertToFakePercent(this.coords.p_from_real);
1126
this.coords.p_to_real = this.convertToRealPercent(handle_x) + this.coords.p_gap_right;
1127
this.coords.p_to_real = this.calcWithStep(this.coords.p_to_real);
1128
this.coords.p_to_real = this.checkDiapason(this.coords.p_to_real, this.options.to_min, this.options.to_max);
1129
this.coords.p_to_real = this.checkMinInterval(this.coords.p_to_real, this.coords.p_from_real, "to");
1130
this.coords.p_to_fake = this.convertToFakePercent(this.coords.p_to_real);
1135
if (this.options.from_fixed || this.options.to_fixed) {
1139
var real_x = this.convertToRealPercent(handle_x),
1140
from = this.result.from_percent,
1141
to = this.result.to_percent,
1144
new_from = real_x - half,
1145
new_to = real_x + half;
1149
new_to = new_from + full;
1154
new_from = new_to - full;
1157
this.coords.p_from_real = this.calcWithStep(new_from);
1158
this.coords.p_from_real = this.checkDiapason(this.coords.p_from_real, this.options.from_min, this.options.from_max);
1159
this.coords.p_from_fake = this.convertToFakePercent(this.coords.p_from_real);
1161
this.coords.p_to_real = this.calcWithStep(new_to);
1162
this.coords.p_to_real = this.checkDiapason(this.coords.p_to_real, this.options.to_min, this.options.to_max);
1163
this.coords.p_to_fake = this.convertToFakePercent(this.coords.p_to_real);
1168
if (this.options.type === "single") {
1169
this.coords.p_bar_x = (this.coords.p_handle / 2);
1170
this.coords.p_bar_w = this.coords.p_single_fake;
1172
this.result.from_percent = this.coords.p_single_real;
1173
this.result.from = this.convertToValue(this.coords.p_single_real);
1174
this.result.from_pretty = this._prettify(this.result.from);
1176
if (this.options.values.length) {
1177
this.result.from_value = this.options.values[this.result.from];
1180
this.coords.p_bar_x = this.toFixed(this.coords.p_from_fake + (this.coords.p_handle / 2));
1181
this.coords.p_bar_w = this.toFixed(this.coords.p_to_fake - this.coords.p_from_fake);
1183
this.result.from_percent = this.coords.p_from_real;
1184
this.result.from = this.convertToValue(this.coords.p_from_real);
1185
this.result.from_pretty = this._prettify(this.result.from);
1186
this.result.to_percent = this.coords.p_to_real;
1187
this.result.to = this.convertToValue(this.coords.p_to_real);
1188
this.result.to_pretty = this._prettify(this.result.to);
1190
if (this.options.values.length) {
1191
this.result.from_value = this.options.values[this.result.from];
1192
this.result.to_value = this.options.values[this.result.to];
1204
calcPointerPercent: function () {
1205
if (!this.coords.w_rs) {
1206
this.coords.p_pointer = 0;
1210
if (this.coords.x_pointer < 0 || isNaN(this.coords.x_pointer) ) {
1211
this.coords.x_pointer = 0;
1212
} else if (this.coords.x_pointer > this.coords.w_rs) {
1213
this.coords.x_pointer = this.coords.w_rs;
1216
this.coords.p_pointer = this.toFixed(this.coords.x_pointer / this.coords.w_rs * 100);
1219
convertToRealPercent: function (fake) {
1220
var full = 100 - this.coords.p_handle;
1221
return fake / full * 100;
1224
convertToFakePercent: function (real) {
1225
var full = 100 - this.coords.p_handle;
1226
return real / 100 * full;
1229
getHandleX: function () {
1230
var max = 100 - this.coords.p_handle,
1231
x = this.toFixed(this.coords.p_pointer - this.coords.p_gap);
1235
} else if (x > max) {
1242
calcHandlePercent: function () {
1243
if (this.options.type === "single") {
1244
this.coords.w_handle = this.$cache.s_single.outerWidth(false);
1246
this.coords.w_handle = this.$cache.s_from.outerWidth(false);
1249
this.coords.p_handle = this.toFixed(this.coords.w_handle / this.coords.w_rs * 100);
1258
chooseHandle: function (real_x) {
1259
if (this.options.type === "single") {
1262
var m_point = this.coords.p_from_real + ((this.coords.p_to_real - this.coords.p_from_real) / 2);
1263
if (real_x >= m_point) {
1264
return this.options.to_fixed ? "from" : "to";
1266
return this.options.from_fixed ? "to" : "from";
1274
calcMinMax: function () {
1275
if (!this.coords.w_rs) {
1279
this.labels.p_min = this.labels.w_min / this.coords.w_rs * 100;
1280
this.labels.p_max = this.labels.w_max / this.coords.w_rs * 100;
1286
calcLabels: function () {
1287
if (!this.coords.w_rs || this.options.hide_from_to) {
1291
if (this.options.type === "single") {
1293
this.labels.w_single = this.$cache.single.outerWidth(false);
1294
this.labels.p_single_fake = this.labels.w_single / this.coords.w_rs * 100;
1295
this.labels.p_single_left = this.coords.p_single_fake + (this.coords.p_handle / 2) - (this.labels.p_single_fake / 2);
1296
this.labels.p_single_left = this.checkEdges(this.labels.p_single_left, this.labels.p_single_fake);
1300
this.labels.w_from = this.$cache.from.outerWidth(false);
1301
this.labels.p_from_fake = this.labels.w_from / this.coords.w_rs * 100;
1302
this.labels.p_from_left = this.coords.p_from_fake + (this.coords.p_handle / 2) - (this.labels.p_from_fake / 2);
1303
this.labels.p_from_left = this.toFixed(this.labels.p_from_left);
1304
this.labels.p_from_left = this.checkEdges(this.labels.p_from_left, this.labels.p_from_fake);
1306
this.labels.w_to = this.$cache.to.outerWidth(false);
1307
this.labels.p_to_fake = this.labels.w_to / this.coords.w_rs * 100;
1308
this.labels.p_to_left = this.coords.p_to_fake + (this.coords.p_handle / 2) - (this.labels.p_to_fake / 2);
1309
this.labels.p_to_left = this.toFixed(this.labels.p_to_left);
1310
this.labels.p_to_left = this.checkEdges(this.labels.p_to_left, this.labels.p_to_fake);
1312
this.labels.w_single = this.$cache.single.outerWidth(false);
1313
this.labels.p_single_fake = this.labels.w_single / this.coords.w_rs * 100;
1314
this.labels.p_single_left = ((this.labels.p_from_left + this.labels.p_to_left + this.labels.p_to_fake) / 2) - (this.labels.p_single_fake / 2);
1315
this.labels.p_single_left = this.toFixed(this.labels.p_single_left);
1316
this.labels.p_single_left = this.checkEdges(this.labels.p_single_left, this.labels.p_single_fake);
1330
updateScene: function () {
1332
cancelAnimationFrame(this.raf_id);
1336
clearTimeout(this.update_tm);
1337
this.update_tm = null;
1339
if (!this.options) {
1345
if (this.is_active) {
1346
this.raf_id = requestAnimationFrame(this.updateScene.bind(this));
1348
this.update_tm = setTimeout(this.updateScene.bind(this), 300);
1355
drawHandles: function () {
1356
this.coords.w_rs = this.$cache.rs.outerWidth(false);
1358
if (!this.coords.w_rs) {
1362
if (this.coords.w_rs !== this.coords.w_rs_old) {
1363
this.target = "base";
1364
this.is_resize = true;
1367
if (this.coords.w_rs !== this.coords.w_rs_old || this.force_redraw) {
1371
if (this.options.grid) {
1372
this.calcGridMargin();
1373
this.calcGridLabels();
1375
this.force_redraw = true;
1376
this.coords.w_rs_old = this.coords.w_rs;
1380
if (!this.coords.w_rs) {
1384
if (!this.dragging && !this.force_redraw && !this.is_key) {
1388
if (this.old_from !== this.result.from || this.old_to !== this.result.to || this.force_redraw || this.is_key) {
1392
this.$cache.bar[0].style.left = this.coords.p_bar_x + "%";
1393
this.$cache.bar[0].style.width = this.coords.p_bar_w + "%";
1395
if (this.options.type === "single") {
1396
this.$cache.bar[0].style.left = 0;
1397
this.$cache.bar[0].style.width = this.coords.p_bar_w + this.coords.p_bar_x + "%";
1399
this.$cache.s_single[0].style.left = this.coords.p_single_fake + "%";
1401
this.$cache.single[0].style.left = this.labels.p_single_left + "%";
1403
this.$cache.s_from[0].style.left = this.coords.p_from_fake + "%";
1404
this.$cache.s_to[0].style.left = this.coords.p_to_fake + "%";
1406
if (this.old_from !== this.result.from || this.force_redraw) {
1407
this.$cache.from[0].style.left = this.labels.p_from_left + "%";
1409
if (this.old_to !== this.result.to || this.force_redraw) {
1410
this.$cache.to[0].style.left = this.labels.p_to_left + "%";
1413
this.$cache.single[0].style.left = this.labels.p_single_left + "%";
1416
this.writeToInput();
1418
if ((this.old_from !== this.result.from || this.old_to !== this.result.to) && !this.is_start) {
1419
this.$cache.input.trigger("change");
1420
this.$cache.input.trigger("input");
1423
this.old_from = this.result.from;
1424
this.old_to = this.result.to;
1427
if (!this.is_resize && !this.is_update && !this.is_start && !this.is_finish) {
1428
this.callOnChange();
1430
if (this.is_key || this.is_click) {
1431
this.is_key = false;
1432
this.is_click = false;
1433
this.callOnFinish();
1436
this.is_update = false;
1437
this.is_resize = false;
1438
this.is_finish = false;
1441
this.is_start = false;
1442
this.is_key = false;
1443
this.is_click = false;
1444
this.force_redraw = false;
1452
drawLabels: function () {
1453
if (!this.options) {
1457
var values_num = this.options.values.length;
1458
var p_values = this.options.p_values;
1465
if (this.options.hide_from_to) {
1469
if (this.options.type === "single") {
1472
text_single = this.decorate(p_values[this.result.from]);
1473
this.$cache.single.html(text_single);
1475
from_pretty = this._prettify(this.result.from);
1477
text_single = this.decorate(from_pretty, this.result.from);
1478
this.$cache.single.html(text_single);
1483
if (this.labels.p_single_left < this.labels.p_min + 1) {
1484
this.$cache.min[0].style.visibility = "hidden";
1486
this.$cache.min[0].style.visibility = "visible";
1489
if (this.labels.p_single_left + this.labels.p_single_fake > 100 - this.labels.p_max - 1) {
1490
this.$cache.max[0].style.visibility = "hidden";
1492
this.$cache.max[0].style.visibility = "visible";
1499
if (this.options.decorate_both) {
1500
text_single = this.decorate(p_values[this.result.from]);
1501
text_single += this.options.values_separator;
1502
text_single += this.decorate(p_values[this.result.to]);
1504
text_single = this.decorate(p_values[this.result.from] + this.options.values_separator + p_values[this.result.to]);
1506
text_from = this.decorate(p_values[this.result.from]);
1507
text_to = this.decorate(p_values[this.result.to]);
1509
this.$cache.single.html(text_single);
1510
this.$cache.from.html(text_from);
1511
this.$cache.to.html(text_to);
1514
from_pretty = this._prettify(this.result.from);
1515
to_pretty = this._prettify(this.result.to);
1517
if (this.options.decorate_both) {
1518
text_single = this.decorate(from_pretty, this.result.from);
1519
text_single += this.options.values_separator;
1520
text_single += this.decorate(to_pretty, this.result.to);
1522
text_single = this.decorate(from_pretty + this.options.values_separator + to_pretty, this.result.to);
1524
text_from = this.decorate(from_pretty, this.result.from);
1525
text_to = this.decorate(to_pretty, this.result.to);
1527
this.$cache.single.html(text_single);
1528
this.$cache.from.html(text_from);
1529
this.$cache.to.html(text_to);
1535
var min = Math.min(this.labels.p_single_left, this.labels.p_from_left),
1536
single_left = this.labels.p_single_left + this.labels.p_single_fake,
1537
to_left = this.labels.p_to_left + this.labels.p_to_fake,
1538
max = Math.max(single_left, to_left);
1540
if (this.labels.p_from_left + this.labels.p_from_fake >= this.labels.p_to_left) {
1541
this.$cache.from[0].style.visibility = "hidden";
1542
this.$cache.to[0].style.visibility = "hidden";
1543
this.$cache.single[0].style.visibility = "visible";
1545
if (this.result.from === this.result.to) {
1546
if (this.target === "from") {
1547
this.$cache.from[0].style.visibility = "visible";
1548
} else if (this.target === "to") {
1549
this.$cache.to[0].style.visibility = "visible";
1550
} else if (!this.target) {
1551
this.$cache.from[0].style.visibility = "visible";
1553
this.$cache.single[0].style.visibility = "hidden";
1556
this.$cache.from[0].style.visibility = "hidden";
1557
this.$cache.to[0].style.visibility = "hidden";
1558
this.$cache.single[0].style.visibility = "visible";
1559
max = Math.max(single_left, to_left);
1562
this.$cache.from[0].style.visibility = "visible";
1563
this.$cache.to[0].style.visibility = "visible";
1564
this.$cache.single[0].style.visibility = "hidden";
1567
if (min < this.labels.p_min + 1) {
1568
this.$cache.min[0].style.visibility = "hidden";
1570
this.$cache.min[0].style.visibility = "visible";
1573
if (max > 100 - this.labels.p_max - 1) {
1574
this.$cache.max[0].style.visibility = "hidden";
1576
this.$cache.max[0].style.visibility = "visible";
1585
drawShadow: function () {
1586
var o = this.options,
1589
is_from_min = typeof o.from_min === "number" && !isNaN(o.from_min),
1590
is_from_max = typeof o.from_max === "number" && !isNaN(o.from_max),
1591
is_to_min = typeof o.to_min === "number" && !isNaN(o.to_min),
1592
is_to_max = typeof o.to_max === "number" && !isNaN(o.to_max),
1599
if (o.type === "single") {
1600
if (o.from_shadow && (is_from_min || is_from_max)) {
1601
from_min = this.convertToPercent(is_from_min ? o.from_min : o.min);
1602
from_max = this.convertToPercent(is_from_max ? o.from_max : o.max) - from_min;
1603
from_min = this.toFixed(from_min - (this.coords.p_handle / 100 * from_min));
1604
from_max = this.toFixed(from_max - (this.coords.p_handle / 100 * from_max));
1605
from_min = from_min + (this.coords.p_handle / 2);
1607
c.shad_single[0].style.display = "block";
1608
c.shad_single[0].style.left = from_min + "%";
1609
c.shad_single[0].style.width = from_max + "%";
1611
c.shad_single[0].style.display = "none";
1614
if (o.from_shadow && (is_from_min || is_from_max)) {
1615
from_min = this.convertToPercent(is_from_min ? o.from_min : o.min);
1616
from_max = this.convertToPercent(is_from_max ? o.from_max : o.max) - from_min;
1617
from_min = this.toFixed(from_min - (this.coords.p_handle / 100 * from_min));
1618
from_max = this.toFixed(from_max - (this.coords.p_handle / 100 * from_max));
1619
from_min = from_min + (this.coords.p_handle / 2);
1621
c.shad_from[0].style.display = "block";
1622
c.shad_from[0].style.left = from_min + "%";
1623
c.shad_from[0].style.width = from_max + "%";
1625
c.shad_from[0].style.display = "none";
1628
if (o.to_shadow && (is_to_min || is_to_max)) {
1629
to_min = this.convertToPercent(is_to_min ? o.to_min : o.min);
1630
to_max = this.convertToPercent(is_to_max ? o.to_max : o.max) - to_min;
1631
to_min = this.toFixed(to_min - (this.coords.p_handle / 100 * to_min));
1632
to_max = this.toFixed(to_max - (this.coords.p_handle / 100 * to_max));
1633
to_min = to_min + (this.coords.p_handle / 2);
1635
c.shad_to[0].style.display = "block";
1636
c.shad_to[0].style.left = to_min + "%";
1637
c.shad_to[0].style.width = to_max + "%";
1639
c.shad_to[0].style.display = "none";
1649
writeToInput: function () {
1650
if (this.options.type === "single") {
1651
if (this.options.values.length) {
1652
this.$cache.input.prop("value", this.result.from_value);
1654
this.$cache.input.prop("value", this.result.from);
1656
this.$cache.input.data("from", this.result.from);
1658
if (this.options.values.length) {
1659
this.$cache.input.prop("value", this.result.from_value + this.options.input_values_separator + this.result.to_value);
1661
this.$cache.input.prop("value", this.result.from + this.options.input_values_separator + this.result.to);
1663
this.$cache.input.data("from", this.result.from);
1664
this.$cache.input.data("to", this.result.to);
1673
callOnStart: function () {
1674
this.writeToInput();
1676
if (this.options.onStart && typeof this.options.onStart === "function") {
1677
if (this.options.scope) {
1678
this.options.onStart.call(this.options.scope, this.result);
1680
this.options.onStart(this.result);
1684
callOnChange: function () {
1685
this.writeToInput();
1687
if (this.options.onChange && typeof this.options.onChange === "function") {
1688
if (this.options.scope) {
1689
this.options.onChange.call(this.options.scope, this.result);
1691
this.options.onChange(this.result);
1695
callOnFinish: function () {
1696
this.writeToInput();
1698
if (this.options.onFinish && typeof this.options.onFinish === "function") {
1699
if (this.options.scope) {
1700
this.options.onFinish.call(this.options.scope, this.result);
1702
this.options.onFinish(this.result);
1706
callOnUpdate: function () {
1707
this.writeToInput();
1709
if (this.options.onUpdate && typeof this.options.onUpdate === "function") {
1710
if (this.options.scope) {
1711
this.options.onUpdate.call(this.options.scope, this.result);
1713
this.options.onUpdate(this.result);
1724
toggleInput: function () {
1725
this.$cache.input.toggleClass("irs-hidden-input");
1727
if (this.has_tab_index) {
1728
this.$cache.input.prop("tabindex", -1);
1730
this.$cache.input.removeProp("tabindex");
1733
this.has_tab_index = !this.has_tab_index;
1743
convertToPercent: function (value, no_min) {
1744
var diapason = this.options.max - this.options.min,
1745
one_percent = diapason / 100,
1749
this.no_diapason = true;
1756
val = value - this.options.min;
1759
percent = val / one_percent;
1761
return this.toFixed(percent);
1770
convertToValue: function (percent) {
1771
var min = this.options.min,
1772
max = this.options.max,
1773
min_decimals = min.toString().split(".")[1],
1774
max_decimals = max.toString().split(".")[1],
1775
min_length, max_length,
1779
if (percent === 0) {
1780
return this.options.min;
1782
if (percent === 100) {
1783
return this.options.max;
1788
min_length = min_decimals.length;
1789
avg_decimals = min_length;
1792
max_length = max_decimals.length;
1793
avg_decimals = max_length;
1795
if (min_length && max_length) {
1796
avg_decimals = (min_length >= max_length) ? min_length : max_length;
1800
abs = Math.abs(min);
1801
min = +(min + abs).toFixed(avg_decimals);
1802
max = +(max + abs).toFixed(avg_decimals);
1805
var number = ((max - min) / 100 * percent) + min,
1806
string = this.options.step.toString().split(".")[1],
1810
number = +number.toFixed(string.length);
1812
number = number / this.options.step;
1813
number = number * this.options.step;
1815
number = +number.toFixed(0);
1823
result = +number.toFixed(string.length);
1825
result = this.toFixed(number);
1828
if (result < this.options.min) {
1829
result = this.options.min;
1830
} else if (result > this.options.max) {
1831
result = this.options.max;
1843
calcWithStep: function (percent) {
1844
var rounded = Math.round(percent / this.coords.p_step) * this.coords.p_step;
1846
if (rounded > 100) {
1849
if (percent === 100) {
1853
return this.toFixed(rounded);
1856
checkMinInterval: function (p_current, p_next, type) {
1857
var o = this.options,
1861
if (!o.min_interval) {
1865
current = this.convertToValue(p_current);
1866
next = this.convertToValue(p_next);
1868
if (type === "from") {
1870
if (next - current < o.min_interval) {
1871
current = next - o.min_interval;
1876
if (current - next < o.min_interval) {
1877
current = next + o.min_interval;
1882
return this.convertToPercent(current);
1885
checkMaxInterval: function (p_current, p_next, type) {
1886
var o = this.options,
1890
if (!o.max_interval) {
1894
current = this.convertToValue(p_current);
1895
next = this.convertToValue(p_next);
1897
if (type === "from") {
1899
if (next - current > o.max_interval) {
1900
current = next - o.max_interval;
1905
if (current - next > o.max_interval) {
1906
current = next + o.max_interval;
1911
return this.convertToPercent(current);
1914
checkDiapason: function (p_num, min, max) {
1915
var num = this.convertToValue(p_num),
1918
if (typeof min !== "number") {
1922
if (typeof max !== "number") {
1934
return this.convertToPercent(num);
1937
toFixed: function (num) {
1938
num = num.toFixed(20);
1942
_prettify: function (num) {
1943
if (!this.options.prettify_enabled) {
1947
if (this.options.prettify && typeof this.options.prettify === "function") {
1948
return this.options.prettify(num);
1950
return this.prettify(num);
1954
prettify: function (num) {
1955
var n = num.toString();
1956
return n.replace(/(\d{1,3}(?=(?:\d\d\d)+(?!\d)))/g, "$1" + this.options.prettify_separator);
1959
checkEdges: function (left, width) {
1960
if (!this.options.force_edges) {
1961
return this.toFixed(left);
1966
} else if (left > 100 - width) {
1970
return this.toFixed(left);
1973
validate: function () {
1974
var o = this.options,
1981
if (typeof o.min === "string") o.min = +o.min;
1982
if (typeof o.max === "string") o.max = +o.max;
1983
if (typeof o.from === "string") o.from = +o.from;
1984
if (typeof o.to === "string") o.to = +o.to;
1985
if (typeof o.step === "string") o.step = +o.step;
1987
if (typeof o.from_min === "string") o.from_min = +o.from_min;
1988
if (typeof o.from_max === "string") o.from_max = +o.from_max;
1989
if (typeof o.to_min === "string") o.to_min = +o.to_min;
1990
if (typeof o.to_max === "string") o.to_max = +o.to_max;
1992
if (typeof o.grid_num === "string") o.grid_num = +o.grid_num;
1994
if (o.max < o.min) {
2006
for (i = 0; i < vl; i++) {
2009
if (!isNaN(value)) {
2011
value = this._prettify(value);
2016
o.p_values.push(value);
2020
if (typeof o.from !== "number" || isNaN(o.from)) {
2024
if (typeof o.to !== "number" || isNaN(o.to)) {
2028
if (o.type === "single") {
2030
if (o.from < o.min) o.from = o.min;
2031
if (o.from > o.max) o.from = o.max;
2035
if (o.from < o.min) o.from = o.min;
2036
if (o.from > o.max) o.from = o.max;
2038
if (o.to < o.min) o.to = o.min;
2039
if (o.to > o.max) o.to = o.max;
2041
if (this.update_check.from) {
2043
if (this.update_check.from !== o.from) {
2044
if (o.from > o.to) o.from = o.to;
2046
if (this.update_check.to !== o.to) {
2047
if (o.to < o.from) o.to = o.from;
2052
if (o.from > o.to) o.from = o.to;
2053
if (o.to < o.from) o.to = o.from;
2057
if (typeof o.step !== "number" || isNaN(o.step) || !o.step || o.step < 0) {
2061
if (typeof o.from_min === "number" && o.from < o.from_min) {
2062
o.from = o.from_min;
2065
if (typeof o.from_max === "number" && o.from > o.from_max) {
2066
o.from = o.from_max;
2069
if (typeof o.to_min === "number" && o.to < o.to_min) {
2073
if (typeof o.to_max === "number" && o.from > o.to_max) {
2078
if (r.min !== o.min) {
2082
if (r.max !== o.max) {
2086
if (r.from < r.min || r.from > r.max) {
2090
if (r.to < r.min || r.to > r.max) {
2095
if (typeof o.min_interval !== "number" || isNaN(o.min_interval) || !o.min_interval || o.min_interval < 0) {
2099
if (typeof o.max_interval !== "number" || isNaN(o.max_interval) || !o.max_interval || o.max_interval < 0) {
2103
if (o.min_interval && o.min_interval > o.max - o.min) {
2104
o.min_interval = o.max - o.min;
2107
if (o.max_interval && o.max_interval > o.max - o.min) {
2108
o.max_interval = o.max - o.min;
2112
decorate: function (num, original) {
2117
decorated += o.prefix;
2122
if (o.max_postfix) {
2123
if (o.values.length && num === o.p_values[o.max]) {
2124
decorated += o.max_postfix;
2128
} else if (original === o.max) {
2129
decorated += o.max_postfix;
2137
decorated += o.postfix;
2143
updateFrom: function () {
2144
this.result.from = this.options.from;
2145
this.result.from_percent = this.convertToPercent(this.result.from);
2146
this.result.from_pretty = this._prettify(this.result.from);
2147
if (this.options.values) {
2148
this.result.from_value = this.options.values[this.result.from];
2152
updateTo: function () {
2153
this.result.to = this.options.to;
2154
this.result.to_percent = this.convertToPercent(this.result.to);
2155
this.result.to_pretty = this._prettify(this.result.to);
2156
if (this.options.values) {
2157
this.result.to_value = this.options.values[this.result.to];
2161
updateResult: function () {
2162
this.result.min = this.options.min;
2163
this.result.max = this.options.max;
2172
appendGrid: function () {
2173
if (!this.options.grid) {
2177
var o = this.options,
2180
total = o.max - o.min,
2181
big_num = o.grid_num,
2195
this.calcGridMargin();
2198
big_num = total / o.step;
2201
if (big_num > 50) big_num = 50;
2202
big_p = this.toFixed(100 / big_num);
2217
for (i = 0; i < big_num + 1; i++) {
2218
local_small_max = small_max;
2220
big_w = this.toFixed(big_p * i);
2225
this.coords.big[i] = big_w;
2227
small_p = (big_w - (big_p * (i - 1))) / (local_small_max + 1);
2229
for (z = 1; z <= local_small_max; z++) {
2234
small_w = this.toFixed(big_w - (small_p * z));
2236
html += '<span class="irs-grid-pol small" style="left: ' + small_w + '%"></span>';
2239
html += '<span class="irs-grid-pol" style="left: ' + big_w + '%"></span>';
2241
result = this.convertToValue(big_w);
2242
if (o.values.length) {
2243
result = o.p_values[result];
2245
result = this._prettify(result);
2248
html += '<span class="irs-grid-text js-grid-text-' + i + '" style="left: ' + big_w + '%">' + result + '</span>';
2250
this.coords.big_num = Math.ceil(big_num + 1);
2254
this.$cache.cont.addClass("irs-with-grid");
2255
this.$cache.grid.html(html);
2256
this.cacheGridLabels();
2259
cacheGridLabels: function () {
2261
num = this.coords.big_num;
2263
for (i = 0; i < num; i++) {
2264
$label = this.$cache.grid.find(".js-grid-text-" + i);
2265
this.$cache.grid_labels.push($label);
2268
this.calcGridLabels();
2271
calcGridLabels: function () {
2272
var i, label, start = [], finish = [],
2273
num = this.coords.big_num;
2275
for (i = 0; i < num; i++) {
2276
this.coords.big_w[i] = this.$cache.grid_labels[i].outerWidth(false);
2277
this.coords.big_p[i] = this.toFixed(this.coords.big_w[i] / this.coords.w_rs * 100);
2278
this.coords.big_x[i] = this.toFixed(this.coords.big_p[i] / 2);
2280
start[i] = this.toFixed(this.coords.big[i] - this.coords.big_x[i]);
2281
finish[i] = this.toFixed(start[i] + this.coords.big_p[i]);
2284
if (this.options.force_edges) {
2285
if (start[0] < -this.coords.grid_gap) {
2286
start[0] = -this.coords.grid_gap;
2287
finish[0] = this.toFixed(start[0] + this.coords.big_p[0]);
2289
this.coords.big_x[0] = this.coords.grid_gap;
2292
if (finish[num - 1] > 100 + this.coords.grid_gap) {
2293
finish[num - 1] = 100 + this.coords.grid_gap;
2294
start[num - 1] = this.toFixed(finish[num - 1] - this.coords.big_p[num - 1]);
2296
this.coords.big_x[num - 1] = this.toFixed(this.coords.big_p[num - 1] - this.coords.grid_gap);
2300
this.calcGridCollision(2, start, finish);
2301
this.calcGridCollision(4, start, finish);
2303
for (i = 0; i < num; i++) {
2304
label = this.$cache.grid_labels[i][0];
2306
if (this.coords.big_x[i] !== Number.POSITIVE_INFINITY) {
2307
label.style.marginLeft = -this.coords.big_x[i] + "%";
2314
calcGridCollision: function (step, start, finish) {
2315
var i, next_i, label,
2316
num = this.coords.big_num;
2318
for (i = 0; i < num; i += step) {
2319
next_i = i + (step / 2);
2320
if (next_i >= num) {
2324
label = this.$cache.grid_labels[next_i][0];
2326
if (finish[i] <= start[next_i]) {
2327
label.style.visibility = "visible";
2329
label.style.visibility = "hidden";
2334
calcGridMargin: function () {
2335
if (!this.options.grid_margin) {
2339
this.coords.w_rs = this.$cache.rs.outerWidth(false);
2340
if (!this.coords.w_rs) {
2344
if (this.options.type === "single") {
2345
this.coords.w_handle = this.$cache.s_single.outerWidth(false);
2347
this.coords.w_handle = this.$cache.s_from.outerWidth(false);
2349
this.coords.p_handle = this.toFixed(this.coords.w_handle / this.coords.w_rs * 100);
2350
this.coords.grid_gap = this.toFixed((this.coords.p_handle / 2) - 0.1);
2352
this.$cache.grid[0].style.width = this.toFixed(100 - this.coords.p_handle) + "%";
2353
this.$cache.grid[0].style.left = this.coords.grid_gap + "%";
2361
update: function (options) {
2366
this.is_update = true;
2368
this.options.from = this.result.from;
2369
this.options.to = this.result.to;
2370
this.update_check.from = this.result.from;
2371
this.update_check.to = this.result.to;
2373
this.options = $.extend(this.options, options);
2375
this.updateResult(options);
2382
reset: function () {
2387
this.updateResult();
2391
destroy: function () {
2397
this.$cache.input.prop("readonly", false);
2398
$.data(this.input, "ionRangeSlider", null);
2402
this.options = null;
2406
$.fn.ionRangeSlider = function (options) {
2407
return this.each(function() {
2408
if (!$.data(this, "ionRangeSlider")) {
2409
$.data(this, "ionRangeSlider", new IonRangeSlider(this, options, plugin_count++));
2426
var vendors = ['ms', 'moz', 'webkit', 'o'];
2427
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
2428
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
2429
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
2430
|| window[vendors[x]+'CancelRequestAnimationFrame'];
2433
if (!window.requestAnimationFrame)
2434
window.requestAnimationFrame = function(callback, element) {
2435
var currTime = new Date().getTime();
2436
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
2437
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
2439
lastTime = currTime + timeToCall;
2443
if (!window.cancelAnimationFrame)
2444
window.cancelAnimationFrame = function(id) {