1(function(window, document) { 2 function isMobileDevice() { 3 var a=navigator.userAgent||navigator.vendor||window.opera; 4 return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4)); 5 } 6 function excludedDevices() { 7 var a=navigator.userAgent||navigator.vendor||window.opera; 8 return false; // /(iPhone|iPad).*OS 14/i.test(a) || /Version.*14.*Safari/i.test(a); 9 } 10 11 if (!Object.assign) { 12 Object.defineProperty(Object, 'assign', { 13 enumerable: false, 14 configurable: true, 15 writable: true, 16 value: function(target, firstSource) { 17 'use strict'; 18 if (target === undefined || target === null) { 19 throw new TypeError('Cannot convert first argument to object'); 20 } 21 22 var to = Object(target); 23 for (var i = 1; i < arguments.length; i++) { 24 var nextSource = arguments[i]; 25 if (nextSource === undefined || nextSource === null) { 26 continue; 27 } 28 29 var keysArray = Object.keys(Object(nextSource)); 30 for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) { 31 var nextKey = keysArray[nextIndex]; 32 var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey); 33 if (desc !== undefined && desc.enumerable) { 34 to[nextKey] = nextSource[nextKey]; 35 } 36 } 37 } 38 return to; 39 } 40 }); 41 } 42 43 if (typeof window.CustomEvent !== "function") { 44 function CustomEvent( event, params ) { 45 params = params || { bubbles: false, cancelable: false, detail: undefined }; 46 var evt = document.createEvent( 'CustomEvent' ); 47 evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail ); 48 return evt; 49 } 50 CustomEvent.prototype = window.Event.prototype; 51 window.CustomEvent = CustomEvent; 52 } 53 54 function getRootScrollTop() { 55 return window.pageYOffset || document.documentElement.scrollTop; 56 } 57 58 function getNodePosition(node) { 59 try { 60 var position = node.getBoundingClientRect(); 61 return { 62 left: position.left, 63 top: position.top + getRootScrollTop(), 64 width: position.width, 65 height: position.height 66 }; 67 } catch (err) { 68 return null; 69 } 70 } 71 72 function getAncestorNode(node, className) { 73 while (node !== undefined && node !== null && node.nodeName.toUpperCase() !== 'BODY') { 74 if (node.classList.contains(className)) { 75 return node; 76 } 77 node = node.parentNode; 78 } 79 return null; 80 } 81 82 function addEvent(node, event, callback, useCapture) { 83 if (typeof node.addEventListener == 'function') { 84 node.addEventListener(event, callback, useCapture || false); 85 } else if (typeof node.attachEvent == 'function') { 86 node.attachEvent('on' + event, callback); 87 } 88 } 89 90 function LazyGroup(node, type) { 91 this.node = node; 92 this.type = type || 'default'; 93 this.position = null; 94 this.showed = false;
95 this.items = []; 96 this.itemLoaded = 0; 97 } 98 99 LazyGroup.prototype = { 100 getType: function() { 101 return this.type; 102 }, 103 104 getItems: function() { 105 return this.items; 106 }, 107 108 allItemsLoaded: function() { 109 return this.items.length == this.itemLoaded; 110 }, 111 112 updatePosition: function() { 113 this.position = getNodePosition(this.node); 114 }, 115 116 getPosition: function() { 117 return this.position; 118 }, 119 120 getNode: function() { 121 return this.node; 122 }, 123 124 addItem: function(item) { 125 if (this.isShowed()) { 126 this.showItem(item); 127 } 128 129 this.items.push(item); 130 }, 131 132 showItem: function(item) { 133 var self = this; 134 item.show(function(event) { 135 self.itemLoaded++; 136 item.loaded(self); 137 }); 138 }, 139 140 show: function(force) { 141 var self = this; 142 143 if (this.isShowed()) { 144 return; 145 } 146 147 if (force === undefined) { 148 force = false; 149 } 150 151 this.showed = true; 152 153 this.items.forEach(function(item) { 154 if (!item.isShowed()) { 155 self.showItem(item); 156 } 157 }); 158 159 this.dispatchShowedEvent(); 160 }, 161 162 isShowed: function() { 163 return this.showed; 164 }, 165 166 hasItems: function() { 167 return this.items.length > 0; 168 }, 169 170 dispatchShowedEvent: function() { 171 this.node.dispatchEvent(new window.CustomEvent('tgpliVisible', { 172 bubbles: true 173 })); 174 } 175 }; 176 177 function LazyItem(node, data) { 178 this.node = node; 179 this.data = data || {}; 180 this.showed = false; 181 this.initType(); 182 } 183 184 LazyItem.prototype = { 185 getNode: function() { 186 return this.node; 187 }, 188 189 show: function(loadedCallback) { 190 if (this.isShowed()) { 191 return; 192 } 193 194 loadedCallback = loadedCallback || null; 195 196 this.showed = true; 197 198 switch (this.getType()) { 199 case 'image': 200 this.showImage(loadedCallback); 201 break; 202 203 case 'iframe': 204 this.showIframe(loadedCallback); 205 break; 206 207 case 'custom': 208 this.showCustom(loadedCallback); 209 break; 210 211 default: 212 this.showDefault(loadedCallback); 213 } 214 }, 215 216 showImage: function(loadedCallback) { 217 if (loadedCallback !== undefined && typeof loadedCallback === 'function') { 218 addEvent(this.node, 'load', function(event) { loadedCallback(event); }, true); 219 } 220 221 if (this.data.sources !== undefined && this.data.sources !== null && this.data.sources != '') { 222 this.node.insertAdjacentHTML('beforebegin', this.data.sources); 223 } 224 225 var srcSet = this.node.getAttribute('data-tgpli-srcset'); 226 if (srcSet) { 227 this.node.setAttribute('srcset', srcSet); 228 } 229 230 var src = this.node.getAttribute('data-tgpli-src'); 231 if (src) { 232 this.node.src = src; 233 } 234 235 this.node.removeAttribute('data-tgpli-image-inited'); 236 }, 237 238 showDefault: function(loadedCallback) { 239 this.node.classList.remove('tgpli-background-inited'); 240 }, 241 242 showIframe: function(loadedCallback) { 243 var src = this.node.getAttribute('data-tgpli-src'); 244 if (src) { 245 this.node.src = src; 246 } 247 248 this.node.removeAttribute('data-tgpli-iframe-inited'); 249 }, 250 251 showCustom: function(loadedCallback) { 252 var action = this.node.getAttribute('data-tgpli-action'); 253 if (action && window[action] !== undefined && typeof window[action] == 'function') { 254 window[action](); 255 } 256 257 this.node.removeAttribute('data-tgpli-custom-inited'); 258 }, 259 260 isShowed: function() { 261 return this.showed; 262 }, 263 264 initType: function() { 265 if (this.data != undefined && this.data.customItem === true) { 266 this.type = 'custom'; 267 return; 268 } 269 270 switch (this.node.nodeName.toUpperCase()) { 271 case 'IMG': 272 this.type = 'image'; 273 break; 274 275 case 'IFRAME': 276 this.type = 'iframe'; 277 break; 278 279 default: 280 this.type = 'default'; 281 } 282 }, 283 284 getType: function() { 285 return this.type; 286 }, 287 288 getGroupNodeInfo: function() { 289 if (this.data != undefined && this.data.customItem === true) { 290 return { 291 node: this.node, 292 type: 'custom' 293 }; 294 } 295 296 switch (this.getType()) { 297 case 'image': 298 return this.getImageGroupNode(); 299 300 case 'iframe': 301 return { 302 node: this.node.parentNode, 303 type: 'iframe' 304 }; 305 306 default: 307 return { 308 node: this.node, 309 type: 'default' 310 }; 311 } 312 }, 313 314 getImageGroupNode: function() { 315 var id = this.node.id; 316 317 if (this.node.parentNode.classList.contains('logo')) { 318 return { 319 node: this.node.parentNode, 320 type: 'logo' 321 }; 322 } 323 324 if (id && document.querySelector('div.gem-client-item #' + id) !== null) { 325 var ancestorNode = getAncestorNode(this.node, 'gem-clients-type-carousel-grid'); 326 if (ancestorNode === null) { 327 var ancestorNode = getAncestorNode(this.node, 'gem_client_carousel-items'); 328 } 329 if (ancestorNode !== null) { 330 return { 331 node: ancestorNode, 332 type: 'gem-clients' 333 }; 334 } 335 } 336 337 if (id && document.querySelector('#colophon .footer-widget-area #' + id) !== null) { 338 var ancestorNode = getAncestorNode(this.node, 'footer-widget-area'); 339 if (ancestorNode !== null) { 340 return { 341 node: ancestorNode, 342 type: 'footer-widget-area' 343 }; 344 } 345 } 346 347 if (id && document.querySelector('div.portfolio #' + id) !== null && 348 !this.node.closest('div.portfolio').classList.contains('disable-isotope')) { 349 var ancestorNode = getAncestorNode(this.node, 'portfolio'); 350 if (ancestorNode !== null) { 351 return { 352 node: ancestorNode, 353 type: 'portfolio' 354 }; 355 } 356 } 357 358 if ( 359 (this.node.className && this.node.className.indexOf('extended-carousel-grid') != -1) || 360 (id && document.querySelector('div.extended-carousel-grid #' + id) !== null && 361 (this.node.closest('div.extended-carousel-grid').classList.contains('carousel-scroll-init')) ) 362 ) { 363 var ancestorNode = getAncestorNode(this.node, 'extended-carousel-grid'); 364 if (ancestorNode !== null) { 365 return { 366 node: ancestorNode, 367 type: 'products-carousel' 368 }; 369 } 370 } 371 372 if (id && document.querySelector('div.blog #' + id) !== null) { 373 var ancestorNode = getAncestorNode(this.node, 'blog'); 374 if (ancestorNode !== null) { 375 return { 376 node: ancestorNode, 377 type: 'blog' 378 }; 379 } 380 } 381 382 if (id && document.querySelector('div.gem-gallery-grid #' + id) !== null && 383 !(this.node.closest('div.gem-gallery-grid').classList.contains('disable-isotope'))) { 384 var ancestorNode = getAncestorNode(this.node, 'gem-gallery-grid'); 385 if (ancestorNode !== null) { 386 return { 387 node: ancestorNode, 388 type: 'gallery-grid' 389 }; 390 } 391 } 392 393 if (id && document.querySelector('div.gem-gallery #' + id) !== null) { 394 var ancestorNode = getAncestorNode(this.node, 'gem-gallery'); 395 if (ancestorNode !== null) { 396 return { 397 node: ancestorNode, 398 type: 'gallery' 399 }; 400 } 401 } 402 403 if (id && document.querySelector('div.gem-simple-gallery #' + id) !== null) { 404 var ancestorNode = getAncestorNode(this.node, 'gem-simple-gallery'); 405 if (ancestorNode !== null) { 406 return { 407 node: ancestorNode, 408 type: 'simple-gallery' 409 }; 410 } 411 } 412 413 if (id && document.querySelector('div.gem-slideshow #' + id) !== null) { 414 var ancestorNode = getAncestorNode(this.node, 'gem-slideshow'); 415 if (ancestorNode !== null) { 416 return { 417 node: ancestorNode, 418 type: 'gem-slideshow' 419 }; 420 } 421 } 422 423 if (id && document.querySelector('div.gem-testimonials #' + id) !== null) { 424 var ancestorNode = getAncestorNode(this.node, 'gem-testimonials'); 425 if (ancestorNode !== null) { 426 return { 427 node: ancestorNode, 428 type: 'gem-testimonials' 429 }; 430 } 431 } 432 433 if (id && document.querySelector('div.rev_slider_wrapper #' + id) !== null) { 434 var ancestorNode = getAncestorNode(this.node, 'rev_slider_wrapper'); 435 if (ancestorNode !== null) { 436 return { 437 node: ancestorNode, 438 type: 'rev_slider' 439 }; 440 } 441 } 442 443 if (id && document.querySelector('div.wpb_images_carousel #' + id) !== null) { 444 var ancestorNode = getAncestorNode(this.node, 'wpb_images_carousel'); 445 if (ancestorNode !== null) { 446 return { 447 node: ancestorNode, 448 type: 'wpb_images_carousel' 449 }; 450 } 451 } 452 453 return { 454 node: this.node.parentNode, 455 type: 'default' 456 }; 457 }, 458 459 imageShowed: function() { 460 var id = this.node.id; 461 462 if (id && document.querySelector('div.caroufredsel_wrapper #' + id) !== null) { 463 window.dispatchEvent(new window.CustomEvent('resize')); 464 } 465 466 if (window.jQuery !== undefined && window.jQuery !== null && 467 window.jQuery.waypoints !== undefined && window.jQuery.waypoints !== null && 468 typeof window.jQuery.waypoints === "function" 469 ) { 470 window.jQuery.waypoints('refresh'); 471 } 472 }, 473 474 loaded: function(group) { 475 var groupItems = group.getItems(); 476 477 if (group.getType() == 'default' && groupItems.length == 1 && groupItems[0].getType() == 'image') { 478 this.imageShowed(); 479 } 480 481 if (group.getType() == 'wpb_images_carousel' && group.allItemsLoaded()) { 482 window.dispatchEvent(new window.CustomEvent('resize')); 483 } 484 } 485 }; 486 487 function LazyItems(options) { 488 options = options || {}; 489 490 this.options = Object.assign({ 491 visibilityOffset: 300, 492 desktopEnable: true, 493 mobileEnable: true 494 }, options); 495 496 this.groups = []; 497 this.scrollTop = 0; 498 this.rootHeight = 0; 499 this.checkGroupsProcess = false;
500 this.enabled = false; 501 this.isPageScroller = false; 502 this.isFullpage = false; 503 this.visibilityOffsetFixed = false; 504 505 this.init(); 506 } 507 508 LazyItems.prototype = { 509 init: function() { 510 this.checkEnabled(); 511 this.updateRootScrollTop(); 512 this.updateRootSize(); 513 this.initEvents(); 514 this.initQueueNodes(); 515 }, 516 517 checkEnabled: function() { 518 var isMobile = isMobileDevice(); 519 this.enabled = !(excludedDevices()) && ((isMobile && this.options.mobileEnable) || (!isMobile && this.options.desktopEnable)); 520 }, 521 522 isEnabled: function() { 523 return this.enabled; 524 }, 525 526 initQueueNodes: function() { 527 if (window.tgpQueue !== undefined) { 528 this.addNodes(window.tgpQueue.flushNodes()); 529 } 530 }, 531 532 initEvents: function() { 533 var self = this; 534 addEvent(window, 'resize', function() { self.resizeHandle(); }, true); 535 addEvent(document, 'scroll', function() { self.scrollHandle(); }, true); 536 addEvent(document, 'DOMContentLoaded', function() { self.documentReadyHandle(); }, true); 537 }, 538 539 resizeHandle: function() { 540 var self = this; 541 setTimeout(function() { 542 self.updateRootScrollTop(); 543 self.updateRootSize(); 544 self.updateGroupsPositions(); 545 self.checkGroups(); 546 }, 0); 547 }, 548 549 scrollHandle: function() { 550 if (!this.visibilityOffsetFixed) { 551 this.visibilityOffsetFixed = true; 552 this.options.visibilityOffset *= 1.5; 553 } 554 this.updateRootScrollTop(); 555 this.updateGroupsPositions(); 556 this.checkGroups(); 557 }, 558 559 documentReadyHandle: function() { 560 this.collectCustomItems(); 561 this.detectPageScroller(); 562 this.detectFullpage(); 563 this.updateRootScrollTop(); 564 this.updateRootSize(); 565 this.updateGroupsPositions(); 566 this.checkGroups(); 567 }, 568 569 detectPageScroller: function() { 570 var self = this; 571 572 this.isPageScroller = document.body.classList.contains('page-scroller'); 573 574 if (this.isPageScroller) { 575 addEvent(document, 'page-scroller-updated', function() { 576 self.scrollHandle(); 577 }); 578 } 579 }, 580 581 detectFullpage: function() { 582 var self = this; 583 584 this.isFullpage = document.body.classList.contains('thegem-fp'); 585 586 if (this.isFullpage) { 587 addEvent(document, 'fullpage-updated', function() { 588 self.scrollHandle(); 589 }); 590 } 591 }, 592 593 hasGroups: function() { 594 return this.groups.length > 0; 595 }, 596 597 checkGroups: function() { 598 var self = this; 599 600 if (this.checkGroupsProcess || !this.hasGroups()) { 601 return; 602 } 603 604 this.checkGroupsProcess = true; 605 606 this.groups.forEach(function(group) { 607 if (group.isShowed() || !group.hasItems()) { 608 return; 609 } 610 611 if (self.isVisibleGroup(group)) { 612 self.showGroup(group, false); 613 } 614 }); 615 616 this.checkGroupsProcess = false; 617 }, 618 619 isVisibleGroup: function(group) { 620 var rootPosition = this.getRootPosition(), 621 groupPosition = group.getPosition(); 622 623 if (groupPosition === null) { 624 return true; 625 } 626 627 if (groupPosition.left == 0 && groupPosition.top == 0 && groupPosition.width == 0 && groupPosition.height == 0) { 628 return false; 629 } 630 631 return groupPosition.top - this.options.visibilityOffset <= rootPosition.bottom && 632 groupPosition.top + groupPosition.height + this.options.visibilityOffset >= rootPosition.top; 633 }, 634 635 showGroup: function(group, force) { 636 if (force === undefined) { 637 force = false;
638 } 639 group.show(force); 640 }, 641 642 showItem: function(item) { 643 item.show(); 644 }, 645 646 addItem: function(item) { 647 if (!this.isEnabled() || this.isIgnoreItem(item)) { 648 this.showItem(item); 649 return; 650 } 651 652 this.getItemGroup(item).addItem(item); 653 }, 654 655 getItemGroup: function(item) { 656 var groupNodeInfo = item.getGroupNodeInfo(), 657 group = this.findGroup(groupNodeInfo.node); 658 659 if (group === null) { 660 group = new LazyGroup(groupNodeInfo.node, groupNodeInfo.type); 661 662 group.updatePosition(); 663 664 if (this.isIgnoreGroup(group) || this.isVisibleGroup(group)) { 665 this.showGroup(group, true); 666 } 667 668 this.groups.push(group); 669 } 670 671 return group; 672 }, 673 674 findGroup: function(node) { 675 for (var i = 0; i < this.groups.length; i++) { 676 if (this.groups[i].getNode() == node) { 677 return this.groups[i]; 678 } 679 } 680 return null; 681 }, 682 683 isIgnoreItem: function(item) { 684 return false; 685 }, 686 687 isIgnoreGroup: function(group) { 688 if (group.getType() == 'gem-slideshow' || group.getType() == 'rev_slider') { 689 return true; 690 } 691 692 return false; 693 }, 694 695 addNodes: function(nodes) { 696 var self = this; 697 nodes.forEach(function(node) { 698 self.addNode(node); 699 }); 700 }, 701 702 addNode: function(data) { 703 if (data.node === null) { 704 return; 705 } 706 707 this.addItem(new LazyItem(data.node, data.data)); 708 }, 709 710 collectItems: function() { 711 var self = this; 712 713 document.querySelectorAll('img[data-tgpli-image-inited]').forEach(function(node) { 714 self.addNode(node); 715 }); 716 717 document.querySelectorAll('.tgpli-background-inited').forEach(function(node) { 718 self.addNode(node); 719 }); 720 }, 721 722 collectCustomItems: function() { 723 var self = this; 724 725 document.querySelectorAll('.tgpli-custom-item').forEach(function(node) { 726 self.addNode({ 727 node: node, 728 data: { 729 customItem: true 730 } 731 }); 732 }); 733 }, 734 735 updateGroupsPositions: function() { 736 this.groups.forEach(function(group) { 737 group.updatePosition(); 738 }); 739 }, 740 741 updateRootScrollTop: function() { 742 this.scrollTop = getRootScrollTop(); 743 }, 744 745 updateRootSize: function() { 746 this.rootHeight = document.documentElement.clientHeight; 747 }, 748 749 getRootPosition: function() { 750 return { 751 top: this.scrollTop, 752 bottom: this.scrollTop + this.rootHeight, 753 height: this.rootHeight 754 }; 755 }, 756 757 checkGroupShowed: function(node, callback) { 758 if (this.isGroupShowed(node)) { 759 return true; 760 } else { 761 addEvent(node, 'tgpliVisible', function() { 762 callback(node); 763 }, true); 764 return false; 765 } 766 }, 767 768 isGroupShowed: function(node) { 769 var group = this.findGroup(node); 770 return group === null || group.isShowed(); 771 } 772 }; 773 774 window.tgpLazyItems = new LazyItems(window.tgpLazyItemsOptions || {}); 775})(window, document);
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.