@@ -48,15 +48,41 @@ function init(Survey, $) {
4848        null , 
4949        "dropdown" 
5050      ) ; 
51+       Survey . JsonObject . metaData . addProperties ( "emotionsratings" ,  [ 
52+         { 
53+           name : "emotions:itemvalues" , 
54+           default : [ "angry" ,  "disappointed" ,  "meh" ,  "happy" ,  "inLove" ] 
55+         } , 
56+         { 
57+           name : "emotionSize:number" , 
58+           default : 30 
59+         } , 
60+         { 
61+           name : "emotionsCount:number" , 
62+           default : 5 
63+         } , 
64+         { 
65+           name : "bgEmotion" , 
66+           default : "happy" 
67+         } , 
68+         { 
69+           name : "emotionColor" , 
70+           default : "#FF0066" 
71+         } 
72+       ] ) ;       
5173    } , 
5274    afterRender : function ( question ,  el )  { 
53-       var  self  =  this ; 
54-       var  emotionsArray  =  [ "angry" ,  "disappointed" ,  "meh" ,  "happy" ,  "inLove" ] ; 
75+       var  emotions  =  ( question . emotions  ||  [ ] ) . map ( function ( item )  {  return  item . value  } ) ; 
76+       if ( emotions . length  ===  0 )  { 
77+         emotions  =  [ "angry" ,  "disappointed" ,  "meh" ,  "happy" ,  "inLove" ] ; 
78+       } 
5579      var  options  =  { 
56-         emotionSize : 30 , 
57-         bgEmotion : "happy" , 
58-         emotions : emotionsArray , 
59-         color : "#FF0066" , 
80+         emotionSize : question . emotionSize , 
81+         bgEmotion : question . bgEmotion , 
82+         emotions :  emotions , 
83+         initialRating : question . value , 
84+         color : question . emotionColor , 
85+         count : question . emotionsCount , 
6086        onUpdate : function ( value )  { 
6187          question . value  =  value ; 
6288        } 
@@ -80,6 +106,7 @@ function init(Survey, $) {
80106      el . innerHTML  =  null ; 
81107      $ ( el ) . off ( ) ; 
82108      question . readOnlyChangedCallback  =  null ; 
109+       question . valueChangedCallback  =  null ; 
83110    } , 
84111    pdfQuestionType : "dropdown" 
85112  } ; 
0 commit comments