solorice/vscodium/extensions/kiteco.kite-0.147.0/dist/assets/js/assets.js
2022-04-28 21:17:01 +03:00

1 line
6.9 KiB
JavaScript

window.handleCollapsibles=function(){[].slice.call(document.querySelectorAll(".collapsible")).forEach((e=>{const t=e.querySelector(".section-content");let s=e.querySelector('a[data-action="expand"]');s||((s=document.createElement("a")).href="#",s.dataset.action="expand",s.innerHTML="show more&hellip;",s.addEventListener("click",(t=>{t.preventDefault(),"expand"===s.dataset.action?(s.dataset.action="collapse",s.innerHTML="show less&hellip;",e.classList.remove("collapse")):(s.dataset.action="expand",s.innerHTML="show more&hellip;",e.classList.add("collapse")),this.scroll()}))),e.classList.add("collapse"),t.scrollHeight>t.offsetHeight?(e.classList.add("overflow"),e.appendChild(s)):(e.classList.remove("overflow"),s.parentNode&&e.removeChild(s))}))},window.request=function(e,t,s){return new Promise((function(o,i){var n=new XMLHttpRequest;n.open(e,t),n.onload=function(){this.status>=200&&this.status<300?o(n.responseText):i({status:this.status,statusText:n.responseText})},n.onerror=function(){i({status:this.status,statusText:n.statusText})},n.send(s)}))},window.requestGet=function(e){return window.request("GET",`http://localhost:${window.PORT}${e}`)},window.requestPost=function(e,t){const s=new FormData;for(const e in t)s.set(e,t[e])},window.showFeedbackFeedback=function(e,t,{confirmation:s}={}){let o=e.parentNode.querySelector(".feedback-feedback");o.classList.toggle("confirmation",s),o.classList.toggle("hint",!s),o.innerHTML=t},window.hideFeedbackFeedback=function(e){e.parentNode.querySelector(".feedback-feedback").classList.remove("hint")},window.handleExternalLinks=function(){[].slice.call(document.querySelectorAll("a.external_link")).forEach((e=>{e.href=e.getAttribute("href").replace(/^#/,"")}))},window.initDownloadProgress=function(){const e=document.querySelector(".download-kite"),t=document.querySelector("progress"),s=setInterval((()=>{requestGet("/install/progress").then((o=>{o=parseFloat(o),e.classList.toggle("hidden",-1===o||1===o),-1!==o&&(t.value=Math.round(100*o),1===o&&clearInterval(s))}))}),50)},window.submitEvent=function(e){const t=document.querySelector("form");return t.querySelector('input[name="event"]').value=e,request(t.method,t.action,new FormData(t)),!1};const iconDocs='<svg viewBox="0 0 17.22 17"><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path id="editor-books-library-collection-glyph" d="M0,5.9V16.39c0,.31.36.55.8.55H3.23c.44,0,.8-.24.8-.55V5.9c0-.31-.36-.55-.8-.55H.8C.36,5.35,0,5.59,0,5.9Zm4.83-5V16.14a.81.81,0,0,0,.8.81H8.05a.8.8,0,0,0,.8-.81V.86a.81.81,0,0,0-.8-.81H5.62A.8.8,0,0,0,4.83.86Zm4.53.78,4,14.76a.81.81,0,0,0,1,.57l2.35-.63a.8.8,0,0,0,.56-1L13.24.6a.81.81,0,0,0-1-.57L9.91.66A.8.8,0,0,0,9.35,1.64Z"/></g></g></svg>',iconExamples='<svg viewBox="0 0 22.96 17.23"><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path d="M7.18,14.12l-.63.63a.39.39,0,0,1-.58,0L.13,8.9a.39.39,0,0,1,0-.58L6,2.48a.39.39,0,0,1,.58,0l.63.63a.39.39,0,0,1,0,.58L2.25,8.62l4.93,4.93a.39.39,0,0,1,0,.58ZM14.59.73,9.91,16.93a.41.41,0,0,1-.19.24.35.35,0,0,1-.29,0L8.65,17a.41.41,0,0,1-.24-.19.38.38,0,0,1,0-.31L13.05.3a.41.41,0,0,1,.19-.24.35.35,0,0,1,.29,0l.78.21a.41.41,0,0,1,.24.19A.38.38,0,0,1,14.59.73ZM22.84,8.9,17,14.75a.39.39,0,0,1-.58,0l-.63-.63a.39.39,0,0,1,0-.58l4.93-4.93L15.79,3.68a.39.39,0,0,1,0-.58l.63-.63a.39.39,0,0,1,.58,0l5.85,5.85a.39.39,0,0,1,0,.58Z"/></g></g></svg>';window.jumpTo=function(e){const t=document.querySelector(e),s=document.querySelector(".sections-wrapper"),o=(s.getBoundingClientRect(),s.scrollTop,t.offsetTop);s.scrollTop=o-0},window.createJumpTo=function(){const e=document.querySelector(".examples-from-your-code")||document.querySelector(".how-to"),t=[];document.querySelector(".summary")&&t.push(`<a href="#" class="docs-button" onclick="jumpTo('.summary'); return false;">${iconDocs} <span>Description</span></a>`),e&&t.push(`<a href="#" class="examples-button" onclick="jumpTo('.${e.className}'); return false;">${iconExamples} <span>How to</span></a>`),t.length>0&&(document.querySelector("footer .actions").innerHTML=`Jump to ${t.join(" ")}`)},window.StickyTitle=class{constructor(e,t){this.scrollContainer=t,this.titleHeight=40,this.stickies=[].slice.call(e).map((e=>{const t=document.createElement("div");return t.className="sticky",t.innerHTML=e.innerHTML,e.innerHTML="",e.appendChild(t),t.parentNode.style.height=this.titleHeight+"px",t.style.width="100%",t})),t.addEventListener("scroll",(e=>{this.scroll()})),this.stickies.forEach((e=>{e.addEventListener("mousewheel",(e=>{t.scrollTop+=e.deltaY}))})),this.scrollContainer.addEventListener("click",(e=>{this.stickies.some((t=>{const s=t.getBoundingClientRect();e.pageY>=s.top&&e.pageY<s.bottom&&this.scrollTo(t.parentNode)}))})),this.handleCollapsibles(),window.addEventListener("resize",(()=>{this.measureWidthAndHeight()})),this.scroll(),this.measureWidthAndHeight()}handleCollapsibles(){[].slice.call(this.scrollContainer.querySelectorAll(".collapsible")).forEach((e=>{const t=e.querySelector(".section-content");let s=e.querySelector('a[data-action="expand"]');s||((s=document.createElement("a")).href="#",s.dataset.action="expand",s.innerHTML="show more&hellip;",s.addEventListener("click",(t=>{t.preventDefault(),"expand"===s.dataset.action?(s.dataset.action="collapse",s.innerHTML="show less&hellip;",e.classList.remove("collapse")):(s.dataset.action="expand",s.innerHTML="show more&hellip;",e.classList.add("collapse")),this.scroll()}))),e.classList.add("collapse"),t.scrollHeight>t.offsetHeight?(e.classList.add("overflow"),e.appendChild(s)):(e.classList.remove("overflow"),s.parentNode&&e.removeChild(s))})),this.scroll()}measureWidthAndHeight(){null!=this.width&&null!=this.height&&this.width===this.scrollContainer.offsetWidth&&this.height===this.scrollContainer.offsetHeight||(this.width=this.scrollContainer.offsetWidth,this.height=this.scrollContainer.offsetHeight,this.compactMode=this.titleHeight*this.stickies.length+200>this.height,this.scrollContainer.classList.toggle("compact",this.compactMode),requestAnimationFrame((()=>this.scroll())))}dispose(){this.subscriptions.dispose(),this.stickies=null,this.scrollContainer=null}scrollTo(e){const t=this.scrollContainer.getBoundingClientRect(),s=this.scrollContainer.scrollTop,o=e.getBoundingClientRect().top+s-t.top,i=this.stickies.reduce(((e,i)=>i.parentNode.getBoundingClientRect().top+s-t.top<o?e+i.offsetHeight:e),0);this.scrollContainer.scrollTop=o-i}scroll(){if(this.scrollContainer)if(this.compactMode)this.stickies.forEach((e=>e.classList.remove("fixed")));else{const e=this.scrollContainer.getBoundingClientRect(),t=this.scrollContainer.scrollTop+e.top,s=t+e.height;let o=t,i=s,n=this.stickies.slice();(n=(n=n.filter(((s,i)=>!(s.parentNode.getBoundingClientRect().top+t-e.top<o&&(s.classList.add("fixed"),s.style.top=i*this.titleHeight+"px",o+=this.titleHeight,1))))).reverse().filter(((s,o)=>!(s.parentNode.getBoundingClientRect().bottom+t-e.top>i&&(s.classList.add("fixed"),s.style.top=e.height-(o+1)*this.titleHeight+"px",i-=this.titleHeight,1))))).forEach((e=>e.classList.remove("fixed")))}}};