관리-도구
편집 파일: options_basic.min.js
jQuery(function(s){function e(){var e,t=s(this).closest("#yarpp_display_web, #yarpp_display_rss");t.length&&(value=t.find(".use_template").val(),t.find(".yarpp_subbox").hide(),t.find(".template_options_"+value).show(),e=t.find(".yarpp_no_results"),"custom"===value?e.hide():e.show(),e=t.find(".generate_missing_thumbnails"),"builtin"===value?e.hide():e.show(),a.apply(t))}function a(){var e=s(this).closest("#yarpp_display_web, #yarpp_display_rss");e.find(".excerpted").toggle(!("builtin"!==e.find(".use_template").val()||!e.find(".show_excerpt input").prop("checked")))}function t(){s("#yarpp_display_rss .inside").is(":visible")&&(s("#yarpp-rss_display").is(":checked")?(s(".rss_displayed").show(),s("#yarpp_display_rss").each(e)):s(".rss_displayed").hide())}function i(){s("#yarpp_display_api .inside").is(":visible")&&(s("#yarpp-rest_api_display").is(":checked")?s(".yarpp_rest_displayed").show():s(".yarpp_rest_displayed").hide())}function r(){s("#yarpp-rest_api_client_side_caching").is(":checked")?s(".yarpp_rest_browser_cache_displayed").show():s(".yarpp_rest_browser_cache_displayed").hide()}postboxes.add_postbox_toggles(pagenow),s(".use_template").each(e).change(e),s(".show_excerpt, .use_template, #yarpp-rss_display").click(a),s("#yarpp-rss_display, #yarpp_display_rss .handlediv, #yarpp_display_rss-hide").click(t),t(),s("#yarpp-rest_api_display").click(i),i(),s("#yarpp-rest_api_client_side_caching").click(r),r();var n=!1;function p(){var i,e;function r(t){var a;t in i||(a=s("#exclude_"+t)).find(".loading").length||(t in e?e[t]=e[t]+100:e[t]=0,s.ajax({type:"POST",url:ajaxurl,data:{action:"yarpp_display_exclude_terms",taxonomy:t,offset:e[t],_ajax_nonce:s("#yarpp_display_exclude_terms-nonce").val()},beforeSend:function(){a.append(loading)},success:function(e){a.find(".loading").remove(),":("==e?(i[t]=!0,a.append("-")):a.append(e)},dataType:"html"}))}!n&&s("#yarpp_pool .inside").is(":visible")&&(n=!0,i={},e={},s(".exclude_terms").each(function(){var a,e=jQuery(this).attr("id");e&&(r(a=e.replace("exclude_","")),s("#exclude_"+a).parent(".yarpp_scroll_wrapper").scroll(function(){var e=s(this),t=e.children("div");e.scrollTop()+e.height()>t.height()-10&&r(a)}))}))}function o(e){s("#tab-link-"+e+" a").click(),s("#contextual-help-link").click()}s("#yarpp_pool .handlediv, #yarpp_pool-hide").click(p),p(),s("#yarpp-optin-learnmore").click(function(){o("optin")}),s("#yarpp-help-cpt").click(function(){o("dev")}),"#help-optin"==location.hash&&setTimeout(function(){o("optin")}),s(".yarpp_help[data-help]").hover(function(){var e=s(this),t={content:"<p>"+e.attr("data-help")+"</p>",position:{edge:isRtl?"right":"left",align:"center",of:e},document:{body:e}},a=e.pointer(t).pointer("open");e.closest(".yarpp_form_row, p").mouseleave(function(){a.pointer("close")})}),s(".yarpp_template_button[data-help]").hover(function(){var e=s(this),t="<p>"+e.attr("data-help")+"</p>",a=e.pointer({content:t,position:{edge:"bottom",of:e},document:{body:e}}).pointer("open");e.mouseleave(function(){a.pointer("close")}),s(".yarpp_copy_templates_button").on("click",function(){var e=s(this),t=e.siblings(".spinner");e.addClass("yarpp-disabled"),t.addClass("is-active"),window.location=window.location+(window.location.search.length?"&":"?")+"action=copy_templates&_ajax_nonce="+s("#yarpp_copy_templates-nonce").val()})}),s(".yarpp_spin_on_click").on("click",function(){var e=s(this),t=e.siblings(".spinner");e.addClass("yarpp-disabled"),t.addClass("is-active")});const d=document.getElementById("yarpp-preview-show-code"),l=document.getElementById("yarpp-display-code-preview");function c(e=!1){"none"===l.style.display||e?(l.style.display="block",d.innerText=yarpp_messages.hide_code):(l.style.display="none",d.innerText=yarpp_messages.show_code)}d&&d.addEventListener("click",()=>c());const _=document.querySelector("#yarpp-display-html-preview .yarpp-preview__iframe__container");if(_){let a;function u(e){var t=e.x-a;a=e.x,_.style.width=parseInt(getComputedStyle(_,"").width)+t+"px",w()}_.addEventListener("mousedown",function(e){e.layerX-e.offsetX<50&&(a=e.x,document.addEventListener("mousemove",u,!1))}),document.addEventListener("mouseup",function(){document.removeEventListener("mousemove",u,!1)})}let y={};function h(e,t,a="value"){t=t.target[a];y[e]="checked"===a?t?1:0:t,x()}var m=document.querySelector("#limit[name=limit]"),m=(m&&m.addEventListener("blur",e=>h("limit",e)),document.querySelector("#yarpp-promote_yarpp[name=promote_yarpp]")),m=(m&&m.addEventListener("change",e=>h("promote_yarpp",e,"checked")),document.querySelector("#order[name=order]"));m&&m.addEventListener("change",e=>h("order",e));const v=document.querySelector("#template_file[name=template_file]"),f=(v&&v.addEventListener("change",e=>h("template",e)),document.querySelector("#thumbnail_size_display[name=thumbnail_size_display]")),b=(f&&f.addEventListener("change",e=>h("size",e)),document.querySelector("#custom_theme_thumbnail_size_display[name=custom_theme_thumbnail_size_display]"));b&&b.addEventListener("change",e=>h("size",e));m=document.querySelector("#thumbnails_heading[name=thumbnails_heading]"),m&&m.addEventListener("blur",e=>h("thumbnails_heading",e)),m=document.querySelector("#thumbnails_default[name=thumbnails_default]"),m&&m.addEventListener("blur",e=>h("thumbnails_default",e)),m=document.querySelector("#before_related[name=before_related]"),m&&m.addEventListener("blur",e=>h("before_related",e)),m=document.querySelector("#after_related[name=after_related]"),m&&m.addEventListener("blur",e=>h("after_related",e)),m=document.querySelector("#before_title[name=before_title]"),m&&m.addEventListener("blur",e=>h("before_title",e)),m=document.querySelector("#after_title[name=after_title]"),m&&m.addEventListener("blur",e=>h("after_title",e)),m=document.querySelector("#yarpp-show_excerpt[name=show_excerpt]"),m&&m.addEventListener("change",e=>h("show_excerpt",e,"checked")),m=document.querySelector("#excerpt_length[name=excerpt_length]"),m&&m.addEventListener("blur",e=>h("excerpt_length",e)),m=document.querySelector("#before_post[name=before_post]"),m&&m.addEventListener("blur",e=>h("before_post",e)),m=document.querySelector("#after_post[name=after_post]");function g(e){_.style.width=e+"px",w()}function w(){var e=document.querySelector(".yarpp-preview__iframe__backdrop");e&&(document.querySelector("#yarpp-preview__show-preview-width__value").innerText=e.offsetWidth-20+"px")}m&&m.addEventListener("blur",e=>h("after_post",e)),window.addEventListener("resize",w);m=document.querySelector("#yarpp-preview-mobile"),m&&m.addEventListener("click",e=>g(320)),m=document.querySelector("#yarpp-preview-tablet"),m&&m.addEventListener("click",e=>g(768)),m=document.querySelector("#yarpp-preview-desktop");function x(e=null){d.setAttribute("disabled","disabled");var i=s("#yarpp-display-html-preview .yarpp-preview__iframe__container"),r=s("#yarpp-display-code-preview");const n=document.querySelector("#yarpp-display-html-preview div.yarpp-preview__iframe__backdrop");w(),e&&("custom"===e?(y.template=v.value,b.value&&(y.size=b.value)):y.template=e,"thumbnails"===e)&&f.value&&(y.size=f.value),console.log("Rendering Template Preview: ",y),s.ajax({type:"POST",url:ajaxurl,data:{action:"yarpp_display_preview",_ajax_nonce:s("#yarpp_display_preview-nonce").val(),...y},beforeSend:function(){i.html(loading)},success:function(e){const t=JSON.parse(e),a=document.createElement("style");a.appendChild(document.createTextNode(t.styles));var e=document.createElement("iframe");e.width="100%",e.height="100%",e.style="overflow: hidden; user-select: none; outline: 0; background-color: white;",i.html(e),i.prepend(n),e.onload=e=>{e=e.target.contentWindow.document;e.getElementsByTagName("head")[0].appendChild(a),e.body.innerHTML=t.html,e.body.style="overflow:hidden;"},"codeEditor"in wp?(c(!0),e={...wp.codeEditor.defaultSettings,type:"text/html",codemirror:{...wp.codeEditor.defaultSettings.codemirror,indentUnit:2,tabSize:2,readOnly:!0}},r.html('<textarea id="yarpp-preview-code-textarea">'+t.code+"</textarea>"),wp.codeEditor.initialize(document.getElementById("yarpp-preview-code-textarea"),e),c()):r.html("<pre><code>"+t.code+"</code></pre>"),d.removeAttribute("disabled")},dataType:"html"})}function k(){var e=s(this).find("option:selected"),t=e.closest(".yarpp_form_row");e.attr("data-url")?t.find(".template_author_wrap").toggle(!!e.attr("data-author")).find("span").empty().append("<a>"+e.attr("data-author")+"</a>").attr("href",e.attr("data-url")):t.find(".template_author_wrap").toggle(!!e.attr("data-author")).find("span").text(e.attr("data-author")),t.find(".template_description_wrap").toggle(!!e.attr("data-description")).find("span").text(e.attr("data-description")),t.find(".template_file_wrap").toggle(!!e.attr("data-basename")).find("span").text(e.attr("data-basename"))}m&&m.addEventListener("click",e=>g(1200)),x(),s(".yarpp_template_button:not(.disabled)").click(function(){var e=s(this).attr("data-value");s(this).siblings("input").val(e).change(),s(this).siblings().removeClass("active"),s(this).addClass("active"),s(this).parents("#yarpp_display_web").length&&x(e)}),s("#template_file, #rss_template_file").each(k).change(k);var S=!1;function E(){var t;s("#optin_data_frame").is(":visible")&&!S&&(S=!0,t=s("#optin_data_frame"),s.ajax({type:"POST",url:ajaxurl,data:{action:"yarpp_optin_data",_ajax_nonce:s("#yarpp_optin_data-nonce").val()},beforeSend:function(){t.html(loading)},success:function(e){t.html("<pre>"+e+"</pre>")},dataType:"html"}))}function L(){setTimeout(E,0)}function q(){var e=s(".yarpp_form_post_types").is(":has(input[type=checkbox]:checked)");s("#yarpp-auto_display_archive").attr("disabled",!e),e||s("#yarpp-auto_display_archive").prop("checked",!1)}function C(e,t){e?(s(".yarpp_form_post_types #yarpp_post_type_"+t).prop("disabled",!1),s(".yarpp_form_post_types #yarpp_post_type_"+t).siblings().hide()):(s(".yarpp_form_post_types #yarpp_post_type_"+t).prop("disabled",!0),s(".yarpp_form_post_types #yarpp_post_type_"+t).siblings().show())}s("#yarpp-optin-learnmore, a[aria-controls=tab-panel-optin]").bind("click focus",L),L(),s(".sync_no_results, .sync_rss_no_results").change(function(){var e=s(this).find("input").attr("value");s(this).hasClass("sync_no_results")&&s(".sync_no_results input").attr("value",e),s(this).hasClass("sync_rss_no_results")&&s(".sync_rss_no_results input").attr("value",e)}),s(".yarpp_form_post_types input[type=checkbox]").change(q),q(),s("#yarpp_fulltext_expand").click(function(e){e.preventDefault();e=s("#yarpp_fulltext_details");e.slideToggle(),e.hasClass("hidden")?(e.removeClass("hidden"),s(this).text("Hide Details [-]")):(e.addClass("hidden"),s(this).text("Show Details [+]"))}),s(".include_post_type input[type=checkbox]").change(function(e){var t=s(this).attr("data-post-type");s("#yarpp-same_post_type").is(":checked")?C(s(this).is(":checked"),t):s(".yarpp_form_post_types #yarpp_post_type_"+t).prop("disabled",!1)}),s("#yarpp-same_post_type").change(function(e){s(this).is(":checked")?s(".include_post_type input[type=checkbox]").each(function(){var e=s(this).attr("data-post-type");C(s(this).is(":checked"),e)}):(s(".yarpp_form_post_types input[type=checkbox]").prop("disabled",!1),s(".yarpp_form_post_types input[type=checkbox]").siblings().hide())});var T=s('\t\t\t<div id="shareaholic-deactivate-dialog" class="shareaholic-deactivate-dialog" data-remodal-id="">\t\t\t\t<div class="shareaholic-deactivate-header" style="background-image: url('+yarpp_messages.logo+"); background-color: "+yarpp_messages.bgcolor+';"><div class="shareaholic-deactivate-text"><h2>'+yarpp_messages.model_title+'</h2></div></div>\t\t\t\t<div class="shareaholic-deactivate-body">\t\t\t\t\t<div class="shareaholic-deactivate-body-foreword">'+yarpp_messages.alert_message+'</div>\t\t\t\t\t<div class="shareaholic-deactivate-dialog-footer"> <input type="submit" class="button confirm button-secondary" id="yarpp-clear-cache-submit" value="Delete"/>\t\t\t\t\t\t<button data-remodal-action="cancel" class="button button-secondary">Cancel</button>\t\t\t\t\t\t</div>\t\t\t\t</div>\t\t\t</div>\t\t')[0];s("#yarpp-clear-cache").click(function(){s(T).remodal({hashTracking:!1,closeOnOutsideClick:!1}).open(),event.preventDefault()}),s(document.body).on("click","#yarpp-clear-cache-submit",function(){s(T).remodal().close();var a="#yarpp-clear-cache",i="#display_notices",r="notice notice-error is-dismissible";s(a).prop("disabled",!0),s.ajax({type:"POST",url:ajaxurl,data:{action:"yarpp_clear_cache",_ajax_nonce:s("#clear_cache-nonce").val()},beforeSend:function(){s(a).siblings(".spinner").addClass("is-active")},success:function(e){var t;s(a).siblings(".spinner").removeClass("is-active"),s(i).show(),"success"==e?(t=yarpp_messages.success,r="notice notice-success is-dismissible",s(a).prop("disabled",!1)):t="forbidden"==e?yarpp_messages.forbidden:"nonce_fail"==e?yarpp_messages.nonce_fail:yarpp_messages.error,s(i).addClass(r),s(i).html("<p>"+t+"</p>")},error:function(e){s(i).show(),s(i).addClass(r),s(a).siblings(".spinner").removeClass("is-active"),s(i).html("<p>"+yarpp_messages.error+"</p>")}}),s(i).delay(5e3).fadeOut(1e3)})});