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