MOON
Server: Apache
System: Linux server1.studioinfinity.com.br 2.6.32-954.3.5.lve1.4.90.el6.x86_64 #1 SMP Tue Feb 21 12:26:30 UTC 2023 x86_64
User: artinside (517)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/artinside/www/sabbry/themes/web/assets/js/modules/counter.js
CNVS.Counter = function() {
	var __core = SEMICOLON.Core;

	var _run = function(elCounter, elFormat) {
		if( elFormat.comma == 'true' ) {
			var reFormat = '\\B(?=(\\d{'+ elFormat.places +'})+(?!\\d))',
				regExp = new RegExp( reFormat, "g" );

			elCounter.find('span').countTo({
				formatter: function(value, options) {
					value = value.toFixed( options.decimals );
					value = value.replace( regExp, elFormat.sep );
					return value;
				}
			});
		} else {
			elCounter.find('span').countTo();
		}
	};

	return {
		init: function(selector) {
			if( __core.getSelector(selector, false, false).length < 1 ){
				return true;
			}

			__core.loadJS({ file: 'plugins.counter.js', id: 'canvas-counter-js', jsFolder: true });

			__core.isFuncTrue( function() {
				return typeof jQuery !== 'undefined' && jQuery().countTo;
			}).then( function(cond) {
				if( !cond ) {
					return false;
				}

				__core.initFunction({ class: 'has-plugin-counter', event: 'pluginCounterReady' });

				selector = __core.getSelector( selector );
				if( selector.length < 1 ){
					return true;
				}

				selector.each(function(){
					var element = jQuery(this),
						elComma = element.find('span').attr('data-comma'),
						elSep = element.find('span').attr('data-sep') || ',',
						elPlaces = element.find('span').attr('data-places') || 3;

					var elCommaObj = {
						comma: elComma,
						sep: elSep,
						places: Number( elPlaces )
					}

					if( element.hasClass('counter-instant') ) {
						_run(element, elCommaObj);
						return;
					}

					var observer = new IntersectionObserver( function(entries, observer) {
						entries.forEach( function(entry) {
							if (entry.isIntersecting) {
								_run(element, elCommaObj);
								observer.unobserve(entry.target);
							}
						});
					}, {rootMargin: '0px 0px 50px'});

					observer.observe( element[0] );
				});
			});
		}
	};
}();