template.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. (function(){
  2. window.addEventListener('load', () => {
  3. const el = document.querySelector('.phpdocumentor-on-this-page__content')
  4. if (!el) {
  5. return;
  6. }
  7. const observer = new IntersectionObserver(
  8. ([e]) => {
  9. e.target.classList.toggle("-stuck", e.intersectionRatio < 1);
  10. },
  11. {threshold: [1]}
  12. );
  13. observer.observe(el);
  14. })
  15. })();
  16. function openSvg(svg) {
  17. // convert to a valid XML source
  18. const as_text = new XMLSerializer().serializeToString(svg);
  19. // store in a Blob
  20. const blob = new Blob([as_text], { type: "image/svg+xml" });
  21. // create an URI pointing to that blob
  22. const url = URL.createObjectURL(blob);
  23. const win = open(url);
  24. // so the Garbage Collector can collect the blob
  25. win.onload = (evt) => URL.revokeObjectURL(url);
  26. };
  27. var svgs = document.querySelectorAll(".phpdocumentor-uml-diagram svg");
  28. for( var i=0,il = svgs.length; i< il; i ++ ) {
  29. svgs[i].onclick = (evt) => openSvg(evt.target);
  30. }