|
1 | 1 | // Ion.RangeSlider
|
2 |
| -// version 2.1.1 Build: 347 |
| 2 | +// version 2.1.2 Build: 350 |
3 | 3 | // © Denis Ineshin, 2015
|
4 | 4 | // https://github.com/IonDen
|
5 | 5 | //
|
|
140 | 140 | /**
|
141 | 141 | * Main plugin constructor
|
142 | 142 | *
|
143 |
| - * @param input {object} link to base input element |
144 |
| - * @param options {object} slider config |
145 |
| - * @param plugin_count {number} |
| 143 | + * @param input {Object} link to base input element |
| 144 | + * @param options {Object} slider config |
| 145 | + * @param plugin_count {Number} |
146 | 146 | * @constructor
|
147 | 147 | */
|
148 | 148 | var IonRangeSlider = function (input, options, plugin_count) {
|
149 |
| - this.VERSION = "2.1.1"; |
| 149 | + this.VERSION = "2.1.2"; |
150 | 150 | this.input = input;
|
151 | 151 | this.plugin_count = plugin_count;
|
152 | 152 | this.current_plugin = 0;
|
|
557 | 557 | * Determine which handles was clicked last
|
558 | 558 | * and which handler should have hover effect
|
559 | 559 | *
|
560 |
| - * @param target {string} |
| 560 | + * @param target {String} |
561 | 561 | */
|
562 | 562 | changeLevel: function (target) {
|
563 | 563 | switch (target) {
|
|
659 | 659 | this.$cache.edge.on("mousedown.irs_" + this.plugin_count, this.pointerClick.bind(this, "click"));
|
660 | 660 | this.$cache.shad_single.on("mousedown.irs_" + this.plugin_count, this.pointerClick.bind(this, "click"));
|
661 | 661 | } else {
|
662 |
| - this.$cache.single.on("touchstart.irs_" + this.plugin_count, this.pointerDown.bind(this, "from")); |
663 |
| - this.$cache.single.on("mousedown.irs_" + this.plugin_count, this.pointerDown.bind(this, "from")); |
| 662 | + this.$cache.single.on("touchstart.irs_" + this.plugin_count, this.pointerDown.bind(this, null)); |
| 663 | + this.$cache.single.on("mousedown.irs_" + this.plugin_count, this.pointerDown.bind(this, null)); |
664 | 664 |
|
665 | 665 | this.$cache.from.on("touchstart.irs_" + this.plugin_count, this.pointerDown.bind(this, "from"));
|
666 | 666 | this.$cache.s_from.on("touchstart.irs_" + this.plugin_count, this.pointerDown.bind(this, "from"));
|
|
691 | 691 | * Mousemove or touchmove
|
692 | 692 | * only for handlers
|
693 | 693 | *
|
694 |
| - * @param e {object} event object |
| 694 | + * @param e {Object} event object |
695 | 695 | */
|
696 | 696 | pointerMove: function (e) {
|
697 | 697 | if (!this.dragging) {
|
|
708 | 708 | * Mouseup or touchend
|
709 | 709 | * only for handlers
|
710 | 710 | *
|
711 |
| - * @param e {object} event object |
| 711 | + * @param e {Object} event object |
712 | 712 | */
|
713 | 713 | pointerUp: function (e) {
|
714 | 714 | if (this.current_plugin !== this.plugin_count) {
|
|
745 | 745 | * Mousedown or touchstart
|
746 | 746 | * only for handlers
|
747 | 747 | *
|
748 |
| - * @param target {string} |
749 |
| - * @param e {object} event object |
| 748 | + * @param target {String|null} |
| 749 | + * @param e {Object} event object |
750 | 750 | */
|
751 | 751 | pointerDown: function (target, e) {
|
752 | 752 | e.preventDefault();
|
|
759 | 759 | this.setTempMinInterval();
|
760 | 760 | }
|
761 | 761 |
|
| 762 | + if (!target) { |
| 763 | + target = this.target; |
| 764 | + } |
| 765 | + |
762 | 766 | this.current_plugin = this.plugin_count;
|
763 | 767 | this.target = target;
|
764 | 768 |
|
|
784 | 788 | * Mousedown or touchstart
|
785 | 789 | * for other slider elements, like diapason line
|
786 | 790 | *
|
787 |
| - * @param target {string} |
788 |
| - * @param e {object} event object |
| 791 | + * @param target {String} |
| 792 | + * @param e {Object} event object |
789 | 793 | */
|
790 | 794 | pointerClick: function (target, e) {
|
791 | 795 | e.preventDefault();
|
|
810 | 814 | /**
|
811 | 815 | * Keyborard controls for focused slider
|
812 | 816 | *
|
813 |
| - * @param target {string} |
814 |
| - * @param e {object} event object |
| 817 | + * @param target {String} |
| 818 | + * @param e {Object} event object |
815 | 819 | * @returns {boolean|undefined}
|
816 | 820 | */
|
817 | 821 | key: function (target, e) {
|
|
1163 | 1167 | /**
|
1164 | 1168 | * Find closest handle to pointer click
|
1165 | 1169 | *
|
1166 |
| - * @param real_x {number} |
1167 |
| - * @returns {string} |
| 1170 | + * @param real_x {Number} |
| 1171 | + * @returns {String} |
1168 | 1172 | */
|
1169 | 1173 | chooseHandle: function (real_x) {
|
1170 | 1174 | if (this.options.type === "single") {
|
|
1457 | 1461 | this.$cache.single[0].style.visibility = "visible";
|
1458 | 1462 |
|
1459 | 1463 | if (this.result.from === this.result.to) {
|
1460 |
| - this.$cache.from[0].style.visibility = "visible"; |
| 1464 | + if (this.target === "from") { |
| 1465 | + this.$cache.from[0].style.visibility = "visible"; |
| 1466 | + } else if (this.target === "to") { |
| 1467 | + this.$cache.to[0].style.visibility = "visible"; |
| 1468 | + } |
1461 | 1469 | this.$cache.single[0].style.visibility = "hidden";
|
1462 | 1470 | max = to_left;
|
1463 | 1471 | } else {
|
1464 | 1472 | this.$cache.from[0].style.visibility = "hidden";
|
| 1473 | + this.$cache.to[0].style.visibility = "hidden"; |
1465 | 1474 | this.$cache.single[0].style.visibility = "visible";
|
1466 | 1475 | max = Math.max(single_left, to_left);
|
1467 | 1476 | }
|
|
1586 | 1595 | /**
|
1587 | 1596 | * Convert real value to percent
|
1588 | 1597 | *
|
1589 |
| - * @param value {number} X in real |
| 1598 | + * @param value {Number} X in real |
1590 | 1599 | * @param no_min {boolean=} don't use min value
|
1591 |
| - * @returns {number} X in percent |
| 1600 | + * @returns {Number} X in percent |
1592 | 1601 | */
|
1593 | 1602 | convertToPercent: function (value, no_min) {
|
1594 | 1603 | var diapason = this.options.max - this.options.min,
|
|
1614 | 1623 | /**
|
1615 | 1624 | * Convert percent to real values
|
1616 | 1625 | *
|
1617 |
| - * @param percent {number} X in percent |
1618 |
| - * @returns {number} X in real |
| 1626 | + * @param percent {Number} X in percent |
| 1627 | + * @returns {Number} X in real |
1619 | 1628 | */
|
1620 | 1629 | convertToValue: function (percent) {
|
1621 | 1630 | var min = this.options.min,
|
|
1687 | 1696 | /**
|
1688 | 1697 | * Round percent value with step
|
1689 | 1698 | *
|
1690 |
| - * @param percent {number} |
1691 |
| - * @returns percent {number} rounded |
| 1699 | + * @param percent {Number} |
| 1700 | + * @returns percent {Number} rounded |
1692 | 1701 | */
|
1693 | 1702 | calcWithStep: function (percent) {
|
1694 | 1703 | var rounded = Math.round(percent / this.coords.p_step) * this.coords.p_step;
|
|
0 commit comments