Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat($compile): adds labelOverlapSeparator as an option #616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ bower_components/
temp/
tests/coverage/
yarn.lock
cypress/videos
cypress/videos
npm-debug.log
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ The default options are:
reversedControls: false,
boundPointerLabels: true,
mergeRangeLabelsIfSame: false,
labelOverlapSeparator: ' - ',
customTemplateScope: null,
logScale: false,
customValueToPosition: null,
Expand Down Expand Up @@ -413,6 +414,8 @@ Just pass an array with each slider value and that's it; the floor, ceil and ste

**mergeRangeLabelsIfSame** - _Boolean (defaults to false)_: Set to true to merge the range labels if they are the same. For instance, if min and max are 50, the label will be "50 - 50" if `mergeRangeLabelsIfSame: false`, else "50".

**labelOverlapSeparator** - _String (defaults to ' - ')_: Separator to use when the labels overlap. For instance, if min and max are -1 and 1, the label will be "-1 .. 1" if `labelOverlapSeparator: ' .. '`.

**onStart** - _Function(sliderId, modelValue, highValue, pointerType)_: Function to be called when a slider update is started. If an id was set in the options, then it's passed to this callback. This callback is called before any update on the model. `pointerType` is either 'min' or 'max' depending on which handle is used.

**onChange** - _Function(sliderId, modelValue, highValue, pointerType)_: Function to be called when rz-slider-model or rz-slider-high change. If an id was set in the options, then it's passed to this callback. `pointerType` is either 'min' or 'max' depending on which handle is used.
Expand Down
6 changes: 3 additions & 3 deletions dist/rzslider.css

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions dist/rzslider.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*! angularjs-slider - v6.4.3 -
/*! angularjs-slider - v6.4.4 -
(c) Rafal Zajac <[email protected]>, Valentin Hervieu <[email protected]>, Jussi Saarivirta <[email protected]>, Angelin Sirbu <[email protected]> -
https://github.com/angular-slider/angularjs-slider -
2018-01-22 */
2018-02-06 */
/*jslint unparam: true */
/*global angular: false, console: false, define, module */
;(function(root, factory) {
Expand Down Expand Up @@ -78,6 +78,7 @@
reversedControls: false,
boundPointerLabels: true,
mergeRangeLabelsIfSame: false,
labelOverlapSeparator: ' - ',
customTemplateScope: null,
logScale: false,
customValueToPosition: null,
Expand Down Expand Up @@ -1473,8 +1474,8 @@
labelVal = lowTr
} else {
labelVal = this.options.rightToLeft
? highTr + ' - ' + lowTr
: lowTr + ' - ' + highTr
? highTr + this.options.labelOverlapSeparator + lowTr
: lowTr + this.options.labelOverlapSeparator + highTr
}

this.translateFn(labelVal, this.cmbLab, 'cmb', false)
Expand Down
2 changes: 1 addition & 1 deletion dist/rzslider.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions dist/rzslider.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/rzslider.scss

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/rzslider.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
reversedControls: false,
boundPointerLabels: true,
mergeRangeLabelsIfSame: false,
labelOverlapSeparator: ' - ',
customTemplateScope: null,
logScale: false,
customValueToPosition: null,
Expand Down Expand Up @@ -1477,8 +1478,8 @@
labelVal = lowTr
} else {
labelVal = this.options.rightToLeft
? highTr + ' - ' + lowTr
: lowTr + ' - ' + highTr
? highTr + this.options.labelOverlapSeparator + lowTr
: lowTr + this.options.labelOverlapSeparator + highTr
}

this.translateFn(labelVal, this.cmbLab, 'cmb', false)
Expand Down
33 changes: 33 additions & 0 deletions tests/specs/options-handling-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1646,6 +1646,39 @@
parseInt(helper.slider.leftOutSelBar.css('left'))
)
})

it('should use the default separator when labels overlap', function() {
helper.scope.slider.min = -1
helper.scope.slider.max = 1
helper.scope.slider.options.floor = -100
helper.scope.slider.options.ceil = +100
helper.scope.slider.options.step = 1
helper.scope.slider.options.rightToLeft = false
helper.scope.$digest()
expect(helper.slider.cmbLab.text()).to.equal('-1 - 1')
})

it('should use the custom separator when labels overlap, and labelOverlapSeparator is set', function() {
helper.scope.slider.min = -1
helper.scope.slider.max = 1
helper.scope.slider.options.floor = -100
helper.scope.slider.options.ceil = +100
helper.scope.slider.options.step = 1
helper.scope.slider.options.rightToLeft = false
helper.scope.slider.options.labelOverlapSeparator = ' .. '
helper.scope.$digest()
expect(helper.slider.cmbLab.text()).to.equal('-1 .. 1')
})
it('should use the custom separator when labels overlap, and labelOverlapSeparator is set, in RTL mode', function() {
helper.scope.slider.min = -1
helper.scope.slider.max = 1
helper.scope.slider.options.floor = -100
helper.scope.slider.options.ceil = +100
helper.scope.slider.options.step = 1
helper.scope.slider.options.labelOverlapSeparator = ' .. '
helper.scope.$digest()
expect(helper.slider.cmbLab.text()).to.equal('1 .. -1')
})
})

describe('options expression specific - ', function() {
Expand Down