1"use strict"; 2 3if (!Element.prototype.matches) { 4 Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector; 5} 6if (!Element.prototype.closest) { 7 Element.prototype.closest = function (s) { 8 var el = this; 9 do { 10 if (el.matches(s)) return el; 11 el = el.parentElement || el.parentNode; 12 } while (el !== null && el.nodeType === 1); 13 return null; 14 }; 15} 16function ub_hashHeaderScroll() { 17 var scrollType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "auto"; 18 var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ""; 19 var offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; 20 if (window.location.hash) { 21 var targetHeading = document.getElementById(window.location.hash.slice(1)); 22 var probableHeaders; 23 try { 24 probableHeaders = document.elementsFromPoint(window.innerWidth / 2, 0); 25 } catch (e) { 26 probableHeaders = document.msElementsFromPoint(window.innerWidth / 2, 0); 27 } 28 var stickyHeaders = Array.prototype.slice.call(probableHeaders).filter(function (e) { 29 return ["fixed", "sticky"].includes(window.getComputedStyle(e).position); 30 }); 31 var stickyHeaderHeights = stickyHeaders.map(function (h) { 32 return h.offsetHeight; 33 }); 34 var deficit = targetHeading.getBoundingClientRect().y || targetHeading.getBoundingClientRect().top; 35 switch (scrollType) { 36 default: 37 window.scrollBy(0, deficit); 38 break; 39 case "off": 40 window.scrollBy(0, deficit); 41 break; 42 case "auto": 43 window.scrollBy(0, deficit - (stickyHeaders.length ? Math.max.apply(Math, stickyHeaderHeights) : 0)); 44 break; 45 case "fixedamount": 46 window.scrollBy(0, deficit - offset); 47 break; 48 case "namedelement": 49 window.scrollBy(0, deficit - (document.querySelector(target) ? document.querySelector(target).offsetHeight : 0)); 50 break; 51 } 52 } 53} 54document.addEventListener("DOMContentLoaded", function () { 55 var instances = []; 56 if (document.getElementById("ub_table-of-contents-toggle-link")) { 57 instances.push(document.getElementById("ub_table-of-contents-toggle-link")); 58 } else { 59 instances = Array.prototype.slice.call(document.getElementsByClassName("ub_table-of-contents-toggle-link")); 60 } 61 instances.forEach(function (instance) { 62 var block = instance.closest(".ub_table-of-contents"); 63 var tocContainer = block.querySelector(".ub_table-of-contents-container"); 64 var containerStyle = tocContainer.style; 65 var tocExtraContainer = block.querySelector(".ub_table-of-contents-extra-container"); 66 var extraContainerStyle = tocExtraContainer.style; 67 var tocMain = tocExtraContainer.parentNode; 68 var mainStyle = block.style; 69 var showButton = block.getAttribute("data-showtext") || "show"; 70 var hideButton = block.getAttribute("data-hidetext") || "hide"; 71 tocContainer.removeAttribute("style"); 72 var padding = 60; 73 function mobileEvent(mql) { 74 if (mql.matches) { 75 if (!tocMain.classList.contains("ub_table-of-contents-collapsed")) { 76 tocMain.classList.add("ub_table-of-contents-collapsed"); 77 instance.innerHTML = showButton; 78 tocContainer.classList.add("ub-hide"); 79 } 80 } else if (JSON.parse(tocMain.dataset.initiallyshow)) { 81 tocMain.classList.remove("ub_table-of-contents-collapsed"); 82 instance.innerHTML = hideButton; 83 tocContainer.classList.remove("ub-hide"); 84 } 85 } 86 var mobileQuery = window.matchMedia("(max-width: 800px)"); 87 if (JSON.parse(block.getAttribute("data-initiallyhideonmobile"))) { 88 mobileQuery.addListener(mobileEvent); 89 } 90 instance.addEventListener("click", function (event) { 91 event.preventDefault(); 92 var curWidth = block.offsetWidth; 93 if (block.classList.contains("ub_table-of-contents-collapsed")) { 94 //begin showing 95 tocExtraContainer.classList.remove("ub-hide"); 96 tocContainer.classList.remove("ub-hide"); 97 var targetHeight = tocExtraContainer.offsetHeight + padding / 2; //doesn't include padding 98 tocContainer.classList.add("ub-hiding"); 99 tocExtraContainer.classList.add("ub-hiding"); 100 mainStyle.width = "".concat(curWidth, "px"); //also take into account number of columns 101 102 setTimeout(function () { 103 mainStyle.width = "auto"; 104 block.classList.remove("ub_table-of-contents-collapsed"); 105 var fullWidth = getComputedStyle(block).width.slice(0, -2); 106 mainStyle.width = "".concat(curWidth, "px"); 107 setTimeout(function () { 108 Object.assign(containerStyle, { 109 height: "".concat(targetHeight, "px"), 110 width: "100px" 111 }); 112 Object.assign(extraContainerStyle, { 113 height: "".concat(targetHeight, "px"), 114 width: "100px" 115 }); 116 tocContainer.classList.remove("ub-hiding"); 117 tocExtraContainer.classList.remove("ub-hiding"); 118 mainStyle.width = "".concat(fullWidth, "px"); 119 setTimeout(function () { 120 tocContainer.style.width = "".concat(fullWidth - padding, "px"); 121 tocExtraContainer.style.width = "".concat(fullWidth - padding, "px"); 122 }, 50); 123 }, 50); 124 }, 50); 125 } else { 126 //begin hiding 127 mainStyle.width = "".concat(block.offsetWidth, "px"); 128 Object.assign(containerStyle, { 129 height: "".concat(tocContainer.offsetHeight, "px"), 130 width: "".concat(tocContainer.offsetWidth, "px") 131 }); 132 Object.assign(extraContainerStyle, { 133 height: "".concat(tocExtraContainer.offsetHeight, "px"), 134 width: "".concat(tocExtraContainer.offsetWidth, "px") 135 }); 136 setTimeout(function () { 137 tocContainer.classList.add("ub-hiding"); 138 Object.assign(containerStyle, { 139 height: "0", 140 width: "0" 141 }); 142 Object.assign(extraContainerStyle, { 143 height: "0", 144 width: "0" 145 }); 146 block.classList.add("ub_table-of-contents-collapsed"); 147 padding = parseInt(getComputedStyle(tocExtraContainer).paddingLeft.slice(0, -2)) + parseInt(getComputedStyle(tocExtraContainer).paddingRight.slice(0, -2)); 148 149 //measure width of toc title + toggle button, then use it as width of block 150 151 mainStyle.width = "".concat(5 + padding + instance.closest(".ub_table-of-contents-header-container").scrollWidth, "px"); 152 }, 50); 153 } 154 instance.innerHTML = tocContainer.classList.contains("ub-hiding") ? hideButton : showButton; 155 mobileQuery.removeListener(mobileEvent); 156 }); 157 tocContainer.addEventListener("transitionend", function () { 158 if (tocContainer.offsetHeight === 0) { 159 //hiding is done 160 tocContainer.classList.remove("ub-hiding"); 161 tocContainer.classList.add("ub-hide"); 162 tocExtraContainer.classList.remove("ub-hiding"); 163 tocExtraContainer.classList.add("ub-hide"); 164 if (containerStyle.display === "block") { 165 containerStyle.display = ""; 166 } 167 if (extraContainerStyle.display === "block") { 168 extraContainerStyle.display = ""; 169 } 170 mainStyle.minWidth = ""; 171 } 172 Object.assign(containerStyle, { 173 height: "", 174 width: "" 175 }); 176 Object.assign(extraContainerStyle, { 177 height: "", 178 width: "" 179 }); 180 mainStyle.width = ""; 181 }); 182 }); 183 if (window.location.hash) { 184 var sourceToC = document.querySelector(".ub_table-of-contents"); 185 if (sourceToC) { 186 var type = sourceToC.dataset.scrolltype; 187 var offset = type === "fixedamount" ? sourceToC.dataset.scrollamount : 0; 188 var target = type === "namedelement" ? sourceToC.dataset.scrolltarget : ""; 189 setTimeout(function () { 190 return ub_hashHeaderScroll(type, target, offset); 191 }, 50); 192 } 193 } 194 195 // Link to divider block. 196 var tableOfContents = document.querySelectorAll('.ub_table-of-contents[data-linktodivider="true"]'); 197 var dividers = document.querySelectorAll(".wp-block-ub-divider:not(.ub-divider-orientation-vertical)"); 198 if (tableOfContents.length > 0 && dividers.length > 0) {
199 dividers.forEach(function (divider) { 200 var closestTOC = null; 201 var minDistance = Infinity; 202 tableOfContents.forEach(function (toc) { 203 var dividerTop = divider.getBoundingClientRect().top; 204 var tocTop = toc.getBoundingClientRect().top; 205 var distance = Math.abs(dividerTop - tocTop); 206 if (distance < minDistance) { 207 minDistance = distance; 208 closestTOC = toc; 209 } 210 }); 211 if (closestTOC) { 212 var linkToTOC = document.createElement("a"); 213 linkToTOC.href = "#".concat(closestTOC.getAttribute("id")); 214 linkToTOC.classList.add("ub-linked-to-toc"); 215 linkToTOC.innerText = "Table Of Contents"; 216 divider.appendChild(linkToTOC); 217 } 218 }); 219 } 220 var smoothScrollElements = document.querySelectorAll('[data-enablesmoothscroll="true"]'); 221 smoothScrollElements.forEach(function (element) { 222 element.style.scrollBehavior = "smooth"; 223 }); 224}); 225window.onhashchange = function () { 226 var sourceToC = document.querySelector(".ub_table-of-contents"); 227 if (sourceToC) { 228 var type = sourceToC.dataset.scrolltype; 229 var offset = type === "fixedamount" ? sourceToC.dataset.scrollamount : 0; 230 var target = type === "namedelement" ? sourceToC.dataset.scrolltarget : ""; 231 ub_hashHeaderScroll(type, target, offset); 232 } 233}; 234Array.prototype.slice.call(document.querySelectorAll(".ub_table-of-contents-container li > a")).forEach(function (link) { 235 link.addEventListener("click", function (e) { 236 var hashlessLink = link.href.replace(link.hash, ""); 237 var targetPageNumber = /[?&]page=\d+/g.exec(hashlessLink); 238 var currentPageNumber = /[?&]page=\d+/g.exec(window.location.search); 239 if (window.location.href.includes(hashlessLink) && (currentPageNumber === null || targetPageNumber && currentPageNumber[0] === targetPageNumber[0])) { 240 var tocData = link.closest(".ub_table-of-contents").dataset; 241 var type = tocData.scrolltype; 242 var offset = type === "fixedamount" ? tocData.scrollamount : 0; 243 var target = type === "namedelement" ? tocData.scrolltarget : ""; 244 e.preventDefault(); 245 history.pushState(null, "", link.hash); 246 ub_hashHeaderScroll(type, target, offset); 247 } 248 }); 249});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.