11function  init ( Survey )  { 
2-     var  widget  =  { 
3-         name : "imagepicker" , 
4-         title : "Image picker" , 
5-         iconName : "icon-imagepicker" , 
6-         widgetIsLoaded : function ( )  {  return  typeof  $  ==  'function'  &&  ! ! $ . fn . imagepicker ;  } , 
7-         isFit  : function ( question )  {  return  question . getType ( )  ===  'imagepicker' ;  } , 
8-         isDefaultRender : true , 
9-         activatedByChanged : function ( activatedBy )  { 
10-             Survey . JsonObject . metaData . addClass ( "imageitemvalues" ,  [ { name : "imageLink" } ] ,  null ,  "itemvalue" ) ; 
11-             Survey . JsonObject . metaData . addClass ( "imagepicker" ,  [ { name : "choices:imageitemvalues" ,  onGetValue : function  ( obj )  {  return  Survey . ItemValue . getData ( obj . choices ) ;  } ,  onSetValue : function  ( obj ,  value )  {  obj . choices  =  value ;  } } ,  
12-                 { name :"showLabel:boolean" ,  default : false } ,  { 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-         } , 
15-         afterRender : function ( question ,  el )  { 
16-             var  $el  =  $ ( el ) . is ( "select" )  ? $ ( el )  : $ ( el ) . find ( "select" ) ; 
17-             var  options  =  $el . find ( 'option' ) ; 
18-             var  choices  =  question . choices ; 
2+   var  widget  =  { 
3+     name : 'imagepicker' , 
4+     title : 'Image picker' , 
5+     iconName : 'icon-imagepicker' , 
6+     widgetIsLoaded : function ( )  { 
7+       return  typeof  $  ==  'function'  &&  ! ! $ . fn . imagepicker 
8+     } , 
9+     isFit : function ( question )  { 
10+       return  question . getType ( )  ===  'imagepicker' 
11+     } , 
12+     isDefaultRender : true , 
13+     activatedByChanged : function ( activatedBy )  { 
14+       Survey . JsonObject . metaData . addClass ( 
15+         'imageitemvalues' , 
16+         [ {  name : 'imageLink'  } ] , 
17+         null , 
18+         'itemvalue' 
19+       ) 
20+       Survey . JsonObject . metaData . addClass ( 
21+         'imagepicker' , 
22+         [ 
23+           { 
24+             name : 'choices:imageitemvalues' , 
25+             onGetValue : function ( obj )  { 
26+               return  Survey . ItemValue . getData ( obj . choices ) 
27+             } , 
28+             onSetValue : function ( obj ,  value )  { 
29+               obj . choices  =  value 
30+             } , 
31+           } , 
32+           {  name : 'showLabel:boolean' ,  default : false  } , 
33+           {  name : 'hasOther' ,  visible : false  } , 
34+           {  name : 'otherText' ,  visible : false  } , 
35+           {  name : 'optionsCaption' ,  visible : false  } , 
36+           {  name : 'otherErrorText' ,  visible : false  } , 
37+           {  name : 'storeOthersAsComment' ,  visible : false  } , 
38+           {  name : 'renderAs' ,  visible : false  } , 
39+         ] , 
40+         null , 
41+         'dropdown' 
42+       ) 
43+     } , 
44+     afterRender : function ( question ,  el )  { 
45+       var  $el  =  $ ( el ) . is ( 'select' )  ? $ ( el )  : $ ( el ) . find ( 'select' ) 
46+       var  options  =  $el . find ( 'option' ) 
47+       var  choices  =  question . choices 
1948
20-             for  ( var  i = 1 ;  i  <  options . length  &&  i - 1  <  choices . length ;  i ++ )  { 
21-                 $ ( options [ i ] ) . data ( "imgSrc" ,  choices [ i - 1 ] . imageLink ) ; 
22-                 options [ i ] . selected  =  question . value  ==  options [ i ] . value ; 
23-             } 
24-             $el . imagepicker ( { 
25-                 hide_select  : true , 
26-                 show_label   : question . showLabel , 
27-                 selected : function ( opts )  { 
28-                     question . value  =  opts . picker . select [ 0 ] . value ; 
29-                 } 
30-             } ) 
49+       for  ( var  i  =  1 ;  i  <  options . length  &&  i  -  1  <  choices . length ;  i ++ )  { 
50+         $ ( options [ i ] ) . data ( 'imgSrc' ,  choices [ i  -  1 ] . imageLink ) 
51+         options [ i ] . selected  =  question . value  ==  options [ i ] . value 
52+       } 
53+       $el . imagepicker ( { 
54+         hide_select : true , 
55+         show_label : question . showLabel , 
56+         selected : function ( opts )  { 
57+           question . value  =  opts . picker . select [ 0 ] . value 
3158        } , 
32-         willUnmount : function ( question ,  el )  { 
33-             var  $el  =  $ ( el ) . find ( "select" ) ; 
34-             $el . data ( 'picker' ) . destroy ( ) ; 
35-         }  
36-     } 
59+       } ) 
60+     } , 
61+     willUnmount : function ( question ,  el )  { 
62+       var  $el  =  $ ( el ) . find ( 'select' ) 
63+       $el . data ( 'picker' ) . destroy ( ) 
64+     } , 
65+   } 
3766
38-      Survey . CustomWidgetCollection . Instance . addCustomWidget ( widget ,  " customtype" ) ; 
67+   Survey . CustomWidgetCollection . Instance . addCustomWidget ( widget ,  ' customtype' ) 
3968} 
4069
41- if  ( typeof  Survey  !==  " undefined" )  { 
42-      init ( Survey ) ; 
70+ if  ( typeof  Survey  !==  ' undefined' )  { 
71+   init ( Survey ) 
4372} 
4473
45- export  default  init ; 
74+ export  default  init 
0 commit comments