@@ -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 ;
0 commit comments