1/* jshint browser: true, jquery: true, devel: true */ 2/* global window, jQuery */ 3 4(function($, window, undefined) { 5 'use strict'; 6 7 function throttle(func, delay) { 8 var timer = null; 9 10 return function() { 11 var context = this, 12 args = arguments; 13 14 if ( timer === null ) { 15 timer = setTimeout(function() { 16 func.apply(context, args); 17 timer = null; 18 }, delay); 19 } 20 }; 21 } 22 23 // Check for browser CSS support and cache the result for subsequent calls. 24 var checkStyleSupport = (function() { 25 var support = {}; 26 return function(prop) { 27 if ( support[prop] !== undefined ) { return support[prop]; } 28 29 var div = document.createElement('div'), 30 style = div.style, 31 ucProp = prop.charAt(0).toUpperCase() + prop.slice(1), 32 prefixes = ["webkit", "moz", "ms", "o"], 33 props = (prop + ' ' + (prefixes).join(ucProp + ' ') + ucProp).split(' '); 34 35 for (var i in props) { 36 if ( props[i] in style ) { return support[prop] = props[i]; } 37 } 38 39 return support[prop] = false; 40 }; 41 }()); 42 43 var svgNS = 'http://www.w3.org/2000/svg', 44 svgSupport = (function() { 45 var support; 46 return function() { 47 if ( support !== undefined ) { return support; } 48 var div = document.createElement('div'); 49 div.innerHTML = '<svg/>'; 50 support = ( div.firstChild && div.firstChild.namespaceURI === svgNS ); 51 return support; 52 }; 53 }()); 54 55 var $window = $(window), 56 57 transformSupport = checkStyleSupport('transform'), 58 59 defaults = { 60 itemContainer: 'ul', 61 // [string|object] 62 // Selector for the container of the flippin' items. 63 64 itemSelector: 'li', 65 // [string|object] 66 // Selector for children of `itemContainer` to flip 67 68 start: 'center', 69 // ['center'|number] 70 // Zero based index of the starting item, or use 'center' to start in the middle 71 72 fadeIn: 400, 73 // [milliseconds] 74 // Speed of the fade in animation after items have been setup 75 76 loop: false, 77 // [true|false|number] 78 // Loop around when the start or end is reached 79 // If number, this is the number of items that will be shown when the beginning or end is reached 80 81 autoplay: false, 82 // [false|milliseconds] 83 // If a positive number, Flipster will automatically advance to next item after that number of milliseconds 84 85 pauseOnHover: true, 86 // [true|false] 87 // If true, autoplay advancement will pause when Flipster is hovered 88 89 style: 'coverflow', 90 // [coverflow|carousel|flat|...] 91 // Adds a class (e.g. flipster--coverflow) to the flipster element to switch between display styles 92 // Create your own theme in CSS and use this setting to have Flipster add the custom class 93 94 spacing: -0.6, 95 // [number] 96 // Space between items relative to each item's width. 0 for no spacing, negative values to overlap 97 98 click: true, 99 // [true|false] 100 // Clicking an item switches to that item 101 102 keyboard: true, 103 // [true|false] 104 // Enable left/right arrow navigation 105 106 scrollwheel: true, 107 // [true|false] 108 // Enable mousewheel/trackpad navigation; up/left = previous, down/right = next 109 110 touch: true, 111 // [true|false] 112 // Enable swipe navigation for touch devices 113 114 nav: false, 115 // [true|false|'before'|'after'] 116 // If not false, Flipster will build an unordered list of the items 117 // Values true or 'before' will insert the navigation before the items, 'after' will append the navigation after the items 118
119 buttons: false, 120 // [true|false|'custom'] 121 // If true, Flipster will insert Previous / Next buttons with SVG arrows 122 // If 'custom', Flipster will not insert the arrows and will instead use the values of `buttonPrev` and `buttonNext` 123 124 buttonPrev: 'Previous', 125 // [text|html] 126 // Changes the text for the Previous button 127 128 buttonNext: 'Next', 129 // [text|html] 130 // Changes the text for the Next button 131 132 onItemSwitch: false 133 // [function] 134 // Callback function when items are switched 135 // Arguments received: [currentItem, previousItem] 136 }, 137 138 classes = { 139 main: 'flipster', 140 active: 'flipster--active', 141 container: 'flipster__container', 142 143 nav: 'flipster__nav', 144 navChild: 'flipster__nav__child', 145 navItem: 'flipster__nav__item', 146 navLink: 'flipster__nav__link', 147 navCurrent: 'flipster__nav__item--current', 148 navCategory: 'flipster__nav__item--category', 149 navCategoryLink: 'flipster__nav__link--category', 150 151 button: 'flipster__button', 152 buttonPrev: 'flipster__button--prev', 153 buttonNext: 'flipster__button--next', 154 155 item: 'flipster__item', 156 itemCurrent: 'flipster__item--current', 157 itemPast: 'flipster__item--past', 158 itemFuture: 'flipster__item--future', 159 itemContent: 'flipster__item__content' 160 }, 161 162 classRemover = new RegExp('\\b(' + classes.itemCurrent + '|' + classes.itemPast + '|' + classes.itemFuture + ')(.*?)(\\s|$)', 'g'), 163 whiteSpaceRemover = new RegExp('\\s\\s+', 'g'); 164 165 $.fn.flipster = function(options) { 166 var isMethodCall = (typeof options === 'string' ? true : false); 167 168 if ( isMethodCall ) { 169 var args = Array.prototype.slice.call(arguments, 1); 170 return this.each(function() { 171 var methods = $(this).data('methods'); 172 if ( methods[options] ) { 173 return methods[options].apply(this, args); 174 } else { 175 return this; 176 } 177 }); 178 } 179 180 var settings = $.extend({}, defaults, options); 181 182 return this.each(function() { 183 184 var self = $(this), 185 methods, 186 187 _container, 188 _containerWidth, 189 190 _items, 191 _itemOffsets = [], 192 _currentItem, 193 _currentIndex = 0, 194 195 _nav, 196 _navItems, 197 _navLinks, 198 199 _playing = false, 200 _startDrag = false, 201 _isItemClicked = false; 202 203 function buildButtonContent(dir) { 204 var text = ( dir === 'next' ? settings.buttonNext : settings.buttonPrev ); 205 206 if ( settings.buttons === 'custom' || !svgSupport ) { return text; } 207 208 return '<svg viewBox="0 0 13 20" xmlns="' + svgNS + '" aria-labelledby="title"><title>' + text + '</title><polyline points="10,3 3,10 10,17"' + (dir === 'next' ? ' transform="rotate(180 6.5,10)"' : '') + '/></svg>'; 209 } 210 211 function buildButton(dir) { 212 dir = dir || 'next'; 213 214 return $('<button class="' + classes.button + ' ' + ( dir === 'next' ? classes.buttonNext : classes.buttonPrev ) + '" role="button" />') 215 .html(buildButtonContent(dir)) 216 .on('click', function(e) { 217 jump(dir); 218 e.preventDefault(); 219 }); 220 221 } 222 223 function buildButtons() { 224 if ( settings.buttons && _items.length > 1 ) { 225 self.find('.' + classes.button).remove(); 226 self.append(buildButton('prev'), buildButton('next')); 227 } 228 } 229 230 function buildNav() { 231 var navCategories = {}; 232 233 if ( !settings.nav || _items.length <= 1 ) { return; } 234 235 if ( _nav ) { _nav.remove(); } 236 237 _nav = $('<ul class="' + classes.nav + '" role="navigation" />'); 238 _navLinks = $(''); 239 240 _items.each(function(i) { 241 var item = $(this), 242 category = item.data('flip-category'), 243 itemTitle = item.data('flip-title') || item.attr('title') || i, 244 navLink = $('<a href="#" class="' + classes.navLink + '">' + itemTitle + '</a>') 245 .data('index', i); 246 247 _navLinks = _navLinks.add(navLink); 248 249 if ( category ) { 250 251 if ( !navCategories[category] ) { 252 253 var categoryItem = $('<li class="' + classes.navItem + ' ' + classes.navCategory + '">'); 254 var categoryLink = $('<a href="#" class="' + classes.navLink + ' ' + classes.navCategoryLink + '" data-flip-category="' + category + '">' + category + '</a>') 255 .data('category', category) 256 .data('index', i); 257 258 navCategories[category] = $('<ul class="' + classes.navChild + '" />'); 259 260 _navLinks = _navLinks.add(categoryLink); 261 262 categoryItem 263 .append(categoryLink, navCategories[category]) 264 .appendTo(_nav); 265 } 266 267 navCategories[category].append(navLink); 268 } else { 269 _nav.append(navLink); 270 } 271 272 navLink.wrap('<li class="' + classes.navItem + '">'); 273 274 }); 275 276 _nav.on('click', 'a', function(e) { 277 var index = $(this).data('index'); 278 if ( index >= 0 ) { 279 jump(index); 280 e.preventDefault(); 281 } 282 }); 283 284 if ( settings.nav === 'after' ) { self.append(_nav); } 285 else { self.prepend(_nav); } 286 287 _navItems = _nav.find('.' + classes.navItem); 288 } 289 290 function updateNav() { 291 if ( settings.nav ) { 292 293 var category = _currentItem.data('flip-category'); 294
295 _navItems.removeClass(classes.navCurrent); 296 297 _navLinks 298 .filter(function() { 299 return ($(this).data('index') === _currentIndex || (category && $(this).data('category') === category)); 300 }) 301 .parent() 302 .addClass(classes.navCurrent); 303 304 } 305 } 306 307 function noTransition() { 308 self.css('transition', 'none'); 309 _container.css('transition', 'none'); 310 _items.css('transition', 'none'); 311 } 312 313 function resetTransition() { 314 self.css('transition', ''); 315 _container.css('transition', ''); 316 _items.css('transition', ''); 317 } 318 319 function calculateBiggestItemHeight() { 320 var biggestHeight = 0, 321 itemHeight; 322 323 _items.each(function() { 324 itemHeight = $(this).height(); 325 if ( itemHeight > biggestHeight ) { biggestHeight = itemHeight; } 326 }); 327 return biggestHeight; 328 } 329 330 function resize(skipTransition) { 331 332 //check for hidden parents 333 334 if(hasHiddenParent() == true) 335 return(false); 336 337 if ( skipTransition ) { noTransition(); } 338 339 _containerWidth = _container.width(); 340 341 _container.height(calculateBiggestItemHeight()); 342 343 _items.each(function(i) { 344 var item = $(this), 345 width, 346 left; 347 348 item.attr('class', function(i, c) { 349 return c && c.replace(classRemover, '').replace(whiteSpaceRemover, ' '); 350 }); 351 352 width = item.outerWidth(); 353 354 if ( settings.spacing !== 0 ) { 355 item.css('margin-right', ( width * settings.spacing ) + 'px'); 356 } 357 358 left = item.position().left; 359 _itemOffsets[i] = -1 * ((left + (width / 2)) - (_containerWidth / 2)); 360 361 if ( i === _items.length - 1 ) { 362 center(); 363 if ( skipTransition ) { setTimeout(resetTransition, 1); } 364 } 365 }); 366 } 367 368 function center() { 369 var total = _items.length, 370 loopCount = ( settings.loop !== true && settings.loop > 0 ? settings.loop : false ), 371 item, newClass, zIndex, past, offset; 372 373 if ( _currentIndex >= 0 ) { 374 375 _items.each(function(i) { 376 item = $(this); 377 newClass = ' '; 378 379 if ( i === _currentIndex ) { 380 newClass += classes.itemCurrent; 381 zIndex = (total + 2); 382 } else { 383 past = ( i < _currentIndex ? true : false ); 384 offset = ( past ? _currentIndex - i : i - _currentIndex ); 385 386 if ( loopCount ) { 387 if ( _currentIndex <= loopCount && i > _currentIndex + loopCount ) { 388 past = true; 389 offset = (total + _currentIndex) - i; 390 } else if ( _currentIndex >= total - loopCount && i < _currentIndex - loopCount ) { 391 past = false; 392 offset = (total - _currentIndex) + i; 393 } 394 } 395 396 newClass += (past ? 397 classes.itemPast + ' ' + classes.itemPast + '-' + offset : 398 classes.itemFuture + ' ' + classes.itemFuture + '-' + offset 399 ); 400 401 zIndex = total - offset; 402 } 403 404 item 405 .css('z-index', zIndex * 2) 406 .attr('class', function(i, c) { 407 return c && c.replace(classRemover, '').replace(whiteSpaceRemover, ' ') + newClass; 408 }); 409 }); 410 411 if ( !_containerWidth || _itemOffsets[_currentIndex] === undefined ) { resize(true); } 412 413 if ( transformSupport ) { 414 _container.css('transform', 'translateX(' + _itemOffsets[_currentIndex] + 'px)'); 415 } else { 416 _container.css('left', _itemOffsets[_currentIndex] + 'px' ); 417 } 418 } 419 420 updateNav(); 421 } 422 423 function jump(to) {
424 var _previous = _currentIndex; 425 426 if ( _items.length <= 1 ) { return; } 427 428 if ( to === 'prev' ) { 429 if ( _currentIndex > 0 ) { _currentIndex--; } 430 else if ( settings.loop ) { _currentIndex = _items.length - 1; } 431 } else if ( to === 'next' ) { 432 if ( _currentIndex < _items.length - 1 ) { _currentIndex++; } 433 else if ( settings.loop ) { _currentIndex = 0; } 434 } else if ( typeof to === 'number' ) { _currentIndex = to; 435 } else if ( to !== undefined ) { 436 // if object is sent, get its index 437 _currentIndex = _items.index(to); 438 } 439 440 _currentItem = _items.eq(_currentIndex); 441 442 if ( _currentIndex !== _previous && settings.onItemSwitch ) { 443 settings.onItemSwitch.call(self, _items[_currentIndex], _items[_previous]); 444 } 445 446 center(); 447 448 return self; 449 } 450 451 function play(interval) { 452 settings.autoplay = interval || settings.autoplay; 453 454 clearInterval(_playing); 455 456 _playing = setInterval(function() { 457 var prev = _currentIndex; 458 jump('next'); 459 if ( prev === _currentIndex && !settings.loop ) { clearInterval(_playing); } 460 }, settings.autoplay); 461 462 return self; 463 } 464 465 function pause() { 466 clearInterval(_playing); 467 if ( settings.autoplay ) { _playing = -1; } 468 469 return self; 470 } 471 472 function show() { 473 resize(true); 474 self.hide() 475 .css('visibility', '')
476 .addClass(classes.active) 477 .fadeIn(settings.fadeIn); 478 } 479 480 function index() { 481 482 _container = self.find(settings.itemContainer).addClass(classes.container); 483 484 _items = _container.find(settings.itemSelector); 485 486 if ( _items.length <= 1 ) { return; } 487 488 _items 489 .addClass(classes.item) 490 // Wrap inner content 491 .each(function() { 492 var item = $(this); 493 if ( !item.children('.' + classes.itemContent ).length) { 494 item.wrapInner('<div class="' + classes.itemContent + '" />'); 495 } 496 }); 497 498 // Navigate directly to an item by clicking 499 if ( settings.click ) { 500 _items.on('click.flipster touchend.flipster', function(e) { 501 502 if ( !_startDrag ) { 503 if ( !$(this).hasClass(classes.itemCurrent) ) { e.preventDefault(); } 504 jump(this); 505 } 506 }); 507 } 508 509 // Insert navigation if enabled. 510 buildButtons(); 511 buildNav(); 512 513 if ( _currentIndex >= 0 ) { jump(_currentIndex); } 514 515 return self; 516 } 517 518 function keyboardEvents(elem) { 519 if ( settings.keyboard ) { 520 elem[0].tabIndex = 0; 521 elem.on('keydown.flipster', throttle(function(e) { 522 var code = e.which; 523 if ( code === 37 || code === 39 ) { 524 jump( code === 37 ? 'prev' : 'next' ); 525 e.preventDefault(); 526 } 527 }, 250, true)); 528 } 529 } 530 531 function wheelEvents(elem) { 532 if ( settings.scrollwheel ) { 533 var _wheelInside = false, 534 _actionThrottle = 0, 535 _throttleTimeout = 0, 536 _delta = 0, 537 _dir, _lastDir; 538 539 elem 540 .on('mousewheel.flipster wheel.flipster', function() { _wheelInside = true; }) 541 .on('mousewheel.flipster wheel.flipster', throttle(function(e) { 542 543 // Reset after a period without scrolling. 544 clearTimeout(_throttleTimeout); 545 _throttleTimeout = setTimeout(function() { 546 _actionThrottle = 0; 547 _delta = 0; 548 }, 300); 549 550 e = e.originalEvent; 551 552 // Add to delta (+=) so that continuous small events can still get past the speed limit, and quick direction reversals get cancelled out 553 _delta += (e.wheelDelta || (e.deltaY + e.deltaX) * -1); // Invert numbers for Firefox 554 555 // Don't trigger unless the scroll is decent speed. 556 if ( Math.abs(_delta) < 25 ) { return; } 557 558 _actionThrottle++; 559 560 _dir = (_delta > 0 ? 'prev' : 'next'); 561 562 // Reset throttle if direction changed. 563 if ( _lastDir !== _dir ) { _actionThrottle = 0; } 564 _lastDir = _dir; 565 566 // Regular scroll wheels trigger less events, so they don't need to be throttled. Trackpads trigger many events (inertia), so only trigger jump every three times to slow things down. 567 if ( _actionThrottle < 6 || _actionThrottle % 3 === 0 ) { jump(_dir); } 568 569 _delta = 0; 570 571 }, 50)); 572 573 // Disable mousewheel on window if event began in elem. 574 elem.on('mousewheel.flipster wheel.flipster', function(e) { 575 if ( _wheelInside ) { 576 e.preventDefault(); 577 _wheelInside = false;
578 } 579 }); 580 } 581 } 582 583 function touchEvents(elem) { 584 585 if ( settings.touch ) { 586 587 var _startDragY, _startDragX = false, 588 _touchJump = throttle(jump, 300), 589 x, y, offsetY, offsetX; 590 591 var lastPosition = _itemOffsets[_currentIndex]; 592 var isMousePressed = false; 593 594 elem.on({ 595 596 'touchstart.flipster': function(e) { 597 598 e = e.originalEvent; 599 _startDragX = (e.touches ? e.touches[0].clientX : e.clientX); 600 _startDragY = (e.touches ? e.touches[0].clientY : e.clientY); 601 //e.preventDefault(); 602 lastPosition = _itemOffsets[_currentIndex]; 603 _isItemClicked = true; 604 }, 605 606 'touchmove.flipster': function(e) { 607 608 if ( _startDragX !== false ) { 609 e = e.originalEvent; 610 611 x = (e.touches ? e.touches[0].clientX : e.clientX); 612 y = (e.touches ? e.touches[0].clientY : e.clientY); 613 offsetY = y - _startDragY; 614 offsetX = x - _startDragX; 615 616 if(settings.style != 'flat'){ 617 618 if ( Math.abs(offsetY) < 100 && Math.abs(offsetX) >= 30 ) { 619 _touchJump((offsetX < 0 ? 'next' : 'prev')); 620 _startDragX = x; 621 // e.preventDefault(); 622 } 623 624 } 625 626 //swipe settings 627 if(settings.style == 'flat'){ 628 629 if ( Math.abs(offsetY) < 100 && Math.abs(offsetX) >= 30) { 630 631 // e.preventDefault(); 632 633 _container.css('transform', 'translateX(' + (lastPosition + offsetX) + 'px)'); 634 _container.css('transition', '0s'); 635 _isItemClicked = false; 636 637 } 638 639 } 640 641 } 642 }, 643 644 'touchend.flipster touchcancel.flipster ': function() { 645 646 //swipe settings 647 if(settings.style == 'flat'){ 648 649 if(Math.abs(offsetX) >= 30){ 650 651 lastPosition += offsetX; 652 653 var closestItemCoord = _itemOffsets.reduce((a, b) => { 654 return Math.abs(b - lastPosition) < Math.abs(a - lastPosition) ? b : a; 655 }); 656 657 var selectedIndex = _itemOffsets.indexOf(closestItemCoord) 658 659 if(_isItemClicked == false) 660 jump(selectedIndex); 661 662 _container.css('transition', ''); 663 lastPosition = closestItemCoord; 664 665 } 666 667 } 668 669 _startDragX = false; 670 671 }, 672 673 674 675 }); 676 677 elem.parents('.'+classes.main).on({ 678 679 'mousedown.flipster': function(e) { 680 681 var objTarget = jQuery(e.target); 682 var isButtonClicked = objTarget.hasClass(classe
682s.button) || objTarget.parents().hasClass(classes.button); 683 684 if(isButtonClicked == false){ 685 686 _isItemClicked = true; 687 688 e = e.originalEvent; 689 _startDragX = e.clientX; 690 _startDragY = e.clientY; 691 692 isMousePressed = true; 693 lastPosition = _itemOffsets[_currentIndex]; 694 695 e.preventDefault(); 696 697 _items.css('cursor', 'grab'); 698 699 } 700 701 }, 702 703 'mousemove.flipster': function(e) { 704 705 var objTarget = jQuery(e.target); 706 var isButtonClicked = objTarget.hasClass(classes.button) || objTarget.parents().hasClass(classes.button); 707 708 if(isButtonClicked == false){ 709 710 if ( _startDragX !== false ) { 711 e = e.originalEvent; 712 713 x = e.clientX; 714 y = e.clientY; 715 offsetY = y - _startDragY; 716 offsetX = x - _startDragX; 717 718 //drag settings 719 if(settings.style == 'flat'){ 720 721 if ( Math.abs(offsetY) < 100 && Math.abs(offsetX) >= 30) { 722 723 e.preventDefault(); 724 725 _container.css('transform', 'translateX(' + (lastPosition + offsetX) + 'px)'); 726 727 _container.css('transition', '0s'); 728 729 _isItemClicked = false; 730 731 } 732 733 } 734 735 } 736 737 } 738 }, 739 740 'mouseup.flipster': function(e) { 741 742 var objTarget = jQuery(e.target); 743 var isButtonClicked = objTarget.hasClass(classe
743s.button) || objTarget.parents().hasClass(classes.button); 744 745 //swipe settings 746 if(settings.style == 'flat' && isButtonClicked == false){ 747 748 if(isMousePressed == true && Math.abs(offsetX) >= 30){ 749 750 lastPosition += offsetX; 751 752 var closestItemCoord = _itemOffsets.reduce((a, b) => { 753 return Math.abs(b - lastPosition) < Math.abs(a - lastPosition) ? b : a; 754 }); 755 756 var selectedIndex = _itemOffsets.indexOf(closestItemCoord); 757 758 _items.css('cursor', ''); 759 _container.css('transition', ''); 760 761 if(_isItemClicked == false) 762 jump(selectedIndex); 763 764 lastPosition = closestItemCoord; 765 766 isMousePressed = false; 767 768 } 769 770 _startDragX = false; 771 } 772 773 774 }, 775 776 'mouseleave.flipster': function() { 777 778 //swipe settings 779 if(settings.style == 'flat'){ 780 781 if(isMousePressed == true && Math.abs(offsetX) >= 30){ 782 783 _container.css('transform', 'translateX(' + lastPosition + 'px)'); 784 785 _items.css('cursor', ''); 786 _container.css('transition', ''); 787 788 isMousePressed = false; 789 790 } 791 792 _startDragX = false; 793 } 794 795 796 }, 797 798 }); 799 } 800 } 801 802 /* 803 * potection from hidden parent 804 */ 805 function hasHiddenParent(){ 806 807 var objParents = self.parents(); 808 var hasHiddenParent = false; 809 810 objParents.each(function(){ 811 812 var objParent = jQuery(this); 813 var isParentVisible = objParent.is(":visible"); 814 815 if(isParentVisible == false) 816 hasHiddenParent = true; 817 818 }); 819 820 return(hasHiddenParent); 821 822 } 823 824 function init() { 825 826 var style; 827 828 self.css('visibility', 'hidden'); 829 830 index(); 831 832 if ( _items.length <= 1 ) { 833 self.css('visibility', ''); 834 return; 835 } 836 837 style = (settings.style ? 'flipster--' + settings.style.split(' ').join(' flipster--') : false); 838 839 self.addClass([ 840 classes.main, 841 (transformSupport ? 'flipster--transform' : ' flipster--no-transform'), 842 style, // 'flipster--'+settings.style : '' ), 843 (settings.click ? 'flipster--click' : '') 844 ].join(' ')); 845 846 // Set the starting item 847 if ( settings.start ) { 848 // Find the middle item if start = center 849 _currentIndex = ( settings.start === 'center' ? Math.floor(_items.length / 2) : settings.start ); 850 } 851 852 jump(_currentIndex); 853 854 var images = self.find('img'); 855 856 if ( images.length ) { 857 var imagesLoaded = 0; 858 859 // Resize after all images have loaded. 860 images.on('load', function() { 861 imagesLoaded++; 862 if ( imagesLoaded >= images.length ) { show(); } 863 }); 864 865 // Fallback to show Flipster while images load in case it takes a while. 866 setTimeout(show, 750); 867 } else { 868 show(); 869 } 870 871 // Attach event bindings. 872 $window.on('resize.flipster', throttle(resize, 400)); 873 874 if ( settings.autoplay ) { play(); } 875 876 if ( settings.pauseOnHover ) { 877 _container 878 .on('mouseenter.flipster', pause) 879 .on('mouseleave.flipster', function() { 880 if ( _playing === -1 ) { play(); } 881 }); 882 } 883 884 keyboardEvents(self); 885 wheelEvents(_container); 886 touchEvents(_container); 887 } 888 889 // public methods 890 methods = { 891 jump: jump, 892 next: function() { return jump('next'); }, 893 prev: function() { return jump('prev'); }, 894 play: play, 895 pause: pause, 896 index: index 897 }; 898 self.data('methods', methods); 899 900 // Initialize if flipster is not already active.
901 if ( !self.hasClass(classes.active) ) { init(); } 902 903 }); 904 }; 905})(jQuery, window); 906
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.