Skip to content

Commit 21501a0

Browse files
auto merge
2 parents 2938161 + 24d5a36 commit 21501a0

12 files changed

+90
-11
lines changed

src/ck-editor.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
function init(Survey) {
2+
var widget = {
3+
name: "editor",
4+
title: "Editor",
5+
iconName: "icon-editor",
6+
widgetIsLoaded: function() { return typeof CKEDITOR !== undefined; },
7+
isFit : function(question) {
8+
return question.getType() === 'editor';
9+
},
10+
htmlTemplate: "<textarea rows='10' cols='80' style: {width:'100%'}></textarea>",
11+
activatedByChanged: function(activatedBy) {
12+
Survey.JsonObject.metaData.addClass("editor", [], null, "empty");
13+
Survey.JsonObject.metaData.addProperty("editor", {name: "height", default: 300});
14+
},
15+
afterRender: function(question, el) {
16+
CKEDITOR.editorConfig = function (config) {
17+
config.language = 'es';
18+
config.height = question.height;
19+
config.toolbarCanCollapse = true;
20+
};
21+
var editor = CKEDITOR.replace(el);
22+
var isValueChanging = false;
23+
var updateValueHandler = function() {
24+
if(isValueChanging) return;
25+
editor.setData(question.value);
26+
};
27+
editor.on('change', function() {
28+
isValueChanging = true;
29+
question.value = editor.getData();
30+
isValueChanging = false;
31+
});
32+
question.valueChangedCallback = updateValueHandler;
33+
updateValueHandler();
34+
},
35+
willUnmount: function(question, el) {
36+
}
37+
}
38+
39+
Survey.CustomWidgetCollection.Instance.addCustomWidget(widget, "customtype");
40+
}
41+
42+
if (typeof Survey !== "undefined") {
43+
init(Survey);
44+
}
45+
46+
export default init;

