1/** 2 * Abt Plugin 3 * 4 * Description: 5 * Add some individual features to the awesome, phenomenal and phantastic owl carousel. 6 * 7 * @author Daniel Reichel 8 */ 9(function($, window, document, undefined){ 10 11 /** 12 * Abt plugin object 13 */ 14 var Abt = function(carousel) { 15 /** 16 * Reference to the core. 17 * @protected 18 * @type {Owl} 19 */ 20 this._core = carousel; 21 22 /** 23 * All event handlers. 24 * @protected 25 * @type {Object} 26 */ 27 this._handlers = { 28 'initialized.owl.carousel': $.proxy(function(e) { 29 if (e.namespace) { 30 this._core.$element.find('.owl-prev, .owl-next').wrapInner('<span></span>'); 31 this.moveDots(); 32 this.numberateDots(); 33 } 34 }, this), 35 'changed.owl.carousel initialized.owl.carousel refreshed.owl.carousel': $.proxy(function(e) { 36 if (e.namespace) { 37 this.addClasses(); 38 //this.addAdditionalActiveStates(); 39 } 40 }, this), 41 'translate.owl.carousel': $.proxy(function(e) { 42 if (e.namespace) { 43 //ABT.bootstrap.resizeEmbedResponsiveItems(this._core.$element); 44 } 45 }, this) 46 }; 47 48 // register event handlers 49 this._core.$element.on(this._handlers); 50 }; 51 52 /** 53 * Move dots to navigation to have everything in line. 54 * @return {void} 55 */ 56 Abt.prototype.moveDots = function() { 57 this._core.$element.find('.owl-dots').insertAfter(this._core.$element.find('.owl-nav .owl-prev')); 58 }; 59 60 /** 61 * Add additional classes. 62 * @return {void} 63 */ 64 Abt.prototype.addClasses = function() { 65 var items = this._core.$element.find('.owl-item:not(.cloned)'); 66 67 if(items.length < 3) { 68 this._core.$element.parent().addClass('abt-carousel--reducedMode'); 69 } else { 70 this._core.$element.parent().removeClass('abt-carousel--reducedMode'); 71 } 72 73 if(items.length > 8) { 74 this._core.$element.parent().addClass('abt-carousel--numberMode'); 75 } else { 76 this._core.$element.parent().removeClass('abt-carousel--numberMode'); 77 } 78 }; 79 80 /** 81 * Add a number to each dot. 82 * @return {void} 83 */ 84 Abt.prototype.numberateDots = function() { 85 this._core.$element.find('.owl-dots .owl-dot').each(function(i,dot){ 86 $(dot).children('span').html(i+1); 87 }); 88 }; 89 90 /** 91 * Add subactive state to the dots of visible items. 92 * @return {void} 93 */ 94 Abt.prototype.addAdditionalActiveStates = function() { 95 $('.owl-dots .subactive').removeClass('subactive'); 96 97 var visibleItems = this.getVisibleItems(); 98 this._core.$element.find('.owl-dots').children(':eq(' + visibleItems.join('), :eq(') + ')').addClass('subactive'); 99 }; 100 101 /** 102 * Return the indexes of all visible items. 103 * @return {Array} 104 */ 105 Abt.prototype.getVisibleItems = function() { 106 var visibleItems = []; 107 108 if(this._core.$stage) { 109 var items = this._core.$stage.children(); 110 var firstActiveItem = this._core.$stage.first('.active'); 111 var lastActiveItem = this._core.$stage.last('.active'); 112 var relevantItems = []; 113 114 this._core.$stage.children().each(function(i, item){ 115 if(!($(item).hasClass('cloned') && !$(item).hasClass('active'))) { 116 relevantItems.push(item); 117 } 118 }); 119 120 $(relevantItems).each(function(j, relevantItem){ 121 if($(relevantItem).hasClass('active')) { 122 visibleItems.push(j); 123 } 124 }); 125 } 126 127 return visibleItems; 128 }; 129 130 $.fn.owlCarousel.Constructor.Plugins.Abt = Abt; 131 132})(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.