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