UNPKG

surveyjs-widgets

Version:

Custom widgets for the SurveyJS library

3 lines 3.74 kB
/*! For license information please see jquery-bar-rating.min.js.LICENSE.txt */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("widgets/jquery-bar-rating",[],t):"object"==typeof exports?exports["widgets/jquery-bar-rating"]=t():e["widgets/jquery-bar-rating"]=t()}(self,(()=>(()=>{var e={775:e=>{e.exports='<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><g><path d="M12.1,15l-4.6-2.4L2.9,15l0.9-5.1L0,6.3l5.2-0.7L7.5,1l2.3,4.6L15,6.3l-3.8,3.6L12.1,15z"></path></g></svg>'}},t={};function a(r){var n=t[r];if(void 0!==n)return n.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,a),o.exports}a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";function e(e,t){const r="icon-barrating",n="barrating";e.SvgRegistry&&e.SvgRegistry.registerIconFromSvg(r,a(775),""),t=t||window.$;var o={name:n,title:"Bar rating",iconName:r,widgetIsLoaded:function(){return"function"==typeof t&&!!t.fn.barrating},defaultJSON:{choices:[1,2,3,4,5]},isFit:function(e){return e.getType()===n},isDefaultRender:!0,activatedByChanged:function(t){e.Serializer.addClass(n,[{name:"hasOther",visible:!1},{name:"otherText",visible:!1},{name:"optionsCaption",visible:!1},{name:"otherErrorText",visible:!1},{name:"storeOthersAsComment",visible:!1},{name:"renderAs",visible:!1},{name:"select2Config",visible:!1}],null,"dropdown");let a=e.ElementFactory.Instance.registerCustomQuestion;a&&a(n),e.Serializer.addProperty(n,{name:"showValues:boolean",default:!1,category:"general"}),e.Serializer.addProperty(n,{name:"ratingTheme",category:"general",default:"css-stars",choices:["fontawesome-stars","css-stars","bars-pill","bars-1to10","bars-movie","bars-reversed","bars-horizontal","fontawesome-stars-o"]})},afterRender:function(e,a){var r,n,o=t(a).is("select")?t(a).parent().parent()[0]:t(a).parent()[0],i=function(){r=t("<select class='sv-widget-select'></select>"),e.visibleChoices.forEach((function(e){r.append('<option value="{0}">{1}</option>'.format(e.value,e.text))})),(n=t(o).find('[id="{0}"]'.format(e.inputId))).css("display","none"),n.after(r),r[0].selectedIndex=-1},s=function(){r.barrating("show",{theme:e.ratingTheme,initialRating:e.value,showValues:e.showValues,showSelectedRating:!1,readonly:e.isReadOnly,onSelect:function(t,a){l=!0,e.value=t,l=!1}})};i(),s(),r.parents()[0]&&(r.parents()[0].style.marginBottom="3px");var l=!1;e.valueChangedCallback=function(){l||t(o).find("select.sv-widget-select")[0].value===e.value||t(o).find("select.sv-widget-select").barrating("set",e.value)},e.__barratingOnPropertyChangedCallback=function(e,t){"ratingTheme"!==t.name&&"showValues"!==t.name||(r.barrating("destroy"),s())},e.onPropertyChanged.add(e.__barratingOnPropertyChangedCallback),e.readOnlyChangedCallback=function(){n.css("display",""),r.barrating("destroy"),r.remove(),i(),s()},e.visibleChoicesChangedCallback=function(){s()}},willUnmount:function(e,a){var r=(t(a).is("select")?t(a).parent().parent():t(a).parent()).find("select.sv-widget-select");r.barrating("destroy"),r.remove(),e.valueChangedCallback=void 0,e.onPropertyChanged.remove(e.__barratingOnPropertyChangedCallback),e.__barratingOnPropertyChangedCallback=void 0},pdfQuestionType:"dropdown"};e.CustomWidgetCollection.Instance.addCustomWidget(o,"customtype")}a.r(r),a.d(r,{default:()=>t}),"undefined"!=typeof Survey&&e(Survey,window.$);const t=e})(),r})())); //# sourceMappingURL=jquery-bar-rating.min.js.map