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