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