"use strict";$(document).ready(function(){function a(){if("undefined"!=typeof $.fn.colorpicker){var a=$(".colorpicker-component");a.length>0&&a.colorpicker()}if("undefined"!=typeof $.fn.selectpicker){var b=$(".selectpicker");b.length>0&&b.selectpicker()}var c=$("[data-relation]");c.length>0&&c.on("change",function(a){var b=$(this),c=b.find("option:selected"),d=$(c.attr("data-related")),e=b.closest(".option");e.find(".option-sub.open").removeClass("open"),d.length>0&&d.addClass("open")}),l=[],$.each($("select.js-reset-color"),function(){l[$(this).attr("id")]=$(this).val()})}function b(a,b){var c=a.find(b);return 0===c.length&&(c=a.filter(b)),c}function c(a){var b=$(".main-content").html(a.html());$.each(i,function(){var a=b.find('[href="'+$(this).find("> a").attr("href")+'"]').closest("li");a.length>0&&(a.parent().find("> li.active").removeClass("active"),a.addClass("active").find('[aria-expanded="false"]').attr("aria-expanded","true"))}),$.each(j,function(){var a=b.find("#"+$(this).attr("id"));a.length>0&&(a.parent().find("> .tab-pane.active.in").removeClass("active in"),a.addClass("active in"))})}function d(a){a.hasClass("disabled")&&(a.removeClass("btn-danger disabled").addClass("btn-success").removeAttr("disabled"),a.find("i.fa").removeClass("fa-times").addClass("fa-check"))}function e(a){a.hasClass("disabled")||(a.removeClass("btn-success").addClass("btn-danger disabled").attr("disabled",!0),a.find("i.fa").removeClass("fa-check").addClass("fa-times"))}function f(a){k=null;var b=$(a),c=b.closest(".form-group"),f=c.closest(".tab-pane"),g=$('[data-toggle="tab"][href="#'+f.attr("id")+'"]'),h=c.closest("form"),i=h.find('[type="submit"]');if(b.is("input[type=url]")){var j=new RegExp(/src="(.*?)"/g),l=j.exec(b.val());l&&l[1].length>0&&b.val(l[1])}a.checkValidity()&&0!==b.val().length?c.hasClass("has-error")&&c.removeClass("has-error"):(c.hasClass("has-error")||c.addClass("has-error"),g.hasClass("has-error")||g.addClass("has-error"),e(i)),0===f.find(".has-error").length&&g.removeClass("has-error"),0===h.find(".has-error").length&&d(i)}function g(){var a=$(document).find(".modal.in");m.addClass("ajax-running"),n.find(".modal-body").html(n.attr("data-loading")),a.hasClass("no-save")||n.modal("show")}function h(a){m.removeClass("ajax-running"),a.is(":empty")?n.modal("hide"):(o.html(a.html()),setTimeout(function(){n.modal("hide")},5e3))}var i,j,k,l,m=$("body"),n=$(".js-info-handler"),o=n.find(".modal-body"),p=!1;$(document).on("click",".img-check",function(){$(this).toggleClass("check")}),$(document).on("mousedown",".js-show-password",function(){$(this).closest(".input-group").find("input[type=password]").attr("type","text")}),$(document).on("mouseup",".js-show-password",function(){$(this).closest(".input-group").find("input[type=text]").attr("type","password")}),$(document).on("click",".js-remove-image",function(){var a=$(this),b=a.closest(".uploaded").find("input"),c=a.closest("form");b.removeAttr("disabled").attr("readonly",""),c.submit()}),$(document).on("click",".js-switch-plugin li:not(.active) button",function(){var a=$(this),b=a.closest("li"),c=b.closest("form"),d=c.find("input[name=selected_plugin]");p=!0,$(".js-switch-plugin li.active").removeClass("active"),b.addClass("active"),d.val(a.attr("data-plugin")),c.submit()}),$(document).on("change","select.js-reset-color",function(){var a=$(this),b=a.attr("id"),c=a.closest(".option").find("[data-color]"),d=c.attr("data-color"),e=c.val();("color"===l[b]||"color"===a.val())&&c.attr("data-color",e).colorpicker("setValue",d),l[b]=a.val()}),$(document).on("change","select.js-auto-submit",function(){$(this).closest("form").submit()}),$(document).on("keyup change paste",'input[pattern], input[type="url"], input[required]',function(){k&&clearTimeout(k),k=setTimeout(f(this),100)}),$(document).on("submit","form",function(a){a.preventDefault();var b=$(this),c=new FormData(this);i=$('[data-toggle="tab"][aria-expanded="true"]').map(function(){return $(this).closest("li.active")}),j=$(".tab-pane.active"),$.ajax({type:b.attr("method"),data:c,contentType:!1,processData:!1})}),$(document).ajaxStart(g),$(document).ajaxComplete(function(d,e,f){var g=$(document).find(".modal.in"),i=!1;g.hasClass("no-save")&&(g.removeClass("fade"),g.modal("hide"),i=!0);var j=$(e.responseText),k=b(j,".js-info-handler").find(".modal-body"),l=b(j,".side-bar"),m=b(j,".main-content"),o=b(j,'input[name="plugin_code"]').val();$(".colorpicker").remove(),$(".side-bar").html(l.html()),$('input[name="plugin_code"]').val(o),1==i&&(n.removeClass("fade"),n.modal("show")),c(m),h(k),a()}),a()});