You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
1.0 KiB
JavaScript
1 line
1.0 KiB
JavaScript
7 months ago
|
(()=>{"use strict";const e=window.wp.domReady,t=window.webStoriesData||{},n=function(e){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const o=e.value,i=e.closest(".widget"),d=t.fields[o];for(const[e,t]of Object.entries(d)){const o=i.querySelector(`.${e}.stories-widget-field`),d=i.querySelector(`.${e}_wrapper`);if(o&&d){"checkbox"===o.getAttribute("type")?(n&&(o.checked=!1),t.hidden&&(o.checked=t.show),d.style.display=t.hidden?"none":"block"):d.style.display=t.show?"block":"none"}}},o=()=>document.getElementsByClassName("view_type stories-widget-field"),i=function(){const e=o();if(e.length)for(let t=0;t<e.length;t++)e[t].addEventListener("change",(e=>{n(e.target,!1)}))};e((()=>{i(),function(){const e=o(),t=document.createEvent("HTMLEvents");t.initEvent("change",!1,!0);for(let n=0;n<e.length;n++)e[n].dispatchEvent(t)}()}));const d=(e,t)=>{if(!t[0])return;const o=t[0].querySelectorAll(".stories-widget-field.view_type");o.length&&(n(o[0],!1),i())},c=window.jQuery;c(document).on("widget-updated",d),c(document).on("widget-added",d)})();
|