vendor: 93,489 bytes, lines 1-3446
1/** 2 * Owl Carousel v2.3.4 3 * Copyright 2013-2018 David Deutsch 4 * Licensed under: SEE LICENSE IN https://github.com/OwlCarousel2/OwlCarousel2/blob/master/LICENSE 5 */ 6/** 7 * Owl carousel 8 * @version 2.3.4 9 * @author Bartosz Wojciechowski 10 * @author David Deutsch 11 * @license The MIT License (MIT) 12 * @todo Lazy Load Icon 13 * @todo prevent animationend bubling 14 * @todo itemsScaleUp 15 * @todo Test Zepto 16 * @todo stagePadding calculate wrong active classes 17 */ 18;(function($, window, document, undefined) { 19 20 /** 21 * Creates a carousel. 22 * @class The Owl Carousel. 23 * @public 24 * @param {HTMLElement|jQuery} element - The element to create the carousel for. 25 * @param {Object} [options] - The options 26 */ 27 function Owl(element, options) { 28 29 /** 30 * Current settings for the carousel. 31 * @public 32 */ 33 this.settings = null; 34 35 /** 36 * Current options set by the caller including defaults. 37 * @public 38 */ 39 this.options = $.extend({}, Owl.Defaults, options); 40 41 /** 42 * Plugin element. 43 * @public 44 */ 45 this.$element = $(element); 46 47 /** 48 * Proxied event handlers. 49 * @protected 50 */ 51 this._handlers = {}; 52 53 /** 54 * References to the running plugins of this carousel. 55 * @protected 56 */ 57 this._plugins = {}; 58 59 /** 60 * Currently suppressed events to prevent them from being retriggered. 61 * @protected 62 */ 63 this._supress = {}; 64 65 /** 66 * Absolute current position. 67 * @protected 68 */ 69 this._current = null; 70 71 /** 72 * Animation speed in milliseconds. 73 * @protected 74 */ 75 this._speed = null; 76 77 /** 78 * Coordinates of all items in pixel. 79 * @todo The name of this member is missleading. 80 * @protected 81 */ 82 this._coordinates = []; 83 84 /** 85 * Current breakpoint. 86 * @todo Real media queries would be nice. 87 * @protected 88 */ 89 this._breakpoint = null; 90 91 /** 92 * Current width of the plugin element. 93 */ 94 this._width = null; 95 96 /** 97 * All real items. 98 * @protected 99 */ 100 this._items = []; 101 102 /** 103 * All cloned items. 104 * @protected 105 */ 106 this._clones = []; 107 108 /** 109 * Merge values of all items. 110 * @todo Maybe this could be part of a plugin. 111 * @protected 112 */ 113 this._mergers = []; 114 115 /** 116 * Widths of all items. 117 */ 118 this._widths = []; 119 120 /** 121 * Invalidated parts within the update process. 122 * @protected 123 */ 124 this._invalidated = {}; 125 126 /** 127 * Ordered list of workers for the update process. 128 * @protected 129 */ 130 this._pipe = []; 131 132 /** 133 * Current state information for the drag operation. 134 * @todo #261 135 * @protected 136 */ 137 this._drag = { 138 time: null, 139 target: null, 140 pointer: null, 141 stage: { 142 start: null, 143 current: null 144 }, 145 direction: null 146 }; 147 148 /** 149 * Current state information and their tags. 150 * @type {Object} 151 * @protected 152 */ 153 this._states = { 154 current: {}, 155 tags: { 156 'initializing': [ 'busy' ], 157 'animating': [ 'busy' ], 158 'dragging': [ 'interacting' ] 159 } 160 }; 161 162 $.each([ 'onResize', 'onThrottledResize' ], $.proxy(function(i, handler) { 163 this._handlers[handler] = $.proxy(this[handler], this); 164 }, this)); 165 166 $.each(Owl.Plugins, $.proxy(function(key, plugin) { 167 this._plugins[key.charAt(0).toLowerCase() + key.slice(1)] 168 = new plugin(this); 169 }, this)); 170 171 $.each(Owl.Workers, $.proxy(function(priority, worker) { 172 this._pipe.push({ 173 'filter': worker.filter, 174 'run': $.proxy(worker.run, this) 175 }); 176 }, this)); 177 178 this.setup(); 179 this.initialize(); 180 } 181 182 /** 183 * Default options for the carousel. 184 * @public 185 */ 186 Owl.Defaults = { 187 items: 3, 188 loop: false, 189 center: false, 190 rewind: false, 191 checkVisibility: true, 192 193 mouseDrag: true, 194 touchDrag: true, 195 pullDrag: true, 196 freeDrag: false, 197 198 margin: 0, 199 stagePadding: 0, 200 201 merge: false, 202 mergeFit: true, 203 autoWidth: false, 204 205 startPosition: 0, 206 rtl: false, 207 208 smartSpeed: 250, 209 fluidSpeed: false, 210 dragEndSpeed: false, 211 212 responsive: {}, 213 responsiveRefreshRate: 200, 214 responsiveBaseElement: window, 215 216 fallbackEasing: 'swing', 217 slideTransition: '', 218 219 info: false, 220 221 nestedItemSelector: false, 222 itemElement: 'div', 223 stageElement: 'div', 224 225 refreshClass: 'owl-refresh', 226 loadedClass: 'owl-loaded', 227 loadingClass: 'owl-loading', 228 rtlClass: 'owl-rtl', 229 responsiveClass: 'owl-responsive', 230 dragClass: 'owl-drag', 231 itemClass: 'owl-item', 232 stageClass: 'owl-stage', 233 stageOuterClass: 'owl-stage-outer', 234 grabClass: 'owl-grab' 235 }; 236 237 /** 238 * Enumeration for width. 239 * @public 240 * @readonly 241 * @enum {String} 242 */ 243 Owl.Width = { 244 Default: 'default', 245 Inner: 'inner', 246 Outer: 'outer' 247 }; 248 249 250 251 /** 252 * Enumeration for types. 253 * @public 254 * @readonly 255 * @enum {String} 256 */ 257 Owl.Type = { 258 Event: 'event', 259 State: 'state' 260 }; 261 262 /** 263 * Contains all registered plugins. 264 * @public 265 */ 266 Owl.Plugins = {}; 267 268 /** 269 * List of workers involved in the update process. 270 */ 271 Owl.Workers = [ { 272 filter: [ 'width', 'settings' ], 273 run: function() { 274 this._width = this.$element.width(); 275 } 276 }, { 277 filter: [ 'width', 'items', 'settings' ], 278 run: function(cache) { 279 cache.current = this._items && this._items[this.relative(this._current)]; 280 } 281 }, { 282 filter: [ 'items', 'settings' ], 283 run: function() { 284 this.$stage.children('.cloned').remove(); 285 } 286 }, { 287 filter: [ 'width', 'items', 'settings' ], 288 run: function(cache) { 289 var margin = this.settings.margin || '', 290 grid = !this.settings.autoWidth, 291 rtl = this.settings.rtl, 292 css = { 293 'width': 'auto', 294 'margin-left': rtl ? margin : '', 295 'margin-right': rtl ? '' : margin 296 }; 297 298 !grid && this.$stage.children().css(css); 299 300 cache.css = css; 301 } 302 }, { 303 filter: [ 'width', 'items', 'settings' ], 304 run: function(cache) { 305 var width = (this.width() / this.settings.items).toFixed(3) - this.settings.margin, 306 merge = null, 307 iterator = this._items.length, 308 grid = !this.settings.autoWidth, 309 widths = []; 310 311 cache.items = { 312 merge: false, 313 width: width 314 }; 315 316 while (iterator--) { 317 merge = this._mergers[iterator]; 318 merge = this.settings.mergeFit && Math.min(merge, this.settings.items) || merge; 319 320 cache.items.merge = merge > 1 || cache.items.merge; 321 322 widths[iterator] = !grid ? this._items[iterator].width() : width * merge; 323 } 324 325 this._widths = widths; 326 } 327 }, { 328 filter: [ 'items', 'settings' ], 329 run: function() { 330 var clones = [], 331 items = this._items, 332 settings = this.settings, 333 // TODO: Should be computed from number of min width items in stage 334 view = Math.max(settings.items * 2, 4), 335 size = Math.ceil(items.length / 2) * 2, 336 repeat = settings.loop && items.length ? settings.rewind ? view : Math.max(view, size) : 0, 337 append = '', 338 prepend = ''; 339 340 repeat /= 2; 341 342 while (repeat > 0) { 343 // Switch to only using appended clones 344 clones.push(this.normalize(clones.length / 2, true)); 345 append = append + items[clones[clones.length - 1]][0].outerHTML; 346 clones.push(this.normalize(items.length - 1 - (clones.length - 1) / 2, true)); 347 prepend = items[clones[clones.length - 1]][0].outerHTML + prepend; 348 repeat -= 1; 349 } 350 351 this._clones = clones; 352 353 $(append).addClass('cloned').appendTo(this.$stage); 354 $(prepend).addClass('cloned').prependTo(this.$stage); 355 } 356 }, { 357 filter: [ 'width', 'items', 'settings' ], 358 run: function() { 359 var rtl = this.settings.rtl ? 1 : -1, 360 size = this._clones.length + this._items.length, 361 iterator = -1, 362 previous = 0, 363 current = 0, 364 coordinates = []; 365 366 while (++iterator < size) { 367 previous = coordinates[iterator - 1] || 0; 368 current = this._widths[this.relative(iterator)] + this.settings.margin; 369 coordinates.push(previous + current * rtl); 370 } 371 372 this._coordinates = coordinates; 373 } 374 }, { 375 filter: [ 'width', 'items', 'settings' ], 376 run: function() { 377 var padding = this.settings.stagePadding, 378 coordinates = this._coordinates, 379 css = { 380 'width': Math.ceil(Math.abs(coordinates[coordinates.length - 1])) + padding * 2, 381 'padding-left': padding || '', 382 'padding-right': padding || '' 383 }; 384 385 this.$stage.css(css); 386 } 387 }, { 388 filter: [ 'width', 'items', 'settings' ], 389 run: function(cache) { 390 var iterator = this._coordinates.length, 391 grid = !this.settings.autoWidth, 392 items = this.$stage.children(); 393 394 if (grid && cache.items.merge) { 395 while (iterator--) { 396 cache.css.width = this._widths[this.relative(iterator)]; 397 items.eq(iterator).css(cache.css); 398 } 399 } else if (grid) { 400 cache.css.width = cache.items.width; 401 items.css(cache.css); 402 } 403 } 404 }, { 405 filter: [ 'items' ], 406 run: function() { 407 this._coordinates.length < 1 && this.$stage.removeAttr('style'); 408 } 409 }, { 410 filter: [ 'width', 'items', 'settings' ], 411 run: function(cache) { 412 cache.current = cache.current ? this.$stage.children().index(cache.current) : 0; 413 cache.current = Math.max(this.minimum(), Math.min(this.maximum(), cache.current)); 414 this.reset(cache.current); 415 } 416 }, { 417 filter: [ 'position' ], 418 run: function() { 419 this.animate(this.coordinates(this._current)); 420 } 421 }, { 422 filter: [ 'width', 'position', 'items', 'settings' ], 423 run: function() { 424 var rtl = this.settings.rtl ? 1 : -1, 425 padding = this.settings.stagePadding * 2, 426 begin = this.coordinates(this.current()) + padding, 427 end = begin + this.width() * rtl, 428 inner, outer, matches = [], i, n; 429 430 for (i = 0, n = this._coordinates.length; i < n; i++) { 431 inner = this._coordinates[i - 1] || 0; 432 outer = Math.abs(this._coordinates[i]) + padding * rtl; 433 434 if ((this.op(inner, '<=', begin) && (this.op(inner, '>', end))) 435 || (this.op(outer, '<', begin) && this.op(outer, '>', end))) { 436 matches.push(i); 437 } 438 } 439 440 this.$stage.children('.active').removeClass('active'); 441 this.$stage.children(':eq(' + matches.join('), :eq(') + ')').addClass('active'); 442 443 this.$stage.children('.center').removeClass('center'); 444 if (this.settings.center) { 445 this.$stage.children().eq(this.current()).addClass('center'); 446 } 447 } 448 } ]; 449 450 /** 451 * Create the stage DOM element 452 */ 453 Owl.prototype.initializeStage = function() { 454 this.$stage = this.$element.find('.' + this.settings.stageClass); 455 456 // if the stage is already in the DOM, grab it and skip stage initialization 457 if (this.$stage.length) { 458 return; 459 } 460 461 this.$element.addClass(this.options.loadingClass); 462 463 // create stage 464 this.$stage = $('<' + this.settings.stageElement + '>', { 465 "class": this.settings.stageClass 466 }).wrap( $( '<div/>', { 467 "class": this.settings.stageOuterClass 468 })); 469 470 // append stage 471 this.$element.append(this.$stage.parent()); 472 }; 473 474 /** 475 * Create item DOM elements 476 */ 477 Owl.prototype.initializeItems = function() { 478 var $items = this.$element.find('.owl-item'); 479 480 // if the items are already in the DOM, grab them and skip item initialization 481 if ($items.length) { 482 this._items = $items.get().map(function(item) { 483 return $(item); 484 }); 485 486 this._mergers = this._items.map(function() { 487 return 1; 488 }); 489 490 this.refresh(); 491 492 return; 493 } 494 495 // append content 496 this.replace(this.$element.children().not(this.$stage.parent())); 497 498 // check visibility 499 if (this.isVisible()) { 500 // update view 501 this.refresh(); 502 } else { 503 // invalidate width 504 this.invalidate('width'); 505 } 506 507 this.$element 508 .removeClass(this.options.loadingClass) 509 .addClass(this.options.loadedClass); 510 }; 511 512 /** 513 * Initializes the carousel. 514 * @protected 515 */ 516 Owl.prototype.initialize = function() { 517 this.enter('initializing'); 518 this.trigger('initialize'); 519 520 this.$element.toggleClass(this.settings.rtlClass, this.settings.rtl); 521 522 if (this.settings.autoWidth && !this.is('pre-loading')) { 523 var imgs, nestedSelector, width; 524 imgs = this.$element.find('img'); 525 nestedSelector = this.settings.nestedItemSelector ? '.' + this.settings.nestedItemSelector : undefined; 526 width = this.$element.children(nestedSelector).width(); 527 528 if (imgs.length && width <= 0) { 529 this.preloadAutoWidthImages(imgs); 530 } 531 } 532 533 this.initializeStage(); 534 this.initializeItems(); 535 536 // register event handlers 537 this.registerEventHandlers(); 538 539 this.leave('initializing'); 540 this.trigger('initialized'); 541 }; 542 543 /** 544 * @returns {Boolean} visibility of $element 545 * if you know the carousel will always be visible you can set `checkVisibility` to `false` to 546 * prevent the expensive browser layout forced reflow the $element.is(':visible') does 547 */ 548 Owl.prototype.isVisible = function() { 549 return this.settings.checkVisibility 550 ? this.$element.is(':visible') 551 : true; 552 }; 553 554 /** 555 * Setups the current settings. 556 * @todo Remove responsive classes. Why should adaptive designs be brought into IE8? 557 * @todo Support for media queries by using `matchMedia` would be nice. 558 * @public 559 */ 560 Owl.prototype.setup = function() { 561 var viewport = this.viewport(), 562 overwrites = this.options.responsive, 563 match = -1, 564 settings = null; 565 566 if (!overwrites) { 567 settings = $.extend({}, this.options); 568 } else { 569 $.each(overwrites, function(breakpoint) { 570 if (breakpoint <= viewport && breakpoint > match) { 571 match = Number(breakpoint); 572 } 573 }); 574 575 settings = $.extend({}, this.options, overwrites[match]); 576 if (typeof settings.stagePadding === 'function') { 577 settings.stagePadding = settings.stagePadding(); 578 } 579 delete settings.responsive; 580 581 // responsive class 582 if (settings.responsiveClass) { 583 this.$element.attr('class', 584 this.$element.attr('class').replace(new RegExp('(' + this.options.responsiveClass + '-)\\S+\\s', 'g'), '$1' + match) 585 ); 586 } 587 } 588 589 this.trigger('change', { property: { name: 'settings', value: settings } }); 590 this._breakpoint = match; 591 this.settings = settings; 592 this.invalidate('settings'); 593 this.trigger('changed', { property: { name: 'settings', value: this.settings } }); 594 }; 595 596 /** 597 * Updates option logic if necessery. 598 * @protected 599 */ 600 Owl.prototype.optionsLogic = function() { 601 if (this.settings.autoWidth) { 602 this.settings.stagePadding = false; 603 this.settings.merge = false; 604 } 605 }; 606 607 /** 608 * Prepares an item before add. 609 * @todo Rename event parameter `content` to `item`. 610 * @protected 611 * @returns {jQuery|HTMLElement} - The item container. 612 */ 613 Owl.prototype.prepare = function(item) { 614 var event = this.trigger('prepare', { content: item }); 615 616 if (!event.data) { 617 event.data = $('<' + this.settings.itemElement + '/>') 618 .addClass(this.options.itemClass).append(item) 619 } 620 621 this.trigger('prepared', { content: event.data }); 622 623 return event.data; 624 }; 625 626 /** 627 * Updates the view. 628 * @public 629 */ 630 Owl.prototype.update = function() { 631 var i = 0, 632 n = this._pipe.length, 633 filter = $.proxy(function(p) { return this[p] }, this._invalidated), 634 cache = {}; 635 636 while (i < n) { 637 if (this._invalidated.all || $.grep(this._pipe[i].filter, filter).length > 0) { 638 this._pipe[i].run(cache); 639 } 640 i++; 641 } 642 643 this._invalidated = {}; 644 645 !this.is('valid') && this.enter('valid'); 646 }; 647 648 /** 649 * Gets the width of the view. 650 * @public 651 * @param {Owl.Width} [dimension=Owl.Width.Default] - The dimension to return. 652 * @returns {Number} - The width of the view in pixel. 653 */ 654 Owl.prototype.width = function(dimension) { 655 dimension = dimension || Owl.Width.Default; 656 switch (dimension) { 657 case Owl.Width.Inner: 658 case Owl.Width.Outer: 659 return this._width; 660 default: 661 return this._width - this.settings.stagePadding * 2 + this.settings.margin; 662 } 663 }; 664 665 /** 666 * Refreshes the carousel primarily for adaptive purposes. 667 * @public 668 */ 669 Owl.prototype.refresh = function() { 670 this.enter('refreshing'); 671 this.trigger('refresh'); 672 673 this.setup(); 674 675 this.optionsLogic(); 676 677 this.$element.addClass(this.options.refreshClass); 678 679 this.update(); 680 681 this.$element.removeClass(this.options.refreshClass); 682 683 this.leave('refreshing'); 684 this.trigger('refreshed'); 685 }; 686 687 /** 688 * Checks window `resize` event. 689 * @protected 690 */ 691 Owl.prototype.onThrottledResize = function() { 692 window.clearTimeout(this.resizeTimer); 693 this.resizeTimer = window.setTimeout(this._handlers.onResize, this.settings.responsiveRefreshRate); 694 }; 695 696 /** 697 * Checks window `resize` event. 698 * @protected 699 */ 700 Owl.prototype.onResize = function() { 701 if (!this._items.length) { 702 return false; 703 } 704 705 if (this._width === this.$element.width()) { 706 return false; 707 } 708 709 if (!this.isVisible()) { 710 return false; 711 } 712 713 this.enter('resizing'); 714 715 if (this.trigger('resize').isDefaultPrevented()) { 716 this.leave('resizing'); 717 return false; 718 } 719 720 this.invalidate('width'); 721 722 this.refresh(); 723 724 this.leave('resizing'); 725 this.trigger('resized'); 726 }; 727 728 /** 729 * Registers event handlers. 730 * @todo Check `msPointerEnabled` 731 * @todo #261 732 * @protected 733 */ 734 Owl.prototype.registerEventHandlers = function() { 735 if ($.support.transition) { 736 this.$stage.on($.support.transition.end + '.owl.core', $.proxy(this.onTransitionEnd, this)); 737 } 738 739 if (this.settings.responsive !== false) { 740 this.on(window, 'resize', this._handlers.onThrottledResize); 741 } 742 743 if (this.settings.mouseDrag) { 744 this.$element.addClass(this.options.dragClass); 745 this.$stage.on('mousedown.owl.core', $.proxy(this.onDragStart, this)); 746 this.$stage.on('dragstart.owl.core selectstart.owl.core', function() { return false }); 747 } 748 749 if (this.settings.touchDrag){ 750 this.$stage.on('touchstart.owl.core', $.proxy(this.onDragStart, this)); 751 this.$stage.on('touchcancel.owl.core', $.proxy(this.onDragEnd, this)); 752 } 753 }; 754 755 /** 756 * Handles `touchstart` and `mousedown` events. 757 * @todo Horizontal swipe threshold as option 758 * @todo #261 759 * @protected 760 * @param {Event} event - The event arguments. 761 */ 762 Owl.prototype.onDragStart = function(event) { 763 var stage = null; 764 765 if (event.which === 3) { 766 return; 767 } 768 769 if ($.support.transform) { 770 stage = this.$stage.css('transform').replace(/.*\(|\)| /g, '').split(','); 771 stage = { 772 x: stage[stage.length === 16 ? 12 : 4], 773 y: stage[stage.length === 16 ? 13 : 5] 774 }; 775 } else { 776 stage = this.$stage.position(); 777 stage = { 778 x: this.settings.rtl ? 779 stage.left + this.$stage.width() - this.width() + this.settings.margin : 780 stage.left, 781 y: stage.top 782 }; 783 } 784 785 if (this.is('animating')) { 786 $.support.transform ? this.animate(stage.x) : this.$stage.stop() 787 this.invalidate('position'); 788 } 789 790 this.$element.toggleClass(this.options.grabClass, event.type === 'mousedown'); 791 792 this.speed(0); 793 794 this._drag.time = new Date().getTime(); 795 this._drag.target = $(event.target); 796 this._drag.stage.start = stage; 797 this._drag.stage.current = stage; 798 this._drag.pointer = this.pointer(event); 799 800 $(document).on('mouseup.owl.core touchend.owl.core', $.proxy(this.onDragEnd, this)); 801 802 $(document).one('mousemove.owl.core touchmove.owl.core', $.proxy(function(event) { 803 var delta = this.difference(this._drag.pointer, this.pointer(event)); 804 805 $(document).on('mousemove.owl.core touchmove.owl.core', $.proxy(this.onDragMove, this)); 806 807 if (Math.abs(delta.x) < Math.abs(delta.y) && this.is('valid')) { 808 return; 809 } 810 811 event.preventDefault(); 812 813 this.enter('dragging'); 814 this.trigger('drag'); 815 }, this)); 816 }; 817 818 /** 819 * Handles the `touchmove` and `mousemove` events. 820 * @todo #261 821 * @protected 822 * @param {Event} event - The event arguments. 823 */ 824 Owl.prototype.onDragMove = function(event) { 825 var minimum = null, 826 maximum = null, 827 pull = null, 828 delta = this.difference(this._drag.pointer, this.pointer(event)), 829 stage = this.difference(this._drag.stage.start, delta); 830 831 if (!this.is('dragging')) { 832 return; 833 } 834 835 event.preventDefault(); 836 837 if (this.settings.loop) { 838 minimum = this.coordinates(this.minimum()); 839 maximum = this.coordinates(this.maximum() + 1) - minimum; 840 stage.x = (((stage.x - minimum) % maximum + maximum) % maximum) + minimum; 841 } else { 842 minimum = this.settings.rtl ? this.coordinates(this.maximum()) : this.coordinates(this.minimum()); 843 maximum = this.settings.rtl ? this.coordinates(this.minimum()) : this.coordinates(this.maximum()); 844 pull = this.settings.pullDrag ? -1 * delta.x / 5 : 0; 845 stage.x = Math.max(Math.min(stage.x, minimum + pull), maximum + pull); 846 } 847 848 this._drag.stage.current = stage; 849 850 this.animate(stage.x); 851 }; 852 853 /** 854 * Handles the `touchend` and `mouseup` events. 855 * @todo #261 856 * @todo Threshold for click event 857 * @protected 858 * @param {Event} event - The event arguments. 859 */ 860 Owl.prototype.onDragEnd = function(event) { 861 var delta = this.difference(this._drag.pointer, this.pointer(event)), 862 stage = this._drag.stage.current, 863 direction = delta.x > 0 ^ this.settings.rtl ? 'left' : 'right'; 864 865 $(document).off('.owl.core'); 866 867 this.$element.removeClass(this.options.grabClass); 868 869 if (delta.x !== 0 && this.is('dragging') || !this.is('valid')) { 870 this.speed(this.settings.dragEndSpeed || this.settings.smartSpeed); 871 this.current(this.closest(stage.x, delta.x !== 0 ? direction : this._drag.direction)); 872 this.invalidate('position'); 873 this.update(); 874 875 this._drag.direction = direction; 876 877 if (Math.abs(delta.x) > 3 || new Date().getTime() - this._drag.time > 300) { 878 this._drag.target.one('click.owl.core', function() { return false; }); 879 } 880 } 881 882 if (!this.is('dragging')) { 883 return; 884 } 885 886 this.leave('dragging'); 887 this.trigger('dragged'); 888 }; 889 890 /** 891 * Gets absolute position of the closest item for a coordinate. 892 * @todo Setting `freeDrag` makes `closest` not reusable. See #165. 893 * @protected 894 * @param {Number} coordinate - The coordinate in pixel. 895 * @param {String} direction - The direction to check for the closest item. Ether `left` or `right`. 896 * @return {Number} - The absolute position of the closest item. 897 */ 898 Owl.prototype.closest = function(coordinate, direction) { 899 var position = -1, 900 pull = 30, 901 width = this.width(), 902 coordinates = this.coordinates(); 903 904 if (!this.settings.freeDrag) { 905 // check closest item 906 $.each(coordinates, $.proxy(function(index, value) { 907 // on a left pull, check on current index 908 if (direction === 'left' && coordinate > value - pull && coordinate < value + pull) { 909 position = index; 910 // on a right pull, check on previous index 911 // to do so, subtract width from value and set position = index + 1 912 } else if (direction === 'right' && coordinate > value - width - pull && coordinate < value - width + pull) { 913 position = index + 1; 914 } else if (this.op(coordinate, '<', value) 915 && this.op(coordinate, '>', coordinates[index + 1] !== undefined ? coordinates[index + 1] : value - width)) { 916 position = direction === 'left' ? index + 1 : index; 917 } 918 return position === -1; 919 }, this)); 920 } 921 922 if (!this.settings.loop) { 923 // non loop boundries 924 if (this.op(coordinate, '>', coordinates[this.minimum()])) { 925 position = coordinate = this.minimum(); 926 } else if (this.op(coordinate, '<', coordinates[this.maximum()])) { 927 position = coordinate = this.maximum(); 928 } 929 } 930 931 return position; 932 }; 933 934 /** 935 * Animates the stage. 936 * @todo #270 937 * @public 938 * @param {Number} coordinate - The coordinate in pixels. 939 */ 940 Owl.prototype.animate = function(coordinate) { 941 var animate = this.speed() > 0; 942 943 this.is('animating') && this.onTransitionEnd(); 944 945 if (animate) { 946 this.enter('animating'); 947 this.trigger('translate'); 948 } 949 950 if ($.support.transform3d && $.support.transition) { 951 this.$stage.css({ 952 transform: 'translate3d(' + coordinate + 'px,0px,0px)', 953 transition: (this.speed() / 1000) + 's' + ( 954 this.settings.slideTransition ? ' ' + this.settings.slideTransition : '' 955 ) 956 }); 957 } else if (animate) { 958 this.$stage.animate({ 959 left: coordinate + 'px' 960 }, this.speed(), this.settings.fallbackEasing, $.proxy(this.onTransitionEnd, this)); 961 } else { 962 this.$stage.css({ 963 left: coordinate + 'px' 964 }); 965 } 966 }; 967 968 /** 969 * Checks whether the carousel is in a specific state or not. 970 * @param {String} state - The state to check. 971 * @returns {Boolean} - The flag which indicates if the carousel is busy. 972 */ 973 Owl.prototype.is = function(state) { 974 return this._states.current[state] && this._states.current[state] > 0; 975 }; 976 977 /** 978 * Sets the absolute position of the current item. 979 * @public 980 * @param {Number} [position] - The new absolute position or nothing to leave it unchanged. 981 * @returns {Number} - The absolute position of the current item. 982 */ 983 Owl.prototype.current = function(position) { 984 if (position === undefined) { 985 return this._current; 986 } 987 988 if (this._items.length === 0) { 989 return undefined; 990 } 991 992 position = this.normalize(position); 993 994 if (this._current !== position) { 995 var event = this.trigger('change', { property: { name: 'position', value: position } }); 996 997 if (event.data !== undefined) { 998 position = this.normalize(event.data); 999 } 1000 1001 this._current = position; 1002 1003 this.invalidate('position'); 1004 1005 this.trigger('changed', { property: { name: 'position', value: this._current } }); 1006 } 1007 1008 return this._current; 1009 }; 1010 1011 /** 1012 * Invalidates the given part of the update routine. 1013 * @param {String} [part] - The part to invalidate. 1014 * @returns {Array.<String>} - The invalidated parts. 1015 */ 1016 Owl.prototype.invalidate = function(part) { 1017 if ($.type(part) === 'string') { 1018 this._invalidated[part] = true; 1019 this.is('valid') && this.leave('valid'); 1020 } 1021 return $.map(this._invalidated, function(v, i) { return i }); 1022 }; 1023 1024 /** 1025 * Resets the absolute position of the current item. 1026 * @public 1027 * @param {Number} position - The absolute position of the new item. 1028 */ 1029 Owl.prototype.reset = function(position) { 1030 position = this.normalize(position); 1031 1032 if (position === undefined) { 1033 return; 1034 } 1035 1036 this._speed = 0; 1037 this._current = position; 1038 1039 this.suppress([ 'translate', 'translated' ]); 1040 1041 this.animate(this.coordinates(position)); 1042 1043 this.release([ 'translate', 'translated' ]); 1044 }; 1045 1046 /** 1047 * Normalizes an absolute or a relative position of an item. 1048 * @public 1049 * @param {Number} position - The absolute or relative position to normalize. 1050 * @param {Boolean} [relative=false] - Whether the given position is relative or not. 1051 * @returns {Number} - The normalized position. 1052 */ 1053 Owl.prototype.normalize = function(position, relative) { 1054 var n = this._items.length, 1055 m = relative ? 0 : this._clones.length; 1056 1057 if (!this.isNumeric(position) || n < 1) { 1058 position = undefined; 1059 } else if (position < 0 || position >= n + m) { 1060 position = ((position - m / 2) % n + n) % n + m / 2; 1061 } 1062 1063 return position; 1064 }; 1065 1066 /** 1067 * Converts an absolute position of an item into a relative one. 1068 * @public 1069 * @param {Number} position - The absolute position to convert. 1070 * @returns {Number} - The converted position. 1071 */ 1072 Owl.prototype.relative = function(position) { 1073 position -= this._clones.length / 2; 1074 return this.normalize(position, true); 1075 }; 1076 1077 /** 1078 * Gets the maximum position for the current item. 1079 * @public 1080 * @param {Boolean} [relative=false] - Whether to return an absolute position or a relative position. 1081 * @returns {Number} 1082 */ 1083 Owl.prototype.maximum = function(relative) { 1084 var settings = this.settings, 1085 maximum = this._coordinates.length, 1086 iterator, 1087 reciprocalItemsWidth, 1088 elementWidth; 1089 1090 if (settings.loop) { 1091 maximum = this._clones.length / 2 + this._items.length - 1; 1092 } else if (settings.autoWidth || settings.merge) { 1093 iterator = this._items.length; 1094 if (iterator) { 1095 reciprocalItemsWidth = this._items[--iterator].width(); 1096 elementWidth = this.$element.width(); 1097 while (iterator--) { 1098 reciprocalItemsWidth += this._items[iterator].width() + this.settings.margin; 1099 if (reciprocalItemsWidth > elementWidth) { 1100 break; 1101 } 1102 } 1103 } 1104 maximum = iterator + 1; 1105 } else if (settings.center) { 1106 maximum = this._items.length - 1; 1107 } else { 1108 maximum = this._items.length - settings.items; 1109 } 1110 1111 if (relative) { 1112 maximum -= this._clones.length / 2; 1113 } 1114 1115 return Math.max(maximum, 0); 1116 }; 1117 1118 /** 1119 * Gets the minimum position for the current item. 1120 * @public 1121 * @param {Boolean} [relative=false] - Whether to return an absolute position or a relative position. 1122 * @returns {Number} 1123 */ 1124 Owl.prototype.minimum = function(relative) { 1125 return relative ? 0 : this._clones.length / 2; 1126 }; 1127 1128 /** 1129 * Gets an item at the specified relative position. 1130 * @public 1131 * @param {Number} [position] - The relative position of the item. 1132 * @return {jQuery|Array.<jQuery>} - The item at the given position or all items if no position was given. 1133 */ 1134 Owl.prototype.items = function(position) { 1135 if (position === undefined) { 1136 return this._items.slice(); 1137 } 1138 1139 position = this.normalize(position, true); 1140 return this._items[position]; 1141 }; 1142 1143 /** 1144 * Gets an item at the specified relative position. 1145 * @public 1146 * @param {Number} [position] - The relative position of the item. 1147 * @return {jQuery|Array.<jQuery>} - The item at the given position or all items if no position was given. 1148 */ 1149 Owl.prototype.mergers = function(position) { 1150 if (position === undefined) { 1151 return this._mergers.slice(); 1152 } 1153 1154 position = this.normalize(position, true); 1155 return this._mergers[position]; 1156 }; 1157 1158 /** 1159 * Gets the absolute positions of clones for an item. 1160 * @public 1161 * @param {Number} [position] - The relative position of the item. 1162 * @returns {Array.<Number>} - The absolute positions of clones for the item or all if no position was given. 1163 */ 1164 Owl.prototype.clones = function(position) { 1165 var odd = this._clones.length / 2, 1166 even = odd + this._items.length, 1167 map = function(index) { return index % 2 === 0 ? even + index / 2 : odd - (index + 1) / 2 }; 1168 1169 if (position === undefined) { 1170 return $.map(this._clones, function(v, i) { return map(i) }); 1171 } 1172 1173 return $.map(this._clones, function(v, i) { return v === position ? map(i) : null }); 1174 }; 1175 1176 /** 1177 * Sets the current animation speed. 1178 * @public 1179 * @param {Number} [speed] - The animation speed in milliseconds or nothing to leave it unchanged. 1180 * @returns {Number} - The current animation speed in milliseconds. 1181 */ 1182 Owl.prototype.speed = function(speed) { 1183 if (speed !== undefined) { 1184 this._speed = speed; 1185 } 1186 1187 return this._speed; 1188 }; 1189 1190 /** 1191 * Gets the coordinate of an item. 1192 * @todo The name of this method is missleanding. 1193 * @public 1194 * @param {Number} position - The absolute position of the item within `minimum()` and `maximum()`. 1195 * @returns {Number|Array.<Number>} - The coordinate of the item in pixel or all coordinates. 1196 */ 1197 Owl.prototype.coordinates = function(position) { 1198 var multiplier = 1, 1199 newPosition = position - 1, 1200 coordinate; 1201 1202 if (position === undefined) { 1203 return $.map(this._coordinates, $.proxy(function(coordinate, index) { 1204 return this.coordinates(index); 1205 }, this)); 1206 } 1207 1208 if (this.settings.center) { 1209 if (this.settings.rtl) { 1210 multiplier = -1; 1211 newPosition = position + 1; 1212 } 1213 1214 coordinate = this._coordinates[position]; 1215 coordinate += (this.width() - coordinate + (this._coordinates[newPosition] || 0)) / 2 * multiplier; 1216 } else { 1217 coordinate = this._coordinates[newPosition] || 0; 1218 } 1219 1220 coordinate = Math.ceil(coordinate); 1221 1222 return coordinate; 1223 }; 1224 1225 /** 1226 * Calculates the speed for a translation. 1227 * @protected 1228 * @param {Number} from - The absolute position of the start item. 1229 * @param {Number} to - The absolute position of the target item. 1230 * @param {Number} [factor=undefined] - The time factor in milliseconds. 1231 * @returns {Number} - The time in milliseconds for the translation. 1232 */ 1233 Owl.prototype.duration = function(from, to, factor) { 1234 if (factor === 0) { 1235 return 0; 1236 } 1237 1238 return Math.min(Math.max(Math.abs(to - from), 1), 6) * Math.abs((factor || this.settings.smartSpeed)); 1239 }; 1240 1241 /** 1242 * Slides to the specified item. 1243 * @public 1244 * @param {Number} position - The position of the item. 1245 * @param {Number} [speed] - The time in milliseconds for the transition. 1246 */ 1247 Owl.prototype.to = function(position, speed) { 1248 var current = this.current(), 1249 revert = null, 1250 distance = position - this.relative(current), 1251 direction = (distance > 0) - (distance < 0), 1252 items = this._items.length, 1253 minimum = this.minimum(), 1254 maximum = this.maximum(); 1255 1256 if (this.settings.loop) { 1257 if (!this.settings.rewind && Math.abs(distance) > items / 2) { 1258 distance += direction * -1 * items; 1259 } 1260 1261 position = current + distance; 1262 revert = ((position - minimum) % items + items) % items + minimum; 1263 1264 if (revert !== position && revert - distance <= maximum && revert - distance > 0) { 1265 current = revert - distance; 1266 position = revert; 1267 this.reset(current); 1268 } 1269 } else if (this.settings.rewind) { 1270 maximum += 1; 1271 position = (position % maximum + maximum) % maximum; 1272 } else { 1273 position = Math.max(minimum, Math.min(maximum, position)); 1274 } 1275 1276 this.speed(this.duration(current, position, speed)); 1277 this.current(position); 1278 1279 if (this.isVisible()) { 1280 this.update(); 1281 } 1282 }; 1283 1284 /** 1285 * Slides to the next item. 1286 * @public 1287 * @param {Number} [speed] - The time in milliseconds for the transition. 1288 */ 1289 Owl.prototype.next = function(speed) { 1290 speed = speed || false; 1291 this.to(this.relative(this.current()) + 1, speed); 1292 }; 1293 1294 /** 1295 * Slides to the previous item. 1296 * @public 1297 * @param {Number} [speed] - The time in milliseconds for the transition. 1298 */ 1299 Owl.prototype.prev = function(speed) { 1300 speed = speed || false; 1301 this.to(this.relative(this.current()) - 1, speed); 1302 }; 1303 1304 /** 1305 * Handles the end of an animation. 1306 * @protected 1307 * @param {Event} event - The event arguments. 1308 */ 1309 Owl.prototype.onTransitionEnd = function(event) { 1310 1311 // if css2 animation then event object is undefined 1312 if (event !== undefined) { 1313 event.stopPropagation(); 1314 1315 // Catch only owl-stage transitionEnd event 1316 if ((event.target || event.srcElement || event.originalTarget) !== this.$stage.get(0)) { 1317 return false; 1318 } 1319 } 1320 1321 this.leave('animating'); 1322 this.trigger('translated'); 1323 }; 1324 1325 /** 1326 * Gets viewport width. 1327 * @protected 1328 * @return {Number} - The width in pixel. 1329 */ 1330 Owl.prototype.viewport = function() { 1331 var width; 1332 if (this.options.responsiveBaseElement !== window) { 1333 width = $(this.options.responsiveBaseElement).width(); 1334 } else if (window.innerWidth) { 1335 width = window.innerWidth; 1336 } else if (document.documentElement && document.documentElement.clientWidth) { 1337 width = document.documentElement.clientWidth; 1338 } else { 1339 console.warn('Can not detect viewport width.'); 1340 } 1341 return width; 1342 }; 1343 1344 /** 1345 * Replaces the current content. 1346 * @public 1347 * @param {HTMLElement|jQuery|String} content - The new content. 1348 */ 1349 Owl.prototype.replace = function(content) { 1350 this.$stage.empty(); 1351 this._items = []; 1352 1353 if (content) { 1354 content = (content instanceof jQuery) ? content : $(content); 1355 } 1356 1357 if (this.settings.nestedItemSelector) { 1358 content = content.find('.' + this.settings.nestedItemSelector); 1359 } 1360 1361 content.filter(function() { 1362 return this.nodeType === 1; 1363 }).each($.proxy(function(index, item) { 1364 item = this.prepare(item); 1365 this.$stage.append(item); 1366 this._items.push(item); 1367 this._mergers.push(item.find('[data-merge]').addBack('[data-merge]').attr('data-merge') * 1 || 1); 1368 }, this)); 1369 1370 this.reset(this.isNumeric(this.settings.startPosition) ? this.settings.startPosition : 0); 1371 1372 this.invalidate('items'); 1373 }; 1374 1375 /** 1376 * Adds an item. 1377 * @todo Use `item` instead of `content` for the event arguments. 1378 * @public 1379 * @param {HTMLElement|jQuery|String} content - The item content to add. 1380 * @param {Number} [position] - The relative position at which to insert the item otherwise the item will be added to the end. 1381 */ 1382 Owl.prototype.add = function(content, position) { 1383 var current = this.relative(this._current); 1384 1385 position = position === undefined ? this._items.length : this.normalize(position, true); 1386 content = content instanceof jQuery ? content : $(content); 1387 1388 this.trigger('add', { content: content, position: position }); 1389 1390 content = this.prepare(content); 1391 1392 if (this._items.length === 0 || position === this._items.length) { 1393 this._items.length === 0 && this.$stage.append(content); 1394 this._items.length !== 0 && this._items[position - 1].after(content); 1395 this._items.push(content); 1396 this._mergers.push(content.find('[data-merge]').addBack('[data-merge]').attr('data-merge') * 1 || 1); 1397 } else { 1398 this._items[position].before(content); 1399 this._items.splice(position, 0, content); 1400 this._mergers.splice(position, 0, content.find('[data-merge]').addBack('[data-merge]').attr('data-merge') * 1 || 1); 1401 } 1402 1403 this._items[current] && this.reset(this._items[current].index()); 1404 1405 this.invalidate('items'); 1406 1407 this.trigger('added', { content: content, position: position }); 1408 }; 1409 1410 /** 1411 * Removes an item by its position. 1412 * @todo Use `item` instead of `content` for the event arguments. 1413 * @public 1414 * @param {Number} position - The relative position of the item to remove. 1415 */ 1416 Owl.prototype.remove = function(position) { 1417 position = this.normalize(position, true); 1418 1419 if (position === undefined) { 1420 return; 1421 } 1422 1423 this.trigger('remove', { content: this._items[position], position: position }); 1424 1425 this._items[position].remove(); 1426 this._items.splice(position, 1); 1427 this._mergers.splice(position, 1); 1428 1429 this.invalidate('items'); 1430 1431 this.trigger('removed', { content: null, position: position }); 1432 }; 1433 1434 /** 1435 * Preloads images with auto width. 1436 * @todo Replace by a more generic approach 1437 * @protected 1438 */ 1439 Owl.prototype.preloadAutoWidthImages = function(images) { 1440 images.each($.proxy(function(i, element) { 1441 this.enter('pre-loading'); 1442 element = $(element); 1443 $(new Image()).one('load', $.proxy(function(e) { 1444 element.attr('src', e.target.src); 1445 element.css('opacity', 1); 1446 this.leave('pre-loading'); 1447 !this.is('pre-loading') && !this.is('initializing') && this.refresh(); 1448 }, this)).attr('src', element.attr('src') || element.attr('data-src') || element.attr('data-src-retina')); 1449 }, this)); 1450 }; 1451 1452 /** 1453 * Destroys the carousel. 1454 * @public 1455 */ 1456 Owl.prototype.destroy = function() { 1457 1458 this.$element.off('.owl.core'); 1459 this.$stage.off('.owl.core'); 1460 $(document).off('.owl.core'); 1461 1462 if (this.settings.responsive !== false) { 1463 window.clearTimeout(this.resizeTimer); 1464 this.off(window, 'resize', this._handlers.onThrottledResize); 1465 } 1466 1467 for (var i in this._plugins) { 1468 this._plugins[i].destroy(); 1469 } 1470 1471 this.$stage.children('.cloned').remove(); 1472 1473 this.$stage.unwrap(); 1474 this.$stage.children().contents().unwrap(); 1475 this.$stage.children().unwrap(); 1476 this.$stage.remove(); 1477 this.$element 1478 .removeClass(this.options.refreshClass) 1479 .removeClass(this.options.loadingClass) 1480 .removeClass(this.options.loadedClass) 1481 .removeClass(this.options.rtlClass) 1482 .removeClass(this.options.dragClass) 1483 .removeClass(this.options.grabClass) 1484 .attr('class', this.$element.attr('class').replace(new RegExp(this.options.responsiveClass + '-\\S+\\s', 'g'), '')) 1485 .removeData('owl.carousel'); 1486 }; 1487 1488 /** 1489 * Operators to calculate right-to-left and left-to-right. 1490 * @protected 1491 * @param {Number} [a] - The left side operand. 1492 * @param {String} [o] - The operator. 1493 * @param {Number} [b] - The right side operand. 1494 */ 1495 Owl.prototype.op = function(a, o, b) { 1496 var rtl = this.settings.rtl; 1497 switch (o) { 1498 case '<': 1499 return rtl ? a > b : a < b; 1500 case '>': 1501 return rtl ? a < b : a > b; 1502 case '>=': 1503 return rtl ? a <= b : a >= b; 1504 case '<=': 1505 return rtl ? a >= b : a <= b; 1506 default: 1507 break; 1508 } 1509 }; 1510 1511 /** 1512 * Attaches to an internal event. 1513 * @protected 1514 * @param {HTMLElement} element - The event source. 1515 * @param {String} event - The event name. 1516 * @param {Function} listener - The event handler to attach. 1517 * @param {Boolean} capture - Wether the event should be handled at the capturing phase or not. 1518 */ 1519 Owl.prototype.on = function(element, event, listener, capture) { 1520 if (element.addEventListener) { 1521 element.addEventListener(event, listener, capture); 1522 } else if (element.attachEvent) { 1523 element.attachEvent('on' + event, listener); 1524 } 1525 }; 1526 1527 /** 1528 * Detaches from an internal event. 1529 * @protected 1530 * @param {HTMLElement} element - The event source. 1531 * @param {String} event - The event name. 1532 * @param {Function} listener - The attached event handler to detach. 1533 * @param {Boolean} capture - Wether the attached event handler was registered as a capturing listener or not. 1534 */ 1535 Owl.prototype.off = function(element, event, listener, capture) { 1536 if (element.removeEventListener) { 1537 element.removeEventListener(event, listener, capture); 1538 } else if (element.detachEvent) { 1539 element.detachEvent('on' + event, listener); 1540 } 1541 }; 1542 1543 /** 1544 * Triggers a public event. 1545 * @todo Remove `status`, `relatedTarget` should be used instead. 1546 * @protected 1547 * @param {String} name - The event name. 1548 * @param {*} [data=null] - The event data. 1549 * @param {String} [namespace=carousel] - The event namespace. 1550 * @param {String} [state] - The state which is associated with the event. 1551 * @param {Boolean} [enter=false] - Indicates if the call enters the specified state or not. 1552 * @returns {Event} - The event arguments. 1553 */ 1554 Owl.prototype.trigger = function(name, data, namespace, state, enter) { 1555 var status = { 1556 item: { count: this._items.length, index: this.current() } 1557 }, handler = $.camelCase( 1558 $.grep([ 'on', name, namespace ], function(v) { return v }) 1559 .join('-').toLowerCase() 1560 ), event = $.Event( 1561 [ name, 'owl', namespace || 'carousel' ].join('.').toLowerCase(), 1562 $.extend({ relatedTarget: this }, status, data) 1563 ); 1564 1565 if (!this._supress[name]) { 1566 $.each(this._plugins, function(name, plugin) { 1567 if (plugin.onTrigger) { 1568 plugin.onTrigger(event); 1569 } 1570 }); 1571 1572 this.register({ type: Owl.Type.Event, name: name }); 1573 this.$element.trigger(event); 1574 1575 if (this.settings && typeof this.settings[handler] === 'function') { 1576 this.settings[handler].call(this, event); 1577 } 1578 } 1579 1580 return event; 1581 }; 1582 1583 /** 1584 * Enters a state. 1585 * @param name - The state name. 1586 */ 1587 Owl.prototype.enter = function(name) { 1588 $.each([ name ].concat(this._states.tags[name] || []), $.proxy(function(i, name) { 1589 if (this._states.current[name] === undefined) { 1590 this._states.current[name] = 0; 1591 } 1592 1593 this._states.current[name]++; 1594 }, this)); 1595 }; 1596 1597 /** 1598 * Leaves a state. 1599 * @param name - The state name. 1600 */ 1601 Owl.prototype.leave = function(name) { 1602 $.each([ name ].concat(this._states.tags[name] || []), $.proxy(function(i, name) { 1603 this._states.current[name]--; 1604 }, this)); 1605 }; 1606 1607 /** 1608 * Registers an event or state. 1609 * @public 1610 * @param {Object} object - The event or state to register. 1611 */ 1612 Owl.prototype.register = function(object) { 1613 if (object.type === Owl.Type.Event) { 1614 if (!$.event.special[object.name]) { 1615 $.event.special[object.name] = {}; 1616 } 1617 1618 if (!$.event.special[object.name].owl) { 1619 var _default = $.event.special[object.name]._default; 1620 $.event.special[object.name]._default = function(e) { 1621 if (_default && _default.apply && (!e.namespace || e.namespace.indexOf('owl') === -1)) { 1622 return _default.apply(this, arguments); 1623 } 1624 return e.namespace && e.namespace.indexOf('owl') > -1; 1625 }; 1626 $.event.special[object.name].owl = true; 1627 } 1628 } else if (object.type === Owl.Type.State) { 1629 if (!this._states.tags[object.name]) { 1630 this._states.tags[object.name] = object.tags; 1631 } else { 1632 this._states.tags[object.name] = this._states.tags[object.name].concat(object.tags); 1633 } 1634 1635 this._states.tags[object.name] = $.grep(this._states.tags[object.name], $.proxy(function(tag, i) { 1636 return $.inArray(tag, this._states.tags[object.name]) === i; 1637 }, this)); 1638 } 1639 }; 1640 1641 /** 1642 * Suppresses events. 1643 * @protected 1644 * @param {Array.<String>} events - The events to suppress. 1645 */ 1646 Owl.prototype.suppress = function(events) { 1647 $.each(events, $.proxy(function(index, event) { 1648 this._supress[event] = true; 1649 }, this)); 1650 }; 1651 1652 /** 1653 * Releases suppressed events. 1654 * @protected 1655 * @param {Array.<String>} events - The events to release. 1656 */ 1657 Owl.prototype.release = function(events) { 1658 $.each(events, $.proxy(function(index, event) { 1659 delete this._supress[event]; 1660 }, this)); 1661 }; 1662 1663 /** 1664 * Gets unified pointer coordinates from event. 1665 * @todo #261 1666 * @protected 1667 * @param {Event} - The `mousedown` or `touchstart` event. 1668 * @returns {Object} - Contains `x` and `y` coordinates of current pointer position. 1669 */ 1670 Owl.prototype.pointer = function(event) { 1671 var result = { x: null, y: null }; 1672 1673 event = event.originalEvent || event || window.event; 1674 1675 event = event.touches && event.touches.length ? 1676 event.touches[0] : event.changedTouches && event.changedTouches.length ? 1677 event.changedTouches[0] : event; 1678 1679 if (event.pageX) { 1680 result.x = event.pageX; 1681 result.y = event.pageY; 1682 } else { 1683 result.x = event.clientX; 1684 result.y = event.clientY; 1685 } 1686 1687 return result; 1688 }; 1689 1690 /** 1691 * Determines if the input is a Number or something that can be coerced to a Number 1692 * @protected 1693 * @param {Number|String|Object|Array|Boolean|RegExp|Function|Symbol} - The input to be tested 1694 * @returns {Boolean} - An indication if the input is a Number or can be coerced to a Number 1695 */ 1696 Owl.prototype.isNumeric = function(number) { 1697 return !isNaN(parseFloat(number)); 1698 }; 1699 1700 /** 1701 * Gets the difference of two vectors. 1702 * @todo #261 1703 * @protected 1704 * @param {Object} - The first vector. 1705 * @param {Object} - The second vector. 1706 * @returns {Object} - The difference. 1707 */ 1708 Owl.prototype.difference = function(first, second) { 1709 return { 1710 x: first.x - second.x, 1711 y: first.y - second.y 1712 }; 1713 }; 1714 1715 /** 1716 * The jQuery Plugin for the Owl Carousel 1717 * @todo Navigation plugin `next` and `prev` 1718 * @public 1719 */ 1720 $.fn.owlCarousel = function(option) { 1721 var args = Array.prototype.slice.call(arguments, 1); 1722 1723 return this.each(function() { 1724 var $this = $(this), 1725 data = $this.data('owl.carousel'); 1726 1727 if (!data) { 1728 data = new Owl(this, typeof option == 'object' && option); 1729 $this.data('owl.carousel', data); 1730 1731 $.each([ 1732 'next', 'prev', 'to', 'destroy', 'refresh', 'replace', 'add', 'remove' 1733 ], function(i, event) { 1734 data.register({ type: Owl.Type.Event, name: event }); 1735 data.$element.on(event + '.owl.carousel.core', $.proxy(function(e) { 1736 if (e.namespace && e.relatedTarget !== this) { 1737 this.suppress([ event ]); 1738 data[event].apply(this, [].slice.call(arguments, 1)); 1739 this.release([ event ]); 1740 } 1741 }, data)); 1742 }); 1743 } 1744 1745 if (typeof option == 'string' && option.charAt(0) !== '_') { 1746 data[option].apply(data, args); 1747 } 1748 }); 1749 }; 1750 1751 /** 1752 * The constructor for the jQuery Plugin 1753 * @public 1754 */ 1755 $.fn.owlCarousel.Constructor = Owl; 1756 1757})(window.Zepto || window.jQuery, window, document); 1758 1759/** 1760 * AutoRefresh Plugin 1761 * @version 2.3.4 1762 * @author Artus Kolanowski 1763 * @author David Deutsch 1764 * @license The MIT License (MIT) 1765 */ 1766;(function($, window, document, undefined) { 1767 1768 /** 1769 * Creates the auto refresh plugin. 1770 * @class The Auto Refresh Plugin 1771 * @param {Owl} carousel - The Owl Carousel 1772 */ 1773 var AutoRefresh = function(carousel) { 1774 /** 1775 * Reference to the core. 1776 * @protected 1777 * @type {Owl} 1778 */ 1779 this._core = carousel; 1780 1781 /** 1782 * Refresh interval. 1783 * @protected 1784 * @type {number} 1785 */ 1786 this._interval = null; 1787 1788 /** 1789 * Whether the element is currently visible or not. 1790 * @protected 1791 * @type {Boolean} 1792 */ 1793 this._visible = null; 1794 1795 /** 1796 * All event handlers. 1797 * @protected 1798 * @type {Object} 1799 */ 1800 this._handlers = { 1801 'initialized.owl.carousel': $.proxy(function(e) { 1802 if (e.namespace && this._core.settings.autoRefresh) { 1803 this.watch(); 1804 } 1805 }, this) 1806 }; 1807 1808 // set default options 1809 this._core.options = $.extend({}, AutoRefresh.Defaults, this._core.options); 1810 1811 // register event handlers 1812 this._core.$element.on(this._handlers); 1813 }; 1814 1815 /** 1816 * Default options. 1817 * @public 1818 */ 1819 AutoRefresh.Defaults = { 1820 autoRefresh: true, 1821 autoRefreshInterval: 500 1822 }; 1823 1824 /** 1825 * Watches the element. 1826 */ 1827 AutoRefresh.prototype.watch = function() { 1828 if (this._interval) { 1829 return; 1830 } 1831 1832 this._visible = this._core.isVisible(); 1833 this._interval = window.setInterval($.proxy(this.refresh, this), this._core.settings.autoRefreshInterval); 1834 }; 1835 1836 /** 1837 * Refreshes the element. 1838 */ 1839 AutoRefresh.prototype.refresh = function() { 1840 if (this._core.isVisible() === this._visible) { 1841 return; 1842 } 1843 1844 this._visible = !this._visible; 1845 1846 this._core.$element.toggleClass('owl-hidden', !this._visible); 1847 1848 this._visible && (this._core.invalidate('width') && this._core.refresh()); 1849 }; 1850 1851 /** 1852 * Destroys the plugin. 1853 */ 1854 AutoRefresh.prototype.destroy = function() { 1855 var handler, property; 1856 1857 window.clearInterval(this._interval); 1858 1859 for (handler in this._handlers) { 1860 this._core.$element.off(handler, this._handlers[handler]); 1861 } 1862 for (property in Object.getOwnPropertyNames(this)) { 1863 typeof this[property] != 'function' && (this[property] = null); 1864 } 1865 }; 1866 1867 $.fn.owlCarousel.Constructor.Plugins.AutoRefresh = AutoRefresh; 1868 1869})(window.Zepto || window.jQuery, window, document); 1870 1871/** 1872 * Lazy Plugin 1873 * @version 2.3.4 1874 * @author Bartosz Wojciechowski 1875 * @author David Deutsch 1876 * @license The MIT License (MIT) 1877 */ 1878;(function($, window, document, undefined) { 1879 1880 /** 1881 * Creates the lazy plugin. 1882 * @class The Lazy Plugin 1883 * @param {Owl} carousel - The Owl Carousel 1884 */ 1885 var Lazy = function(carousel) { 1886 1887 /** 1888 * Reference to the core. 1889 * @protected 1890 * @type {Owl} 1891 */ 1892 this._core = carousel; 1893 1894 /** 1895 * Already loaded items. 1896 * @protected 1897 * @type {Array.<jQuery>} 1898 */ 1899 this._loaded = []; 1900 1901 /** 1902 * Event handlers. 1903 * @protected 1904 * @type {Object} 1905 */ 1906 this._handlers = { 1907 'initialized.owl.carousel change.owl.carousel resized.owl.carousel': $.proxy(function(e) { 1908 if (!e.namespace) { 1909 return; 1910 } 1911 1912 if (!this._core.settings || !this._core.settings.lazyLoad) { 1913 return; 1914 } 1915 1916 if ((e.property && e.property.name == 'position') || e.type == 'initialized') { 1917 var settings = this._core.settings, 1918 n = (settings.center && Math.ceil(settings.items / 2) || settings.items), 1919 i = ((settings.center && n * -1) || 0), 1920 position = (e.property && e.property.value !== undefined ? e.property.value : this._core.current()) + i, 1921 clones = this._core.clones().length, 1922 load = $.proxy(function(i, v) { this.load(v) }, this); 1923 //TODO: Need documentation for this new option 1924 if (settings.lazyLoadEager > 0) { 1925 n += settings.lazyLoadEager; 1926 // If the carousel is looping also preload images that are to the "left" 1927 if (settings.loop) { 1928 position -= settings.lazyLoadEager; 1929 n++; 1930 } 1931 } 1932 1933 while (i++ < n) { 1934 this.load(clones / 2 + this._core.relative(position)); 1935 clones && $.each(this._core.clones(this._core.relative(position)), load); 1936 position++; 1937 } 1938 } 1939 }, this) 1940 }; 1941 1942 // set the default options 1943 this._core.options = $.extend({}, Lazy.Defaults, this._core.options); 1944 1945 // register event handler 1946 this._core.$element.on(this._handlers); 1947 }; 1948 1949 /** 1950 * Default options. 1951 * @public 1952 */ 1953 Lazy.Defaults = { 1954 lazyLoad: false, 1955 lazyLoadEager: 0 1956 }; 1957 1958 /** 1959 * Loads all resources of an item at the specified position. 1960 * @param {Number} position - The absolute position of the item. 1961 * @protected 1962 */ 1963 Lazy.prototype.load = function(position) { 1964 var $item = this._core.$stage.children().eq(position), 1965 $elements = $item && $item.find('.owl-lazy'); 1966 1967 if (!$elements || $.inArray($item.get(0), this._loaded) > -1) { 1968 return; 1969 } 1970 1971 $elements.each($.proxy(function(index, element) { 1972 var $element = $(element), image, 1973 url = (window.devicePixelRatio > 1 && $element.attr('data-src-retina')) || $element.attr('data-src') || $element.attr('data-srcset'); 1974 1975 this._core.trigger('load', { element: $element, url: url }, 'lazy'); 1976 1977 if ($element.is('img')) { 1978 $element.one('load.owl.lazy', $.proxy(function() { 1979 $element.css('opacity', 1); 1980 this._core.trigger('loaded', { element: $element, url: url }, 'lazy'); 1981 }, this)).attr('src', url); 1982 } else if ($element.is('source')) { 1983 $element.one('load.owl.lazy', $.proxy(function() { 1984 this._core.trigger('loaded', { element: $element, url: url }, 'lazy'); 1985 }, this)).attr('srcset', url); 1986 } else { 1987 image = new Image(); 1988 image.onload = $.proxy(function() { 1989 $element.css({ 1990 'background-image': 'url("' + url + '")', 1991 'opacity': '1' 1992 }); 1993 this._core.trigger('loaded', { element: $element, url: url }, 'lazy'); 1994 }, this); 1995 image.src = url; 1996 } 1997 }, this)); 1998 1999 this._loaded.push($item.get(0)); 2000 }; 2001 2002 /** 2003 * Destroys the plugin. 2004 * @public 2005 */ 2006 Lazy.prototype.destroy = function() { 2007 var handler, property; 2008 2009 for (handler in this.handlers) { 2010 this._core.$element.off(handler, this.handlers[handler]); 2011 } 2012 for (property in Object.getOwnPropertyNames(this)) { 2013 typeof this[property] != 'function' && (this[property] = null); 2014 } 2015 }; 2016 2017 $.fn.owlCarousel.Constructor.Plugins.Lazy = Lazy; 2018 2019})(window.Zepto || window.jQuery, window, document); 2020 2021/** 2022 * AutoHeight Plugin 2023 * @version 2.3.4 2024 * @author Bartosz Wojciechowski 2025 * @author David Deutsch 2026 * @license The MIT License (MIT) 2027 */ 2028;(function($, window, document, undefined) { 2029 2030 /** 2031 * Creates the auto height plugin. 2032 * @class The Auto Height Plugin 2033 * @param {Owl} carousel - The Owl Carousel 2034 */ 2035 var AutoHeight = function(carousel) { 2036 /** 2037 * Reference to the core. 2038 * @protected 2039 * @type {Owl} 2040 */ 2041 this._core = carousel; 2042 2043 this._previousHeight = null; 2044 2045 /** 2046 * All event handlers. 2047 * @protected 2048 * @type {Object} 2049 */ 2050 this._handlers = { 2051 'initialized.owl.carousel refreshed.owl.carousel': $.proxy(function(e) { 2052 if (e.namespace && this._core.settings.autoHeight) { 2053 this.update(); 2054 } 2055 }, this), 2056 'changed.owl.carousel': $.proxy(function(e) { 2057 if (e.namespace && this._core.settings.autoHeight && e.property.name === 'position'){ 2058 this.update(); 2059 } 2060 }, this), 2061 'loaded.owl.lazy': $.proxy(function(e) { 2062 if (e.namespace && this._core.settings.autoHeight 2063 && e.element.closest('.' + this._core.settings.itemClass).index() === this._core.current()) { 2064 this.update(); 2065 } 2066 }, this) 2067 }; 2068 2069 // set default options 2070 this._core.options = $.extend({}, AutoHeight.Defaults, this._core.options); 2071 2072 // register event handlers 2073 this._core.$element.on(this._handlers); 2074 this._intervalId = null; 2075 var refThis = this; 2076 2077 // These changes have been taken from a PR by gavrochelegnou proposed in #1575 2078 // and have been made compatible with the latest jQuery version 2079 $(window).on('load', function() { 2080 if (refThis._core.settings.autoHeight) { 2081 refThis.update(); 2082 } 2083 }); 2084 2085 // Autoresize the height of the carousel when window is resized 2086 // When carousel has images, the height is dependent on the width 2087 // and should also change on resize 2088 $(window).resize(function() { 2089 if (refThis._core.settings.autoHeight) { 2090 if (refThis._intervalId != null) { 2091 clearTimeout(refThis._intervalId); 2092 } 2093 2094 refThis._intervalId = setTimeout(function() { 2095 refThis.update(); 2096 }, 250); 2097 } 2098 }); 2099 2100 }; 2101 2102 /** 2103 * Default options. 2104 * @public 2105 */ 2106 AutoHeight.Defaults = { 2107 autoHeight: false, 2108 autoHeightClass: 'owl-height' 2109 }; 2110 2111 /** 2112 * Updates the view. 2113 */ 2114 AutoHeight.prototype.update = function() { 2115 var start = this._core._current, 2116 end = start + this._core.settings.items, 2117 lazyLoadEnabled = this._core.settings.lazyLoad, 2118 visible = this._core.$stage.children().toArray().slice(start, end), 2119 heights = [], 2120 maxheight = 0; 2121 2122 $.each(visible, function(index, item) { 2123 heights.push($(item).height()); 2124 }); 2125 2126 maxheight = Math.max.apply(null, heights); 2127 2128 if (maxheight <= 1 && lazyLoadEnabled && this._previousHeight) { 2129 maxheight = this._previousHeight; 2130 } 2131 2132 this._previousHeight = maxheight; 2133 2134 this._core.$stage.parent() 2135 .height(maxheight) 2136 .addClass(this._core.settings.autoHeightClass); 2137 }; 2138 2139 AutoHeight.prototype.destroy = function() { 2140 var handler, property; 2141 2142 for (handler in this._handlers) { 2143 this._core.$element.off(handler, this._handlers[handler]); 2144 } 2145 for (property in Object.getOwnPropertyNames(this)) { 2146 typeof this[property] !== 'function' && (this[property] = null); 2147 } 2148 }; 2149 2150 $.fn.owlCarousel.Constructor.Plugins.AutoHeight = AutoHeight; 2151 2152})(window.Zepto || window.jQuery, window, document); 2153 2154/** 2155 * Video Plugin 2156 * @version 2.3.4 2157 * @author Bartosz Wojciechowski 2158 * @author David Deutsch 2159 * @license The MIT License (MIT) 2160 */ 2161;(function($, window, document, undefined) { 2162 2163 /** 2164 * Creates the video plugin. 2165 * @class The Video Plugin 2166 * @param {Owl} carousel - The Owl Carousel 2167 */ 2168 var Video = function(carousel) { 2169 /** 2170 * Reference to the core. 2171 * @protected 2172 * @type {Owl} 2173 */ 2174 this._core = carousel; 2175 2176 /** 2177 * Cache all video URLs. 2178 * @protected 2179 * @type {Object} 2180 */ 2181 this._videos = {}; 2182 2183 /** 2184 * Current playing item. 2185 * @protected 2186 * @type {jQuery} 2187 */ 2188 this._playing = null; 2189 2190 /** 2191 * All event handlers. 2192 * @todo The cloned content removale is too late 2193 * @protected 2194 * @type {Object} 2195 */ 2196 this._handlers = { 2197 'initialized.owl.carousel': $.proxy(function(e) { 2198 if (e.namespace) { 2199 this._core.register({ type: 'state', name: 'playing', tags: [ 'interacting' ] }); 2200 } 2201 }, this), 2202 'resize.owl.carousel': $.proxy(function(e) { 2203 if (e.namespace && this._core.settings.video && this.isInFullScreen()) { 2204 e.preventDefault(); 2205 } 2206 }, this), 2207 'refreshed.owl.carousel': $.proxy(function(e) { 2208 if (e.namespace && this._core.is('resizing')) { 2209 this._core.$stage.find('.cloned .owl-video-frame').remove(); 2210 } 2211 }, this), 2212 'changed.owl.carousel': $.proxy(function(e) { 2213 if (e.namespace && e.property.name === 'position' && this._playing) { 2214 this.stop(); 2215 } 2216 }, this), 2217 'prepared.owl.carousel': $.proxy(function(e) { 2218 if (!e.namespace) { 2219 return; 2220 } 2221 2222 var $element = $(e.content).find('.owl-video'); 2223 2224 if ($element.length) { 2225 $element.css('display', 'none'); 2226 this.fetch($element, $(e.content)); 2227 } 2228 }, this) 2229 }; 2230 2231 // set default options 2232 this._core.options = $.extend({}, Video.Defaults, this._core.options); 2233 2234 // register event handlers 2235 this._core.$element.on(this._handlers); 2236 2237 this._core.$element.on('click.owl.video', '.owl-video-play-icon', $.proxy(function(e) { 2238 this.play(e); 2239 }, this)); 2240 }; 2241 2242 /** 2243 * Default options. 2244 * @public 2245 */ 2246 Video.Defaults = { 2247 video: false, 2248 videoHeight: false, 2249 videoWidth: false 2250 }; 2251 2252 /** 2253 * Gets the video ID and the type (YouTube/Vimeo/vzaar only). 2254 * @protected 2255 * @param {jQuery} target - The target containing the video data. 2256 * @param {jQuery} item - The item containing the video. 2257 */ 2258 Video.prototype.fetch = function(target, item) { 2259 var type = (function() { 2260 if (target.attr('data-vimeo-id')) { 2261 return 'vimeo'; 2262 } else if (target.attr('data-vzaar-id')) { 2263 return 'vzaar' 2264 } else { 2265 return 'youtube'; 2266 } 2267 })(), 2268 id = target.attr('data-vimeo-id') || target.attr('data-youtube-id') || target.attr('data-vzaar-id'), 2269 width = target.attr('data-width') || this._core.settings.videoWidth, 2270 height = target.attr('data-height') || this._core.settings.videoHeight, 2271 url = target.attr('href'); 2272 2273 if (url) { 2274 2275 /* 2276 Parses the id's out of the following urls (and probably more): 2277 https://www.youtube.com/watch?v=:id 2278 https://youtu.be/:id 2279 https://vimeo.com/:id 2280 https://vimeo.com/channels/:channel/:id 2281 https://vimeo.com/groups/:group/videos/:id 2282 https://app.vzaar.com/videos/:id 2283 2284 Visual example: https://regexper.com/#(http%3A%7Chttps%3A%7C)%5C%2F%5C%2F(player.%7Cwww.%7Capp.)%3F(vimeo%5C.com%7Cyoutu(be%5C.com%7C%5C.be%7Cbe%5C.googleapis%5C.com)%7Cvzaar%5C.com)%5C%2F(video%5C%2F%7Cvideos%5C%2F%7Cembed%5C%2F%7Cchannels%5C%2F.%2B%5C%2F%7Cgroups%5C%2F.%2B%5C%2F%7Cwatch%5C%3Fv%3D%7Cv%5C%2F)%3F(%5BA-Za-z0-9._%25-%5D*)(%5C%26%5CS%2B)%3F 2285 */ 2286 2287 id = url.match(/(http:|https:|)\/\/(player.|www.|app.)?(vimeo\.com|youtu(be\.com|\.be|be\.googleapis\.com|be\-nocookie\.com)|vzaar\.com)\/(video\/|videos\/|embed\/|channels\/.+\/|groups\/.+\/|watch\?v=|v\/)?([A-Za-z0-9._%-]*)(\&\S+)?/); 2288 2289 if (id[3].indexOf('youtu') > -1) { 2290 type = 'youtube'; 2291 } else if (id[3].indexOf('vimeo') > -1) { 2292 type = 'vimeo'; 2293 } else if (id[3].indexOf('vzaar') > -1) { 2294 type = 'vzaar'; 2295 } else { 2296 throw new Error('Video URL not supported.'); 2297 } 2298 id = id[6]; 2299 } else { 2300 throw new Error('Missing video URL.'); 2301 } 2302 2303 this._videos[url] = { 2304 type: type, 2305 id: id, 2306 width: width, 2307 height: height 2308 }; 2309 2310 item.attr('data-video', url); 2311 2312 this.thumbnail(target, this._videos[url]); 2313 }; 2314 2315 /** 2316 * Creates video thumbnail. 2317 * @protected 2318 * @param {jQuery} target - The target containing the video data. 2319 * @param {Object} info - The video info object. 2320 * @see `fetch` 2321 */ 2322 Video.prototype.thumbnail = function(target, video) { 2323 var tnLink, 2324 icon, 2325 path, 2326 dimensions = video.width && video.height ? 'width:' + video.width + 'px;height:' + video.height + 'px;' : '', 2327 customTn = target.find('img'), 2328 srcType = 'src', 2329 lazyClass = '', 2330 settings = this._core.settings, 2331 create = function(path) { 2332 icon = '<div class="owl-video-play-icon"></div>'; 2333 2334 if (settings.lazyLoad) { 2335 tnLink = $('<div/>',{ 2336 "class": 'owl-video-tn ' + lazyClass, 2337 "srcType": path 2338 }); 2339 } else { 2340 tnLink = $( '<div/>', { 2341 "class": "owl-video-tn", 2342 "style": 'opacity:1;background-image:url(' + path + ')' 2343 }); 2344 } 2345 target.after(tnLink); 2346 target.after(icon); 2347 }; 2348 2349 // wrap video content into owl-video-wrapper div 2350 target.wrap( $( '<div/>', { 2351 "class": "owl-video-wrapper", 2352 "style": dimensions 2353 })); 2354 2355 if (this._core.settings.lazyLoad) { 2356 srcType = 'data-src'; 2357 lazyClass = 'owl-lazy'; 2358 } 2359 2360 // custom thumbnail 2361 if (customTn.length) { 2362 create(customTn.attr(srcType)); 2363 customTn.remove(); 2364 return false; 2365 } 2366 2367 if (video.type === 'youtube') { 2368 path = "//img.youtube.com/vi/" + video.id + "/hqdefault.jpg"; 2369 create(path); 2370 } else if (video.type === 'vimeo') { 2371 $.ajax({ 2372 type: 'GET', 2373 url: '//vimeo.com/api/v2/video/' + video.id + '.json', 2374 jsonp: 'callback', 2375 dataType: 'jsonp', 2376 success: function(data) { 2377 path = data[0].thumbnail_large; 2378 create(path); 2379 } 2380 }); 2381 } else if (video.type === 'vzaar') { 2382 $.ajax({ 2383 type: 'GET', 2384 url: '//vzaar.com/api/videos/' + video.id + '.json', 2385 jsonp: 'callback', 2386 dataType: 'jsonp', 2387 success: function(data) { 2388 path = data.framegrab_url; 2389 create(path); 2390 } 2391 }); 2392 } 2393 }; 2394 2395 /** 2396 * Stops the current video. 2397 * @public 2398 */ 2399 Video.prototype.stop = function() { 2400 this._core.trigger('stop', null, 'video'); 2401 this._playing.find('.owl-video-frame').remove(); 2402 this._playing.removeClass('owl-video-playing'); 2403 this._playing = null; 2404 this._core.leave('playing'); 2405 this._core.trigger('stopped', null, 'video'); 2406 }; 2407 2408 /** 2409 * Starts the current video. 2410 * @public 2411 * @param {Event} event - The event arguments. 2412 */ 2413 Video.prototype.play = function(event) { 2414 var target = $(event.target), 2415 item = target.closest('.' + this._core.settings.itemClass), 2416 video = this._videos[item.attr('data-video')], 2417 width = video.width || '100%', 2418 height = video.height || this._core.$stage.height(), 2419 html, 2420 iframe; 2421 2422 if (this._playing) { 2423 return; 2424 } 2425 2426 this._core.enter('playing'); 2427 this._core.trigger('play', null, 'video'); 2428 2429 item = this._core.items(this._core.relative(item.index())); 2430 2431 this._core.reset(item.index()); 2432 2433 html = $( '<iframe frameborder="0" allowfullscreen mozallowfullscreen webkitAllowFullScreen ></iframe>' ); 2434 html.attr( 'height', height ); 2435 html.attr( 'width', width ); 2436 if (video.type === 'youtube') { 2437 html.attr( 'src', '//www.youtube.com/embed/' + video.id + '?autoplay=1&rel=0&v=' + video.id ); 2438 } else if (video.type === 'vimeo') { 2439 html.attr( 'src', '//player.vimeo.com/video/' + video.id + '?autoplay=1' ); 2440 } else if (video.type === 'vzaar') { 2441 html.attr( 'src', '//view.vzaar.com/' + video.id + '/player?autoplay=true' ); 2442 } 2443 2444 iframe = $(html).wrap( '<div class="owl-video-frame" />' ).insertAfter(item.find('.owl-video')); 2445 2446 this._playing = item.addClass('owl-video-playing'); 2447 }; 2448 2449 /** 2450 * Checks whether an video is currently in full screen mode or not. 2451 * @todo Bad style because looks like a readonly method but changes members. 2452 * @protected 2453 * @returns {Boolean} 2454 */ 2455 Video.prototype.isInFullScreen = function() { 2456 var element = document.fullscreenElement || document.mozFullScreenElement || 2457 document.webkitFullscreenElement; 2458 2459 return element && $(element).parent().hasClass('owl-video-frame'); 2460 }; 2461 2462 /** 2463 * Destroys the plugin. 2464 */ 2465 Video.prototype.destroy = function() { 2466 var handler, property; 2467 2468 this._core.$element.off('click.owl.video'); 2469 2470 for (handler in this._handlers) { 2471 this._core.$element.off(handler, this._handlers[handler]); 2472 } 2473 for (property in Object.getOwnPropertyNames(this)) { 2474 typeof this[property] != 'function' && (this[property] = null); 2475 } 2476 }; 2477 2478 $.fn.owlCarousel.Constructor.Plugins.Video = Video; 2479 2480})(window.Zepto || window.jQuery, window, document); 2481 2482/** 2483 * Animate Plugin 2484 * @version 2.3.4 2485 * @author Bartosz Wojciechowski 2486 * @author David Deutsch 2487 * @license The MIT License (MIT) 2488 */ 2489;(function($, window, document, undefined) { 2490 2491 /** 2492 * Creates the animate plugin. 2493 * @class The Navigation Plugin 2494 * @param {Owl} scope - The Owl Carousel 2495 */ 2496 var Animate = function(scope) { 2497 this.core = scope; 2498 this.core.options = $.extend({}, Animate.Defaults, this.core.options); 2499 this.swapping = true; 2500 this.previous = undefined; 2501 this.next = undefined; 2502 2503 this.handlers = { 2504 'change.owl.carousel': $.proxy(function(e) { 2505 if (e.namespace && e.property.name == 'position') { 2506 this.previous = this.core.current(); 2507 this.next = e.property.value; 2508 } 2509 }, this), 2510 'drag.owl.carousel dragged.owl.carousel translated.owl.carousel': $.proxy(function(e) { 2511 if (e.namespace) { 2512 this.swapping = e.type == 'translated'; 2513 } 2514 }, this), 2515 'translate.owl.carousel': $.proxy(function(e) { 2516 if (e.namespace && this.swapping && (this.core.options.animateOut || this.core.options.animateIn)) { 2517 this.swap(); 2518 } 2519 }, this) 2520 }; 2521 2522 this.core.$element.on(this.handlers); 2523 }; 2524 2525 /** 2526 * Default options. 2527 * @public 2528 */ 2529 Animate.Defaults = { 2530 animateOut: false, 2531 animateIn: false 2532 }; 2533 2534 /** 2535 * Toggles the animation classes whenever an translations starts. 2536 * @protected 2537 * @returns {Boolean|undefined} 2538 */ 2539 Animate.prototype.swap = function() { 2540 2541 if (this.core.settings.items !== 1) { 2542 return; 2543 } 2544 2545 if (!$.support.animation || !$.support.transition) { 2546 return; 2547 } 2548 2549 this.core.speed(0); 2550 2551 var left, 2552 clear = $.proxy(this.clear, this), 2553 previous = this.core.$stage.children().eq(this.previous), 2554 next = this.core.$stage.children().eq(this.next), 2555 incoming = this.core.settings.animateIn, 2556 outgoing = this.core.settings.animateOut; 2557 2558 if (this.core.current() === this.previous) { 2559 return; 2560 } 2561 2562 if (outgoing) { 2563 left = this.core.coordinates(this.previous) - this.core.coordinates(this.next); 2564 previous.one($.support.animation.end, clear) 2565 .css( { 'left': left + 'px' } ) 2566 .addClass('animated owl-animated-out') 2567 .addClass(outgoing); 2568 } 2569 2570 if (incoming) { 2571 next.one($.support.animation.end, clear) 2572 .addClass('animated owl-animated-in') 2573 .addClass(incoming); 2574 } 2575 }; 2576 2577 Animate.prototype.clear = function(e) { 2578 $(e.target).css( { 'left': '' } ) 2579 .removeClass('animated owl-animated-out owl-animated-in') 2580 .removeClass(this.core.settings.animateIn) 2581 .removeClass(this.core.settings.animateOut); 2582 this.core.onTransitionEnd(); 2583 }; 2584 2585 /** 2586 * Destroys the plugin. 2587 * @public 2588 */ 2589 Animate.prototype.destroy = function() { 2590 var handler, property; 2591 2592 for (handler in this.handlers) { 2593 this.core.$element.off(handler, this.handlers[handler]); 2594 } 2595 for (property in Object.getOwnPropertyNames(this)) { 2596 typeof this[property] != 'function' && (this[property] = null); 2597 } 2598 }; 2599 2600 $.fn.owlCarousel.Constructor.Plugins.Animate = Animate; 2601 2602})(window.Zepto || window.jQuery, window, document); 2603 2604/** 2605 * Autoplay Plugin 2606 * @version 2.3.4 2607 * @author Bartosz Wojciechowski 2608 * @author Artus Kolanowski 2609 * @author David Deutsch 2610 * @author Tom De Caluwé 2611 * @license The MIT License (MIT) 2612 */ 2613;(function($, window, document, undefined) { 2614 2615 /** 2616 * Creates the autoplay plugin. 2617 * @class The Autoplay Plugin 2618 * @param {Owl} scope - The Owl Carousel 2619 */ 2620 var Autoplay = function(carousel) { 2621 /** 2622 * Reference to the core. 2623 * @protected 2624 * @type {Owl} 2625 */ 2626 this._core = carousel; 2627 2628 /** 2629 * The autoplay timeout id. 2630 * @type {Number} 2631 */ 2632 this._call = null; 2633 2634 /** 2635 * Depending on the state of the plugin, this variable contains either 2636 * the start time of the timer or the current timer value if it's 2637 * paused. Since we start in a paused state we initialize the timer 2638 * value. 2639 * @type {Number} 2640 */ 2641 this._time = 0; 2642 2643 /** 2644 * Stores the timeout currently used. 2645 * @type {Number} 2646 */ 2647 this._timeout = 0; 2648 2649 /** 2650 * Indicates whenever the autoplay is paused. 2651 * @type {Boolean} 2652 */ 2653 this._paused = true; 2654 2655 /** 2656 * All event handlers. 2657 * @protected 2658 * @type {Object} 2659 */ 2660 this._handlers = { 2661 'changed.owl.carousel': $.proxy(function(e) { 2662 if (e.namespace && e.property.name === 'settings') { 2663 if (this._core.settings.autoplay) { 2664 this.play(); 2665 } else { 2666 this.stop(); 2667 } 2668 } else if (e.namespace && e.property.name === 'position' && this._paused) { 2669 // Reset the timer. This code is triggered when the position 2670 // of the carousel was changed through user interaction. 2671 this._time = 0; 2672 } 2673 }, this), 2674 'initialized.owl.carousel': $.proxy(function(e) { 2675 if (e.namespace && this._core.settings.autoplay) { 2676 this.play(); 2677 } 2678 }, this), 2679 'play.owl.autoplay': $.proxy(function(e, t, s) { 2680 if (e.namespace) { 2681 this.play(t, s); 2682 } 2683 }, this), 2684 'stop.owl.autoplay': $.proxy(function(e) { 2685 if (e.namespace) { 2686 this.stop(); 2687 } 2688 }, this), 2689 'mouseover.owl.autoplay': $.proxy(function() { 2690 if (this._core.settings.autoplayHoverPause && this._core.is('rotating')) { 2691 this.pause(); 2692 } 2693 }, this), 2694 'mouseleave.owl.autoplay': $.proxy(function() { 2695 if (this._core.settings.autoplayHoverPause && this._core.is('rotating')) { 2696 this.play(); 2697 } 2698 }, this), 2699 'touchstart.owl.core': $.proxy(function() { 2700 if (this._core.settings.autoplayHoverPause && this._core.is('rotating')) { 2701 this.pause(); 2702 } 2703 }, this), 2704 'touchend.owl.core': $.proxy(function() { 2705 if (this._core.settings.autoplayHoverPause) { 2706 this.play(); 2707 } 2708 }, this) 2709 }; 2710 2711 // register event handlers 2712 this._core.$element.on(this._handlers); 2713 2714 // set default options 2715 this._core.options = $.extend({}, Autoplay.Defaults, this._core.options); 2716 }; 2717 2718 /** 2719 * Default options. 2720 * @public 2721 */ 2722 Autoplay.Defaults = { 2723 autoplay: false, 2724 autoplayTimeout: 5000, 2725 autoplayHoverPause: false, 2726 autoplaySpeed: false 2727 }; 2728 2729 /** 2730 * Transition to the next slide and set a timeout for the next transition. 2731 * @private 2732 * @param {Number} [speed] - The animation speed for the animations. 2733 */ 2734 Autoplay.prototype._next = function(speed) { 2735 this._call = window.setTimeout( 2736 $.proxy(this._next, this, speed), 2737 this._timeout * (Math.round(this.read() / this._timeout) + 1) - this.read() 2738 ); 2739 2740 if (this._core.is('interacting') || document.hidden) { 2741 return; 2742 } 2743 this._core.next(speed || this._core.settings.autoplaySpeed); 2744 } 2745 2746 /** 2747 * Reads the current timer value when the timer is playing. 2748 * @public 2749 */ 2750 Autoplay.prototype.read = function() { 2751 return new Date().getTime() - this._time; 2752 }; 2753 2754 /** 2755 * Starts the autoplay. 2756 * @public 2757 * @param {Number} [timeout] - The interval before the next animation starts. 2758 * @param {Number} [speed] - The animation speed for the animations. 2759 */ 2760 Autoplay.prototype.play = function(timeout, speed) { 2761 var elapsed; 2762 2763 if (!this._core.is('rotating')) { 2764 this._core.enter('rotating'); 2765 } 2766 2767 timeout = timeout || this._core.settings.autoplayTimeout; 2768 2769 // Calculate the elapsed time since the last transition. If the carousel 2770 // wasn't playing this calculation will yield zero. 2771 elapsed = Math.min(this._time % (this._timeout || timeout), timeout); 2772 2773 if (this._paused) { 2774 // Start the clock. 2775 this._time = this.read(); 2776 this._paused = false; 2777 } else { 2778 // Clear the active timeout to allow replacement. 2779 window.clearTimeout(this._call); 2780 } 2781 2782 // Adjust the origin of the timer to match the new timeout value. 2783 this._time += this.read() % timeout - elapsed; 2784 2785 this._timeout = timeout; 2786 this._call = window.setTimeout($.proxy(this._next, this, speed), timeout - elapsed); 2787 }; 2788 2789 /** 2790 * Stops the autoplay. 2791 * @public 2792 */ 2793 Autoplay.prototype.stop = function() { 2794 if (this._core.is('rotating')) { 2795 // Reset the clock. 2796 this._time = 0; 2797 this._paused = true; 2798 2799 window.clearTimeout(this._call); 2800 this._core.leave('rotating'); 2801 } 2802 }; 2803 2804 /** 2805 * Pauses the autoplay. 2806 * @public 2807 */ 2808 Autoplay.prototype.pause = function() { 2809 if (this._core.is('rotating') && !this._paused) { 2810 // Pause the clock. 2811 this._time = this.read(); 2812 this._paused = true; 2813 2814 window.clearTimeout(this._call); 2815 } 2816 }; 2817 2818 /** 2819 * Destroys the plugin. 2820 */ 2821 Autoplay.prototype.destroy = function() { 2822 var handler, property; 2823 2824 this.stop(); 2825 2826 for (handler in this._handlers) { 2827 this._core.$element.off(handler, this._handlers[handler]); 2828 } 2829 for (property in Object.getOwnPropertyNames(this)) { 2830 typeof this[property] != 'function' && (this[property] = null); 2831 } 2832 }; 2833 2834 $.fn.owlCarousel.Constructor.Plugins.autoplay = Autoplay; 2835 2836})(window.Zepto || window.jQuery, window, document); 2837 2838/** 2839 * Navigation Plugin 2840 * @version 2.3.4 2841 * @author Artus Kolanowski 2842 * @author David Deutsch 2843 * @license The MIT License (MIT) 2844 */ 2845;(function($, window, document, undefined) { 2846 'use strict'; 2847 2848 /** 2849 * Creates the navigation plugin. 2850 * @class The Navigation Plugin 2851 * @param {Owl} carousel - The Owl Carousel. 2852 */ 2853 var Navigation = function(carousel) { 2854 /** 2855 * Reference to the core. 2856 * @protected 2857 * @type {Owl} 2858 */ 2859 this._core = carousel; 2860 2861 /** 2862 * Indicates whether the plugin is initialized or not. 2863 * @protected 2864 * @type {Boolean} 2865 */ 2866 this._initialized = false; 2867 2868 /** 2869 * The current paging indexes. 2870 * @protected 2871 * @type {Array} 2872 */ 2873 this._pages = []; 2874 2875 /** 2876 * All DOM elements of the user interface. 2877 * @protected 2878 * @type {Object} 2879 */ 2880 this._controls = {}; 2881 2882 /** 2883 * Markup for an indicator. 2884 * @protected 2885 * @type {Array.<String>} 2886 */ 2887 this._templates = []; 2888 2889 /** 2890 * The carousel element. 2891 * @type {jQuery} 2892 */ 2893 this.$element = this._core.$element; 2894 2895 /** 2896 * Overridden methods of the carousel. 2897 * @protected 2898 * @type {Object} 2899 */ 2900 this._overrides = { 2901 next: this._core.next, 2902 prev: this._core.prev, 2903 to: this._core.to 2904 }; 2905 2906 /** 2907 * All event handlers. 2908 * @protected 2909 * @type {Object} 2910 */ 2911 this._handlers = { 2912 'prepared.owl.carousel': $.proxy(function(e) { 2913 if (e.namespace && this._core.settings.dotsData) { 2914 this._templates.push('<div class="' + this._core.settings.dotClass + '">' + 2915 $(e.content).find('[data-dot]').addBack('[data-dot]').attr('data-dot') + '</div>'); 2916 } 2917 }, this), 2918 'added.owl.carousel': $.proxy(function(e) { 2919 if (e.namespace && this._core.settings.dotsData) { 2920 this._templates.splice(e.position, 0, this._templates.pop()); 2921 } 2922 }, this), 2923 'remove.owl.carousel': $.proxy(function(e) { 2924 if (e.namespace && this._core.settings.dotsData) { 2925 this._templates.splice(e.position, 1); 2926 } 2927 }, this), 2928 'changed.owl.carousel': $.proxy(function(e) { 2929 if (e.namespace && e.property.name == 'position') { 2930 this.draw(); 2931 } 2932 }, this), 2933 'initialized.owl.carousel': $.proxy(function(e) { 2934 if (e.namespace && !this._initialized) { 2935 this._core.trigger('initialize', null, 'navigation'); 2936 this.initialize(); 2937 this.update(); 2938 this.draw(); 2939 this._initialized = true; 2940 this._core.trigger('initialized', null, 'navigation'); 2941 } 2942 }, this), 2943 'refreshed.owl.carousel': $.proxy(function(e) { 2944 if (e.namespace && this._initialized) { 2945 this._core.trigger('refresh', null, 'navigation'); 2946 this.update(); 2947 this.draw(); 2948 this._core.trigger('refreshed', null, 'navigation'); 2949 } 2950 }, this) 2951 }; 2952 2953 // set default options 2954 this._core.options = $.extend({}, Navigation.Defaults, this._core.options); 2955 2956 // register event handlers 2957 this.$element.on(this._handlers); 2958 }; 2959 2960 /** 2961 * Default options. 2962 * @public 2963 * @todo Rename `slideBy` to `navBy` 2964 */ 2965 Navigation.Defaults = { 2966 nav: false, 2967 navText: [ 2968 '<span aria-label="' + 'Previous' + '"><img loading="lazy" src="https://transform.storyasset.link/website-images/arr-l.svg"></span>', 2969 '<span aria-label="' + 'Next' + '"><img loading="lazy" src="https://transform.storyasset.link/website-images/arr-r.svg"></span>' 2970 ], 2971 navSpeed: false, 2972 navElement: 'button type="button" role="presentation"', 2973 navContainer: false, 2974 navContainerClass: 'owl-nav', 2975 navClass: [ 2976 'owl-prev', 2977 'owl-next' 2978 ], 2979 slideBy: 1, 2980 dotClass: 'owl-dot', 2981 dotsClass: 'owl-dots', 2982 dots: true, 2983 dotsEach: false, 2984 dotsData: false, 2985 dotsSpeed: false, 2986 dotsContainer: false 2987 }; 2988 2989 /** 2990 * Initializes the layout of the plugin and extends the carousel. 2991 * @protected 2992 */ 2993 Navigation.prototype.initialize = function() { 2994 var override, 2995 settings = this._core.settings; 2996 2997 // create DOM structure for relative navigation 2998 this._controls.$relative = (settings.navContainer ? $(settings.navContainer) 2999 : $('<div>').addClass(settings.navContainerClass).appendTo(this.$element)).addClass('disabled'); 3000 3001 this._controls.$previous = $('<' + settings.navElement + '>') 3002 .addClass(settings.navClass[0]) 3003 .html(settings.navText[0]) 3004 .prependTo(this._controls.$relative) 3005 .on('click', $.proxy(function(e) { 3006 this.prev(settings.navSpeed); 3007 }, this)); 3008 this._controls.$next = $('<' + settings.navElement + '>') 3009 .addClass(settings.navClass[1]) 3010 .html(settings.navText[1]) 3011 .appendTo(this._controls.$relative) 3012 .on('click', $.proxy(function(e) { 3013 this.next(settings.navSpeed); 3014 }, this)); 3015 3016 // create DOM structure for absolute navigation 3017 if (!settings.dotsData) { 3018 this._templates = [ $('<button role="button">') 3019 .addClass(settings.dotClass) 3020 .append($('<span>')) 3021 .prop('outerHTML') ]; 3022 } 3023 3024 this._controls.$absolute = (settings.dotsContainer ? $(settings.dotsContainer) 3025 : $('<div>').addClass(settings.dotsClass).appendTo(this.$element)).addClass('disabled'); 3026 3027 this._controls.$absolute.on('click', 'button', $.proxy(function(e) { 3028 var index = $(e.target).parent().is(this._controls.$absolute) 3029 ? $(e.target).index() : $(e.target).parent().index(); 3030 3031 e.preventDefault(); 3032 3033 this.to(index, settings.dotsSpeed); 3034 }, this)); 3035 3036 /*$el.on('focusin', function() { 3037 $(document).off(".carousel"); 3038 3039 $(document).on('keydown.carousel', function(e) { 3040 if(e.keyCode == 37) { 3041 $el.trigger('prev.owl') 3042 } 3043 if(e.keyCode == 39) { 3044 $el.trigger('next.owl') 3045 } 3046 }); 3047 });*/ 3048 3049 // override public methods of the carousel 3050 for (override in this._overrides) { 3051 this._core[override] = $.proxy(this[override], this); 3052 } 3053 }; 3054 3055 /** 3056 * Destroys the plugin. 3057 * @protected 3058 */ 3059 Navigation.prototype.destroy = function() { 3060 var handler, control, property, override, settings; 3061 settings = this._core.settings; 3062 3063 for (handler in this._handlers) { 3064 this.$element.off(handler, this._handlers[handler]); 3065 } 3066 for (control in this._controls) { 3067 if (control === '$relative' && settings.navContainer) { 3068 this._controls[control].html(''); 3069 } else { 3070 this._controls[control].remove(); 3071 } 3072 } 3073 for (override in this.overides) { 3074 this._core[override] = this._overrides[override]; 3075 } 3076 for (property in Object.getOwnPropertyNames(this)) { 3077 typeof this[property] != 'function' && (this[property] = null); 3078 } 3079 }; 3080 3081 /** 3082 * Updates the internal state. 3083 * @protected 3084 */ 3085 Navigation.prototype.update = function() { 3086 var i, j, k, 3087 lower = this._core.clones().length / 2, 3088 upper = lower + this._core.items().length, 3089 maximum = this._core.maximum(true), 3090 settings = this._core.settings, 3091 size = settings.center || settings.autoWidth || settings.dotsData 3092 ? 1 : settings.dotsEach || settings.items; 3093 3094 if (settings.slideBy !== 'page') { 3095 settings.slideBy = Math.min(settings.slideBy, settings.items); 3096 } 3097 3098 if (settings.dots || settings.slideBy == 'page') { 3099 this._pages = []; 3100 3101 for (i = lower, j = 0, k = 0; i < upper; i++) { 3102 if (j >= size || j === 0) { 3103 this._pages.push({ 3104 start: Math.min(maximum, i - lower), 3105 end: i - lower + size - 1 3106 }); 3107 if (Math.min(maximum, i - lower) === maximum) { 3108 break; 3109 } 3110 j = 0, ++k; 3111 } 3112 j += this._core.mergers(this._core.relative(i)); 3113 } 3114 } 3115 }; 3116 3117 /** 3118 * Draws the user interface. 3119 * @todo The option `dotsData` wont work. 3120 * @protected 3121 */ 3122 Navigation.prototype.draw = function() { 3123 var difference, 3124 settings = this._core.settings, 3125 disabled = this._core.items().length <= settings.items, 3126 index = this._core.relative(this._core.current()), 3127 loop = settings.loop || settings.rewind; 3128 3129 this._controls.$relative.toggleClass('disabled', !settings.nav || disabled); 3130 3131 if (settings.nav) { 3132 this._controls.$previous.toggleClass('disabled', !loop && index <= this._core.minimum(true)); 3133 this._controls.$next.toggleClass('disabled', !loop && index >= this._core.maximum(true)); 3134 } 3135 3136 this._controls.$absolute.toggleClass('disabled', !settings.dots || disabled); 3137 3138 if (settings.dots) { 3139 difference = this._pages.length - this._controls.$absolute.children().length; 3140 3141 if (settings.dotsData && difference !== 0) { 3142 this._controls.$absolute.html(this._templates.join('')); 3143 } else if (difference > 0) { 3144 this._controls.$absolute.append(new Array(difference + 1).join(this._templates[0])); 3145 } else if (difference < 0) { 3146 this._controls.$absolute.children().slice(difference).remove(); 3147 } 3148 3149 this._controls.$absolute.find('.active').removeClass('active'); 3150 this._controls.$absolute.children().eq($.inArray(this.current(), this._pages)).addClass('active'); 3151 } 3152 }; 3153 3154 /** 3155 * Extends event data. 3156 * @protected 3157 * @param {Event} event - The event object which gets thrown. 3158 */ 3159 Navigation.prototype.onTrigger = function(event) { 3160 var settings = this._core.settings; 3161 3162 event.page = { 3163 index: $.inArray(this.current(), this._pages), 3164 count: this._pages.length, 3165 size: settings && (settings.center || settings.autoWidth || settings.dotsData 3166 ? 1 : settings.dotsEach || settings.items) 3167 }; 3168 }; 3169 3170 /** 3171 * Gets the current page position of the carousel. 3172 * @protected 3173 * @returns {Number} 3174 */ 3175 Navigation.prototype.current = function() { 3176 var current = this._core.relative(this._core.current()); 3177 return $.grep(this._pages, $.proxy(function(page, index) { 3178 return page.start <= current && page.end >= current; 3179 }, this)).pop(); 3180 }; 3181 3182 /** 3183 * Gets the current succesor/predecessor position. 3184 * @protected 3185 * @returns {Number} 3186 */ 3187 Navigation.prototype.getPosition = function(successor) { 3188 var position, length, 3189 settings = this._core.settings; 3190 3191 if (settings.slideBy == 'page') { 3192 position = $.inArray(this.current(), this._pages); 3193 length = this._pages.length; 3194 successor ? ++position : --position; 3195 position = this._pages[((position % length) + length) % length].start; 3196 } else { 3197 position = this._core.relative(this._core.current()); 3198 length = this._core.items().length; 3199 successor ? position += settings.slideBy : position -= settings.slideBy; 3200 } 3201 3202 return position; 3203 }; 3204 3205 /** 3206 * Slides to the next item or page. 3207 * @public 3208 * @param {Number} [speed=false] - The time in milliseconds for the transition. 3209 */ 3210 Navigation.prototype.next = function(speed) { 3211 $.proxy(this._overrides.to, this._core)(this.getPosition(true), speed); 3212 }; 3213 3214 /** 3215 * Slides to the previous item or page. 3216 * @public 3217 * @param {Number} [speed=false] - The time in milliseconds for the transition. 3218 */ 3219 Navigation.prototype.prev = function(speed) { 3220 $.proxy(this._overrides.to, this._core)(this.getPosition(false), speed); 3221 }; 3222 3223 /** 3224 * Slides to the specified item or page. 3225 * @public 3226 * @param {Number} position - The position of the item or page. 3227 * @param {Number} [speed] - The time in milliseconds for the transition. 3228 * @param {Boolean} [standard=false] - Whether to use the standard behaviour or not. 3229 */ 3230 Navigation.prototype.to = function(position, speed, standard) { 3231 var length; 3232 3233 if (!standard && this._pages.length) { 3234 length = this._pages.length; 3235 $.proxy(this._overrides.to, this._core)(this._pages[((position % length) + length) % length].start, speed); 3236 } else { 3237 $.proxy(this._overrides.to, this._core)(position, speed); 3238 } 3239 }; 3240 3241 $.fn.owlCarousel.Constructor.Plugins.Navigation = Navigation; 3242 3243})(window.Zepto || window.jQuery, window, document); 3244 3245/** 3246 * Hash Plugin 3247 * @version 2.3.4 3248 * @author Artus Kolanowski 3249 * @author David Deutsch 3250 * @license The MIT License (MIT) 3251 */ 3252;(function($, window, document, undefined) { 3253 'use strict'; 3254 3255 /** 3256 * Creates the hash plugin. 3257 * @class The Hash Plugin 3258 * @param {Owl} carousel - The Owl Carousel 3259 */ 3260 var Hash = function(carousel) { 3261 /** 3262 * Reference to the core. 3263 * @protected 3264 * @type {Owl} 3265 */ 3266 this._core = carousel; 3267 3268 /** 3269 * Hash index for the items. 3270 * @protected 3271 * @type {Object} 3272 */ 3273 this._hashes = {}; 3274 3275 /** 3276 * The carousel element. 3277 * @type {jQuery} 3278 */ 3279 this.$element = this._core.$element; 3280 3281 /** 3282 * All event handlers. 3283 * @protected 3284 * @type {Object} 3285 */ 3286 this._handlers = { 3287 'initialized.owl.carousel': $.proxy(function(e) { 3288 if (e.namespace && this._core.settings.startPosition === 'URLHash') { 3289 $(window).trigger('hashchange.owl.navigation'); 3290 } 3291 }, this), 3292 'prepared.owl.carousel': $.proxy(function(e) { 3293 if (e.namespace) { 3294 var hash = $(e.content).find('[data-hash]').addBack('[data-hash]').attr('data-hash'); 3295 3296 if (!hash) { 3297 return; 3298 } 3299 3300 this._hashes[hash] = e.content; 3301 } 3302 }, this), 3303 'changed.owl.carousel': $.proxy(function(e) { 3304 if (e.namespace && e.property.name === 'position') { 3305 var current = this._core.items(this._core.relative(this._core.current())), 3306 hash = $.map(this._hashes, function(item, hash) { 3307 return item === current ? hash : null; 3308 }).join(); 3309 3310 if (!hash || window.location.hash.slice(1) === hash) { 3311 return; 3312 } 3313 3314 window.location.hash = hash; 3315 } 3316 }, this) 3317 }; 3318 3319 // set default options 3320 this._core.options = $.extend({}, Hash.Defaults, this._core.options); 3321 3322 // register the event handlers 3323 this.$element.on(this._handlers); 3324 3325 // register event listener for hash navigation 3326 $(window).on('hashchange.owl.navigation', $.proxy(function(e) { 3327 var hash = window.location.hash.substring(1), 3328 items = this._core.$stage.children(), 3329 position = this._hashes[hash] && items.index(this._hashes[hash]); 3330 3331 if (position === undefined || position === this._core.current()) { 3332 return; 3333 } 3334 3335 this._core.to(this._core.relative(position), false, true); 3336 }, this)); 3337 }; 3338 3339 /** 3340 * Default options. 3341 * @public 3342 */ 3343 Hash.Defaults = { 3344 URLhashListener: false 3345 }; 3346 3347 /** 3348 * Destroys the plugin. 3349 * @public 3350 */ 3351 Hash.prototype.destroy = function() { 3352 var handler, property; 3353 3354 $(window).off('hashchange.owl.navigation'); 3355 3356 for (handler in this._handlers) { 3357 this._core.$element.off(handler, this._handlers[handler]); 3358 } 3359 for (property in Object.getOwnPropertyNames(this)) { 3360 typeof this[property] != 'function' && (this[property] = null); 3361 } 3362 }; 3363 3364 $.fn.owlCarousel.Constructor.Plugins.Hash = Hash; 3365 3366})(window.Zepto || window.jQuery, window, document); 3367 3368/** 3369 * Support Plugin 3370 * 3371 * @version 2.3.4 3372 * @author Vivid Planet Software GmbH 3373 * @author Artus Kolanowski 3374 * @author David Deutsch 3375 * @license The MIT License (MIT) 3376 */ 3377;(function($, window, document, undefined) { 3378 3379 var style = $('<support>').get(0).style, 3380 prefixes = 'Webkit Moz O ms'.split(' '), 3381 events = { 3382 transition: { 3383 end: { 3384 WebkitTransition: 'webkitTransitionEnd', 3385 MozTransition: 'transitionend', 3386 OTransition: 'oTransitionEnd', 3387 transition: 'transitionend' 3388 } 3389 }, 3390 animation: { 3391 end: { 3392 WebkitAnimation: 'webkitAnimationEnd', 3393 MozAnimation: 'animationend', 3394 OAnimation: 'oAnimationEnd', 3395 animation: 'animationend' 3396 } 3397 } 3398 }, 3399 tests = { 3400 csstransforms: function() { 3401 return !!test('transform'); 3402 }, 3403 csstransforms3d: function() { 3404 return !!test('perspective'); 3405 }, 3406 csstransitions: function() { 3407 return !!test('transition'); 3408 }, 3409 cssanimations: function() { 3410 return !!test('animation'); 3411 } 3412 }; 3413 3414 function test(property, prefixed) { 3415 var result = false, 3416 upper = property.charAt(0).toUpperCase() + property.slice(1); 3417 3418 $.each((property + ' ' + prefixes.join(upper + ' ') + upper).split(' '), function(i, property) { 3419 if (style[property] !== undefined) { 3420 result = prefixed ? property : true; 3421 return false; 3422 } 3423 }); 3424 3425 return result; 3426 } 3427 3428 function prefixed(property) { 3429 return test(property, true); 3430 } 3431 3432 if (tests.csstransitions()) { 3433 /* jshint -W053 */ 3434 $.support.transition = new String(prefixed('transition')) 3435 $.support.transition.end = events.transition.end[ $.support.transition ]; 3436 } 3437 3438 if (tests.cssanimations()) { 3439 /* jshint -W053 */ 3440 $.support.animation = new String(prefixed('animation')) 3441 $.support.animation.end = events.animation.end[ $.support.animation ]; 3442 } 3443 3444 if (tests.csstransforms()) { 3445 /* jshint -W053 */ 3446 $.support.transform = new String(prefixed('transform'));
3447 $.support.transform3d = tests.csstransforms3d(); 3448 } 3449 3450})(window.Zepto || window.jQuery, window, document);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.