filesbox/web/dist/reader/js/hooks.min.js

2 lines
4.2 KiB
JavaScript
Raw Normal View History

2024-07-26 06:10:54 +00:00
EPUBJS.Hooks.register("beforeChapterDisplay").endnotes=function(i,t){var d=t.contents.querySelectorAll("a[href]"),p=Array.prototype.slice.call(d),l=EPUBJS.core.folder(location.pathname),e=(EPUBJS.cssPath,{});EPUBJS.core.addCss(EPUBJS.cssPath+"popup.css",!1,t.render.document.head),p.forEach(function(s){function h(){var o,x,y=t.height,C=t.width,E=225;v||(o=f.cloneNode(!0),v=o.querySelector("p")),e[n]||(e[n]=document.createElement("div"),e[n].setAttribute("class","popup"),pop_content=document.createElement("div"),e[n].appendChild(pop_content),pop_content.appendChild(v),pop_content.setAttribute("class","pop_content"),t.render.document.body.appendChild(e[n]),e[n].addEventListener("mouseover",u,!1),e[n].addEventListener("mouseout",a,!1),t.on("renderer:pageChanged",g,this),t.on("renderer:pageChanged",a,this)),o=e[n],x=s.getBoundingClientRect(),c=x.left,m=x.top,o.classList.add("show"),popRect=o.getBoundingClientRect(),o.style.left=c-popRect.width/2+"px",o.style.top=m+"px",E>y/2.5&&(E=y/2.5,pop_content.style.maxHeight=E+"px"),popRect.height+m>=y-25?(o.style.top=m-popRect.height+"px",o.classList.add("above")):o.classList.remove("above"),c-popRect.width<=0?(o.style.left=c+"px",o.classList.add("left")):o.classList.remove("left"),c+popRect.width/2>=C?(o.style.left=c-300+"px",popRect=o.getBoundingClientRect(),o.style.left=c-popRect.width+"px",popRect.height+m>=y-25?(o.style.top=m-popRect.height+"px",o.classList.add("above")):o.classList.remove("above"),o.classList.add("right")):o.classList.remove("right")}function u(){e[n].classList.add("on")}function a(){e[n].classList.remove("on")}function g(){setTimeout(function(){e[n].classList.remove("show")},100)}var r,n,f,c,m,v;s.getAttribute("epub:type")=="noteref"&&(r=s.getAttribute("href"),n=r.replace("#",""),f=t.render.document.getElementById(n),s.addEventListener("mouseover",h,!1),s.addEventListener("mouseout",g,!1))}),i&&i()},EPUBJS.Hooks.register("beforeChapterDisplay").mathml=function(i,t){if(t.currentChapter.manifestProperties.indexOf("mathml")!==-1){t.render.iframe.contentWindow.mathmlCallback=i;var d=document.createElement("script");d.type="text/x-mathjax-config",d.innerHTML=' MathJax.Hub.Register.StartupHook("End",function () { window.mathmlCallback(); }); MathJax.Hub.Config({jax: ["input/TeX","input/MathML","output/SVG"],extensions: ["tex2jax.js","mml2jax.js","MathEvents.js"],TeX: {extensions: ["noErrors.js","noUndefined.js","autoload-all.js"]},MathMenu: {showRenderer: false},menuSettings: {zoom: "Click"},messageStyle: "none"}); ',t.doc.body.appendChild(d),EPUBJS.core.addScript("http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML",null,t.doc.head)}else i&&i()},EPUBJS.Hooks.register("beforeChapterDisplay").smartimages=function(i,t){var d=t.contents.querySelectorAll("img"),p=Array.prototype.slice.call(d),l=t.height;if(t.layoutSettings.layout!="reflowable")return void i();p.forEach(function(e){var s=function(){var u,a=e.getBoundingClientRect(),g=a.height,r=a.top,n=e.getAttribute("data-height"),f=n||g,c=Number(getComputedStyle(e,"").fontSize.match(/(\d*(\.\d*)?)px/)[1]),m=c?c/2:0;l=t.contents.clientHeight,r<0&&(r=0),e.style.maxWidth="100%",f+r>=l?(r<l/2?(u=l-r-m,e.style.maxHeight=u+"px",e.style.width="auto"):(f>l&&(e.style.maxHeight=l+"px",e.style.width="auto",a=e.getBoundingClientRect(),f=a.height),e.style.display="block",e.style.WebkitColumnBreakBefore="always",e.style.breakBefore="column"),e.setAttribute("data-height",u)):(e.style.removeProperty("max-height"),e.style.removeProperty("margin-top"))},h=function(){t.off("renderer:resized",s),t.off("renderer:chapterUnload",this)};e.addEventListener("load",s,!1),t.on("renderer:resized",s),t.on("renderer:chapterUnload",h),s()}),i&&i()},EPUBJS.Hooks.register("beforeChapterDisplay").transculsions=function(i,t){var d=t.contents.querySelectorAll("[transclusion]");Array.prototype.slice.call(d).forEach(function(p){function l(){r=u,n=a,r>chapter.colWidth&&(e=chapter.colWidth/r,r=chapter.colWidth,n*=e),h.width=r,h.height=n}var e,s=p.getAttribute("ref"),h=document.createElem