1/* 2 * ================== js/jquery.appearl.js =================== 3 */ 4 5;( function( $, window, document, undefined ) { 6 7 "use strict"; 8 9 var pluginName = "appearl", 10 defaults = { 11 offset: 0, 12 insetOffset: '50%' 13 }, 14 attributesMap = { 15 'offset': 'offset', 16 'inset-offset': 'insetOffset' 17 }, 18 $window = $(window); 19 20 // The actual plugin constructor 21 function Plugin ( element, options ) { 22 this.element = element; 23 this.$element = $(element); 24 this.settings = $.extend( {}, defaults, options ); 25 26 // read attributes 27 for ( var key in attributesMap ) { 28 var value = attributesMap[ key ], 29 dataAttr = this.$element.data( key ); 30 31 if ( dataAttr === undefined ) { 32 continue; 33 } 34 35 this.settings[ value ] = dataAttr; 36 } 37 38 this.init(); 39 } 40 41 // Avoid Plugin.prototype conflicts 42 $.extend( Plugin.prototype, { 43 init: function() { 44 if ( typeof this.settings.offset === 'object' ) { 45 this._offsetTop = this.settings.offset.top; 46 this._offsetBottom = this.settings.offset.bottom; 47 } else { 48 this._offsetTop = this._offsetBottom = this.settings.offset; 49 } 50 51 // To check if the element is on viewport and set the offset 0 for them 52 if ( this._isOnViewPort( this.$element) ) { 53 this._offsetTop = this._offsetBottom = 0 54 } 55 56 this._appeared = false; 57 this._lastScroll = 0; 58 59 $window.on( 'scroll resize', this.update.bind( this ) ); 60 setTimeout( this.update.bind(this) ); 61 }, 62 63 update: function( event ) { 64 var rect = this.element.getBoundingClientRect(), 65 areaTop = this._parseOffset( this._offsetTop ), 66 areaBottom = window.innerHeight - this._parseOffset( this._offsetBottom ), 67 insetOffset = this._parseOffset( this.settings.insetOffset, true ); 68 69 if ( rect.top + insetOffset <= areaBottom && rect.bottom - insetOffset >= areaTop ) { 70 !this._appeared && this.$element.trigger( 'appear', [{ from: ( this._lastScroll <= $window.scrollTop() ? 'bottom' : 'top' ) }] ); 71 this._appeared = true; 72 } else if ( this._appeared ) { 73 this.$element.trigger( 'disappear', [{ from: ( rect.top < areaTop ? 'top' : 'bottom' ) }] ); 74 this._appeared = false; 75 } 76 77 this._lastScroll = $window.scrollTop(); 78 }, 79 80 _parseOffset: function( value, inset ) { 81 var percentage = typeof value === 'string' && value.indexOf( '%' ) !== -1; 82 value = parseInt( value ); 83 84 return !percentage ? value : ( inset ? this.element.offsetHeight : window.innerHeight ) * value / 100; 85 }, 86 87 _isOnViewPort: function( element ) { 88 var bottomOffset = this.element.getBoundingClientRect().bottom; 89 return bottomOffset < window.innerHeight 90 }, 91 } ); 92 93 $.fn[ pluginName ] = function( options ) { 94 return this.each( function() { 95 if ( !$.data( this, "plugin_" + pluginName ) ) { 96 $.data( this, "plugin_" + 97 pluginName, new Plugin( this, options ) ); 98 } 99 } ); 100 }; 101 102 103 104 105 /*! 106 * 107 * ================== js/plugins/tilt.jquery.js =================== 108 **/ 109 (function (factory) { 110 if (typeof define === 'function' && define.amd) { 111 // AMD. Register as an anonymous module. 112 define(['jquery'], factory); 113 } else if (typeof module === 'object' && module.exports) { 114 // Node/CommonJS 115 module.exports = function( root, jQuery ) { 116 if ( jQuery === undefined ) { 117 // require('jQuery') returns a factory that requires window to 118 // build a jQuery instance, we normalize how we use modules 119 // that require this pattern but the window provided is a noop 120 // if it's defined (how jquery works) 121 if ( typeof window !== 'undefined' ) { 122 jQuery = require('jquery'); 123 } 124 else { 125 jQuery = require('jquery')(root); 126 } 127 } 128 factory(jQuery); 129 return jQuery; 130 }; 131 } else { 132 // Browser globals 133 factory(jQuery); 134 } 135 }(function ($) { 136 $.fn.tilt = function (options) { 137 138 /** 139 * RequestAnimationFrame 140 */ 141 const requestTick = function() { 142 if (this.ticking) return; 143 requestAnimationFrame(updateTransforms.bind(this)); 144 this.ticking = true; 145 }; 146 147 /** 148 * Bind mouse movement evens on instance 149 */ 150 const bindEvents = function() { 151 const _this = this; 152 $(this).on('mousemove', mouseMove); 153 $(this).on('mouseenter', mouseEnter); 154 if (this.settings.reset) $(this).on('mouseleave', mouseLeave); 155 if (this.settings.glare) $(window).on('resize', updateGlareSize.bind(_this)); 156 }; 157 158 /** 159 * Set transition only on mouse leave and mouse enter so it doesn't influence mouse move transforms 160 */ 161 const setTransition = function() { 162 if (this.timeout !== undefined) clearTimeout(this.timeout); 163 $(this).css({'transition': `${this.settings.speed}ms ${this.settings.easing}`}); 164 if(this.settings.glare) this.glareElement.css({'transition': `opacity ${this.settings.speed}ms ${this.settings.easing}`}); 165 this.timeout = setTimeout(() => { 166 $(this).css({'transition': ''}); 167 if(this.settings.glare) this.glareElement.css({'transition': ''}); 168 }, this.settings.speed); 169 }; 170 171 /** 172 * When user mouse enters tilt element 173 */ 174 const mouseEnter = function(event) { 175 this.ticking = false;
176 $(this).css({'will-change': 'transform'}); 177 setTransition.call(this); 178 179 // Trigger change event 180 $(this).trigger("tilt.mouseEnter"); 181 }; 182 183 /** 184 * Return the x,y position of the mouse on the tilt element 185 * @returns {{x: *, y: *}} 186 */ 187 const getMousePositions = function(event) { 188 if (typeof(event) === "undefined") { 189 event = { 190 pageX: $(this).offset().left + $(this).outerWidth() / 2, 191 pageY: $(this).offset().top + $(this).outerHeight() / 2 192 }; 193 } 194 return {x: event.pageX, y: event.pageY}; 195 }; 196 197 /** 198 * When user mouse moves over the tilt element 199 */ 200 const mouseMove = function(event) { 201 this.mousePositions = getMousePositions(event); 202 requestTick.call(this); 203 }; 204 205 /** 206 * When user mouse leaves tilt element 207 */ 208 const mouseLeave = function() { 209 setTransition.call(this); 210 this.reset = true; 211 requestTick.call(this); 212 213 // Trigger change event 214 $(this).trigger("tilt.mouseLeave"); 215 }; 216 217 /** 218 * Get tilt values 219 * 220 * @returns {{x: tilt value, y: tilt value}} 221 */ 222 const getValues = function() { 223 const width = $(this).outerWidth(); 224 const height = $(this).outerHeight(); 225 const left = $(this).offset().left; 226 const top = $(this).offset().top; 227 const percentageX = (this.mousePositions.x - left) / width; 228 const percentageY = (this.mousePositions.y - top) / height; 229 // x or y position inside instance / width of instance = percentage of position inside instance * the max tilt value 230 const tiltX = ((this.settings.maxTilt / 2) - ((percentageX) * this.settings.maxTilt)).toFixed(2); 231 const tiltY = (((percentageY) * this.settings.maxTilt) - (this.settings.maxTilt / 2)).toFixed(2); 232 // angle 233 const angle = Math.atan2(this.mousePositions.x - (left+width/2),- (this.mousePositions.y - (top+height/2)) )*(180/Math.PI); 234 // Return x & y tilt values 235 return {tiltX, tiltY, 'percentageX': percentageX * 100, 'percentageY': percentageY * 100, angle}; 236 }; 237 238 /** 239 * Update tilt transforms on mousemove 240 */ 241 const updateTransforms = function() { 242 this.transforms = getValues.call(this); 243 244 if (this.reset) { 245 this.reset = false; 246 $(this).css('transform', `perspective(${this.settings.perspective}px) rotateX(0deg) rotateY(0deg)`); 247 248 // Rotate glare if enabled 249 if (this.settings.glare){ 250 this.glareElement.css('transform', `rotate(180deg) translate(-50%, -50%)`); 251 this.glareElement.css('opacity', `0`); 252 } 253 254 return; 255 } else { 256 $(this).css('transform', `perspective(${this.settings.perspective}px) rotateX(${this.settings.disableAxis === 'x' ? 0 : this.transforms.tiltY}deg) rotateY(${this.settings.disableAxis === 'y' ? 0 : this.transforms.tiltX}deg) scale3d(${this.settings.scale},${this.settings.scale},${this.settings.scale})`); 257 258 // Rotate glare if enabled 259 if (this.settings.glare){ 260 this.glareElement.css('transform', `rotate(${this.transforms.angle}deg) translate(-50%, -50%)`); 261 this.glareElement.css('opacity', `${this.transforms.percentageY * this.settings.maxGlare / 100}`); 262 } 263 } 264 265 // Trigger change event 266 $(this).trigger("change", [this.transforms]); 267 268 this.ticking = false; 269 }; 270 271 /** 272 * Prepare elements 273 */ 274 const prepareGlare = function () { 275 const glarePrerender = this.settings.glarePrerender; 276 277 // If option pre-render is enabled we assume all html/css is present for an optimal glare effect. 278 if (!glarePrerender) 279 // Create glare element 280 $(this).append('<div class="js-tilt-glare"><div class="js-tilt-glare-inner"></div></div>'); 281 282 // Store glare selector if glare is enabled 283 this.glareElementWrapper = $(this).find(".js-tilt-glare"); 284 this.glareElement = $(this).find(".js-tilt-glare-inner"); 285 286 // Remember? We assume all css is already set, so just return 287 if (glarePrerender) return; 288 289 // Abstracted re-usable glare styles 290 const stretch = { 291 'position': 'absolute', 292 'top': '0', 293 'left': '0', 294 'width': '100%', 295 'height': '100%', 296 }; 297 298 // Style glare wrapper 299 this.glareElementWrapper.css(stretch).css({ 300 'overflow': 'hidden', 301 'pointer-events': 'none', 302 }); 303 304 // Style glare element 305 this.glareElement.css({ 306 'position': 'absolute', 307 'top': '50%', 308 'left': '50%', 309 'background-image': `linear-gradient(0deg, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%)`, 310 'width': `${$(this).outerWidth()*2}`, 311 'height': `${$(this).outerWidth()*2}`, 312 'transform': 'rotate(180deg) translate(-50%, -50%)', 313 'transform-origin': '0% 0%', 314 'opacity': '0', 315 }); 316 317 }; 318 319 /** 320 * Update glare on resize 321 */ 322 const updateGlareSize = function () { 323 this.glareElement.css({ 324 'width': `${$(this).outerWidth()*2}`, 325 'height': `${$(this).outerWidth()*2}`, 326 }); 327 }; 328 329 /** 330 * Public methods 331 */ 332 $.fn.tilt.destroy = function() { 333 $(this).each(function () { 334 $(this).find('.js-tilt-glare').remove(); 335 $(this).css({'will-change': '', 'transform': ''}); 336 $(this).off('mousemove mouseenter mouseleave'); 337 }); 338 }; 339 340 $.fn.tilt.getValues = function() { 341 const results = []; 342 $(this).each(function () { 343 this.mousePositions = getMousePositions.call(this); 344 results.push(getValues.call(this)); 345 }); 346 return results; 347 }; 348 349 $.fn.tilt.reset = function() { 350 $(this).each(function () { 351 this.mousePositions = getMousePositions.call(this); 352 this.settings = $(this).data('settings'); 353 mouseLeave.call(this); 354 setTimeout(() => { 355 this.reset = false;
356 }, this.settings.transition); 357 }); 358 }; 359 360 /** 361 * Loop every instance 362 */ 363 return this.each(function () { 364 365 /** 366 * Default settings merged with user settings 367 * Can be set trough data attributes or as parameter. 368 * @type {*} 369 */ 370 this.settings = $.extend({ 371 maxTilt: $(this).is('[data-tilt-max]') ? $(this).data('tilt-max') : 20, 372 perspective: $(this).is('[data-tilt-perspective]') ? $(this).data('tilt-perspective') : 300, 373 easing: $(this).is('[data-tilt-easing]') ? $(this).data('tilt-easing') : 'cubic-bezier(.03,.98,.52,.99)', 374 scale: $(this).is('[data-tilt-scale]') ? $(this).data('tilt-scale') : '1', 375 speed: $(this).is('[data-tilt-speed]') ? $(this).data('tilt-speed') : '400', 376 transition: $(this).is('[data-tilt-transition]') ? $(this).data('tilt-transition') : true, 377 disableAxis: $(this).is('[data-tilt-disable-axis]') ? $(this).data('tilt-disable-axis') : null, 378 axis: $(this).is('[data-tilt-axis]') ? $(this).data('tilt-axis') : null, 379 reset: $(this).is('[data-tilt-reset]') ? $(this).data('tilt-reset') : true, 380 glare: $(this).is('[data-tilt-glare]') ? $(this).data('tilt-glare') : false, 381 maxGlare: $(this).is('[data-tilt-maxglare]') ? $(this).data('tilt-maxglare') : 1, 382 }, options); 383 384 // Add deprecation warning & set disableAxis to deprecated axis setting 385 if(this.settings.axis !== null){ 386 console.warn('Tilt.js: the axis setting has been renamed to disableAxis. See https://github.com/gijsroge/tilt.js/pull/26 for more information'); 387 this.settings.disableAxis = this.settings.axis; 388 } 389 390 this.init = () => { 391 // Store settings 392 $(this).data('settings', this.settings); 393 394 // Prepare element 395 if(this.settings.glare) prepareGlare.call(this); 396 397 // Bind events 398 bindEvents.call(this); 399 }; 400 401 // Init 402 this.init(); 403 404 }); 405 }; 406 407 /** 408 * Auto load 409 */ 410 $('[data-tilt]').tilt(); 411 412 return true; 413 })); 414 415 416 417 418 419 if( typeof Object.create !== 'function' ){ Object.create = function (obj){ function F(){} F.prototype = obj; return new F();}; } 420 421 // config for lazysizes 422 window.lazySizesConfig = window.lazySizesConfig || {}; 423 window.lazySizesConfig.lazyClass = 'jltma-preload'; 424 window.lazySizesConfig.loadingClass = 'jltma-preloading'; 425 window.lazySizesConfig.loadedClass = 'jltma-preloaded'; 426 427 // On Loading 428 // an event right before of the "unveil" transformation of lazyload 429 document.addEventListener('lazybeforeunveil', function( e ){ 430 var color = e.target.getAttribute( 'data-bg-color' ); 431 if( color ){ 432 e.target.style.backgroundColor = color; 433 } 434 }); 435 436 document.addEventListener('lazyloaded', function( e ){ 437 if( e.target.getAttribute('data-bg-color') ){ 438 e.target.style.backgroundColor = 'initial'; 439 } 440 if( e.target.classList.contains('jltma-has-preload-height') ){ 441 e.target.classList.remove('jltma-has-preload-height'); 442 e.target.style.height = 'auto'; 443 } 444 445 // Lazyload videos 446 if( e.target.nodeName === "VIDEO" ){ 447 var video = e.target; 448 449 for (var source in video.children) { 450 var videoSource = video.children[source]; 451 if ( videoSource.tagName === "SOURCE" && videoSource.getAttribute('data-src') ) { 452 videoSource.src = videoSource.getAttribute('data-src'); 453 } 454 } 455 video.load(); 456 457 // autoPlay video 458 if( video.classList.contains('jltma-autoplay') ){ 459 video.play(); 460 } 461 } 462 }); 463 464 (function($, window, document, undefined){ 465 "use strict"; 466 467 var resposiveNotLoadedImages = function(){ 468 var width, height, lazysizeImages = document.querySelectorAll('.jltma-preload'); 469 470 Array.prototype.forEach.call(lazysizeImages, function(el, i){ 471 if( ( width = el.getAttribute('width') ) && ( height = el.getAttribute('height') ) ){ 472 el.style.height = el.clientWidth/(width/height) + 'px'; 473 el.classList.add('jltma-has-preload-height'); 474 } 475 }); 476 }; 477 478 window.addEventListener("orientationchange", resposiveNotLoadedImages); 479 window.addEventListener('resize', resposiveNotLoadedImages); 480 $(resposiveNotLoadedImages); 481 482 })(jQuery, window, document); 483 484 485 486 487 488 489/*! 490 * ================== js/libs/plugins/lazysizes.js =================== 491 **/ 492 493(function(window, factory) { 494 var lazySizes = factory(window, window.document); 495 window.lazySizes = lazySizes; 496 if(typeof module == 'object' && module.exports){ 497 module.exports = lazySizes; 498 } 499}(window, function l(window, document) { 500 'use strict'; 501 /*jshint eqnull:true */ 502 if(!document.getElementsByClassName){return;} 503 504 var lazysizes, lazySizesConfig; 505 506 var docElem = document.documentElement; 507 508 var Date = window.Date; 509 510 var supportPicture = window.HTMLPictureElement; 511 512 var _addEventListener = 'addEventListener'; 513 514 var _getAttribute = 'getAttribute'; 515 516 var addEventListener = window[_addEventListener]; 517 518 var setTimeout = window.setTimeout; 519 520 var requestAnimationFrame = window.requestAnimationFrame || setTimeout; 521 522 var requestIdleCallback = window.requestIdleCallback; 523 524 var regPicture = /^picture$/i; 525 526 var loadEvents = ['load', 'error', 'lazyincluded', '_lazyloaded']; 527 528 var regClassCache = {}; 529
vendor: 4,991 bytes, lines 530-751
530 var forEach = Array.prototype.forEach; 531 532 var hasClass = function(ele, cls) { 533 if(!regClassCache[cls]){ 534 regClassCache[cls] = new RegExp('(\\s|^)'+cls+'(\\s|$)'); 535 } 536 return regClassCache[cls].test(ele[_getAttribute]('class') || '') && regClassCache[cls]; 537 }; 538 539 var addClass = function(ele, cls) { 540 if (!hasClass(ele, cls)){ 541 ele.setAttribute('class', (ele[_getAttribute]('class') || '').trim() + ' ' + cls); 542 } 543 }; 544 545 var removeClass = function(ele, cls) { 546 var reg; 547 if ((reg = hasClass(ele,cls))) { 548 ele.setAttribute('class', (ele[_getAttribute]('class') || '').replace(reg, ' ')); 549 } 550 }; 551 552 var addRemoveLoadEvents = function(dom, fn, add){ 553 var action = add ? _addEventListener : 'removeEventListener'; 554 if(add){ 555 addRemoveLoadEvents(dom, fn); 556 } 557 loadEvents.forEach(function(evt){ 558 dom[action](evt, fn); 559 }); 560 }; 561 562 var triggerEvent = function(elem, name, detail, noBubbles, noCancelable){ 563 var event = document.createEvent('CustomEvent'); 564 565 if(!detail){ 566 detail = {}; 567 } 568 569 detail.instance = lazysizes; 570 571 event.initCustomEvent(name, !noBubbles, !noCancelable, detail); 572 573 elem.dispatchEvent(event); 574 return event; 575 }; 576 577 var updatePolyfill = function (el, full){ 578 var polyfill; 579 if( !supportPicture && ( polyfill = (window.picturefill || lazySizesConfig.pf) ) ){ 580 polyfill({reevaluate: true, elements: [el]}); 581 } else if(full && full.src){ 582 el.src = full.src; 583 } 584 }; 585 586 var getCSS = function (elem, style){ 587 return (getComputedStyle(elem, null) || {})[style]; 588 }; 589 590 var getWidth = function(elem, parent, width){ 591 width = width || elem.offsetWidth; 592 593 while(width < lazySizesConfig.minSize && parent && !elem._lazysizesWidth){ 594 width = parent.offsetWidth; 595 parent = parent.parentNode; 596 } 597 598 return width; 599 }; 600 601 var rAF = (function(){ 602 var running, waiting; 603 var firstFns = []; 604 var secondFns = []; 605 var fns = firstFns; 606 607 var run = function(){ 608 var runFns = fns; 609 610 fns = firstFns.length ? secondFns : firstFns; 611 612 running = true; 613 waiting = false; 614 615 while(runFns.length){ 616 runFns.shift()(); 617 } 618 619 running = false; 620 }; 621 622 var rafBatch = function(fn, queue){ 623 if(running && !queue){ 624 fn.apply(this, arguments); 625 } else { 626 fns.push(fn); 627 628 if(!waiting){ 629 waiting = true; 630 (document.hidden ? setTimeout : requestAnimationFrame)(run); 631 } 632 } 633 }; 634 635 rafBatch._lsFlush = run; 636 637 return rafBatch; 638 })(); 639 640 var rAFIt = function(fn, simple){ 641 return simple ? 642 function() { 643 rAF(fn); 644 } : 645 function(){ 646 var that = this; 647 var args = arguments; 648 rAF(function(){ 649 fn.apply(that, args); 650 }); 651 } 652 ; 653 }; 654 655 var throttle = function(fn){ 656 var running; 657 var lastTime = 0; 658 var gDelay = 125; 659 var rICTimeout = lazySizesConfig.ricTimeout; 660 var run = function(){ 661 running = false; 662 lastTime = Date.now(); 663 fn(); 664 }; 665 var idleCallback = requestIdleCallback && lazySizesConfig.ricTimeout ? 666 function(){ 667 requestIdleCallback(run, {timeout: rICTimeout}); 668 669 if(rICTimeout !== lazySizesConfig.ricTimeout){ 670 rICTimeout = lazySizesConfig.ricTimeout; 671 } 672 } : 673 rAFIt(function(){ 674 setTimeout(run); 675 }, true) 676 ; 677 678 return function(isPriority){ 679 var delay; 680 681 if((isPriority = isPriority === true)){ 682 rICTimeout = 33; 683 } 684 685 if(running){ 686 return; 687 } 688 689 running = true; 690 691 delay = gDelay - (Date.now() - lastTime); 692 693 if(delay < 0){ 694 delay = 0; 695 } 696 697 if(isPriority || (delay < 9 && requestIdleCallback)){ 698 idleCallback(); 699 } else { 700 setTimeout(idleCallback, delay); 701 } 702 }; 703 }; 704 705 //based on http://modernjavascript.blogspot.de/2013/08/building-better-debounce.html 706 var debounce = function(func) { 707 var timeout, timestamp; 708 var wait = 99; 709 var run = function(){ 710 timeout = null; 711 func(); 712 }; 713 var later = function() { 714 var last = Date.now() - timestamp; 715 716 if (last < wait) { 717 setTimeout(later, wait - last); 718 } else { 719 (requestIdleCallback || run)(run); 720 } 721 }; 722 723 return function() { 724 timestamp = Date.now(); 725 726 if (!timeout) { 727 timeout = setTimeout(later, wait); 728 } 729 }; 730 }; 731 732 (function(){ 733 var prop; 734 735 var lazySizesDefaults = { 736 lazyClass: 'lazyload', 737 loadedClass: 'lazyloaded', 738 loadingClass: 'lazyloading', 739 preloadClass: 'lazypreload', 740 errorClass: 'lazyerror', 741 //strictClass: 'lazystrict', 742 autosizesClass: 'lazyautosizes', 743 srcAttr: 'data-src', 744 srcsetAttr: 'data-srcset', 745 sizesAttr: 'data-sizes', 746 //preloadAfterLoad: false, 747 minSize: 40, 748 customMedia: {}, 749 init: true, 750 expFactor: 1.5, 751 hFac: 0.8,
vendor: 13,165 bytes, lines 752-1192
752 loadMode: 2, 753 loadHidden: true, 754 ricTimeout: 300, 755 }; 756 757 lazySizesConfig = window.lazySizesConfig || window.lazysizesConfig || {}; 758 759 for(prop in lazySizesDefaults){ 760 if(!(prop in lazySizesConfig)){ 761 lazySizesConfig[prop] = lazySizesDefaults[prop]; 762 } 763 } 764 765 window.lazySizesConfig = lazySizesConfig; 766 767 setTimeout(function(){ 768 if(lazySizesConfig.init){ 769 init(); 770 } 771 }); 772 })(); 773 774 var loader = (function(){ 775 var preloadElems, isCompleted, resetPreloadingTimer, loadMode, started; 776 777 var eLvW, elvH, eLtop, eLleft, eLright, eLbottom; 778 779 var defaultExpand, preloadExpand, hFac; 780 781 var regImg = /^img$/i; 782 var regIframe = /^iframe$/i; 783 784 var supportScroll = ('onscroll' in window) && !(/glebot/.test(navigator.userAgent)); 785 786 var shrinkExpand = 0; 787 var currentExpand = 0; 788 789 var isLoading = 0; 790 var lowRuns = -1; 791 792 var resetPreloading = function(e){ 793 isLoading--; 794 if(e && e.target){ 795 addRemoveLoadEvents(e.target, resetPreloading); 796 } 797 798 if(!e || isLoading < 0 || !e.target){ 799 isLoading = 0; 800 } 801 }; 802 803 var isNestedVisible = function(elem, elemExpand){ 804 var outerRect; 805 var parent = elem; 806 var visible = getCSS(document.body, 'visibility') == 'hidden' || getCSS(elem, 'visibility') != 'hidden'; 807 808 eLtop -= elemExpand; 809 eLbottom += elemExpand; 810 eLleft -= elemExpand; 811 eLright += elemExpand; 812 813 while(visible && (parent = parent.offsetParent) && parent != document.body && parent != docElem){ 814 visible = ((getCSS(parent, 'opacity') || 1) > 0); 815 816 if(visible && getCSS(parent, 'overflow') != 'visible'){ 817 outerRect = parent.getBoundingClientRect(); 818 visible = eLright > outerRect.left && 819 eLleft < outerRect.right && 820 eLbottom > outerRect.top - 1 && 821 eLtop < outerRect.bottom + 1 822 ; 823 } 824 } 825 826 return visible; 827 }; 828 829 var checkElements = function() { 830 var eLlen, i, rect, autoLoadElem, loadedSomething, elemExpand, elemNegativeExpand, elemExpandVal, beforeExpandVal; 831 832 var lazyloadElems = lazysizes.elements; 833 834 if((loadMode = lazySizesConfig.loadMode) && isLoading < 8 && (eLlen = lazyloadElems.length)){ 835 836 i = 0; 837 838 lowRuns++; 839 840 if(preloadExpand == null){ 841 if(!('expand' in lazySizesConfig)){ 842 lazySizesConfig.expand = docElem.clientHeight > 500 && docElem.clientWidth > 500 ? 500 : 370; 843 } 844 845 defaultExpand = lazySizesConfig.expand; 846 preloadExpand = defaultExpand * lazySizesConfig.expFactor; 847 } 848 849 if(currentExpand < preloadExpand && isLoading < 1 && lowRuns > 2 && loadMode > 2 && !document.hidden){ 850 currentExpand = preloadExpand; 851 lowRuns = 0; 852 } else if(loadMode > 1 && lowRuns > 1 && isLoading < 6){ 853 currentExpand = defaultExpand; 854 } else { 855 currentExpand = shrinkExpand; 856 } 857 858 for(; i < eLlen; i++){ 859 860 if(!lazyloadElems[i] || lazyloadElems[i]._lazyRace){continue;} 861 862 if(!supportScroll){unveilElement(lazyloadElems[i]);continue;} 863 864 if(!(elemExpandVal = lazyloadElems[i][_getAttribute]('data-expand')) || !(elemExpand = elemExpandVal * 1)){ 865 elemExpand = currentExpand; 866 } 867 868 if(beforeExpandVal !== elemExpand){ 869 eLvW = innerWidth + (elemExpand * hFac); 870 elvH = innerHeight + elemExpand; 871 elemNegativeExpand = elemExpand * -1; 872 beforeExpandVal = elemExpand; 873 } 874 875 rect = lazyloadElems[i].getBoundingClientRect(); 876 877 if ((eLbottom = rect.bottom) >= elemNegativeExpand && 878 (eLtop = rect.top) <= elvH && 879 (eLright = rect.right) >= elemNegativeExpand * hFac && 880 (eLleft = rect.left) <= eLvW && 881 (eLbottom || eLright || eLleft || eLtop) && 882 (lazySizesConfig.loadHidden || getCSS(lazyloadElems[i], 'visibility') != 'hidden') && 883 ((isCompleted && isLoading < 3 && !elemExpandVal && (loadMode < 3 || lowRuns < 4)) || isNestedVisible(lazyloadElems[i], elemExpand))){ 884 unveilElement(lazyloadElems[i]); 885 loadedSomething = true; 886 if(isLoading > 9){break;} 887 } else if(!loadedSomething && isCompleted && !autoLoadElem && 888 isLoading < 4 && lowRuns < 4 && loadMode > 2 && 889 (preloadElems[0] || lazySizesConfig.preloadAfterLoad) && 890 (preloadElems[0] || (!elemExpandVal && ((eLbottom || eLright || eLleft || eLtop) || lazyloadElems[i][_getAttribute](lazySizesConfig.sizesAttr) != 'auto')))){ 891 autoLoadElem = preloadElems[0] || lazyloadElems[i]; 892 } 893 } 894 895 if(autoLoadElem && !loadedSomething){ 896 unveilElement(autoLoadElem); 897 } 898 } 899 }; 900 901 var throttledCheckElements = throttle(checkElements); 902 903 var switchLoadingClass = function(e){ 904 addClass(e.target, lazySizesConfig.loadedClass); 905 removeClass(e.target, lazySizesConfig.loadingClass); 906 addRemoveLoadEvents(e.target, rafSwitchLoadingClass); 907 triggerEvent(e.target, 'lazyloaded'); 908 }; 909 var rafedSwitchLoadingClass = rAFIt(switchLoadingClass); 910 var rafSwitchLoadingClass = function(e){ 911 rafedSwitchLoadingClass({target: e.target}); 912 }; 913 914 var changeIframeSrc = function(elem, src){ 915 try { 916 elem.contentWindow.location.replace(src); 917 } catch(e){ 918 elem.src = src; 919 } 920 }; 921 922 var handleSources = function(source){ 923 var customMedia; 924 925 var sourceSrcset = source[_getAttribute](lazySizesConfig.srcsetAttr); 926 927 if( (customMedia = lazySizesConfig.customMedia[source[_getAttribute]('data-media') || source[_getAttribute]('media')]) ){ 928 source.setAttribute('media', customMedia); 929 } 930 931 if(sourceSrcset){ 932 source.setAttribute('srcset', sourceSrcset); 933 } 934 }; 935 936 var lazyUnveil = rAFIt(function (elem, detail, isAuto, sizes, isImg){ 937 var src, srcset, parent, isPicture, event, firesLoad; 938 939 if(!(event = triggerEvent(elem, 'lazybeforeunveil', detail)).defaultPrevented){ 940 941 if(sizes){ 942 if(isAuto){ 943 addClass(elem, lazySizesConfig.autosizesClass); 944 } else { 945 elem.setAttribute('sizes', sizes); 946 } 947 } 948 949 srcset = elem[_getAttribute](lazySizesConfig.srcsetAttr); 950 src = elem[_getAttribute](lazySizesConfig.srcAttr); 951 952 if(isImg) { 953 parent = elem.parentNode; 954 isPicture = parent && regPicture.test(parent.nodeName || ''); 955 } 956 957 firesLoad = detail.firesLoad || (('src' in elem) && (srcset || src || isPicture)); 958 959 event = {target: elem}; 960 961 if(firesLoad){ 962 addRemoveLoadEvents(elem, resetPreloading, true); 963 clearTimeout(resetPreloadingTimer); 964 resetPreloadingTimer = setTimeout(resetPreloading, 2500); 965 966 addClass(elem, lazySizesConfig.loadingClass); 967 addRemoveLoadEvents(elem, rafSwitchLoadingClass, true); 968 } 969 970 if(isPicture){ 971 forEach.call(parent.getElementsByTagName('source'), handleSources); 972 } 973 974 if(srcset){ 975 elem.setAttribute('srcset', srcset); 976 } else if(src && !isPicture){ 977 if(regIframe.test(elem.nodeName)){ 978 changeIframeSrc(elem, src); 979 } else { 980 elem.src = src; 981 } 982 } 983 984 if(isImg && (srcset || isPicture)){ 985 updatePolyfill(elem, {src: src}); 986 } 987 } 988 989 if(elem._lazyRace){ 990 delete elem._lazyRace; 991 } 992 removeClass(elem, lazySizesConfig.lazyClass); 993 994 rAF(function(){ 995 if( !firesLoad || (elem.complete && elem.naturalWidth > 1)){ 996 if(firesLoad){ 997 resetPreloading(event); 998 } else { 999 isLoading--; 1000 } 1001 switchLoadingClass(event); 1002 } 1003 }, true); 1004 }); 1005 1006 var unveilElement = function (elem){ 1007 var detail; 1008 1009 var isImg = regImg.test(elem.nodeName); 1010 1011 //allow using sizes="auto", but don't use. it's invalid. Use data-sizes="auto" or a valid value for sizes instead (i.e.: sizes="80vw") 1012 var sizes = isImg && (elem[_getAttribute](lazySizesConfig.sizesAttr) || elem[_getAttribute]('sizes')); 1013 var isAuto = sizes == 'auto'; 1014 1015 if( (isAuto || !isCompleted) && isImg && (elem[_getAttribute]('src') || elem.srcset) && !elem.complete && !hasClass(elem, lazySizesConfig.errorClass) && hasClass(elem, lazySizesConfig.lazyClass)){return;} 1016 1017 detail = triggerEvent(elem, 'lazyunveilread').detail; 1018 1019 if(isAuto){ 1020 autoSizer.updateElem(elem, true, elem.offsetWidth); 1021 } 1022 1023 elem._lazyRace = true; 1024 isLoading++; 1025 1026 lazyUnveil(elem, detail, isAuto, sizes, isImg); 1027 }; 1028 1029 var onload = function(){ 1030 if(isCompleted){return;} 1031 if(Date.now() - started < 999){ 1032 setTimeout(onload, 999); 1033 return; 1034 } 1035 var afterScroll = debounce(function(){ 1036 lazySizesConfig.loadMode = 3; 1037 throttledCheckElements(); 1038 }); 1039 1040 isCompleted = true; 1041 1042 lazySizesConfig.loadMode = 3; 1043 1044 throttledCheckElements(); 1045 1046 addEventListener('scroll', function(){ 1047 if(lazySizesConfig.loadMode == 3){ 1048 lazySizesConfig.loadMode = 2; 1049 } 1050 afterScroll(); 1051 }, true); 1052 }; 1053 1054 return { 1055 _: function(){ 1056 started = Date.now(); 1057 1058 lazysizes.elements = document.getElementsByClassName(lazySizesConfig.lazyClass); 1059 preloadElems = document.getElementsByClassName(lazySizesConfig.lazyClass + ' ' + lazySizesConfig.preloadClass); 1060 hFac = lazySizesConfig.hFac; 1061 1062 addEventListener('scroll', throttledCheckElements, true); 1063 1064 addEventListener('resize', throttledCheckElements, true); 1065 1066 if(window.MutationObserver){ 1067 new MutationObserver( throttledCheckElements ).observe( docElem, {childList: true, subtree: true, attributes: true} ); 1068 } else { 1069 docElem[_addEventListener]('DOMNodeInserted', throttledCheckElements, true); 1070 docElem[_addEventListener]('DOMAttrModified', throttledCheckElements, true); 1071 setInterval(throttledCheckElements, 999); 1072 } 1073 1074 addEventListener('hashchange', throttledCheckElements, true); 1075 1076 //, 'fullscreenchange' 1077 ['focus', 'mouseover', 'click', 'load', 'transitionend', 'animationend', 'webkitAnimationEnd'].forEach(function(name){ 1078 document[_addEventListener](name, throttledCheckElements, true); 1079 }); 1080 1081 if((/d$|^c/.test(document.readyState))){ 1082 onload(); 1083 } else { 1084 addEventListener('load', onload); 1085 document[_addEventListener]('DOMContentLoaded', throttledCheckElements); 1086 setTimeout(onload, 20000); 1087 } 1088 1089 if(lazysizes.elements.length){ 1090 checkElements(); 1091 rAF._lsFlush(); 1092 } else { 1093 throttledCheckElements(); 1094 } 1095 }, 1096 checkElems: throttledCheckElements, 1097 unveil: unveilElement 1098 }; 1099 })(); 1100 1101 1102 var autoSizer = (function(){ 1103 var autosizesElems; 1104 1105 var sizeElement = rAFIt(function(elem, parent, event, width){ 1106 var sources, i, len; 1107 elem._lazysizesWidth = width; 1108 width += 'px'; 1109 1110 elem.setAttribute('sizes', width); 1111 1112 if(regPicture.test(parent.nodeName || '')){ 1113 sources = parent.getElementsByTagName('source'); 1114 for(i = 0, len = sources.length; i < len; i++){ 1115 sources[i].setAttribute('sizes', width); 1116 } 1117 } 1118 1119 if(!event.detail.dataAttr){ 1120 updatePolyfill(elem, event.detail); 1121 } 1122 }); 1123 var getSizeElement = function (elem, dataAttr, width){ 1124 var event; 1125 var parent = elem.parentNode; 1126 1127 if(parent){ 1128 width = getWidth(elem, parent, width); 1129 event = triggerEvent(elem, 'lazybeforesizes', {width: width, dataAttr: !!dataAttr}); 1130 1131 if(!event.defaultPrevented){ 1132 width = event.detail.width; 1133 1134 if(width && width !== elem._lazysizesWidth){ 1135 sizeElement(elem, parent, event, width); 1136 } 1137 } 1138 } 1139 }; 1140 1141 var updateElementsSizes = function(){ 1142 var i; 1143 var len = autosizesElems.length; 1144 if(len){ 1145 i = 0; 1146 1147 for(; i < len; i++){ 1148 getSizeElement(autosizesElems[i]); 1149 } 1150 } 1151 }; 1152 1153 var debouncedUpdateElementsSizes = debounce(updateElementsSizes); 1154 1155 return { 1156 _: function(){ 1157 autosizesElems = document.getElementsByClassName(lazySizesConfig.autosizesClass); 1158 addEventListener('resize', debouncedUpdateElementsSizes); 1159 }, 1160 checkElems: debouncedUpdateElementsSizes, 1161 updateElem: getSizeElement 1162 }; 1163 })(); 1164 1165 var init = function(){ 1166 if(!init.i){ 1167 init.i = true; 1168 autoSizer._(); 1169 loader._(); 1170 } 1171 }; 1172 1173 lazysizes = { 1174 cfg: lazySizesConfig, 1175 autoSizer: autoSizer, 1176 loader: loader, 1177 init: init, 1178 uP: updatePolyfill, 1179 aC: addClass, 1180 rC: removeClass, 1181 hC: hasClass, 1182 fire: triggerEvent, 1183 gW: getWidth, 1184 rAF: rAF, 1185 }; 1186 1187 return lazysizes; 1188} 1189)); 1190 1191 1192} )( jQuery, 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.