|
48 | 48 | interval: 350,
|
49 | 49 | showTicks: false,
|
50 | 50 | showTicksValues: false,
|
| 51 | + ticksValuesTooltip: null, |
51 | 52 | scale: 1,
|
52 | 53 | onStart: null,
|
53 | 54 | onChange: null,
|
|
123 | 124 | };
|
124 | 125 | })
|
125 | 126 |
|
126 |
| - .factory('RzSlider', ['$timeout', '$document', '$window', 'RzSliderOptions', 'rzThrottle', function($timeout, $document, $window, RzSliderOptions, rzThrottle) { |
| 127 | + .factory('RzSlider', ['$timeout', '$document', '$window', '$compile', 'RzSliderOptions', 'rzThrottle', function($timeout, $document, $window, $compile, RzSliderOptions, rzThrottle) { |
127 | 128 | 'use strict';
|
128 | 129 |
|
129 | 130 | /**
|
|
360 | 361 | this.options.draggableRange = this.range && this.options.draggableRange;
|
361 | 362 | this.options.showTicks = this.options.showTicks || this.options.showTicksValues;
|
362 | 363 |
|
363 |
| - if(this.options.stepsArray) { |
| 364 | + if (this.options.stepsArray) { |
364 | 365 | this.options.floor = 0;
|
365 |
| - this.options.ceil = this.options.stepsArray.length -1; |
| 366 | + this.options.ceil = this.options.stepsArray.length - 1; |
366 | 367 | this.options.step = 1;
|
367 | 368 | this.customTrFn = function(value) {
|
368 | 369 | return this.options.stepsArray[value];
|
|
645 | 646 | var value = this.roundStep(this.minValue + i * this.step);
|
646 | 647 | var selectedClass = this.isTickSelected(value) ? 'selected' : '';
|
647 | 648 | positions += '<li class="tick ' + selectedClass + '">';
|
648 |
| - if (this.options.showTicksValues) |
649 |
| - positions += '<span class="tick-value">' + this.getDisplayValue(value) + '</span>'; |
| 649 | + if (this.options.showTicksValues) { |
| 650 | + var tooltip = ''; |
| 651 | + if (this.options.ticksValuesTooltip) { |
| 652 | + tooltip = 'uib-tooltip="' + this.options.ticksValuesTooltip(value) + '"'; |
| 653 | + } |
| 654 | + positions += '<span ' + tooltip + ' class="tick-value">' + this.getDisplayValue(value) + '</span>'; |
| 655 | + } |
650 | 656 | positions += '</li>';
|
651 | 657 | }
|
652 | 658 | this.ticks.html(positions);
|
| 659 | + if (this.options.ticksValuesTooltip) |
| 660 | + $compile(this.ticks.contents())(this.scope); |
653 | 661 | },
|
654 | 662 |
|
655 | 663 | isTickSelected: function(value) {
|
|
963 | 971 | return (this.sanitizeOffsetValue(val) - this.minValue) * this.maxLeft / this.valueRange || 0;
|
964 | 972 | },
|
965 | 973 |
|
966 |
| - /** |
| 974 | + /** |
967 | 975 | * Ensure that the position rendered is within the slider bounds, even if the value is not
|
968 | 976 | *
|
969 | 977 | * @param {number} val
|
970 | 978 | * @returns {number}
|
971 | 979 | */
|
972 |
| - sanitizeOffsetValue: function(val) |
973 |
| - { |
| 980 | + sanitizeOffsetValue: function(val) { |
974 | 981 | return Math.min(Math.max(val, this.minValue), this.maxValue);
|
975 | 982 | },
|
976 | 983 |
|
|
0 commit comments