1/** 2 * Animated headline (Codrops-style). Initialises on Elementor element_ready so imported / late-rendered widgets work. 3 */ 4;(function ($) { 5 'use strict'; 6 7 var animationDelay = 2500, 8 barAnimationDelay = 3800, 9 barWaiting = barAnimationDelay - 3000, 10 lettersDelay = 50, 11 typeLettersDelay = 150, 12 selectionDuration = 500, 13 typeAnimationDelay = selectionDuration + 800, 14 revealDuration = 600, 15 revealAnimationDelay = 1500; 16 17 function initHeadlineInScope($context) { 18 if (!$context || !$context.length) { 19 return; 20 } 21 var $headlines = $context.find('.cd-headline').not('.htmega-animated-heading-initialized'); 22 if (!$headlines.length) { 23 return; 24 } 25 $headlines.addClass('htmega-animated-heading-initialized'); 26 singleLetters($headlines.filter('.letters').find('b')); 27 animateHeadline($headlines); 28 } 29 30 function singleLetters($words) { 31 $words.each(function () { 32 var word = $(this), 33 letters = word.text().split(''), 34 selected = word.hasClass('is-visible'), 35 i; 36 for (i in letters) { 37 if (word.parents('.rotate-2').length > 0) { 38 letters[i] = '<em>' + letters[i] + '</em>'; 39 } 40 letters[i] = selected ? '<i class="in">' + letters[i] + '</i>' : '<i>' + letters[i] + '</i>'; 41 } 42 var newLetters = letters.join(''); 43 word.html(newLetters).css('opacity', 1); 44 }); 45 } 46 47 function animateHeadline($headlines) { 48 var duration = animationDelay; 49 $headlines.each(function () { 50 var headline = $(this); 51 52 if (headline.hasClass('loading-bar')) { 53 duration = barAnimationDelay; 54 setTimeout(function () { 55 headline.find('.cd-words-wrapper').addClass('is-loading'); 56 }, barWaiting); 57 } else if (headline.hasClass('clip')) { 58 var spanWrapper = headline.find('.cd-words-wrapper'), 59 newWidth = spanWrapper.width() + 10; 60 spanWrapper.css('width', newWidth); 61 } else if (!headline.hasClass('type')) { 62 var words = headline.find('.cd-words-wrapper b'), 63 width = 0; 64 words.each(function () { 65 var wordWidth = $(this).width(); 66 if (wordWidth > width) { 67 width = wordWidth; 68 } 69 }); 70 headline.find('.cd-words-wrapper').css('width', width); 71 } 72 73 setTimeout(function () { 74 hideWord(headline.find('.is-visible').eq(0)); 75 }, duration); 76 }); 77 } 78 79 function hideWord($word) { 80 var nextWord = takeNext($word); 81 82 if ($word.parents('.cd-headline').hasClass('type')) { 83 var parentSpan = $word.parent('.cd-words-wrapper'); 84 parentSpan.addClass('selected').removeClass('waiting'); 85 setTimeout(function () { 86 parentSpan.removeClass('selected'); 87 $word.removeClass('is-visible').addClass('is-hidden').children('i').removeClass('in').addClass('out'); 88 }, selectionDuration); 89 setTimeout(function () { 90 showWord(nextWord, typeLettersDelay); 91 }, typeAnimationDelay); 92 } else if ($word.parents('.cd-headline').hasClass('letters')) { 93 var bool = $word.children('i').length >= nextWord.children('i').length; 94 hideLetter($word.find('i').eq(0), $word, bool, lettersDelay); 95 showLetter(nextWord.find('i').eq(0), nextWord, bool, lettersDelay); 96 } else if ($word.parents('.cd-headline').hasClass('clip')) { 97 $word.parents('.cd-words-wrapper').animate({ width: '2px' }, revealDuration, function () { 98 switchWord($word, nextWord); 99 showWord(nextWord); 100 }); 101 } else if ($word.parents('.cd-headline').hasClass('loading-bar')) { 102 $word.parents('.cd-words-wrapper').removeClass('is-loading'); 103 switchWord($word, nextWord); 104 setTimeout(function () { 105 hideWord(nextWord); 106 }, barAnimationDelay); 107 setTimeout(function () { 108 $word.parents('.cd-words-wrapper').addClass('is-loading'); 109 }, barWaiting); 110 } else { 111 switchWord($word, nextWord); 112 setTimeout(function () { 113 hideWord(nextWord); 114 }, animationDelay); 115 } 116 } 117 118 function showWord($word, $duration) { 119 if ($word.parents('.cd-headline').hasClass('type')) { 120 showLetter($word.find('i').eq(0), $word, false, $duration); 121 $word.addClass('is-visible').removeClass('is-hidden'); 122 } else if ($word.parents('.cd-headline').hasClass('clip')) { 123 $word.parents('.cd-words-wrapper').animate({ width: $word.width() + 10 }, revealDuration, function () { 124 setTimeout(function () { 125 hideWord($word); 126 }, 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 }, 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('.cd-headline').hasClass('type')) { 159 setTimeout(function () { 160 $word.parents('.cd-words-wrapper').addClass('waiting'); 161 }, 200); 162 } 163 if (!$bool) { 164 setTimeout(function () { 165 hideWord($word); 166 }, animationDelay); 167 } 168 } 169 } 170 171 function takeNext($word) { 172 return !$word.is(':last-child') ? $word.next() : $word.parent().children().eq(0); 173 } 174 175 function switchWord($oldWord, $newWord) { 176 $oldWord.removeClass('is-visible').addClass('is-hidden'); 177 $newWord.removeClass('is-hidden').addClass('is-visible'); 178 } 179 180 var elementorHookRegistered = false;
181 182 function registerElementorHook() { 183 if (elementorHookRegistered) { 184 return; 185 } 186 if (typeof window.elementorFrontend === 'undefined' || !elementorFrontend.hooks) { 187 return; 188 } 189 elementorHookRegistered = true; 190 elementorFrontend.hooks.addAction( 191 'frontend/element_ready/htmega-animatedheading-addons.default', 192 function ($scope) { 193 initHeadlineInScope($scope); 194 } 195 ); 196 } 197 198 $(function () { 199 $(window).on('elementor/frontend/init', registerElementorHook); 200 registerElementorHook(); 201 if (typeof window.elementorFrontend === 'undefined') { 202 initHeadlineInScope($(document)); 203 } 204 }); 205})(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.