@@ -10,8 +10,7 @@ function init(Survey, $) {
1010 isFit : function ( question ) {
1111 return question . getType ( ) === "datepicker" ;
1212 } ,
13- htmlTemplate :
14- "<input class='form-control widget-datepicker' type='text' style='width: 100%;'>" ,
13+ htmlTemplate : "<input class='form-control widget-datepicker' type='text'>" ,
1514 activatedByChanged : function ( activatedBy ) {
1615 Survey . JsonObject . metaData . addClass (
1716 "datepicker" ,
@@ -26,21 +25,33 @@ function init(Survey, $) {
2625 Survey . JsonObject . metaData . addProperty ( "datepicker" , {
2726 name : "dateFormat"
2827 } ) ;
28+ Survey . JsonObject . metaData . addProperty ( "datepicker" , {
29+ name : "config" ,
30+ default : null
31+ } ) ;
2932 } ,
3033 afterRender : function ( question , el ) {
3134 var $el = $ ( el ) . is ( ".widget-datepicker" )
3235 ? $ ( el )
3336 : $ ( el ) . find ( ".widget-datepicker" ) ;
34- var pickerWidget = $el . datepicker ( {
35- dateFormat : ! ! question . dateFormat ? question . dateFormat : undefined ,
36- option : {
37+ var config = question . config || { } ;
38+ if ( config . dateFormat === undefined ) {
39+ config . dateFormat = ! ! question . dateFormat
40+ ? question . dateFormat
41+ : undefined ;
42+ }
43+ if ( config . option === undefined ) {
44+ config . option = {
3745 minDate : null ,
3846 maxDate : null
39- } ,
40- onSelect : function ( dateText ) {
47+ } ;
48+ }
49+ if ( config . onSelect === undefined ) {
50+ config . onSelect = function ( dateText ) {
4151 question . value = dateText ;
42- }
43- } ) ;
52+ } ;
53+ }
54+ var pickerWidget = $el . datepicker ( config ) ;
4455 question . valueChangedCallback = function ( ) {
4556 if ( question . value ) {
4657 pickerWidget . datepicker ( "setDate" , question . value ) ;
0 commit comments