|
377 | 377 | this.range = this.scope.rzSliderModel !== undefined && this.scope.rzSliderHigh !== undefined;
|
378 | 378 | this.options.draggableRange = this.range && this.options.draggableRange;
|
379 | 379 | this.options.showTicks = this.options.showTicks || this.options.showTicksValues;
|
380 |
| - this.scope.showTicks = this.options.showTicks; //scope is used in the template |
381 | 380 |
|
382 | 381 | if (this.options.stepsArray) {
|
383 | 382 | this.options.floor = 0;
|
|
491 | 490 | this.alwaysHide(this.cmbLab, this.options.showTicksValues || !this.range);
|
492 | 491 | this.alwaysHide(this.selBar, !this.range && !this.options.showSelectionBar);
|
493 | 492 |
|
| 493 | + if (!this.options.showTicks) |
| 494 | + this.ticks.html(''); |
| 495 | + |
494 | 496 | if (this.options.draggableRange)
|
495 | 497 | this.selBar.addClass('rz-draggable');
|
496 | 498 | else
|
|
657 | 659 | */
|
658 | 660 | updateTicksScale: function() {
|
659 | 661 | if (!this.options.showTicks) return;
|
660 |
| - if (!this.step) return; //if step is 0, we'll get a zero division |
| 662 | + if (!this.step) return; //if step is 0, the following loop will be endless. |
661 | 663 |
|
662 | 664 | var positions = '',
|
663 | 665 | ticksCount = Math.round((this.maxValue - this.minValue) / this.step) + 1;
|
664 |
| - this.scope.ticks = []; |
665 | 666 | for (var i = 0; i < ticksCount; i++) {
|
666 |
| - var value = this.roundStep(this.minValue + i * this.step); |
667 |
| - var tick = { |
668 |
| - selected: this.isTickSelected(value) |
669 |
| - }; |
| 667 | + var value = this.roundStep(this.minValue + i * this.step), |
| 668 | + selected = this.isTickSelected(value), |
| 669 | + selectedClass = selected ? 'selected' : '', |
| 670 | + customStyle = ''; |
| 671 | + if (selected && this.options.getSelectionBarColor) { |
| 672 | + var color = this.options.getSelectionBarColor(); |
| 673 | + customStyle = 'style="background-color: ' + color + '"'; |
| 674 | + } |
| 675 | + positions += '<li class="tick ' + selectedClass + '" ' + customStyle + '>'; |
670 | 676 | if (this.options.showTicksValues) {
|
671 |
| - tick.value = this.getDisplayValue(value); |
| 677 | + var tooltip = ''; |
672 | 678 | if (this.options.ticksValuesTooltip) {
|
673 |
| - tick.tooltip = this.options.ticksValuesTooltip(value); |
674 |
| - tick.tooltipPlacement = this.options.vertical ? 'right' : 'top'; |
| 679 | + tooltip = 'uib-tooltip="' + this.options.ticksValuesTooltip(value) + '"'; |
| 680 | + if (this.options.vertical) |
| 681 | + tooltip += ' tooltip-placement="right"' |
675 | 682 | }
|
| 683 | + positions += '<span ' + tooltip + ' class="tick-value">' + this.getDisplayValue(value) + '</span>'; |
676 | 684 | }
|
677 |
| - this.scope.ticks.push(tick); |
| 685 | + positions += '</li>'; |
678 | 686 | }
|
| 687 | + this.ticks.html(positions); |
| 688 | + if (this.options.ticksValuesTooltip) |
| 689 | + $compile(this.ticks.contents())(this.scope); |
679 | 690 | },
|
680 | 691 |
|
681 | 692 | isTickSelected: function(value) {
|
|
865 | 876 | updateSelectionBar: function() {
|
866 | 877 | this.setDimension(this.selBar, Math.abs(this.maxH.rzsp - this.minH.rzsp) + this.handleHalfDim);
|
867 | 878 | this.setPosition(this.selBar, this.range ? this.minH.rzsp + this.handleHalfDim : 0);
|
868 |
| - if(this.options.getSelectionBarColor) { |
| 879 | + if (this.options.getSelectionBarColor) { |
869 | 880 | var color = this.options.getSelectionBarColor();
|
870 | 881 | this.selBarChild.css({backgroundColor: color});
|
871 | 882 | }
|
|
1434 | 1445 | 'use strict';
|
1435 | 1446 |
|
1436 | 1447 | $templateCache.put('rzSliderTpl.html',
|
1437 |
| - "<span class=rz-bar-wrapper><span class=rz-bar></span></span> <span class=rz-bar-wrapper><span class=\"rz-bar rz-selection\"></span></span> <span class=rz-pointer></span> <span class=rz-pointer></span> <span class=\"rz-bubble rz-limit\"></span> <span class=\"rz-bubble rz-limit\"></span> <span class=rz-bubble></span> <span class=rz-bubble></span> <span class=rz-bubble></span><ul ng-show=showTicks class=rz-ticks><li ng-repeat=\"t in ticks\" class=tick ng-class=\"{selected: t.selected}\"><span ng-if=\"t.value != null && t.tooltip == null\" class=tick-value>{{ t.value }}</span> <span ng-if=\"t.value != null && t.tooltip != null\" class=tick-value uib-tooltip=\"{{ t.tooltip }}\" tooltip-placement={{t.tooltipPlacement}}>{{ t.value }}</span></li></ul>" |
| 1448 | + "<span class=rz-bar-wrapper><span class=rz-bar></span></span> <span class=rz-bar-wrapper><span class=\"rz-bar rz-selection\"></span></span> <span class=rz-pointer></span> <span class=rz-pointer></span> <span class=\"rz-bubble rz-limit\"></span> <span class=\"rz-bubble rz-limit\"></span> <span class=rz-bubble></span> <span class=rz-bubble></span> <span class=rz-bubble></span><ul class=rz-ticks></ul>" |
1438 | 1449 | );
|
1439 | 1450 |
|
1440 | 1451 | }]);
|
|
0 commit comments