/* * SiteSEO * https://siteseo.io/ * (c) SiteSEO Team <support@siteseo.io> */ /* Copyright 2016 - 2024 - Benjamin Denis (email : contact@seopress.org) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ function siteseo_universal_tag_dropdown(){let e=!1;jQuery(".siteseo-tag-dropdown").each(function(t){let s=jQuery(this);var i=function(e){s.hasClass("tag-title")&&(jQuery(".siteseo_titles_title_meta").val(siteseo_get_field_length(jQuery(".siteseo_titles_title_meta"))+jQuery(e).attr("data-value")),jQuery(".siteseo_titles_title_meta").trigger("paste",!0)),s.hasClass("tag-description")&&(jQuery(".siteseo_titles_desc_meta").val(siteseo_get_field_length(jQuery(".siteseo_titles_desc_meta"))+jQuery(e).attr("data-value")),jQuery(".siteseo_titles_desc_meta").trigger("paste",!0))};jQuery(this).off("click").on("click",function(){function t(s){!(jQuery(s.target).hasClass("dashicons")||jQuery(s.target).hasClass("siteseo-tag-single-all"))&&(e=!1,jQuery(document).off("click",t),jQuery(".siteseo-wrap-tag-variables-list").removeClass("open"))}jQuery(this).next(".siteseo-wrap-tag-variables-list").toggleClass("open"),jQuery(this).next(".siteseo-wrap-tag-variables-list").find("li").on("click",function(e){i(this),e.stopImmediatePropagation()}).on("keyup",function(e){13===e.keyCode&&(i(this),e.stopImmediatePropagation())}),jQuery(this).next(".siteseo-wrap-tag-variables-list").find(".siteseo-tag-search-input").on("click input",function(e){(function e(t){let s=t.value.toLowerCase();jQuery(t).closest(".siteseo-tag-variables-list").find("li").filter(function(){jQuery(this).toggle(jQuery(this).text().toLowerCase().indexOf(s)>-1)})})(this),e.stopImmediatePropagation()}),e||(e=!0,jQuery(document).on("click",t))})})}async function siteseo_resolve_variable(e,t=!1){let s=jQuery(".siteseo-metabox-tabs").data("term-id"),i=jQuery(".siteseo-metabox-tabs").data("home-id"),a=await jQuery.ajax({method:"GET",url:siteseoAjaxRealPreview.ajax_url,data:{action:"get_preview_meta_title",template:e,post_id:jQuery(".siteseo-metabox-tabs").attr("data_id"),term_id:0===s.length?void 0:s,home_id:0===i.length?void 0:i,nonce:siteseoAjaxRealPreview.get_preview_meta_title}});if(!a||!a.success||!a.data)return e;a&&a.data.length>0&&(e=a.data),t?siteseo_update_desc(e):siteseo_update_title(e)}function siteseo_get_field_length(e){return e.val().length>0?e.val()+" ":e.val()}!function(e){e(document).ready(function(){e(document).on("click",".siteseo-metabox-tab-label",function(){let t=e(this),s=t.closest(".siteseo-metabox-tabs, .siteseo-metabox-subtabs"),i=s.find(".siteseo-metabox-tab-label-active");i.length&&i.removeClass("siteseo-metabox-tab-label-active"),t.addClass("siteseo-metabox-tab-label-active");let a=t.data("tab");s.siblings("."+a).show(),s.siblings("."+a).siblings(".siteseo-metabox-tab").hide()}),e(document).on("change",'[name="siteseo_analysis_target_kw"]',function(){e('[name="siteseo_analysis_target_kw"]').val(event.target.value)}),e(document).on("change",".siteseo-metabox-robots-options",function(){let t=e(this);if(t.is(":disabled"))return;let s=t.attr("name");t.is(":checked")?e('[name="'+s+'"]').attr("checked",!0):e('[name="'+s+'"]').attr("checked",!1)}),e(document).on("input",'[name="siteseo_robots_canonical"]',function(){e('[name="siteseo_robots_canonical"]').val(event.target.value)}),e(document).on("change",'[name="siteseo_robots_primary_cat"]',function(){e('[name="siteseo_robots_primary_cat"]').val(event.target.value)}),e(document).on("change",'[name="siteseo_redirections_enabled"]',function(){e('[name="siteseo_redirections_enabled"]').attr("checked",e(this).is(":checked"))}),e(document).on("change",'[name="siteseo_redirections_logged_status"]',function(){e('[name="siteseo_redirections_logged_status"]').val(event.target.value)}),e(document).on("change",'[name="siteseo_redirections_type"]',function(){e('[name="siteseo_redirections_type"]').val(event.target.value)}),e(document).on("input",'[name="siteseo_redirections_value"]',function(){e('[name="siteseo_redirections_value"]').val(event.target.value)}),e(document).on("click","#siteseo-sidebar-wrapper .siteseo-sidebar-tabs",function(){e(this).toggleClass("siteseo-sidebar-tabs-opened"),e(this).next().slideToggle("fast")}),e(document).on("click","#siteseo-metabox-search-mobile",function(){e(this).hide(),e(this).prev().show(),e(".siteseo-search-preview-desktop").css("max-width","414px")}),e(document).on("click","#siteseo-metabox-search-pc",function(){e(this).hide(),e(this).next().show(),e(".siteseo-search-preview-desktop").css("max-width","")}),e(document).on("click",".siteseo-metabox-tag",function(){event.preventDefault();let t=e(event.target),s=t.attr("data-tag"),i=t.closest(".siteseo-metabox-tags").next("input, textarea"),a=i.val();s&&(e("."+i.attr("class")).val(a+" "+s),i.trigger("input",!0))}),e(document).on("input paste",".siteseo_titles_title_meta",async function(t,i){if(i){var a=e("#siteseo_titles_title_meta").val();e(".siteseo_titles_title_meta").val(a),a.length<1&&(a=e(".siteseo_titles_title_meta").attr("placeholder"))}else{var a=e(event.target).val();e(".siteseo_titles_title_meta").val(a),a.length<1&&(a=e(event.target).attr("placeholder"))}-1!=a.indexOf("%%")?s(()=>siteseo_resolve_variable(a),i?0:300):siteseo_update_title(a)}),e(document).on("input",".siteseo_titles_desc_meta",async function(t,i){if(i){var a=e(".siteseo_titles_desc_meta").val();e(".siteseo_titles_desc_meta").val(a)}else{var a=e(event.target).val();e(".siteseo_titles_desc_meta").val(a)}-1!=a.indexOf("%%")?s(()=>siteseo_resolve_variable(a,!0),i?0:300):siteseo_update_desc(a)}),e(document).on("input paste","#siteseo_social_fb_title_meta",function(){let t=e(".siteseo-metabox-fb-preview .siteseo-metabox-fb-title");e(document.querySelectorAll("#siteseo_social_fb_title_meta")).val(event.target.value),t.html(event.target.value)}),e(document).on("input paste","#siteseo_social_fb_desc_meta",function(){let t=e(".siteseo-metabox-fb-preview .siteseo-metabox-fb-desc");e(document.querySelectorAll("#siteseo_social_fb_desc_meta")).val(event.target.value),t.html(event.target.value)}),e(document).on("input paste","#siteseo_social_twitter_title_meta",function(){let t=e(".siteseo-metabox-x-preview .siteseo-metabox-x-title");e(document.querySelectorAll("#siteseo_social_twitter_title_meta")).val(event.target.value),t.html(event.target.value)}),e(document).on("input paste","#siteseo_social_twitter_desc_meta",function(){e(document.querySelectorAll("#siteseo_social_twitter_desc_meta")).val(event.target.value)}),e(document).on("change paste","#siteseo_social_twitter_img_meta",function(t,s=!1){if(s){e('[name="siteseo_social_twitter_img"]').val(e("#siteseo_social_twitter_img_meta").val());return}let i=e(".siteseo-metabox-x-preview .siteseo-metabox-x-image img");e('[name="siteseo_social_twitter_img"]').val(event.target.value),i.attr("src",event.target.value)}),e(document).on("change paste","#siteseo_social_fb_img_meta",function(t,s=!1){if(s){e('[name="siteseo_social_fb_img"]').val(e("#siteseo_social_fb_img_meta").val());return}let i=e(".siteseo-metabox-fb-preview .siteseo-metabox-fb-image img");e('[name="siteseo_social_fb_img"]').val(e("#siteseo_social_fb_img_meta").val()),i.attr("src",event.target.value)}),siteseo_universal_tag_dropdown();let t;function s(e,s=300){clearTimeout(t),t=setTimeout(()=>{e.apply(this,arguments)},s)}})}(jQuery);var siteseo_sidebar_tag,siteseo_tags_is_syncing=!1;function siteseo_sync_kw_tags(e,t){if(!siteseo_tags_is_syncing){siteseo_tags_is_syncing=!0;var s=e.value;t.loadOriginalValues(s),siteseo_tags_is_syncing=!1}}function siteseo_update_desc(e){let t=jQuery(".siteseo-metabox-search-preview .siteseo-search-preview-description"),s=jQuery(".siteseo_titles_desc_meta").closest(".siteseo-metabox-input-wrap"),i=e.length,a=Math.ceil(i/160*100);i>160?t.text(e.substring(0,160)+"..."):t.text(e),s.find(".siteseo-metabox-limits-numbers em").text(i),a<=100?(s.find(".siteseo-metabox-limits-meter span").css({width:a+"%","background-color":"#00308F"}),s.find(".siteseo-metabox-limits-numbers em").css({color:"unset","font-weight":"normal"})):(s.find(".siteseo-metabox-limits-meter span").css({"background-color":"#DC143C",width:"100%"}),s.find(".siteseo-metabox-limits-numbers em").css({color:"red","font-weight":"bold"}))}function siteseo_update_title(e){let t=jQuery(".siteseo-metabox-search-preview h3"),s=jQuery(".siteseo_titles_title_meta").closest(".siteseo-metabox-input-wrap"),i=e.length,a=Math.ceil(i/60*100);i>60?t.text(e.substring(0,60)+"..."):t.text(e),s.find(".siteseo-metabox-limits-numbers em").text(i),a<=100?(s.find(".siteseo-metabox-limits-meter span").css({width:a+"%","background-color":"#00308F"}),s.find(".siteseo-metabox-limits-numbers em").css({color:"unset","font-weight":"normal"})):(s.find(".siteseo-metabox-limits-meter span").css({width:"100%","background-color":"red"}),s.find(".siteseo-metabox-limits-numbers em").css({color:"red","font-weight":"bold"}))}