|
376 | 376 | this.range = this.scope.rzSliderModel !== undefined && this.scope.rzSliderHigh !== undefined;
|
377 | 377 | this.options.draggableRange = this.range && this.options.draggableRange;
|
378 | 378 | this.options.showTicks = this.options.showTicks || this.options.showTicksValues;
|
| 379 | + this.scope.showTicks = this.options.showTicks; //scope is used in the template |
379 | 380 |
|
380 | 381 | if (this.options.stepsArray) {
|
381 | 382 | this.options.floor = 0;
|
|
488 | 489 | this.alwaysHide(this.cmbLab, this.options.showTicksValues || !this.range);
|
489 | 490 | this.alwaysHide(this.selBar, !this.range && !this.options.showSelectionBar);
|
490 | 491 |
|
491 |
| - if (!this.options.showTicks) |
492 |
| - this.ticks.html(''); |
493 |
| - |
494 | 492 | if (this.options.draggableRange)
|
495 | 493 | this.selBar.addClass('rz-draggable');
|
496 | 494 | else
|
|
657 | 655 | */
|
658 | 656 | updateTicksScale: function() {
|
659 | 657 | if (!this.options.showTicks) return;
|
660 |
| - if (!this.step) return; //if step is 0, the following loop will be endless. |
| 658 | + if (!this.step) return; //if step is 0, we'll get a zero division |
661 | 659 |
|
662 | 660 | var positions = '',
|
663 | 661 | ticksCount = Math.round((this.maxValue - this.minValue) / this.step) + 1;
|
| 662 | + this.scope.ticks = []; |
664 | 663 | for (var i = 0; i < ticksCount; i++) {
|
665 | 664 | var value = this.roundStep(this.minValue + i * this.step);
|
666 |
| - var selectedClass = this.isTickSelected(value) ? 'selected' : ''; |
667 |
| - positions += '<li class="tick ' + selectedClass + '">'; |
| 665 | + var tick = { |
| 666 | + selected: this.isTickSelected(value) |
| 667 | + }; |
668 | 668 | if (this.options.showTicksValues) {
|
669 |
| - var tooltip = ''; |
| 669 | + tick.value = this.getDisplayValue(value); |
670 | 670 | if (this.options.ticksValuesTooltip) {
|
671 |
| - tooltip = 'uib-tooltip="' + this.options.ticksValuesTooltip(value) + '"'; |
672 |
| - if (this.options.vertical) |
673 |
| - tooltip += ' tooltip-placement="right"' |
| 671 | + tick.tooltip = this.options.ticksValuesTooltip(value); |
| 672 | + tick.tooltipPlacement = this.options.vertical ? 'right' : 'top'; |
674 | 673 | }
|
675 |
| - positions += '<span ' + tooltip + ' class="tick-value">' + this.getDisplayValue(value) + '</span>'; |
676 | 674 | }
|
677 |
| - positions += '</li>'; |
| 675 | + this.scope.ticks.push(tick); |
678 | 676 | }
|
679 |
| - this.ticks.html(positions); |
680 |
| - if (this.options.ticksValuesTooltip) |
681 |
| - $compile(this.ticks.contents())(this.scope); |
682 | 677 | },
|
683 | 678 |
|
684 | 679 | isTickSelected: function(value) {
|
|
1433 | 1428 | 'use strict';
|
1434 | 1429 |
|
1435 | 1430 | $templateCache.put('rzSliderTpl.html',
|
1436 |
| - "<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>" |
| 1431 | + "<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>" |
1437 | 1432 | );
|
1438 | 1433 |
|
1439 | 1434 | }]);
|
|
0 commit comments