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