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