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