HEX
Server: LiteSpeed
System: Linux linux31.centraldnserver.com 4.18.0-553.83.1.lve.el8.x86_64 #1 SMP Wed Nov 12 10:04:12 UTC 2025 x86_64
User: salamatk (1501)
PHP: 8.1.33
Disabled: show_source, system, shell_exec, passthru, exec, popen, proc_open
Upload Files
File: /home/salamatk/takarzan.ir/wp-content/themes/xts-luman/js/scripts/calcVideoSize.js
/* global xts_settings */
(function($) {
	XTSThemeModule.$document.on('xtsPjaxComplete xtsPostVideoLoaded xtsBlogLoadMoreSuccess', function() {
		XTSThemeModule.calcVideoSize();
	});

	$.each([
		'frontend/element_ready/xts_blog.default'
	], function(index, value) {
		XTSThemeModule.xtsElementorAddAction(value, function() {
			XTSThemeModule.calcVideoSize();
		});
	});

	XTSThemeModule.calcVideoSize = function() {
		$('.xts-video-resize').each(function() {
			var $this = $(this);
			var $video = $this.find('iframe');

			if ($video.length <= 0) {
				return;
			}

			var containerWidth = $this.outerWidth() + 5;
			var containerHeight = $this.outerHeight() + 5;
			var aspectRatioSetting = '16:9';

			var aspectRatioArray = aspectRatioSetting.split(':');
			var aspectRatio = aspectRatioArray[0] / aspectRatioArray[1];
			var ratioWidth = containerWidth / aspectRatio;
			var ratioHeight = containerHeight * aspectRatio;
			var isWidthFixed = containerWidth / containerHeight > aspectRatio;

			var size = {
				width : isWidthFixed ? containerWidth : ratioHeight,
				height: isWidthFixed ? ratioWidth : containerHeight
			};

			$video.width(size.width).height(size.height + 140);
		});
	};

	$(document).ready(function() {
		XTSThemeModule.calcVideoSize();
	});
})(jQuery);