1(function () { 2 3 /* Polyfills */ 4 5 if (window.NodeList && !NodeList.prototype.forEach) { 6 NodeList.prototype.forEach = Array.prototype.forEach; 7 } 8 9 if (!Element.prototype.matches) { 10 Element.prototype.matches = Element.prototype.msMatchesSelector || 11 Element.prototype.webkitMatchesSelector; 12 } 13 14 if (!Element.prototype.closest) { 15 Element.prototype.closest = function (s) { 16 var el = this; 17 18 do { 19 if (el.matches(s)) return el; 20 el = el.parentElement || el.parentNode; 21 } while (el !== null && el.nodeType === 1); 22 return null; 23 }; 24 } 25 26 /* Polyfills end */ 27 28 document.addEventListener('DOMContentLoaded', function () { 29 document.querySelectorAll('[data-sf-role="toggleLink"]').forEach(function (x) { 30 x.addEventListener('click', function () { 31 var link = this; 32 33 expandElement(link); 34 35 var wrapper = link.closest('[data-sf-role="lists"]'); 36 37 var linkCount = wrapper.querySelectorAll('[data-sf-role="toggleLink"]').length; 38 var expandedLinkCount = wrapper.querySelectorAll('[data-sf-role="toggleLink"].expanded').length; 39 40 if (linkCount === expandedLinkCount) { 41 hideExpandAllLink(wrapper); 42 } 43 else { 44 hideCollapseAllLink(wrapper); 45 } 46 }); 47 }); 48 49 document.querySelectorAll('[data-sf-role="expandAll"]').forEach(function (x) { 50 x.addEventListener('click', function () { 51 var wrapper = this.closest('[data-sf-role="lists"]'); 52 wrapper.querySelector('[data-sf-role="expandAll"]').style.display = 'none'; 53 wrapper.querySelector('[data-sf-role="collapseAll"]').style.display = 'block'; 54 var links = wrapper.querySelectorAll('[data-sf-role="toggleLink"]'); 55 links.forEach(function (link) { 56 link.classList.add('expanded'); 57 toggleLinkArrow(link); 58 59 var nextSiblingDiv = link.nextElementSibling; 60 if (nextSiblingDiv.tagName.toLowerCase() === 'div') { 61 nextSiblingDiv.style.display = 'block'; 62 } 63 }); 64 }); 65 }); 66 67 document.querySelectorAll('[data-sf-role="collapseAll"]').forEach(function (x) { 68 x.addEventListener('click', function () { 69 var wrapper = this.closest('[data-sf-role="lists"]'); 70 wrapper.querySelector('[data-sf-role="expandAll"]').style.display = 'block'; 71 wrapper.querySelector('[data-sf-role="collapseAll"]').style.display = 'none'; 72 var links = wrapper.querySelectorAll('[data-sf-role="toggleLink"]'); 73 links.forEach(function (link) { 74 link.classList.remove('expanded'); 75 toggleLinkArrow(link); 76 var nextSiblingDiv = link.nextElementSibling; 77 if (nextSiblingDiv.tagName.toLowerCase() === 'div') { 78 nextSiblingDiv.style.display = 'none'; 79 } 80 }); 81 }); 82 }); 83 }); 84 85 function expandElement(link) { 86 if (link.classList.contains('expanded')) { 87 link.classList.remove('expanded'); 88 } else { 89 link.classList.add('expanded'); 90 var itemTitle = link.innerText.trim(); 91 sendSentence(itemTitle); 92 } 93 94 var content = link.nextElementSibling; 95 if (content.style.display === 'none') { 96 content.style.display = 'block'; 97 } else { 98 content.style.display = 'none'; 99 } 100 toggleLinkArrow(link); 101 } 102 103 function toggleLinkArrow(link) { 104 var isExpanded = link.classList.contains("expanded"); 105 if (link.querySelectorAll("[data-sf-toggle='collapsed']")) { 106 link.querySelectorAll("[data-sf-toggle='collapsed']").forEach(function (e) { e.style.display = isExpanded ? "none" : ""; }); 107 }
108 if (link.querySelectorAll("[data-sf-toggle='expanded']")) { 109 link.querySelectorAll("[data-sf-toggle='expanded']").forEach(function (e) { e.style.display = isExpanded ? "" : "none"; }); 110 } 111 } 112 113 function hideExpandAllLink(wrapper) { 114 wrapper.querySelectorAll('[data-sf-role="expandAll"]').forEach(function (node) { 115 node.style.display = 'none'; 116 }); 117 wrapper.querySelectorAll('[data-sf-role="collapseAll"]').forEach(function (node) { 118 node.style.display = 'block'; 119 }); 120 } 121 122 function hideCollapseAllLink(wrapper) { 123 wrapper.querySelectorAll('[data-sf-role="expandAll"]').forEach(function (node) { 124 node.style.display = 'block'; 125 }); 126 wrapper.querySelectorAll('[data-sf-role="collapseAll"]').forEach(function (node) { 127 node.style.display = 'none'; 128 }); 129 } 130 131 function sendSentence(itemTitle) { 132 if (window.DataIntelligenceSubmitScript) { 133 DataIntelligenceSubmitScript._client.sentenceClient.writeSentence({ 134 predicate: "Expand list", 135 object: itemTitle, 136 objectMetadata: [{ 137 'K': 'PageTitle', 138 'V': document.title 139 }, 140 { 141 'K': 'PageUrl', 142 'V': location.href 143 } 144 ] 145 }); 146 } 147 } 148}());
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.