1/** Front-end Scripts. */ 2//Button collapse text toggle 3jQuery(document).ready(function() { 4 var buttonCollapseToggles = jQuery('a[data-toggle="collapse"][data-label-show][data-label-hide]'); 5 buttonCollapseToggles.each(function() { 6 var button = jQuery(this); 7 if (button.children().length == 0) { 8 var target = button.attr('href'); 9 var targetObject = jQuery(target); 10 var labelShow = button.attr('data-label-show'); 11 var labelHide = button.attr('data-label-hide'); 12 targetObject.on('show.bs.collapse', function () { 13 button.text(labelHide); 14 }); 15 targetObject.on('hide.bs.collapse', function () { 16 button.text(labelShow); 17 }); 18 } 19 }); 20}); 21 22//set images 23jQuery(window).on('load.builder', function() { 24 var size = jQuery('body').attr('data-view'); 25 ADimageSwap(size); 26}); 27 28/** Tabs */ 29//set resize event on tab change 30jQuery(document).ready(function() { 31 var tabShowInterval; 32 jQuery('a[data-toggle="tab"]').on('show.bs.tab', function (e) { 33 tabShowInterval = setInterval(function(){ 34 jQuery(window).trigger('resize'); 35 },10); 36 }); 37 jQuery('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { 38 setTimeout(function(){ 39 clearInterval(tabShowInterval); 40 }, 1000); 41 }); 42}); 43 44//deep linking 45jQuery(window).on('load.builder', function() { 46 var targetID = window.location.hash 47 var targetTabTrigger = jQuery('a[data-toggle="tab"][href="'+ targetID +'"]'); 48 if (targetTabTrigger.length > 0) { 49 var offset = srbTabsGetOffset(targetTabTrigger); 50 setTimeout(function() { 51 jQuery(window).scrollTop(offset); 52 }, 100); 53 targetTabTrigger.trigger('click'); 54 } 55}); 56 57//control tabs from WordPress menus 58jQuery(document).ready(function() { 59 jQuery('body').on('click.builder', '.menu-item-type-custom > a', function(e) { 60 if (e.target.hash != '') { 61 var targetTabTrigger = jQuery('a[data-toggle="tab"][href="'+ e.target.hash +'"]'); 62 if (targetTabTrigger.length > 0) { 63 e.preventDefault(); 64 var offset = srbTabsGetOffset(targetTabTrigger); 65 jQuery(window).scrollTop(offset); 66 targetTabTrigger.trigger('click'); 67 //update hash 68 if (history.replaceState) { 69 history.replaceState(null, null, e.target.hash); 70 } 71 //collapse mobile nav menu 72 var mobileNavMenu = jQuery(e.target).closest('.navbar-collapse'); 73 if (mobileNavMenu.length > 0 && mobileNavMenu.is('.in')) { 74 mobileNavMenu.collapse('hide'); 75 } 76 } 77 } 78 }); 79}); 80 81function srbTabsGetOffset(targetTabTrigger) { 82 if (jQuery('body').hasClass('admin-bar') && jQuery(window).width() >= 768) { 83 var offset = targetTabTrigger.offset().top - 132; 84 } else { 85 var offset = targetTabTrigger.offset().top - 100; 86 } 87 if (jQuery(window).width() >= 768 && jQuery('.locking-menu').length > 0) { 88 offset = offset - 80; 89 } 90 return offset; 91} 92 93/** Modals */ 94jQuery(document).ready(function() { 95 var modals = jQuery('.modal'); 96 modals.each(function() { 97 var modal = jQuery(this); 98 modal.on('shown.bs.modal', function () { 99 jQuery(this).find('.modal-dialog .close').focus(); 100 }) 101 }); 102}); 103 104//update images 105function ADimageSwap(size) { 106 //create json object 107 var $images = jQuery('.ad-dynamic-image'); 108 $images.each(function() { 109 var image = jQuery(this); 110 var imageData = image.data('image-json'); 111 switch(size) { 112 case 'mobile': 113 var imageSrc = imageData.mobile_src; 114 var imageWidth = imageData.mobile_width; 115 var imageHeight = imageData.mobile_height; 116 break; 117 case 'desktop': 118 var imageSrc = imageData.desktop_src; 119 var imageWidth = imageData.desktop_width; 120 var imageHeight = imageData.desktop_height; 121 } 122 image.attr('src', imageSrc); 123 image.attr('width', imageWidth); 124 image.attr('height', imageHeight); 125 jQuery(window).imagesLoaded(function() { 126 jQuery('body').trigger('imagesSwapped.srb'); 127 }); 128 }); 129} 130 131// Animate blocks into view using IntersectionObserver 132var srbAnimateSelector = ".animate-from-left, .animate-from-right, .animate-from-above, .animate-from-below"; 133var srbAnimateObserver = null; 134 135function srbGetStartTransform(el) { 136 if (el.classList.contains("animate-from-left")) return "translateX(-100px)"; 137 if (el.classList.contains("animate-from-right")) return "translateX(100px)"; 138 if (el.classList.contains("animate-from-above")) return "translateY(-100px)"; 139 if (el.classList.contains("animate-from-below")) return "translateY(100px)"; 140 return "translateY(0)"; 141} 142 143function srbAnimateElement(el) { 144 // Skip if already animated 145 if (el.classList.contains("visible") || el.getAttribute("data-srb-animated") === "1") return; 146 147 // Set initial hidden state 148 el.style.setProperty("transition", "none", "important"); 149 el.style.setProperty("opacity", "0", "important"); 150 el.style.setProperty("visibility", "hidden", "important"); 151 el.style.setProperty("transform", srbGetStartTransform(el), "important"); 152 153 // Force reflow 154 void el.offsetHeight; 155 156 // Enable transition 157 el.style.setProperty("transition", "opacity 0.5s ease-out 0.5s, transform 0.5s ease-out 0.5s, visibility 0.5s ease-out 0.5s", "important"); 158 159 // Force reflow 160 void el.offsetHeight; 161 162 // Observe for viewport entry 163 if (srbAnimateObserver) { 164 srbAnimateObserver.observe(el); 165 } else { 166 // No IntersectionObserver â show immediately 167 srbRevealElement(el); 168 } 169} 170 171function srbRevealElement(el) { 172 el.classList.add("visible"); 173 el.setAttribute("data-srb-animated", "1"); 174 el.style.setProperty("opacity", "1", "important"); 175 el.style.setProperty("visibility", "visible", "important"); 176 el.style.setProperty("transform", "translateX(0) translateY(0)", "important"); 177} 178 179function srbInitAnimations() { 180 // Create the IntersectionObserver (once) 181 if (!srbAnimateObserver && "IntersectionObserver" in window) { 182 srbAnimateObserver = new IntersectionObserver(function (entries) {
183 entries.forEach(function (entry) { 184 if (entry.isIntersecting) { 185 srbRevealElement(entry.target); 186 srbAnimateObserver.unobserve(entry.target); 187 } 188 }); 189 }, { threshold: 0.1 }); 190 } 191 192 // Initialize any animated elements currently in the DOM 193 var animateElements = document.querySelectorAll(srbAnimateSelector); 194 animateElements.forEach(function (el) { 195 srbAnimateElement(el); 196 }); 197} 198 199// Run on initial page load 200document.addEventListener("DOMContentLoaded", function () { 201 srbInitAnimations(); 202}); 203 204// Re-run on bfcache restore 205window.addEventListener("pageshow", function (event) { 206 if (event.persisted) { 207 // Reset all animated elements so they can re-animate 208 document.querySelectorAll(srbAnimateSelector).forEach(function (el) { 209 el.classList.remove("visible"); 210 el.removeAttribute("data-srb-animated"); 211 }); 212 srbInitAnimations(); 213 } 214}); 215 216// MutationObserver: detect new animated elements added via AJAX navigation 217(function () { 218 if ("MutationObserver" in window) { 219 var domObserver = new MutationObserver(function (mutations) { 220 mutations.forEach(function (mutation) { 221 mutation.addedNodes.forEach(function (node) { 222 if (node.nodeType !== 1) return; // skip text nodes 223 // Check if the added node itself is an animate element 224 if (node.matches && node.matches(srbAnimateSelector)) { 225 srbAnimateElement(node); 226 } 227 // Check descendants of the added node 228 if (node.querySelectorAll) { 229 node.querySelectorAll(srbAnimateSelector).forEach(function (el) { 230 srbAnimateElement(el); 231 }); 232 } 233 }); 234 }); 235 }); 236 // Start observing once the body exists 237 if (document.body) { 238 domObserver.observe(document.body, { childList: true, subtree: true }); 239 } else { 240 document.addEventListener("DOMContentLoaded", function () { 241 domObserver.observe(document.body, { childList: true, subtree: true }); 242 }); 243 } 244 } 245})();
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.