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