vendor: 16,305 bytes, lines 1-521
1/* 2 _ _ _ _ 3 ___| (_) ___| | __ (_)___ 4/ __| | |/ __| |/ / | / __| 5\__ \ | | (__| < _ | \__ \ 6|___/_|_|\___|_|\_(_)/ |___/ 7 |__/ 8 9 Version: 1.6.0 10 Author: Ken Wheeler 11 Website: http://kenwheeler.github.io 12 Docs: http://kenwheeler.github.io/slick 13 Repo: http://github.com/kenwheeler/slick 14 Issues: http://github.com/kenwheeler/slick/issues 15 16 */ 17(function($) { 18 'use strict'; 19 var Slick = window.a4jSlick || {}; 20 21 Slick = (function() { 22 23 var instanceUid = 0; 24 25 function Slick(element, settings) { 26 27 var _ = this, dataSettings; 28 29 _.defaults = { 30 accessibility: true, 31 adaptiveHeight: false, 32 appendArrows: $(element), 33 appendDots: $(element), 34 arrows: true, 35 asNavFor: null, 36 prevArrow: '<span data-role="none" class="a4j-slick-prev" aria-label="Previous" tabindex="0" role="button"><i class="ing-icon-angle-left ing-fw"></i></span>', 37 nextArrow: '<span data-role="none" class="a4j-slick-next" aria-label="Next" tabindex="0" role="button"><i class="ing-icon-angle-right ing-fw"></i></span>', 38 autoplay: false, 39 autoplaySpeed: 3000, 40 centerMode: false, 41 centerPadding: '50px', 42 cssEase: 'ease', 43 customPaging: function(slider, i) { 44 return $('<i data-role="none" role="button" tabindex="0" />').text(i + 1); 45 }, 46 dots: false, 47 dotsClass: 'a4j-slick-dots', 48 draggable: true, 49 easing: 'linear', 50 edgeFriction: 0.35, 51 fade: false, 52 focusOnSelect: false, 53 infinite: false, 54 initialSlide: 0, 55 lazyLoad: 'ondemand', 56 mobileFirst: false, 57 pauseOnHover: true, 58 pauseOnFocus: true, 59 pauseOnDotsHover: false, 60 respondTo: 'window', 61 responsive: null, 62 rows: 1, 63 rtl: false, 64 slide: '', 65 slidesPerRow: 1, 66 slidesToShow: 1, 67 slidesToScroll: 1, 68 speed: 500, 69 swipe: true, 70 swipeToSlide: false, 71 touchMove: true, 72 touchThreshold: 5, 73 useCSS: true, 74 useTransform: true, 75 variableWidth: false, 76 vertical: false, 77 verticalSwiping: false, 78 waitForAnimate: true, 79 zIndex: 1000 80 }; 81 82 _.initials = { 83 animating: false, 84 dragging: false, 85 autoPlayTimer: null, 86 currentDirection: 0, 87 currentLeft: null, 88 currentSlide: 0, 89 direction: 1, 90 $dots: null, 91 listWidth: null, 92 listHeight: null, 93 loadIndex: 0, 94 $nextArrow: null, 95 $prevArrow: null, 96 slideCount: null, 97 slideWidth: null, 98 $slideTrack: null, 99 $slides: null, 100 sliding: false, 101 slideOffset: 0, 102 swipeLeft: null, 103 $list: null, 104 touchObject: {}, 105 transformsEnabled: false, 106 unslicked: false 107 }; 108 109 $.extend(_, _.initials); 110 111 _.activeBreakpoint = null; 112 _.animType = null; 113 _.animProp = null; 114 _.breakpoints = []; 115 _.breakpointSettings = []; 116 _.cssTransitions = false; 117 _.focussed = false; 118 _.interrupted = false; 119 _.hidden = 'hidden'; 120 _.paused = true; 121 _.positionProp = null; 122 _.respondTo = null; 123 _.rowCount = 1; 124 _.shouldClick = true; 125 _.$slider = $(element); 126 _.$slidesCache = null; 127 _.transformType = null; 128 _.transitionType = null; 129 _.visibilityChange = 'visibilitychange'; 130 _.windowWidth = 0; 131 _.windowTimer = null; 132 133 dataSettings = JSON.parse($(element).attr('data-slick') || '{}'); 134 135 _.options = $.extend({}, _.defaults, settings, dataSettings); 136 137 _.currentSlide = _.options.initialSlide; 138 139 _.originalSettings = _.options; 140 141 if (typeof document.mozHidden !== 'undefined') { 142 _.hidden = 'mozHidden'; 143 _.visibilityChange = 'mozvisibilitychange'; 144 } else if (typeof document.webkitHidden !== 'undefined') { 145 _.hidden = 'webkitHidden'; 146 _.visibilityChange = 'webkitvisibilitychange'; 147 } 148 149 _.autoPlay = $.proxy(_.autoPlay, _); 150 _.autoPlayClear = $.proxy(_.autoPlayClear, _); 151 _.autoPlayIterator = $.proxy(_.autoPlayIterator, _); 152 _.changeSlide = $.proxy(_.changeSlide, _); 153 _.clickHandler = $.proxy(_.clickHandler, _); 154 _.selectHandler = $.proxy(_.selectHandler, _); 155 _.setPosition = $.proxy(_.setPosition, _); 156 _.swipeHandler = $.proxy(_.swipeHandler, _); 157 _.dragHandler = $.proxy(_.dragHandler, _); 158 _.keyHandler = $.proxy(_.keyHandler, _); 159 160 _.instanceUid = instanceUid++; 161 162 // A simple way to check for HTML strings 163 // Strict HTML recognition (must start with <) 164 // Extracted from jQuery v1.11 source 165 _.htmlExpr = /^(?:\s*(<[\w\W]+>)[^>]*)$/; 166 167 168 _.registerBreakpoints(); 169 _.init(true); 170 171 $(element).data('ingslick',_); 172 } 173 174 return Slick; 175 176 }()); 177 178 Slick.prototype.activateADA = function() { 179 var _ = this; 180 181 _.$slideTrack.find('.a4j-slick-active').attr({ 182 'aria-hidden': 'false' 183 }).find('a, input, button, select').attr({ 184 'tabindex': '0' 185 }); 186 187 }; 188 189 Slick.prototype.addSlide = Slick.prototype.slickAdd = function(markup, index, addBefore) { 190 var _ = this; 191 192 if (typeof(index) === 'boolean') { 193 addBefore = index; 194 index = null; 195 } else if (index < 0 || (index >= _.slideCount)) { 196 return false; 197 } 198 199 _.unload(); 200 201 if (typeof(index) === 'number') { 202 if (index === 0 && _.$slides.length === 0) { 203 _.getRowsItems($(markup)).appendTo(_.$slideTrack); 204 } else if (addBefore) { 205 _.getRowsItems($(markup)).insertBefore(_.$slides.eq(index)); 206 } else { 207 _.getRowsItems($(markup)).insertAfter(_.$slides.eq(index)); 208 } 209 } else { 210 if (addBefore === true) { 211 _.getRowsItems($(markup)).prependTo(_.$slideTrack); 212 } else { 213 _.getRowsItems($(markup)).appendTo(_.$slideTrack); 214 } 215 } 216 217 _.$slides = _.$slideTrack.children(this.options.slide); 218 219 _.$slideTrack.children(this.options.slide).detach(); 220 221 _.$slideTrack.append(_.$slides); 222 223 _.$slides.each(function(index, element) { 224 $(element).attr('data-slick-index', index); 225 }); 226 227 _.$slidesCache = _.$slides; 228 229 _.reinit(); 230 231 }; 232 233 234 235 Slick.prototype.animateHeight = function() { 236 var _ = this; 237 if (_.options.slidesToShow === 1 && _.options.adaptiveHeight === true && _.options.vertical === false) { 238 var targetHeight = _.$slides.eq(_.currentSlide).outerHeight(true); 239 _.$list.animate({ 240 height: targetHeight 241 }, _.options.speed); 242 } 243 }; 244 245 Slick.prototype.animateSlide = function(targetLeft, callback) { 246 247 var animProps = {}, 248 _ = this; 249 250 _.animateHeight(); 251 252 if (_.options.rtl === true && _.options.vertical === false) { 253 targetLeft = -targetLeft; 254 } 255 if (_.transformsEnabled === false) { 256 if (_.options.vertical === false) { 257 _.$slideTrack.animate({ 258 left: targetLeft 259 }, _.options.speed, _.options.easing, callback); 260 } else { 261 _.$slideTrack.animate({ 262 top: targetLeft 263 }, _.options.speed, _.options.easing, callback); 264 } 265 266 } else { 267 268 if (_.cssTransitions === false) { 269 if (_.options.rtl === true) { 270 _.currentLeft = -(_.currentLeft); 271 } 272 $({ 273 animStart: _.currentLeft 274 }).animate({ 275 animStart: targetLeft 276 }, { 277 duration: _.options.speed, 278 easing: _.options.easing, 279 step: function(now) { 280 now = Math.ceil(now); 281 if (_.options.vertical === false) { 282 animProps[_.animType] = 'translate(' + 283 now + 'px, 0px)'; 284 _.$slideTrack.css(animProps); 285 } else { 286 animProps[_.animType] = 'translate(0px,' + 287 now + 'px)'; 288 _.$slideTrack.css(animProps); 289 } 290 }, 291 complete: function() { 292 if (callback) { 293 callback.call(); 294 } 295 } 296 }); 297 298 } else { 299 300 _.applyTransition(); 301 targetLeft = Math.ceil(targetLeft); 302 303 if (_.options.vertical === false) { 304 animProps[_.animType] = 'translate3d(' + targetLeft + 'px, 0px, 0px)'; 305 } else { 306 animProps[_.animType] = 'translate3d(0px,' + targetLeft + 'px, 0px)'; 307 } 308 _.$slideTrack.css(animProps); 309 310 if (callback) { 311 setTimeout(function() { 312 313 _.disableTransition(); 314 315 callback.call(); 316 }, _.options.speed); 317 } 318 319 } 320 321 } 322 323 }; 324 325 Slick.prototype.getNavTarget = function() { 326 327 var _ = this, 328 asNavFor = _.options.asNavFor; 329 330 if ( asNavFor && asNavFor !== null ) { 331 asNavFor = $(asNavFor).not(_.$slider); 332 } 333 334 return asNavFor; 335 336 }; 337 338 Slick.prototype.asNavFor = function(index) { 339 340 var _ = this, 341 asNavFor = _.getNavTarget(); 342 343 if ( asNavFor !== null && typeof asNavFor === 'object' ) { 344 asNavFor.each(function() { 345 var target = $(this).a4jslick('getSlick'); 346 if(!target.unslicked) { 347 target.slideHandler(index, true); 348 } 349 }); 350 } 351 352 }; 353 354 Slick.prototype.applyTransition = function(slide) { 355 356 var _ = this, 357 transition = {}; 358 359 if (_.options.fade === false) { 360 transition[_.transitionType] = _.transformType + ' ' + _.options.speed + 'ms ' + _.options.cssEase; 361 } else { 362 transition[_.transitionType] = 'opacity ' + _.options.speed + 'ms ' + _.options.cssEase; 363 } 364 365 if (_.options.fade === false) { 366 _.$slideTrack.css(transition); 367 } else { 368 _.$slides.eq(slide).css(transition); 369 } 370 371 }; 372 373 Slick.prototype.autoPlay = function() { 374 375 var _ = this; 376 377 _.autoPlayClear(); 378 379 if ( _.slideCount > _.options.slidesToShow ) { 380 _.autoPlayTimer = setInterval( _.autoPlayIterator, _.options.autoplaySpeed ); 381 } 382 383 }; 384 385 Slick.prototype.autoPlayClear = function() { 386 387 var _ = this; 388 389 if (_.autoPlayTimer) { 390 clearInterval(_.autoPlayTimer); 391 } 392 393 }; 394 395 Slick.prototype.autoPlayIterator = function() { 396 397 var _ = this, 398 slideTo = _.currentSlide + _.options.slidesToScroll; 399 400 if ( !_.paused && !_.interrupted && !_.focussed ) { 401 402 if ( _.options.infinite === false ) { 403 404 if ( _.direction === 1 && ( _.currentSlide + 1 ) === ( _.slideCount - 1 )) { 405 _.direction = 0; 406 } 407 408 else if ( _.direction === 0 ) { 409 410 slideTo = _.currentSlide - _.options.slidesToScroll; 411 412 if ( _.currentSlide - 1 === 0 ) { 413 _.direction = 1; 414 } 415 416 } 417 418 } 419 420 _.slideHandler( slideTo ); 421 422 } 423 424 }; 425 426 Slick.prototype.buildArrows = function() { 427 428 var _ = this; 429 430 if (_.options.arrows === true ) { 431 432 _.$prevArrow = $(_.options.prevArrow).addClass('a4j-slick-arrow'); 433 _.$nextArrow = $(_.options.nextArrow).addClass('a4j-slick-arrow'); 434 435 if( _.slideCount > _.options.slidesToShow ) { 436 437 _.$prevArrow.removeClass('a4j-slick-hidden').removeAttr('aria-hidden tabindex'); 438 _.$nextArrow.removeClass('a4j-slick-hidden').removeAttr('aria-hidden tabindex'); 439 440 if (_.htmlExpr.test(_.options.prevArrow)) { 441 _.$prevArrow.appendTo(_.options.appendArrows); 442 } 443 444 if (_.htmlExpr.test(_.options.nextArrow)) { 445 _.$nextArrow.appendTo(_.options.appendArrows); 446 } 447 448 if (_.options.infinite !== true) { 449 _.$prevArrow 450 .addClass('a4j-slick-disabled') 451 .attr('aria-disabled', 'true'); 452 } 453 454 } else { 455 456 _.$prevArrow.add( _.$nextArrow ) 457 458 .addClass('a4j-slick-hidden') 459 .attr({ 460 'aria-disabled': 'true', 461 'tabindex': '-1' 462 }); 463 464 } 465 466 } 467 468 }; 469 470 Slick.prototype.buildDots = function() { 471 472 var _ = this, 473 i, dot; 474 475 if (_.options.dots === true && _.slideCount > _.options.slidesToShow) { 476 477 _.$slider.addClass('a4j-slick-dotted'); 478 479 dot = $('<div />').addClass(_.options.dotsClass); 480 481 for (i = 0; i <= _.getDotCount(); i += 1) { 482 dot.append(_.options.customPaging.call(this, _, i)); 483 } 484 485 _.$dots = dot.appendTo(_.options.appendDots); 486 487 _.$dots.find('i').first().addClass('a4j-slick-active').attr('aria-hidden', 'false'); 488 489 } 490 491 }; 492 493 Slick.prototype.buildOut = function() { 494 495 var _ = this; 496 497 _.$slides = 498 _.$slider 499 .children( _.options.slide + ':not(.a4j-slick-cloned)') 500 .addClass('a4j-slick-slide'); 501 502 _.slideCount = _.$slides.length; 503 504 _.$slides.each(function(index, element) { 505 $(element) 506 .attr('data-slick-index', index) 507 .data('originalStyling', $(element).attr('style') || ''); 508 }); 509 510 _.$slider.addClass('a4j-slick-slider'); 511 _.$slider.addClass('a4j-slick-slider'); 512 513 _.$slideTrack = (_.slideCount === 0) ? 514 $('<div class="a4j-slick-track"/>').appendTo(_.$slider) : 515 _.$slides.wrapAll('<div class="a4j-slick-track"/>').parent(); 516 517 _.$list = _.$slideTrack.wrap( 518 '<div aria-live="polite" class="a4j-slick-list"/>').parent(); 519 _.$slideTrack.css('opacity', 0); 520 521 if (_.options.centerMode === true || _.options.swipeToSlide === true) {
522 _.options.slidesToScroll = 1; 523 } 524 525 $('img[data-lazy]', _.$slider).not('[src]').addClass('a4j-slick-loading'); 526 527 _.setupInfinite(); 528 529 _.buildArrows(); 530 531 _.buildDots(); 532 533 _.updateDots(); 534 535 536 _.setSlideClasses(typeof _.currentSlide === 'number' ? _.currentSlide : 0); 537 538 if (_.options.draggable === true) { 539 _.$list.addClass('draggable'); 540 } 541 542 }; 543 544 Slick.prototype.buildRows = function() { 545 546 var _ = this, a, b, c, newSlides, numOfSlides, originalSlides,slidesPerSection; 547 548 newSlides = document.createDocumentFragment(); 549 originalSlides = _.$slider.children(); 550 551 if(_.options.rows > 1) { 552 553 slidesPerSection = _.options.slidesPerRow * _.options.rows; 554 numOfSlides = Math.ceil( 555 originalSlides.length / slidesPerSection 556 ); 557 558 for(a = 0; a < numOfSlides; a++){ 559 var slide = document.createElement('div'); 560 for(b = 0; b < _.options.rows; b++) { 561 var row = document.createElement('div'); 562 row.className = "ingallery-row"; 563 for(c = 0; c < _.options.slidesPerRow; c++) { 564 var target = (a * slidesPerSection + ((b * _.options.slidesPerRow) + c)); 565 if (originalSlides.get(target)) { 566 row.appendChild(originalSlides.get(target)); 567 } 568 } 569 slide.appendChild(row); 570 } 571 newSlides.appendChild(slide); 572 } 573 574 _.$slider.empty().append(newSlides); 575 _.$slider.children().children().children() 576 .css({ 577 'width':(100 / _.options.slidesPerRow) + '%', 578 }); 579 580 } 581 582 }; 583 584 Slick.prototype.getRowsItems = function(_jqItems){ 585 var _ = this; 586 if(_.options.rows <= 1){ 587 return _jqItems; 588 } 589 var slide = $('<div></div>'); 590 var index = 0; 591 for(var a=0;a<_.options.rows;a++) { 592 var row = $('<div class="ingallery-row"></div>'); 593 slide.append(row); 594 for(var b=0;b<_.options.slidesPerRow;b++){ 595 var _item = $(_jqItems.get(index)).css('width',(100 / _.options.slidesPerRow) + '%'); 596 row.append(_item); 597 index++; 598 } 599 } 600 return slide; 601 }; 602 603 Slick.prototype.checkResponsive = function(initial, forceUpdate) { 604 605 var _ = this, 606 breakpoint, targetBreakpoint, respondToWidth, triggerBreakpoint = false; 607 var sliderWidth = _.$slider.width(); 608 var windowWidth = window.innerWidth || $(window).width(); 609 610 if (_.respondTo === 'window') { 611 respondToWidth = windowWidth; 612 } else if (_.respondTo === 'slider') { 613 respondToWidth = sliderWidth; 614 } else if (_.respondTo === 'min') { 615 respondToWidth = Math.min(windowWidth, sliderWidth); 616 } 617 618 if ( _.options.responsive && 619 _.options.responsive.length && 620 _.options.responsive !== null) { 621 622 targetBreakpoint = null; 623 624 for (breakpoint in _.breakpoints) { 625 if (_.breakpoints.hasOwnProperty(breakpoint)) { 626 if (_.originalSettings.mobileFirst === false) { 627 if (respondToWidth < _.breakpoints[breakpoint]) { 628 targetBreakpoint = _.breakpoints[breakpoint]; 629 } 630 } else { 631 if (respondToWidth > _.breakpoints[breakpoint]) { 632 targetBreakpoint = _.breakpoints[breakpoint]; 633 } 634 } 635 } 636 } 637 638 if (targetBreakpoint !== null) { 639 if (_.activeBreakpoint !== null) { 640 if (targetBreakpoint !== _.activeBreakpoint || forceUpdate) { 641 _.activeBreakpoint = 642 targetBreakpoint;
vendor: 15,717 bytes, lines 643-1132
643 if (_.breakpointSettings[targetBreakpoint] === 'unslick') { 644 _.unslick(targetBreakpoint); 645 } else { 646 _.options = $.extend({}, _.originalSettings, 647 _.breakpointSettings[ 648 targetBreakpoint]); 649 if (initial === true) { 650 _.currentSlide = _.options.initialSlide; 651 } 652 _.refresh(initial); 653 } 654 triggerBreakpoint = targetBreakpoint; 655 } 656 } else { 657 _.activeBreakpoint = targetBreakpoint; 658 if (_.breakpointSettings[targetBreakpoint] === 'unslick') { 659 _.unslick(targetBreakpoint); 660 } else { 661 _.options = $.extend({}, _.originalSettings, 662 _.breakpointSettings[ 663 targetBreakpoint]); 664 if (initial === true) { 665 _.currentSlide = _.options.initialSlide; 666 } 667 _.refresh(initial); 668 } 669 triggerBreakpoint = targetBreakpoint; 670 } 671 } else { 672 if (_.activeBreakpoint !== null) { 673 _.activeBreakpoint = null; 674 _.options = _.originalSettings; 675 if (initial === true) { 676 _.currentSlide = _.options.initialSlide; 677 } 678 _.refresh(initial); 679 triggerBreakpoint = targetBreakpoint; 680 } 681 } 682 683 // only trigger breakpoints during an actual break. not on initialize. 684 if( !initial && triggerBreakpoint !== false ) { 685 _.$slider.trigger('breakpoint', [_, triggerBreakpoint]); 686 } 687 } 688 689 }; 690 691 Slick.prototype.changeSlide = function(event, dontAnimate) { 692 693 var _ = this, 694 $target = $(event.currentTarget), 695 indexOffset, slideOffset, unevenOffset; 696 697 // If target is a link, prevent default action. 698 if($target.is('a')) { 699 event.preventDefault(); 700 } 701 702 // If target is not the <li> element (ie: a child), find the <li>. 703 if(!$target.is('i')) { 704 $target = $target.closest('i'); 705 } 706 707 unevenOffset = (_.slideCount % _.options.slidesToScroll !== 0); 708 indexOffset = unevenOffset ? 0 : (_.slideCount - _.currentSlide) % _.options.slidesToScroll; 709 710 switch (event.data.message) { 711 712 case 'previous': 713 slideOffset = indexOffset === 0 ? _.options.slidesToScroll : _.options.slidesToShow - indexOffset; 714 if (_.slideCount > _.options.slidesToShow) { 715 _.slideHandler(_.currentSlide - slideOffset, false, dontAnimate); 716 } 717 break; 718 719 case 'next': 720 slideOffset = indexOffset === 0 ? _.options.slidesToScroll : indexOffset; 721 if (_.slideCount > _.options.slidesToShow) { 722 _.slideHandler(_.currentSlide + slideOffset, false, dontAnimate); 723 } 724 break; 725 726 case 'index': 727 var index = event.data.index === 0 ? 0 : 728 event.data.index || $target.index() * _.options.slidesToScroll; 729 730 _.slideHandler(_.checkNavigable(index), false, dontAnimate); 731 $target.children().trigger('focus'); 732 break; 733 734 default: 735 return; 736 } 737 738 }; 739 740 Slick.prototype.checkNavigable = function(index) { 741 742 var _ = this, 743 navigables, prevNavigable; 744 745 navigables = _.getNavigableIndexes(); 746 prevNavigable = 0; 747 if (index > navigables[navigables.length - 1]) { 748 index = navigables[navigables.length - 1]; 749 } else { 750 for (var n in navigables) { 751 if (index < navigables[n]) { 752 index = prevNavigable; 753 break; 754 } 755 prevNavigable = navigables[n]; 756 } 757 } 758 759 return index; 760 }; 761 762 Slick.prototype.cleanUpEvents = function() { 763 764 var _ = this; 765 766 if (_.options.dots && _.$dots !== null) { 767 768 $('i', _.$dots) 769 .off('click.slick', _.changeSlide) 770 .off('mouseenter.slick', $.proxy(_.interrupt, _, true)) 771 .off('mouseleave.slick', $.proxy(_.interrupt, _, false)); 772 773 } 774 775 _.$slider.off('focus.slick blur.slick'); 776 777 if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) { 778 _.$prevArrow && _.$prevArrow.off('click.slick', _.changeSlide); 779 _.$nextArrow && _.$nextArrow.off('click.slick', _.changeSlide); 780 } 781 782 _.$list.off('touchstart.slick mousedown.slick', _.swipeHandler); 783 _.$list.off('touchmove.slick mousemove.slick', _.swipeHandler); 784 _.$list.off('touchend.slick mouseup.slick', _.swipeHandler); 785 _.$list.off('touchcancel.slick mouseleave.slick', _.swipeHandler); 786 787 _.$list.off('click.slick', _.clickHandler); 788 789 $(document).off(_.visibilityChange, _.visibility); 790 791 _.cleanUpSlideEvents(); 792 793 if (_.options.accessibility === true) { 794 _.$list.off('keydown.slick', _.keyHandler); 795 } 796 797 if (_.options.focusOnSelect === true) { 798 $(_.$slideTrack).children().off('click.slick', _.selectHandler); 799 } 800 801 $(window).off('orientationchange.slick.slick-' + _.instanceUid, _.orientationChange); 802 803 $(window).off('resize.slick.slick-' + _.instanceUid, _.resize); 804 805 $('[draggable!=true]', _.$slideTrack).off('dragstart', _.preventDefault); 806 807 $(window).off('load.slick.slick-' + _.instanceUid, _.setPosition); 808 $(document).off('ready.slick.slick-' + _.instanceUid, _.setPosition); 809 810 }; 811 812 Slick.prototype.cleanUpSlideEvents = function() { 813 814 var _ = this; 815 816 _.$list.off('mouseenter.slick', $.proxy(_.interrupt, _, true)); 817 _.$list.off('mouseleave.slick', $.proxy(_.interrupt, _, false)); 818 819 }; 820 821 Slick.prototype.cleanUpRows = function() { 822 823 var _ = this, originalSlides; 824 825 if(_.options.rows > 1) { 826 originalSlides = _.$slides.children().children(); 827 originalSlides.removeAttr('style'); 828 _.$slider.empty().append(originalSlides); 829 } 830 831 }; 832 833 Slick.prototype.clickHandler = function(event) { 834 835 var _ = this; 836 837 if (_.shouldClick === false) { 838 event.stopImmediatePropagation(); 839 event.stopPropagation(); 840 event.preventDefault(); 841 } 842 843 }; 844 845 Slick.prototype.destroy = function(refresh) { 846 847 var _ = this; 848 849 _.autoPlayClear(); 850 851 _.touchObject = {}; 852 853 _.cleanUpEvents(); 854 855 $('.a4j-slick-cloned', _.$slider).detach(); 856 857 if (_.$dots) { 858 _.$dots.remove(); 859 } 860 861 862 if ( _.$prevArrow && _.$prevArrow.length ) { 863 864 _.$prevArrow 865 .removeClass('a4j-slick-disabled a4j-slick-arrow a4j-slick-hidden') 866 .removeAttr('aria-hidden aria-disabled tabindex') 867 .css('display',''); 868 869 if ( _.htmlExpr.test( _.options.prevArrow )) { 870 _.$prevArrow.remove(); 871 } 872 } 873 874 if ( _.$nextArrow && _.$nextArrow.length ) { 875 876 _.$nextArrow 877 .removeClass('a4j-slick-disabled a4j-slick-arrow a4j-slick-hidden') 878 .removeAttr('aria-hidden aria-disabled tabindex') 879 .css('display',''); 880 881 if ( _.htmlExpr.test( _.options.nextArrow )) { 882 _.$nextArrow.remove(); 883 } 884 885 } 886 887 888 if (_.$slides) { 889 890 _.$slides 891 .removeClass('a4j-slick-slide a4j-slick-active a4j-slick-center a4j-slick-visible a4j-slick-current') 892 .removeAttr('aria-hidden') 893 .removeAttr('data-slick-index') 894 .each(function(){ 895 $(this).attr('style', $(this).data('originalStyling')); 896 }); 897 898 _.$slideTrack.children(this.options.slide).detach(); 899 900 _.$slideTrack.detach(); 901 902 _.$list.detach(); 903 904 _.$slider.append(_.$slides); 905 } 906 907 _.cleanUpRows(); 908 909 _.$slider.removeClass('a4j-slick-slider'); 910 _.$slider.removeClass('a4j-slick-initialized'); 911 _.$slider.removeClass('a4j-slick-dotted'); 912 913 _.unslicked = true; 914 915 if(!refresh) { 916 _.$slider.trigger('destroy', [_]); 917 } 918 919 }; 920 921 Slick.prototype.disableTransition = function(slide) { 922 923 var _ = this, 924 transition = {}; 925 926 transition[_.transitionType] = ''; 927 928 if (_.options.fade === false) { 929 _.$slideTrack.css(transition); 930 } else { 931 _.$slides.eq(slide).css(transition); 932 } 933 934 }; 935 936 Slick.prototype.fadeSlide = function(slideIndex, callback) { 937 938 var _ = this; 939 940 if (_.cssTransitions === false) { 941 942 _.$slides.eq(slideIndex).css({ 943 zIndex: _.options.zIndex 944 }); 945 946 _.$slides.eq(slideIndex).animate({ 947 opacity: 1 948 }, _.options.speed, _.options.easing, callback); 949 950 } else { 951 952 _.applyTransition(slideIndex); 953 954 _.$slides.eq(slideIndex).css({ 955 opacity: 1, 956 zIndex: _.options.zIndex 957 }); 958 959 if (callback) { 960 setTimeout(function() { 961 962 _.disableTransition(slideIndex); 963 964 callback.call(); 965 }, _.options.speed); 966 } 967 968 } 969 970 }; 971 972 Slick.prototype.fadeSlideOut = function(slideIndex) { 973 974 var _ = this; 975 976 if (_.cssTransitions === false) { 977 978 _.$slides.eq(slideIndex).animate({ 979 opacity: 0, 980 zIndex: _.options.zIndex - 2 981 }, _.options.speed, _.options.easing); 982 983 } else { 984 985 _.applyTransition(slideIndex); 986 987 _.$slides.eq(slideIndex).css({ 988 opacity: 0, 989 zIndex: _.options.zIndex - 2 990 }); 991 992 } 993 994 }; 995 996 Slick.prototype.filterSlides = Slick.prototype.slickFilter = function(filter) { 997 998 var _ = this; 999 1000 if (filter !== null) { 1001 1002 _.$slidesCache = _.$slides; 1003 1004 _.unload(); 1005 1006 _.$slideTrack.children(this.options.slide).detach(); 1007 1008 _.$slidesCache.filter(filter).appendTo(_.$slideTrack); 1009 1010 _.reinit(); 1011 1012 } 1013 1014 }; 1015 1016 Slick.prototype.focusHandler = function() { 1017 1018 var _ = this; 1019 1020 _.$slider 1021 .off('focus.slick blur.slick') 1022 .on('focus.slick blur.slick', 1023 '*:not(.a4j-slick-arrow)', function(event) { 1024 1025 event.stopImmediatePropagation(); 1026 var $sf = $(this); 1027 1028 setTimeout(function() { 1029 1030 if( _.options.pauseOnFocus ) { 1031 _.focussed = $sf.is(':focus'); 1032 _.autoPlay(); 1033 } 1034 1035 }, 0); 1036 1037 }); 1038 }; 1039 1040 Slick.prototype.getCurrent = Slick.prototype.slickCurrentSlide = function() { 1041 1042 var _ = this; 1043 return _.currentSlide; 1044 1045 }; 1046 1047 Slick.prototype.getDotCount = function() { 1048 1049 var _ = this; 1050 1051 var breakPoint = 0; 1052 var counter = 0; 1053 var pagerQty = 0; 1054 1055 if (_.options.infinite === true) { 1056 while (breakPoint < _.slideCount) { 1057 ++pagerQty; 1058 breakPoint = counter + _.options.slidesToScroll; 1059 counter += _.options.slidesToScroll <= _.options.slidesToShow ? _.options.slidesToScroll : _.options.slidesToShow; 1060 } 1061 } else if (_.options.centerMode === true) { 1062 pagerQty = _.slideCount; 1063 } else if(!_.options.asNavFor) { 1064 pagerQty = 1 + Math.ceil((_.slideCount - _.options.slidesToShow) / _.options.slidesToScroll); 1065 }else { 1066 while (breakPoint < _.slideCount) { 1067 ++pagerQty; 1068 breakPoint = counter + _.options.slidesToScroll; 1069 counter += _.options.slidesToScroll <= _.options.slidesToShow ? _.options.slidesToScroll : _.options.slidesToShow; 1070 } 1071 } 1072 1073 return pagerQty - 1; 1074 1075 }; 1076 1077 Slick.prototype.getLeft = function(slideIndex) { 1078 1079 var _ = this, 1080 targetLeft, 1081 verticalHeight, 1082 verticalOffset = 0, 1083 targetSlide; 1084 1085 _.slideOffset = 0; 1086 verticalHeight = _.$slides.first().outerHeight(true); 1087 1088 if (_.options.infinite === true) { 1089 if (_.slideCount > _.options.slidesToShow) { 1090 _.slideOffset = (_.slideWidth * _.options.slidesToShow) * -1; 1091 verticalOffset = (verticalHeight * _.options.slidesToShow) * -1; 1092 } 1093 if (_.slideCount % _.options.slidesToScroll !== 0) { 1094 if (slideIndex + _.options.slidesToScroll > _.slideCount && _.slideCount > _.options.slidesToShow) { 1095 if (slideIndex > _.slideCount) { 1096 _.slideOffset = ((_.options.slidesToShow - (slideIndex - _.slideCount)) * _.slideWidth) * -1; 1097 verticalOffset = ((_.options.slidesToShow - (slideIndex - _.slideCount)) * verticalHeight) * -1; 1098 } else { 1099 _.slideOffset = ((_.slideCount % _.options.slidesToScroll) * _.slideWidth) * -1; 1100 verticalOffset = ((_.slideCount % _.options.slidesToScroll) * verticalHeight) * -1; 1101 } 1102 } 1103 } 1104 } else { 1105 if (slideIndex + _.options.slidesToShow > _.slideCount) { 1106 _.slideOffset = ((slideIndex + _.options.slidesToShow) - _.slideCount) * _.slideWidth; 1107 verticalOffset = ((slideIndex + _.options.slidesToShow) - _.slideCount) * verticalHeight; 1108 } 1109 } 1110 1111 if (_.slideCount <= _.options.slidesToShow) { 1112 _.slideOffset = 0; 1113 verticalOffset = 0; 1114 } 1115 1116 if (_.options.centerMode === true && _.slideCount <= _.options.slidesToShow) { 1117 _.slideOffset = ((_.slideWidth * Math.floor(_.options.slidesToShow)) / 2) - ((_.slideWidth * _.slideCount) / 2); 1118 } else if (_.options.centerMode === true && _.options.infinite === true) { 1119 _.slideOffset += _.slideWidth * Math.floor(_.options.slidesToShow / 2) - _.slideWidth; 1120 } else if (_.options.centerMode === true) { 1121 _.slideOffset = 0; 1122 _.slideOffset += _.slideWidth * Math.floor(_.options.slidesToShow / 2); 1123 } 1124 1125 if (_.options.vertical === false) { 1126 targetLeft = ((slideIndex * _.slideWidth) * -1) + _.slideOffset; 1127 } else { 1128 targetLeft = ((slideIndex * verticalHeight) * -1) + verticalOffset; 1129 } 1130 1131 if (_.options.variableWidth === true) { 1132
1133 if (_.slideCount <= _.options.slidesToShow || _.options.infinite === false) { 1134 targetSlide = _.$slideTrack.children('.a4j-slick-slide').eq(slideIndex); 1135 } else { 1136 targetSlide = _.$slideTrack.children('.a4j-slick-slide').eq(slideIndex + _.options.slidesToShow); 1137 } 1138 1139 if (_.options.rtl === true) { 1140 if (targetSlide[0]) { 1141 targetLeft = (_.$slideTrack.width() - targetSlide[0].offsetLeft - targetSlide.width()) * -1; 1142 } else { 1143 targetLeft = 0; 1144 } 1145 } else { 1146 targetLeft = targetSlide[0] ? targetSlide[0].offsetLeft * -1 : 0; 1147 } 1148 1149 if (_.options.centerMode === true) { 1150 if (_.slideCount <= _.options.slidesToShow || _.options.infinite === false) { 1151 targetSlide = _.$slideTrack.children('.a4j-slick-slide').eq(slideIndex); 1152 } else { 1153 targetSlide = _.$slideTrack.children('.a4j-slick-slide').eq(slideIndex + _.options.slidesToShow + 1); 1154 } 1155 1156 if (_.options.rtl === true) { 1157 if (targetSlide[0]) { 1158 targetLeft = (_.$slideTrack.width() - targetSlide[0].offsetLeft - targetSlide.width()) * -1; 1159 } else { 1160 targetLeft = 0; 1161 } 1162 } else { 1163 targetLeft = targetSlide[0] ? targetSlide[0].offsetLeft * -1 : 0; 1164 } 1165 1166 targetLeft += (_.$list.width() - targetSlide.outerWidth()) / 2; 1167 } 1168 } 1169 1170 return targetLeft; 1171 1172 }; 1173 1174 Slick.prototype.getOption = Slick.prototype.slickGetOption = function(option) { 1175 1176 var _ = this; 1177 1178 return _.options[option]; 1179 1180 }; 1181 1182 Slick.prototype.getNavigableIndexes = function() { 1183 1184 var _ = this, 1185 breakPoint = 0, 1186 counter = 0, 1187 indexes = [], 1188 max; 1189 1190 if (_.options.infinite === false) { 1191 max = _.slideCount; 1192 } else { 1193 breakPoint = _.options.slidesToScroll * -1; 1194 counter = _.options.slidesToScroll * -1; 1195 max = _.slideCount * 2; 1196 } 1197 1198 while (breakPoint < max) { 1199 indexes.push(breakPoint); 1200 breakPoint = counter + _.options.slidesToScroll; 1201 counter += _.options.slidesToScroll <= _.options.slidesToShow ? _.options.slidesToScroll : _.options.slidesToShow; 1202 } 1203 1204 return indexes; 1205 1206 }; 1207 1208 Slick.prototype.getSlick = function() { 1209 1210 return this; 1211 1212 }; 1213 1214 Slick.prototype.getSlideCount = function() { 1215 1216 var _ = this, 1217 slidesTraversed, swipedSlide, centerOffset; 1218 1219 centerOffset = _.options.centerMode === true ? _.slideWidth * Math.floor(_.options.slidesToShow / 2) : 0; 1220 1221 if (_.options.swipeToSlide === true) { 1222 _.$slideTrack.find('.a4j-slick-slide').each(function(index, slide) { 1223 if (slide.offsetLeft - centerOffset + ($(slide).outerWidth() / 2) > (_.swipeLeft * -1)) { 1224 swipedSlide = slide; 1225 return false; 1226 } 1227 }); 1228 1229 slidesTraversed = Math.abs($(swipedSlide).attr('data-slick-index') - _.currentSlide) || 1; 1230 1231 return slidesTraversed; 1232 1233 } else { 1234 return _.options.slidesToScroll; 1235 } 1236 1237 }; 1238 1239 Slick.prototype.goTo = Slick.prototype.slickGoTo = function(slide, dontAnimate) { 1240 1241 var _ = this; 1242 1243 _.changeSlide({ 1244 data: { 1245 message: 'index', 1246 index: parseInt(slide) 1247 } 1248 }, dontAnimate); 1249 1250 }; 1251 1252 Slick.prototype.init = function(creation) { 1253 1254 var _ = this; 1255 if (!_.$slider.hasClass('a4j-slick-initialized')) { 1256 1257 _.$slider.addClass('a4j-slick-initialized'); 1258 1259 _.buildRows(); 1260 _.buildOut(); 1261 _.setProps(); 1262 _.startLoad(); 1263 _.loadSlider(); 1264 _.initializeEvents(); 1265 _.updateArrows(); 1266 _.updateDots(); 1267 _.checkResponsive(true); 1268 _.focusHandler(); 1269 1270 } 1271 1272 if (creation) { 1273 _.$slider.trigger('init', [_]); 1274 } 1275 1276 if (_.options.accessibility === true) { 1277 _.initADA(); 1278 } 1279 1280 if ( _.options.autoplay ) { 1281 1282 _.paused = false; 1283 _.autoPlay(); 1284 1285 } 1286 1287 }; 1288 1289 Slick.prototype.initADA = function() { 1290 var _ = this; 1291 _.$slides.add(_.$slideTrack.find('.a4j-slick-cloned')).attr({ 1292 'aria-hidden': 'true', 1293 'tabindex': '-1' 1294 }).find('a, input, button, select').attr({ 1295 'tabindex': '-1' 1296 }); 1297 1298 _.$slideTrack.attr('role', 'listbox'); 1299 1300 _.$slides.not(_.$slideTrack.find('.a4j-slick-cloned')).each(function(i) { 1301 $(this).attr('role', 'option'); 1302 1303 //Evenly distribute aria-describedby tags through available dots. 1304 var describedBySlideId = _.options.centerMode ? i : Math.floor(i / _.options.slidesToShow); 1305 1306 if (_.options.dots === true) { 1307 $(this).attr('aria-describedby', 'slick-slide' + _.instanceUid + describedBySlideId + ''); 1308 } 1309 }); 1310 1311 if (_.$dots !== null) { 1312 _.$dots.attr('role', 'tablist').find('i').each(function(i) { 1313 $(this).attr({ 1314 'role': 'presentation', 1315 'aria-selected': 'false', 1316 'aria-controls': 'navigation' + _.instanceUid + i + '', 1317 'id': 'slick-slide' + _.instanceUid + i + '' 1318 }); 1319 }) 1320 .first().attr('aria-selected', 'true').end() 1321 .find('button').attr('role', 'button').end() 1322 .closest('div').attr('role', 'toolbar'); 1323 } 1324 _.activateADA(); 1325 1326 }; 1327 1328 Slick.prototype.initArrowEvents = function() { 1329 1330 var _ = this; 1331 1332 if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) { 1333 _.$prevArrow 1334 .off('click.slick') 1335 .on('click.slick', { 1336 message: 'previous' 1337 }, _.changeSlide); 1338 _.$nextArrow 1339 .off('click.slick') 1340 .on('click.slick', { 1341 message: 'next' 1342 }, _.changeSlide); 1343 } 1344 1345 }; 1346 1347 Slick.prototype.initDotEvents = function() { 1348 1349 var _ = this; 1350 1351 if (_.options.dots === true && _.slideCount > _.options.slidesToShow) { 1352 $('i', _.$dots).on('click.slick', { 1353 message: 'index' 1354 }, _.changeSlide); 1355 } 1356 1357 if ( _.options.dots === true && _.options.pauseOnDotsHover === true ) { 1358 1359 $('i', _.$dots) 1360 .on('mouseenter.slick', $.proxy(_.interrupt, _, true))
vendor: 22,267 bytes, lines 1361-2151
1361 .on('mouseleave.slick', $.proxy(_.interrupt, _, false)); 1362 1363 } 1364 1365 }; 1366 1367 Slick.prototype.initSlideEvents = function() { 1368 1369 var _ = this; 1370 1371 if ( _.options.pauseOnHover ) { 1372 1373 _.$list.on('mouseenter.slick', $.proxy(_.interrupt, _, true)); 1374 _.$list.on('mouseleave.slick', $.proxy(_.interrupt, _, false)); 1375 1376 } 1377 1378 }; 1379 1380 Slick.prototype.initializeEvents = function() { 1381 1382 var _ = this; 1383 1384 _.initArrowEvents(); 1385 1386 _.initDotEvents(); 1387 _.initSlideEvents(); 1388 1389 _.$list.on('touchstart.slick mousedown.slick', { 1390 action: 'start' 1391 }, _.swipeHandler); 1392 _.$list.on('touchmove.slick mousemove.slick', { 1393 action: 'move' 1394 }, _.swipeHandler); 1395 _.$list.on('touchend.slick mouseup.slick', { 1396 action: 'end' 1397 }, _.swipeHandler); 1398 _.$list.on('touchcancel.slick mouseleave.slick', { 1399 action: 'end' 1400 }, _.swipeHandler); 1401 1402 _.$list.on('click.slick', _.clickHandler); 1403 1404 $(document).on(_.visibilityChange, $.proxy(_.visibility, _)); 1405 1406 if (_.options.accessibility === true) { 1407 _.$list.on('keydown.slick', _.keyHandler); 1408 } 1409 1410 if (_.options.focusOnSelect === true) { 1411 $(_.$slideTrack).children().on('click.slick', _.selectHandler); 1412 } 1413 1414 $(window).on('orientationchange.slick.slick-' + _.instanceUid, $.proxy(_.orientationChange, _)); 1415 1416 $(window).on('resize.slick.slick-' + _.instanceUid, $.proxy(_.resize, _)); 1417 1418 $('[draggable!=true]', _.$slideTrack).on('dragstart', _.preventDefault); 1419 1420 $(window).on('load.slick.slick-' + _.instanceUid, _.setPosition); 1421 $(document).on('ready.slick.slick-' + _.instanceUid, _.setPosition); 1422 1423 }; 1424 1425 Slick.prototype.initUI = function() { 1426 1427 var _ = this; 1428 1429 if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) { 1430 1431 _.$prevArrow.show(); 1432 _.$nextArrow.show(); 1433 1434 } 1435 1436 if (_.options.dots === true && _.slideCount > _.options.slidesToShow) { 1437 1438 _.$dots.show(); 1439 1440 } 1441 1442 }; 1443 1444 Slick.prototype.keyHandler = function(event) { 1445 1446 var _ = this; 1447 //Dont slide if the cursor is inside the form fields and arrow keys are pressed 1448 if(!event.target.tagName.match('TEXTAREA|INPUT|SELECT')) { 1449 if (event.keyCode === 37 && _.options.accessibility === true) { 1450 _.changeSlide({ 1451 data: { 1452 message: _.options.rtl === true ? 'next' : 'previous' 1453 } 1454 }); 1455 } else if (event.keyCode === 39 && _.options.accessibility === true) { 1456 _.changeSlide({ 1457 data: { 1458 message: _.options.rtl === true ? 'previous' : 'next' 1459 } 1460 }); 1461 } 1462 } 1463 1464 }; 1465 1466 Slick.prototype.lazyLoad = function() { 1467 1468 var _ = this, 1469 loadRange, cloneRange, rangeStart, rangeEnd; 1470 1471 function loadImages(imagesScope) { 1472 1473 $('img[data-lazy]', imagesScope).each(function() { 1474 1475 var image = $(this), 1476 imageSource = $(this).attr('data-lazy'), 1477 imageToLoad = document.createElement('img'); 1478 1479 imageToLoad.onload = function() { 1480 1481 image 1482 .animate({ opacity: 0 }, 100, function() { 1483 image 1484 .attr('src', imageSource) 1485 .animate({ opacity: 1 }, 200, function() { 1486 image 1487 .removeAttr('data-lazy') 1488 .removeClass('a4j-slick-loading'); 1489 }); 1490 _.$slider.trigger('lazyLoaded', [_, image, imageSource]); 1491 }); 1492 1493 }; 1494 1495 imageToLoad.onerror = function() { 1496 1497 image 1498 .removeAttr( 'data-lazy' ) 1499 .removeClass( 'a4j-slick-loading' ) 1500 .addClass( 'a4j-slick-lazyload-error' ); 1501 1502 _.$slider.trigger('lazyLoadError', [ _, image, imageSource ]); 1503 1504 }; 1505 1506 imageToLoad.src = imageSource; 1507 1508 }); 1509 1510 } 1511 1512 if (_.options.centerMode === true) { 1513 if (_.options.infinite === true) { 1514 rangeStart = _.currentSlide + (_.options.slidesToShow / 2 + 1); 1515 rangeEnd = rangeStart + _.options.slidesToShow + 2; 1516 } else { 1517 rangeStart = Math.max(0, _.currentSlide - (_.options.slidesToShow / 2 + 1)); 1518 rangeEnd = 2 + (_.options.slidesToShow / 2 + 1) + _.currentSlide; 1519 } 1520 } else { 1521 rangeStart = _.options.infinite ? _.options.slidesToShow + _.currentSlide : _.currentSlide; 1522 rangeEnd = Math.ceil(rangeStart + _.options.slidesToShow); 1523 if (_.options.fade === true) { 1524 if (rangeStart > 0) rangeStart--; 1525 if (rangeEnd <= _.slideCount) rangeEnd++; 1526 } 1527 } 1528 1529 loadRange = _.$slider.find('.a4j-slick-slide').slice(rangeStart, rangeEnd); 1530 loadImages(loadRange); 1531 1532 if (_.slideCount <= _.options.slidesToShow) { 1533 cloneRange = _.$slider.find('.a4j-slick-slide'); 1534 loadImages(cloneRange); 1535 } else 1536 if (_.currentSlide >= _.slideCount - _.options.slidesToShow) { 1537 cloneRange = _.$slider.find('.a4j-slick-cloned').slice(0, _.options.slidesToShow); 1538 loadImages(cloneRange); 1539 } else if (_.currentSlide === 0) { 1540 cloneRange = _.$slider.find('.a4j-slick-cloned').slice(_.options.slidesToShow * -1); 1541 loadImages(cloneRange); 1542 } 1543 1544 }; 1545 1546 Slick.prototype.loadSlider = function() { 1547 1548 var _ = this; 1549 1550 _.setPosition(); 1551 1552 _.$slideTrack.css({ 1553 opacity: 1 1554 }); 1555 1556 _.$slider.removeClass('a4j-slick-loading'); 1557 1558 _.initUI(); 1559 1560 if (_.options.lazyLoad === 'progressive') { 1561 _.progressiveLazyLoad(); 1562 } 1563 1564 }; 1565 1566 Slick.prototype.next = Slick.prototype.slickNext = function() { 1567 1568 var _ = this; 1569 1570 _.changeSlide({ 1571 data: { 1572 message: 'next' 1573 } 1574 }); 1575 1576 }; 1577 1578 Slick.prototype.orientationChange = function() { 1579 1580 var _ = this; 1581 1582 _.checkResponsive(); 1583 _.setPosition(); 1584 1585 }; 1586 1587 Slick.prototype.pause = Slick.prototype.slickPause = function() { 1588 1589 var _ = this; 1590 1591 _.autoPlayClear(); 1592 _.paused = true; 1593 1594 }; 1595 1596 Slick.prototype.play = Slick.prototype.slickPlay = function() { 1597 1598 var _ = this; 1599 1600 _.autoPlay(); 1601 _.options.autoplay = true; 1602 _.paused = false; 1603 _.focussed = false; 1604 _.interrupted = false; 1605 1606 }; 1607 1608 Slick.prototype.postSlide = function(index) { 1609 1610 var _ = this; 1611 1612 if( !_.unslicked ) { 1613 1614 _.$slider.trigger('afterChange', [_, index]); 1615 1616 _.animating = false; 1617 1618 _.setPosition(); 1619 1620 _.swipeLeft = null; 1621 1622 if ( _.options.autoplay ) { 1623 _.autoPlay(); 1624 } 1625 1626 if (_.options.accessibility === true) { 1627 _.initADA(); 1628 } 1629 1630 } 1631 1632 }; 1633 1634 Slick.prototype.prev = Slick.prototype.slickPrev = function() { 1635 1636 var _ = this; 1637 1638 _.changeSlide({ 1639 data: { 1640 message: 'previous' 1641 } 1642 }); 1643 1644 }; 1645 1646 Slick.prototype.preventDefault = function(event) { 1647 1648 event.preventDefault(); 1649 1650 }; 1651 1652 Slick.prototype.progressiveLazyLoad = function( tryCount ) { 1653 1654 tryCount = tryCount || 1; 1655 1656 var _ = this, 1657 $imgsToLoad = $( 'img[data-lazy]', _.$slider ), 1658 image, 1659 imageSource, 1660 imageToLoad; 1661 1662 if ( $imgsToLoad.length ) { 1663 1664 image = $imgsToLoad.first(); 1665 imageSource = image.attr('data-lazy'); 1666 imageToLoad = document.createElement('img'); 1667 1668 imageToLoad.onload = function() { 1669 1670 image 1671 .attr( 'src', imageSource ) 1672 .removeAttr('data-lazy') 1673 .removeClass('a4j-slick-loading'); 1674 1675 if ( _.options.adaptiveHeight === true ) { 1676 _.setPosition(); 1677 } 1678 1679 _.$slider.trigger('lazyLoaded', [ _, image, imageSource ]); 1680 _.progressiveLazyLoad(); 1681 1682 }; 1683 1684 imageToLoad.onerror = function() { 1685 1686 if ( tryCount < 3 ) { 1687 1688 /** 1689 * try to load the image 3 times, 1690 * leave a slight delay so we don't get 1691 * servers blocking the request. 1692 */ 1693 setTimeout( function() { 1694 _.progressiveLazyLoad( tryCount + 1 ); 1695 }, 500 ); 1696 1697 } else { 1698 1699 image 1700 .removeAttr( 'data-lazy' ) 1701 .removeClass( 'a4j-slick-loading' ) 1702 .addClass( 'a4j-slick-lazyload-error' ); 1703 1704 _.$slider.trigger('lazyLoadError', [ _, image, imageSource ]); 1705 1706 _.progressiveLazyLoad(); 1707 1708 } 1709 1710 }; 1711 1712 imageToLoad.src = imageSource; 1713 1714 } else { 1715 1716 _.$slider.trigger('allImagesLoaded', [ _ ]); 1717 1718 } 1719 1720 }; 1721 1722 Slick.prototype.refresh = function( initializing ) { 1723 1724 var _ = this, currentSlide, lastVisibleIndex; 1725 1726 lastVisibleIndex = _.slideCount - _.options.slidesToShow; 1727 1728 // in non-infinite sliders, we don't want to go past the 1729 // last visible index. 1730 if( !_.options.infinite && ( _.currentSlide > lastVisibleIndex )) { 1731 _.currentSlide = lastVisibleIndex; 1732 } 1733 1734 // if less slides than to show, go to start. 1735 if ( _.slideCount <= _.options.slidesToShow ) { 1736 _.currentSlide = 0; 1737 1738 } 1739 1740 currentSlide = _.currentSlide; 1741 1742 _.destroy(true); 1743 1744 $.extend(_, _.initials, { currentSlide: currentSlide }); 1745 1746 _.init(); 1747 1748 if( !initializing ) { 1749 1750 _.changeSlide({ 1751 data: { 1752 message: 'index', 1753 index: currentSlide 1754 } 1755 }, false); 1756 1757 } 1758 1759 }; 1760 1761 Slick.prototype.registerBreakpoints = function() { 1762 1763 var _ = this, breakpoint, currentBreakpoint, l, 1764 responsiveSettings = _.options.responsive || null; 1765 1766 if ( $.type(responsiveSettings) === 'array' && responsiveSettings.length ) { 1767 1768 _.respondTo = _.options.respondTo || 'window'; 1769 1770 for ( breakpoint in responsiveSettings ) { 1771 1772 l = _.breakpoints.length-1; 1773 currentBreakpoint = responsiveSettings[breakpoint].breakpoint; 1774 1775 if (responsiveSettings.hasOwnProperty(breakpoint)) { 1776 1777 // loop through the breakpoints and cut out any existing 1778 // ones with the same breakpoint number, we don't want dupes. 1779 while( l >= 0 ) { 1780 if( _.breakpoints[l] && _.breakpoints[l] === currentBreakpoint ) { 1781 _.breakpoints.splice(l,1); 1782 } 1783 l--; 1784 } 1785 1786 _.breakpoints.push(currentBreakpoint); 1787 _.breakpointSettings[currentBreakpoint] = responsiveSettings[breakpoint].settings; 1788 1789 } 1790 1791 } 1792 1793 _.breakpoints.sort(function(a, b) { 1794 return ( _.options.mobileFirst ) ? a-b : b-a; 1795 }); 1796 1797 } 1798 1799 }; 1800 1801 Slick.prototype.reinit = function() { 1802 1803 var _ = this; 1804 1805 _.$slides = 1806 _.$slideTrack 1807 .children(_.options.slide) 1808 .addClass('a4j-slick-slide'); 1809 1810 _.slideCount = _.$slides.length; 1811 1812 if (_.currentSlide >= _.slideCount && _.currentSlide !== 0) { 1813 _.currentSlide = _.currentSlide - _.options.slidesToScroll; 1814 } 1815 1816 if (_.slideCount <= _.options.slidesToShow) { 1817 _.currentSlide = 0; 1818 } 1819 1820 _.registerBreakpoints(); 1821 1822 _.setProps(); 1823 _.setupInfinite(); 1824 _.buildArrows(); 1825 _.updateArrows(); 1826 _.initArrowEvents(); 1827 _.buildDots(); 1828 _.updateDots(); 1829 _.initDotEvents(); 1830 _.cleanUpSlideEvents(); 1831 _.initSlideEvents(); 1832 1833 _.checkResponsive(false, true); 1834 1835 if (_.options.focusOnSelect === true) { 1836 $(_.$slideTrack).children().on('click.slick', _.selectHandler); 1837 } 1838 1839 _.setSlideClasses(typeof _.currentSlide === 'number' ? _.currentSlide : 0); 1840 1841 _.setPosition(); 1842 _.focusHandler(); 1843 1844 _.paused = !_.options.autoplay; 1845 _.autoPlay(); 1846 1847 _.$slider.trigger('reInit', [_]); 1848 1849 }; 1850 1851 Slick.prototype.resize = function() { 1852 1853 var _ = this; 1854 1855 if ($(window).width() !== _.windowWidth) { 1856 clearTimeout(_.windowDelay); 1857 _.windowDelay = window.setTimeout(function() { 1858 _.windowWidth = $(window).width(); 1859 _.checkResponsive(); 1860 if( !_.unslicked ) { _.setPosition(); } 1861 }, 50); 1862 } 1863 }; 1864 1865 Slick.prototype.removeSlide = Slick.prototype.slickRemove = function(index, removeBefore, removeAll) { 1866 1867 var _ = this; 1868 1869 if (typeof(index) === 'boolean') { 1870 removeBefore = index; 1871 index = removeBefore === true ? 0 : _.slideCount - 1; 1872 } else { 1873 index = removeBefore === true ? --index : index; 1874 } 1875 1876 if (_.slideCount < 1 || index < 0 || index > _.slideCount - 1) { 1877 return false; 1878 } 1879 1880 _.unload(); 1881 1882 if (removeAll === true) { 1883 _.$slideTrack.children().remove(); 1884 } else { 1885 _.$slideTrack.children(this.options.slide).eq(index).remove(); 1886 } 1887 1888 _.$slides = _.$slideTrack.children(this.options.slide); 1889 1890 _.$slideTrack.children(this.options.slide).detach(); 1891 1892 _.$slideTrack.append(_.$slides); 1893 1894 _.$slidesCache = _.$slides; 1895 1896 _.reinit(); 1897 1898 }; 1899 1900 Slick.prototype.setCSS = function(position) { 1901 1902 var _ = this, 1903 positionProps = {}, 1904 x, y; 1905 1906 if (_.options.rtl === true) { 1907 position = -position; 1908 } 1909 x = _.positionProp == 'left' ? Math.ceil(position) + 'px' : '0px'; 1910 y = _.positionProp == 'top' ? Math.ceil(position) + 'px' : '0px'; 1911 1912 positionProps[_.positionProp] = position; 1913 1914 if (_.transformsEnabled === false) { 1915 _.$slideTrack.css(positionProps); 1916 } else { 1917 positionProps = {}; 1918 if (_.cssTransitions === false) { 1919 positionProps[_.animType] = 'translate(' + x + ', ' + y + ')'; 1920 _.$slideTrack.css(positionProps); 1921 } else { 1922 positionProps[_.animType] = 'translate3d(' + x + ', ' + y + ', 0px)'; 1923 _.$slideTrack.css(positionProps); 1924 } 1925 } 1926 1927 }; 1928 1929 Slick.prototype.setDimensions = function() { 1930 1931 var _ = this; 1932 1933 if (_.options.vertical === false) { 1934 if (_.options.centerMode === true) { 1935 _.$list.css({ 1936 padding: ('0px ' + _.options.centerPadding) 1937 }); 1938 } 1939 } else { 1940 _.$list.height(_.$slides.first().outerHeight(true) * _.options.slidesToShow); 1941 if (_.options.centerMode === true) { 1942 _.$list.css({ 1943 padding: (_.options.centerPadding + ' 0px') 1944 }); 1945 } 1946 } 1947 1948 _.listWidth = _.$list.width(); 1949 _.listHeight = _.$list.height(); 1950 1951 1952 if (_.options.vertical === false && _.options.variableWidth === false) { 1953 _.slideWidth = Math.ceil(_.listWidth / _.options.slidesToShow); 1954 _.$slideTrack.width(Math.ceil((_.slideWidth * _.$slideTrack.children('.a4j-slick-slide').length))); 1955 1956 } else if (_.options.variableWidth === true) { 1957 _.$slideTrack.width(5000 * _.slideCount); 1958 } else { 1959 _.slideWidth = Math.ceil(_.listWidth); 1960 _.$slideTrack.height(Math.ceil((_.$slides.first().outerHeight(true) * _.$slideTrack.children('.a4j-slick-slide').length))); 1961 } 1962 1963 var offset = _.$slides.first().outerWidth(true) - _.$slides.first().width(); 1964 if (_.options.variableWidth === false) _.$slideTrack.children('.a4j-slick-slide').width(_.slideWidth - offset); 1965 1966 }; 1967 1968 Slick.prototype.setFade = function() { 1969 1970 var _ = this, 1971 targetLeft; 1972 1973 _.$slides.each(function(index, element) { 1974 targetLeft = (_.slideWidth * index) * -1; 1975 if (_.options.rtl === true) { 1976 $(element).css({ 1977 position: 'relative', 1978 right: targetLeft, 1979 top: 0, 1980 zIndex: _.options.zIndex - 2, 1981 opacity: 0 1982 }); 1983 } else { 1984 $(element).css({ 1985 position: 'relative', 1986 left: targetLeft, 1987 top: 0, 1988 zIndex: _.options.zIndex - 2, 1989 opacity: 0 1990 }); 1991 } 1992 }); 1993 1994 _.$slides.eq(_.currentSlide).css({ 1995 zIndex: _.options.zIndex - 1, 1996 opacity: 1 1997 }); 1998 1999 }; 2000 2001 Slick.prototype.setHeight = function() { 2002 2003 var _ = this; 2004 2005 if (_.options.slidesToShow === 1 && _.options.adaptiveHeight === true && _.options.vertical === false) { 2006 var targetHeight = _.$slides.eq(_.currentSlide).outerHeight(true); 2007 _.$list.css('height', targetHeight); 2008 } 2009 2010 }; 2011 2012 Slick.prototype.setOption = 2013 Slick.prototype.slickSetOption = function() { 2014 2015 /** 2016 * accepts arguments in format of: 2017 * 2018 * - for changing a single option's value: 2019 * .a4jslick("setOption", option, value, refresh ) 2020 * 2021 * - for changing a set of responsive options: 2022 * .a4jslick("setOption", 'responsive', [{}, ...], refresh ) 2023 * 2024 * - for updating multiple values at once (not responsive) 2025 * .a4jslick("setOption", { 'option': value, ... }, refresh ) 2026 */ 2027 2028 var _ = this, l, item, option, value, refresh = false, type; 2029 2030 if( $.type( arguments[0] ) === 'object' ) { 2031 2032 option = arguments[0]; 2033 refresh = arguments[1]; 2034 type = 'multiple'; 2035 2036 } else if ( $.type( arguments[0] ) === 'string' ) { 2037 2038 option = arguments[0]; 2039 value = arguments[1]; 2040 refresh = arguments[2]; 2041 2042 if ( arguments[0] === 'responsive' && $.type( arguments[1] ) === 'array' ) { 2043 2044 type = 'responsive'; 2045 2046 } else if ( typeof arguments[1] !== 'undefined' ) { 2047 2048 type = 'single'; 2049 2050 } 2051 2052 } 2053 2054 if ( type === 'single' ) { 2055 2056 _.options[option] = value; 2057 2058 2059 } else if ( type === 'multiple' ) { 2060 2061 $.each( option , function( opt, val ) { 2062 2063 _.options[opt] = val; 2064 2065 }); 2066 2067 2068 } else if ( type === 'responsive' ) { 2069 2070 for ( item in value ) { 2071 2072 if( $.type( _.options.responsive ) !== 'array' ) { 2073 2074 _.options.responsive = [ value[item] ]; 2075 2076 } else { 2077 2078 l = _.options.responsive.length-1; 2079 2080 // loop through the responsive object and splice out duplicates. 2081 while( l >= 0 ) { 2082 2083 if( _.options.responsive[l].breakpoint === value[item].breakpoint ) { 2084 2085 _.options.responsive.splice(l,1); 2086 2087 } 2088 2089 l--; 2090 2091 } 2092 2093 _.options.responsive.push( value[item] ); 2094 2095 } 2096 2097 } 2098 2099 } 2100 2101 if ( refresh ) { 2102 2103 _.unload(); 2104 _.reinit(); 2105 2106 } 2107 2108 }; 2109 2110 Slick.prototype.setPosition = function() { 2111 2112 var _ = this; 2113 2114 _.setDimensions(); 2115 2116 _.setHeight(); 2117 2118 if (_.options.fade === false) { 2119 _.setCSS(_.getLeft(_.currentSlide)); 2120 } else { 2121 _.setFade(); 2122 } 2123 2124 _.$slider.trigger('setPosition', [_]); 2125 2126 }; 2127 2128 Slick.prototype.setProps = function() { 2129 2130 var _ = this, 2131 bodyStyle = document.body.style; 2132 2133 _.positionProp = _.options.vertical === true ? 'top' : 'left'; 2134 2135 if (_.positionProp === 'top') { 2136 _.$slider.addClass('a4j-slick-vertical'); 2137 } else { 2138 _.$slider.removeClass('a4j-slick-vertical'); 2139 } 2140 2141 if (bodyStyle.WebkitTransition !== undefined || 2142 bodyStyle.MozTransition !== undefined || 2143 bodyStyle.msTransition !== undefined) { 2144 if (_.options.useCSS === true) { 2145 _.cssTransitions = true; 2146 } 2147 } 2148 2149 if ( _.options.fade ) { 2150 if ( typeof _.options.zIndex === 'number' ) { 2151 if( _.options.zIndex < 3 ) {
2152 _.options.zIndex = 3; 2153 } 2154 } else { 2155 _.options.zIndex = _.defaults.zIndex; 2156 } 2157 } 2158 2159 if (bodyStyle.OTransform !== undefined) { 2160 _.animType = 'OTransform'; 2161 _.transformType = '-o-transform'; 2162 _.transitionType = 'OTransition'; 2163 if (bodyStyle.perspectiveProperty === undefined && bodyStyle.webkitPerspective === undefined) _.animType = false; 2164 } 2165 if (bodyStyle.MozTransform !== undefined) { 2166 _.animType = 'MozTransform'; 2167 _.transformType = '-moz-transform'; 2168 _.transitionType = 'MozTransition'; 2169 if (bodyStyle.perspectiveProperty === undefined && bodyStyle.MozPerspective === undefined) _.animType = false; 2170 } 2171 if (bodyStyle.webkitTransform !== undefined) { 2172 _.animType = 'webkitTransform'; 2173 _.transformType = '-webkit-transform'; 2174 _.transitionType = 'webkitTransition'; 2175 if (bodyStyle.perspectiveProperty === undefined && bodyStyle.webkitPerspective === undefined) _.animType = false; 2176 } 2177 if (bodyStyle.msTransform !== undefined) { 2178 _.animType = 'msTransform'; 2179 _.transformType = '-ms-transform'; 2180 _.transitionType = 'msTransition'; 2181 if (bodyStyle.msTransform === undefined) _.animType = false; 2182 } 2183 if (bodyStyle.transform !== undefined && _.animType !== false) { 2184 _.animType = 'transform'; 2185 _.transformType = 'transform'; 2186 _.transitionType = 'transition'; 2187 } 2188 _.transformsEnabled = _.options.useTransform && (_.animType !== null && _.animType !== false); 2189 }; 2190 2191 2192 Slick.prototype.setSlideClasses = function(index) { 2193 2194 var _ = this, 2195 centerOffset, allSlides, indexOffset, remainder; 2196 2197 allSlides = _.$slider 2198 .find('.a4j-slick-slide') 2199 .removeClass('a4j-slick-active a4j-slick-center a4j-slick-current') 2200 .attr('aria-hidden', 'true'); 2201 2202 _.$slides 2203 .eq(index) 2204 .addClass('a4j-slick-current'); 2205 2206 if (_.options.centerMode === true) { 2207 2208 centerOffset = Math.floor(_.options.slidesToShow / 2); 2209 2210 if (_.options.infinite === true) { 2211 2212 if (index >= centerOffset && index <= (_.slideCount - 1) - centerOffset) { 2213 2214 _.$slides 2215 .slice(index - centerOffset, index + centerOffset + 1) 2216 .addClass('a4j-slick-active') 2217 .attr('aria-hidden', 'false'); 2218 2219 } else { 2220 2221 indexOffset = _.options.slidesToShow + index; 2222 allSlides 2223 .slice(indexOffset - centerOffset + 1, indexOffset + centerOffset + 2) 2224 .addClass('a4j-slick-active') 2225 .attr('aria-hidden', 'false'); 2226 2227 } 2228 2229 if (index === 0) { 2230 2231 allSlides 2232 .eq(allSlides.length - 1 - _.options.slidesToShow) 2233 .addClass('a4j-slick-center'); 2234 2235 } else if (index === _.slideCount - 1) { 2236 2237 allSlides 2238 .eq(_.options.slidesToShow) 2239 .addClass('a4j-slick-center'); 2240 2241 } 2242 2243 } 2244 2245 _.$slides 2246 .eq(index) 2247 .addClass('a4j-slick-center'); 2248 2249 } else { 2250 2251 if (index >= 0 && index <= (_.slideCount - _.options.slidesToShow)) { 2252 2253 _.$slides 2254 .slice(index, index + _.options.slidesToShow) 2255 .addClass('a4j-slick-active') 2256 .attr('aria-hidden', 'false'); 2257 2258 } else if (allSlides.length <= _.options.slidesToShow) { 2259 2260 allSlides 2261 .addClass('a4j-slick-active') 2262 .attr('aria-hidden', 'false'); 2263 2264 } else { 2265 2266 remainder = _.slideCount % _.options.slidesToShow;
vendor: 15,835 bytes, lines 2267-2807
2267 indexOffset = _.options.infinite === true ? _.options.slidesToShow + index : index; 2268 2269 if (_.options.slidesToShow == _.options.slidesToScroll && (_.slideCount - index) < _.options.slidesToShow) { 2270 2271 allSlides 2272 .slice(indexOffset - (_.options.slidesToShow - remainder), indexOffset + remainder) 2273 .addClass('a4j-slick-active') 2274 .attr('aria-hidden', 'false'); 2275 2276 } else { 2277 2278 allSlides 2279 .slice(indexOffset, indexOffset + _.options.slidesToShow) 2280 .addClass('a4j-slick-active') 2281 .attr('aria-hidden', 'false'); 2282 2283 } 2284 2285 } 2286 2287 } 2288 2289 if (_.options.lazyLoad === 'ondemand') { 2290 _.lazyLoad(); 2291 } 2292 2293 }; 2294 2295 Slick.prototype.setupInfinite = function() { 2296 2297 var _ = this, 2298 i, slideIndex, infiniteCount; 2299 2300 if (_.options.fade === true) { 2301 _.options.centerMode = false; 2302 } 2303 2304 if (_.options.infinite === true && _.options.fade === false) { 2305 2306 slideIndex = null; 2307 2308 if (_.slideCount > _.options.slidesToShow) { 2309 2310 if (_.options.centerMode === true) { 2311 infiniteCount = _.options.slidesToShow + 1; 2312 } else { 2313 infiniteCount = _.options.slidesToShow; 2314 } 2315 2316 for (i = _.slideCount; i > (_.slideCount - 2317 infiniteCount); i -= 1) { 2318 slideIndex = i - 1; 2319 $(_.$slides[slideIndex]).clone(true).attr('id', '') 2320 .attr('data-slick-index', slideIndex - _.slideCount) 2321 .prependTo(_.$slideTrack).addClass('a4j-slick-cloned'); 2322 } 2323 for (i = 0; i < infiniteCount; i += 1) { 2324 slideIndex = i; 2325 $(_.$slides[slideIndex]).clone(true).attr('id', '') 2326 .attr('data-slick-index', slideIndex + _.slideCount) 2327 .appendTo(_.$slideTrack).addClass('a4j-slick-cloned'); 2328 } 2329 _.$slideTrack.find('.a4j-slick-cloned').find('[id]').each(function() { 2330 $(this).attr('id', ''); 2331 }); 2332 2333 } 2334 2335 } 2336 2337 }; 2338 2339 Slick.prototype.interrupt = function( toggle ) { 2340 2341 var _ = this; 2342 2343 if( !toggle ) { 2344 _.autoPlay(); 2345 } 2346 _.interrupted = toggle; 2347 2348 }; 2349 2350 Slick.prototype.selectHandler = function(event) { 2351 2352 var _ = this; 2353 2354 var targetElement = 2355 $(event.target).is('.a4j-slick-slide') ? 2356 $(event.target) : 2357 $(event.target).parents('.a4j-slick-slide'); 2358 2359 var index = parseInt(targetElement.attr('data-slick-index')); 2360 2361 if (!index) index = 0; 2362 2363 if (_.slideCount <= _.options.slidesToShow) { 2364 2365 _.setSlideClasses(index); 2366 _.asNavFor(index); 2367 return; 2368 2369 } 2370 2371 _.slideHandler(index); 2372 2373 }; 2374 2375 Slick.prototype.slideHandler = function(index, sync, dontAnimate) { 2376 2377 var targetSlide, animSlide, oldSlide, slideLeft, targetLeft = null, 2378 _ = this, navTarget; 2379 2380 sync = sync || false; 2381 2382 if (_.animating === true && _.options.waitForAnimate === true) { 2383 return; 2384 } 2385 2386 if (_.options.fade === true && _.currentSlide === index) { 2387 return; 2388 } 2389 2390 if (_.slideCount <= _.options.slidesToShow) { 2391 return; 2392 } 2393 2394 if (sync === false) { 2395 _.asNavFor(index); 2396 } 2397 2398 targetSlide = index; 2399 targetLeft = _.getLeft(targetSlide); 2400 slideLeft = _.getLeft(_.currentSlide); 2401 2402 _.currentLeft = _.swipeLeft === null ? slideLeft : _.swipeLeft; 2403 2404 if (_.options.infinite === false && _.options.centerMode === false && (index < 0 || index > _.getDotCount() * _.options.slidesToScroll)) { 2405 if (_.options.fade === false) { 2406 targetSlide = _.currentSlide; 2407 if (dontAnimate !== true) { 2408 _.animateSlide(slideLeft, function() { 2409 _.postSlide(targetSlide); 2410 }); 2411 } else { 2412 _.postSlide(targetSlide); 2413 } 2414 } 2415 return; 2416 } else if (_.options.infinite === false && _.options.centerMode === true && (index < 0 || index > (_.slideCount - _.options.slidesToScroll))) { 2417 if (_.options.fade === false) { 2418 targetSlide = _.currentSlide; 2419 if (dontAnimate !== true) { 2420 _.animateSlide(slideLeft, function() { 2421 _.postSlide(targetSlide); 2422 }); 2423 } else { 2424 _.postSlide(targetSlide); 2425 } 2426 } 2427 return; 2428 } 2429 2430 if ( _.options.autoplay ) { 2431 clearInterval(_.autoPlayTimer); 2432 } 2433 2434 if (targetSlide < 0) { 2435 if (_.slideCount % _.options.slidesToScroll !== 0) { 2436 animSlide = _.slideCount - (_.slideCount % _.options.slidesToScroll); 2437 } else { 2438 animSlide = _.slideCount + targetSlide; 2439 } 2440 } else if (targetSlide >= _.slideCount) { 2441 if (_.slideCount % _.options.slidesToScroll !== 0) { 2442 animSlide = 0; 2443 } else { 2444 animSlide = targetSlide - _.slideCount; 2445 } 2446 } else { 2447 animSlide = targetSlide; 2448 } 2449 2450 _.animating = true; 2451 2452 _.$slider.closest('.ingallery').trigger('beforeCarouselChange', [_, _.currentSlide, animSlide]); 2453 _.$slider.trigger('beforeChange', [_, _.currentSlide, animSlide]); 2454 2455 oldSlide = _.currentSlide; 2456 _.currentSlide = animSlide; 2457 2458 _.setSlideClasses(_.currentSlide); 2459 2460 if ( _.options.asNavFor ) { 2461 2462 navTarget = _.getNavTarget(); 2463 navTarget = navTarget.a4jslick('getSlick'); 2464 2465 if ( navTarget.slideCount <= navTarget.options.slidesToShow ) { 2466 navTarget.setSlideClasses(_.currentSlide); 2467 } 2468 2469 } 2470 2471 _.updateDots(); 2472 _.updateArrows(); 2473 2474 if (_.options.fade === true) { 2475 if (dontAnimate !== true) { 2476 2477 _.fadeSlideOut(oldSlide); 2478 2479 _.fadeSlide(animSlide, function() { 2480 _.postSlide(animSlide); 2481 }); 2482 2483 } else { 2484 _.postSlide(animSlide); 2485 } 2486 _.animateHeight(); 2487 return; 2488 } 2489 2490 if (dontAnimate !== true) { 2491 _.animateSlide(targetLeft, function() { 2492 _.postSlide(animSlide); 2493 }); 2494 } else { 2495 _.postSlide(animSlide); 2496 } 2497 2498 }; 2499 2500 Slick.prototype.startLoad = function() { 2501 2502 var _ = this; 2503 2504 if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) { 2505 2506 _.$prevArrow.hide(); 2507 _.$nextArrow.hide(); 2508 2509 } 2510 2511 if (_.options.dots === true && _.slideCount > _.options.slidesToShow) { 2512 2513 _.$dots.hide(); 2514 2515 } 2516 2517 _.$slider.addClass('a4j-slick-loading'); 2518 2519 }; 2520 2521 Slick.prototype.swipeDirection = function() { 2522 2523 var xDist, yDist, r, swipeAngle, _ = this; 2524 2525 xDist = _.touchObject.startX - _.touchObject.curX; 2526 yDist = _.touchObject.startY - _.touchObject.curY; 2527 r = Math.atan2(yDist, xDist); 2528 2529 swipeAngle = Math.round(r * 180 / Math.PI); 2530 if (swipeAngle < 0) { 2531 swipeAngle = 360 - Math.abs(swipeAngle); 2532 } 2533 2534 if ((swipeAngle <= 45) && (swipeAngle >= 0)) { 2535 return (_.options.rtl === false ? 'left' : 'right'); 2536 } 2537 if ((swipeAngle <= 360) && (swipeAngle >= 315)) { 2538 return (_.options.rtl === false ? 'left' : 'right'); 2539 } 2540 if ((swipeAngle >= 135) && (swipeAngle <= 225)) { 2541 return (_.options.rtl === false ? 'right' : 'left'); 2542 } 2543 if (_.options.verticalSwiping === true) { 2544 if ((swipeAngle >= 35) && (swipeAngle <= 135)) { 2545 return 'down'; 2546 } else { 2547 return 'up'; 2548 } 2549 } 2550 2551 return 'vertical'; 2552 2553 }; 2554 2555 Slick.prototype.swipeEnd = function(event) { 2556 2557 var _ = this, 2558 slideCount, 2559 direction; 2560 2561 _.dragging = false; 2562 _.interrupted = false; 2563 _.shouldClick = ( _.touchObject.swipeLength > 10 ) ? false : true; 2564 2565 if ( _.touchObject.curX === undefined ) { 2566 return false; 2567 } 2568 2569 if ( _.touchObject.edgeHit === true ) { 2570 _.$slider.trigger('edge', [_, _.swipeDirection() ]); 2571 } 2572 2573 if ( _.touchObject.swipeLength >= _.touchObject.minSwipe ) { 2574 2575 direction = _.swipeDirection(); 2576 2577 switch ( direction ) { 2578 2579 case 'left': 2580 case 'down': 2581 2582 slideCount = 2583 _.options.swipeToSlide ? 2584 _.checkNavigable( _.currentSlide + _.getSlideCount() ) : 2585 _.currentSlide + _.getSlideCount(); 2586 2587 _.currentDirection = 0; 2588 2589 break; 2590 2591 case 'right': 2592 case 'up': 2593 2594 slideCount = 2595 _.options.swipeToSlide ? 2596 _.checkNavigable( _.currentSlide - _.getSlideCount() ) : 2597 _.currentSlide - _.getSlideCount(); 2598 2599 _.currentDirection = 1; 2600 2601 break; 2602 2603 default: 2604 2605 2606 } 2607 2608 if( direction != 'vertical' ) { 2609 2610 _.slideHandler( slideCount ); 2611 _.touchObject = {}; 2612 _.$slider.trigger('swipe', [_, direction ]); 2613 2614 } 2615 2616 } else { 2617 2618 if ( _.touchObject.startX !== _.touchObject.curX ) { 2619 2620 _.slideHandler( _.currentSlide ); 2621 _.touchObject = {}; 2622 2623 } 2624 2625 } 2626 2627 }; 2628 2629 Slick.prototype.swipeHandler = function(event) { 2630 2631 var _ = this; 2632 2633 if ((_.options.swipe === false) || ('ontouchend' in document && _.options.swipe === false)) { 2634 return; 2635 } else if (_.options.draggable === false && event.type.indexOf('mouse') !== -1) { 2636 return; 2637 } 2638 2639 _.touchObject.fingerCount = event.originalEvent && event.originalEvent.touches !== undefined ? 2640 event.originalEvent.touches.length : 1; 2641 2642 _.touchObject.minSwipe = _.listWidth / _.options 2643 .touchThreshold; 2644 2645 if (_.options.verticalSwiping === true) { 2646 _.touchObject.minSwipe = _.listHeight / _.options 2647 .touchThreshold; 2648 } 2649 2650 switch (event.data.action) { 2651 2652 case 'start': 2653 _.swipeStart(event); 2654 break; 2655 2656 case 'move': 2657 _.swipeMove(event); 2658 break; 2659 2660 case 'end': 2661 _.swipeEnd(event); 2662 break; 2663 2664 } 2665 2666 }; 2667 2668 Slick.prototype.swipeMove = function(event) { 2669 2670 var _ = this, 2671 edgeWasHit = false, 2672 curLeft, swipeDirection, swipeLength, positionOffset, touches; 2673 2674 touches = event.originalEvent !== undefined ? event.originalEvent.touches : null; 2675 2676 if (!_.dragging || touches && touches.length !== 1) { 2677 return false; 2678 } 2679 2680 curLeft = _.getLeft(_.currentSlide); 2681 2682 _.touchObject.curX = touches !== undefined ? touches[0].pageX : event.clientX; 2683 _.touchObject.curY = touches !== undefined ? touches[0].pageY : event.clientY; 2684 2685 _.touchObject.swipeLength = Math.round(Math.sqrt( 2686 Math.pow(_.touchObject.curX - _.touchObject.startX, 2))); 2687 2688 if (_.options.verticalSwiping === true) { 2689 _.touchObject.swipeLength = Math.round(Math.sqrt( 2690 Math.pow(_.touchObject.curY - _.touchObject.startY, 2))); 2691 } 2692 2693 swipeDirection = _.swipeDirection(); 2694 2695 if (swipeDirection === 'vertical') { 2696 return; 2697 } 2698 2699 if (event.originalEvent !== undefined && _.touchObject.swipeLength > 4) { 2700 event.preventDefault(); 2701 } 2702 2703 positionOffset = (_.options.rtl === false ? 1 : -1) * (_.touchObject.curX > _.touchObject.startX ? 1 : -1); 2704 if (_.options.verticalSwiping === true) { 2705 positionOffset = _.touchObject.curY > _.touchObject.startY ? 1 : -1; 2706 } 2707 2708 2709 swipeLength = _.touchObject.swipeLength; 2710 2711 _.touchObject.edgeHit = false; 2712 2713 if (_.options.infinite === false) { 2714 if ((_.currentSlide === 0 && swipeDirection === 'right') || (_.currentSlide >= _.getDotCount() && swipeDirection === 'left')) { 2715 swipeLength = _.touchObject.swipeLength * _.options.edgeFriction; 2716 _.touchObject.edgeHit = true; 2717 } 2718 } 2719 2720 if (_.options.vertical === false) { 2721 _.swipeLeft = curLeft + swipeLength * positionOffset; 2722 } else { 2723 _.swipeLeft = curLeft + (swipeLength * (_.$list.height() / _.listWidth)) * positionOffset; 2724 } 2725 if (_.options.verticalSwiping === true) { 2726 _.swipeLeft = curLeft + swipeLength * positionOffset; 2727 } 2728 2729 if (_.options.fade === true || _.options.touchMove === false) { 2730 return false; 2731 } 2732 2733 if (_.animating === true) { 2734 _.swipeLeft = null; 2735 return false; 2736 } 2737 2738 _.setCSS(_.swipeLeft); 2739 2740 }; 2741 2742 Slick.prototype.swipeStart = function(event) { 2743 2744 var _ = this, 2745 touches; 2746 2747 _.interrupted = true; 2748 2749 if (_.touchObject.fingerCount !== 1 || _.slideCount <= _.options.slidesToShow) { 2750 _.touchObject = {}; 2751 return false; 2752 } 2753 2754 if (event.originalEvent !== undefined && event.originalEvent.touches !== undefined) { 2755 touches = event.originalEvent.touches[0]; 2756 } 2757 2758 _.touchObject.startX = _.touchObject.curX = touches !== undefined ? touches.pageX : event.clientX; 2759 _.touchObject.startY = _.touchObject.curY = touches !== undefined ? touches.pageY : event.clientY; 2760 2761 _.dragging = true; 2762 2763 }; 2764 2765 Slick.prototype.unfilterSlides = Slick.prototype.slickUnfilter = function() { 2766 2767 var _ = this; 2768 2769 if (_.$slidesCache !== null) { 2770 2771 _.unload(); 2772 2773 _.$slideTrack.children(this.options.slide).detach(); 2774 2775 _.$slidesCache.appendTo(_.$slideTrack); 2776 2777 _.reinit(); 2778 2779 } 2780 2781 }; 2782 2783 Slick.prototype.unload = function() { 2784 2785 var _ = this; 2786 2787 $('.a4j-slick-cloned', _.$slider).remove(); 2788 2789 if (_.$dots) { 2790 _.$dots.remove(); 2791 } 2792 2793 if (_.$prevArrow && _.htmlExpr.test(_.options.prevArrow)) { 2794 _.$prevArrow.remove(); 2795 } 2796 2797 if (_.$nextArrow && _.htmlExpr.test(_.options.nextArrow)) { 2798 _.$nextArrow.remove(); 2799 } 2800 2801 _.$slides 2802 .removeClass('a4j-slick-slide a4j-slick-active a4j-slick-visible a4j-slick-current') 2803 .attr('aria-hidden', 'true') 2804 .css('width', ''); 2805 2806 }; 2807
2808 Slick.prototype.unslick = function(fromBreakpoint) { 2809 2810 var _ = this; 2811 _.$slider.trigger('unslick', [_, fromBreakpoint]); 2812 _.destroy(); 2813 2814 }; 2815 2816 Slick.prototype.updateArrows = function() { 2817 2818 var _ = this, 2819 centerOffset; 2820 2821 centerOffset = Math.floor(_.options.slidesToShow / 2); 2822 2823 if ( _.options.arrows === true && 2824 _.slideCount > _.options.slidesToShow && 2825 !_.options.infinite ) { 2826 2827 _.$prevArrow.removeClass('a4j-slick-disabled').attr('aria-disabled', 'false'); 2828 _.$nextArrow.removeClass('a4j-slick-disabled').attr('aria-disabled', 'false'); 2829 2830 if (_.currentSlide === 0) { 2831 2832 _.$prevArrow.addClass('a4j-slick-disabled').attr('aria-disabled', 'true'); 2833 _.$nextArrow.removeClass('a4j-slick-disabled').attr('aria-disabled', 'false'); 2834 2835 } else if (_.currentSlide >= _.slideCount - _.options.slidesToShow && _.options.centerMode === false) { 2836 2837 _.$nextArrow.addClass('a4j-slick-disabled').attr('aria-disabled', 'true'); 2838 _.$prevArrow.removeClass('a4j-slick-disabled').attr('aria-disabled', 'false'); 2839 2840 } else if (_.currentSlide >= _.slideCount - 1 && _.options.centerMode === true) { 2841 2842 _.$nextArrow.addClass('a4j-slick-disabled').attr('aria-disabled', 'true'); 2843 _.$prevArrow.removeClass('a4j-slick-disabled').attr('aria-disabled', 'false'); 2844 2845 } 2846 2847 } 2848 2849 }; 2850 2851 Slick.prototype.updateDots = function() { 2852 2853 var _ = this; 2854 2855 if (_.$dots !== null) { 2856 2857 _.$dots 2858 .find('i') 2859 .removeClass('a4j-slick-active') 2860 .attr('aria-hidden', 'true'); 2861 2862 _.$dots 2863 .find('i') 2864 .eq(Math.floor(_.currentSlide / _.options.slidesToScroll)) 2865 .addClass('a4j-slick-active') 2866 .attr('aria-hidden', 'false'); 2867 2868 } 2869 2870 }; 2871 2872 Slick.prototype.visibility = function() { 2873 2874 var _ = this; 2875 2876 if ( _.options.autoplay ) { 2877 2878 if ( document[_.hidden] ) { 2879 2880 _.interrupted = true; 2881 2882 } else { 2883 2884 _.interrupted = false; 2885 2886 } 2887 2888 } 2889 2890 }; 2891 2892 $.fn.a4jSlick = function() { 2893 var _ = this, 2894 opt = arguments[0], 2895 args = Array.prototype.slice.call(arguments, 1), 2896 l = _.length, 2897 i, 2898 ret; 2899 for (i = 0; i < l; i++) { 2900 if (typeof opt == 'object' || typeof opt == 'undefined') 2901 _[i].a4jslick = new Slick(_[i], opt); 2902 else 2903 ret = _[i].a4jslick[opt].apply(_[i].a4jslick, args); 2904 if (typeof ret != 'undefined') return ret; 2905 } 2906 return _; 2907 }; 2908 2909})(jQuery); 2910 2911(function ($) { 2912 'use strict'; 2913 2914 if (window.inGallery) { 2915 return; 2916 } 2917 2918 var popupShown = false; 2919 var fitPopupTimeout = 0; 2920 var popupShade = null; 2921 var popup = null; 2922 var loaderHTML = '<div class="ingLoaderWrap"><i class="ing-icon-spin2 animate-spin"></i></div>'; 2923 2924 var InGallery = function (htmlNode, config, items, _editorForm=null) { 2925 this.jqNode = $(htmlNode); 2926 this.container = this.jqNode.parent('.ingallery-container'); 2927 this.id = this.jqNode.attr('data-id'); 2928 this.cfg = config; 2929 this.page = parseInt(this.jqNode.attr('data-page')); 2930 this.commentsCache = {}; 2931 this.layoutFitTimeout = 0; 2932 this.layoutResetCounter = 0; 2933 this.masonry = null; 2934 this.visible = false; 2935 this.items = items; 2936 this.editorForm = _editorForm; 2937 2938 var self = this; 2939 2940 var loadMoreBtn = this.jqNode.find('.ingallery-loadmore-btn'); 2941 var infScroll = this.jqNode.find('.ingallery-loadmore.ingallery-inf-scroll'); 2942 2943 this.jqNode.find('.ingallery-album').off('click').on('click', function () { 2944 self.filterGallery($(this).attr('data-id')); 2945 }); 2946 if (this.cfg.layout_type == 'carousel') { 2947 this.jqNode.find('.ingallery-items').not('.a4j-slick-initialized').a4jSlick({ 2948 'prevArrow': '<span data-role="none" class="a4j-slick-prev" aria-label="Previous" tabindex="0" role="button"><i class="ing-icon-angle-left ing-fw"></i></span>', 2949 'nextArrow': '<span data-role="none" class="a4j-slick-next" aria-label="Next" tabindex="0" role="button"><i class="ing-icon-angle-right ing-fw"></i></span>' 2950 }); 2951 this.jqNode.off('beforeCarouselChange').on('beforeCarouselChange', function (e, _slick, _prevSlideID, _nextSlideID) { 2952 self.checkCarouselLoad(_nextSlideID); 2953 }); 2954 } else if (this.cfg.layout_type.indexOf('masonry') >= 0) { 2955 this.buildMasonryLayout(); 2956 this.activateMasonry(); 2957 } 2958 this.bindItemsLinks(); 2959
2960 loadMoreBtn.off('click').on('click', function () { 2961 var $this = $(this); 2962 if ($this.hasClass('disabled')) { 2963 return false; 2964 } 2965 var btnContent = $this.html(); 2966 self.page++; 2967 self.jqNode.attr('data-page', self.page); 2968 var currentPage = self.page; 2969 var messageContainer = self.jqNode.find('.ingallery-loadmore'); 2970 $this.addClass('disabled').html('<i class="ing-icon-spin2 animate-spin"></i>'); 2971 2972 var ajaxConfig = { 2973 'url': window.inGallery.getConfigValue('ajax_url'), 2974 'type': 'get', 2975 'dataType': 'json', 2976 'success': function (response, statusText, xhr, $form) { 2977 if (!response) { 2978 messageContainer.html(getMessageHTML(window.inGallery._('system_error'), 'error')); 2979 return false; 2980 } 2981 if (response.status && response.status == 'success') { 2982 self.addItems(response.items); 2983 var gallery = self.jqNode; 2984 var newItems = $(response.html).find('.ingallery-cell'); 2985 var itemsContainer = gallery.find('.ingallery-items'); 2986 if (self.cfg.layout_type == 'carousel') { 2987 gallery.css('min-height', gallery.height()); 2988 itemsContainer.a4jSlick('slickAdd', newItems); 2989 gallery.css('min-height', 'auto'); 2990 } else if (self.cfg.layout_type.indexOf('masonry') >= 0) { 2991 itemsContainer.append(newItems) 2992 self.buildMasonryLayout(gallery); 2993 itemsContainer.masonry('appended', newItems); 2994 } else { 2995 itemsContainer.append(newItems); 2996 } 2997 self.lazyImages(); 2998 /*newItems.css('opacity',0).stop().animate({ 2999 'opacity': 1 3000 },300);*/ 3001 self.bindItemsLinks(); 3002 var galleryFiltered = gallery.attr('data-filtered'); 3003 if (galleryFiltered && galleryFiltered != '' && galleryFiltered != '0') { 3004 self.filterGallery(galleryFiltered, true); 3005 } else { 3006 self.fitLayout(); 3007 } 3008 if (response.has_more) { 3009 $this.removeClass('disabled').html(btnContent); 3010 if (gallery.hasClass('ingallery-layout-carousel')) { 3011 self.checkCarouselLoad(null); 3012 } else if (infScroll.length) { 3013 self.checkInfScroll(loadMoreBtn); 3014 } 3015 } else { 3016 var tmp = gallery.find('.ingallery-loadmore'); 3017 tmp.slideUp(200, 'swing', function () { 3018 tmp.remove(); 3019 }); 3020 } 3021 $(window).trigger('resize'); 3022 } else if (response.status && response.status == 'error') { 3023 messageContainer.html(getMessageHTML(response.message, 'error')); 3024 } else { 3025 messageContainer.html(getMessageHTML(window.inGallery._('system_error'), 'error')); 3026 } 3027 }, 3028 error: function (jqXHR, textStatus, errorThrown) { 3029 messageContainer.html(getMessageHTML(window.inGallery._('system_error') + '<br><i>' + textStatus + ' (' + errorThrown + ')</i>', 'error')); 3030 } 3031 }; 3032 3033 if(self.editorForm!==null){ 3034 ajaxConfig.url = window.inGallery.getConfigValue('ajax_backend_url'); 3035 ajaxConfig.type = "POST"; 3036 ajaxConfig.data = self.editorForm.serialize(); 3037 } 3038 ajaxConfig.url+= '&id=' + self.id + '&page=' + currentPage; 3039 $.ajax(ajaxConfig); 3040 3041 return false; 3042 }); 3043 if (this.cfg.layout_type == 'carousel') {
3044 loadMoreBtn.click(); 3045 } else if (infScroll.length) { 3046 $(window).on('scroll', function () { 3047 self.checkInfScroll(loadMoreBtn); 3048 }); 3049 self.checkInfScroll(loadMoreBtn); 3050 } 3051 3052 this.jqNode.off('updateLayout').on('updateLayout', function () { 3053 self.updateLayout(); 3054 }); 3055 3056 3057 $(window).on('resize scroll', function () { 3058 self.updateLayout(); 3059 }).trigger('resize'); 3060 3061 window.setTimeout(function(){ 3062 self.updateLayout(); 3063 }, 1000); 3064 3065 window.setInterval(function () { 3066 self.checkIsVisible(); 3067 }, 100); 3068 3069 this.container.trigger('IngInit'); 3070 } 3071 3072 InGallery.prototype = { 3073 getItem: function(value, key="code"){ 3074 for(var i=0;i<this.items.length;i++){ 3075 if(this.items[i][key]==value){ 3076 return this.items[i]; 3077 } 3078 } 3079 return false; 3080 }, 3081 addItems: function(items){ 3082 for(var i=0;i<items.length;i++){ 3083 var item = items[i]; 3084 if(this.getItem(item.code)===false){ 3085 this.items.push(item); 3086 } 3087 } 3088 }, 3089 checkIsVisible: function () { 3090 this.lazyImages(); 3091 var visible = this.jqNode.is(':visible'); 3092 if (!this.visible && visible) { 3093 this.updateLayout(); 3094 } 3095 this.visible = visible; 3096 }, 3097 lazyImages: function(){ 3098 var winY = parseInt($(window).scrollTop()+$(window).height()); 3099 var thisY = this.jqNode.offset().top; 3100 if((winY+200)>=thisY){ 3101 this.jqNode.find('img').each(function(){ 3102 var img = $(this); 3103 if(img.data('src')){ 3104 img.css('opacity', 0); 3105 img.on('load', function () { 3106 if(this.complete && this.naturalWidth) { 3107 img.animate({'opacity': 1}, 300); 3108 } 3109 }); 3110 img.attr('src', img.data('src')); 3111 img.data('src', null); 3112 } 3113 }); 3114 } 3115 }, 3116 updateLayout: function () { 3117 if (this.layoutFitTimeout > 0) { 3118 window.clearTimeout(this.layoutFitTimeout); 3119 this.layoutFitTimeout = 0; 3120 } 3121 if(this.layoutResetCounter>50){ 3122 this.layoutResetCounter = 0; 3123 this.fitLayout(); 3124 } 3125 else{ 3126 this.layoutResetCounter++; 3127 this.layoutFitTimeout = window.setTimeout(this.fitLayout.bind(this), 150); 3128 } 3129 }, 3130 fitLayout: function () { 3131 if (this.layoutFitTimeout > 0) { 3132 window.clearTimeout(this.layoutFitTimeout); 3133 this.layoutFitTimeout = 0; 3134 } 3135 var winWidth = $(window).width(); 3136 var respCfg = { 3137 "cols": parseInt(this.cfg.layout_cols), 3138 "rows": parseInt(this.cfg.layout_rows), 3139 "gutter": parseInt(this.cfg.layout_gutter) 3140 }; 3141 for (var w in this.cfg.layout_responsive) { 3142 if (parseInt(w) >= winWidth) { 3143 respCfg = this.cfg.layout_responsive[w]; 3144 break; 3145 } 3146 } 3147 var $margin = (respCfg.gutter > 0 ? Math.floor(respCfg.gutter / 2) : 0); 3148 var $widthPercent = (respCfg.cols > 1 ? precisionRound(100 / respCfg.cols, 5) : 100); 3149 if (this.cfg.layout_type == 'masonry') { 3150 $widthPercent = (respCfg.cols > 1 ? precisionRound(100 / (respCfg.cols + 1), 5) : 100); 3151 } 3152 3153 var css = ""; 3154 if (this.cfg.layout_type == 'carousel') { 3155 css += "#ingallery-" + this.id + " .ingallery-col, #ingallery-" + this.id + " .ingallery-cell{padding:" + $margin + "px;}"; 3156 } else { 3157 css += "#ingallery-" + this.id + " .ingallery-items{margin-left:-" + $margin + "px;margin-right:-" + $margin + "px;}"; 3158 css += "#ingallery-" + this.id + " .ingallery-col, #ingallery-" + this.id + " .ingallery-cell{padding-left:" + $margin + "px;padding-right:" + $margin + "px;padding-bottom:" + respCfg.gutter + "px;
3158width:" + $widthPercent + "%;}"; 3159 css += "#ingallery-" + this.id + " .grid-sizer{width:" + $widthPercent + "%;}"; 3160 css += "#ingallery-" + this.id + " .ingallery-col-big, #ingallery-" + this.id + " .ingallery-cell-big{width:" + ($widthPercent * 2) + "%;}"; 3161 } 3162 3163 var customCSSNode = this.jqNode.find('.custom-css-node'); 3164 if (customCSSNode.length == 0) { 3165 customCSSNode = $('<style type="text/css" class="custom-css-node"></style>'); 3166 this.jqNode.append(customCSSNode); 3167 } 3168 customCSSNode.text(css); 3169 3170 if (this.masonry) { 3171 var feed = this; 3172 this.masonry.masonry(); 3173 var images = this.masonry.find('img'); 3174 var imagesLoaded = 0; 3175 var imagesTotal = images.length; 3176 var imgLoaded = function (img) { 3177 imagesLoaded++; 3178 feed.masonry.masonry('layout'); 3179 }; 3180 images.each(function () { 3181 if (this.complete && this.naturalWidth) { 3182 imgLoaded(this); 3183 } 3184 }); 3185 if (imagesLoaded < imagesTotal) { 3186 images.on('load', function () { 3187 if (this.complete && this.naturalWidth) { 3188 imgLoaded(this); 3189 } 3190 }); 3191 } 3192 } 3193 var newImages = this.jqNode.find('.ingallery-item img').not('.ing-loading, .ing-loaded'); 3194 newImages.each(function () { 3195 if (this.complete && this.naturalWidth) { 3196 return 3197 } 3198 var $img = $(this); 3199 $img.addClass('ing-loading').css('opacity', 0); 3200 $img.on('load', function () { 3201 if (this.complete && this.naturalWidth) { 3202 $(this).removeClass('ing-loading').addClass('ing-loaded').stop().animate({'opacity': 1}, 300); 3203 } 3204 }); 3205 }); 3206 this.container.trigger('IngLayout'); 3207 }, 3208 showInPopup: function (_item) { 3209 if (popupShown) { 3210 this.updatePopup(_item); 3211 } else { 3212 this.createPopup(_item); 3213 } 3214 }, 3215 3216 createPopup: function (_item) { 3217 if (popupShown) { 3218 return; 3219 } 3220 var gallery = this; 3221 var popupHTML; 3222 popupHTML = '<div id="ingallery-shade">'; 3223 popupHTML += '<div id="ingallery-popup" class="' + this.id + ' ingallery-' + this.id + '">'; 3224 popupHTML += '<div id="ingallery-popup-close"><i class="ing-icon-cancel-1"></i></div>'; 3225 popupHTML += '<div id="ingallery-popup-wrap">'; 3226 popupHTML += '<div id="ingallery-popup-wrap-img">'; 3227 popupHTML += '<div id="ingallery-popup-left"><i class="ing-icon-angle-left"></i></div>'; 3228 popupHTML += '<div id="ingallery-popup-right"><i class="ing-icon-angle-right"></i></div>'; 3229 popupHTML += '<div id="ingallery-popup-wrap-img-cnt"></div>'; 3230 popupHTML += '</div>'; 3231 popupHTML += '<div id="ingallery-popup-wrap-content"></div>'; 3232 popupHTML += '</div>'; 3233 popupHTML += '</div>'; 3234 popupHTML += '</div>'; 3235 popupShade = $(popupHTML); 3236 var _body = $('body'); 3237 popup = popupShade.find('#ingallery-popup'); 3238 _body.append(popupShade); 3239 popupShown = true; 3240 popupShade.fadeIn(300); 3241 popup.css('opacity', 0).css('margin-top', '30px').stop().animate({ 3242 opacity: 1, 3243 'margin-top': 0 3244 }, 300); 3245 3246 popupShade.on('click', function (e) { 3247 var _target = $(e.target); 3248 var _close = _target.closest('#ingallery-popup-close'); 3249 if (_target.is(popupShade) || _close.length) { 3250 gallery.closePopup.call(this); 3251 } 3252 }); 3253 3254 $(document).on('keydown', this.processKeydown); 3255 3256 this.placeDataToPopup(_item); 3257 }, 3258 updatePopup: function (_item) { 3259 if (!popupShown) { 3260 return; 3261 } 3262 var gallery = this; 3263 var popupWraps = $('#ingallery-popup-wrap-img-cnt > img,#ingallery-popup-wrap-content'); 3264 popupWraps.stop().animate({ 3265 'opacity': 0 3266 }, 100, 'swing', function () { 3267 gallery.placeDataToPopup(_item); 3268 popupWraps.stop().animate({ 3269 'opacity': 1 3270 }, 100); 3271 }); 3272 }, 3273 closePopup: function () { 3274 if (!popupShown) { 3275 return; 3276 } 3277 var _body = $('body'); 3278 popupShade.fadeOut(300, 'swing', function () { 3279 popupShade.remove(); 3280 popupShown = false; 3281 }); 3282 popup.stop().animate({ 3283 opacity: 0, 3284 'margin-top': 30 3285 }, 300); 3286 $(document).off('keydown', this.processKeydown); 3287 }, 3288 3289 processKeydown: function (e) { 3290 if (!e.which) { 3291 return; 3292 } 3293 if (e.which == 37) { 3294 $('#ingallery-popup-left:visible').click(); 3295 } else if (e.which == 39) { 3296 $('#ingallery-popup-right:visible').click(); 3297 } 3298 }, 3299 3300 placeDataToPopup: function (_item) { 3301 var popupWrap = $('#ingallery-popup-wrap'); 3302 var popupImgWrap = $('#ingallery-popup-wrap-img'); 3303 var popupContentWrap = $('#ingallery-popup-wrap-content'); 3304 if (popupImgWrap.length == 0 || popupContentWrap.length == 0) { 3305 return false; 3306 } 3307 var gallery = this; 3308 popupImgWrap.attr('data-img-size', this.cfg.display_popup_img_size); 3309 popupImgWrap.attr('data-ratio', _item.ratio); 3310 popupImgWrap.attr('data-width', _item.full_width); 3311 popupImgWrap.attr('data-height', _item.full_height); 3312 var imgPlaceholder = popupImgWrap.find('#ingallery-popup-wrap-img-cnt'); 3313 imgPlaceholder.off('click').removeClass('ing-video').removeClass('ing-playing'); 3314 if (_item.type=='video') { 3315 this.showVideo(_item); 3316 } else if (_item.items.length) { 3317 this.showSubgallery(_item); 3318 } else { 3319 var _img = $('<img />').css('opacity', 0); 3320 _img.on('load', function () { 3321 _img.animate({ 3322 'opacity': 1 3323 }, 200); 3324 }); 3325 _img.attr('src', _item.picture_url); 3326 imgPlaceholder.empty().append(_img); 3327 } 3328 3329 var needToLoadData = false;
3330 var contentHTML = ''; 3331 if (this.cfg.display_popup_user) { 3332 contentHTML += '<div class="ingallery-popup-content-user '+(_item.author_picture_url!=''?'':'ing-loading')+'">'; 3333 if(_item.author_picture_url!=''){ 3334 if (this.cfg.display_popup_instagram_link) { 3335 contentHTML += '<a href="https://www.instagram.com/' + _item.author_username + '/" title="' + _item.author_username + '" target="_blank"><img src="' + _item.author_picture_url + '"> ' + _item.author_name+'</a>'; 3336 } 3337 else{ 3338 contentHTML += '<img src="' + _item.author_picture_url + '"> ' + _item.author_name; 3339 } 3340 } 3341 else{ 3342 needToLoadData = true; 3343 } 3344 contentHTML += '</div>'; 3345 } 3346 if (this.cfg.display_popup_likes || this.cfg.display_popup_comments || this.cfg.display_popup_plays || this.cfg.display_popup_date) { 3347 contentHTML += '<div class="ingallery-popup-content-stats">'; 3348 if (this.cfg.display_popup_date) { 3349 contentHTML += '<time title="' + _item.full_date + '" datetime="' + _item.date_iso + '">' + _item.time_passed + '</time>'; 3350 } 3351 if (this.cfg.display_popup_likes) { 3352 contentHTML += '<span class="ingallery-popup-content-stats-likes"><i class="ing-icon-heart-1"></i> ' + _item.likes_count + '</span>'; 3353 } 3354 if (this.cfg.display_popup_comments) { 3355 contentHTML += '<span class="ingallery-popup-content-stats-comments"><i class="ing-icon-comment-1"></i> ' + _item.comments_count + '</span>'; 3356 } 3357 contentHTML += '</div>'; 3358 } 3359 if (this.cfg.display_popup_description || this.cfg.display_popup_comments_listx) { 3360 contentHTML += '<div class="ingallery-popup-content-stretch">'; 3361 if (this.cfg.display_popup_description) { 3362 contentHTML += '<div class="ingallery-popup-content-descr">'; 3363 if(_item.text_html){ 3364 contentHTML += _item.text_html; 3365 } 3366 else{ 3367 needToLoadData = true; 3368 } 3369 contentHTML += '</div>'; 3370 } 3371 if (this.cfg.display_popup_comments_listx){ 3372 contentHTML += '<div class="ingallery-popup-content-comments ing-loading"></div>'; 3373 needToLoadData = true; 3374 } 3375 contentHTML += '</div>'; 3376 } 3377 3378 if (contentHTML != '') { 3379 popupWrap.removeClass('noRight'); 3380 popupContentWrap.html(contentHTML); 3381 } else { 3382 popupWrap.addClass('noRight'); 3383 } 3384 3385 $('#ingallery-popup-c2a-btn').remove(); 3386 var c2a_cfg = this.getC1A_ItemConfig(_item.code); 3387 if(c2a_cfg){ 3388 console.info(c2a_cfg.label); 3389 var btn = $('<a href="'+c2a_cfg.uri+'" target="_blank" rel="nofollow" id="ingallery-popup-c2a-btn"><svg class="eapps-instagram-feed-popup-item-cta-button-icon" viewBox="0 0 6 10"><path d="M5.71,4.286L1.727,0.302c-0.39-0.392-1.023-0.392-1.414,0c-0.39,0.39-0.39,1.023,0,1.414L3.59,4.992 L0.289,8.284c-0.39,0.39-0.39,1.025,0,1.415c0.39,0.39,1.023,0.39,1.414,0l4.008-4C6.101,5.309,6.101,4.675,5.71,4.286z"></path></svg>'+c2a_cfg.label+'</a>'); 3390 switch(c2a_cfg.position){ 3391 case 'top': 3392 case 'middle': 3393 case 'bottom': 3394 btn.addClass('ingallery-position-'+c2a_cfg.position); 3395 popupImgWrap.append(btn); 3396 break; 3397 case 'descr.top': 3398 if(popupContentWrap.find('.ingallery-popup-content-stretch')){ 3399 popupContentWrap.find('.ingallery-popup-content-stretch').prepend(btn); 3400 } 3401 break; 3402 case 'descr.bottom': 3403 if(popupContentWrap.find('.ingallery-popup-content-stretch')){ 3404 popupContentWrap.find('.ingallery-popup-content-stretch').append(btn); 3405 } 3406 break; 3407 } 3408 } 3409 3410 if (needToLoadData) { 3411 $.ajax({
3412 url: window.inGallery.getConfigValue('ajax_data_url'), 3413 type: 'get', 3414 dataType: 'json', 3415 cache: true, 3416 data: 'galleryID='+this.id+'&pictureID='+_item.id, 3417 success: function (response){ 3418 if (response && response.status && response.status == 'success') { 3419 if(_item.code==response.data.code){ 3420 gallery.updatePopupData(response.data, response.comments); 3421 if(response.data.type=='video'){ 3422 gallery.showVideo(response.data); 3423 } 3424 else if(response.data.items.length){ 3425 gallery.showSubgallery(response.data); 3426 } 3427 } 3428 } 3429 }, 3430 error: function(jqXHR, textStatus, errorThrown){ 3431 console.info(textStatus, errorThrown); 3432 } 3433 }); 3434 } 3435 3436 var _items = this.jqNode.find('a.ingallery-item-link-popup:visible'); 3437 var goPrev = $('#ingallery-popup-left'); 3438 var goNext = $('#ingallery-popup-right'); 3439 var itemIndex = _items.index(_item.jqItem); 3440 if (itemIndex > 0) { 3441 goPrev.show(); 3442 goPrev.off('click').on('click', function () { 3443 _items.get(itemIndex - 1).click(); 3444 }); 3445 } else { 3446 goPrev.hide(); 3447 } 3448 if (itemIndex + 1 < _items.length) { 3449 goNext.show(); 3450 goNext.off('click').on('click', function () { 3451 _items.get(itemIndex + 1).click(); 3452 }); 3453 } else { 3454 goNext.hide(); 3455 } 3456 3457 if (itemIndex > _items.length - 4) { 3458 this.jqNode.find('.ingallery-loadmore-btn').click(); 3459 } 3460 3461 setFitPopup(); 3462 3463 return true; 3464 }, 3465 3466 getC1A_ItemConfig: function(code){ 3467 if(this.cfg.c2a){ 3468 for(var i=0;i<this.cfg.c2a.length;i++){ 3469 if(this.cfg.c2a[i]['post']=='https://www.instagram.com/p/'+code || this.cfg.c2a[i]['post']=='https://www.instagram.com/p/'+code+'/'){ 3470 return this.cfg.c2a[i]; 3471 } 3472 } 3473 } 3474 return false; 3475 }, 3476 3477 showVideo: function(_item){ 3478 var popupImgWrap = $('#ingallery-popup-wrap-img'); 3479 var imgPlaceholder = popupImgWrap.find('#ingallery-popup-wrap-img-cnt'); 3480 imgPlaceholder.addClass('ing-video'); 3481 var _video = $('<video poster="' + _item.picture_url + '" src="' + _item.video_url + '" preload="false" ' + (this.cfg.display_popup_loop_video ? 'loop="loop"' : '') + ' playsinline type="video/mp4"><source src="' + _item.video_url + '" type="video/mp4"></video>'); 3482 imgPlaceholder.empty().append(_video); 3483 3484 _video.on('click', function () { 3485 var player = _video.get(0); 3486 if (player.paused) { 3487 imgPlaceholder.addClass('ing-playing'); 3488 player.play(); 3489 } else { 3490 imgPlaceholder.removeClass('ing-playing'); 3491 player.pause(); 3492 } 3493 }); 3494 }, 3495 3496 showSubgallery: function(_item){ 3497 var popupImgWrap = $('#ingallery-popup-wrap-img'); 3498 var imgPlaceholder = popupImgWrap.find('#ingallery-popup-wrap-img-cnt'); 3499 3500 var _subgallery = $('<div id="ingallery-popup-wrap-img-subgallery"></div>'); 3501 var _subgalleryItems = $('<div id="ingallery-popup-wrap-img-subgallery-items"></div>'); 3502 var _subgalleryNav = $('<div id="ingallery-popup-wrap-img-subgallery-nav"></div>'); 3503 var _subgalleryPrev = $('<div id="ingallery-popup-wrap-img-subgallery-prev"><i class="ing-icon-angle-left ing-fw"></i></div>'); 3504 var _subgalleryNext = $('<div id="ingallery-popup-wrap-img-subgallery-next"><i class="ing-icon-angle-right ing-fw"></i></div>'); 3505 var _subgalleryCurrentIdx = 0; 3506 for (var i = 0; i < _item.items.length; i++) { 3507 var _subgalleryItemClass = ''; 3508 if (i == _subgalleryCurrentIdx) { 3509 _subgalleryItemClass = 'active'; 3510 } 3511 var _subgalleryItem = '<div class="ingallery-popup-subgallery-item ' + _subgalleryItemClass + '" data-ratio="' + _item.items[i].ratio + '" data-width="' + _item.items[i].full_width + '" data-height="' + _item.items[i].full_height + '">'; 3512 if (_item.items[i].type=='video') { 3513 imgPlaceholder.addClass('ing-video'); 3514 _subgalleryItem += '<video poster="' + _item.items[i].picture_url + '" src="' + _item.items[i].video_url + '" preload="false" ' + (this.cfg.display_popup_loop_video ? 'loop="loop"' : '') + ' playsinline type="video/mp4"><source src="' + _item.items[i].video_url + '" type="video/mp4"></video>'; 3515 } else { 3516 _subgalleryItem += '<img src="' + _item.items[i].picture_url + '" />'; 3517 } 3518 _subgalleryItem += '</div>';
3519 _subgalleryItems.append(_subgalleryItem); 3520 _subgalleryNav.append('<i class="' + _subgalleryItemClass + '"></i>'); 3521 } 3522 _subgallery.append(_subgalleryItems); 3523 _subgallery.append(_subgalleryNav); 3524 _subgallery.append(_subgalleryPrev); 3525 _subgallery.append(_subgalleryNext); 3526 imgPlaceholder.empty().append(_subgallery); 3527 3528 _subgallery.find('video').each(function () { 3529 var _video = $(this); 3530 _video.on('click', function () { 3531 var player = _video.get(0); 3532 if (player.paused) { 3533 imgPlaceholder.addClass('ing-playing'); 3534 player.play(); 3535 } else { 3536 imgPlaceholder.removeClass('ing-playing'); 3537 player.pause(); 3538 } 3539 }); 3540 }); 3541 3542 var checkNav = function () { 3543 if (_subgalleryCurrentIdx == 0) { 3544 _subgalleryPrev.hide(); 3545 } else { 3546 _subgalleryPrev.show(); 3547 } 3548 if (_subgalleryCurrentIdx == _item.items.length - 1) { 3549 _subgalleryNext.hide(); 3550 } else { 3551 _subgalleryNext.show(); 3552 } 3553 } 3554 checkNav(); 3555 var switchItem = function (_index) { 3556 if (_index < 0 || _index > _item.items.length - 1) { 3557 return false; 3558 } 3559 if (imgPlaceholder.hasClass('ing-playing')) { 3560 _subgalleryItems.children('.active').find('video').click(); 3561 } 3562 var _direction = (_subgalleryCurrentIdx > _index ? 'backward' : 'forward'); 3563 var _csgitemEx = $(_subgalleryItems.children().get(_subgalleryCurrentIdx)); 3564 var _csgitem = $(_subgalleryItems.children().get(_index)); 3565 3566 _subgalleryCurrentIdx = _index; 3567 popupImgWrap.attr('data-ratio', _csgitem.attr('data-ratio')); 3568 popupImgWrap.attr('data-width', _csgitem.attr('data-width')); 3569 popupImgWrap.attr('data-height', _csgitem.attr('data-height')); 3570 _subgalleryItems.children().removeClass('active prev next'); 3571 _csgitem.addClass('active'); 3572 _csgitem.prev().addClass('prev'); 3573 _csgitem.next().addClass('next'); 3574 _subgalleryNav.children().removeClass('active'); 3575 $(_subgalleryNav.children().get(_index)).addClass('active'); 3576 if (_csgitem.find('video').length) { 3577 imgPlaceholder.addClass('ing-video'); 3578 } else { 3579 imgPlaceholder.removeClass('ing-video'); 3580 } 3581 checkNav(); 3582 if (_direction == 'forward') { 3583 _csgitemEx.animate({ 3584 'left': '-100%' 3585 }, 100); 3586 _csgitem.css('left', '100%').animate({ 3587 'left': 0 3588 }, 100); 3589 } else { 3590 _csgitemEx.animate({ 3591 'left': '100%' 3592 }, 100); 3593 _csgitem.css('left', '-100%').animate({ 3594 'left': 0 3595 }, 100); 3596 } 3597 3598 setFitPopup(); 3599 } 3600 _subgalleryNav.children().on('click', function () { 3601 switchItem($(this).index()); 3602 return false; 3603 }); 3604 _subgalleryPrev.on('click', function () { 3605 switchItem(_subgalleryCurrentIdx - 1); 3606 return false; 3607 }); 3608 _subgalleryNext.on('click', function () { 3609 switchItem(_subgalleryCurrentIdx + 1); 3610 return false; 3611 }); 3612 switchItem(0); 3613 }, 3614 3615 updatePopupData: function(_data, _comments){ 3616 //gallery.commentsCache[response.media_code] = response.html; 3617 var popupWrap = $('#ingallery-popup-wrap'); 3618 3619 var html = ''; 3620 3621 html = '<img src="' + _data.author_picture_url + '"> ' + _data.author_name; 3622 if (this.cfg.display_popup_instagram_link) { 3623 html = '<a href="https://www.instagram.com/' + _data.author_username + '/" title="' + _data.author_username + '" target="_blank"><img src="' + _data.author_picture_url + '"> ' + _data.author_name+'</a>'; 3624 } 3625 popupWrap.find('.ingallery-popup-content-user').removeClass('ing-loading').html(html).css('opacity', 0).stop().animate({ 3626 'opacity': 1 3627 }, 300); 3628 3629 popupWrap.find('.ingallery-popup-content-descr').removeClass('ing-loading').html(_data.text_html).css('opacity', 0).stop().animate({ 3630 'opacity': 1 3631 }, 300); 3632 3633 html = ''; 3634 for(var i=0;i<_comments.length;i++){ 3635 html+= '<div class="ingallery-popup-content-comments-item">'; 3636 html+= '<strong><a href="https://www.instagram.com/'+_comments[i]['author_username']+'/" target="_blank" rel="nofollow">@'+_comments[i]['author_username']+'</a></strong>'; 3637 html+= '<span>'+_comments[i]['text_html']+'</span>'; 3638 html+= '</div>'; 3639 } 3640 popupWrap.find('.ingallery-popup-content-comments').removeClass('ing-loading').html(html).css('opacity', 0).stop().animate({ 3641 'opacity': 1 3642 }, 300); 3643 }, 3644 3645 filterGallery: function (albumID, _force) { 3646 this.jqNode.css('height', this.jqNode.height()); 3647 var oldAlbum = this.jqNode.find('.ingallery-album.active'); 3648 if (oldAlbum.attr('data-id') == albumID && !_force) { 3649 return; 3650 } 3651 var newAlbum = this.jqNode.find('.ingallery-album[data-id="' + albumID + '"]'); 3652 var itemsToShow; 3653 var itemsToHide; 3654 3655 this.jqNode.attr('data-filtered', newAlbum.attr('data-id')); 3656 oldAlbum.removeClass('active'); 3657 newAlbum.addClass('active'); 3658 3659 itemsToHide = this.jqNode.find('.ingallery-cell'); 3660 3661 if (newAlbum.attr('data-id') == '0') { 3662 itemsToShow = this.jqNode.find('.ingallery-cell'); 3663 } else { 3664 itemsToShow = this.jqNode.find('.ingallery-cell[data-album="' + newAlbum.attr('data-id') + '"]'); 3665 } 3666 itemsToHide.stop().hide(); 3667 itemsToShow.stop().show().css('opacity', 0).animate({ 3668 'opacity': 1 3669 }, 300); 3670 3671 this.jqNode.css('height', 'auto'); 3672 this.fitLayout(); 3673 3674 if (this.masonry) { 3675 this.buildMasonryLayout(); 3676 this.masonry.masonry('layout'); 3677 } 3678 }, 3679 3680 checkCarouselLoad: function (_nextSlideID) { 3681 var carousel = this.jqNode.find('.ingallery-items').data('ingslick'); 3682 if (!carousel) { 3683 return; 3684 } 3685 var curSlide; 3686 var totalSlides; 3687 if (_nextSlideID) { 3688 carousel.currentSlide = _nextSlideID; 3689 } 3690 if (carousel.options.rows > 1) { 3691 curSlide = carousel.currentSlide; 3692 totalSlides = carousel.slideCount; 3693 //carousel.options.slidesPerRow 3694 } else { 3695 curSlide = Math.floor((parseInt(carousel.currentSlide) + 1) / parseInt(carousel.options.slidesToShow)); 3696 totalSlides = Math.ceil((parseInt(carousel.slideCount) - parseInt(carousel.options.slidesToShow)) / parseInt(carousel.options.slidesToShow)); 3697 } 3698 if (curSlide > totalSlides - 3) { 3699 this.jqNode.find('.ingallery-loadmore-btn').click(); 3700 } 3701 }, 3702 3703 checkInfScroll: function (loadMoreBtn) { 3704 if (loadMoreBtn.hasClass('disabled')) { 3705 return false; 3706 } 3707 var top = $(window).scrollTop() + ($(window).height() * 1.4); 3708 if (top > loadMoreBtn.offset().top) {
3709 loadMoreBtn.click(); 3710 } 3711 }, 3712 3713 buildMasonryLayout: function () { 3714 if (this.cfg.layout_type != 'masonry') { 3715 return this; 3716 } 3717 var cols = this.cfg.layout_cols; 3718 var maxColPos = cols - 1; 3719 var curColPos = -1; 3720 var colPosDir = 1; 3721 var lastRowNum = -1; 3722 3723 this.jqNode.find('.ingallery-cell:visible').each(function (index) { 3724 var itemRowNum = Math.floor(index / (cols * 2 - 1)); 3725 var itemColNum = index % (cols * 2 - 1); 3726 if (lastRowNum != itemRowNum) { 3727 if (curColPos + colPosDir > maxColPos) { 3728 colPosDir = -1; 3729 } else if (curColPos + colPosDir < 0) { 3730 colPosDir = 1; 3731 } 3732 curColPos += colPosDir; 3733 } 3734 if (curColPos == itemColNum) { 3735 $(this).addClass('ingallery-cell-big'); 3736 } else { 3737 $(this).removeClass('ingallery-cell-big'); 3738 } 3739 lastRowNum = itemRowNum; 3740 }); 3741 this.fitLayout(); 3742 }, 3743 3744 activateMasonry: function () { 3745 this.masonry = this.jqNode.find('.ingallery-items').masonry({ 3746 'itemSelector': '.ingallery-cell', 3747 'percentPosition': true, 3748 'columnWidth': '.grid-sizer', 3749 'masonry': { 3750 'columnWidth': '.grid-sizer' 3751 }, 3752 'originLeft': $('body').css('direction')!=='rtl' 3753 }); 3754 }, 3755 3756 bindItemsLinks: function () { 3757 var gallery = this; 3758 this.jqNode.find('a.ingallery-item-link-popup').off('click').on('click', function (e) { 3759 e.preventDefault(); 3760 var $this = $(this); 3761 var code = $this.closest('.ingallery-item').data('code'); 3762 var _item = gallery.getItem(code); 3763 _item.jqItem = $this; 3764 gallery.showInPopup(_item); 3765 return false; 3766 }); 3767 }, 3768 3769 } 3770 3771 function getMessageHTML(msg, type) { 3772 var html = '<div class="ingallery-message ing-' + type + '">'; 3773 html += '<div class="ingallery-message-title">' + window.inGallery._('error_title') + '</div>'; 3774 html += '<div class="ingallery-message-text">' + msg + '</div>'; 3775 html += '</div>'; 3776 return html; 3777 } 3778 3779 function setFitPopup() { 3780 if (fitPopupTimeout > 0) { 3781 window.clearTimeout(fitPopupTimeout); 3782 fitPopupTimeout = 0; 3783 } 3784 fitPopupTimeout = window.setTimeout(fitPopup, 100); 3785 } 3786 3787 function fitPopup() { 3788 if (fitPopupTimeout > 0) { 3789 window.clearTimeout(fitPopupTimeout); 3790 fitPopupTimeout = 0; 3791 } 3792 if (!popupShown) { 3793 return; 3794 } 3795 var popupImgWrap = $('#ingallery-popup-wrap-img'); 3796 var popupWrap = $('#ingallery-popup-wrap'); 3797 var winH = $(window).height(); 3798 var winW = $(window).width(); 3799 var ratio = popupImgWrap.attr('data-ratio'); 3800 if (popupImgWrap.length == 0 || popupWrap.length == 0) { 3801 return false; 3802 } 3803 if (winW < 750) { 3804 popup.addClass('ing-smallest'); 3805 popupWrap.height(winW / ratio); 3806 return false; 3807 } else { 3808 popup.removeClass('ing-smallest'); 3809 } 3810 var maxH = winH - 100; 3811 var minH = 550; 3812 var maxw = winW - 330 - 100; 3813 if (popupImgWrap.attr('data-img-size') == 'try_to_fit') { 3814 maxH = Math.min(maxH, popupImgWrap.attr('data-height')); 3815 maxw = Math.min(maxw, popupImgWrap.attr('data-width')); 3816 } 3817 var width = 750; 3818 var height = width / ratio; 3819 if (height > maxH) { 3820 height = maxH; 3821 width = height * ratio; 3822 } 3823 if (height < minH) { 3824 height = minH; 3825 width = height * ratio; 3826 } 3827 if (width > maxw) { 3828 width = maxw; 3829 height = width / ratio; 3830 } 3831 var top = Math.max((winH - height) / 2, 50); 3832 popup.css('top', top); 3833 popupWrap.height(height); 3834 popupImgWrap.width(width); 3835 3836 } 3837 3838 function precisionRound(number, precision) { 3839 var factor = Math.pow(10, precision); 3840 return Math.round(number * factor) / factor; 3841 } 3842 3843 window.inGallery = { 3844 config: {}, 3845 i18n: {}, 3846 init: function(){ 3847 var node = $('#ingallery-cfg'); 3848 if(node.length==0){ 3849 console.log('No InGallery config'); 3850 return; 3851 } 3852 var configData = JSON.parse(node.html()); 3853 if (!configData || !configData.hasOwnProperty('config')) { 3854 console.log('No InGallery config'); 3855 } 3856 this.config = configData.config; 3857 this.i18n = configData.i18n; 3858 }, 3859 create: function (htmlNode, config, items, _editorForm) { 3860 return new InGallery(htmlNode, config, items, _editorForm); 3861 }, 3862 addRequestData: function (gallery) { 3863 return ''; 3864 }, 3865 _: function (key) { 3866 if(this.i18n.hasOwnProperty(key)){ 3867 return this.i18n[key]; 3868 } 3869 return '*'+key+'*'; 3870 }, 3871 addTranslation: function(_lang){ 3872 for(var k in _lang){ 3873 this.i18n[k] = _lang[k]; 3874 } 3875 }, 3876 getConfigValue: function (paramName, _default=null) { 3877 if(this.config.hasOwnProperty(paramName)){ 3878 return this.config[paramName]; 3879 } 3880 return _default; 3881 }, 3882 setConfigValue: function (paramName, paramValue) { 3883 this.config[paramName] = paramValue; 3884 }, 3885 } 3886 3887 $(window).on('resize', function () { 3888 setFitPopup(); 3889 });
3890 3891 $(document).ready(function (e) { 3892 window.inGallery.init(); 3893 3894 $('.ingallery-container').each(function () { 3895 var self = $(this); 3896 self.html(loaderHTML); 3897 var $aj = { 3898 url: window.inGallery.getConfigValue('ajax_url'), 3899 type: 'get', 3900 dataType: 'json', 3901 cache: true, 3902 data: 'task=gallery.view&id=' + self.attr('data-id'), 3903 success: function (response, statusText, xhr, $form) { 3904 if (!response) { 3905 self.html(getMessageHTML(window.inGallery._('system_error'), 'error')); 3906 return false; 3907 } 3908 if (response && response.status && response.status == 'success') { 3909 var node = $(response.html); 3910 self.empty().append(node); 3911 window.inGallery.create(node.get(0), response.config, response.items); 3912 } else if (response && response.status && response.status == 'error') { 3913 self.html(getMessageHTML(response.message, 'error')); 3914 } else { 3915 self.html(getMessageHTML(window.inGallery._('system_error'), 'error')); 3916 } 3917 }, 3918 error: function (jqXHR, textStatus, errorThrown) { 3919 self.html(getMessageHTML(window.inGallery._('system_error') + '<br><i>' + textStatus + ' (' + errorThrown + ')</i>', 'error')); 3920 }, 3921 } 3922 $.ajax($aj); 3923 }); 3924 }); 3925 3926})(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.