!function(e){formintorjs.define(["text!tpl/dashboard.html"],function(t){return Backbone.View.extend({className:"forminator-popup-create--quiz",step:1,pagination:1,type:"knowledge",events:{"click .select-quiz-template":"selectTemplate","click .select-quiz-pagination":"selectPagination","click .forminator-popup-back":"goBack","click .forminator-popup-close":"close","change .forminator-new-quiz-type":"clickTemplate","click #forminator-build-your-form":"handleMouseClick","click #forminator-new-quiz-leads":"handleToggle",keyup:"handleKeyClick"},popupTpl:Forminator.Utils.template(e(t).find("#forminator-quizzes-popup-tpl").html()),newFormTpl:Forminator.Utils.template(e(t).find("#forminator-new-quiz-tpl").html()),paginationTpl:Forminator.Utils.template(e(t).find("#forminator-new-quiz-pagination-tpl").html()),newFormContent:Forminator.Utils.template(e(t).find("#forminator-new-quiz-content-tpl").html()),render:function(){var e=jQuery("#forminator-popup");e.removeClass("sui-dialog-sm forminator-create-quiz-second-step forminator-create-quiz-pagination-step"),1===this.step&&(this.$el.html(this.popupTpl()),this.name&&(this.$el.find("#forminator-form-name").val(this.name),this.$el.find("#forminator-new-quiz--"+this.type).prop("checked",!0)),this.$el.find(".select-quiz-template").prop("disabled",!1)),2===this.step&&(this.$el.html(this.paginationTpl()),this.pagination||this.$el.find('[name="forminator-quiz-pagination"]').eq(1).prop("checked",!0),e.addClass("forminator-create-quiz-pagination-step")),3===this.step&&(this.$el.html(this.newFormTpl()),this.$el.find(".sui-box-body").html(this.newFormContent()),e.addClass("sui-dialog-sm forminator-create-quiz-second-step"))},close:function(e){e.preventDefault(),Forminator.Popup.close()},clickTemplate:function(e){this.$el.find(".select-quiz-template").prop("disabled",!1)},selectTemplate:function(t){t.preventDefault();var i=this.$el.find("input[name=forminator-new-quiz]:checked").val(),n=this.$el.find("#forminator-form-name").val();""===n.trim()?e(t.target).closest(".sui-box").find("#sui-quiz-name-error").show():(this.type=i,this.name=n,this.step=2,this.render())},goBack:function(e){e.preventDefault(),this.step--,this.render()},selectPagination:function(e){e.preventDefault();var t=this.$el.find('input[name="forminator-quiz-pagination"]:checked').val();this.pagination=t,this.step=3,this.render()},handleMouseClick:function(e){this.createQuiz(e)},handleKeyClick:function(e){e.preventDefault(),13===e.which&&(1===this.step?this.selectTemplate(e):this.createQuiz(e))},handleToggle:function(t){var i=e(t.target).is(":checked"),n=e(t.target).closest(".sui-box").find("#sui-quiz-leads-description");i?n.show():n.hide()},createQuiz:function(t){var i=e(t.target).closest(".sui-box").find("#forminator-new-quiz-leads").is(":checked"),n=Forminator.Data.modules.quizzes.knowledge_url;"nowrong"===this.type&&(n=Forminator.Data.modules.quizzes.nowrong_url),form_url=n+"&name="+this.name,this.pagination&&(form_url+="&pagination=true"),i&&(form_url+="&leads=true"),window.location.href=form_url}})})}(jQuery);