Skip to content

Commit 9a9db3e

Browse files
committed
feat(options): Add a customTemplateScope option
Close #354
1 parent e999284 commit 9a9db3e

10 files changed

+44
-14
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 5.2.0 (2016-07-07)
2+
## Features
3+
- Add a `customTemplateScope` option (#354).
4+
15
# 5.1.1 (2016-07-06)
26
## Fix
37
- Fix the way to check when event properties are undefined (#365).

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ The default options are:
224224
onEnd: null,
225225
rightToLeft: false,
226226
boundPointerLabels: true,
227-
mergeRangeLabelsIfSame: false
227+
mergeRangeLabelsIfSame: false,
228+
customTemplateScope: null
228229
}
229230
````
230231

@@ -359,6 +360,8 @@ _Changing this value at runtime is not currently supported._
359360
- Home: minimum value
360361
- End: maximum value
361362

363+
**customTemplateScope** - _Object (default to null)_: The properties defined in this object will be exposed in the slider template under `custom.X`.
364+
362365
## Change default options
363366
If you want the change the default options for all the sliders displayed in your application, you can set them using the `RzSliderOptions.options()` method:
364367
```js

bower.json

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

dist/rzslider.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
/*! angularjs-slider - v5.1.1 -
1+
/*! angularjs-slider - v5.2.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-
2016-07-06 */
4+
2016-07-07 */
55
.rzslider {
66
position: relative;
77
display: inline-block;

dist/rzslider.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
/*! angularjs-slider - v5.1.1 -
1+
/*! angularjs-slider - v5.2.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-
2016-07-06 */
4+
2016-07-07 */
55
/*jslint unparam: true */
66
/*global angular: false, console: false, define, module */
77
(function(root, factory) {
@@ -69,7 +69,8 @@
6969
onEnd: null,
7070
rightToLeft: false,
7171
boundPointerLabels: true,
72-
mergeRangeLabelsIfSame: false
72+
mergeRangeLabelsIfSame: false,
73+
customTemplateScope: null
7374
};
7475
var globalOptions = {};
7576

@@ -558,6 +559,9 @@
558559
this.positionProperty = 'bottom';
559560
this.dimensionProperty = 'height';
560561
}
562+
563+
if (this.options.customTemplateScope)
564+
this.scope.custom = this.options.customTemplateScope;
561565
},
562566

563567
parseStepsArray: function() {
@@ -570,7 +574,7 @@
570574
}
571575
else {
572576
this.customTrFn = function(modelValue) {
573-
if(this.options.bindIndexForStepsArray)
577+
if (this.options.bindIndexForStepsArray)
574578
return this.getStepValue(modelValue)
575579
return modelValue;
576580
};

dist/rzslider.min.css

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

dist/rzslider.min.js

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

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angularjs-slider",
3-
"version": "5.1.1",
3+
"version": "5.2.0",
44
"description": "AngularJS slider directive with no external dependencies. Mobile friendly!.",
55
"main": "dist/rzslider.js",
66
"repository": {

src/rzslider.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@
7373
onEnd: null,
7474
rightToLeft: false,
7575
boundPointerLabels: true,
76-
mergeRangeLabelsIfSame: false
76+
mergeRangeLabelsIfSame: false,
77+
customTemplateScope: null
7778
};
7879
var globalOptions = {};
7980

@@ -562,6 +563,9 @@
562563
this.positionProperty = 'bottom';
563564
this.dimensionProperty = 'height';
564565
}
566+
567+
if (this.options.customTemplateScope)
568+
this.scope.custom = this.options.customTemplateScope;
565569
},
566570

567571
parseStepsArray: function() {
@@ -574,7 +578,7 @@
574578
}
575579
else {
576580
this.customTrFn = function(modelValue) {
577-
if(this.options.bindIndexForStepsArray)
581+
if (this.options.bindIndexForStepsArray)
578582
return this.getStepValue(modelValue)
579583
return modelValue;
580584
};

tests/specs/options-handling-test.js

+15
Original file line numberDiff line numberDiff line change
@@ -1307,6 +1307,21 @@
13071307
expect(maxHChild.css('background-color')).to.equal('blue');
13081308

13091309
});
1310+
1311+
it('should correctly link the customTemplateScope properties on slider scope', function() {
1312+
var sliderConf = {
1313+
value: 10,
1314+
options: {
1315+
customTemplateScope: {
1316+
a: 1,
1317+
b: 'test'
1318+
}
1319+
}
1320+
};
1321+
helper.createSlider(sliderConf);
1322+
expect(helper.slider.scope.custom.a).to.equal(1)
1323+
expect(helper.slider.scope.custom.b).to.equal('test')
1324+
});
13101325
});
13111326

13121327
describe('range slider specific - ', function() {

0 commit comments

Comments
 (0)