This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblockit.min.js
1 lines (1 loc) · 10.7 KB
/
blockit.min.js
1
function activeMenu(e){"use strict";const t=Object.assign({},{activeClass:"uk-active",navbarClass:"uk-navbar-nav",dropdownClass:"uk-navbar-dropdown"},e);if(null!==document.querySelector("."+t.navbarClass)){const e=location.pathname.slice(location.pathname.lastIndexOf("/")+1),n=document.querySelector("."+t.navbarClass).querySelectorAll("li"),a=document.querySelectorAll("."+t.dropdownClass),r={addActive:function(n){"/"==location.pathname[location.pathname.length-1]?n[0].classList.add(t.activeClass):n.forEach(n=>{n.children[0].attributes[0].value==e&&n.classList.add(t.activeClass)})},addActiveParent:function(e){e.forEach(e=>{null!==e.querySelector("."+t.activeClass)&&e.parentElement.classList.add(t.activeClass)})},init:function(){r.addActive(n),r.addActiveParent(a)}};r.init()}}function breadcrumb(e){"use strict";const t=Object.assign({},{homeTitle:"Home",breadcrumbElement:"uk-breadcrumb",articleElement:"in-article",titleElement:"h2",blogTitle:"blog",truncate:!0,truncateWords:60},e);if(null!==document.querySelector("."+t.breadcrumbElement)){const e=document.querySelector("."+t.breadcrumbElement),n=document.querySelector(".uk-navbar-nav"),a=n.children[0].getElementsByTagName("a")[0].pathname,r=n.querySelectorAll("li.uk-active"),o=document.title.toLowerCase();let i;const l={createBreadcrumb:function(){e.innerHTML=`<li><a href="${a.slice(location.pathname.lastIndexOf("/")+1)}">${t.homeTitle}</a></li>`,r.forEach((function(t){i=document.createElement("li"),i.innerHTML=`<a href="${t.querySelector("a").attributes[0].textContent}">${t.querySelector("a").innerText}</a>`,e.appendChild(i)}))},createBreadcrumbLast:function(){const t=e.children[e.childNodes.length-1];i=document.createElement("li"),t&&(t.remove(),i.innerHTML=`<span>${t.innerText}</span>`,e.appendChild(i))},createBreadcrumbArticle:function(a){if(o.includes(t.blogTitle)&&null!==document.querySelector("."+t.articleElement)){let r=document.querySelector("."+t.articleElement).querySelector(t.titleElement).innerText;const o=document.createElement("li"),i=n.querySelectorAll("li a");e.innerHTML=`<li><a href="${a.slice(location.pathname.lastIndexOf("/")+1)}">${t.homeTitle}</a></li>`,i.forEach((function(n){if(n.innerText.toLowerCase()==t.blogTitle){const t=document.createElement("li"),a=document.createElement("li");n.parentNode.classList.add("uk-active"),t.innerHTML=`<a href="${n.parentNode.parentNode.parentNode.parentNode.querySelector("a")}">${n.parentNode.parentNode.parentNode.parentNode.querySelector("a").innerText}</a>`,a.innerHTML=`<a href="${n}">${n.innerText}</a>`,n.parentNode.parentNode.parentNode.parentNode.classList.contains("uk-container")||(n.parentNode.parentNode.parentNode.parentNode.classList.add("uk-active"),e.appendChild(t)),e.appendChild(a)}})),r=t.truncate?l.truncateBreadcrumb(r,t.truncateWords):r,o.innerHTML=`<span>${r}</span>`,e.appendChild(o)}},truncateBreadcrumb:function(e,t){return e.length<=t?e:e.slice(0,t)+"..."},init:function(){l.createBreadcrumb(),l.createBreadcrumbLast(),l.createBreadcrumbArticle(a)}};l.init()}}function mobileNav(e){"use strict";const t=Object.assign({},{addonButtons:!0,buttons:[{name:"",url:"",type:"primary",icon:"sign-in-alt"}]},e);if(null!==document.querySelector(".uk-navbar-nav")){const e=document.querySelector(".uk-navbar-nav"),n=e.cloneNode(!0),a=n.querySelectorAll("ul.uk-nav"),r=document.querySelector(".in-optional-nav"),o={createMobileNav:function(){n.classList.remove("uk-navbar-nav","uk-visible@m"),n.classList.add("uk-nav-default","uk-nav-parent-icon"),n.setAttribute("data-uk-nav",""),Array.from(n.children).forEach((function(e){2==e.children.length&&(e.classList.add("uk-parent"),e.querySelectorAll(".fa-chevron-down")[0].remove())}));const e=e=>e.replaceWith(...e.childNodes);a.forEach((function(t){t.classList.remove("uk-nav","uk-navbar-dropdown-nav"),t.classList.add("uk-nav-sub"),e(t.parentElement),null!==t.querySelector("a.uk-disabled")&&(e(t.parentElement.parentElement),e(t.parentElement),t.querySelector("a.uk-disabled").parentElement.parentElement.remove())}))},createMobileBtn:function(){const t=document.createElement("div"),a=document.createElement("div");t.classList.add("uk-navbar-item","in-mobile-nav","uk-hidden@m"),t.innerHTML='<a class="uk-button" href="#modal-full" data-uk-toggle><i class="fas fa-bars"></i></a>',a.id="modal-full",a.classList.add("uk-modal-full"),a.setAttribute("data-uk-modal",""),a.innerHTML=`\n <div class="uk-modal-dialog uk-flex uk-flex-center uk-flex-middle" data-uk-height-viewport>\n <a class="uk-modal-close-full uk-button"><i class="fas fa-times"></i></a>\n <div class="uk-width-large uk-padding-large">\n ${n.outerHTML}\n ${o.createAddonBtn()}\n </div>\n </div>`,e.parentElement.removeChild(e.parentElement.lastChild),e.parentElement.appendChild(t).appendChild(a)},createAddonBtn:function(){let e="";return t.addonButtons&&null!==r&&r.children.length>0&&t.buttons.forEach((function(t){e+=`<a href="${o.addonBtnUrl(t)}" class="uk-button uk-button-${t.type} uk-border-rounded uk-align-center" style="margin-bottom : -12px">${o.addonBtnName(t)}${o.addonBtnIcon(t)}</a>`})),e},addonBtnName:function(e){let t;return t=e.name.length>0?e.name:r.querySelector("a").innerText,t},addonBtnUrl:function(e){let t;return t=e.url.length>0?e.url:r.querySelector("a").href,t},addonBtnIcon:function(e){let t;return t=void 0!==e.icon&&e.icon.length>0?`<i class="fas fa-${e.icon} uk-margin-small-left"></i>`:"",t},init:function(){o.createMobileNav(),o.createMobileBtn()}};o.init()}}function serialize(e){return Array.from(new FormData(e),e=>e.map(encodeURIComponent).join("=")).join("&")}function ajaxRequest(e,t,n,a){const r=new XMLHttpRequest;r.open(e,t,!0),r.setRequestHeader("Content-type","application/x-www-form-urlencoded"),r.send(n),r.onreadystatechange=function(){4==r.readyState&&200==r.status?a(!0,r.responseText):a(!1,"")}}function emptyElements(e){for(let t of e)t.innerHTML=""}function counterUp(e){"use strict";this.defaults={duration:2e3,prepend:"",append:"",selector:".in-counter",start:0,end:100,intvalues:!1,interval:100};var t=this;for(var n in this.upating=!1,this.intervalID=null,this.props={},this.defaults)void 0!==n&&(t.props[n]=t.defaults[n],e.hasOwnProperty(n)&&t.props.hasOwnProperty(n)&&(t.props[n]=e[n]));this.domelems=document.querySelectorAll(this.props.selector),this.elems=[];var a={};this.domelems.forEach((function(e){a.obj=e;var n=parseInt(e.getAttribute("data-counter-start"));isNaN(n)?a.start=t.props.start:a.start=n;var r=parseInt(e.getAttribute("data-counter-end"));isNaN(r)?a.end=t.props.end:a.end=r;var o=parseInt(e.getAttribute("data-counter-duration"));isNaN(o)?a.duration=t.props.duration:a.duration=o;var i=e.getAttribute("data-counter-prepend");a.prepend=null==i?t.props.prepend:i;var l=e.getAttribute("data-counter-append");a.append=null==l?t.props.append:l;var c=e.getAttribute("data-counter-intval");a.intvalues=null==c?t.props.intvalues:c,a.step=(a.end-a.start)/(a.duration/t.props.interval),a.val=a.start,t.elems.push(a),a={}}))}function modalIframe(e){"use strict";const t=Object.assign({},{selector:"in-iframe",videos:[{id:"",url:""}]},e);if(null!==document.querySelector("."+t.selector)){const e=window.matchMedia("(max-width: 960px)"),n=document.querySelectorAll("."+t.selector),a=t.videos,r={createIframeVideo:function(){const e=window.screen.width/100*r.getAspectRatio(),t=e/(16/9);n.forEach((function(n,r){n.parentElement.setAttribute("id",a[r].id),n.parentElement.previousElementSibling.children[0].setAttribute("href","#"+a[r].id);new IntersectionObserver((function(o){if(o[0].isIntersecting&&1===n.children.length){const o=document.createElement("iframe");o.setAttribute("src",a[r].url),o.setAttribute("width",e),o.setAttribute("height",t),o.setAttribute("data-uk-video","automute: true"),n.appendChild(o)}}),{threshold:[0]}).observe(n)}))},getAspectRatio:function(){let t;return t=e.matches?85:45,t},init:function(){r.createIframeVideo(),r.getAspectRatio()}};r.init()}}window.addEventListener("load",(function(){const e="loaded";!0&&document.querySelector("body").classList.add(e)})),document.querySelectorAll(".media").length>0&&Plyr.setup(".media"),activeMenu(),breadcrumb(),mobileNav(),function(){if(null!==document.querySelector(".in-totop")){const e=document.querySelector(".in-totop");window.addEventListener("scroll",(function(){setTimeout((function(){window.scrollY>300?(e.style.opacity=1,e.classList.add("uk-animation-slide-top")):(e.style.opacity-=.1,e.classList.remove("uk-animation-slide-top"))}),400)}))}}(),document.addEventListener("DOMContentLoaded",()=>{const e=document.getElementById("contact-form"),t=document.getElementById("sendemail");void 0!==t&&null!=t&&t.addEventListener("click",t=>{t.preventDefault();ajaxRequest("POST","./sendmail.php",serialize(document.getElementById("contact-form")),(t,n)=>{if(t){const t=JSON.parse(n);t.isSuccess?(UIkit.notification("<i class='fas fa-check-circle uk-margin-small-right'></i> Your message has been sent successfully. Thank you!",{timeout:3e3,status:"primary",pos:"bottom-right"}),e.reset()):(t.nameError&&document.getElementById("name").classList.add("uk-form-danger"),document.getElementById("name").addEventListener("click",(function(){document.getElementById("name").classList.remove("uk-form-danger")})),t.emailError&&document.getElementById("email").classList.add("uk-form-danger"),document.getElementById("email").addEventListener("click",(function(){document.getElementById("email").classList.remove("uk-form-danger")})),t.subjectError&&document.getElementById("subject").classList.add("uk-form-danger"),document.getElementById("subject").addEventListener("click",(function(){document.getElementById("subject").classList.remove("uk-form-danger")})),t.messageError&&document.getElementById("message").classList.add("uk-form-danger"),document.getElementById("message").addEventListener("click",(function(){document.getElementById("message").classList.remove("uk-form-danger")})))}})})}),counterUp.prototype.start=function(){"use strict";var e=this;if(null!=document.querySelector(e.props.selector)){new IntersectionObserver((function(t){t[0].isIntersecting&&(this.intervalID=setInterval((function(){e.updating||e.update()}),e.props.interval))}),{threshold:[0]}).observe(document.querySelector(e.props.selector))}},counterUp.prototype.update=function(){"use strict";this.updating=!0;var e=!0;this.elems.forEach((function(t){t.val+=t.step,t.val<t.end?(1==t.intvalues?t.obj.innerHTML=t.prepend+Math.floor(t.val).toString()+t.append:t.obj.innerHTML=t.prepend+(Math.round(100*t.val)/100).toString()+t.append,e=!1):t.obj.innerHTML=t.prepend+t.end.toString()+t.append})),1==e&&clearInterval(this.intervalID),this.updating=!1},function(){if(null!==document.querySelector(".in-timeline-2")){Array.from(document.querySelector(".in-timeline-2").children).filter((function(e,t){return t%2==1})).forEach((function(e){e.children[0].classList.add("right")}))}}();