vendor: 15,665 bytes, lines 1-685
1/** 2 * Owl Carousel v2.2.1 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 beeing 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), 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--) { 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 } 345 346 this._clones = clones; 347 348 $(append).addClass('cloned').appendTo(this.$stage); 349 $(prepend).addClass('cloned').prependTo(this.$stage); 350 } 351 }, { 352 filter: [ 'width', 'items', 'settings' ], 353 run: function() { 354 var rtl = this.settings.rtl ? 1 : -1, 355 size = this._clones.length + this._items.length, 356 iterator = -1, 357 previous = 0, 358 current = 0, 359 coordinates = []; 360 361 while (++iterator < size) { 362 previous = coordinates[iterator - 1] || 0; 363 current = this._widths[this.relative(iterator)] + this.settings.margin; 364 coordinates.push(previous + current * rtl); 365 } 366 367 this._coordinates = coordinates; 368 } 369 }, { 370 filter: [ 'width', 'items', 'settings' ], 371 run: function() { 372 var padding = this.settings.stagePadding, 373 coordinates = this._coordinates, 374 css = { 375 'width': Math.ceil(Math.abs(coordinates[coordinates.length - 1])) + padding * 2, 376 'padding-left': padding || '', 377 'padding-right': padding || '' 378 }; 379 380 this.$stage.css(css); 381 } 382 }, { 383 filter: [ 'width', 'items', 'settings' ], 384 run: function(cache) { 385 var iterator = this._coordinates.length, 386 grid = !this.settings.autoWidth, 387 items = this.$stage.children(); 388 389 if (grid && cache.items.merge) { 390 while (iterator--) { 391 cache.css.width = this._widths[this.relative(iterator)]; 392 items.eq(iterator).css(cache.css); 393 } 394 } else if (grid) { 395 cache.css.width = cache.items.width; 396 items.css(cache.css); 397 } 398 } 399 }, { 400 filter: [ 'items' ], 401 run: function() { 402 this._coordinates.length < 1 && this.$stage.removeAttr('style'); 403 } 404 }, { 405 filter: [ 'width', 'items', 'settings' ], 406 run: function(cache) { 407 cache.current = cache.current ? this.$stage.children().index(cache.current) : 0; 408 cache.current = Math.max(this.minimum(), Math.min(this.maximum(), cache.current)); 409 this.reset(cache.current); 410 } 411 }, { 412 filter: [ 'position' ], 413 run: function() { 414 this.animate(this.coordinates(this._current)); 415 } 416 }, { 417 filter: [ 'width', 'position', 'items', 'settings' ], 418 run: function() { 419 var rtl = this.settings.rtl ? 1 : -1, 420 padding = this.settings.stagePadding * 2, 421 begin = this.coordinates(this.current()) + padding, 422 end = begin + this.width() * rtl, 423 inner, outer, matches = [], i, n; 424 425 for (i = 0, n = this._coordinates.length; i < n; i++) { 426 inner = this._coordinates[i - 1] || 0; 427 outer = Math.abs(this._coordinates[i]) + padding * rtl; 428 429 if ((this.op(inner, '<=', begin) && (this.op(inner, '>', end))) 430 || (this.op(outer, '<', begin) && this.op(outer, '>', end))) { 431 matches.push(i); 432 } 433 } 434 435 this.$stage.children('.active').removeClass('active'); 436 this.$stage.children(':eq(' + matches.join('), :eq(') + ')').addClass('active'); 437 438 if (this.settings.center) { 439 this.$stage.children('.center').removeClass('center'); 440 this.$stage.children().eq(this.current()).addClass('center'); 441 } 442 } 443 } ]; 444 445 /** 446 * Initializes the carousel. 447 * @protected 448 */ 449 Owl.prototype.initialize = function() { 450 this.enter('initializing'); 451 this.trigger('initialize'); 452 453 this.$element.toggleClass(this.settings.rtlClass, this.settings.rtl); 454 455 if (this.settings.autoWidth && !this.is('pre-loading')) { 456 var imgs, nestedSelector, width; 457 imgs = this.$element.find('img'); 458 nestedSelector = this.settings.nestedItemSelector ? '.' + this.settings.nestedItemSelector : undefined; 459 width = this.$element.children(nestedSelector).width(); 460 461 if (imgs.length && width <= 0) { 462 this.preloadAutoWidthImages(imgs); 463 } 464 } 465 466 this.$element.addClass(this.options.loadingClass); 467 468 // create stage 469 this.$stage = $('<' + this.settings.stageElement + ' class="' + this.settings.stageClass + '"/>') 470 .wrap('<div class="' + this.settings.stageOuterClass + '"/>'); 471 472 // append stage 473 this.$element.append(this.$stage.parent()); 474 475 // append content 476 this.replace(this.$element.children().not(this.$stage.parent())); 477 478 // check visibility 479 if (this.$element.is(':visible')) { 480 // update view 481 this.refresh(); 482 } else { 483 // invalidate width 484 this.invalidate('width'); 485 } 486 487 this.$element 488 .removeClass(this.options.loadingClass) 489 .addClass(this.options.loadedClass); 490 491 // register event handlers 492 this.registerEventHandlers(); 493 494 this.leave('initializing'); 495 this.trigger('initialized'); 496 }; 497 498 /** 499 * Setups the current settings. 500 * @todo Remove responsive classes. Why should adaptive designs be brought into IE8? 501 * @todo Support for media queries by using `matchMedia` would be nice. 502 * @public 503 */ 504 Owl.prototype.setup = function() { 505 var viewport = this.viewport(), 506 overwrites = this.options.responsive, 507 match = -1, 508 settings = null; 509 510 if (!overwrites) { 511 settings = $.extend({}, this.options); 512 } else { 513 $.each(overwrites, function(breakpoint) { 514 if (breakpoint <= viewport && breakpoint > match) { 515 match = Number(breakpoint); 516 } 517 }); 518 519 settings = $.extend({}, this.options, overwrites[match]); 520 if (typeof settings.stagePadding === 'function') { 521 settings.stagePadding = settings.stagePadding(); 522 } 523 delete settings.responsive; 524 525 // responsive class 526 if (settings.responsiveClass) { 527 this.$element.attr('class', 528 this.$element.attr('class').replace(new RegExp('(' + this.options.responsiveClass + '-)\\S+\\s', 'g'), '$1' + match) 529 ); 530 } 531 } 532 533 this.trigger('change', { property: { name: 'settings', value: settings } }); 534 this._breakpoint = match; 535 this.settings = settings; 536 this.invalidate('settings'); 537 this.trigger('changed', { property: { name: 'settings', value: this.settings } }); 538 }; 539 540 /** 541 * Updates option logic if necessery. 542 * @protected 543 */ 544 Owl.prototype.optionsLogic = function() { 545 if (this.settings.autoWidth) { 546 this.settings.stagePadding = false; 547 this.settings.merge = false; 548 } 549 }; 550 551 /** 552 * Prepares an item before add. 553 * @todo Rename event parameter `content` to `item`. 554 * @protected 555 * @returns {jQuery|HTMLElement} - The item container. 556 */ 557 Owl.prototype.prepare = function(item) { 558 var event = this.trigger('prepare', { content: item }); 559 560 if (!event.data) { 561 event.data = $('<' + this.settings.itemElement + '/>') 562 .addClass(this.options.itemClass).append(item) 563 } 564 565 this.trigger('prepared', { content: event.data }); 566 567 return event.data; 568 }; 569 570 /** 571 * Updates the view. 572 * @public 573 */ 574 Owl.prototype.update = function() { 575 var i = 0, 576 n = this._pipe.length, 577 filter = $.proxy(function(p) { return this[p] }, this._invalidated), 578 cache = {}; 579 580 while (i < n) { 581 if (this._invalidated.all || $.grep(this._pipe[i].filter, filter).length > 0) { 582 this._pipe[i].run(cache); 583 } 584 i++; 585 } 586 587 this._invalidated = {}; 588 589 !this.is('valid') && this.enter('valid'); 590 }; 591 592 /** 593 * Gets the width of the view. 594 * @public 595 * @param {Owl.Width} [dimension=Owl.Width.Default] - The dimension to return. 596 * @returns {Number} - The width of the view in pixel. 597 */ 598 Owl.prototype.width = function(dimension) { 599 dimension = dimension || Owl.Width.Default; 600 switch (dimension) { 601 case Owl.Width.Inner: 602 case Owl.Width.Outer: 603 return this._width; 604 default: 605 return this._width - this.settings.stagePadding * 2 + this.settings.margin; 606 } 607 }; 608 609 /** 610 * Refreshes the carousel primarily for adaptive purposes. 611 * @public 612 */ 613 Owl.prototype.refresh = function() { 614 this.enter('refreshing'); 615 this.trigger('refresh'); 616 617 this.setup(); 618 619 this.optionsLogic(); 620 621 this.$element.addClass(this.options.refreshClass); 622 623 this.update(); 624 625 this.$element.removeClass(this.options.refreshClass); 626 627 this.leave('refreshing'); 628 this.trigger('refreshed'); 629 }; 630 631 /** 632 * Checks window `resize` event. 633 * @protected 634 */ 635 Owl.prototype.onThrottledResize = function() { 636 window.clearTimeout(this.resizeTimer); 637 this.resizeTimer = window.setTimeout(this._handlers.onResize, this.settings.responsiveRefreshRate); 638 }; 639 640 /** 641 * Checks window `resize` event. 642 * @protected 643 */ 644 Owl.prototype.onResize = function() { 645 if (!this._items.length) { 646 return false; 647 } 648 649 if (this._width === this.$element.width()) { 650 return false; 651 } 652 653 if (!this.$element.is(':visible')) { 654 return false; 655 } 656 657 this.enter('resizing'); 658 659 if (this.trigger('resize').isDefaultPrevented()) { 660 this.leave('resizing'); 661 return false; 662 } 663 664 this.invalidate('width'); 665 666 this.refresh(); 667 668 this.leave('resizing'); 669 this.trigger('resized'); 670 }; 671 672 /** 673 * Registers event handlers. 674 * @todo Check `msPointerEnabled` 675 * @todo #261 676 * @protected 677 */ 678 Owl.prototype.registerEventHandlers = function() { 679 if ($.support.transition) { 680 this.$stage.on($.support.transition.end + '.owl.core', $.proxy(this.onTransitionEnd, this)); 681 } 682 683 if (this.settings.responsive !== false) { 684 this.on(window, 'resize', this._handlers.onThrottledResize); 685
vendor: 22,548 bytes, lines 685-1458
685 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 reciprocalItemsWidth = this._items[--iterator].width(); 1038 elementWidth = this.$element.width(); 1039 while (iterator--) { 1040 reciprocalItemsWidth += this._items[iterator].width() + this.settings.margin; 1041 if (reciprocalItemsWidth > elementWidth) { 1042 break; 1043 } 1044 } 1045 maximum = iterator + 1; 1046 } else if (settings.center) { 1047 maximum = this._items.length - 1; 1048 } else { 1049 maximum = this._items.length - settings.items; 1050 } 1051 1052 if (relative) { 1053 maximum -= this._clones.length / 2; 1054 } 1055 1056 return Math.max(maximum, 0); 1057 }; 1058 1059 /** 1060 * Gets the minimum position for the current item. 1061 * @public 1062 * @param {Boolean} [relative=false] - Whether to return an absolute position or a relative position. 1063 * @returns {Number} 1064 */ 1065 Owl.prototype.minimum = function(relative) { 1066 return relative ? 0 : this._clones.length / 2; 1067 }; 1068 1069 /** 1070 * Gets an item at the specified relative position. 1071 * @public 1072 * @param {Number} [position] - The relative position of the item. 1073 * @return {jQuery|Array.<jQuery>} - The item at the given position or all items if no position was given. 1074 */ 1075 Owl.prototype.items = function(position) { 1076 if (position === undefined) { 1077 return this._items.slice(); 1078 } 1079 1080 position = this.normalize(position, true); 1081 return this._items[position]; 1082 }; 1083 1084 /** 1085 * Gets an item at the specified relative position. 1086 * @public 1087 * @param {Number} [position] - The relative position of the item. 1088 * @return {jQuery|Array.<jQuery>} - The item at the given position or all items if no position was given. 1089 */ 1090 Owl.prototype.mergers = function(position) { 1091 if (position === undefined) { 1092 return this._mergers.slice(); 1093 } 1094 1095 position = this.normalize(position, true); 1096 return this._mergers[position]; 1097 }; 1098 1099 /** 1100 * Gets the absolute positions of clones for an item. 1101 * @public 1102 * @param {Number} [position] - The relative position of the item. 1103 * @returns {Array.<Number>} - The absolute positions of clones for the item or all if no position was given. 1104 */ 1105 Owl.prototype.clones = function(position) { 1106 var odd = this._clones.length / 2, 1107 even = odd + this._items.length, 1108 map = function(index) { return index % 2 === 0 ? even + index / 2 : odd - (index + 1) / 2 }; 1109 1110 if (position === undefined) { 1111 return $.map(this._clones, function(v, i) { return map(i) }); 1112 } 1113 1114 return $.map(this._clones, function(v, i) { return v === position ? map(i) : null }); 1115 }; 1116 1117 /** 1118 * Sets the current animation speed. 1119 * @public 1120 * @param {Number} [speed] - The animation speed in milliseconds or nothing to leave it unchanged. 1121 * @returns {Number} - The current animation speed in milliseconds. 1122 */ 1123 Owl.prototype.speed = function(speed) { 1124 if (speed !== undefined) { 1125 this._speed = speed; 1126 } 1127 1128 return this._speed; 1129 }; 1130 1131 /** 1132 * Gets the coordinate of an item. 1133 * @todo The name of this method is missleanding. 1134 * @public 1135 * @param {Number} position - The absolute position of the item within `minimum()` and `maximum()`. 1136 * @returns {Number|Array.<Number>} - The coordinate of the item in pixel or all coordinates. 1137 */ 1138 Owl.prototype.coordinates = function(position) { 1139 var multiplier = 1, 1140 newPosition = position - 1, 1141 coordinate; 1142 1143 if (position === undefined) { 1144 return $.map(this._coordinates, $.proxy(function(coordinate, index) { 1145 return this.coordinates(index); 1146 }, this)); 1147 } 1148 1149 if (this.settings.center) { 1150 if (this.settings.rtl) { 1151 multiplier = -1; 1152 newPosition = position + 1; 1153 } 1154 1155 coordinate = this._coordinates[position]; 1156 coordinate += (this.width() - coordinate + (this._coordinates[newPosition] || 0)) / 2 * multiplier; 1157 } else { 1158 coordinate = this._coordinates[newPosition] || 0; 1159 } 1160 1161 coordinate = Math.ceil(coordinate); 1162 1163 return coordinate; 1164 }; 1165 1166 /** 1167 * Calculates the speed for a translation. 1168 * @protected 1169 * @param {Number} from - The absolute position of the start item. 1170 * @param {Number} to - The absolute position of the target item. 1171 * @param {Number} [factor=undefined] - The time factor in milliseconds. 1172 * @returns {Number} - The time in milliseconds for the translation. 1173 */ 1174 Owl.prototype.duration = function(from, to, factor) { 1175 if (factor === 0) { 1176 return 0; 1177 } 1178 1179 return Math.min(Math.max(Math.abs(to - from), 1), 6) * Math.abs((factor || this.settings.smartSpeed)); 1180 }; 1181 1182 /** 1183 * Slides to the specified item. 1184 * @public 1185 * @param {Number} position - The position of the item. 1186 * @param {Number} [speed] - The time in milliseconds for the transition. 1187 */ 1188 Owl.prototype.to = function(position, speed) { 1189 var current = this.current(), 1190 revert = null, 1191 distance = position - this.relative(current), 1192 direction = (distance > 0) - (distance < 0), 1193 items = this._items.length, 1194 minimum = this.minimum(), 1195 maximum = this.maximum(); 1196 1197 if (this.settings.loop) { 1198 if (!this.settings.rewind && Math.abs(distance) > items / 2) { 1199 distance += direction * -1 * items; 1200 } 1201 1202 position = current + distance; 1203 revert = ((position - minimum) % items + items) % items + minimum; 1204 1205 if (revert !== position && revert - distance <= maximum && revert - distance > 0) { 1206 current = revert - distance; 1207 position = revert; 1208 this.reset(current); 1209 } 1210 } else if (this.settings.rewind) { 1211 maximum += 1; 1212 position = (position % maximum + maximum) % maximum; 1213 } else { 1214 position = Math.max(minimum, Math.min(maximum, position)); 1215 } 1216 1217 this.speed(this.duration(current, position, speed)); 1218 this.current(position); 1219 1220 if (this.$element.is(':visible')) { 1221 this.update(); 1222 } 1223 }; 1224 1225 /** 1226 * Slides to the next item. 1227 * @public 1228 * @param {Number} [speed] - The time in milliseconds for the transition. 1229 */ 1230 Owl.prototype.next = function(speed) { 1231 speed = speed || false; 1232 this.to(this.relative(this.current()) + 1, speed); 1233 }; 1234 1235 /** 1236 * Slides to the previous item. 1237 * @public 1238 * @param {Number} [speed] - The time in milliseconds for the transition. 1239 */ 1240 Owl.prototype.prev = function(speed) { 1241 speed = speed || false; 1242 this.to(this.relative(this.current()) - 1, speed); 1243 }; 1244 1245 /** 1246 * Handles the end of an animation. 1247 * @protected 1248 * @param {Event} event - The event arguments. 1249 */ 1250 Owl.prototype.onTransitionEnd = function(event) { 1251 1252 // if css2 animation then event object is undefined 1253 if (event !== undefined) { 1254 event.stopPropagation(); 1255 1256 // Catch only owl-stage transitionEnd event 1257 if ((event.target || event.srcElement || event.originalTarget) !== this.$stage.get(0)) { 1258 return false; 1259 } 1260 } 1261 1262 this.leave('animating'); 1263 this.trigger('translated'); 1264 }; 1265 1266 /** 1267 * Gets viewport width. 1268 * @protected 1269 * @return {Number} - The width in pixel. 1270 */ 1271 Owl.prototype.viewport = function() { 1272 var width; 1273 if (this.options.responsiveBaseElement !== window) { 1274 width = $(this.options.responsiveBaseElement).width(); 1275 } else if (window.innerWidth) { 1276 width = window.innerWidth; 1277 } else if (document.documentElement && document.documentElement.clientWidth) { 1278 width = document.documentElement.clientWidth; 1279 } else { 1280 console.warn('Can not detect viewport width.'); 1281 } 1282 return width; 1283 }; 1284 1285 /** 1286 * Replaces the current content. 1287 * @public 1288 * @param {HTMLElement|jQuery|String} content - The new content. 1289 */ 1290 Owl.prototype.replace = function(content) { 1291 this.$stage.empty(); 1292 this._items = []; 1293 1294 if (content) { 1295 content = (content instanceof jQuery) ? content : $(content); 1296 } 1297 1298 if (this.settings.nestedItemSelector) { 1299 content = content.find('.' + this.settings.nestedItemSelector); 1300 } 1301 1302 content.filter(function() { 1303 return this.nodeType === 1; 1304 }).each($.proxy(function(index, item) { 1305 item = this.prepare(item); 1306 this.$stage.append(item); 1307 this._items.push(item); 1308 this._mergers.push(item.find('[data-merge]').addBack('[data-merge]').attr('data-merge') * 1 || 1); 1309 }, this)); 1310 1311 this.reset(this.isNumeric(this.settings.startPosition) ? this.settings.startPosition : 0); 1312 1313 this.invalidate('items'); 1314 }; 1315 1316 /** 1317 * Adds an item. 1318 * @todo Use `item` instead of `content` for the event arguments. 1319 * @public 1320 * @param {HTMLElement|jQuery|String} content - The item content to add. 1321 * @param {Number} [position] - The relative position at which to insert the item otherwise the item will be added to the end. 1322 */ 1323 Owl.prototype.add = function(content, position) { 1324 var current = this.relative(this._current); 1325 1326 position = position === undefined ? this._items.length : this.normalize(position, true); 1327 content = content instanceof jQuery ? content : $(content); 1328 1329 this.trigger('add', { content: content, position: position }); 1330 1331 content = this.prepare(content); 1332 1333 if (this._items.length === 0 || position === this._items.length) { 1334 this._items.length === 0 && this.$stage.append(content); 1335 this._items.length !== 0 && this._items[position - 1].after(content); 1336 this._items.push(content); 1337 this._mergers.push(content.find('[data-merge]').addBack('[data-merge]').attr('data-merge') * 1 || 1); 1338 } else { 1339 this._items[position].before(content); 1340 this._items.splice(position, 0, content); 1341 this._mergers.splice(position, 0, content.find('[data-merge]').addBack('[data-merge]').attr('data-merge') * 1 || 1); 1342 } 1343 1344 this._items[current] && this.reset(this._items[current].index()); 1345 1346 this.invalidate('items'); 1347 1348 this.trigger('added', { content: content, position: position }); 1349 }; 1350 1351 /** 1352 * Removes an item by its position. 1353 * @todo Use `item` instead of `content` for the event arguments. 1354 * @public 1355 * @param {Number} position - The relative position of the item to remove. 1356 */ 1357 Owl.prototype.remove = function(position) { 1358 position = this.normalize(position, true); 1359 1360 if (position === undefined) { 1361 return; 1362 } 1363 1364 this.trigger('remove', { content: this._items[position], position: position }); 1365 1366 this._items[position].remove(); 1367 this._items.splice(position, 1); 1368 this._mergers.splice(position, 1); 1369 1370 this.invalidate('items'); 1371 1372 this.trigger('removed', { content: null, position: position }); 1373 }; 1374 1375 /** 1376 * Preloads images with auto width. 1377 * @todo Replace by a more generic approach 1378 * @protected 1379 */ 1380 Owl.prototype.preloadAutoWidthImages = function(images) { 1381 images.each($.proxy(function(i, element) { 1382 this.enter('pre-loading'); 1383 element = $(element); 1384 $(new Image()).one('load', $.proxy(function(e) { 1385 element.attr('src', e.target.src); 1386 element.css('opacity', 1); 1387 this.leave('pre-loading'); 1388 !this.is('pre-loading') && !this.is('initializing') && this.refresh(); 1389 }, this)).attr('src', element.attr('src') || element.attr('data-src') || element.attr('data-src-retina')); 1390 }, this)); 1391 }; 1392 1393 /** 1394 * Destroys the carousel. 1395 * @public 1396 */ 1397 Owl.prototype.destroy = function() { 1398 1399 this.$element.off('.owl.core'); 1400 this.$stage.off('.owl.core'); 1401 $(document).off('.owl.core'); 1402 1403 if (this.settings.responsive !== false) { 1404 window.clearTimeout(this.resizeTimer); 1405 this.off(window, 'resize', this._handlers.onThrottledResize); 1406 } 1407 1408 for (var i in this._plugins) { 1409 this._plugins[i].destroy(); 1410 } 1411 1412 this.$stage.children('.cloned').remove(); 1413 1414 this.$stage.unwrap(); 1415 this.$stage.children().contents().unwrap(); 1416 this.$stage.children().unwrap(); 1417 1418 this.$element 1419 .removeClass(this.options.refreshClass) 1420 .removeClass(this.options.loadingClass) 1421 .removeClass(this.options.loadedClass) 1422 .removeClass(this.options.rtlClass) 1423 .removeClass(this.options.dragClass) 1424 .removeClass(this.options.grabClass) 1425 .attr('class', this.$element.attr('class').replace(new RegExp(this.options.responsiveClass + '-\\S+\\s', 'g'), '')) 1426 .removeData('owl.carousel'); 1427 }; 1428 1429 /** 1430 * Operators to calculate right-to-left and left-to-right. 1431 * @protected 1432 * @param {Number} [a] - The left side operand. 1433 * @param {String} [o] - The operator. 1434 * @param {Number} [b] - The right side operand. 1435 */ 1436 Owl.prototype.op = function(a, o, b) { 1437 var rtl = this.settings.rtl; 1438 switch (o) { 1439 case '<': 1440 return rtl ? a > b : a < b; 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 default: 1448 break; 1449 } 1450 }; 1451 1452 /** 1453 * Attaches to an internal event. 1454 * @protected 1455 * @param {HTMLElement} element - The event source. 1456 * @param {String} event - The event name. 1457 * @param {Function} listener - The event handler to attach. 1458 * @param {Boolean} capture - Wether the event should be handled at the capturing p
vendor: 7,017 bytes, lines 1458-1702
1458hase or not. 1459 */ 1460 Owl.prototype.on = function(element, event, listener, capture) { 1461 if (element.addEventListener) { 1462 element.addEventListener(event, listener, capture); 1463 } else if (element.attachEvent) { 1464 element.attachEvent('on' + event, listener); 1465 } 1466 }; 1467 1468 /** 1469 * Detaches from an internal event. 1470 * @protected 1471 * @param {HTMLElement} element - The event source. 1472 * @param {String} event - The event name. 1473 * @param {Function} listener - The attached event handler to detach. 1474 * @param {Boolean} capture - Wether the attached event handler was registered as a capturing listener or not. 1475 */ 1476 Owl.prototype.off = function(element, event, listener, capture) { 1477 if (element.removeEventListener) { 1478 element.removeEventListener(event, listener, capture); 1479 } else if (element.detachEvent) { 1480 element.detachEvent('on' + event, listener); 1481 } 1482 }; 1483 1484 /** 1485 * Triggers a public event. 1486 * @todo Remove `status`, `relatedTarget` should be used instead. 1487 * @protected 1488 * @param {String} name - The event name. 1489 * @param {*} [data=null] - The event data. 1490 * @param {String} [namespace=carousel] - The event namespace. 1491 * @param {String} [state] - The state which is associated with the event. 1492 * @param {Boolean} [enter=false] - Indicates if the call enters the specified state or not. 1493 * @returns {Event} - The event arguments. 1494 */ 1495 Owl.prototype.trigger = function(name, data, namespace, state, enter) { 1496 var status = { 1497 item: { count: this._items.length, index: this.current() } 1498 }, handler = $.camelCase( 1499 $.grep([ 'on', name, namespace ], function(v) { return v }) 1500 .join('-').toLowerCase() 1501 ), event = $.Event( 1502 [ name, 'owl', namespace || 'carousel' ].join('.').toLowerCase(), 1503 $.extend({ relatedTarget: this }, status, data) 1504 ); 1505 1506 if (!this._supress[name]) { 1507 $.each(this._plugins, function(name, plugin) { 1508 if (plugin.onTrigger) { 1509 plugin.onTrigger(event); 1510 } 1511 }); 1512 1513 this.register({ type: Owl.Type.Event, name: name }); 1514 this.$element.trigger(event); 1515 1516 if (this.settings && typeof this.settings[handler] === 'function') { 1517 this.settings[handler].call(this, event); 1518 } 1519 } 1520 1521 return event; 1522 }; 1523 1524 /** 1525 * Enters a state. 1526 * @param name - The state name. 1527 */ 1528 Owl.prototype.enter = function(name) { 1529 $.each([ name ].concat(this._states.tags[name] || []), $.proxy(function(i, name) { 1530 if (this._states.current[name] === undefined) { 1531 this._states.current[name] = 0; 1532 } 1533 1534 this._states.current[name]++; 1535 }, this)); 1536 }; 1537 1538 /** 1539 * Leaves a state. 1540 * @param name - The state name. 1541 */ 1542 Owl.prototype.leave = function(name) { 1543 $.each([ name ].concat(this._states.tags[name] || []), $.proxy(function(i, name) { 1544 this._states.current[name]--; 1545 }, this)); 1546 }; 1547 1548 /** 1549 * Registers an event or state. 1550 * @public 1551 * @param {Object} object - The event or state to register. 1552 */ 1553 Owl.prototype.register = function(object) { 1554 if (object.type === Owl.Type.Event) { 1555 if (!$.event.special[object.name]) { 1556 $.event.special[object.name] = {}; 1557 } 1558 1559 if (!$.event.special[object.name].owl) { 1560 var _default = $.event.special[object.name]._default; 1561 $.event.special[object.name]._default = function(e) { 1562 if (_default && _default.apply && (!e.namespace || e.namespace.indexOf('owl') === -1)) { 1563 return _default.apply(this, arguments); 1564 } 1565 return e.namespace && e.namespace.indexOf('owl') > -1; 1566 }; 1567 $.event.special[object.name].owl = true; 1568 } 1569 } else if (object.type === Owl.Type.State) { 1570 if (!this._states.tags[object.name]) { 1571 this._states.tags[object.name] = object.tags; 1572 } else { 1573 this._states.tags[object.name] = this._states.tags[object.name].concat(object.tags); 1574 } 1575 1576 this._states.tags[object.name] = $.grep(this._states.tags[object.name], $.proxy(function(tag, i) { 1577 return $.inArray(tag, this._states.tags[object.name]) === i; 1578 }, this)); 1579 } 1580 }; 1581 1582 /** 1583 * Suppresses events. 1584 * @protected 1585 * @param {Array.<String>} events - The events to suppress. 1586 */ 1587 Owl.prototype.suppress = function(events) { 1588 $.each(events, $.proxy(function(index, event) { 1589 this._supress[event] = true; 1590 }, this)); 1591 }; 1592 1593 /** 1594 * Releases suppressed events. 1595 * @protected 1596 * @param {Array.<String>} events - The events to release. 1597 */ 1598 Owl.prototype.release = function(events) { 1599 $.each(events, $.proxy(function(index, event) { 1600 delete this._supress[event]; 1601 }, this)); 1602 }; 1603 1604 /** 1605 * Gets unified pointer coordinates from event. 1606 * @todo #261 1607 * @protected 1608 * @param {Event} - The `mousedown` or `touchstart` event. 1609 * @returns {Object} - Contains `x` and `y` coordinates of current pointer position. 1610 */ 1611 Owl.prototype.pointer = function(event) { 1612 var result = { x: null, y: null }; 1613 1614 event = event.originalEvent || event || window.event; 1615 1616 event = event.touches && event.touches.length ? 1617 event.touches[0] : event.changedTouches && event.changedTouches.length ? 1618 event.changedTouches[0] : event; 1619 1620 if (event.pageX) { 1621 result.x = event.pageX; 1622 result.y = event.pageY; 1623 } else { 1624 result.x = event.clientX; 1625 result.y = event.clientY; 1626 } 1627 1628 return result; 1629 }; 1630 1631 /** 1632 * Determines if the input is a Number or something that can be coerced to a Number 1633 * @protected 1634 * @param {Number|String|Object|Array|Boolean|RegExp|Function|Symbol} - The input to be tested 1635 * @returns {Boolean} - An indication if the input is a Number or can be coerced to a Number 1636 */ 1637 Owl.prototype.isNumeric = function(number) { 1638 return !isNaN(parseFloat(number)); 1639 }; 1640 1641 /** 1642 * Gets the difference of two vectors. 1643 * @todo #261 1644 * @protected 1645 * @param {Object} - The first vector. 1646 * @param {Object} - The second vector. 1647 * @returns {Object} - The difference. 1648 */ 1649 Owl.prototype.difference = function(first, second) { 1650 return { 1651 x: first.x - second.x, 1652 y: first.y - second.y 1653 }; 1654 }; 1655 1656 /** 1657 * The jQuery Plugin for the Owl Carousel 1658 * @todo Navigation plugin `next` and `prev` 1659 * @public 1660 */ 1661 $.fn.owlCarousel = function(option) { 1662 var args = Array.prototype.slice.call(arguments, 1); 1663 1664 return this.each(function() { 1665 var $this = $(this), 1666 data = $this.data('owl.carousel'); 1667 1668 if (!data) { 1669 data = new Owl(this, typeof option == 'object' && option); 1670 $this.data('owl.carousel', data); 1671 1672 $.each([ 1673 'next', 'prev', 'to', 'destroy', 'refresh', 'replace', 'add', 'remove' 1674 ], function(i, event) { 1675 data.register({ type: Owl.Type.Event, name: event }); 1676 data.$element.on(event + '.owl.carousel.core', $.proxy(function(e) { 1677 if (e.namespace && e.relatedTarget !== this) { 1678 this.suppress([ event ]); 1679 data[event].apply(this, [].slice.call(arguments, 1)); 1680 this.release([ event ]); 1681 } 1682 }, data)); 1683 }); 1684 } 1685 1686 if (typeof option == 'string' && option.charAt(0) !== '_') { 1687 data[option].apply(data, args); 1688 } 1689 }); 1690 }; 1691 1692 /** 1693 * The constructor for the jQuery Plugin 1694 * @public 1695 */ 1696 $.fn.owlCarousel.Constructor = Owl; 1697 1698})(window.Zepto || window.jQuery, window, document); 1699 1700/** 1701 * AutoRefresh Plugin 1702 * @version 2.
vendor: 8,226 bytes, lines 1702-2050
17021.0 1703 * @author Artus Kolanowski 1704 * @author David Deutsch 1705 * @license The MIT License (MIT) 1706 */ 1707;(function($, window, document, undefined) { 1708 1709 /** 1710 * Creates the auto refresh plugin. 1711 * @class The Auto Refresh Plugin 1712 * @param {Owl} carousel - The Owl Carousel 1713 */ 1714 var AutoRefresh = function(carousel) { 1715 /** 1716 * Reference to the core. 1717 * @protected 1718 * @type {Owl} 1719 */ 1720 this._core = carousel; 1721 1722 /** 1723 * Refresh interval. 1724 * @protected 1725 * @type {number} 1726 */ 1727 this._interval = null; 1728 1729 /** 1730 * Whether the element is currently visible or not. 1731 * @protected 1732 * @type {Boolean} 1733 */ 1734 this._visible = null; 1735 1736 /** 1737 * All event handlers. 1738 * @protected 1739 * @type {Object} 1740 */ 1741 this._handlers = { 1742 'initialized.owl.carousel': $.proxy(function(e) { 1743 if (e.namespace && this._core.settings.autoRefresh) { 1744 this.watch(); 1745 } 1746 }, this) 1747 }; 1748 1749 // set default options 1750 this._core.options = $.extend({}, AutoRefresh.Defaults, this._core.options); 1751 1752 // register event handlers 1753 this._core.$element.on(this._handlers); 1754 }; 1755 1756 /** 1757 * Default options. 1758 * @public 1759 */ 1760 AutoRefresh.Defaults = { 1761 autoRefresh: true, 1762 autoRefreshInterval: 500 1763 }; 1764 1765 /** 1766 * Watches the element. 1767 */ 1768 AutoRefresh.prototype.watch = function() { 1769 if (this._interval) { 1770 return; 1771 } 1772 1773 this._visible = this._core.$element.is(':visible'); 1774 this._interval = window.setInterval($.proxy(this.refresh, this), this._core.settings.autoRefreshInterval); 1775 }; 1776 1777 /** 1778 * Refreshes the element. 1779 */ 1780 AutoRefresh.prototype.refresh = function() { 1781 if (this._core.$element.is(':visible') === this._visible) { 1782 return; 1783 } 1784 1785 this._visible = !this._visible; 1786 1787 this._core.$element.toggleClass('owl-hidden', !this._visible); 1788 1789 this._visible && (this._core.invalidate('width') && this._core.refresh()); 1790 }; 1791 1792 /** 1793 * Destroys the plugin. 1794 */ 1795 AutoRefresh.prototype.destroy = function() { 1796 var handler, property; 1797 1798 window.clearInterval(this._interval); 1799 1800 for (handler in this._handlers) { 1801 this._core.$element.off(handler, this._handlers[handler]); 1802 } 1803 for (property in Object.getOwnPropertyNames(this)) { 1804 typeof this[property] != 'function' && (this[property] = null); 1805 } 1806 }; 1807 1808 $.fn.owlCarousel.Constructor.Plugins.AutoRefresh = AutoRefresh; 1809 1810})(window.Zepto || window.jQuery, window, document); 1811 1812/** 1813 * Lazy Plugin 1814 * @version 2.1.0 1815 * @author Bartosz Wojciechowski 1816 * @author David Deutsch 1817 * @license The MIT License (MIT) 1818 */ 1819;(function($, window, document, undefined) { 1820 1821 /** 1822 * Creates the lazy plugin. 1823 * @class The Lazy Plugin 1824 * @param {Owl} carousel - The Owl Carousel 1825 */ 1826 var Lazy = function(carousel) { 1827 1828 /** 1829 * Reference to the core. 1830 * @protected 1831 * @type {Owl} 1832 */ 1833 this._core = carousel; 1834 1835 /** 1836 * Already loaded items. 1837 * @protected 1838 * @type {Array.<jQuery>} 1839 */ 1840 this._loaded = []; 1841 1842 /** 1843 * Event handlers. 1844 * @protected 1845 * @type {Object} 1846 */ 1847 this._handlers = { 1848 'initialized.owl.carousel change.owl.carousel resized.owl.carousel': $.proxy(function(e) { 1849 if (!e.namespace) { 1850 return; 1851 } 1852 1853 if (!this._core.settings || !this._core.settings.lazyLoad) { 1854 return; 1855 } 1856 1857 if ((e.property && e.property.name == 'position') || e.type == 'initialized') { 1858 var settings = this._core.settings, 1859 n = (settings.center && Math.ceil(settings.items / 2) || settings.items), 1860 i = ((settings.center && n * -1) || 0), 1861 position = (e.property && e.property.value !== undefined ? e.property.value : this._core.current()) + i, 1862 clones = this._core.clones().length, 1863 load = $.proxy(function(i, v) { this.load(v) }, this); 1864 1865 while (i++ < n) { 1866 this.load(clones / 2 + this._core.relative(position)); 1867 clones && $.each(this._core.clones(this._core.relative(position)), load); 1868 position++; 1869 } 1870 } 1871 }, this) 1872 }; 1873 1874 // set the default options 1875 this._core.options = $.extend({}, Lazy.Defaults, this._core.options); 1876 1877 // register event handler 1878 this._core.$element.on(this._handlers); 1879 }; 1880 1881 /** 1882 * Default options. 1883 * @public 1884 */ 1885 Lazy.Defaults = { 1886 lazyLoad: false 1887 }; 1888 1889 /** 1890 * Loads all resources of an item at the specified position. 1891 * @param {Number} position - The absolute position of the item. 1892 * @protected 1893 */ 1894 Lazy.prototype.load = function(position) { 1895 var $item = this._core.$stage.children().eq(position), 1896 $elements = $item && $item.find('.owl-lazy'); 1897 1898 if (!$elements || $.inArray($item.get(0), this._loaded) > -1) { 1899 return; 1900 } 1901 1902 $elements.each($.proxy(function(index, element) { 1903 var $element = $(element), image, 1904 url = (window.devicePixelRatio > 1 && $element.attr('data-src-retina')) || $element.attr('data-src'); 1905 1906 this._core.trigger('load', { element: $element, url: url }, 'lazy'); 1907 1908 if ($element.is('img')) { 1909 $element.one('load.owl.lazy', $.proxy(function() { 1910 $element.css('opacity', 1); 1911 this._core.trigger('loaded', { element: $element, url: url }, 'lazy'); 1912 }, this)).attr('src', url); 1913 } else { 1914 image = new Image(); 1915 image.onload = $.proxy(function() { 1916 $element.css({ 1917 'background-image': 'url("' + url + '")', 1918 'opacity': '1' 1919 }); 1920 this._core.trigger('loaded', { element: $element, url: url }, 'lazy'); 1921 }, this); 1922 image.src = url; 1923 } 1924 }, this)); 1925 1926 this._loaded.push($item.get(0)); 1927 }; 1928 1929 /** 1930 * Destroys the plugin. 1931 * @public 1932 */ 1933 Lazy.prototype.destroy = function() { 1934 var handler, property; 1935 1936 for (handler in this.handlers) { 1937 this._core.$element.off(handler, this.handlers[handler]); 1938 } 1939 for (property in Object.getOwnPropertyNames(this)) { 1940 typeof this[property] != 'function' && (this[property] = null); 1941 } 1942 }; 1943 1944 $.fn.owlCarousel.Constructor.Plugins.Lazy = Lazy; 1945 1946})(window.Zepto || window.jQuery, window, document); 1947 1948/** 1949 * AutoHeight Plugin 1950 * @version 2.1.0 1951 * @author Bartosz Wojciechowski 1952 * @author David Deutsch 1953 * @license The MIT License (MIT) 1954 */ 1955;(function($, window, document, undefined) { 1956 1957 /** 1958 * Creates the auto height plugin. 1959 * @class The Auto Height Plugin 1960 * @param {Owl} carousel - The Owl Carousel 1961 */ 1962 var AutoHeight = function(carousel) { 1963 /** 1964 * Reference to the core. 1965 * @protected 1966 * @type {Owl} 1967 */ 1968 this._core = carousel; 1969 1970 /** 1971 * All event handlers. 1972 * @protected 1973 * @type {Object} 1974 */ 1975 this._handlers = { 1976 'initialized.owl.carousel refreshed.owl.carousel': $.proxy(function(e) { 1977 if (e.namespace && this._core.settings.autoHeight) { 1978 this.update(); 1979 } 1980 }, this), 1981 'changed.owl.carousel': $.proxy(function(e) { 1982 if (e.namespace && this._core.settings.autoHeight && e.property.name == 'position'){ 1983 this.update(); 1984 } 1985 }, this), 1986 'loaded.owl.lazy': $.proxy(function(e) { 1987 if (e.namespace && this._core.settings.autoHeight 1988 && e.element.closest('.' + this._core.settings.itemClass).index() === this._core.current()) { 1989 this.update(); 1990 } 1991 }, this) 1992 }; 1993 1994 // set default options 1995 this._core.options = $.extend({}, AutoHeight.Defaults, this._core.options); 1996 1997 // register event handlers 1998 this._core.$element.on(this._handlers); 1999 }; 2000 2001 /** 2002 * Default options. 2003 * @public 2004 */ 2005 AutoHeight.Defaults = { 2006 autoHeight: false, 2007 autoHeightClass: 'owl-height' 2008 }; 2009 2010 /** 2011 * Updates the view. 2012 */ 2013 AutoHeight.prototype.update = function() { 2014 var start = this._core._current, 2015 end = start + this._core.settings.items, 2016 visible = this._core.$stage.children().toArray().slice(start, end), 2017 heights = [], 2018 maxheight = 0; 2019 2020 $.each(visible, function(index, item) { 2021 heights.push($(item).height()); 2022 }); 2023 2024 maxheight = Math.max.apply(null, heights); 2025 2026 this._core.$stage.parent() 2027 .height(maxheight) 2028 .addClass(this._core.settings.autoHeightClass); 2029 }; 2030 2031 AutoHeight.prototype.destroy = function() { 2032 var handler, property; 2033 2034 for (handler in this._handlers) { 2035 this._core.$element.off(handler, this._handlers[handler]); 2036 } 2037 for (property in Object.getOwnPropertyNames(this)) { 2038 typeof this[property] != 'function' && (this[property] = null); 2039 } 2040 }; 2041 2042 $.fn.owlCarousel.Constructor.Plugins.AutoHeight = AutoHeight; 2043 2044})(window.Zepto || window.jQuery, window, document); 2045 2046/** 2047 * Video Plugin 2048 * @version 2.1.0 2049 * @author Bartosz Wojciechowski 2050 * @author David Deutsch
vendor: 9,012 bytes, lines 2050-2370
2050 2051 * @license The MIT License (MIT) 2052 */ 2053;(function($, window, document, undefined) { 2054 2055 /** 2056 * Creates the video plugin. 2057 * @class The Video Plugin 2058 * @param {Owl} carousel - The Owl Carousel 2059 */ 2060 var Video = function(carousel) { 2061 /** 2062 * Reference to the core. 2063 * @protected 2064 * @type {Owl} 2065 */ 2066 this._core = carousel; 2067 2068 /** 2069 * Cache all video URLs. 2070 * @protected 2071 * @type {Object} 2072 */ 2073 this._videos = {}; 2074 2075 /** 2076 * Current playing item. 2077 * @protected 2078 * @type {jQuery} 2079 */ 2080 this._playing = null; 2081 2082 /** 2083 * All event handlers. 2084 * @todo The cloned content removale is too late 2085 * @protected 2086 * @type {Object} 2087 */ 2088 this._handlers = { 2089 'initialized.owl.carousel': $.proxy(function(e) { 2090 if (e.namespace) { 2091 this._core.register({ type: 'state', name: 'playing', tags: [ 'interacting' ] }); 2092 } 2093 }, this), 2094 'resize.owl.carousel': $.proxy(function(e) { 2095 if (e.namespace && this._core.settings.video && this.isInFullScreen()) { 2096 e.preventDefault(); 2097 } 2098 }, this), 2099 'refreshed.owl.carousel': $.proxy(function(e) { 2100 if (e.namespace && this._core.is('resizing')) { 2101 this._core.$stage.find('.cloned .owl-video-frame').remove(); 2102 } 2103 }, this), 2104 'changed.owl.carousel': $.proxy(function(e) { 2105 if (e.namespace && e.property.name === 'position' && this._playing) { 2106 this.stop(); 2107 } 2108 }, this), 2109 'prepared.owl.carousel': $.proxy(function(e) { 2110 if (!e.namespace) { 2111 return; 2112 } 2113 2114 var $element = $(e.content).find('.owl-video'); 2115 2116 if ($element.length) { 2117 $element.css('display', 'none'); 2118 this.fetch($element, $(e.content)); 2119 } 2120 }, this) 2121 }; 2122 2123 // set default options 2124 this._core.options = $.extend({}, Video.Defaults, this._core.options); 2125 2126 // register event handlers 2127 this._core.$element.on(this._handlers); 2128 2129 this._core.$element.on('click.owl.video', '.owl-video-play-icon', $.proxy(function(e) { 2130 this.play(e); 2131 }, this)); 2132 }; 2133 2134 /** 2135 * Default options. 2136 * @public 2137 */ 2138 Video.Defaults = { 2139 video: false, 2140 videoHeight: false, 2141 videoWidth: false 2142 }; 2143 2144 /** 2145 * Gets the video ID and the type (YouTube/Vimeo/vzaar only). 2146 * @protected 2147 * @param {jQuery} target - The target containing the video data. 2148 * @param {jQuery} item - The item containing the video. 2149 */ 2150 Video.prototype.fetch = function(target, item) { 2151 var type = (function() { 2152 if (target.attr('data-vimeo-id')) { 2153 return 'vimeo'; 2154 } else if (target.attr('data-vzaar-id')) { 2155 return 'vzaar' 2156 } else { 2157 return 'youtube'; 2158 } 2159 })(), 2160 id = target.attr('data-vimeo-id') || target.attr('data-youtube-id') || target.attr('data-vzaar-id'), 2161 width = target.attr('data-width') || this._core.settings.videoWidth, 2162 height = target.attr('data-height') || this._core.settings.videoHeight, 2163 url = target.attr('href'); 2164 2165 if (url) { 2166 2167 /* 2168 Parses the id's out of the following urls (and probably more): 2169 https://www.youtube.com/watch?v=:id 2170 https://youtu.be/:id 2171 https://vimeo.com/:id 2172 https://vimeo.com/channels/:channel/:id 2173 https://vimeo.com/groups/:group/videos/:id 2174 https://app.vzaar.com/videos/:id 2175 2176 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 2177 */ 2178 2179 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+)?/); 2180 2181 if (id[3].indexOf('youtu') > -1) { 2182 type = 'youtube'; 2183 } else if (id[3].indexOf('vimeo') > -1) { 2184 type = 'vimeo'; 2185 } else if (id[3].indexOf('vzaar') > -1) { 2186 type = 'vzaar'; 2187 } else { 2188 throw new Error('Video URL not supported.'); 2189 } 2190 id = id[6]; 2191 } else { 2192 throw new Error('Missing video URL.'); 2193 } 2194 2195 this._videos[url] = { 2196 type: type, 2197 id: id, 2198 width: width, 2199 height: height 2200 }; 2201 2202 item.attr('data-video', url); 2203 2204 this.thumbnail(target, this._videos[url]); 2205 }; 2206 2207 /** 2208 * Creates video thumbnail. 2209 * @protected 2210 * @param {jQuery} target - The target containing the video data. 2211 * @param {Object} info - The video info object. 2212 * @see `fetch` 2213 */ 2214 Video.prototype.thumbnail = function(target, video) { 2215 var tnLink, 2216 icon, 2217 path, 2218 dimensions = video.width && video.height ? 'style="width:' + video.width + 'px;height:' + video.height + 'px;"' : '', 2219 customTn = target.find('img'), 2220 srcType = 'src', 2221 lazyClass = '', 2222 settings = this._core.settings, 2223 create = function(path) { 2224 icon = '<div class="owl-video-play-icon"></div>'; 2225 2226 if (settings.lazyLoad) { 2227 tnLink = '<div class="owl-video-tn ' + lazyClass + '" ' + srcType + '="' + path + '"></div>'; 2228 } else { 2229 tnLink = '<div class="owl-video-tn" style="opacity:1;background-image:url(' + path + ')"></div>'; 2230 } 2231 target.after(tnLink); 2232 target.after(icon); 2233 }; 2234 2235 // wrap video content into owl-video-wrapper div 2236 target.wrap('<div class="owl-video-wrapper"' + dimensions + '></div>'); 2237 2238 if (this._core.settings.lazyLoad) { 2239 srcType = 'data-src'; 2240 lazyClass = 'owl-lazy'; 2241 } 2242 2243 // custom thumbnail 2244 if (customTn.length) { 2245 create(customTn.attr(srcType)); 2246 customTn.remove(); 2247 return false; 2248 } 2249 2250 if (video.type === 'youtube') { 2251 path = "//img.youtube.com/vi/" + video.id + "/hqdefault.jpg"; 2252 create(path); 2253 } else if (video.type === 'vimeo') { 2254 $.ajax({ 2255 type: 'GET', 2256 url: '//vimeo.com/api/v2/video/' + video.id + '.json', 2257 jsonp: 'callback', 2258 dataType: 'jsonp', 2259 success: function(data) { 2260 path = data[0].thumbnail_large; 2261 create(path); 2262 } 2263 }); 2264 } else if (video.type === 'vzaar') { 2265 $.ajax({ 2266 type: 'GET', 2267 url: '//vzaar.com/api/videos/' + video.id + '.json', 2268 jsonp: 'callback', 2269 dataType: 'jsonp', 2270 success: function(data) { 2271 path = data.framegrab_url; 2272 create(path); 2273 } 2274 }); 2275 } 2276 }; 2277 2278 /** 2279 * Stops the current video. 2280 * @public 2281 */ 2282 Video.prototype.stop = function() { 2283 this._core.trigger('stop', null, 'video'); 2284 this._playing.find('.owl-video-frame').remove(); 2285 this._playing.removeClass('owl-video-playing'); 2286 this._playing = null; 2287 this._core.leave('playing'); 2288 this._core.trigger('stopped', null, 'video'); 2289 }; 2290 2291 /** 2292 * Starts the current video. 2293 * @public 2294 * @param {Event} event - The event arguments. 2295 */ 2296 Video.prototype.play = function(event) { 2297 var target = $(event.target), 2298 item = target.closest('.' + this._core.settings.itemClass), 2299 video = this._videos[item.attr('data-video')], 2300 width = video.width || '100%', 2301 height = video.height || this._core.$stage.height(), 2302 html; 2303 2304 if (this._playing) { 2305 return; 2306 } 2307 2308 this._core.enter('playing'); 2309 this._core.trigger('play', null, 'video'); 2310 2311 item = this._core.items(this._core.relative(item.index())); 2312 2313 this._core.reset(item.index()); 2314 2315 if (video.type === 'youtube') { 2316 html = '<iframe width="' + width + '" height="' + height + '" src="//www.youtube.com/embed/' + 2317 video.id + '?autoplay=1&rel=0&v=' + video.id + '" frameborder="0" allowfullscreen></iframe>'; 2318 } else if (video.type === 'vimeo') { 2319 html = '<iframe src="//player.vimeo.com/video/' + video.id + 2320 '?autoplay=1" width="' + width + '" height="' + height + 2321 '" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>'; 2322 } else if (video.type === 'vzaar') { 2323 html = '<iframe frameborder="0"' + 'height="' + height + '"' + 'width="' + width + 2324 '" allowfullscreen mozallowfullscreen webkitAllowFullScreen ' + 2325 'src="//view.vzaar.com/' + video.id + '/player?autoplay=true"></iframe>'; 2326 } 2327 2328 $('<div class="owl-video-frame">' + html + '</div>').insertAfter(item.find('.owl-video')); 2329 2330 this._playing = item.addClass('owl-video-playing'); 2331 }; 2332 2333 /** 2334 * Checks whether an video is currently in full screen mode or not. 2335 * @todo Bad style because looks like a readonly method but changes members. 2336 * @protected 2337 * @returns {Boolean} 2338 */ 2339 Video.prototype.isInFullScreen = function() { 2340 var element = document.fullscreenElement || document.mozFullScreenElement || 2341 document.webkitFullscreenElement; 2342 2343 return element && $(element).parent().hasClass('owl-video-frame'); 2344 }; 2345 2346 /** 2347 * Destroys the plugin. 2348 */ 2349 Video.prototype.destroy = function() { 2350 var handler, property; 2351 2352 this._core.$element.off('click.owl.video'); 2353 2354 for (handler in this._handlers) { 2355 this._core.$element.off(handler, this._handlers[handler]); 2356 } 2357 for (property in Object.getOwnPropertyNames(this)) { 2358 typeof this[property] != 'function' && (this[property] = null); 2359 } 2360 }; 2361 2362 $.fn.owlCarousel.Constructor.Plugins.Video = Video; 2363 2364})(window.Zepto || window.jQuery, window, document); 2365 2366/** 2367 * Animate Plugin 2368 * @version 2.1.0 2369 * @author Bartosz Wojciechowski 2370 * @author
vendor: 1,393 bytes, lines 2370-2428
2370David Deutsch 2371 * @license The MIT License (MIT) 2372 */ 2373;(function($, window, document, undefined) { 2374 2375 /** 2376 * Creates the animate plugin. 2377 * @class The Navigation Plugin 2378 * @param {Owl} scope - The Owl Carousel 2379 */ 2380 var Animate = function(scope) { 2381 this.core = scope; 2382 this.core.options = $.extend({}, Animate.Defaults, this.core.options); 2383 this.swapping = true; 2384 this.previous = undefined; 2385 this.next = undefined; 2386 2387 this.handlers = { 2388 'change.owl.carousel': $.proxy(function(e) { 2389 if (e.namespace && e.property.name == 'position') { 2390 this.previous = this.core.current(); 2391 this.next = e.property.value; 2392 } 2393 }, this), 2394 'drag.owl.carousel dragged.owl.carousel translated.owl.carousel': $.proxy(function(e) { 2395 if (e.namespace) { 2396 this.swapping = e.type == 'translated'; 2397 } 2398 }, this), 2399 'translate.owl.carousel': $.proxy(function(e) { 2400 if (e.namespace && this.swapping && (this.core.options.animateOut || this.core.options.animateIn)) { 2401 this.swap(); 2402 } 2403 }, this) 2404 }; 2405 2406 this.core.$element.on(this.handlers); 2407 }; 2408 2409 /** 2410 * Default options. 2411 * @public 2412 */ 2413 Animate.Defaults = { 2414 animateOut: false, 2415 animateIn: false 2416 }; 2417 2418 /** 2419 * Toggles the animation classes whenever an translations starts. 2420 * @protected 2421 * @returns {Boolean|undefined} 2422 */ 2423 Animate.prototype.swap = function() { 2424 2425 if (this.core.settings.items !== 1) { 2426 return; 2427 } 2428
vendor: 6,167 bytes, lines 2429-2692
2429 if (!$.support.animation || !$.support.transition) { 2430 return; 2431 } 2432 2433 this.core.speed(0); 2434 2435 var left, 2436 clear = $.proxy(this.clear, this), 2437 previous = this.core.$stage.children().eq(this.previous), 2438 next = this.core.$stage.children().eq(this.next), 2439 incoming = this.core.settings.animateIn, 2440 outgoing = this.core.settings.animateOut; 2441 2442 if (this.core.current() === this.previous) { 2443 return; 2444 } 2445 2446 if (outgoing) { 2447 left = this.core.coordinates(this.previous) - this.core.coordinates(this.next); 2448 previous.one($.support.animation.end, clear) 2449 .css( { 'left': left + 'px' } ) 2450 .addClass('animated owl-animated-out') 2451 .addClass(outgoing); 2452 } 2453 2454 if (incoming) { 2455 next.one($.support.animation.end, clear) 2456 .addClass('animated owl-animated-in') 2457 .addClass(incoming); 2458 } 2459 }; 2460 2461 Animate.prototype.clear = function(e) { 2462 $(e.target).css( { 'left': '' } ) 2463 .removeClass('animated owl-animated-out owl-animated-in') 2464 .removeClass(this.core.settings.animateIn) 2465 .removeClass(this.core.settings.animateOut); 2466 this.core.onTransitionEnd(); 2467 }; 2468 2469 /** 2470 * Destroys the plugin. 2471 * @public 2472 */ 2473 Animate.prototype.destroy = function() { 2474 var handler, property; 2475 2476 for (handler in this.handlers) { 2477 this.core.$element.off(handler, this.handlers[handler]); 2478 } 2479 for (property in Object.getOwnPropertyNames(this)) { 2480 typeof this[property] != 'function' && (this[property] = null); 2481 } 2482 }; 2483 2484 $.fn.owlCarousel.Constructor.Plugins.Animate = Animate; 2485 2486})(window.Zepto || window.jQuery, window, document); 2487 2488/** 2489 * Autoplay Plugin 2490 * @version 2.1.0 2491 * @author Bartosz Wojciechowski 2492 * @author Artus Kolanowski 2493 * @author David Deutsch 2494 * @license The MIT License (MIT) 2495 */ 2496;(function($, window, document, undefined) { 2497 2498 /** 2499 * Creates the autoplay plugin. 2500 * @class The Autoplay Plugin 2501 * @param {Owl} scope - The Owl Carousel 2502 */ 2503 var Autoplay = function(carousel) { 2504 /** 2505 * Reference to the core. 2506 * @protected 2507 * @type {Owl} 2508 */ 2509 this._core = carousel; 2510 2511 /** 2512 * The autoplay timeout. 2513 * @type {Timeout} 2514 */ 2515 this._timeout = null; 2516 2517 /** 2518 * Indicates whenever the autoplay is paused. 2519 * @type {Boolean} 2520 */ 2521 this._paused = false; 2522 2523 /** 2524 * All event handlers. 2525 * @protected 2526 * @type {Object} 2527 */ 2528 this._handlers = { 2529 'changed.owl.carousel': $.proxy(function(e) { 2530 if (e.namespace && e.property.name === 'settings') { 2531 if (this._core.settings.autoplay) { 2532 this.play(); 2533 } else { 2534 this.stop(); 2535 } 2536 } else if (e.namespace && e.property.name === 'position') { 2537 //console.log('play?', e); 2538 if (this._core.settings.autoplay) { 2539 this._setAutoPlayInterval(); 2540 } 2541 } 2542 }, this), 2543 'initialized.owl.carousel': $.proxy(function(e) { 2544 if (e.namespace && this._core.settings.autoplay) { 2545 this.play(); 2546 } 2547 }, this), 2548 'play.owl.autoplay': $.proxy(function(e, t, s) { 2549 if (e.namespace) { 2550 this.play(t, s); 2551 } 2552 }, this), 2553 'stop.owl.autoplay': $.proxy(function(e) { 2554 if (e.namespace) { 2555 this.stop(); 2556 } 2557 }, this), 2558 'mouseover.owl.autoplay': $.proxy(function() { 2559 if (this._core.settings.autoplayHoverPause && this._core.is('rotating')) { 2560 this.pause(); 2561 } 2562 }, this), 2563 'mouseleave.owl.autoplay': $.proxy(function() { 2564 if (this._core.settings.autoplayHoverPause && this._core.is('rotating')) { 2565 this.play(); 2566 } 2567 }, this), 2568 'touchstart.owl.core': $.proxy(function() { 2569 if (this._core.settings.autoplayHoverPause && this._core.is('rotating')) { 2570 this.pause(); 2571 } 2572 }, this), 2573 'touchend.owl.core': $.proxy(function() { 2574 if (this._core.settings.autoplayHoverPause) { 2575 this.play(); 2576 } 2577 }, this) 2578 }; 2579 2580 // register event handlers 2581 this._core.$element.on(this._handlers); 2582 2583 // set default options 2584 this._core.options = $.extend({}, Autoplay.Defaults, this._core.options); 2585 }; 2586 2587 /** 2588 * Default options. 2589 * @public 2590 */ 2591 Autoplay.Defaults = { 2592 autoplay: false, 2593 autoplayTimeout: 5000, 2594 autoplayHoverPause: false, 2595 autoplaySpeed: false 2596 }; 2597 2598 /** 2599 * Starts the autoplay. 2600 * @public 2601 * @param {Number} [timeout] - The interval before the next animation starts. 2602 * @param {Number} [speed] - The animation speed for the animations. 2603 */ 2604 Autoplay.prototype.play = function(timeout, speed) { 2605 this._paused = false; 2606 2607 if (this._core.is('rotating')) { 2608 return; 2609 } 2610 2611 this._core.enter('rotating'); 2612 2613 this._setAutoPlayInterval(); 2614 }; 2615 2616 /** 2617 * Gets a new timeout 2618 * @private 2619 * @param {Number} [timeout] - The interval before the next animation starts. 2620 * @param {Number} [speed] - The animation speed for the animations. 2621 * @return {Timeout} 2622 */ 2623 Autoplay.prototype._getNextTimeout = function(timeout, speed) { 2624 if ( this._timeout ) { 2625 window.clearTimeout(this._timeout); 2626 } 2627 return window.setTimeout($.proxy(function() { 2628 if (this._paused || this._core.is('busy') || this._core.is('interacting') || document.hidden) { 2629 return; 2630 } 2631 this._core.next(speed || this._core.settings.autoplaySpeed); 2632 }, this), timeout || this._core.settings.autoplayTimeout); 2633 }; 2634 2635 /** 2636 * Sets autoplay in motion. 2637 * @private 2638 */ 2639 Autoplay.prototype._setAutoPlayInterval = function() { 2640 this._timeout = this._getNextTimeout(); 2641 }; 2642 2643 /** 2644 * Stops the autoplay. 2645 * @public 2646 */ 2647 Autoplay.prototype.stop = function() { 2648 if (!this._core.is('rotating')) { 2649 return; 2650 } 2651 2652 window.clearTimeout(this._timeout); 2653 this._core.leave('rotating'); 2654 }; 2655 2656 /** 2657 * Stops the autoplay. 2658 * @public 2659 */ 2660 Autoplay.prototype.pause = function() { 2661 if (!this._core.is('rotating')) { 2662 return; 2663 } 2664 2665 this._paused = true; 2666 }; 2667 2668 /** 2669 * Destroys the plugin. 2670 */ 2671 Autoplay.prototype.destroy = function() { 2672 var handler, property; 2673 2674 this.stop(); 2675 2676 for (handler in this._handlers) { 2677 this._core.$element.off(handler, this._handlers[handler]); 2678 } 2679 for (property in Object.getOwnPropertyNames(this)) { 2680 typeof this[property] != 'function' && (this[property] = null); 2681 } 2682 }; 2683 2684 $.fn.owlCarousel.Constructor.Plugins.autoplay = Autoplay; 2685 2686})(window.Zepto || window.jQuery, window, document); 2687 2688/** 2689 * Navigation Plugin 2690 * @version 2.1.0 2691 * @author Artus Kolanowski 2692 * @author David Deutsch
vendor: 10,575 bytes, lines 2692-3075
2692 2693 * @license The MIT License (MIT) 2694 */ 2695;(function($, window, document, undefined) { 2696 'use strict'; 2697 2698 /** 2699 * Creates the navigation plugin. 2700 * @class The Navigation Plugin 2701 * @param {Owl} carousel - The Owl Carousel. 2702 */ 2703 var Navigation = function(carousel) { 2704 /** 2705 * Reference to the core. 2706 * @protected 2707 * @type {Owl} 2708 */ 2709 this._core = carousel; 2710 2711 /** 2712 * Indicates whether the plugin is initialized or not. 2713 * @protected 2714 * @type {Boolean} 2715 */ 2716 this._initialized = false; 2717 2718 /** 2719 * The current paging indexes. 2720 * @protected 2721 * @type {Array} 2722 */ 2723 this._pages = []; 2724 2725 /** 2726 * All DOM elements of the user interface. 2727 * @protected 2728 * @type {Object} 2729 */ 2730 this._controls = {}; 2731 2732 /** 2733 * Markup for an indicator. 2734 * @protected 2735 * @type {Array.<String>} 2736 */ 2737 this._templates = []; 2738 2739 /** 2740 * The carousel element. 2741 * @type {jQuery} 2742 */ 2743 this.$element = this._core.$element; 2744 2745 /** 2746 * Overridden methods of the carousel. 2747 * @protected 2748 * @type {Object} 2749 */ 2750 this._overrides = { 2751 next: this._core.next, 2752 prev: this._core.prev, 2753 to: this._core.to 2754 }; 2755 2756 /** 2757 * All event handlers. 2758 * @protected 2759 * @type {Object} 2760 */ 2761 this._handlers = { 2762 'prepared.owl.carousel': $.proxy(function(e) { 2763 if (e.namespace && this._core.settings.dotsData) { 2764 this._templates.push('<div class="' + this._core.settings.dotClass + '">' + 2765 $(e.content).find('[data-dot]').addBack('[data-dot]').attr('data-dot') + '</div>'); 2766 } 2767 }, this), 2768 'added.owl.carousel': $.proxy(function(e) { 2769 if (e.namespace && this._core.settings.dotsData) { 2770 this._templates.splice(e.position, 0, this._templates.pop()); 2771 } 2772 }, this), 2773 'remove.owl.carousel': $.proxy(function(e) { 2774 if (e.namespace && this._core.settings.dotsData) { 2775 this._templates.splice(e.position, 1); 2776 } 2777 }, this), 2778 'changed.owl.carousel': $.proxy(function(e) { 2779 if (e.namespace && e.property.name == 'position') { 2780 this.draw(); 2781 } 2782 }, this), 2783 'initialized.owl.carousel': $.proxy(function(e) { 2784 if (e.namespace && !this._initialized) { 2785 this._core.trigger('initialize', null, 'navigation'); 2786 this.initialize(); 2787 this.update(); 2788 this.draw(); 2789 this._initialized = true; 2790 this._core.trigger('initialized', null, 'navigation'); 2791 } 2792 }, this), 2793 'refreshed.owl.carousel': $.proxy(function(e) { 2794 if (e.namespace && this._initialized) { 2795 this._core.trigger('refresh', null, 'navigation'); 2796 this.update(); 2797 this.draw(); 2798 this._core.trigger('refreshed', null, 'navigation'); 2799 } 2800 }, this) 2801 }; 2802 2803 // set default options 2804 this._core.options = $.extend({}, Navigation.Defaults, this._core.options); 2805 2806 // register event handlers 2807 this.$element.on(this._handlers); 2808 }; 2809 2810 /** 2811 * Default options. 2812 * @public 2813 * @todo Rename `slideBy` to `navBy` 2814 */ 2815 Navigation.Defaults = { 2816 nav: false, 2817 navText: [ 'prev', 'next' ], 2818 navSpeed: false, 2819 navElement: 'div', 2820 navContainer: false, 2821 navContainerClass: 'owl-nav', 2822 navClass: [ 'owl-prev', 'owl-next' ], 2823 slideBy: 1, 2824 dotClass: 'owl-dot', 2825 dotsClass: 'owl-dots', 2826 dots: true, 2827 dotsEach: false, 2828 dotsData: false, 2829 dotsSpeed: false, 2830 dotsContainer: false 2831 }; 2832 2833 /** 2834 * Initializes the layout of the plugin and extends the carousel. 2835 * @protected 2836 */ 2837 Navigation.prototype.initialize = function() { 2838 var override, 2839 settings = this._core.settings; 2840 2841 // create DOM structure for relative navigation 2842 this._controls.$relative = (settings.navContainer ? $(settings.navContainer) 2843 : $('<div>').addClass(settings.navContainerClass).appendTo(this.$element)).addClass('disabled'); 2844 2845 this._controls.$previous = $('<' + settings.navElement + '>') 2846 .addClass(settings.navClass[0]) 2847 .html(settings.navText[0]) 2848 .prependTo(this._controls.$relative) 2849 .on('click', $.proxy(function(e) { 2850 this.prev(settings.navSpeed); 2851 }, this)); 2852 this._controls.$next = $('<' + settings.navElement + '>') 2853 .addClass(settings.navClass[1]) 2854 .html(settings.navText[1]) 2855 .appendTo(this._controls.$relative) 2856 .on('click', $.proxy(function(e) { 2857 this.next(settings.navSpeed); 2858 }, this)); 2859 2860 // create DOM structure for absolute navigation 2861 if (!settings.dotsData) { 2862 this._templates = [ $('<div>') 2863 .addClass(settings.dotClass) 2864 .append($('<span>')) 2865 .prop('outerHTML') ]; 2866 } 2867 2868 this._controls.$absolute = (settings.dotsContainer ? $(settings.dotsContainer) 2869 : $('<div>').addClass(settings.dotsClass).appendTo(this.$element)).addClass('disabled'); 2870 2871 this._controls.$absolute.on('click', 'div', $.proxy(function(e) { 2872 var index = $(e.target).parent().is(this._controls.$absolute) 2873 ? $(e.target).index() : $(e.target).parent().index(); 2874 2875 e.preventDefault(); 2876 2877 this.to(index, settings.dotsSpeed); 2878 }, this)); 2879 2880 // override public methods of the carousel 2881 for (override in this._overrides) { 2882 this._core[override] = $.proxy(this[override], this); 2883 } 2884 }; 2885 2886 /** 2887 * Destroys the plugin. 2888 * @protected 2889 */ 2890 Navigation.prototype.destroy = function() { 2891 var handler, control, property, override; 2892 2893 for (handler in this._handlers) { 2894 this.$element.off(handler, this._handlers[handler]); 2895 } 2896 for (control in this._controls) { 2897 this._controls[control].remove(); 2898 } 2899 for (override in this.overides) { 2900 this._core[override] = this._overrides[override]; 2901 } 2902 for (property in Object.getOwnPropertyNames(this)) { 2903 typeof this[property] != 'function' && (this[property] = null); 2904 } 2905 }; 2906 2907 /** 2908 * Updates the internal state. 2909 * @protected 2910 */ 2911 Navigation.prototype.update = function() { 2912 var i, j, k, 2913 lower = this._core.clones().length / 2, 2914 upper = lower + this._core.items().length, 2915 maximum = this._core.maximum(true), 2916 settings = this._core.settings, 2917 size = settings.center || settings.autoWidth || settings.dotsData 2918 ? 1 : settings.dotsEach || settings.items; 2919 2920 if (settings.slideBy !== 'page') { 2921 settings.slideBy = Math.min(settings.slideBy, settings.items); 2922 } 2923 2924 if (settings.dots || settings.slideBy == 'page') { 2925 this._pages = []; 2926 2927 for (i = lower, j = 0, k = 0; i < upper; i++) { 2928 if (j >= size || j === 0) { 2929 this._pages.push({ 2930 start: Math.min(maximum, i - lower), 2931 end: i - lower + size - 1 2932 }); 2933 if (Math.min(maximum, i - lower) === maximum) { 2934 break; 2935 } 2936 j = 0, ++k; 2937 } 2938 j += this._core.mergers(this._core.relative(i)); 2939 } 2940 } 2941 }; 2942 2943 /** 2944 * Draws the user interface. 2945 * @todo The option `dotsData` wont work. 2946 * @protected 2947 */ 2948 Navigation.prototype.draw = function() { 2949 var difference, 2950 settings = this._core.settings, 2951 disabled = this._core.items().length <= settings.items, 2952 index = this._core.relative(this._core.current()), 2953 loop = settings.loop || settings.rewind; 2954 2955 this._controls.$relative.toggleClass('disabled', !settings.nav || disabled); 2956 2957 if (settings.nav) { 2958 this._controls.$previous.toggleClass('disabled', !loop && index <= this._core.minimum(true)); 2959 this._controls.$next.toggleClass('disabled', !loop && index >= this._core.maximum(true)); 2960 } 2961 2962 this._controls.$absolute.toggleClass('disabled', !settings.dots || disabled); 2963 2964 if (settings.dots) { 2965 difference = this._pages.length - this._controls.$absolute.children().length; 2966 2967 if (settings.dotsData && difference !== 0) { 2968 this._controls.$absolute.html(this._templates.join('')); 2969 } else if (difference > 0) { 2970 this._controls.$absolute.append(new Array(difference + 1).join(this._templates[0])); 2971 } else if (difference < 0) { 2972 this._controls.$absolute.children().slice(difference).remove(); 2973 } 2974 2975 this._controls.$absolute.find('.active').removeClass('active'); 2976 this._controls.$absolute.children().eq($.inArray(this.current(), this._pages)).addClass('active'); 2977 } 2978 }; 2979 2980 /** 2981 * Extends event data. 2982 * @protected 2983 * @param {Event} event - The event object which gets thrown. 2984 */ 2985 Navigation.prototype.onTrigger = function(event) { 2986 var settings = this._core.settings; 2987 2988 event.page = { 2989 index: $.inArray(this.current(), this._pages), 2990 count: this._pages.length, 2991 size: settings && (settings.center || settings.autoWidth || settings.dotsData 2992 ? 1 : settings.dotsEach || settings.items) 2993 }; 2994 }; 2995 2996 /** 2997 * Gets the current page position of the carousel. 2998 * @protected 2999 * @returns {Number} 3000 */ 3001 Navigation.prototype.current = function() { 3002 var current = this._core.relative(this._core.current()); 3003 return $.grep(this._pages, $.proxy(function(page, index) { 3004 return page.start <= current && page.end >= current; 3005 }, this)).pop(); 3006 }; 3007 3008 /** 3009 * Gets the current succesor/predecessor position. 3010 * @protected 3011 * @returns {Number} 3012 */ 3013 Navigation.prototype.getPosition = function(successor) { 3014 var position, length, 3015 settings = this._core.settings; 3016 3017 if (settings.slideBy == 'page') { 3018 position = $.inArray(this.current(), this._pages); 3019 length = this._pages.length; 3020 successor ? ++position : --position; 3021 position = this._pages[((position % length) + length) % length].start; 3022 } else { 3023 position = this._core.relative(this._core.current()); 3024 length = this._core.items().length; 3025 successor ? position += settings.slideBy : position -= settings.slideBy; 3026 } 3027 3028 return position; 3029 }; 3030 3031 /** 3032 * Slides to the next item or page. 3033 * @public 3034 * @param {Number} [speed=false] - The time in milliseconds for the transition. 3035 */ 3036 Navigation.prototype.next = function(speed) { 3037 $.proxy(this._overrides.to, this._core)(this.getPosition(true), speed); 3038 }; 3039 3040 /** 3041 * Slides to the previous item or page. 3042 * @public 3043 * @param {Number} [speed=false] - The time in milliseconds for the transition. 3044 */ 3045 Navigation.prototype.prev = function(speed) { 3046 $.proxy(this._overrides.to, this._core)(this.getPosition(false), speed); 3047 }; 3048 3049 /** 3050 * Slides to the specified item or page. 3051 * @public 3052 * @param {Number} position - The position of the item or page. 3053 * @param {Number} [speed] - The time in milliseconds for the transition. 3054 * @param {Boolean} [standard=false] - Whether to use the standard behaviour or not. 3055 */ 3056 Navigation.prototype.to = function(position, speed, standard) { 3057 var length; 3058 3059 if (!standard && this._pages.length) { 3060 length = this._pages.length; 3061 $.proxy(this._overrides.to, this._core)(this._pages[((position % length) + length) % length].start, speed); 3062 } else { 3063 $.proxy(this._overrides.to, this._core)(position, speed); 3064 } 3065 }; 3066 3067 $.fn.owlCarousel.Constructor.Plugins.Navigation = Navigation; 3068 3069})(window.Zepto || window.jQuery, window, document); 3070 3071/** 3072 * Hash Plugin 3073 * @version 2.1.0 3074 * @author Artus Kolanowski 3075 * @author
vendor: 4,770 bytes, lines 3075-3276
3075David Deutsch 3076 * @license The MIT License (MIT) 3077 */ 3078;(function($, window, document, undefined) { 3079 'use strict'; 3080 3081 /** 3082 * Creates the hash plugin. 3083 * @class The Hash Plugin 3084 * @param {Owl} carousel - The Owl Carousel 3085 */ 3086 var Hash = function(carousel) { 3087 /** 3088 * Reference to the core. 3089 * @protected 3090 * @type {Owl} 3091 */ 3092 this._core = carousel; 3093 3094 /** 3095 * Hash index for the items. 3096 * @protected 3097 * @type {Object} 3098 */ 3099 this._hashes = {}; 3100 3101 /** 3102 * The carousel element. 3103 * @type {jQuery} 3104 */ 3105 this.$element = this._core.$element; 3106 3107 /** 3108 * All event handlers. 3109 * @protected 3110 * @type {Object} 3111 */ 3112 this._handlers = { 3113 'initialized.owl.carousel': $.proxy(function(e) { 3114 if (e.namespace && this._core.settings.startPosition === 'URLHash') { 3115 $(window).trigger('hashchange.owl.navigation'); 3116 } 3117 }, this), 3118 'prepared.owl.carousel': $.proxy(function(e) { 3119 if (e.namespace) { 3120 var hash = $(e.content).find('[data-hash]').addBack('[data-hash]').attr('data-hash'); 3121 3122 if (!hash) { 3123 return; 3124 } 3125 3126 this._hashes[hash] = e.content; 3127 } 3128 }, this), 3129 'changed.owl.carousel': $.proxy(function(e) { 3130 if (e.namespace && e.property.name === 'position') { 3131 var current = this._core.items(this._core.relative(this._core.current())), 3132 hash = $.map(this._hashes, function(item, hash) { 3133 return item === current ? hash : null; 3134 }).join(); 3135 3136 if (!hash || window.location.hash.slice(1) === hash) { 3137 return; 3138 } 3139 3140 window.location.hash = hash; 3141 } 3142 }, this) 3143 }; 3144 3145 // set default options 3146 this._core.options = $.extend({}, Hash.Defaults, this._core.options); 3147 3148 // register the event handlers 3149 this.$element.on(this._handlers); 3150 3151 // register event listener for hash navigation 3152 $(window).on('hashchange.owl.navigation', $.proxy(function(e) { 3153 var hash = window.location.hash.substring(1), 3154 items = this._core.$stage.children(), 3155 position = this._hashes[hash] && items.index(this._hashes[hash]); 3156 3157 if (position === undefined || position === this._core.current()) { 3158 return; 3159 } 3160 3161 this._core.to(this._core.relative(position), false, true); 3162 }, this)); 3163 }; 3164 3165 /** 3166 * Default options. 3167 * @public 3168 */ 3169 Hash.Defaults = { 3170 URLhashListener: false 3171 }; 3172 3173 /** 3174 * Destroys the plugin. 3175 * @public 3176 */ 3177 Hash.prototype.destroy = function() { 3178 var handler, property; 3179 3180 $(window).off('hashchange.owl.navigation'); 3181 3182 for (handler in this._handlers) { 3183 this._core.$element.off(handler, this._handlers[handler]); 3184 } 3185 for (property in Object.getOwnPropertyNames(this)) { 3186 typeof this[property] != 'function' && (this[property] = null); 3187 } 3188 }; 3189 3190 $.fn.owlCarousel.Constructor.Plugins.Hash = Hash; 3191 3192})(window.Zepto || window.jQuery, window, document); 3193 3194/** 3195 * Support Plugin 3196 * 3197 * @version 2.1.0 3198 * @author Vivid Planet Software GmbH 3199 * @author Artus Kolanowski 3200 * @author David Deutsch 3201 * @license The MIT License (MIT) 3202 */ 3203;(function($, window, document, undefined) { 3204 3205 var style = $('<support>').get(0).style, 3206 prefixes = 'Webkit Moz O ms'.split(' '), 3207 events = { 3208 transition: { 3209 end: { 3210 WebkitTransition: 'webkitTransitionEnd', 3211 MozTransition: 'transitionend', 3212 OTransition: 'oTransitionEnd', 3213 transition: 'transitionend' 3214 } 3215 }, 3216 animation: { 3217 end: { 3218 WebkitAnimation: 'webkitAnimationEnd', 3219 MozAnimation: 'animationend', 3220 OAnimation: 'oAnimationEnd', 3221 animation: 'animationend' 3222 } 3223 } 3224 }, 3225 tests = { 3226 csstransforms: function() { 3227 return !!test('transform'); 3228 }, 3229 csstransforms3d: function() { 3230 return !!test('perspective'); 3231 }, 3232 csstransitions: function() { 3233 return !!test('transition'); 3234 }, 3235 cssanimations: function() { 3236 return !!test('animation'); 3237 } 3238 }; 3239 3240 function test(property, prefixed) { 3241 var result = false, 3242 upper = property.charAt(0).toUpperCase() + property.slice(1); 3243 3244 $.each((property + ' ' + prefixes.join(upper + ' ') + upper).split(' '), function(i, property) { 3245 if (style[property] !== undefined) { 3246 result = prefixed ? property : true; 3247 return false; 3248 } 3249 }); 3250 3251 return result; 3252 } 3253 3254 function prefixed(property) { 3255 return test(property, true); 3256 } 3257 3258 if (tests.csstransitions()) { 3259 /* jshint -W053 */ 3260 $.support.transition = new String(prefixed('transition')) 3261 $.support.transition.end = events.transition.end[ $.support.transition ]; 3262 } 3263 3264 if (tests.cssanimations()) { 3265 /* jshint -W053 */ 3266 $.support.animation = new String(prefixed('animation')) 3267 $.support.animation.end = events.animation.end[ $.support.animation ]; 3268 } 3269 3270 if (tests.csstransforms()) { 3271 /* jshint -W053 */ 3272 $.support.transform = new String(prefixed('transform')); 3273 $.support.transform3d = tests.csstransforms3d(); 3274 } 3275 3276})(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.