UNPKG

surveyjs-widgets

Version:

Custom widgets for the SurveyJS library

3 lines 2.63 kB
/*! For license information please see emotionsratings.min.js.LICENSE.txt */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("widgets/emotionsratings",[],t):"object"==typeof exports?exports["widgets/emotionsratings"]=t():e["widgets/emotionsratings"]=t()}(self,(()=>(()=>{"use strict";var e={d:(t,o)=>{for(var n in o)e.o(o,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:o[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function o(e,t){t=t||window.$;const o="emotionsratings";var n={name:o,title:"Emotions Ratings",iconName:"icon-emotionsratings",widgetIsLoaded:function(){return"function"==typeof t&&!!t.fn.emotionsRating},defaultJSON:{choices:[1,2,3,4,5]},isFit:function(e){return e.getType()===o},isDefaultRender:!1,htmlTemplate:"<div style='height: 33px'></div>",activatedByChanged:function(t){e.Serializer.addClass(o,[{name:"hasOther",visible:!1},{name:"otherText",visible:!1},{name:"optionsCaption",visible:!1},{name:"otherErrorText",visible:!1},{name:"storeOthersAsComment",visible:!1},{name:"renderAs",visible:!1}],null,"dropdown");let n=e.ElementFactory.Instance.registerCustomQuestion;n&&n(o),e.Serializer.addProperties(o,[{name:"emotions:itemvalues",category:"emotions",categoryIndex:1,default:["angry","disappointed","meh","happy","inLove"]},{name:"emotionSize:number",category:"emotions",default:30},{name:"emotionsCount:number",category:"emotions",default:5},{name:"bgEmotion",category:"emotions",default:"happy"},{name:"emotionColor",category:"emotions",default:"#FF0066"}])},afterRender:function(e,o){var n=(e.emotions||[]).map((function(e){return e.value}));0===n.length&&(n=["angry","disappointed","meh","happy","inLove"]);var i={emotionSize:e.emotionSize,bgEmotion:e.bgEmotion,emotions:n,initialRating:e.value,color:e.emotionColor,count:e.emotionsCount,onUpdate:function(t){e.value=t}};function a(){o.innerHTML="<div></div>",t(o).off(),i.initialRating=e.value||0,i.disabled=e.isReadOnly,t(o).find("div").emotionsRating(i)}a(),e.valueChangedCallback=a,e.readOnlyChangedCallback=a},willUnmount:function(e,o){o.innerHTML=null,t(o).off(),e.readOnlyChangedCallback=null,e.valueChangedCallback=null},pdfQuestionType:"dropdown"};e.CustomWidgetCollection.Instance.addCustomWidget(n,"customtype")}e.r(t),e.d(t,{default:()=>n}),"undefined"!=typeof Survey&&o(Survey,window.jQuery);const n=o;return t})())); //# sourceMappingURL=emotionsratings.min.js.map