Skip to content

Commit 783c663

Browse files
Merge branch 'master' of https://github.com/surveyjs/widgets
2 parents 68df03c + 94e821d commit 783c663

File tree

7 files changed

+22
-19
lines changed

7 files changed

+22
-19
lines changed

src/easy-autocomplete.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ function init(Survey, $) {
33
var widget = {
44
name: "autocomplete",
55
widgetIsLoaded: function() {
6-
return !!$.fn.easyAutocomplete;
6+
return typeof $ == "function" && !!$.fn.easyAutocomplete;
77
},
88
isFit: function(question) {
99
return question.getType() === "text";

src/emotionsratings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function init(Survey, $) {
66
title: "Emotions Ratings",
77
iconName: "icon-emotionsratings",
88
widgetIsLoaded: function() {
9-
return !!$.fn.emotionsRating;
9+
return typeof $ == "function" && !!$.fn.emotionsRating;
1010
},
1111
defaultJSON: {
1212
choices: [1, 2, 3, 4, 5]

src/icheck.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ function init(Survey, $) {
33
var widget = {
44
className: "iradio_square-blue",
55
name: "icheck",
6-
widgetIsLoaded: function () {
7-
return !!$.fn.iCheck;
6+
widgetIsLoaded: function() {
7+
return typeof $ == "function" && !!$.fn.iCheck;
88
},
9-
isFit: function (question) {
9+
isFit: function(question) {
1010
var t = question.getType();
1111
return t === "radiogroup" || t === "checkbox" || t === "matrix";
1212
},
1313
isDefaultRender: true,
14-
afterRender: function (question, el) {
14+
afterRender: function(question, el) {
1515
var rootWidget = this;
1616
var $el = $(el);
1717
$el.find("input").data({
@@ -22,17 +22,17 @@ function init(Survey, $) {
2222
checkboxClass: rootWidget.className,
2323
radioClass: rootWidget.className
2424
});
25-
var select = function () {
25+
var select = function() {
2626
if (question.getType() !== "matrix") {
2727
var values = question.value;
2828
if (!Array.isArray(values)) {
2929
values = [values];
3030
}
31-
values.forEach(function (value) {
31+
values.forEach(function(value) {
3232
$el.find("input[value=" + value + "]").iCheck("check");
3333
});
3434
} else {
35-
question.generatedVisibleRows.forEach(function (row, index, rows) {
35+
question.generatedVisibleRows.forEach(function(row, index, rows) {
3636
if (row.value) {
3737
$(el)
3838
.find(
@@ -43,9 +43,9 @@ function init(Survey, $) {
4343
});
4444
}
4545
};
46-
$el.find("input").on("ifChecked", function (event) {
46+
$el.find("input").on("ifChecked", function(event) {
4747
if (question.getType() === "matrix") {
48-
question.generatedVisibleRows.forEach(function (row, index, rows) {
48+
question.generatedVisibleRows.forEach(function(row, index, rows) {
4949
if (row.fullName === event.target.name) {
5050
row.value = event.target.value;
5151
}
@@ -60,7 +60,7 @@ function init(Survey, $) {
6060
question.value = event.target.value;
6161
}
6262
});
63-
$el.find("input").on("ifUnchecked", function (event) {
63+
$el.find("input").on("ifUnchecked", function(event) {
6464
if (question.getType() === "checkbox") {
6565
var oldValue = question.value || [];
6666
var index = oldValue.indexOf(event.target.value);
@@ -73,7 +73,7 @@ function init(Survey, $) {
7373
question.valueChangedCallback = select;
7474
select();
7575
},
76-
willUnmount: function (question, el) {
76+
willUnmount: function(question, el) {
7777
var $el = $(el);
7878
$el.find("input").iCheck("destroy");
7979
}
@@ -86,4 +86,4 @@ if (typeof Survey !== "undefined") {
8686
init(Survey, window.$);
8787
}
8888

89-
export default init;
89+
export default init;

src/image-picker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function init(Survey, $) {
55
title: "Image picker",
66
iconName: "icon-imagepicker",
77
widgetIsLoaded: function() {
8-
return !!$.fn.imagepicker;
8+
return typeof $ == "function" && !!$.fn.imagepicker;
99
},
1010
isFit: function(question) {
1111
return question.getType() === "imagepicker";

src/jquery-bar-rating.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function init(Survey, $) {
55
title: "Bar rating",
66
iconName: "icon-barrating",
77
widgetIsLoaded: function() {
8-
return !!$.fn.barrating;
8+
return typeof $ == "function" && !!$.fn.barrating;
99
},
1010
defaultJSON: { choices: [1, 2, 3, 4, 5] },
1111
isFit: function(question) {

src/jquery-ui-datepicker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function init(Survey, $) {
55
title: "Date picker",
66
iconName: "icon-datepicker",
77
widgetIsLoaded: function() {
8-
return !!$.fn.datepicker;
8+
return !!$ && !!$.fn.datepicker;
99
},
1010
isFit: function(question) {
1111
return question.getType() === "datepicker";

src/nouislider.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ function init(Survey) {
3030
]);
3131
},
3232
afterRender: function(question, el) {
33-
question.value = (question.rangeMin + question.rangeMax) / 2;
33+
if (question.isEmpty()) {
34+
question.value = (question.rangeMin + question.rangeMax) / 2;
35+
}
3436

3537
el.style.marginBottom = "50px";
3638
var slider = noUiSlider.create(el, {
@@ -57,6 +59,7 @@ function init(Survey) {
5759
if (question.isReadOnly) {
5860
el.setAttribute("disabled", true);
5961
}
62+
updateValueHandler();
6063
question.noUiSlider = slider;
6164
question.valueChangedCallback = updateValueHandler;
6265
question.readOnlyChangedCallback = function() {
@@ -65,7 +68,7 @@ function init(Survey) {
6568
} else {
6669
el.removeAttribute("disabled");
6770
}
68-
}
71+
};
6972
},
7073
willUnmount: function(question, el) {
7174
question.noUiSlider.destroy();

0 commit comments

Comments
 (0)