!function($){"use strict";$.fn.serializeFormJSON=function(){var o={},a=this.serializeArray();return $.each(a,(function(){o[this.name]?(o[this.name].push||(o[this.name]=[o[this.name]]),o[this.name].push(this.value||"")):o[this.name]=this.value||""})),o},window.temporary_deactivation_flag=!1,$(document).on("click",'[data-slug="quiz-maker"] .deactivate a',(function(){return swal({html:"<h2>Do you want to upgrade to Pro version or permanently delete the plugin?</h2><ul><li>Upgrade: Your data will be saved for upgrade.</li><li>Deactivate: Your data will be deleted completely.</li></ul>",footer:'<a href="" class="ays-quiz-temporary-deactivation">Temporary deactivation</a>',type:"question",showCloseButton:!0,showCancelButton:!0,allowOutsideClick:!1,allowEscapeKey:!1,allowEnterKey:!1,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:"Upgrade",cancelButtonText:"Deactivate",confirmButtonClass:"ays-quiz-upgrade-button",cancelButtonClass:"ays-quiz-cancel-button",customClass:"ays-quiz-deactivate-popup"}).then((function(result){if(result.dismiss&&"close"==result.dismiss)return!1;var wp_nonce=$(document).find("#ays_quiz_ajax_deactivate_plugin_nonce").val(),feedback_container=$(document).find(".ays-quiz-dialog-widget"),upgrade_plugin=!1;result.value&&(upgrade_plugin=!0);var data={action:"deactivate_plugin_option_qm",upgrade_plugin:upgrade_plugin,_ajax_nonce:wp_nonce};$.ajax({url:quiz_maker_admin_ajax.ajax_url,method:"post",dataType:"json",data:data,beforeSend:function(xhr){!1===window.temporary_deactivation_flag&&feedback_container.length>0&&(feedback_container.hasClass("ays-quiz-dialog-widget-show")||(feedback_container.css("display","flex"),feedback_container.addClass("ays-quiz-dialog-widget-show")))},success:function(){!1===window.temporary_deactivation_flag&&feedback_container.length>0?feedback_container.hasClass("ays-quiz-dialog-widget-show")||feedback_container.css("display","flex"):window.location=$(document).find('[data-slug="quiz-maker"]').find(".deactivate").find("a").attr("href")},error:function(){swal.fire({type:"info",html:"<h2>"+quiz_maker_admin_ajax.errorMsg+"</h2><p>"+quiz_maker_admin_ajax.somethingWentWrong+"</p>"}).then((function(res){window.location=$(document).find('[data-slug="quiz-maker"]').find(".deactivate").find("a").attr("href")}))}})})),!1})),$(document).on("click",".ays-quiz-temporary-deactivation",(function(e){e.preventDefault(),window.temporary_deactivation_flag=!0,$(document).find(".ays-quiz-upgrade-button").trigger("click")})),$(document).on("click",".ays-quiz-dialog-button",(function(e){e.preventDefault();var _this=$(this),parent=_this.parents(".ays-quiz-dialog-widget"),data=parent.find("form").serializeFormJSON(),type=_this.attr("data-type");data.type=type,data._ajax_nonce=data.ays_quiz_deactivate_feedback_nonce,$.ajax({url:quiz_maker_admin_ajax.ajax_url,method:"post",dataType:"json",data:data,success:function(){parent.css("display","none"),window.location=$(document).find('[data-slug="quiz-maker"]').find(".deactivate").find("a").attr("href")},error:function(){parent.css("display","none"),window.location=$(document).find('[data-slug="quiz-maker"]').find(".deactivate").find("a").attr("href")}})})),$(document).find(".ays-quiz-dialog-widget").on("click",(function(e){var modalBox=$(e.target).attr("class"),feedback_container=$(document).find(".ays-quiz-dialog-widget");void 0!==modalBox&&""!=modalBox&&-1!=modalBox.indexOf("ays-quiz-dialog-widget-show")&&(feedback_container.hasClass("ays-quiz-dialog-widget-show")&&feedback_container.removeClass("ays-quiz-dialog-widget-show"),feedback_container.css("display","none"),window.temporary_deactivation_flag=!1)}))}(jQuery);