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