!function(a){"use strict";window.jkitdashboard=window.jkitdashboard||{},window.jkitdashboard={init:function(e){var n=this;n.xhr=null,n.container=void 0===e?a("body"):e,Notiflix.Notify.init({position:"right-top",zindex:999999,showOnlyTheLastOne:!0,success:{notiflixIconColor:"#fff"}}),n.button_save=n.container.find(".jkit-dashboard-body-wrap .jkit-form-submit>button"),n.form_handler(),n.elements(),n.admin_menu()},admin_menu:function(){this.container.find(".jkit-support-menu a, .jkit-review-menu a").attr("target","_blank")},form_handler:function(){var e=this,n="undefined"!=typeof jkit_custom_dashboard_form_id&&jkit_custom_dashboard_form_id.name?"#"+jkit_custom_dashboard_form_id.name:"#jkit-user-data-form, #jkit-settings-form, #jkit-notfound-form",t=e.container.find(n);t.find(".jkit-form-content").on("click",function(e){e.preventDefault();var n=a(this).parents(".jkit-form-tab ");n.hasClass("collapse")?n.removeClass("collapse"):n.addClass("collapse")}),t.on("submit",function(n){n.preventDefault();var t=a(this).attr("id"),i={},s="",o="",d="",r=/\[([^\]]+)\]/;"jkit-user-data-form"===t?s="save_user_data":"jkit-settings-form"===t?s="save_settings":"jkit-notfound-form"===t?s="save_notfound":"undefined"!=typeof jkit_custom_dashboard_form_id&&jkit_custom_dashboard_form_id.name===t&&(s="save_"+jkit_custom_dashboard_form_id.name),a(this).find("input, select").each(function(e){o=r.exec(a(this).attr("name")),d=a(this).val(),i[o[1]]=d}),e.button_save.addClass("saving"),e.button_save.find("i").removeClass("fa-save").addClass("fa-spinner fa-spin"),a.ajax({type:"POST",url:"undefined"!=typeof jkit_custom_ajax_url?jkit_custom_ajax_url:jkit_ajax_url,data:{form_data:i,action:s,nonce:jkit_nonce},dataType:"json",encode:!0}).done(function(a){Notiflix.Notify.success(a.message),e.button_save.removeClass("saving"),e.button_save.find("i").removeClass("fa-spinner fa-spin").addClass("fa-save")}).fail(function(a){Notiflix.Notify.failure(void 0!==a.responseJSON&&a.responseJSON.message?a.responseJSON.message:jkit_dashboard_localize.save_failed),e.button_save.removeClass("saving"),e.button_save.find("i").removeClass("fa-spinner fa-spin").addClass("fa-save")})})},elements:function(){var e=this,n=e.container.find(".element-checkbox-option .switch"),t=e.container.find(".jkit-button.enable-all"),i=e.container.find(".jkit-button.disable-all"),s=e.container.find("#jkit-elements-enable-form");n.on("click",function(e){e.preventDefault();var n=a(this).prev("input");n.is(":checked")?n.prop("checked",!1):n.prop("checked",!0)}),t.on("click",function(a){a.preventDefault(),n.prev("input").prop("checked",!0)}),i.on("click",function(a){a.preventDefault(),n.prev("input").prop("checked",!1)}),s.on("submit",function(t){t.preventDefault();var i={};e.button_save.addClass("saving"),e.button_save.find("i").removeClass("fa-save").addClass("fa-spinner fa-spin"),n.each(function(e,n){var t=a(n).prev("input"),s=t.data("element-key");i[s]=t.is(":checked")}),a.ajax({type:"POST",url:jkit_ajax_url,data:{form_data:i,action:"save_elements_enable",nonce:jkit_nonce},dataType:"json",encode:!0}).done(function(a){Notiflix.Notify.success(a.message),e.button_save.removeClass("saving"),e.button_save.find("i").removeClass("fa-spinner fa-spin").addClass("fa-save")}).fail(function(){Notiflix.Notify.failure(jkit_dashboard_localize.save_failed),e.button_save.removeClass("saving"),e.button_save.find("i").removeClass("fa-spinner fa-spin").addClass("fa-save")})})}},a(document).on("ready",function(){window.jkitdashboard.init()})}(jQuery);