"use strict";var _createClass=function(){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}}(),_get=function e(t,n,i){null===t&&(t=Function.prototype);var o=Object.getOwnPropertyDescriptor(t,n);if(void 0===o){var r=Object.getPrototypeOf(t);return null===r?void 0:e(r,n,i)}if("value"in o)return o.value;var s=o.get;return void 0!==s?s.call(i):void 0};function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}!function(n,i){function o(){return _classCallCheck(this,o),_possibleConstructorReturn(this,(o.__proto__||Object.getPrototypeOf(o)).apply(this,arguments))}n.ListQuiz=(_inherits(o,n.Quiz),_createClass(o,[{key:"parseQuestion",value:function(e){return(e=_get(o.prototype.__proto__||Object.getPrototypeOf(o.prototype),"parseQuestion",this).call(this,e)).color||(e.color=this.store.defaultQuestion.color),e}},{key:"getQuestionTmplData",value:function(e,t){return{question:e,baseName:this.questionsBaseName,index:t,listType:this.store.settings.list_type||"",i18n:n.i18n}}},{key:"loadEvents",value:function(){var t=this;_get(o.prototype.__proto__||Object.getPrototypeOf(o.prototype),"loadEvents",this).call(this),this.$wrapper.on("click",".wp-quiz-list-options button[data-type]",function(e){return t.handleClickListTypeBtn(e)}),this.$wrapper.find(".wp-quiz-list-color").wpColorPicker({hide:!1,change:function(e,n){t.$wrapper.find(".wp-quiz-listquiz-questions").each(function(e,t){return t.style.setProperty("--list-color",n.color.toString())})}}),i(document).on("click",function(e){return t.$wrapper.find(".wp-quiz-list-color-panel").hide()}),i(document).on("click",".wp-quiz-list-color-btn",function(e){return e.stopPropagation()}),i(document).on("click",".wp-quiz-list-color-panel",function(e){return e.stopPropagation()}),this.$wrapper.on("click",".wp-quiz-list-color-btn",function(e){return t.handleClickListColorBtn(e)}),this.$wrapper.on("click",".wp-quiz-question-votes-up-btn",function(e){return t.handleClickVotesUpBtn(e)}),this.$wrapper.on("click",".wp-quiz-question-votes-down-btn",function(e){return t.handleClickVotesDownBtn(e)})}},{key:"handleClickListTypeBtn",value:function(e){e.preventDefault();var t=i(e.currentTarget),n=t.attr("data-type");switch(t.parent().children(".is-active").removeClass("is-active"),t.addClass("is-active"),this.$wrapper.find(".wp-quiz-list-type-input").val(n),this.$wrapper.find(".wp-quiz-question-heading-inner > .is-active").removeClass("is-active"),n){case"number":this.$wrapper.find(".wp-quiz-question-number").addClass("is-active");break;case"bullet":this.$wrapper.find(".wp-quiz-question-bullet").addClass("is-active");break;case"interactive":this.$wrapper.find(".wp-quiz-question-interactive-btns").addClass("is-active")}this.store.settings.list_type=n}},{key:"handleClickListColorBtn",value:function(e){e.preventDefault(),i(e.currentTarget).next(".wp-quiz-list-color-panel").toggle()}},{key:"handleClickVotesUpBtn",value:function(e){e.preventDefault();var t=i(e.currentTarget),n=t.closest(".wp-quiz-question");t.hasClass("is-enabled")?(t.removeClass("is-enabled").addClass("is-disabled"),n.find(".wp-quiz-question-votes-up").val("")):(t.addClass("is-enabled").removeClass("is-disabled"),n.find(".wp-quiz-question-votes-up").val(1))}},{key:"handleClickVotesDownBtn",value:function(e){e.preventDefault();var t=i(e.currentTarget),n=t.closest(".wp-quiz-question");t.hasClass("is-enabled")?(t.removeClass("is-enabled").addClass("is-disabled"),n.find(".wp-quiz-question-votes-down").val("")):(t.addClass("is-enabled").removeClass("is-disabled"),n.find(".wp-quiz-question-votes-down").val(1))}},{key:"name",get:function(){return"listquiz"}},{key:"answerSortable",get:function(){return!1}},{key:"resultSortable",get:function(){return!1}},{key:"videoUpload",get:function(){return!1}},{key:"questionMediaType",get:function(){return!1}},{key:"answerType",get:function(){return!1}}]),o),i(document).ready(function(){i('.wp-quiz-backend[data-type="listquiz"]').each(function(){new n.ListQuiz(i(this))})})}(wpQuizAdmin,jQuery);