@@ -49,21 +49,38 @@ function init(Survey, $) {
4949 } ) ;
5050 } ,
5151 afterRender : function ( question , el ) {
52- var $el = $ ( el ) . is ( "select" ) ? $ ( el ) : $ ( el ) . find ( "select" ) ;
53- var options = $el . find ( "option" ) ;
5452 var choices = question . choices ;
53+ if ( question . isReadOnly ) {
54+ $el = $ ( el ) ;
55+ var $ul = $ ( '<ul class="thumbnails image_picker_selector"></ul>' ) ;
56+ $el . empty ( ) ;
57+ $el . append ( $ul ) ;
58+ for ( var i = 0 ; i < choices . length ; i ++ ) {
59+ var selected = question . value === choices [ i ] . value ? "selected" : "" ;
60+ $ul . append (
61+ '<li><div class="thumbnail ' +
62+ selected +
63+ '"><img class="image_picker_image" src="' +
64+ choices [ i ] . imageLink +
65+ '"></div></li>'
66+ ) ;
67+ }
68+ } else {
69+ var $el = $ ( el ) . is ( "select" ) ? $ ( el ) : $ ( el ) . find ( "select" ) ;
70+ var options = $el . find ( "option" ) ;
5571
56- for ( var i = 1 ; i < options . length && i - 1 < choices . length ; i ++ ) {
57- $ ( options [ i ] ) . data ( "imgSrc" , choices [ i - 1 ] . imageLink ) ;
58- options [ i ] . selected = question . value == options [ i ] . value ;
59- }
60- $el . imagepicker ( {
61- hide_select : true ,
62- show_label : question . showLabel ,
63- selected : function ( opts ) {
64- question . value = opts . picker . select [ 0 ] . value ;
72+ for ( var i = 1 ; i < options . length && i - 1 < choices . length ; i ++ ) {
73+ $ ( options [ i ] ) . data ( "imgSrc" , choices [ i - 1 ] . imageLink ) ;
74+ options [ i ] . selected = question . value == options [ i ] . value ;
6575 }
66- } ) ;
76+ $el . imagepicker ( {
77+ hide_select : true ,
78+ show_label : question . showLabel ,
79+ selected : function ( opts ) {
80+ question . value = opts . picker . select [ 0 ] . value ;
81+ }
82+ } ) ;
83+ }
6784 } ,
6885 willUnmount : function ( question , el ) {
6986 var $el = $ ( el ) . find ( "select" ) ;
0 commit comments