src/icheck.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ function init(Survey) {
22
var widget = {
33
className: "iradio_square-blue",
44
name: "icheck",
5-
isFit : function(question) { var t = question.getType(); return t === 'radiogroup' || t === 'checkbox' || t === 'matrix'; },
5+
isFit : function(question) {
6+
if(typeof iCheck == undefined && typeof _iCheck == undefined) return false;
7+
var t = question.getType(); return t === 'radiogroup' || t === 'checkbox' || t === 'matrix';
8+
},
69
isDefaultRender: true,
710
afterRender: function(question, el) {
811
var rootWidget = this;

src/image-picker.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ import $ from 'jquery';
33
function init(Survey) {
44
var widget = {
55
name: "imagepicker",
6+
title: "Image picker",
7+
iconName: "icon-imagepicker",
8+
widgetIsLoaded: function() { return typeof ImagePicker !== undefined; },
69
isFit : function(question) { return question.getType() === 'imagepicker'; },
710
isDefaultRender: true,
811
activatedByChanged: function(activatedBy) {
912
Survey.JsonObject.metaData.addClass("imageitemvalues", [{name: "imageLink"}], null, "itemvalue");
1013
Survey.JsonObject.metaData.addClass("imagepicker", [{name: "choices:imageitemvalues", onGetValue: function (obj) { return Survey.ItemValue.getData(obj.choices); }, onSetValue: function (obj, value) { obj.choices = value; }},
11-
{name:"showLabel:boolean", default: false}, {name:"hasOther", visible: false}], null, "dropdown");
14+
{name:"showLabel:boolean", default: false}, {name:"hasOther", visible: false}, {name: "otherText", visible: false}, {name: "optionsCaption", visible: false},
15+
{name: "otherErrorText", visible: false}, {name: "storeOthersAsComment", visible: false}, {name: "renderAs", visible: false}], null, "dropdown");
1216
},
1317
afterRender: function(question, el) {
1418
var $el = $(el).is("select") ? $(el) : $(el).find("select");

src/inputmask.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ function init(Survey) {
88
numericPrefix: '$',
99
numericPlaceholder: '0',
1010
isFit : function(question) {
11+
if(typeof Inputmask == undefined) return false;
1112
if(question.getType() == "multipletext") return true;
1213
return question.getType() == "text" && (question.inputMask != "none" || question.inputFormat);
1314
},

src/jquery-bar-rating.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
function init(Survey) {
22
var widget = {
33
name: "barrating",
4+
title: "Bar rating",
5+
iconName: "icon-barrating",
6+
widgetIsLoaded: function() { return typeof Barrating !== undefined; },
7+
defaultJSON: {choices: [1, 2, 3, 4, 5]},
48
isFit : function(question) { return question.getType() === 'barrating'; },
59
isDefaultRender: true,
610
activatedByChanged: function(activatedBy) {
7-
Survey.JsonObject.metaData.addClass("barrating", [ {name: "ratingTheme", default: "fontawesome-stars", choices: ["fontawesome-stars", "css-stars", "bars-pill", "bars-1to10", "bars-movie", "bars-square", "bars-reversed", "bars-horizontal", "bootstrap-stars", "fontawesome-stars-o"]},
8-
{name: "showValues", default: false}, {name:"hasOther", visible: false}], null, "dropdown");
11+
Survey.JsonObject.metaData.addClass("barrating", [ {name: "showValues:boolean", default: false},
12+
{name:"hasOther", visible: false}, {name: "otherText", visible: false}, {name: "optionsCaption", visible: false},
13+
{name: "otherErrorText", visible: false}, {name: "storeOthersAsComment", visible: false}, {name: "renderAs", visible: false}], null, "dropdown");
14+
Survey.JsonObject.metaData.addProperty("barrating", {name: "ratingTheme", default: "fontawesome-stars", choices: ["fontawesome-stars", "css-stars", "bars-pill", "bars-1to10", "bars-movie", "bars-square", "bars-reversed", "bars-horizontal", "bootstrap-stars", "fontawesome-stars-o"]});
915
},
1016
afterRender: function(question, el) {
1117
var $el = $(el).is("select") ? $(el) : $(el).find("select");

src/jquery-ui-datepicker.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
function init(Survey) {
22
var widget = {
33
name: "datepicker",
4+
title: "Date picker",
5+
iconName: "icon-datepicker",
6+
widgetIsLoaded: function() { return typeof DatePicker !== undefined; },
47
isFit : function(question) { return question.getType() === 'datepicker'; },
58
htmlTemplate: "<input class='widget-datepicker' type='text' style='width: 100%;'>",
69
activatedByChanged: function(activatedBy) {
710
Survey.JsonObject.metaData.addClass("datepicker",
8-
[{name: "dateFormat", default: "mm/dd/yy", choices: ["mm/dd/yy", "yy-mm-dd", "d M, y", "d MM, y", "DD, d MM, yy", "'day' d 'of' MM 'in the year' yy"]}],
9-
null, "text");
11+
[{name: "dateFormat", default: "mm/dd/yy", choices: ["mm/dd/yy", "yy-mm-dd", "d M, y", "d MM, y", "DD, d MM, yy", "'day' d 'of' MM 'in the year' yy"]},
12+
{name:"inputType", visible: false}, {name:"inputFormat", visible: false}, {name: "inputMask", visible: false}], null, "text");
1013
},
1114
afterRender: function(question, el) {
1215
var $el = $(el).is(".widget-datepicker") ? $(el) : $(el).find(".widget-datepicker");

src/nouislider.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
function init(Survey) {
22
var widget = {
33
name: "nouislider",
4+
title: "noUiSlider",
5+
iconName: "icon-nouislider",
6+
widgetIsLoaded: function() { return typeof noUiSlider !== undefined; },
47
isFit : function(question) { return question.getType() === 'nouislider'; },
58
htmlTemplate: "<div></div>",
69
activatedByChanged: function(activatedBy) {

src/select2-tagbox.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
function init(Survey) {
22
var widget = {
33
name: "tagbox",
4+
title: "Tag box",
5+
iconName: "icon-tagbox",
6+
widgetIsLoaded: function() { return typeof Select2 !== undefined; },
7+
defaultJSON: {choices: ["Item 1", "Item 2", "Item 3"]},
48
htmlTemplate: "<select multiple='multiple' style='width: 100%;'></select>",
59
isFit : function(question) { return question.getType() === 'tagbox'; },
610
activatedByChanged: function(activatedBy) {

src/select2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function init(Survey) {
77
htmlTemplate: "<select style='width: 100%;'></select>",
88
isFit : function(question) {
99
if(widget.activatedBy == "property") return question["renderAs"] === 'select2' && question.getType() === 'dropdown';
10-
if(widget.activatedBy == "type") return question.getType() === 'dropdown';
10+
if(widget.activatedBy == "type") return typeof Select2 !== undefined && question.getType() === 'dropdown';
1111
if(widget.activatedBy == "customtype") return question.getType() === 'select2';
1212
return false;
1313
},

src/signature_pad.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
function init(Survey) {
22
var widget = {
33
name: "signaturepad",
4+
title: "Signature pad",
5+
iconName: "icon-signaturepad",
6+
widgetIsLoaded: function() { return typeof SignaturePad !== undefined; },
47
penColor: "1ab394",
58
isFit : function(question) { return question.getType() === 'signaturepad'; },
9+
htmlTemplate: "<div></div>",
610
activatedByChanged: function(activatedBy) {
711
Survey.JsonObject.metaData.addClass("signaturepad", [], null, "empty");
812
Survey.JsonObject.metaData.addProperties("signaturepad", [{name: "width:number", default: 300}, {name: "height:number", default: 200}]);

0 commit comments

Comments
 (0)