1(function($) { 2 3 $.fn.animatedHeadline = function(options) { 4 var settings = $.extend({ 5 // Below are the default settings. 6 animationType: "rotate-1", 7 animationDelay: 2500, 8 barAnimationDelay: 3800, 9 barWaiting: 800, 10 lettersDelay: 50, 11 typeLettersDelay: 150, 12 selectionDuration: 500, 13 typeAnimationDelay: 1300, 14 revealDuration: 600, 15 revealAnimationDelay: 1500 16 }, options ); 17 18 var duration = settings.animationDelay; 19 20 this.each( function() { 21 var headline = $(this); 22 23 if (settings.animationType) { 24 if (settings.animationType == 'type' || 25 settings.animationType == 'rotate-2' || 26 settings.animationType == 'rotate-3' || 27 settings.animationType == 'scale') { 28 headline.find('.ah-headline').addClass('letters ' + settings.animationType); 29 } else if (settings.animationType == 'clip') { 30 headline.find('.ah-headline').addClass(settings.animationType + ' is-full-width'); 31 } else { 32 headline.find('.ah-headline').addClass(settings.animationType); 33 } 34 } 35 36 singleLetters($('.ah-headline.letters').find('b')); 37 38 if(headline.hasClass('loading-bar')) { 39 duration = settings.barAnimationDelay; 40 setTimeout(function() { 41 headline.find('.ah-words-wrapper').addClass('is-loading') 42 }, settings.barWaiting); 43 } else if (headline.hasClass('clip')){ 44 var spanWrapper = headline.find('.ah-words-wrapper'), 45 newWidth = spanWrapper.width() + 10; 46 spanWrapper.css('width', newWidth); 47 } else if (!headline.find('.ah-headline').hasClass('type') ) { 48 //assign to .ah-words-wrapper the width of its longest word 49 var words = headline.find('.ah-words-wrapper b'), 50 width = 0; 51 words.each(function(){ 52 var wordWidth = $(this).width(); 53 if (wordWidth > width) width = wordWidth; 54 }); 55 headline.find('.ah-words-wrapper').css('width', width); 56 }; 57 58 //trigger animation 59 setTimeout(function(){ 60 hideWord( headline.find('.is-visible').eq(0) ) 61 }, duration); 62 }); 63 64 function singleLetters(words) { 65 words.each(function(){ 66 var word = $(this),
67 letters = word.text().split(''), 68 selected = word.hasClass('is-visible'); 69 for (i in letters) { 70 if(word.parents('.rotate-2').length > 0) letters[i] = '<em>' + letters[i] + '</em>'; 71 letters[i] = (selected) ? '<i class="in">' + letters[i] + '</i>': '<i>' + letters[i] + '</i>'; 72 } 73 var newLetters = letters.join(''); 74 word.html(newLetters).css('opacity', 1); 75 }); 76 } 77 78 function hideWord(word) { 79 var nextWord = takeNext(word); 80 81 if(word.parents('.ah-headline').hasClass('type')) { 82 var parentSpan = word.parent('.ah-words-wrapper'); 83 parentSpan.addClass('selected').removeClass('waiting'); 84 setTimeout(function(){ 85 parentSpan.removeClass('selected'); 86 word.removeClass('is-visible').addClass('is-hidden').children('i').removeClass('in').addClass('out'); 87 }, settings.selectionDuration); 88 setTimeout(function(){ 89 showWord(nextWord, settings.typeLettersDelay) 90 }, settings.typeAnimationDelay); 91 92 } else if(word.parents('.ah-headline').hasClass('letters')) { 93 var bool = (word.children('i').length >= nextWord.children('i').length) ? true : false; 94 hideLetter(word.find('i').eq(0), word, bool, settings.lettersDelay); 95 showLetter(nextWord.find('i').eq(0), nextWord, bool, settings.lettersDelay); 96 97 } else if(word.parents('.ah-headline').hasClass('clip')) { 98 word.parents('.ah-words-wrapper').animate({ width : '2px' }, settings.revealDuration, function(){ 99 switchWord(word, nextWord); 100 showWord(nextWord); 101 }); 102 103 } else if (word.parents('.ah-headline').hasClass('loading-bar')){ 104 word.parents('.ah-words-wrapper').removeClass('is-loading'); 105 switchWord(word, nextWord); 106 setTimeout(function(){ hideWord(nextWord) }, settings.barAnimationDelay); 107 setTimeout(function(){ word.parents('.ah-words-wrapper').addClass('is-loading') }, settings.barWaiting); 108 109 } else { 110 switchWord(word, nextWord); 111 setTimeout(function(){ 112 hideWord(nextWord) 113 }, settings.animationDelay); 114 } 115 } 116 117 function showWord(word, duration) { 118 if(word.parents('.ah-headline').hasClass('type')) { 119 showLetter(word.find('i').eq(0), word, false, duration); 120 word.addClass('is-visible').removeClass('is-hidden'); 121 122 } else if(word.parents('.ah-headline').hasClass('clip')) { 123 word.parents('.ah-words-wrapper').animate({ 'width' : word.width() + 10 }, settings.revealDuration, function(){ 124 setTimeout(function(){ 125 hideWord(word) 126 }, settings.revealAnimationDelay); 127 }); 128 } 129 } 130 131 function hideLetter(letter, word, bool, duration) { 132 letter.removeClass('in').addClass('out'); 133 134 if(!letter.is(':last-child')) { 135 setTimeout(function(){ 136 hideLetter(letter.next(), word, bool, duration); 137 }, duration); 138 } else if(bool) { 139 setTimeout(function(){ 140 hideWord(takeNext(word)) 141 }, settings.animationDelay); 142 } 143 144 if(letter.is(':last-child') && $('html').hasClass('no-csstransitions')) { 145 var nextWord = takeNext(word); 146 switchWord(word, nextWord); 147 } 148 } 149 150 function showLetter(letter, word, bool, duration) { 151 letter.addClass('in').removeClass('out'); 152 153 if(!letter.is(':last-child')) { 154 setTimeout(function(){ 155 showLetter(letter.next(), word, bool, duration); 156 }, duration); 157 } else { 158 if(word.parents('.ah-headline').hasClass('type')) { 159 setTimeout(function(){ 160 word.parents('.ah-words-wrapper').addClass('waiting'); 161 }, 200);} 162 if(!bool) { setTimeout(function(){ 163 hideWord(word) 164 }, settings.animationDelay) } 165 } 166 } 167 168 function takeNext(word) { 169 return (!word.is(':last-child')) ? word.next() : word.parent().children().eq(0); 170 } 171 172 function takePrev(word) { 173 return (!word.is(':first-child')) ? word.prev() : word.parent().children().last(
173); 174 } 175 176 function switchWord(oldWord, newWord) { 177 oldWord.removeClass('is-visible').addClass('is-hidden'); 178 newWord.removeClass('is-hidden').addClass('is-visible'); 179 } 180 }; 181 182}(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.