/*!*
 **                 _     _                         
 ** __      ___ __ | |   (_)_ __   __ _ _   _  __ _ 
 ** \ \ /\ / / '_ \| |   | | '_ \ / _` | | | |/ _` |
 **  \ V  V /| |_) | |___| | | | | (_| | |_| | (_| |
 **   \_/\_/ | .__/|_____|_|_| |_|\__, |\__,_|\__,_|
 **          |_|                  |___/             
 **
 **        -- wpLingua | WordPress plugin --
 **   Translate and make your website multilingual
 **
 **     https://github.com/julien-jacob/wplingua
 **      https://wordpress.org/plugins/wplingua/
 **              https://wplingua.com/
 **
 **/
jQuery(document).ready(function(t){let g=t("#wplng-slug-editor");t("#toplevel_page_wplingua-settings").removeClass("wp-not-current-submenu").addClass("wp-has-current-submenu"),t("a.toplevel_page_wplingua-settings").addClass("wp-menu-open").addClass("wp-has-current-submenu"),t("#wplng-modal-edit-show-all").on("click",function(){t(this).hide(),g.find(".wplng-edit-language").show()});let e=!1,n={onload:a(),now:a()};function a(){let e="";return g.find(".wplng-edit-language textarea").each(function(){e+=t(this).val()}),g.find(".wplng-edit-language input[type=checkbox]").each(function(){e+=t(this).prop("checked")}),e}function i(){n.now=a(),n.onload==n.now?t("#wplng-modal-edit-save").prop("disabled",!0):t("#wplng-modal-edit-save").prop("disabled",!1)}e=!1,n={onload:a(),now:a()},g.find('.wplng-mark-as-reviewed input[type="checkbox"]').change(function(){var e=g.find("#wplng-slug-"+t(this).attr("wplng-lang"));e.removeClass("wplng-status-generated"),e.removeClass("wplng-status-reviewed"),e.removeClass("wplng-status-ungenerated"),this.checked?e.addClass("wplng-status-reviewed"):e.addClass("wplng-status-generated")}),g.find(".wplng-edit-language .wplng-slug-input").each(function(){g.find("#wplng_mark_as_reviewed_"+t(this).attr("lang")).prop("disabled",""==t(this).val().trim())}),g.find(".wplng-edit-language .wplng-slug-input").on("keyup paste",function(){var e=g.find("#wplng-slug-"+t(this).attr("lang")),n=g.find("#wplng_mark_as_reviewed_"+t(this).attr("lang"));e.removeClass("wplng-status-generated"),e.removeClass("wplng-status-reviewed"),e.removeClass("wplng-status-ungenerated"),""==t(this).val().trim()?(e.addClass("wplng-status-ungenerated"),n.prop("checked",!1),n.prop("disabled",!0)):(e.addClass("wplng-status-reviewed"),n.prop("checked",!0),n.prop("disabled",!1))}),g.find(".wplng-generate-spin").hide(),g.find(".wplng-generate").on("click",function(){if("disabled"!=t(this).attr("disabled")){var e=g.find("#wplng-original-language").attr("wplng-lang");let s=g.find(this).attr("wplng-lang");var n=g.find("#wplng-source").html();if(null!=e&&null!=s&&null!=n){let l="#wplng-slug-"+s;g.find(l+" .wplng-generate").attr("disabled",!0),g.find(l+" .wplng-generate-spin").show(),t.ajax({url:wplngI18nSlug.ajaxUrl,method:"POST",data:{action:"wplng_ajax_slug",text:n,language_source:e,language_target:s},success:function(e){var n,a;e.success?(n="#wplng_slug_"+s,t(n).val(e.data),""!=e.data&&(n=g.find("#wplng-slug-"+s),a=g.find("#wplng_mark_as_reviewed_"+s),n.removeClass("wplng-status-generated"),n.removeClass("wplng-status-reviewed"),n.removeClass("wplng-status-ungenerated"),n.addClass("wplng-status-reviewed"),a.prop("checked",!0),a.prop("disabled",!1)),i(),t(l+" .wplng-generate-spin").hide(),setTimeout(function(){g.find(l+" .wplng-generate").attr("disabled",!1)},8e3)):(console.log("wpLingua - Error:"),console.log(e),g.find(l+" .wplng-generate-spin").removeClass("dashicons-update").removeClass("wplng-spin").addClass("dashicons-no"))},error:function(e){console.log("wpLingua - Error:"),console.log(e),g.find(l+" .wplng-generate-spin").removeClass("dashicons-update").removeClass("wplng-spin").addClass("dashicons-no")}})}}}),g.find(".wplng-edit-language textarea, .wplng-edit-language input").on("change input propertychange",i),t("#submitpost [type=submit], #wplng-modal-edit-save").click(function(){e=!0}),t(window).on("beforeunload",function(){if(!e&&n.onload!=n.now)return confirm(wplngI18nSlug.message.exitPage)})});//# sourceMappingURL=edit-slug.js.map
