vendor: 3,512 bytes, lines 1-161
1/** 2 * Autoplay Plugin 3 * @version 2.0.0 4 * @author Bartosz Wojciechowski 5 * @author Artus Kolanowski 6 * @license The MIT License (MIT) 7 */ 8;(function($, window, document, undefined) { 9 10 /** 11 * Creates the autoplay plugin. 12 * @class The Autoplay Plugin 13 * @param {Owl} scope - The Owl Carousel 14 */ 15 var Autoplay = function(carousel) { 16 /** 17 * Reference to the core. 18 * @protected 19 * @type {Owl} 20 */ 21 this._core = carousel; 22 23 /** 24 * The autoplay interval. 25 * @type {Number} 26 */ 27 this._interval = null; 28 29 /** 30 * Indicates whenever the autoplay is paused. 31 * @type {Boolean} 32 */ 33 this._paused = false; 34 35 /** 36 * All event handlers. 37 * @protected 38 * @type {Object} 39 */ 40 this._handlers = { 41 'changed.owl.carousel': $.proxy(function(e) { 42 if (e.namespace && e.property.name === 'settings') { 43 if (this._core.settings.autoplay) { 44 this.play(); 45 } else { 46 this.stop(); 47 } 48 } 49 }, this), 50 'initialized.owl.carousel': $.proxy(function(e) { 51 if (e.namespace && this._core.settings.autoplay) { 52 this.play(); 53 } 54 }, this), 55 'play.owl.autoplay': $.proxy(function(e, t, s) { 56 if (e.namespace) { 57 this.play(t, s); 58 } 59 }, this), 60 'stop.owl.autoplay': $.proxy(function(e) { 61 if (e.namespace) { 62 this.stop(); 63 } 64 }, this), 65 'mouseover.owl.autoplay': $.proxy(function() { 66 if (this._core.settings.autoplayHoverPause && this._core.is('rotating')) { 67 this.pause(); 68 } 69 }, this), 70 'mouseleave.owl.autoplay': $.proxy(function() { 71 if (this._core.settings.autoplayHoverPause && this._core.is('rotating')) { 72 this.play(); 73 } 74 }, this) 75 }; 76 77 // register event handlers 78 this._core.$element.on(this._handlers); 79 80 // set default options 81 this._core.options = $.extend({}, Autoplay.Defaults, this._core.options); 82 }; 83 84 /** 85 * Default options. 86 * @public 87 */ 88 Autoplay.Defaults = { 89 autoplay: false, 90 autoplayTimeout: 5000, 91 autoplayHoverPause: false, 92 autoplaySpeed: false 93 }; 94 95 /** 96 * Starts the autoplay. 97 * @public 98 * @param {Number} [timeout] - The interval before the next animation starts. 99 * @param {Number} [speed] - The animation speed for the animations. 100 */ 101 Autoplay.prototype.play = function(timeout, speed) { 102 this._paused = false; 103 104 if (this._core.is('rotating')) { 105 return; 106 } 107 108 this._core.enter('rotating'); 109 110 this._interval = window.setInterval($.proxy(function() { 111 if (this._paused || this._core.is('busy') || this._core.is('interacting') || document.hidden) { 112 return; 113 } 114 this._core.next(speed || this._core.settings.autoplaySpeed); 115 }, this), timeout || this._core.settings.autoplayTimeout); 116 }; 117 118 /** 119 * Stops the autoplay. 120 * @public 121 */ 122 Autoplay.prototype.stop = function() { 123 if (!this._core.is('rotating')) { 124 return; 125 } 126 127 window.clearInterval(this._interval); 128 this._core.leave('rotating'); 129 }; 130 131 /** 132 * Stops the autoplay. 133 * @public 134 */ 135 Autoplay.prototype.pause = function() { 136 if (!this._core.is('rotating')) { 137 return; 138 } 139 140 this._paused = true; 141 }; 142 143 /** 144 * Destroys the plugin. 145 */ 146 Autoplay.prototype.destroy = function() { 147 var handler, property; 148 149 this.stop(); 150 151 for (handler in this._handlers) { 152 this._core.$element.off(handler, this._handlers[handler]); 153 } 154 for (property in Object.getOwnPropertyNames(this)) { 155 typeof this[property] != 'function' && (this[property] = null); 156 } 157 }; 158 159 $.fn.owlCarousel.Constructor.Plugins.autoplay = Autoplay; 160 161})(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.