|
1 | 1 | // Ion.RangeSlider
|
2 |
| -// version 2.1.4 Build: 355 |
| 2 | +// version 2.1.5 Build: 365 |
3 | 3 | // © Denis Ineshin, 2016
|
4 | 4 | // https://github.com/IonDen
|
5 | 5 | //
|
|
10 | 10 | // http://ionden.com/a/plugins/licence-en.html
|
11 | 11 | // =====================================================================================================================
|
12 | 12 |
|
13 |
| -(function (factory) { |
14 |
| - if (typeof define === 'function' && define.amd) { |
15 |
| - define(['jquery'], function ($) { |
16 |
| - factory($, document, window, navigator); |
| 13 | +;(function(factory) { |
| 14 | + if (typeof define === "function" && define.amd) { |
| 15 | + define(["jquery"], function (jQuery) { |
| 16 | + return factory(jQuery, document, window, navigator); |
17 | 17 | });
|
| 18 | + } else if (typeof exports === "object") { |
| 19 | + factory(require("jquery"), document, window, navigator); |
18 | 20 | } else {
|
19 | 21 | factory(jQuery, document, window, navigator);
|
20 | 22 | }
|
|
154 | 156 | * @constructor
|
155 | 157 | */
|
156 | 158 | var IonRangeSlider = function (input, options, plugin_count) {
|
157 |
| - this.VERSION = "2.1.4"; |
| 159 | + this.VERSION = "2.1.5"; |
158 | 160 | this.input = input;
|
159 | 161 | this.plugin_count = plugin_count;
|
160 | 162 | this.current_plugin = 0;
|
|
176 | 178 | this.is_resize = false;
|
177 | 179 | this.is_click = false;
|
178 | 180 |
|
| 181 | + options = options || {}; |
| 182 | + |
179 | 183 | // cache for links to all DOM elements
|
180 | 184 | this.$cache = {
|
181 | 185 | win: $(window),
|
|
384 | 388 |
|
385 | 389 | for (prop in config_from_data) {
|
386 | 390 | if (config_from_data.hasOwnProperty(prop)) {
|
387 |
| - if (!config_from_data[prop] && config_from_data[prop] !== 0) { |
| 391 | + if (config_from_data[prop] === undefined || config_from_data[prop] === "") { |
388 | 392 | delete config_from_data[prop];
|
389 | 393 | }
|
390 | 394 | }
|
|
393 | 397 |
|
394 | 398 |
|
395 | 399 | // input value extends default config
|
396 |
| - if (val) { |
| 400 | + if (val !== "") { |
397 | 401 | val = val.split(config_from_data.input_values_separator || options.input_values_separator || ";");
|
398 | 402 |
|
399 | 403 | if (val[0] && val[0] == +val[0]) {
|
|
425 | 429 |
|
426 | 430 |
|
427 | 431 | // validate config, to be sure that all data types are correct
|
| 432 | + this.update_check = {}; |
428 | 433 | this.validate();
|
429 | 434 |
|
430 | 435 |
|
|
456 | 461 | /**
|
457 | 462 | * Starts or updates the plugin instance
|
458 | 463 | *
|
459 |
| - * @param is_update {boolean} |
| 464 | + * @param [is_update] {boolean} |
460 | 465 | */
|
461 | 466 | init: function (is_update) {
|
462 | 467 | this.no_diapason = false;
|
|
743 | 748 |
|
744 | 749 | // callbacks call
|
745 | 750 | if ($.contains(this.$cache.cont[0], e.target) || this.dragging) {
|
746 |
| - this.is_finish = true; |
747 | 751 | this.callOnFinish();
|
748 | 752 | }
|
749 | 753 |
|
|
769 | 773 | }
|
770 | 774 |
|
771 | 775 | if (!target) {
|
772 |
| - target = this.target; |
| 776 | + target = this.target || "from"; |
773 | 777 | }
|
774 | 778 |
|
775 | 779 | this.current_plugin = this.plugin_count;
|
|
955 | 959 | this.calcPointerPercent();
|
956 | 960 | var handle_x = this.getHandleX();
|
957 | 961 |
|
| 962 | + |
| 963 | + if (this.target === "both") { |
| 964 | + this.coords.p_gap = 0; |
| 965 | + handle_x = this.getHandleX(); |
| 966 | + } |
| 967 | + |
958 | 968 | if (this.target === "click") {
|
959 | 969 | this.coords.p_gap = this.coords.p_handle / 2;
|
960 | 970 | handle_x = this.getHandleX();
|
|
1042 | 1052 | break;
|
1043 | 1053 | }
|
1044 | 1054 |
|
1045 |
| - handle_x = this.toFixed(handle_x + (this.coords.p_handle * 0.1)); |
| 1055 | + handle_x = this.toFixed(handle_x + (this.coords.p_handle * 0.001)); |
1046 | 1056 |
|
1047 | 1057 | this.coords.p_from_real = this.convertToRealPercent(handle_x) - this.coords.p_gap_left;
|
1048 | 1058 | this.coords.p_from_real = this.calcWithStep(this.coords.p_from_real);
|
|
1894 | 1904 | o.from = o.min;
|
1895 | 1905 | }
|
1896 | 1906 |
|
1897 |
| - if (typeof o.to !== "number" || isNaN(o.from)) { |
| 1907 | + if (typeof o.to !== "number" || isNaN(o.to)) { |
1898 | 1908 | o.to = o.max;
|
1899 | 1909 | }
|
1900 | 1910 |
|
1901 | 1911 | if (o.type === "single") {
|
1902 | 1912 |
|
1903 |
| - if (o.from < o.min) { |
1904 |
| - o.from = o.min; |
1905 |
| - } |
1906 |
| - |
1907 |
| - if (o.from > o.max) { |
1908 |
| - o.from = o.max; |
1909 |
| - } |
| 1913 | + if (o.from < o.min) o.from = o.min; |
| 1914 | + if (o.from > o.max) o.from = o.max; |
1910 | 1915 |
|
1911 | 1916 | } else {
|
1912 | 1917 |
|
1913 |
| - if (o.from < o.min || o.from > o.max) { |
1914 |
| - o.from = o.min; |
1915 |
| - } |
1916 |
| - if (o.to > o.max || o.to < o.min) { |
1917 |
| - o.to = o.max; |
1918 |
| - } |
1919 |
| - if (o.from > o.to) { |
1920 |
| - o.from = o.to; |
| 1918 | + if (o.from < o.min) o.from = o.min; |
| 1919 | + if (o.from > o.max) o.from = o.max; |
| 1920 | + |
| 1921 | + if (o.to < o.min) o.to = o.min; |
| 1922 | + if (o.to > o.max) o.to = o.max; |
| 1923 | + |
| 1924 | + if (this.update_check.from) { |
| 1925 | + |
| 1926 | + if (this.update_check.from !== o.from) { |
| 1927 | + if (o.from > o.to) o.from = o.to; |
| 1928 | + } |
| 1929 | + if (this.update_check.to !== o.to) { |
| 1930 | + if (o.to < o.from) o.to = o.from; |
| 1931 | + } |
| 1932 | + |
1921 | 1933 | }
|
1922 | 1934 |
|
| 1935 | + if (o.from > o.to) o.from = o.to; |
| 1936 | + if (o.to < o.from) o.to = o.from; |
| 1937 | + |
1923 | 1938 | }
|
1924 | 1939 |
|
1925 | 1940 | if (typeof o.step !== "number" || isNaN(o.step) || !o.step || o.step < 0) {
|
|
2242 | 2257 |
|
2243 | 2258 | this.options.from = this.result.from;
|
2244 | 2259 | this.options.to = this.result.to;
|
| 2260 | + this.update_check.from = this.result.from; |
| 2261 | + this.update_check.to = this.result.to; |
2245 | 2262 |
|
2246 | 2263 | this.options = $.extend(this.options, options);
|
2247 | 2264 | this.validate();
|
|
0 commit comments