Skip to content

Commit a4b0f10

Browse files
1 parent 9d0341d commit a4b0f10

File tree

1 file changed

+32
-8
lines changed

1 file changed

+32
-8
lines changed

src/bootstrap-slider.js

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ function init(Survey) {
2828
default: 100
2929
}
3030
]);
31+
Survey.JsonObject.metaData.addProperty("bootstrapslider", {
32+
name: "config",
33+
default: null
34+
});
3135
},
3236
afterRender: function(question, el) {
3337
var inputEl = document.createElement("input");
@@ -42,14 +46,34 @@ function init(Survey) {
4246
question.value || question.rangeMin
4347
);
4448
el.appendChild(inputEl);
45-
var slider = new Slider(inputEl, {
46-
id: question.name + "_" + question.id,
47-
min: question.rangeMin,
48-
max: question.rangeMax,
49-
step: question.step,
50-
enabled: !question.isReadOnly,
51-
value: question.value || question.rangeMin
52-
});
49+
50+
var config = question.config || {};
51+
52+
if (config.id === undefined) {
53+
config.id = question.name + "_" + question.id;
54+
}
55+
56+
if (config.min === undefined) {
57+
config.min = question.rangeMin;
58+
}
59+
60+
if (config.max === undefined) {
61+
config.max = question.rangeMax;
62+
}
63+
64+
if (config.step === undefined) {
65+
config.step = question.step;
66+
}
67+
68+
if (config.enabled === undefined) {
69+
config.enabled = !question.isReadOnly;
70+
}
71+
72+
if (config.value === undefined) {
73+
config.value = question.value || question.rangeMin;
74+
}
75+
76+
var slider = new Slider(inputEl, config);
5377

5478
slider.on("change", function(valueObj) {
5579
question.value = slider.getValue();

0 commit comments

Comments
 (0)