|
1 | 1 | // Ion.RangeSlider
|
2 |
| -// version 2.0.7 Build: 315 |
| 2 | +// version 2.0.8 Build: 320 |
3 | 3 | // © Denis Ineshin, 2015
|
4 | 4 | // https://github.com/IonDen
|
5 | 5 | //
|
|
18 | 18 |
|
19 | 19 | var plugin_count = 0;
|
20 | 20 |
|
| 21 | + // IE8 fix |
21 | 22 | var is_old_ie = (function () {
|
22 | 23 | var n = navigator.userAgent,
|
23 | 24 | r = /msie\s\d+/i,
|
|
32 | 33 | }
|
33 | 34 | return false;
|
34 | 35 | } ());
|
35 |
| - |
36 |
| - // IE8 fix |
37 | 36 | if (!Function.prototype.bind) {
|
38 | 37 | Function.prototype.bind = function bind(that) {
|
39 | 38 |
|
|
139 | 138 | // Core
|
140 | 139 |
|
141 | 140 | var IonRangeSlider = function (input, options, plugin_count) {
|
142 |
| - this.VERSION = "2.0.7"; |
| 141 | + this.VERSION = "2.0.8"; |
143 | 142 | this.input = input;
|
144 | 143 | this.plugin_count = plugin_count;
|
145 | 144 | this.current_plugin = 0;
|
|
232 | 231 | disable: $inp.data("disable")
|
233 | 232 | };
|
234 | 233 | data.values = data.values && data.values.split(",");
|
235 |
| - options = $.extend(data, options); |
236 | 234 |
|
237 | 235 | // get from and to out of input
|
238 | 236 | var val = $inp.prop("value");
|
|
255 | 253 | }
|
256 | 254 | }
|
257 | 255 |
|
| 256 | + // JS config has a priority |
| 257 | + options = $.extend(data, options); |
| 258 | + |
258 | 259 | // get config from options
|
259 | 260 | this.options = $.extend({
|
260 | 261 | type: "single",
|
|
446 | 447 | this.$cache.s_to = this.$cache.cont.find(".to");
|
447 | 448 | this.$cache.shad_from = this.$cache.cont.find(".shadow-from");
|
448 | 449 | this.$cache.shad_to = this.$cache.cont.find(".shadow-to");
|
| 450 | + |
| 451 | + this.setTopHandler(); |
449 | 452 | }
|
450 | 453 |
|
451 | 454 | if (this.options.hide_from_to) {
|
|
466 | 469 | }
|
467 | 470 | },
|
468 | 471 |
|
| 472 | + setTopHandler: function () { |
| 473 | + var min = this.options.min, |
| 474 | + max = this.options.max, |
| 475 | + from = this.options.from, |
| 476 | + to = this.options.to; |
| 477 | + |
| 478 | + if (from > min && to === max) { |
| 479 | + this.$cache.s_from.addClass("type_last"); |
| 480 | + } else if (to < max) { |
| 481 | + this.$cache.s_to.addClass("type_last"); |
| 482 | + } |
| 483 | + }, |
| 484 | + |
469 | 485 | appendDisableMask: function () {
|
470 | 486 | this.$cache.cont.append(disable_html);
|
471 | 487 | this.$cache.cont.addClass("irs-disabled");
|
|
681 | 697 | return true;
|
682 | 698 | },
|
683 | 699 |
|
684 |
| - // Move by key beta |
| 700 | + // Move by key. Beta |
685 | 701 | // TODO: refactor than have plenty of time
|
686 | 702 | moveByKey: function (right) {
|
687 | 703 | var p = this.coords.p_pointer;
|
|
1137 | 1153 | } else {
|
1138 | 1154 |
|
1139 | 1155 | if (this.options.decorate_both) {
|
1140 |
| - text_single = this.decorate(this._prettify(this.result.from)); |
| 1156 | + text_single = this.decorate(this._prettify(this.result.from), this.result.from); |
1141 | 1157 | text_single += this.options.values_separator;
|
1142 |
| - text_single += this.decorate(this._prettify(this.result.to)); |
| 1158 | + text_single += this.decorate(this._prettify(this.result.to), this.result.to); |
1143 | 1159 | } else {
|
1144 |
| - text_single = this.decorate(this._prettify(this.result.from) + this.options.values_separator + this._prettify(this.result.to), this.result.from); |
| 1160 | + text_single = this.decorate(this._prettify(this.result.from) + this.options.values_separator + this._prettify(this.result.to), this.result.to); |
1145 | 1161 | }
|
1146 | 1162 | text_from = this.decorate(this._prettify(this.result.from), this.result.from);
|
1147 | 1163 | text_to = this.decorate(this._prettify(this.result.to), this.result.to);
|
|
1281 | 1297 | }
|
1282 | 1298 |
|
1283 | 1299 | var number = ((max - min) / 100 * percent) + min,
|
1284 |
| - string = this.options.step.toString().split(".")[1]; |
| 1300 | + string = this.options.step.toString().split(".")[1], |
| 1301 | + result; |
1285 | 1302 |
|
1286 | 1303 | if (string) {
|
1287 | 1304 | number = +number.toFixed(string.length);
|
|
1295 | 1312 | number -= abs;
|
1296 | 1313 | }
|
1297 | 1314 |
|
1298 |
| - if (number < this.options.min) { |
1299 |
| - number = this.options.min; |
1300 |
| - } else if (number > this.options.max) { |
1301 |
| - number = this.options.max; |
1302 |
| - } |
1303 |
| - |
1304 | 1315 | if (string) {
|
1305 |
| - return +number.toFixed(string.length); |
| 1316 | + result = +number.toFixed(string.length); |
1306 | 1317 | } else {
|
1307 |
| - return this.toFixed(number); |
| 1318 | + result = this.toFixed(number); |
| 1319 | + } |
| 1320 | + |
| 1321 | + if (result < this.options.min) { |
| 1322 | + result = this.options.min; |
| 1323 | + } else if (result > this.options.max) { |
| 1324 | + result = this.options.max; |
1308 | 1325 | }
|
| 1326 | + |
| 1327 | + return result; |
1309 | 1328 | },
|
1310 | 1329 |
|
1311 | 1330 | calcWithStep: function (percent) {
|
|
1500 | 1519 | o.to = o.max;
|
1501 | 1520 | }
|
1502 | 1521 |
|
1503 |
| - if (o.from < o.min || o.from > o.max) { |
1504 |
| - o.from = o.min; |
1505 |
| - } |
| 1522 | + if (o.type === "single") { |
1506 | 1523 |
|
1507 |
| - if (o.to > o.max || o.to < o.min) { |
1508 |
| - o.to = o.max; |
1509 |
| - } |
| 1524 | + if (o.from < o.min) { |
| 1525 | + o.from = o.min; |
| 1526 | + } |
| 1527 | + |
| 1528 | + if (o.from > o.max) { |
| 1529 | + o.from = o.max; |
| 1530 | + } |
| 1531 | + |
| 1532 | + } else { |
| 1533 | + |
| 1534 | + if (o.from < o.min || o.from > o.max) { |
| 1535 | + o.from = o.min; |
| 1536 | + } |
| 1537 | + if (o.to > o.max || o.to < o.min) { |
| 1538 | + o.to = o.max; |
| 1539 | + } |
| 1540 | + if (o.from > o.to) { |
| 1541 | + o.from = o.to; |
| 1542 | + } |
1510 | 1543 |
|
1511 |
| - if (o.type === "double" && o.from > o.to) { |
1512 |
| - o.from = o.to; |
1513 | 1544 | }
|
1514 | 1545 |
|
1515 | 1546 | if (typeof o.step !== "number" || isNaN(o.step) || !o.step || o.step < 0) {
|
|
0 commit comments