cms系统的站点模板库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
cms_templates/mytoothbetold/js/app.min.js@ver=1.0.10

1 lines
4.1 KiB

function openModal(){document.getElementById("modal").style.display="flex"}function closeModal(){document.getElementById("modal").style.display="none"}function plusSlides(e){showSlides(slideIndex+=e)}function currentSlide(e){showSlides(slideIndex=e)}function showSlides(e){var t,n=document.getElementsByClassName("slide"),a=document.getElementById("caption");for(e>n.length&&(slideIndex=1),e<1&&(slideIndex=n.length),t=0;t<n.length;t++)n[t].style.display="none";n[slideIndex-1].style.display="block",a.innerHTML=n[slideIndex-1].dataset.caption}function WebpIsSupported(e){if(window.createImageBitmap){fetch("data:image/webp;base64,UklGRiQAAABXRUJQVlA4IBgAAAAwAQCdASoCAAEAAQAcJaQAA3AA/v3AgAA=").then(function(e){return e.blob()}).then(function(t){createImageBitmap(t).then(function(){e(!0)},function(){e(!1)})})}else e(!1)}function replaceImages(){WebpIsSupported(function(e){for(var t=document.getElementsByClassName("webp-check"),n=0;n<t.length;n++){var a="",s=window.getComputedStyle(t[n]).display;e?""!=t[n].getAttribute("data-webp-url")&&null!=t[n].getAttribute("data-webp-url")?"none"!=s&&(a=t[n].getAttribute("data-webp-url")):""!=t[n].getAttribute("mobile-data-webp-url")&&null!=t[n].getAttribute("mobile-data-webp-url")?"none"!=s&&(a=t[n].getAttribute("data-webp-url")):"none"!=s&&(a=t[n].getAttribute("data-jpg-url")):"none"!=s&&(a=t[n].getAttribute("data-jpg-url")),cssVal='background-image: url("'+a+'")',t[n].setAttribute("style",cssVal)}})}replaceImages(),window.addEventListener("resize",function(){replaceImages()},!0),function(){var e,t,n,a,s,i,l,o,d;if((e=document.getElementById("masthead"))&&void 0!==(t=e.getElementsByTagName("button")[0]))if(o=document.getElementById("site-navigation"),n=e.getElementsByTagName("ul")[0],l=document.getElementById("search-icon"),void 0!==n){n.setAttribute("aria-expanded","false"),-1===n.className.indexOf("nav-menu")&&(n.className+=" nav-menu"),t.addEventListener("click",function(){e.className.indexOf("toggled")>-1||(e.className+=" toggled",t.setAttribute("aria-expanded","true"),n.setAttribute("aria-expanded","true"),o.style.overflow="visible")},!0),r(),window.onresize=function(){setTimeout(function(){r()},200)},d=document.getElementsByClassName("toggle-submenu");for(var c=0;c<d.length;c++)d[c].addEventListener("click",function(){-1===this.parentNode.className.indexOf("submenu-active")?this.parentNode.className+=" submenu-active":this.parentNode.classList.remove("submenu-active")});for(s=0,i=(a=n.getElementsByTagName("a")).length;s<i;s++)a[s].addEventListener("focus",u,!0),a[s].addEventListener("blur",u,!0);l.addEventListener("click",function(){-1!==l.parentElement.className.indexOf("search-active")?l.parentElement.className=l.parentElement.className.replace(" search-active",""):(l.parentElement.className+=" search-active",setTimeout(function(){document.getElementById("search-field").focus()},500))},!0),function(e){var t,n,a=e.querySelectorAll(".menu-item-has-children > a, .page_item_has_children > a"),s=!1;try{var i=Object.defineProperty({},"passive",{get:function(){s=!0}});window.addEventListener("testPassive",null,i),window.removeEventListener("testPassive",null,i)}catch(e){}if("ontouchstart"in window)for(t=function(e){var t,n=this.parentNode;if(n.classList.contains("focus"))n.classList.remove("focus");else{for(e.preventDefault(),t=0;t<n.parentNode.children.length;++t)n!==n.parentNode.children[t]&&n.parentNode.children[t].classList.remove("focus");n.classList.add("focus")}},n=0;n<a.length;++n)a[n].addEventListener("touchstart",t,!!s&&{passive:!0})}(e)}else t.style.display="none";function r(){window.outerWidth>=1200&&(e.className.indexOf("desktop-toggle")>-1?-1==e.className.indexOf("toggled")&&(e.className+=" toggled",t.setAttribute("aria-expanded","true"),n.setAttribute("aria-expanded","true"),o.style.overflow="visible"):e.className.indexOf("toggled")>-1&&Array.prototype.forEach.call(e.querySelectorAll(".submenu-active"),function(e){e.classList.remove("submenu-active")}))}function u(){for(var e=this;-1===e.className.indexOf("nav-menu");)"li"===e.tagName.toLowerCase()&&(-1!==e.className.indexOf("focus")?e.className=e.className.replace(" focus",""):e.className+=" focus"),e=e.parentElement}}();