Skip to content

Commit be55de3

Browse files
auto merge
2 parents d6258b4 + e8be161 commit be55de3

File tree

12 files changed

+68
-15
lines changed

12 files changed

+68
-15
lines changed

README.md

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
## Widgets
2+
13
- select2: [site](https://select2.org/), [repo](https://github.com/select2/select2), license: MIT
24

35
- select2tagbox: [site](https://select2.org/), [repo](https://github.com/select2/select2), license: MIT
@@ -20,6 +22,48 @@
2022

2123
- ckeditor: [site](https://ckeditor.com/ckeditor-4/), [repo](https://github.com/ckeditor/ckeditor-dev), license: https://github.com/ckeditor/ckeditor-dev/blob/major/LICENSE.md
2224

23-
24-
# examples of usage
25+
## Getting started
26+
es5 examples: https://surveyjs.io/Examples/Library/?id=custom-widget-select2-tagbox
2527
es moules examples: https://stackblitz.com/edit/surveyjs-widgets-react
28+
29+
Install the library using es5.
30+
```
31+
<script src="https://unpkg.com/surveyjs-widgets"></script>
32+
```
33+
Install the library using npm.
34+
35+
```
36+
npm install surveyjs-widgets
37+
```
38+
39+
Or use Azure CDN:
40+
https://surveyjs.azureedge.net/0.95.0/surveyjs-widgets.min.js
41+
42+
You find all versions/builds in the [surveyjs/build repo](https://github.com/surveyjs/builds).
43+
44+
45+
## Building surveyjs-widgets from sources
46+
47+
To build library yourself:
48+
49+
1. **Clone the repo from GitHub**
50+
```
51+
git clone https://github.com/surveyjs/surveyjs-widgets.git
52+
cd surveyjs-widgets
53+
```
54+
55+
2. **Acquire build dependencies.** Make sure you have [Node.js](http://nodejs.org/) installed on your workstation. This is only needed to _build_ surveyjs from sources.
56+
```
57+
npm install
58+
```
59+
60+
3. **Build the library**
61+
```
62+
npm run build
63+
```
64+
After that you should have the libraries (angular, jquery, knockout, react and vue) at 'packages' directory.
65+
66+
67+
## License
68+
69+
[MIT license](https://github.com/surveyjs/widgets/blob/master/LICENSE)

src/ck-editor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ function init(Survey) {
33
name: "editor",
44
title: "Editor",
55
iconName: "icon-editor",
6-
widgetIsLoaded: function() { return typeof CKEDITOR !== undefined; },
6+
widgetIsLoaded: function() { return typeof CKEDITOR != "undefined"; },
77
isFit : function(question) {
88
return question.getType() === 'editor';
99
},

src/icheck.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ function init(Survey) {
22
var widget = {
33
className: "iradio_square-blue",
44
name: "icheck",
5+
widgetIsLoaded: function() { return typeof $ == 'function' && !!$.fn.iCheck; },
56
isFit : function(question) {
6-
if(typeof iCheck == undefined && typeof _iCheck == undefined) return false;
77
var t = question.getType(); return t === 'radiogroup' || t === 'checkbox' || t === 'matrix';
88
},
99
isDefaultRender: true,

src/image-picker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ function init(Survey) {
33
name: "imagepicker",
44
title: "Image picker",
55
iconName: "icon-imagepicker",
6-
widgetIsLoaded: function() { return !!$.fn.imagepicker; },
6+
widgetIsLoaded: function() { return typeof $ == 'function' && !!$.fn.imagepicker; },
77
isFit : function(question) { return question.getType() === 'imagepicker'; },
88
isDefaultRender: true,
99
activatedByChanged: function(activatedBy) {

src/inputmask.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ function init(Survey) {
99
numericDigitsOptional: false,
1010
numericPrefix: '$',
1111
numericPlaceholder: '0',
12+
widgetIsLoaded: function() { return typeof Inputmask != "undefined"; },
1213
isFit : function(question) {
13-
if(typeof Inputmask == undefined) return false;
1414
if(question.getType() == "multipletext") return true;
1515
return question.getType() == "text" && (question.inputMask != "none" || question.inputFormat);
1616
},

src/jquery-bar-rating.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ function init(Survey) {
33
name: "barrating",
44
title: "Bar rating",
55
iconName: "icon-barrating",
6-
widgetIsLoaded: function() { return typeof Barrating !== undefined; },
6+
widgetIsLoaded: function() { return !!$.fn.barrating; },
77
defaultJSON: {choices: [1, 2, 3, 4, 5]},
8-
isFit : function(question) { return question.getType() === 'barrating'; },
8+
isFit : function(question) { return typeof $ == 'function' && !!$.fn.barrating; },
99
isDefaultRender: true,
1010
activatedByChanged: function(activatedBy) {
1111
Survey.JsonObject.metaData.addClass("barrating", [ {name: "showValues:boolean", default: false},

src/jquery-ui-datepicker.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ function init(Survey) {
33
name: "datepicker",
44
title: "Date picker",
55
iconName: "icon-datepicker",
6-
widgetIsLoaded: function() { return typeof DatePicker !== undefined; },
6+
widgetIsLoaded: function() { return typeof $ == 'function' && !!$.fn.datepicker; },
77
isFit : function(question) { return question.getType() === 'datepicker'; },
88
htmlTemplate: "<input class='widget-datepicker' type='text' style='width: 100%;'>",
99
activatedByChanged: function(activatedBy) {
@@ -15,15 +15,22 @@ function init(Survey) {
1515
var $el = $(el).is(".widget-datepicker") ? $(el) : $(el).find(".widget-datepicker");
1616
var pickerWidget = $el.datepicker({
1717
dateFormat: question.dateFormat,
18+
option: {
19+
minDate: null,
20+
maxDate: null
21+
},
1822
onSelect: function(dateText) {
1923
question.value = dateText;
2024
}
2125
});
2226
question.valueChangedCallback = function() {
23-
pickerWidget.datepicker('setDate', new Date(question.value));
27+
if(question.value) {
28+
pickerWidget.datepicker('setDate', new Date(question.value));
29+
} else {
30+
pickerWidget.datepicker('setDate', null);
31+
}
2432
}
2533
question.valueChangedCallback();
26-
if(!question.value) question.value = new Date();
2734
},
2835
willUnmount: function(question, el) {
2936
var $el = $(el).is(".widget-datepicker") ? $(el) : $(el).find(".widget-datepicker");

src/nouislider.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function init(Survey) {
55
name: "nouislider",
66
title: "noUiSlider",
77
iconName: "icon-nouislider",
8-
widgetIsLoaded: function() { return typeof noUiSlider !== undefined; },
8+
widgetIsLoaded: function() { return typeof noUiSlider != "undefined"; },
99
isFit : function(question) { return question.getType() === 'nouislider'; },
1010
htmlTemplate: "<div></div>",
1111
activatedByChanged: function(activatedBy) {

src/select2-tagbox.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function init(Survey) {
55
name: "tagbox",
66
title: "Tag box",
77
iconName: "icon-tagbox",
8-
widgetIsLoaded: function() { return typeof Select2 !== undefined; },
8+
widgetIsLoaded: function() { return typeof $ == 'function' && !!$.fn.select2; },
99
defaultJSON: {choices: ["Item 1", "Item 2", "Item 3"]},
1010
htmlTemplate: "<select multiple='multiple' style='width: 100%;'></select>",
1111
isFit : function(question) { return question.getType() === 'tagbox'; },

src/select2.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ function init(Survey) {
55
activatedBy: "property",
66
name: "select2",
77
htmlTemplate: "<select style='width: 100%;'></select>",
8+
widgetIsLoaded: function() { return typeof $ == 'function' && !!$.fn.select2; },
89
isFit : function(question) {
910
if(widget.activatedBy == "property") return question["renderAs"] === 'select2' && question.getType() === 'dropdown';
1011
if(widget.activatedBy == "type") return typeof Select2 !== undefined && question.getType() === 'dropdown';
1112
if(widget.activatedBy == "customtype") return question.getType() === 'select2';
1213
return false;
1314
},
1415
activatedByChanged: function(activatedBy) {
16+
if(!this.widgetIsLoaded()) return;
1517
widget.activatedBy = activatedBy;
1618
Survey.JsonObject.metaData.removeProperty("dropdown", "renderAs");
1719
if(activatedBy == "property") {

0 commit comments

Comments
 (0)