1(function($) 2{ 3 "use strict"; 4 5 // ------------------------------------------------------------------------------------------- 6 // Avia Text Rotator 7 // 8 // accordion slider script 9 // ------------------------------------------------------------------------------------------- 10 11 $.AviaTextRotator = function(options, slider) 12 { 13 this.$win = $( window ); 14 this.$slider = $( slider ); 15 this.$inner = this.$slider.find('.av-rotator-text'); 16 this.$slides = this.$inner.find('.av-rotator-text-single'); 17 this.$current = this.$slides.eq(0); 18 this.open = 0; 19 this.count = this.$slides.length; 20 21 if($.avia_utilities.supported.transition === undefined) 22 { 23 $.avia_utilities.supported.transition = $.avia_utilities.supports('transition'); 24 } 25 26 this.browserPrefix = $.avia_utilities.supported.transition; 27 this.cssActive = this.browserPrefix !== false ? true : false; 28 this.property = this.browserPrefix + 'transform', 29 30 //this.cssActive = false; //testing no css3 browser 31 32 this._init( options ); 33 } 34 35 $.AviaTextRotator.prototype = 36 { 37 _init: function( options ) 38 { 39 var _self = this; 40 41 if(this.count <= 1) return; 42 43 _self.options = $.extend({}, options, this.$slider.data()); 44 _self.$inner.addClass('av-rotation-active'); 45 //if(_self.options.fixwidth == 1) this.$inner.width(this.$current.width()); 46 _self._autoplay(); 47 48 if(_self.options.animation == "typewriter") 49 { 50 _self.$slider.addClass('av-caret av-blinking-caret'); 51 } 52 53 54 }, 55 56 _autoplay: function() 57 { 58 var _self = this; 59 60 _self.autoplay = setTimeout(function() 61 { 62 _self.open = _self.open === false ? 0 : _self.open + 1; 63 if(_self.open >= _self.count) _self.open = 0; 64 65 if(_self.options.animation != "typewriter") 66 { 67 _self._move({}, _self.open); 68 _self._autoplay(); 69 } 70 else 71 { 72 _self._typewriter(); 73 } 74 75 76 }, _self.options.interval * 1000) 77 }, 78 79 _typewriter: function(event) 80 { 81 var _self = this; 82 83 //mark text 84 _self.$current.css('background-color', _self.$current.css('color') ); 85 _self.$slider.removeClass('av-caret av-blinking-caret').addClass('av-marked-text'); 86 87 88 //store and hide text 89 setTimeout(function() 90 { 91 _self.$slider.addClass('av-caret av-blinking-caret').removeClass('av-marked-text'); 92 _self.$current.data('av_typewriter_text', _self.$current.html()); 93 _self.$current.css('background-color', 'transparent'); 94 _self.$current.html(""); 95 96 }, 800 ); 97 98 99 //start typing new text 100 setTimeout(function() 101 { 102 _self.$slider.removeClass('av-blinking-caret'); 103 _self.$next = _self.$slides.eq(_self.open); 104 var content = _self.$next.data('av_typewriter_text') || _self.$next.html(); 105 _self.$current.css({display:'none'}); 106 _self.$next.css({display:'inline'}); 107 _self.$next.html(""); 108 109 var i = 0; 110 var speed = 50; /* The speed/duration of the effect in milliseconds */ 111 112 function typeWriter() { 113 114 if (i < content.length) { 115 _self.$next[0].innerHTML += content.charAt(i); 116 i++; 117 setTimeout(typeWriter, speed + Math.floor(Math.random() * 100 ) ); 118 } 119 else 120 { 121 _self.$slider.addClass('av-caret av-blinking-caret'); 122 _self.$current = _self.$slides.eq(_self.open); 123 _self._autoplay(); 124 } 125 126 } 127 128 typeWriter(); 129 130 }, 1500 ); 131 }, 132 133 _move: function(event) 134 { 135 var _self = this, 136 modifier = 30 * _self.options.animation, 137 fade_out = {opacity:0}, 138 fade_start = {display:'inline-block', opacity:0}, 139 fade_in = {opacity:1}; 140 141 this.$next = _self.$slides.eq(this.open); 142 143 if(this.cssActive) 144 { 145 fade_out[_self.property] = "translate(0px," + modifier +"px)"; 146 fade_start[_self.property] = "translate(0px," + (modifier * -1) +"px)"; 147 fade_in[_self.property] = "translate(0px,0px)"; 148 } 149 else 150 { 151 fade_out['top'] = modifier; 152 fade_start['top'] = (modifier * -1); 153 fade_in['top'] = 0; 154 } 155 156 157 _self.$current.avia_animate(fade_out, function() 158 { 159 _self.$current.css({display:'none'}); 160 _self.$next.css(fade_start).avia_animate(fade_in, function() 161 { 162 _self.$current = _self.$slides.eq(_self.open); 163 }); 164 }); 165 } 166 }; 167 168 169 $.fn.avia_textrotator = function( options ) 170 { 171 return this.each(function() 172 { 173 var active = $.data( this, 'AviaTextRotator' ); 174 175 if(!active) 176 { 177 //make sure that the function doesnt get aplied a second time 178 $.data( this, 'AviaTextRotator', 1 ); 179 180 //create the preparations for fullscreen slider 181 new $.AviaTextRotator( options, this ); 182 } 183 }); 184 } 185 186}(jQuery));
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.