PageSourceSearch

https://trtfn.com/wp-content/themes/scalia/js/functions.js?ver=6.0.16

js trtfn.com collected 2026-10-03 21:37:37 UTC 16,691 bytes, 505 lines download raw bytes

1(function($) {
2
3	var ua = navigator.userAgent.toLowerCase(),
4	platform = navigator.platform.toLowerCase(),
5	UA = ua.match(/(opera|ie|firefox|chrome|version)[\s\/:]([\w\d\.]+)?.*?(safari|version[\s\/:]([\w\d\.]+)|$)/) || [null, 'unknown', 0],
6	mode = UA[1] == 'ie' && document.documentMode;
7
8	var Browser = {
9		name: (UA[1] == 'version') ? UA[3] : UA[1],
10		Platform: {
11			name: ua.match(/ip(?:ad|od|hone)/) ? 'ios' : (ua.match(/(?:webos|android)/) || platform.match(/mac|win|linux/) || ['other'])[0]
12		},
13	};
14
15	function getOffset(elem) {
16		if (elem.getBoundingClientRect && Browser.Platform.name != 'ios'){
17			var bound = elem.getBoundingClientRect(),
18				html = elem.ownerDocument.documentElement,
19				htmlScroll = getScroll(html),
20				elemScrolls = getScrolls(elem),
21				isFixed = (styleString(elem, 'position') == 'fixed');
22			return {
23				x: parseInt(bound.left) + elemScrolls.x + ((isFixed) ? 0 : htmlScroll.x) - html.clientLeft,
24				y: parseInt(bound.top)  + elemScrolls.y + ((isFixed) ? 0 : htmlScroll.y) - html.clientTop
25			};
26		}
27
28		var element = elem, position = {x: 0, y: 0};
29		if (isBody(elem)) return position;
30
31		while (element && !isBody(element)){
32			position.x += element.offsetLeft;
33			position.y += element.offsetTop;
34
35			if (Browser.name == 'firefox'){
36				if (!borderBox(element)){
37					position.x += leftBorder(element);
38					position.y += topBorder(element);
39				}
40				var parent = element.parentNode;
41				if (parent && styleString(parent, 'overflow') != 'visible'){
42					position.x += leftBorder(parent);
43					position.y += topBorder(parent);
44				}
45			} else if (element != elem && Browser.name == 'safari'){
46				position.x += leftBorder(element);
47				position.y += topBorder(element);
48			}
49
50			element = element.offsetParent;
51		}
52		if (Browser.name == 'firefox' && !borderBox(elem)){
53			position.x -= leftBorder(elem);
54			position.y -= topBorder(elem);
55		}
56		return position;
57	};
58
59	function getScroll(elem){
60		return {x: window.pageXOffset || document.documentElement.scrollLeft, y: window.pageYOffset || document.documentElement.scrollTop};
61	};
62
63	function getScrolls(elem){
64		var element = elem.parentNode, position = {x: 0, y: 0};
65		while (element && !isBody(element)){
66			position.x += element.scrollLeft;
67			position.y += element.scrollTop;
68			element = element.parentNode;
69		}
70		return position;
71	};
72
73	function styleString(element, style) {
74		return $(element).css(style);
75	};
76
77	function styleNumber(element, style){
78		return parseInt(styleString(element, style)) || 0;
79	};
80
81	function borderBox(element){
82		return styleString(element, '-moz-box-sizing') == 'border-box';
83	};
84
85	function topBorder(element){
86		return styleNumber(element, 'border-top-width');
87	};
88
89	function leftBorder(element){
90		return styleNumber(element, 'border-left-width');
91	};
92
93	function isBody(element){
94		return (/^(?:body|html)$/i).test(element.tagName);
95	};
96
97	$('#site-header.animated-header').headerAnimation();
98
99	if(Modernizr.touch) {
100		jQuery('body').addClass('lazy-disabled');
101	}
102
103	if(!$('body').hasClass('lazy-disabled')) {
104		if($.support.opacity) {
105			if($(window).width() > 800) {
106				$('.wpb_text_column.wpb_animate_when_almost_visible.wpb_fade').each(function() {
107					$(this).wrap('<div class="lazy-loading"></div>').addClass('lazy-loading-item').data('ll-effect', 'fading');
108				});
109
110				$('.sc-list.lazy-loading').each(function() {
111					$(this).data('ll-item-delay', '200');
112					$('li', this).addClass('lazy-loading-item').data('ll-effect', 'slide-right');
113				});
114
115				$.lazyLoading();
116			}
117		}
118	}
119
120	function fix_megamenu_position() {
121		$('#primary-menu > li.megamenu-enable').each(function() {
122					var $item = $('> ul', this);
123					if($item.length == 0) return;
124					var self = $('> ul', this).get(0);
125								$item.addClass('without-transition');
126								$item.removeClass('megamenu-masonry-inited').removeClass('megamenu-fullwidth').css({
127									left: 0,
128									width: 'auto',
129									height: 'auto'
130								});
131								$(' > li', $item).css({
132									left: 0,
133									top: 0
134								}).each(function() {
135									var old_width = $(this).data('old-width') || -1;
136									if (old_width != -1)
137										$(this).width(old_width).data('old-width', -1);
138								});
139
140								if ($('#primary-navigation .menu-toggle').is(':visible'))
141									return;
142
143								var $container = $item.closest('.container');
144								var container_width = $container.width();
145								var container_padding_left = parseInt($container.css('padding-left'));
146								var container_padding_right = parseInt($container.css('padding-right'));
147								var megamenu_width = $item.outerWidth();
148								var parent_width = $item.parent().outerWidth();
149
150								if (megamenu_width > container_width) {
151									megamenu_width = container_width;
152									var new_megamenu_width = container_width - parseInt($item.css('padding-left')) - parseInt($item.css('padding-right'));
153									$item.addClass('megamenu-fullwidth').width(new_megamenu_width);
154									var columns = $item.data('megamenu-columns') || 4;
155									var column_width = (new_megamenu_width - (columns - 1) * parseInt($(' > li:first', $item).css('margin-left'))) / columns;
156									$(' > li', $item).each(function() {
157										$(this).data('old-width', $(this).width()).width(column_width);
158									});
159								}
160
161								if (megamenu_width > parent_width)
162									var left = -(megamenu_width - parent_width) / 2;
163								else
164									var left = 0;
165
166								var container_offset = getOffset($container[0]);
167								var megamenu_offset = getOffset(self);
168
169								if ((megamenu_offset.x - container_offset.x - container_padding_left + left) < 0)
170									left = -(megamenu_offset.x - container_offset.x - container_padding_left);
171
172								if ((megamenu_offset.x + megamenu_width + left) > (container_offset.x + $container.outerWidth() - container_padding_right)) {
173									left -= (megamenu_offset.x + megamenu_width + left) - (container_offset.x + $container.outerWidth() - container_padding_right);
174								}
175
176								$item.css('left', left).css('left');
177
178								if ($item.hasClass('megamenu-masonry')) {
179									var positions = {};
180									var max_bottom = 0;
181									$item.width($item.width());
182									var new_row_height = $('.megamenu-new-row', $item).outerHeight() + parseInt($('.megamenu-new-row', $item).css('margin-bottom'));
183									$('> li.menu-item', $item).each(function() {
184										var pos = $(this).position();
185										if (positions[pos.left] != null && positions[pos.left] != undefined) {
186											var top_position = positions[pos.left];
187										} else {
188											var top_position = pos.top;
189										}
190										positions[pos.left] = top_position + $(this).outerHeight() + new_row_height;
191										if (positions[pos.left] > max_bottom)
192											max_bottom = positions[pos.left];
193										$(this).css({
194											left: pos.left,
195											top: top_position
196										})
197									});
198									$item.height(max_bottom - new_row_height - parseInt($item.css('padding-top')));
199									$item.addClass('megamenu-masonry-inited');
200								}
201
202								$item.removeClass('without-transition');
203		});
204	}
205
206	fix_megamenu_position();
207
208	$.fn.updateTabs = function() {
209
210		jQuery('.sc-tabs', this).each(function(index) {
211			var $tabs = $(this);
212			$tabs.scaliaPreloader(function() {
213				$tabs.easyResponsiveTabs({
214					type: 'default',
215					width: 'auto',
216					fit: false,
217					activate: function(currentTab, e) {
218						var $tab = $(currentTab.target);
219						var controls = $tab.attr('aria-controls');
220						$tab.closest('.ui-tabs').find('.sc_tab[aria-labelledby="' + controls + '"]').trigger('tab-update');
221					}
222				});
223			});
224		});
225
226		jQuery('.sc-tour', this).each(function(index) {
227			var $tabs = $(this);
228			$tabs.scaliaPreloader(function() {
229				$tabs.easyResponsiveTabs({
230					type: 'vertical',
231					width: 'auto',
232					fit: false,
233					activate: function(currentTab, e) {
234						var $tab = $(currentTab.target);
235						var controls = $tab.attr('aria-controls');
236						$tab.closest('.ui-tabs').find('.sc_tab[aria-labelledby="' + controls + '"]').trigger('tab-update');
237					}
238				});
239			});
240		});
241
242	}
243
244	$(function() {
245
246		/* PRIMARY MENU */
247
248		$('#primary-navigation .submenu-languages').addClass('dl-submenu');
249		$('#primary-navigation > ul> li.menu-item-language').addClass('menu-item-parent');
250
251		$('#primary-navigation').dlmenu({
252			animationClasses: {
253				classin : 'dl-animate-in',
254				classout : 'dl-animate-out'
255			},
256			onLevelClick: function (el, name) {
257				$('html, body').animate({ scrollTop : 0 });
258			}
259		});
260
261		$(window).resize(function() {
262			if($('#primary-navigation .menu-toggle').is(':visible')) {
263				$('#primary-navigation .dl-submenu-disabled').addClass('dl-submenu').removeClass('dl-submenu-disabled');
264				$('#primary-menu').removeClass('no-responsive');
265				$('#primary-navigation').addClass('responsive');
266				fix_megamenu_position();
267			} else {
268				$('#primary-navigation .dl-submenu').addClass('dl-submenu-disabled').removeClass('dl-submenu');
269				$('#primary-menu').addClass('no-responsive').removeClass('dl-menuopen dl-subview');
270				$('#primary-navigation').removeClass('responsive');
271				fix_megamenu_position();
272				
273				$('#primary-menu ul:not(.minicart ul), #primary-menu .minicart').each(function() {
274					var $item = $(this);
275					var self = this;
276					$item.removeClass('invert');
277					if ($item.closest('.megamenu-enable').size() == 0) {
278						if($item.offset().left - $('#page').offset().left + $item.outerWidth() > $('#page').width()) {
279							$item.addClass('invert');
280						}
281					}
282				});
283				
284			}
285		});
286
287		$('#primary-navigation a').click(function(e) {
288			var $item = $(this);
289			if($('#primary-menu').hasClass('no-responsive') && Modernizr.touch && $item.next('ul').length) {
290				e.preventDefault();
291			}
292		});
293
294		/* FULLWIDTH BLOCK */
295		$('.fullwidth-block').each(function() {
296			var $item = $(this);
297			$(window).resize(function() {
298				$item.offset({
299					left: $('#page').offset().left,
300					top: $item.offset().top
301				});
302				$item.outerWidth($('#page').outerWidth());
303				$item.trigger('updateTestimonialsCarousel');
304				$item.trigger('updateClientsCarousel');
305				$item.trigger('fullwidthUpdate');
306			});
307		});
308
309		jQuery('.sc-combobox, .widget_archive select, .widget_product_categories select, .widget_layered_nav select, .widget_categories select').each(function(index) {
310			$(this).combobox();
311		});
312
313		jQuery('.sc-checkbox').checkbox();
314
315		jQuery('.sc-table-responsive').each(function(index) {
316			$('> table', this).ReStable({
317				maxWidth: 768,
318				rowHeaders : $(this).hasClass('row-headers')
319			});
320		});
321
322		jQuery('.fancybox').each(function() {
323			$(this).fancybox();
324		});
325
326		jQuery('iframe').not('.sc-video-background iframe').each(function() {
327			$(this).scaliaPreloader(function() {});
328		});
329
330		jQuery('.sc-video-background').each(function() {
331			var $videoBG = $(this);
332			var $videoContainer = $('.sc-video-background-inner', this);
333			var ratio = $videoBG.data('aspect-ratio') ? $videoBG.data('aspect-ratio') : '16:9';
334			var regexp = /(\d+):(\d+)/;
335			ratio = regexp.exec(ratio);
336			if(!ratio || parseInt(ratio[1]) == 0 || parseInt(ratio[2]) == 0) {
337				ratio = 16/9;
338			} else {
339				ratio = parseInt(ratio[1])/parseInt(ratio[2]);
340			}
341			$(window).resize(function() {
342				$videoContainer.removeAttr('style');
343				if($videoContainer.width() / $videoContainer.height() > ratio) {
344					$videoContainer.css({
345						height: ($videoContainer.width() / ratio) + 'px',
346						marginTop: -($videoContainer.width() / ratio - $videoBG.height()) / 2 + 'px'
347					});
348				} else {
349					$videoContainer.css({
350						width: ($videoContainer.height() * ratio) + 'px',
351						marginLeft: -($videoContainer.height() * ratio - $videoBG.width()) / 2 + 'px'
352					});
353				}
354			});
355		});
356
357		jQuery('.sc-slideshow').each(function() {
358			var $slideshow = $(this);
359			$slideshow.scaliaPreloader(function() {});
360		});
361
362		function init_odometer(el) {
363			if (jQuery('.sc-counter-odometer', el).size() == 0)
364				return;
365			var odometer = jQuery('.sc-counter-odometer', el).get(0);
366			var od = new Odometer({
367				el: odometer,
368				value: $(odometer).text(),
369				format: '( ddd).ddd'
370				//format: '( ddd),ddd'
371				//format: '(,ddd).ddd'
372			});
373			od.update($(odometer).data('to'));
374		}
375		window['scalia_init_odometer'] = init_odometer;
376
377		jQuery('.sc-counter').each(function(index) {
378			if ($(window).width() > 800 && jQuery(this).closest('.sc-counter-box').size() > 0 && jQuery(this).closest('.sc-counter-box').hasClass('lazy-loading') && !jQuery('body').hasClass('lazy-disabled')) {
379				jQuery(this).addClass('lazy-loading-item').data('ll-effect', 'action').data('item-delay', '0').data('ll-action-func', 'scalia_init_odometer');
380				jQuery('.sc-icon', this).addClass('lazy-loading-item').data('ll-effect', 'fading').data('item-delay', '0');
381				jQuery('.sc-counter-text', this).addClass('lazy-loading-item').data('ll-effect', 'fading').data('item-delay', '0');
382				return;
383			}
384			init_odometer(this);
385		});
386
387		jQuery('.panel-sidebar-sticky > .sidebar').scSticky();
388
389		jQuery('iframe + .map-locker').each(function() {
390			var $locker = $(this);
391			$locker.click(function(e) {
392				e.preventDefault();
393				if($locker.hasClass('disabled')) {
394					$locker.prev('iframe').css({ 'pointer-events' : 'none' });
395				} else {
396					$locker.prev('iframe').css({ 'pointer-events' : 'auto' });
397				}
398				$locker.toggleClass('disabled');
399			});
400		});
401
402		$('.primary-navigation a, .footer-navigation a, .scroll-top-button, .scroll-to-anchor, .sc-button').each(function() {
403			var $anhor = $(this);
404			var link = $anhor.attr('href');
405			if(!link) return false;
406			link = link.split('#');
407			if($('#'+link[1]).hasClass('vc_tta-panel')) return ;
408			if($('#'+link[1]).length) {
409				$anhor.closest('li').removeClass('menu-item-active current-menu-item');
410				$(window).scroll(function() {
411					var correction = $('#site-header').outerHeight() + $('#site-header').position().top;
412					var target_top = $('#'+link[1]).offset().top - correction;
413					if(getScrollY() >= target_top && getScrollY() <= target_top + $('#'+link[1]).outerHeight()) {
414						$anhor.closest('li').addClass('menu-item-active');
415					} else {
416						$anhor.closest('li').removeClass('menu-item-active');
417					}
418				});
419				$anhor.click(function(e) {
420					e.preventDefault();
421					var correction = 0;
422					if($('#site-header.animated-header').length) {
423						var shrink = $('#site-header').hasClass('shrink');
424						$('#site-header').addClass('scroll-counting');
425						$('#site-header').addClass('fixed shrink');
426						correction = $('#site-header').outerHeight() + $('#site-header').position().top;
427						if(!shrink) {
428							$('#site-header').removeClass('fixed shrink');
429						}
430						$('#site-header').removeClass('scroll-counting');
431					}
432					var target_top = $('#'+link[1]).offset().top - correction + 1;
433					$('html, body').stop(true, true).animate({scrollTop:target_top}, 1500, 'easeInOutQuint');
434				});
435				$(window).load(function() {
436					if(window.location.href == $anhor.attr('href')) {
437						$anhor.click();
438					}
439				});
440			}
441		});
442
443		$(window).scroll(function() {
444			if(getScrollY() > 0) {
445				$('.scroll-top-button').addClass('visible');
446			} else {
447				$('.scroll-top-button').removeClass('visible');
448			}
449		}).scroll();
450
451		function getScrollY(elem){
452			return window.pageYOffset || document.documentElement.scrollTop;
453		}
454
455		$('a.hidden-email').each(function() {
456			$(this).attr('href', 'mailto:'+$(this).data('name')+'@'+$(this).data('domain'));
457		});
458
459		$('body').updateTabs();
460
461		$(window).trigger('resize');
462
463		$(window).load(function() {
464			$(window).trigger('resize');
465		});
466
467	});
468})(jQuery);
469
470(function($) {
471	$.fn.scaliaPreloader = function(callback) {
472		$(this).each(function() {
473			var $el = $(this);
474			if(!$el.prev('.preloader').length) {
475				$('<div class="preloader">').insertBefore($el);
476			}
477			$el.data('scaliaPreloader', $('img, iframe', $el).add($el.filter('img, iframe')).length);
478			if($el.data('scaliaPreloader') == 0) {
479				$el.prev('.preloader').remove();
480				callback();
481			}
482			$('img, iframe', $el).add($el.filter('img, iframe')).each(function() {
483				var $obj = $('<img>');
484				if($(this).prop('tagName').toLowerCase() == 'iframe') {
485					$obj = $(this);
486				}
487				$obj.attr('src', $(this).attr('src'));
488				if($obj.get(0).complete) {
489					$el.data('scaliaPreloader', $el.data('scaliaPreloader')-1);
490					if($el.data('scaliaPreloader') == 0) {
491						$el.prev('.preloader').remove();
492						callback();
493					}
494				}
495				$obj.on('load error', function() {
496					$el.data('scaliaPreloader', $el.data('scaliaPreloader')-1);
497					if($el.data('scaliaPreloader') == 0) {
498						$el.prev('.preloader').remove();
499						callback();
500					}
501				});
502			});
503		});
504	}
505})(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.