1(function ($) { 2 3 var lazy_effects = { 4 'clip': { 5 show: function(element) { 6 $(element.el).animate({ 7 transform: 'scale(1.1)', 8 }, 9 { 10 duration : 200, 11 }).animate({ 12 transform: 'scale(1)', 13 }, 14 { 15 duration : 200, 16 complete: function() { 17 if (element.options.queueType == 'sync') 18 element.finishAnimation(); 19 } 20 }) 21 } 22 }, 23 24 'fading': { 25 show: function(element) { 26 $(element.el).css({ 27 opacity: 0 28 }).animate({ 29 opacity: 1 30 }, 31 { 32 duration : 400, 33 complete: function() { 34 if (element.options.queueType == 'sync') 35 element.finishAnimation(); 36 } 37 }); 38 } 39 }, 40 41 'drop-right': { 42 show: function(element) { 43 var left = parseInt($(element.el).width()/15); 44 $(element.el).wrapInner('<div style="position: relative; left: ' + left + 'px;"></div>').css({ 45 opacity: 1 46 }); 47 48 $(element.el).find('> div').css({ 49 opacity: 0 50 }).animate({ 51 opacity: 1, 52 left: 0, 53 }, 54 { 55 duration : 700, 56 complete: function() { 57 //$(element.el).html($(element.el).find('> div').html()); 58 var $div = $(element.el).find('> div'); 59 $(element.el).append($div.find('> *')); 60 $div.remove(); 61 if (element.options.queueType == 'sync') 62 element.finishAnimation(); 63 } 64 }); 65 } 66 }, 67 68 'drop-right-without-wrap': { 69 show: function(element) { 70 var left = parseInt($(element.el).width()/15); 71 72 $(element.el).css({ 73 opacity: 0, 74 position: 'relative', 75 left: left 76 }).animate({ 77 opacity: 1, 78 left: 0, 79 }, 80 { 81 duration : 700, 82 complete: function() { 83 if (element.options.queueType == 'sync') 84 element.finishAnimation(); 85 } 86 }); 87 } 88 }, 89 90 'drop-right-unwrap': { 91 show: function(element) { 92 var left = parseInt($(element.el).width()/15); 93 $(element.el).wrapInner('<div style="position: relative; left: ' + left + 'px;"></div>').css({ 94 opacity: 1 95 }); 96 97 $(element.el).find('> div').css({ 98 opacity: 0 99 }).animate({ 100 opacity: 1, 101 left: 0, 102 }, 103 { 104 duration : 700, 105 complete: function() { 106 //$(element.el).unwrap(); 107 if (element.options.queueType == 'sync') 108 element.finishAnimation(); 109 } 110 }); 111 } 112 }, 113 114 'drop-left': { 115 show: function(element) { 116 var right = parseInt($(element.el).width()/15); 117 $(element.el).wrapInner('<div style="position: relative; right: ' + right + 'px;"></div>').css({ 118 opacity: 1 119 }); 120 121 $(element.el).find('> div').css({ 122 opacity: 0 123 }).animate({ 124 opacity: 1, 125 right: 0 126 }, 127 { 128 duration : 700, 129 complete: function() { 130 $(element.el).html($(element.el).find('> div').html()); 131 if (element.options.queueType == 'sync') 132 element.finishAnimation(); 133 } 134 }); 135 } 136 }, 137 138 'drop-bottom': { 139 show: function(element) { 140 var top = parseInt($(element.el).height()/15); 141 $(element.el).wrapInner('<div style="position: relative; top: ' + top + 'px;"></div>').css({ 142 opacity: 1 143 }); 144 145 $(element.el).find('> div').css({ 146 opacity: 0 147 }).animate({ 148 opacity: 1, 149 top: 0 150 }, 151 { 152 duration : 700, 153 complete: function() { 154 var $div = $(element.el).find('> div'); 155 $(element.el).append($div.find('> *')); 156 $div.remove(); 157 if (element.options.queueType == 'sync') 158 element.finishAnimation(); 159 } 160 }); 161 } 162 }, 163 164 'drop-top': { 165 show: function(element) { 166 var step = $(element.el).data('ll-step') || 0.07; 167 step = parseFloat(step); 168 var bottom = parseInt($(element.el).height() * step); 169 $(element.el).wrapInner('<div style="position: relative; bottom: ' + bottom + 'px;"></div>').css({ 170 opacity: 1 171 }); 172 173 $(element.el).find('> div').css({ 174 opacity: 0 175 }).animate({ 176 opacity: 1, 177 bottom: 0 178 }, 179 { 180 duration : 700, 181 complete: function() { 182 $(element.el).html($(element.el).find('> div').html()); 183 if (element.options.queueType == 'sync') 184 element.finishAnimation(); 185 } 186 }); 187 } 188 }, 189 190 'slide-right': { 191 show: function(element) { 192 if (element.options.firstGroupElement) 193 $(element.el).parent().css({ 194 overflow: 'hidden' 195 }); 196 $(element.el).css({ 197 opacity: 0, 198 position: 'relative', 199 left: '100%' 200 }).animate({left: 0, opacity: 1}, 100).animate({left: -15}, 100).animate({left: 0}, 100, function() { 201 if (element.options.lastGroupElement) 202 $(element.el).parent().css({ 203 overflow: 'visible' 204 }); 205 if (element.options.queueType == 'sync') 206 element.finishAnimation(); 207 }); 208 } 209 }, 210 211 'action': { 212 show: function(element) { 213 var func = $(element.el).data('ll-action-func') || ''; 214 if (!func || window[func] == null || window[func] == undefined) 215 return; 216 217 window[func](element.el); 218 } 219 }, 220 }; 221 222 function Element(el, options) { 223 this.el = el; 224 225 this.options = { 226 offset: 1, 227 delay: -1, 228 }; 229 $.extend(this.options, options); 230 231 if (this.options['delay'] == undefined || this.options['delay'] == null) 232 this.options['delay'] = -1; 233 this.options.queueType = this.options.delay == -1 ? 'sync': 'async'; 234 } 235 236 function Group(el, options) { 237 this.el = el; 238 this.queue = new Queue(this); 239 240 this.options = { 241 offset: 0.7, 242 delay: -1, 243 queueType: 'sync', 244 isFirst: false, 245 force: false, 246 firstGroupElement: false, 247 lastGroupElement: false 248 }; 249 $.extend(this.options, options); 250 251 if (this.options['itemDelay'] == undefined || this.options['itemDelay'] == null) 252 this.options['itemDelay'] = -1; 253 this.options.itemQueueType = this.options.itemDelay == -1 ? 'sync': 'async'; 254 this.options['finishDelay'] = this.options['finishDelay'] || 300; 255 } 256 257 function Queue(obj) { 258 this.object = obj; 259 this.queue = []; 260 this.is_exec = false;
261 } 262 263 function LazyLoading(options) { 264 this.options = { 265 }; 266 $.extend(this.options, options); 267 this.initialize(); 268 } 269 270 $.fn.reverse = [].reverse; 271 272 String.prototype.startsWith = function (str) { 273 return this.indexOf(str) == 0; 274 }; 275 276 $.lazyLoading = function(options) { 277 return new LazyLoading(options); 278 } 279 280 var ua = navigator.userAgent.toLowerCase(), 281 platform = navigator.platform.toLowerCase(), 282 UA = ua.match(/(opera|ie|firefox|chrome|version)[\s\/:]([\w\d\.]+)?.*?(safari|version[\s\/:]([\w\d\.]+)|$)/) || [null, 'unknown', 0], 283 mode = UA[1] == 'ie' && document.documentMode; 284 285 var Browser = { 286 name: (UA[1] == 'version') ? UA[3] : UA[1], 287 Platform: { 288 name: ua.match(/ip(?:ad|od|hone)/) ? 'ios' : (ua.match(/(?:webos|android)/) || platform.match(/mac|win|linux/) || ['other'])[0] 289 }, 290 }; 291 292 function getOffset(elem) { 293 if (elem.getBoundingClientRect && Browser.Platform.name != 'ios'){ 294 var bound = elem.getBoundingClientRect(), 295 html = elem.ownerDocument.documentElement, 296 htmlScroll = getScroll(html), 297 elemScrolls = getScrolls(elem), 298 isFixed = (styleString(elem, 'position') == 'fixed'); 299 return { 300 x: parseInt(bound.left) + elemScrolls.x + ((isFixed) ? 0 : htmlScroll.x) - html.clientLeft, 301 y: parseInt(bound.top) + elemScrolls.y + ((isFixed) ? 0 : htmlScroll.y) - html.clientTop 302 }; 303 } 304 305 var element = elem, position = {x: 0, y: 0}; 306 if (isBody(elem)) return position; 307 308 while (element && !isBody(element)){ 309 position.x += element.offsetLeft; 310 position.y += element.offsetTop; 311 312 if (Browser.name == 'firefox'){ 313 if (!borderBox(element)){ 314 position.x += leftBorder(element); 315 position.y += topBorder(element); 316 } 317 var parent = element.parentNode; 318 if (parent && styleString(parent, 'overflow') != 'visible'){ 319 position.x += leftBorder(parent); 320 position.y += topBorder(parent); 321 } 322 } else if (element != elem && Browser.name == 'safari'){ 323 position.x += leftBorder(element); 324 position.y += topBorder(element); 325 } 326 327 element = element.offsetParent; 328 } 329 if (Browser.name == 'firefox' && !borderBox(elem)){ 330 position.x -= leftBorder(elem); 331 position.y -= topBorder(elem); 332 } 333 return position; 334 }; 335 336 function getScroll(elem){ 337 return {x: window.pageXOffset || document.documentElement.scrollLeft, y: window.pageYOffset || document.documentElement.scrollTop}; 338 }; 339 340 function getScrolls(elem){ 341 var element = elem.parentNode, position = {x: 0, y: 0}; 342 while (element && !isBody(element)){ 343 position.x += element.scrollLeft; 344 position.y += element.scrollTop; 345 element = element.parentNode; 346 } 347 return position; 348 }; 349 350 function styleString(element, style) { 351 return $(element).css(style); 352 }; 353 354 function styleNumber(element, style){ 355 return parseInt(styleString(element, style)) || 0; 356 }; 357 358 function borderBox(element){ 359 return styleString(element, '-moz-box-sizing') == 'border-box'; 360 }; 361
362 function topBorder(element){ 363 return styleNumber(element, 'border-top-width'); 364 }; 365 366 function leftBorder(element){ 367 return styleNumber(element, 'border-left-width'); 368 }; 369 370 function isBody(element){ 371 return (/^(?:body|html)$/i).test(element.tagName); 372 }; 373 374 LazyLoading.prototype = { 375 initialize: function() { 376 this.animated = false; 377 this.groups = []; 378 this.queue = new Queue(this); 379 this.init = true; 380 381 this.hasHeaderVisuals = $('.ls-wp-container').size() > 0; 382 383 $(document).find('.lazy-loading:first').addClass('lazy-loading-first'); 384 $(document).find('.lazy-loading').not('.lazy-loading-not-hide').css({visibility: 'hidden'}); 385 386 $(document).ready(function() { 387 self.rebuild(); 388 389 $(window).resize(function() { 390 if (self.resizeTimeout) { 391 clearTimeout(self.resizeTimeout); 392 } 393 self.rebuild(); 394 }); 395 }); 396 397 var self = this; 398 $(window).scroll(function() { 399 if (!self.animated) { 400 if (self.init) 401 self.buildList(); 402 self.init = false; 403 setTimeout(function() { 404 self.scrollPageHandler(); 405 }, 100); 406 self.animated = true; 407 } 408 }); 409 410 $(window).on('lazy-loading-start', function() { 411 self.rebuild(); 412 }); 413 }, 414 415 rebuild: function() { 416 this.buildList(); 417 this.scrollPageHandler(); 418 }, 419 420 scrollPageHandler: function() { 421 var self = this; 422 423 var new_elements = []; 424 var window_bottom = $(window).scrollTop() + $(window).height(); 425 $.each(this.groups, function(index, group) { 426 if (group.is_visible(window_bottom)) { 427 group.show(); 428 } else { 429 new_elements.push(group); 430 } 431 }); 432 this.queue.next(); 433 this.groups = new_elements; 434 this.animated = false; 435 }, 436 437 buildList: function() { 438 var self = this; 439 this.groups = []; 440 $(document).find('.lazy-loading').not('.lazy-loading-showed').each(function() { 441 var group = new Group(this, { 442 offset: $(this).data('ll-offset') || 0.7, 443 lazyLoading: self, 444 itemDelay: $(this).data('ll-item-delay'), 445 isFirst: self.hasHeaderVisuals && $(this).hasClass('lazy-loading-first'), 446 finishDelay: $(this).data('ll-finish-delay'), 447 force: $(this).data('ll-force-start') != undefined && $(this).data('ll-force-start') != null 448 }); 449 450 var elements = []; 451 $(this).find('.lazy-loading-item').not('.lazy-loading-showed').each(function() { 452 var effect = self.getEffect(this); 453 if (effect == '') { 454 $(this).css({ 455 opacity: 1 456 }); 457 return; 458 } 459 var el_delay = group.options.itemDelay; 460 var element_delay = $(this).data('ll-item-delay'); 461 if (element_delay != null && element_delay != undefined) { 462 el_delay = element_delay; 463 } 464 element = new Element(this, { 465 effect: effect, 466 group: group, 467 delay: el_delay, 468 }); 469 elements.push(element); 470 }); 471 472 if (elements.length > 0) { 473 group.setElements(elements); 474 self.groups.push(group); 475 } 476 }); 477 }, 478 479 getEffect: function(element) { 480 return $(element).data('ll-effect') || ''; 481 }, 482 483 finishAnimation: function() { 484 } 485 }; 486 487 Group.prototype = { 488 is_visible: function(window_bottom) { 489 if (this.options.force) 490 return true; 491 var position = getOffset(this.el); 492 if ((position.y + parseFloat(this.options.offset) * this.el.offsetHeight) <= window_bottom) { 493 //console.log('lazy group visible: ' + $(this.el).attr('class') + ' | position: ' + position.y + ' | height: ' + this.el.offsetHeight + ' | offset: ' + parseFloat(this.options.offset) + ' | window_bottom: ' + window_bottom); 494 return true; 495 } 496 else 497 return false; 498 }, 499 500 show: function() { 501 this.options.lazyLoading.queue.add(this); 502 $(this.el).addClass('lazy-loading-showed'); 503 }, 504 505 setElements: function(elements) { 506 this.elements = elements; 507 }, 508 509 startAnimation: function() { 510 var self = this; 511 512 $(this.el).css({visibility: 'visible'}); 513 514 $.each(this.elements, function(index, element) { 515 if (self.elements[index].options.effect != 'action') 516 if (self.elements[index].options.effect != 'clip') 517 $(self.elements[index].el).css({ 518 opacity: 0 519 }); 520 else 521 $(self.elements[index].el).css({ 522 position: 'relative', 523 transform: 'scale(0)' 524 }); 525 if (index == 0) 526 self.elements[index].options.firstGroupElement = true; 527 if (index == self.elements.length - 1) { 528 self.elements[index].options.lastGroupElement = true; 529 self.elements[index].options.queueType = 'sync'; 530 } 531 self.elements[index].show(); 532 }); 533 if (this.options.isFirst) { 534 setTimeout(function() { 535 self.queue.next(); 536 }, 500); 537 } else { 538 this.queue.next(); 539 } 540 setTimeout(function() { 541 self.finishAnimation(); 542 }, this.options.finishDelay); 543 }, 544 545 finishAnimation: function() { 546 this.options.lazyLoading.queue.finishPosition(); 547 } 548 }; 549 550 Element.prototype = { 551 is_visible: function(window_bottom) { 552 var lazy_effect = lazy_effects[this.options.effect] || {}; 553 var offset = lazy_effect['offset'] || this.options.offset; 554 var position = getOffset(this.el);
555 if ((position.y + offset * this.el.offsetHeight) <= window_bottom) 556 return true; 557 else 558 return false; 559 }, 560 561 show: function() { 562 this.options.group.queue.add(this); 563 $(this.el).addClass('lazy-loading-showed'); 564 }, 565 566 startAnimation: function() { 567 var self = this; 568 var lazy_effect = lazy_effects[this.options.effect] || {}; 569 var func = lazy_effect['show'] || function() {}; 570 func(this); 571 if (this.options.delay >= 0 && this.options.queueType == 'async') 572 if (this.options.delay > 0) 573 setTimeout(function() { 574 self.finishAnimation(); 575 }, this.options.delay); 576 else 577 self.finishAnimation(); 578 }, 579 580 finishAnimation: function() { 581 this.options.group.queue.finishPosition(); 582 } 583 }; 584 585 Queue.prototype = { 586 add: function(obj) { 587 this.queue.push(obj); 588 //this.next(); 589 }, 590 591 next: function() { 592 if (this.is_exec || this.queue.length == 0) 593 return false; 594 595 this.is_exec = true; 596 var obj = this.queue.shift(); 597 obj.startAnimation(); 598 }, 599 600 finishPosition: function() { 601 this.is_exec = false; 602 if (this.queue.length > 0) 603 this.next(); 604 } 605 }; 606 607}(jQuery));
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.