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