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