Skip to content

Commit 062cf25

Browse files
GMaxeraValentinH
authored andcommitted
First attempt to add colouring of outside areas for range sliders (#553)
* First attempt to add colouring of outside areas for range sliders * Created dist files * Updated custom-tpl.html * Fixed tests on <span> count * Added rightToLeft support Added test for new option * Created dist files * Fix mistake on assign options on test * Two test for rightToTest false/true * Documented new feature and added demo Changed version to 6.4.0
1 parent feb36f0 commit 062cf25

17 files changed

+185
-45
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ The default options are:
217217
draggableRangeOnly: false,
218218
showSelectionBar: false,
219219
showSelectionBarEnd: false,
220+
showOuterSelectionBars: false,
220221
showSelectionBarFromValue: null,
221222
hidePointerLabels: false,
222223
hideLimitLabels: false,
@@ -333,6 +334,8 @@ Just pass an array with each slider value and that's it; the floor, ceil and ste
333334
334335
**showSelectionBarEnd** - _Boolean (defaults to false)_: Set to true to always show the selection bar after the slider handle.
335336
337+
**showOuterSelectionBars** - _Boolean (defaults to false)_: Only for range slider. Set to true to visualize in different colour the areas on the left/right (top/bottom for vertical range slider) of selection bar between the handles.
338+
336339
**showSelectionBarFromValue** - _Number (defaults to null)_: Set a number to draw the selection bar between this value and the slider handle.
337340
338341
**getSelectionBarColor** - _Function(value) or Function(minVal, maxVal) (defaults to null)_: Function that returns the current color of the selection bar. *If your color won't changed, don't use this option but set it through CSS.* If the returned color depends on a model value (either `rzScopeModel`or `'rzSliderHigh`), you should use the argument passed to the function. Indeed, when the function is called, there is no certainty that the model has already been updated.

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angularjs-slider",
3-
"version": "6.3.0",
3+
"version": "6.4.0",
44
"homepage": "https://github.com/angular-slider/angularjs-slider",
55
"authors": [
66
"Rafal Zajac <rzajac@gmail.com>",

demo/demo.js

+11
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,17 @@ app.controller('MainCtrl', function($scope, $rootScope, $timeout, $uibModal) {
8888
}
8989
};
9090

91+
$scope.outerBarsRangeSlider = {
92+
minValue: 30,
93+
maxValue: 70,
94+
options: {
95+
floor: 0,
96+
ceil: 100,
97+
step: 1,
98+
showOuterSelectionBars: true
99+
}
100+
};
101+
91102
//Slider with selection bar
92103
$scope.slider_visible_bar = {
93104
value: 10,

demo/index.html

+9
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ <h2>Range slider with minimum range of 10 and pushRange option</h2>
8181
></rzslider>
8282
</article>
8383

84+
<article>
85+
<h2>Range slider with coloured bars outside the selected range</h2>
86+
<rzslider
87+
rz-slider-model="outerBarsRangeSlider.minValue"
88+
rz-slider-high="outerBarsRangeSlider.maxValue"
89+
rz-slider-options="outerBarsRangeSlider.options"
90+
></rzslider>
91+
</article>
92+
8493
<article>
8594
<h2>Slider with visible selection bar</h2>
8695
<rzslider

dist/rzslider.css

+14-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rzslider.js

+37-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*! angularjs-slider - v6.3.0 -
22
(c) Rafal Zajac <rzajac@gmail.com>, Valentin Hervieu <valentin@hervieu.me>, Jussi Saarivirta <jusasi@gmail.com>, Angelin Sirbu <angelin.sirbu@gmail.com> -
33
https://github.com/angular-slider/angularjs-slider -
4-
2017-08-07 */
4+
2017-08-11 */
55
/*jslint unparam: true */
66
/*global angular: false, console: false, define, module */
77
(function(root, factory) {
@@ -50,6 +50,7 @@
5050
showSelectionBar: false,
5151
showSelectionBarEnd: false,
5252
showSelectionBarFromValue: null,
53+
showOuterSelectionBars: false,
5354
hidePointerLabels: false,
5455
hideLimitLabels: false,
5556
autoHideLimitLabels: true,
@@ -658,33 +659,39 @@
658659

659660
switch (index) {
660661
case 0:
661-
this.fullBar = jElem;
662+
this.leftOutSelBar = jElem;
662663
break;
663664
case 1:
664-
this.selBar = jElem;
665+
this.rightOutSelBar = jElem;
665666
break;
666667
case 2:
667-
this.minH = jElem;
668+
this.fullBar = jElem;
668669
break;
669670
case 3:
670-
this.maxH = jElem;
671+
this.selBar = jElem;
671672
break;
672673
case 4:
673-
this.flrLab = jElem;
674+
this.minH = jElem;
674675
break;
675676
case 5:
676-
this.ceilLab = jElem;
677+
this.maxH = jElem;
677678
break;
678679
case 6:
679-
this.minLab = jElem;
680+
this.flrLab = jElem;
680681
break;
681682
case 7:
682-
this.maxLab = jElem;
683+
this.ceilLab = jElem;
683684
break;
684685
case 8:
685-
this.cmbLab = jElem;
686+
this.minLab = jElem;
686687
break;
687688
case 9:
689+
this.maxLab = jElem;
690+
break;
691+
case 10:
692+
this.cmbLab = jElem;
693+
break;
694+
case 11:
688695
this.ticks = jElem;
689696
break;
690697
}
@@ -721,6 +728,12 @@
721728
this.alwaysHide(this.maxLab, hideLabelsForTicks || !this.range || this.options.hidePointerLabels);
722729
this.alwaysHide(this.cmbLab, hideLabelsForTicks || !this.range || this.options.hidePointerLabels);
723730
this.alwaysHide(this.selBar, !this.range && !this.options.showSelectionBar);
731+
this.alwaysHide(this.leftOutSelBar, !this.range || !this.options.showOuterSelectionBars);
732+
this.alwaysHide(this.rightOutSelBar, !this.range || !this.options.showOuterSelectionBars);
733+
734+
if ( this.range && this.options.showOuterSelectionBars ) {
735+
this.fullBar.addClass('rz-transparent');
736+
}
724737

725738
if (this.options.vertical)
726739
this.sliderElem.addClass('rz-vertical');
@@ -1281,6 +1294,19 @@
12811294
}
12821295
this.setDimension(this.selBar, dimension);
12831296
this.setPosition(this.selBar, position);
1297+
if (this.range && this.options.showOuterSelectionBars) {
1298+
if (this.options.rightToLeft) {
1299+
this.setDimension(this.rightOutSelBar, position);
1300+
this.setPosition(this.rightOutSelBar, 0);
1301+
this.setDimension(this.leftOutSelBar, this.getDimension(this.fullBar) - (position + dimension));
1302+
this.setPosition(this.leftOutSelBar, position + dimension);
1303+
} else {
1304+
this.setDimension(this.leftOutSelBar, position);
1305+
this.setPosition(this.leftOutSelBar, 0);
1306+
this.setDimension(this.rightOutSelBar, this.getDimension(this.fullBar) - (position + dimension));
1307+
this.setPosition(this.rightOutSelBar, position + dimension);
1308+
}
1309+
}
12841310
if (this.options.getSelectionBarColor) {
12851311
var color = this.getSelectionBarColor();
12861312
this.scope.barStyle = {
@@ -2397,7 +2423,7 @@
23972423
'use strict';
23982424

23992425
$templateCache.put('rzSliderTpl.html',
2400-
"<div class=rzslider><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 rz-pointer-min\" ng-style=minPointerStyle></span> <span class=\"rz-pointer rz-pointer-max\" ng-style=maxPointerStyle></span> <span class=\"rz-bubble rz-limit rz-floor\"></span> <span class=\"rz-bubble rz-limit rz-ceil\"></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=rz-tick ng-class=\"{'rz-selected': t.selected}\" ng-style=t.style ng-attr-uib-tooltip=\"{{ t.tooltip }}\" ng-attr-tooltip-placement={{t.tooltipPlacement}} ng-attr-tooltip-append-to-body=\"{{ t.tooltip ? true : undefined}}\"><span ng-if=\"t.value != null\" class=rz-tick-value ng-attr-uib-tooltip=\"{{ t.valueTooltip }}\" ng-attr-tooltip-placement={{t.valueTooltipPlacement}}>{{ t.value }}</span> <span ng-if=\"t.legend != null\" class=rz-tick-legend>{{ t.legend }}</span></li></ul></div>"
2426+
"<div class=rzslider><span class=\"rz-bar-wrapper rz-left-out-selection\"><span class=rz-bar></span></span> <span class=\"rz-bar-wrapper rz-right-out-selection\"><span class=rz-bar></span></span> <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 rz-pointer-min\" ng-style=minPointerStyle></span> <span class=\"rz-pointer rz-pointer-max\" ng-style=maxPointerStyle></span> <span class=\"rz-bubble rz-limit rz-floor\"></span> <span class=\"rz-bubble rz-limit rz-ceil\"></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=rz-tick ng-class=\"{'rz-selected': t.selected}\" ng-style=t.style ng-attr-uib-tooltip=\"{{ t.tooltip }}\" ng-attr-tooltip-placement={{t.tooltipPlacement}} ng-attr-tooltip-append-to-body=\"{{ t.tooltip ? true : undefined}}\"><span ng-if=\"t.value != null\" class=rz-tick-value ng-attr-uib-tooltip=\"{{ t.valueTooltip }}\" ng-attr-tooltip-placement={{t.valueTooltipPlacement}}>{{ t.value }}</span> <span ng-if=\"t.legend != null\" class=rz-tick-legend>{{ t.legend }}</span></li></ul></div>"
24012427
);
24022428

24032429
}]);

dist/rzslider.min.css

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rzslider.min.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)