|
50 | 50 | showTicksValues: false, |
51 | 51 | ticksValuesTooltip: null, |
52 | 52 | vertical: false, |
| 53 | + selectionBarColor: null, |
53 | 54 | scale: 1, |
54 | 55 | onStart: null, |
55 | 56 | onChange: null, |
|
432 | 433 | break; |
433 | 434 | case 1: |
434 | 435 | this.selBar = jElem; |
| 436 | + this.selBarChild = this.selBar.children('rz-selection'); |
435 | 437 | break; |
436 | 438 | case 2: |
437 | 439 | this.minH = jElem; |
|
472 | 474 | this.cmbLab.rzsp = 0; |
473 | 475 | }, |
474 | 476 |
|
475 | | - /** Update each elements style based on options |
476 | | - * |
| 477 | + /** |
| 478 | + * Update each elements style based on options |
477 | 479 | */ |
478 | 480 | manageElementsStyle: function() { |
479 | 481 |
|
|
662 | 664 | this.scope.ticks = []; |
663 | 665 | for (var i = 0; i < ticksCount; i++) { |
664 | 666 | var value = this.roundStep(this.minValue + i * this.step); |
665 | | - var tick = { |
| 667 | + var tick = { |
666 | 668 | selected: this.isTickSelected(value) |
667 | 669 | }; |
| 670 | + if (tick.selected && this.options.getSelectionBarColor) { |
| 671 | + tick.style = { |
| 672 | + 'background-color': this.getSelectionBarColor() |
| 673 | + }; |
| 674 | + } |
668 | 675 | if (this.options.showTicksValues) { |
669 | 676 | tick.value = this.getDisplayValue(value); |
670 | 677 | if (this.options.ticksValuesTooltip) { |
|
863 | 870 | updateSelectionBar: function() { |
864 | 871 | this.setDimension(this.selBar, Math.abs(this.maxH.rzsp - this.minH.rzsp) + this.handleHalfDim); |
865 | 872 | this.setPosition(this.selBar, this.range ? this.minH.rzsp + this.handleHalfDim : 0); |
| 873 | + if (this.options.getSelectionBarColor) { |
| 874 | + var color = this.getSelectionBarColor(); |
| 875 | + this.scope.barStyle = { |
| 876 | + backgroundColor: color |
| 877 | + }; |
| 878 | + } |
| 879 | + }, |
| 880 | + |
| 881 | + /** |
| 882 | + * Wrapper around the getSelectionBarColor of the user to pass to |
| 883 | + * correct parameters |
| 884 | + */ |
| 885 | + getSelectionBarColor: function() { |
| 886 | + if (this.range) |
| 887 | + return this.options.getSelectionBarColor(this.scope.rzSliderModel, this.scope.rzSliderHigh); |
| 888 | + return this.options.getSelectionBarColor(this.scope.rzSliderModel); |
866 | 889 | }, |
867 | 890 |
|
868 | 891 | /** |
|
1305 | 1328 | valueChanged = true; |
1306 | 1329 | } |
1307 | 1330 |
|
1308 | | - if(valueChanged) { |
| 1331 | + if (valueChanged) { |
1309 | 1332 | this.scope.$apply(); |
1310 | 1333 | this.callOnChange(); |
1311 | 1334 | } |
|
1428 | 1451 | 'use strict'; |
1429 | 1452 |
|
1430 | 1453 | $templateCache.put('rzSliderTpl.html', |
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>" |
| 1454 | + "<span class=rz-bar-wrapper><span class=rz-bar></span></span> <span class=rz-bar-wrapper><span class=\"rz-bar rz-selection\" ng-style=barStyle></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 track by $index\" class=tick ng-class=\"{selected: t.selected}\" ng-style=t.style><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>" |
1432 | 1455 | ); |
1433 | 1456 |
|
1434 | 1457 | }]); |
|
0 commit comments