1+ import "./utils/surveyjs_importer.js" ;
2+
3+ var widget = {
4+ className : "iradio_square-blue" ,
5+ name : "icheck" ,
6+ isFit : function ( question ) { var t = question . getType ( ) ; return t === 'radiogroup' || t === 'checkbox' || t === 'matrix' ; } ,
7+ isDefaultRender : true ,
8+ afterRender : function ( question , el ) {
9+ var $el = $ ( el ) ;
10+ $ ( el ) . find ( 'input' ) . data ( { "iCheck" : undefined } ) ;
11+ $el . find ( 'input' ) . iCheck ( {
12+ checkboxClass : widget . className ,
13+ radioClass : widget . className
14+ } ) ;
15+ var select = function ( ) {
16+ if ( question . getType ( ) != "matrix" ) {
17+ $el . find ( "input[value=" + question . value + "]" ) . iCheck ( 'check' ) ;
18+ } else {
19+ question . generatedVisibleRows . forEach ( function ( row , index , rows ) {
20+ if ( row . value ) {
21+ $ ( el ) . find ( "input[name='" + row . fullName + "'][value=" + row . value + "]" ) . iCheck ( 'check' ) ;
22+ }
23+ } ) ;
24+ }
25+ }
26+ $el . find ( 'input' ) . on ( 'ifChecked' , function ( event ) {
27+ if ( question . getType ( ) != "matrix" ) {
28+ question . value = event . target . value ;
29+ } else {
30+ question . generatedVisibleRows . forEach ( function ( row , index , rows ) {
31+ if ( row . fullName === event . target . name ) {
32+ row . value = event . target . value
33+ }
34+ } ) ;
35+ }
36+ } ) ;
37+ question . valueChangedCallback = select ;
38+ select ( ) ;
39+ } ,
40+ willUnmount : function ( question , el ) {
41+ var $el = $ ( el ) ;
42+ $el . find ( 'input' ) . iCheck ( 'destroy' ) ;
43+ }
44+ }
45+
46+ Survey . CustomWidgetCollection . Instance . addCustomWidget ( widget , "type" ) ;
0 commit comments