1var currentPageURL = document.location.toString(); 2var isAnchor = false; 3if (location.hash) { 4 isAnchor = true; 5 window.scrollTo(0, 0); 6} 7jQuery(document).ready(function () { 8 9 10 if (window.useManagedSmoothScroll) { 11 return; 12 } 13 14 var duration = 1500; 15 var easing = 'easeInOutQuart'; 16 var lastId, anchors, scrollItems; 17 18 function targetIsSamePage(target) { 19 return !target || target == "_self"; 20 } 21 22 function getHash(url) { 23 if (!url) { 24 return false; 25 } 26 var indexOfHash = url.indexOf('#'); 27 if (indexOfHash > -1) { 28 if (indexOfHash === 0) { 29 return url.replace('#', ''); 30 } 31 var hash = url.substring(indexOfHash + 1); 32 var urlQuery = ""; 33 if (url.indexOf('?') > -1) { 34 urlQuery = url.substring(url.indexOf('?')); 35 } 36 var absLinkRegExp = /(https?|file):\/\//; 37 var pageLocation = window.location.pathname; 38 var urlLocation = url.replace(urlQuery, '').replace('#' + hash, '').replace(absLinkRegExp, ''); 39 if (url.match(absLinkRegExp)) { 40 pageLocation = window.location.host + pageLocation; 41 } else { 42 urlLocation = pageLocation.substring(0, pageLocation.lastIndexOf("/")) + "/" + urlLocation; 43 } 44 if (pageLocation == urlLocation || pageLocation == urlLocation + "/") { 45 return hash; 46 } 47 } 48 return false; 49 } 50 51 function change_url_hash(hash) { 52 setTimeout(function () { 53 if (hash) { 54 hash = "#" + hash; 55 } else { 56 hash = ""; 57 } 58 if (history && history.replaceState) { 59 history.replaceState({}, "", hash); 60 } else { 61 } 62 }, 100); 63 /* safari issue fixed by throtteling the event */ 64 } 65 66 var scrollStarted = false; 67 68 69 function scrollToSection(section, elem) { 70 if (scrollStarted) { 71 return; 72 } 73 74 try { 75 scrollStarted = true; 76 77 if (section) { 78 var parent; 79 if (elem) { 80 parent = elem.parent().parentsUntil('body').filter(function () { 81 if (jQuery(this).css('position') == "fixed" && !jQuery(this).is('.mobile-overlay')) return jQuery(this); 82 }).eq(0); 83 } 84 85 var topDistance = 0; 86 if (parent && parent.length) { 87 var parentClass = parent.attr("class"); 88 var flexiMenu = jQuery('div[class*="_menu_wrapper"]'); 89 if (parent.outerHeight() !== window.innerHeight || !parent.is('.full-sidebar')) { 90 topDistance = parent.outerHeight() + parent.position().top; 91 } 92 } 93 var scrollToValue = section.offset().top - topDistance; 94 if (scrollToValue < 0) { 95 scrollToValue = 0; 96 } 97 var stickTo = jQuery("[data-cp-shrink=initial]"); 98 if (scrollToValue > stickTo.height()) { 99 scrollToValue -= jQuery('[data-cp-shrink=shrinked]').height(); 100 } 101 102 var ratio = Math.max(0.5, scrollToValue / jQuery('body').height()); 103 104 jQuery('html, body').animate({ 105 scrollTop: scrollToValue 106 }, duration * ratio, easing, function () { 107 scrollStarted = false; 108 jQuery(window).trigger('scroll'); 109 jQuery(document).trigger('scroll'); 110 }); 111 112 return true; 113 } 114 } catch (e) { 115 alert('error in xtd one page site script ' + e); 116 } 117 } 118 119 function linkClick(ev, elem) { 120 121 if (!targetIsSamePage(elem.attr("target"))) { 122 return; 123 } 124 125 var section = elem.data('onepage-section') ? elem.data('onepage-section') : false; 126 127 if (section && section.length) { 128 ev.preventDefault(); 129 130 // ev.stopPropagation(); 131 } 132 133 var scrolled = scrollToSection(section, elem); 134 if (scrolled && ev) { 135 ev.preventDefault(); 136 } 137 138 } 139 140 function bubbleSortByTop(arr) { 141 var swapped; 142 do { 143 swapped = false;
144 for (var i = 0; i < arr.length - 1; i++) { 145 var elem = arr[i]; 146 var elem2 = arr[i + 1]; 147 if (elem.offset().top > elem2.offset().top) { 148 var temp = arr[i]; 149 arr[i] = arr[i + 1]; 150 arr[i + 1] = temp; 151 swapped = true; 152 } 153 } 154 } while (swapped); 155 } 156 157 function getAnchors() { 158 scrollItems = []; 159 anchors = jQuery('a').filter(function () { 160 var elem = jQuery(this); 161 var href = elem.attr('href'); 162 var target = elem.attr('target'); 163 var hash = getHash(href); 164 if (hash && hash !== 'wp-toolbar') { 165 try { 166 var section = jQuery("#" + hash); 167 if (section.length > 0) { 168 elem.data('onepage-section', section); 169 if (elem.parent()[0].tagName == "LI") { 170 section.data('onepage-anchor', elem); 171 } 172 scrollItems.push(section); 173 return true; 174 } 175 } catch (e) { 176 177 } 178 } 179 return false; 180 }); 181 182 183 anchors.each(function () { 184 185 if (jQuery(this).closest('.fm2_mobile_jq_menu').length || !jQuery(this).is(':visible')) { 186 return; 187 } 188 189 if (jQuery(this).parent().is('li.menu-item')) { 190 var selfAnchor = this; 191 jQuery(this).unbind('click.onepage'); 192 jQuery(this).attr('data-smoothscroll', 'true'); 193 jQuery(this).parent().unbind('click.onepage').bind("click.onepage", function (e) { 194 195 if (!jQuery(e.target).parent().is(e.currentTarget)) { 196 return; 197 } 198 199 e.preventDefault(); 200 e.stopPropagation(); 201 linkClick(e, jQuery(selfAnchor)); 202 }); 203 } else { 204 jQuery(this).unbind('click.onepage').bind("click.onepage", function (e) { 205 206 linkClick(e, jQuery(this)); 207 }); 208 } 209 }); 210 try { 211 bubbleSortByTop(scrollItems); 212 } catch (e) { 213 } 214 } 215 216 var scrollTimeout; 217 var is_touch_device = 'ontouchstart' in document.documentElement; 218 if (!is_touch_device) { 219 jQuery(window).scroll(function () { 220 clearTimeout(scrollTimeout); 221 scrollTimeout = setTimeout(doneScrolling, 20); 222 }); 223 } 224 225 function doneScrolling() { 226 var windowElem = jQuery(window); 227 var fromTop = windowElem.scrollTop() + window.innerHeight * 0.5; 228 var cur = []; 229 if (!scrollItems) { 230 getAnchors(); 231 } 232 for (var i = 0; i < scrollItems.length; i++) { 233 if (scrollItems[i].offset().top < fromTop) { 234 cur.push(scrollItems[i]); 235 } 236 } 237 var lastItem = scrollItems[scrollItems.length - 1]; 238 if ((windowElem.scrollTop() + windowElem.height() + 50) >= jQuery(document).height()) { 239 cur.push(lastItem); 240 } 241 cur = cur[cur.length - 1]; 242 var id = cur && cur.length ? cur[0].id : ""; 243 change_url_hash(id); 244 if (id.length === 0 && anchors) { 245 // anchors.closest('ul').find('.current_page_item').removeClass('current_page_item'); 246 anchors.parent().andSelf().removeClass('current_page_item'); 247 loc = (window.location + "").split('#')[0].replace(/\/$/, ""); 248 anchors.closest('ul').find('[href$="' + loc + '"]').eq(0).parent().andSelf().addClass('current_page_item'); 249 if (!loc.length) { 250 anchors.closest('ul').find('[href$="' + window.location + '"]').eq(0).parent().andSelf().addClass('current_page_item'); 251 252 } 253 } 254 255 if (lastId !== id && id.length) { 256 lastId = id; 257 try { 258 anchors.filter('.current_page_item').each(function () { 259 jQuery(this).parent().andSelf().removeClass('current_page_item'); 260 261 }); 262 anchors.closest('ul').find('.current_page_item').removeClass('current_page_item'); 263 cur.data('onepage-anchor').parent().andSelf().addClass('current_page_item'); 264 } catch (e) { 265 } 266 } 267 } 268 269 var id; 270 jQuery(window).bind("resize orientationchange", function () { 271 clearTimeout(id); 272 id = setTimeout(doneResizing, 100); 273 }); 274 275 function doneResizing() { 276 getAnchors(); 277 } 278 279 getAnchors(); 280 281 is_touch_device = 'ontouchstart' in document.documentElement; 282 283 if (!is_touch_device) { 284 doneScrolling(); 285 } 286 if (isAnchor) { 287 if (jQuery.find('a[href^="' + currentPageURL + '"]').length > 0) { 288 jQuery(jQuery.find('a[href="' + currentPageURL + '"]')).trigger('click'); 289 } else { 290 var hash = getHash(currentPageURL); 291 if (hash.length) { 292 jQuery(jQuery.find('a[href*="#' + hash + '"]')).trigger('click'); 293 } 294 } 295 } else { 296 jQuery('a[href*="#"]').each(function (index, el) { 297 var parts = el.href.split('#'), 298 anchor = parts[parts.length - 1]; 299 300 if (parts.length >= 2) { 301 if (anchor.length) { 302 jQuery(this).parent().andSelf().removeClass('current_page_item'); 303 } 304 } 305 }); 306 } 307 308 window.scrollToSection = scrollToSection; 309 window.smoothScrollGetAnchors = getAnchors; 310}); 311 312
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.