PageSourceSearch

https://www.afc.fm/wp-content/plugins/kentha-elementor/assets/js/extend.js?ver=1732708543

js afc.fm collected 2026-10-08 22:13:32 UTC 20,230 bytes, 572 lines download raw bytes

1/**====================================================================
2 *
3 *  Main Script File
4 *
5 *====================================================================*/
6/* jshint unused:false */
7/*globals snabbt */
8
9(function($) {
10	"use strict";
11	$.kenthaElementor = {
12		window: $(window),
13		fxActivationClass: 'kentha-fx-on',
14		
15		/**
16		 * ====================================================================
17		 * Global options
18		 * ====================================================================
19		 */
20		options: {
21			glitchDuration: 1000, //glitchFx
22			glitchPause: 4000, //glitchFx
23		},
24
25		/**
26		 * ====================================================================
27		 * Initialization
28		 * ====================================================================
29		 */
30		__init: function(){
31			var kenthaElementor = this;
32			kenthaElementor.countFps(kenthaElementor);
33			kenthaElementor.kenthaCarousel(kenthaElementor, 'init', 'body');
34			kenthaElementor.windowResized(kenthaElementor);
35			kenthaElementor.kenthaMouseMove.init( kenthaElementor );
36			kenthaElementor.fx3dElements.init(kenthaElementor);
37			kenthaElementor.kenthaSectionFx();
38			kenthaElementor.glitchParticles.init( kenthaElementor );
39			kenthaElementor.glitchText.init( kenthaElementor );
40			kenthaElementor.glitchPics.init( kenthaElementor );
41			kenthaElementor.glitchLoop.init( kenthaElementor );
42		},
43
44
45		/**
46		 * ====================================================================
47		 *  FPS counter
48		 * ====================================================================
49		 */
50		countFps: function(kenthaElementor){
51			var that = this;
52			var body = $("body");
53			var debugOutput = ($("body").data('jsdebug'))? 1 : 0;
54			body.append('<output id="kentha-elementor-PerformanceCheck" style="position: fixed;bottom: 0px;left: auto; right:0;padding: 0 2px;opacity: '+debugOutput+';background:black;color:white;z-index:100; font-size: 10px;"></output>');
55			var $out = $('#kentha-elementor-PerformanceCheck');
56			that.countFPSf = (function () {
57			  var lastLoop = (new Date()).getMilliseconds();
58			  var count = 1;
59			  var fps = 0;
60			  return function () {
61				var currentLoop = (new Date()).getMilliseconds();
62				if (lastLoop > currentLoop) {
63				  fps = count;
64				  count = 1;
65				} else {
66				  count += 1;
67				}
68				lastLoop = currentLoop;
69				kenthaElementor.fps = fps;
70				return fps;
71			  };
72			}());
73			
74			(function loop() {
75				requestAnimationFrame(function () {
76				  $out.html(that.countFPSf() + 'FPS');
77				  loop();
78				});
79			}());
80		},
81
82		/**
83		 * ====================================================================
84		 * Trigger custom functions on window resize
85		 * ====================================================================
86		 */
87		windowResized: function(v){
88			var rst;
89			var	w = v.window;
90			v.wW = v.window.width();
91			v.wH = v.window.height();
92			w.on('resize', function() {
93				clearTimeout(rst);
94				rst = setTimeout(function() {
95					if (w.width() != v.wW){
96						v.wW = w.width();
97						v.animation3D.reset();
98						v.kenthaMouseMove.init( v );
99					}
100					if (w.height() != v.wH){
101						v.wH = w.height(); // used in other functions
102					}
103				}, 1000);
104			});
105		},
106
107	
108		/**
109		 * ====================================================================
110		 *  Mouse move binding
111		 *  * Do not run on small screens
112		 *  * Do not run if the FPS are too low, prevent browser stuck
113		 * ====================================================================
114		 */
115		kenthaMouseMove: {
116			init: function( kentha ){
117				var win = kentha.window;
118				win.off('mousemove.kenthaspace'); //kenthaspace = aleatory namespace
119				kentha.mousePos = { x: kentha.wW / 2, y: kentha.wH / 2 };
120				win.trigger('kenthaMouseMoved');
121				kentha.mouseAnimation = false;
122				if( win.width() > 1190 ){
123					win.on('mousemove.kenthaspace', function(e){ // stateful 
124						kentha.mousePos = { 
125							x: e.pageX,
126							y: e.pageY
127						};
128						win.trigger('kenthaMouseMoved'); 
129					});
130				}
131			},
132		},
133
134		
135		/**
136		 * ====================================================================
137		 * Animation in 3D
138		 * ====================================================================
139		 */
140		animation3D: {
141			target: false,
142			reset: function() {
143				var old = $('.kentha-animating-3d');
144				if( old.length > 0 ){
145					var resetCss = {"transform": "matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1) translate(0, 0)", "transition" : 'all 1s ease' };
146					jQuery('.kentha-animating-3d').css(resetCss).find('.kentha-3d-element__front').css(resetCss);
147					old.removeClass('kentha-animating-3d');
148				}
149			},
150			init: function( v ){
151				var that = this,
152					win = v.window,
153					item = false, e, mouseXrel, mouseYrel,  moveX, moveY, matrix1, matrix2;
154				that.reset();
155				if( v.wW > 1190 && false !== that.target ){
156					that.target.addClass('kentha-animating-3d');
157					item = $('.kentha-animating-3d');
158					e = v.mousePos;
159					var centerX = item.offset().left + ( item.width() / 2 );
160					var centerY = item.offset().top + ( item.height() / 2 );
161					mouseXrel = (e.x - centerX) * - 1 / 100;
162					mouseYrel = (e.y - centerY) * - 1 / 100;
163					moveX = mouseXrel * 0.000013;
164					moveY = mouseYrel * 0.000013;
165					matrix1 = [[1, 0, 0, - moveX], [0, 1, 0, - moveY], [0, 0, 1, 1], [0, 0, 0, 1]];
166					matrix2 = [[1, 0, 0, - moveX], [0, 1, 0, - moveY], [0, 0, 1, 1], [0, 0, 0, 1]];
167					
168					item .css({"transition" : 'all 0.15s ease', "transform": "matrix3d(" + matrix1.toString() + ") translate(" + mouseXrel *  -4 + "px, " + mouseYrel  * -4 + "px)"})
169						.find('.kentha-3d-element__front').css({"transition" : 'all 0.15s ease', "transform": "perspective(1000px) matrix3d(" + matrix2.toString() + ") translate(" + mouseXrel  * -4 + "px, " + mouseYrel * -4 + "px)"});
170					
171					v.moverMouse = { 
172						x: centerX,
173						y: centerY
174					};
175
176					win.on('kenthaMouseMoved.kentha3d', function(){
177						if( v.fps > 8 ){
178							var tempItem = $('.kentha-animating-3d');
179							$(v.moverMouse).clearQueue();
180							$(v.moverMouse).animate({
181							  x: v.mousePos.x ,
182							  y: v.mousePos.y
183							}, {
184							  	duration: 110,
185							  	step: function() {
186									mouseXrel = (v.moverMouse.x - centerX) * - 1 / 100;
187									mouseYrel = (v.moverMouse.y - centerY) * - 1 / 100;
188									moveX = mouseXrel * 0.000013;
189									moveY = mouseYrel * 0.000013;
190									matrix1 = [[1, 0, 0, - moveX], [0, 1, 0, - moveY], [0, 0, 1, 1], [0, 0, 0, 1]];
191									matrix2 = [[1, 0, 0, - moveX], [0, 1, 0, - moveY], [0, 0, 1, 1], [0, 0, 0, 1]];
192									// IMPORTANT: never replace $('.kentha-animating-3d') with a variable or the animation falls bad
193									$('.kentha-animating-3d').css({"transform": "matrix3d(" + matrix1.toString() + ") translate(" + mouseXrel *  -4 + "px, " + mouseYrel  * -4 + "px)", 'transition':'none'})
194									.find('.kentha-3d-element__front').css({"transform": "perspective(1000px) matrix3d(" + matrix2.toString() + ") translate(" + mouseXrel  * -4 + "px, " + mouseYrel * -4 + "px)", 'transition':'none'});
195							  	}
196							});
197						}
198					});
199				}
200			},
201		},
202
203		/**
204		 * ====================================================================
205		 *  3D elements append listeners
206		 * ====================================================================
207		 */
208		fx3dElements: {
209			init: function(v){
210				$('.kentha-elementor-3dfx [data-kentha-elementor-3dpicture="true"]').attr('data-kentha-elementor-3dpicture', 'false'); // disable if the container has 3d
211				$('.kentha-elementor-3dfx [data-kentha-elementor-3delement="true"]').attr('data-kentha-elementor-3delement', 'false'); // disable if the container has 3d
212				var the3dElements = [
213					$('[data-kentha-elementor-3dpicture="true"]'), 
214					$('[data-kentha-animation3d="true"] .owl-item'),
215					$('[data-kentha-elementor-3delement="true"]'), 
216					$('.kentha-elementor-3dfx > .elementor-container')
217				];
218				$.each(the3dElements, function(){
219					$(this).each(function(){
220						var t = $(this);
221						t.css({"transform": "matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1) translate(0, 0)" });
222						t.off('onmouseenter.kentha3d').off('mouseleave.kentha3d')
223						.on('mouseenter.kentha3d', function(){
224							v.animation3D.target = t;
225							v.animation3D.init( v );
226						});
227					});
228				});
229			},
230		},
231
232
233		isInViewport: function( element ) {
234			var elementTop = element.offset().top;
235			var elementBottom = elementTop + element.outerHeight();
236			var viewportTop = $(window).scrollTop();
237			var viewportBottom = viewportTop + $(window).height();
238			return elementBottom > viewportTop && elementTop < viewportBottom;
239		},
240
241		/**
242		 * ====================================================================
243		 * kenthaCarousel
244		 * ====================================================================
245		 */
246		kenthaCarousel: function(kenthaElementor, action, targetContainer){
247			if(!jQuery.fn.owlCarousel) { return; }
248			if(undefined === targetContainer) { targetContainer = "body"; }
249			if(undefined === action) { action = "init"; }
250
251			if( 'init' === action ){
252				$(targetContainer+' .kentha-elementor-owl-carousel').each( function(i,c){
253					var T = $(c),
254						itemIndex,
255						controllerTarget;
256					if(!T.hasClass('kentha-elementor-carousel-created')){
257						T.fadeTo(0, 0);
258					}
259					T.owlCarousel({
260						loop: T.data('loop'),
261						margin: T.data('gap'),
262						nav: T.data('nav'),
263						dots: T.data('dots'),
264						navText: ['<i class="kentha-elementor-arrow kentha-elementor-arrow__l"></i>', '<i class="kentha-elementor-arrow kentha-elementor-arrow__r"></i>'],
265						center: T.data('center'),
266						stagePadding: T.data('stage_padding'),
267						autoplay:  T.data('autoplay_timeout') > 0,
268						autoWidth:false,
269						autoplayTimeout: T.data('autoplay_timeout'),
270						autoplayHoverPause: T.data('pause_on_hover'),
271						callbacks: true,
272						responsive:{
273							0:{
274								items: T.data('items_mobile'),
275								autoWidth:false,
276								margin: 30,
277								mouseDrag: false,
278								touchDrag: true
279							},
280							420:{
281								items: T.data('items_mobile_hori'),
282								autoWidth:false,
283								mouseDrag: false,
284								touchDrag: true
285							},
286							600:{
287								items: T.data('items_tablet'),
288								autoWidth:false,
289								mouseDrag: false,
290								touchDrag: true
291							},
292							1025:{
293								items: T.data('items'),
294								autoWidth:false
295							}
296						},
297						onInitialized:function(){
298							T.addClass('kentha-elementor-carousel-created');
299							$(c).delay(250).fadeTo(250, 1);
300						},
301					});
302					// multinav
303					if( T.hasClass('kentha-elementor-multinav-main')) {
304						controllerTarget = T.data('target');
305						T.parent().find('.kentha-elementor-multinav__controller').find('a:first-child').addClass('current');
306						T.on('changed.owl.carousel', function (e) {
307							if (e.item) {
308								itemIndex = T.find('.active [data-index]').data('index') + 1;
309								T.parent().find('.kentha-elementor-multinav__controller .current').removeClass('current');
310								T.parent().find('.kentha-elementor-multinav__controller').find('[data-multinav-controller="'+itemIndex+'"]').addClass('current');
311							}
312						});
313					}
314					// Index number [modernSlider]
315					if( T.data('indexslide') ){
316						T.find('.owl-nav').append('<div class="kentha-modernslider__index" data-kentha-itemindex>01</div>');
317						var cur;
318						var indexContainer = T.find('.owl-nav').find('[data-kentha-itemindex]');
319						var currentItem = T.find('.active');
320						if(T.data('kenthafx') === 'glitch'){
321							currentItem.find('[data-kenthafx="glitch"]').addClass(kenthaElementor.fxActivationClass);
322						}
323						T.on('translated.owl.carousel', function(e) {
324							if (e.item) {
325								cur = T.find('.active [data-index]').data('index');
326								if( cur < 10 ){
327									cur = '0'+cur;
328								}
329								indexContainer.animate({
330									'opacity': 0,
331									'margin-top': '-20px'
332								}, 300, function(){
333									indexContainer.html( cur ).css({'margin-top': '20px'}).animate({
334										'opacity': 1,
335										'margin-top': '0px'
336									}, 300);
337								});
338								if(T.data('kenthafx') === 'glitch'){
339									currentItem = T.find('.active');
340									currentItem.find('[data-kentha-imgfx="glitch"]').addClass(kenthaElementor.fxActivationClass);
341									currentItem.prev().find('[data-kentha-imgfx="glitch"]').removeClass(kenthaElementor.fxActivationClass);
342								}
343							}
344						});
345					}
346					T.on('click', "[data-multinav-controller]", function(e){
347						e.preventDefault();
348						var t = $(this),
349							i = t.data("multinav-controller"),
350							targ = t.data("multinav-target");
351						$('#'+targ).trigger('stop.owl.autoplay', i);
352						$('#'+targ).trigger('to.owl.carousel', i);
353						T.parent().find('.kentha-elementor-multinav__controller .owl-item a').removeClass('current');
354						t.addClass('current');
355					});
356				});
357			} // if( 'init' === action ){
358		},
359
360		/**
361		 * ====================================================================
362		 * Glitch on text capions
363		 * ====================================================================
364		 */
365		glitchText: {
366			init: function( kenthaElementor ){
367				var that = this;
368				var glitchclass = kenthaElementor.fxActivationClass;
369				that.items = $('[data-kentha-textfx="glitch"]');
370				that.items.each(function(){
371					var t = $(this);
372					var text = t.html();
373					var decor = t.find('.kentha-elementor-caption__decor');
374					t.html('<span class="kentha-textfx-glitch__l0">'+text+'</span><span class="kentha-textfx-glitch__l1">'+text+'</span><span class="kentha-textfx-glitch__l2">'+text+'</span>');
375					t.addClass(glitchclass);
376					t.on('touchstart, mouseenter', function(){
377						t.addClass(glitchclass);
378					}).on('touchend, mouseleave', function(){
379						t.removeClass(glitchclass);
380					});
381				});
382				kenthaElementor.window.off('kenthaGlitchStart.kenthatextglitch')
383					.off('kenthaGlitchStop.kenthatextglitch')
384					.on('kenthaGlitchStart.kenthatextglitch', function(){
385						that.items.addClass(glitchclass);
386					}).on('kenthaGlitchStop.kenthatextglitch', function(){
387						that.items.removeClass(glitchclass);
388					});
389			}
390		},
391
392		/**
393		 * ====================================================================
394		 * Glitch picture
395		 * ====================================================================
396		 */
397		glitchPics: {
398			init: function( kenthaElementor ){
399				var that = this;
400				var glitchclass = kenthaElementor.fxActivationClass;//'kentha-fx-on';
401				that.items = $('[data-kentha-imgfx="glitch"]');
402				that.items.each(function(){
403					var t = $(this);
404					var ti = t.find('img:first-child');
405					var imgurl = ti.attr('src');
406					t.append('<img src="'+ti.attr('src')+'" class="kentha-imgfx--glitch__f1">');
407					t.append('<img src="'+ti.attr('src')+'" class="kentha-imgfx--glitch__f2">');
408					if( t.data('kentha-fx-activation') === 'auto' ){
409							t.addClass(glitchclass);
410						}
411					if( t.data('kentha-glitch-activation') == 'hover' ){
412						t.on('touchstart, mouseenter', function(){
413							t.addClass(glitchclass);
414						}).on('touchend, mouseleave', function(){
415							t.removeClass(glitchclass);
416						});
417					}
418				});
419				kenthaElementor.window.off('kenthaGlitchStart.kenthaimgglitch').off('kenthaGlitchStop.kenthaimgglitch');
420				kenthaElementor.window.on('kenthaGlitchStart.kenthaimgglitch', function(){
421					that.items.each(function(){
422						var t = $(this);
423						if( t.data('kentha-fx-activation') === 'auto' ){
424							t.addClass(glitchclass);
425						}
426					});
427				});
428				kenthaElementor.window.on('kenthaGlitchStop.kenthaimgglitch', function(){
429					that.items.removeClass(glitchclass);
430				});
431			}
432		},
433
434		/**
435		 * ====================================================================
436		 * Elementor section glitch effect
437		 * transform background image into an inline image and glitch it
438		 * ====================================================================
439		 */
440		kenthaSectionFx: function(){
441			// Add a phisical image as background to apply the glitch
442			$(".kentha-elementor-glitchsection").each(function(){
443				var bg = $(this).css('background-image');
444				if( bg && "none" !== bg ){
445					bg = bg.replace('url(','').replace(')','').replace(/\"/gi, "");
446					$(this).prepend('<div class="kentha-elementor-glitchsection__bg kentha-imgfx--glitch" data-kentha-imgfx="glitch" data-kentha-fx-activation="auto"><img src="'+bg+'"></div>');
447				}
448			});
449		},
450
451		/**
452		 * ====================================================================
453		 * Glitch particles
454		 * ====================================================================
455		 */
456		glitchParticles: {
457			quantity: 10,
458			fxBoxes: [],
459			items: [],
460			animationInterval: false,
461			init: function(kenthaElementor){
462				var that = this;
463				that.targets = $('.kentha-elementor-glitchsection');
464				that.class = kenthaElementor.fxActivationClass;
465				if( that.targets.length === 0 ){ return; }
466				that.destroy(that);
466 // always destroy first, or it can destroy the browser 
467				that.create(that);
468				kenthaElementor.window.off('kenthaGlitchStart.particles').off('kenthaGlitchStop.particles')
469					.on('kenthaGlitchStart.particles', function(){ that.show(that); })
470					.on('kenthaGlitchStop.particles', function(){ that.hide(that); });
471			},
472			create: function(that){
473				that.targets.each(function(){
474					var t = $(this);
475					t.find('.kentha-elementor-glitchparticles').remove();
476					t.find('[data-kentha-particles]').remove();
477					t.append('<div data-kentha-particles class="kentha-elementor-glitchparticles"></div>');
478					var layer = t.find('[data-kentha-particles]');
479					for(var i = 0; i < that.quantity; i ++){
480						t.find('[data-kentha-particles]').append('<hr>');
481					}
482					that.fxBoxes.push(layer);
483				}).promise().done(function(){
484					that.fxBoxes = $('[data-kentha-particles]');
485					that.show(that); 
486				})
487			},
488			show: function(that){
489				that.fxBoxes.addClass(that.class);
490				that.animation(that);
491				that.animationInterval = setInterval(function(){ 
492					that.animation(that);
493				}, 200);
494			},
495			animation: function(that){
496				if( that.fxBoxes.hasClass(that.class) ){
497					var total = 0;
498					that.fxBoxes.find('hr').each( function(){
499						total++;
500						$(this).css({
501							'left': Math.floor(Math.random() * 90)+'%',
502							'top': Math.floor(Math.random() * 100)+'%',
503							'width':   8 + Math.floor( Math.random() * 20) +'px',
504							'height': 3 +  Math.floor( Math.random() * 3) + 'px'
505						});
506					});
507				}
508			},
509			hide: function(that){
510				if( false !== that.animationInterval ){
511					clearInterval(that.animationInterval);
512				}
513				that.fxBoxes.removeClass(that.class);
514			},
515			destroy: function(that){
516				if('undefined' !== typeof(that.animateInterval) ){
517					clearInterval(that.animateInterval);
518				}
519			}
520		},
521
522		/**
523		 * ====================================================================
524		 * Global glitch automation loop
525		 * ====================================================================
526		 */
527		glitchLoop: {
528			state: 0,
529			newstate: 0,
530			init: function( kenthaElementor ){
531				var that = this;
532				var arrogance = $('[data-kentha-glitch-arrogance]').data('kentha-glitch-arrogance');
533				if( !arrogance ){
534					arrogance = 15;
535				}
536				arrogance = 1 - ( arrogance / 100 );
537				if( 'undefined' !== typeof( that.glitchInterval  ) ){
538					clearInterval( that.glitchInterval );
539				}
540				that.glitchInterval = setInterval(
541					function(){
542						that.newstate = 0;
543						if( Math.random() > arrogance){ // the hightr the limit it, the less it glitches. Chance or probability to glitch
544							that.newstate = 1;
545						}
546						// act only if it changes
547						if( that.newstate !== that.state ){
548							that.state = that.newstate;
549							if( that.state ){
550								kenthaElementor.window.trigger('kenthaGlitchStart');
551							}else {
552								kenthaElementor.window.trigger('kenthaGlitchStop');
553							}
554						}
555					}, 500
556				);
557			}
558		}
559
560	};
561
562	/**====================================================================
563	 *
564	 *	Page Ready Trigger
565	 * 	This needs to call only $.fn.qtInitTheme
566	 * 
567	 ====================================================================*/
568	$(document).ready(function() {
569		$.kenthaElementor.__init($.kenthaElementor);		
570	});
571
572})(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.