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