Skip to content

Commit 8902c55

Browse files
committed
feat(hidePointerLabels): Add a hidePointerLabels option
Closes #273
1 parent 30d82df commit 8902c55

File tree

5 files changed

+50
-8
lines changed

5 files changed

+50
-8
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ The default options are:
193193
showSelectionBar: false,
194194
showSelectionBarEnd: false,
195195
showSelectionBarFromValue: null,
196+
hidePointerLabels: false,
196197
hideLimitLabels: false,
197198
readOnly: false,
198199
disabled: false,
@@ -274,6 +275,8 @@ $scope.slider = {
274275

275276
**getPointerColor** - _Function(value, pointerType) (defaults to null)_: Function that returns the current color of a pointer. 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. To handle range slider pointers independently, you should evaluate pointerType within the given function where "min" stands for `rzScopeModel` and "max" for `rzScopeHigh` values.
276277

278+
**hidePointerLabels** - _Boolean (defaults to false)_: Set to true to hide pointer labels
279+
277280
**hideLimitLabels** - _Boolean (defaults to false)_: Set to true to hide min / max labels
278281

279282
**readOnly** - _Boolean (defaults to false)_: Set to true to make the slider read-only.

dist/rzslider.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
showSelectionBar: false,
4141
showSelectionBarEnd: false,
4242
showSelectionBarFromValue: null,
43+
hidePointerLabels: false,
4344
hideLimitLabels: false,
4445
readOnly: false,
4546
disabled: false,
@@ -531,9 +532,9 @@
531532

532533
this.alwaysHide(this.flrLab, this.options.showTicksValues || this.options.hideLimitLabels);
533534
this.alwaysHide(this.ceilLab, this.options.showTicksValues || this.options.hideLimitLabels);
534-
this.alwaysHide(this.minLab, this.options.showTicksValues);
535-
this.alwaysHide(this.maxLab, this.options.showTicksValues || !this.range);
536-
this.alwaysHide(this.cmbLab, this.options.showTicksValues || !this.range);
535+
this.alwaysHide(this.minLab, this.options.showTicksValues || this.options.hidePointerLabels);
536+
this.alwaysHide(this.maxLab, this.options.showTicksValues || !this.range || this.options.hidePointerLabels);
537+
this.alwaysHide(this.cmbLab, this.options.showTicksValues || !this.range || this.options.hidePointerLabels);
537538
this.alwaysHide(this.selBar, !this.range && !this.options.showSelectionBar);
538539

539540
if (this.options.vertical)

dist/rzslider.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/rzslider.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
showSelectionBar: false,
4545
showSelectionBarEnd: false,
4646
showSelectionBarFromValue: null,
47+
hidePointerLabels: false,
4748
hideLimitLabels: false,
4849
readOnly: false,
4950
disabled: false,
@@ -535,9 +536,9 @@
535536

536537
this.alwaysHide(this.flrLab, this.options.showTicksValues || this.options.hideLimitLabels);
537538
this.alwaysHide(this.ceilLab, this.options.showTicksValues || this.options.hideLimitLabels);
538-
this.alwaysHide(this.minLab, this.options.showTicksValues);
539-
this.alwaysHide(this.maxLab, this.options.showTicksValues || !this.range);
540-
this.alwaysHide(this.cmbLab, this.options.showTicksValues || !this.range);
539+
this.alwaysHide(this.minLab, this.options.showTicksValues || this.options.hidePointerLabels);
540+
this.alwaysHide(this.maxLab, this.options.showTicksValues || !this.range || this.options.hidePointerLabels);
541+
this.alwaysHide(this.cmbLab, this.options.showTicksValues || !this.range || this.options.hidePointerLabels);
541542
this.alwaysHide(this.selBar, !this.range && !this.options.showSelectionBar);
542543

543544
if (this.options.vertical)

tests/specs/options-handling-test.js

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,43 @@
244244
expect(helper.slider.selBar.css('left')).to.equal(expectedPosition + 'px');
245245
});
246246

247+
it('should set alwaysHide on floor/ceil when hideLimitLabels is set to true', function() {
248+
var sliderConf = {
249+
value: 10,
250+
options: {
251+
hideLimitLabels: true
252+
}
253+
};
254+
helper.createSlider(sliderConf);
255+
expect(helper.slider.flrLab.rzAlwaysHide).to.be.true;
256+
expect(helper.slider.ceilLab.rzAlwaysHide).to.be.true;
257+
});
258+
259+
it('should set alwaysHide on minLab when hidePointerLabels is set to true on a single slider', function() {
260+
var sliderConf = {
261+
value: 10,
262+
options: {
263+
hidePointerLabels: true
264+
}
265+
};
266+
helper.createSlider(sliderConf);
267+
expect(helper.slider.minLab.rzAlwaysHide).to.be.true;
268+
});
269+
270+
it('should set alwaysHide on minLab when hidePointerLabels is set to true on a single slider', function() {
271+
var sliderConf = {
272+
min: 10,
273+
max: 100,
274+
options: {
275+
hidePointerLabels: true
276+
}
277+
};
278+
helper.createRangeSlider(sliderConf);
279+
expect(helper.slider.minLab.rzAlwaysHide).to.be.true;
280+
expect(helper.slider.maxLab.rzAlwaysHide).to.be.true;
281+
expect(helper.slider.cmbLab.rzAlwaysHide).to.be.true;
282+
});
283+
247284
it('should set the correct background-color on selection bar for single slider', function() {
248285
var sliderConf = {
249286
value: 10,
@@ -463,7 +500,7 @@
463500
});
464501
});
465502

466-
describe('range slider spcific - ', function() {
503+
describe('range slider specific - ', function() {
467504
beforeEach(function() {
468505
var sliderConf = {
469506
min: 10,

0 commit comments

Comments
 (0)