HEX
Server: Apache
System: Linux p3plzcpnl489526.prod.phx3.secureserver.net 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: vmasmheia229 (9244908)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /home/vmasmheia229/domains/cindymuscarello.com/html/wp-content/themes/kathy/js/kathy.js
/*global jQuery:false */

jQuery( document ).ready(function( $ ) {
	"use strict";
	
	
	/* #General
	 ================================================== */
	
	var waitForFinalEvent = (function () {
	  var timers = {};
	  return function (callback, ms, uniqueId) {
		if (!uniqueId) {
		  uniqueId = "Don't call this twice without a uniqueId";
		}
		if (timers[uniqueId]) {
		  clearTimeout (timers[uniqueId]);
		}
		timers[uniqueId] = setTimeout(callback, ms);
	  };
	})();
	
	
	
	// Set the position and size of the side container relative to the root container
	setSideContainer();
	
	function setSideContainer() {
		
		if ( checkModernizr() ) {
		
			var $sideContainer = $( '#side-container' ),
				$mainContainer = $( '#main-container' ),
				$rootContainer = $( '#root-container' );
				
			if ( Modernizr.mq( '(min-width: 1150px)' ) ) {
					
				var adminBarHeight = 0;
				
				if ( $( '#wpadminbar' ).length > 0 ) {
					adminBarHeight = $( '#wpadminbar' ).outerHeight();
				}
				
				var fromTop = Math.max( 0, ( ( $( window ).height() - $sideContainer.outerHeight() ) / 2 ) );
				var reduced = 0.15 * fromTop;
				
				$sideContainer.css({
					marginLeft: $mainContainer.outerWidth() + getIntValurFromCSSAttribute( $mainContainer.css( 'margin-right' ) ),
					top: fromTop - reduced,
					opacity: 1,
					width: 0.1916 * $rootContainer.outerWidth(), // 0.1916 = 230/1200, 230 = original side container's width
				});
				
			} else {
				
				$sideContainer.css({
					marginLeft: '',
					top: '',
					opacity: 1,
					width: '',
				});
				
			}
			
		}
		
	}
	
	
	
	// Set the size of the images in the search results
	setSearchImageSize();
	
	function setSearchImageSize() {
		
		$( '.search-result-list article .post-image' ).each( function() {
			
			$( this ).css({
				background: 'url(' + $( this ).attr( 'data-img-src' ) + ') center no-repeat',
				height: $( '.search-result-list article .post-content-container' ).outerHeight(),
			});
			
		});
		
	}
	
	
	
	// For other pages that are not portfolio, display the footer right away
	// For portfolio, it will display after portfolio items have been loaded
	if ( 0 == $( '.portfolio-loading' ).length ) {
		setFooterWidgetSize();
	}
	
	function setFooterWidgetSize() {
		
		if ( $( '.theme-widget-area' ).length > 0 ) {
				
			// Set the size of the footer widget area
			$( '.theme-widget-area' ).css({
				maxWidth: $( '#content-container' ).outerWidth() + getIntValurFromCSSAttribute( $( '#root-container' ).css( 'margin-left' ) ) - getIntValurFromCSSAttribute( $( '.theme-widget-area' ).css( 'margin-left' ) ),
				opacity: 1,
			});
			
		}
		
	}
	
	
	
	// Set the location of the copyright and social icon elements
	setCopyrightSocialIconsLocation();
	
	function setCopyrightSocialIconsLocation() {
		
		if ( checkModernizr() ) {
			
			if ( Modernizr.mq( '(max-width: 1150px)' ) ) {
				
				$( '.theme-widget-area' ).append( $( '.copyright-social-wrapper' ).css( 'opacity', 1 ) );
				
				waitForFinalEvent(function() {
					
					$( '#mobile-menu' ).before(
						
						$( '.search-button-wrapper' ).css({
							marginRight: '',
							marginTop: -5,
							display: 'inline-block',
						})
					
					);
					
				}, 300, 'adjust_search_social_location');
				
			} else {
				
				$( '#side-container' ).append( $( '.copyright-social-wrapper' ) );
				
				
				waitForFinalEvent(function() {
					
					$( '.site-menu' ).after(
							
						$( '.search-button-wrapper' ).css({
							marginRight: 0,
							display: 'inline-block',
						})
					
					);
					
				}, 300, 'adjust_search_social_location2');
				
			}
			
		}
		
	}
	
	
	
	/* #Pages & Posts
	 ================================================== */
	if ( jQuery().imagesLoaded ) {
		
		// Show opacity animation for images after loading
		$( '.post-image' ).imagesLoaded( function() {
			
			$( '.post-image' ).each( function( index ) {
				
				$( this ).css( 'min-height', 0 ).find( 'img' ).css( 'visibility', 'visible' ).delay( 90 * index ).animate({
					opacity : 1,
				}, 300, function() {
					$( this ).addClass( 'visible' );
				});
				
			});
			
		});
		
		
	} else {
		console.log( 'imagesLoaded JS is disabled or missing.' );
	}
	
	
	
	/* #Portfolio
	 ================================================== */
	
	var layout = $( '.portfolio-listing' ).attr( 'data-layout' );
			
	// For loading and showing portfolio items
	if ( jQuery().imagesLoaded ) {
		
		// Use imagesLoaded for both portfolio listing templates and single page
		var countItems = $( '.portfolio-item, .image-wrapper' ).length;
	
		$( '.portfolio-listing, .port-format-content' ).imagesLoaded()
		.always( function( instance ) {
			
			if ( $( '.portfolio-listing' ).length > 0 ) {
					
				if ( 'grid' === layout ) {
					// Justify images
					initFlexImages();
				} else {
					displayPortfolioItems();
				}
				
			} else { // For portfolio single pages
				displayPortfolioItems();
			}
				
		})
		.progress( function( instance, image ) {
			
			if ( image.isLoaded ) {
				
				$( image.img ).closest( '.portfolio-item, .image-wrapper' ).addClass( 'loaded' );
				
				var countLoadedImages = $( '.portfolio-item.loaded, .image-wrapper.loaded' ).length;
				var width = 100 * ( countLoadedImages / countItems );
				
				$( '.progress-bar' ).css({
					'width' : width + '%',
				});
				
			}
			
		});
		
	} else {
		console.log( 'imagesLoaded JS is disabled or missing.' );
	}
	
	function validateImageHeight() {
		
		// Only do this on portfolio listing templates
		if ( $( '.portfolio-listing' ).length > 0 ) {
			
			$( '.justified-images .portfolio-item' ).each( function() {
				
				var $item = $( this ),
					originalHeight = parseInt( $item.attr( 'data-h' ), 10 ),
					imgClientHeight = parseInt( $item.find( 'img' ).height(), 10 );
				
				// Reset the height to "auto" instead of 100% if the displaying img is taller than the original
				// to prevent blurry img when it is stretched to 100%
				if ( imgClientHeight > originalHeight ) {
					$item.find( 'img' ).css( 'height', 'auto' );
				}
				
			});
			
		}
		
	}
	
	function initFlexImages() {
		
		if ( jQuery().flexImages ) {
			
			// Adjust row height a bit on lower resolutions
			var rowHeightValue = parseInt( ThemeOptions.justified_images_row_height, 10 );
			
			if ( checkModernizr() ) {
					
				if ( Modernizr.mq( '(max-width: 1400px)' ) ) {
					rowHeightValue = rowHeightValue * 0.8;
				}
				
			}
			
			$( '.justified-images' ).flexImages({
				container: '.portfolio-item',
				rowHeight: rowHeightValue,
			});
			
			
			// Check the height of images to make sure that they don't exceed the original's
			validateImageHeight();
			
			// Display the items one after another
			displayPortfolioItems();
			
		} else {
			console.log( 'flexImages JS is disabled or missing.' );
		}
		
	}
	
	function displayPortfolioItems() {
		
		$( '.portfolio-loading, .portfolio-loading-wrapper' ).animate({
			opacity: 0,
		}, function() {
			
			// For smoother showing items
			waitForFinalEvent(function() {
				
				// Bring back the overflow of the body
				$( 'body' ).css( 'overflow', 'auto' );
				
				$( '.portfolio-loading, .portfolio-loading-wrapper' ).css( 'display', 'none' );
				$( '.portfolio-item-block' ).css( 'display', 'block' );
				$( '.portfolio-listing, .port-format-content' ).css( 'height', 'auto' );
				$( '.portfolio-container' ).css( 'min-height', 0 );
				
				$( '.portfolio-item, .image-wrapper' ).each( function( index ) {
					
					var finalMultiplier = index;
					var displayMode = 'sequential'; // random, sequential
					
					if ( 'random' === displayMode ) {
						finalMultiplier = randomizeNumberFromRange( 0, $( '.portfolio-item, .image-wrapper' ).length - 1 );
					}
					
					var speed = 300;
					if ( $( '.port-format-content' ).length > 0 ) {
						speed = 500;
					}
					
					$( this ).css( 'visibility', 'visible' ).delay( 90 * finalMultiplier ).animate({
						opacity : 1,
					}, speed, function() {
						$( this ).addClass( 'visible' );
					});
					
				});
				
				setFooterWidgetSize();
				
			}, 200, 'delay_item_display');
			
		});
		
	}
	
	
	
	// Set the position and size of the portfolio categories relative to the root container
	setPortfolioCategories();
	
	function setPortfolioCategories() {
		
		if ( checkModernizr() ) {
		
			var $categories = $( '.portfolio-category-wrapper' ),
				$contentContainer = $( '#content-container' );
			
			if ( Modernizr.mq( '(min-width: 1000px)' ) ) {
						
				$categories.css({
					marginTop: 0.10 * $contentContainer.outerWidth(), // 0.10 = 85/830, 85 = margin from the top of content-container
					paddingBottom: 0.10 * $contentContainer.outerWidth(),
					opacity: 1,
					width: 0.174 * $contentContainer.outerWidth(), // 0.174 = 145/830, 145 = original content container's width
				});
				
			} else {
				
				$categories.css({
					marginTop: 0,
					paddingBottom: 0,
					opacity: 1,
					width: '100%',
				});
				
			}
			
		}
		
	}
	
	
	
	// For hiding/showing the portfolio categories when the footer widget area is displayed or off
	setPortfolioCategoryDisplay();
	
	function setPortfolioCategoryDisplay() {
		
		if ( $( '.portfolio-category-wrapper' ).length > 0 && $( '.theme-widget-area' ).length > 0 ) {
				
			// Get the distance between the elements and the top of the viewport
			var categoryFromTopViewport = $( '.portfolio-category-wrapper' ).offset().top - $(window).scrollTop() + $( '.portfolio-category-wrapper' ).outerHeight();
			var footerFromTopViewport = $( '.theme-widget-area' ).offset().top - $(window).scrollTop();
			
			// If the elements overlap each other, hide the category
			if ( categoryFromTopViewport >= footerFromTopViewport ) {
				
				if ( ! $( '.portfolio-category-wrapper' ).hasClass( 'js-hidden' ) ) {
					
					$( '.portfolio-category-wrapper' ).stop().animate({
						opacity: 0,
					}, 50 ).addClass( 'js-hidden' );
					
				}
				
			} else {
			
				$( '.portfolio-category-wrapper' ).stop().animate({
					opacity: 1,
				}).removeClass( 'js-hidden' );
				
			}
			
		}
		
	}
	
	
	$( window ).scroll( function() {
		
		setPortfolioCategoryDisplay();
		
	});
	
	
	
	/* #Site Menu
	 ================================================== */
	if ( jQuery().superfish ) {
		
		// Init the menu and submenu
		$( '.menu-list' ).superfish({
			popUpSelector: '.sub-menu, .children',
			animation: {
				opacity: 'show',
			},
			speed: 300,
			speedOut: 400,
			delay: 500	// milliseconds delay on mouseout
		});
		
	} else {
		console.log( 'superfish JS is disabled or missing.' );
	}
	
	
	
	/* #Mobile Menu
	 ================================================== */
	createMobileMenuItems();
	
	if ( jQuery().mmenu ) {
			
		// Initialize the mobile menu
		$( '#mobile-menu-entity' ).mmenu({
			// Options
			extensions 	: [ 'pagedim-black' ],
			slidingSubmenus : false,
			offCanvas : {
				position : 'right',
			},
			navbars	: {
				content : [ 'close' ],
			}
		});
		
	} else {
		console.log( 'mmenu JS is disabled or missing.' );
	}
	
	function createMobileMenuItems() {
		
		var mobileMenuList = $( '<ul />' ).appendTo( $( '#mobile-menu-entity' ) );
		
		var clonedList = $( '.menu-list > li' ).clone();
		clonedList = getGeneratedSubmenu( clonedList );
		clonedList.appendTo( mobileMenuList );
		
	}
	
	// Recursive function for generating submenus
	function getGeneratedSubmenu( list ) {
		
		$( list ).each( function() {
			
			if ( $( this ).find( 'ul' ).length > 0 ) {
				
				var submenu = $( this ).find( 'ul' ).removeAttr( 'style' ).removeAttr( 'class' ); // To remove styles that prevents mobile menu to display properly
				getGeneratedSubmenu( submenu.find( 'li' ) );
				
			}
			
		});
		
		return list;
		
	}
	
	
	
	/* #Search 
	 ================================================== */
	 
	// Change the default placeholder text of the modal search input
	$( '#search-panel-wrapper .search-field' ).attr( 'placeholder', ThemeOptions.modal_search_input_text );
	
	var isSearchOpened = false;
	
	$( '.search-button, .search-icon-button' ).on( 'click', function() {
		
		$( '#search-panel-wrapper' ).css( 'display', 'block' ).stop().animate({
			opacity: 1,
		}, 300, function() {
			
			$( '#search-panel-wrapper .search-field' ).focus();
			isSearchOpened = true;
			
		});
		
	});
	
	$( '#search-close-button' ).on( 'click', function() {
		closeSearchPanel();
	});
	
	$( document ).on( 'keyup', function( e ) {
		
		// Escape key
		if ( 27 === e.keyCode ) {
			closeSearchPanel();
		}
		
	});
	
	function closeSearchPanel() {
		
		if ( isSearchOpened ) {
			
			$( '#search-panel-wrapper' ).stop().animate({
				opacity: 0,
			}, 300, function() {
				
				$( this ).css( 'display', 'none' );
				isSearchOpened = false;
				
			});
	
		}
		
	}
	
	
	
	/* #Fancybox 
	 ================================================== */
	 
	var enableLightbox = ThemeOptions.enable_lightbox_wp_gallery;
	if ( '0' === enableLightbox ) {
		enableLightbox = false;
	} else {
		enableLightbox = true;
	}
	
	// Add FancyBox feature to WP gallery and WP images
	if ( enableLightbox ) {
		
		registerFancyBoxToWPGallery();
		registerFancyBoxToWPImage();
		
	}
	 
	function registerFancyBoxToWPGallery() {
		// WP Gallery shortcode
		var $wpGallery = $( '.gallery' );

		$wpGallery.each( function() {
			
			var mainId = $( this ).attr( 'id' );
			var items = $( this ).find( '.gallery-item' ).find( 'a' );

			items.each( function() {

				var href = $( this ).attr( 'href' );
				
				// Check the target file extension, if it is one of the image extension then add Fancybox class
				if ( href.toLowerCase().indexOf( '.jpg' ) >= 0 || href.toLowerCase().indexOf( '.jpeg' ) >= 0 || href.toLowerCase().indexOf( '.png' ) >= 0 || href.toLowerCase().indexOf( '.gif' ) >= 0) {

					$( this ).addClass( 'image-box' );
					$( this ).attr( 'data-fancybox-group', mainId );

				}

			});

		});
	}
	
	function registerFancyBoxToWPImage() {
		
		// Run through WP images on the page
		$( 'img[class*="wp-image-"]' ).each( function() {
			
			// If the image has an anchor tag
			var $parentAnchor = $( this ).closest( 'a' );
			
			if ( $parentAnchor.length > 0 ) {
				
				var href = $parentAnchor.attr( 'href' );
				
				// Check the target file extension, if it is one of the image extension then add Fancybox class
				if (href.toLowerCase().indexOf( '.jpg' ) >= 0 || href.toLowerCase().indexOf( '.jpeg' ) >= 0 || href.toLowerCase().indexOf( '.png' ) >= 0 || href.toLowerCase().indexOf( '.gif' ) >= 0) {

					$parentAnchor.addClass( 'image-box no-slideshow' );

				}
				
			}
			
		});
		
	}
	
	
	callFancyBoxScript();
	
	function callFancyBoxScript() {
		
		if ( jQuery().fancybox ) {
			
			// For portfolio and WP gallery
			$( '.image-box' ).fancybox({
				mouseWheel: false,
				padding: 0,
				closeBtn: false,
				nextEffect: 'fade',
				prevEffect: 'fade',
				tpl: {
					error: '<p class="fancybox-error">' + ThemeOptions.lightbox_error_text + '</p>',
					closeBtn: '<a title="' + ThemeOptions.lightbox_close_text + '" class="fancybox-item fancybox-close" href="javascript:;"></a>',
					next: '<a title="' + ThemeOptions.lightbox_next_text + '" class="fancybox-nav fancybox-next" href="javascript:;"><span></span></a>',
					prev: '<a title="' + ThemeOptions.lightbox_prev_text + '" class="fancybox-nav fancybox-prev" href="javascript:;"><span></span></a>',	
				},
				helpers : {
					thumbs : {
						width : 40,
						height : 40,
					},
					overlay: {
						locked: true, // to prevent page jumping to the top when clicking on the object
						css: { 'background': 'rgba(248,248,248,1)' },
					},
					title: {
						type : 'outside',
					},
					buttons: {
						tpl: '<div id="fancybox-buttons"><ul><li><a class="btnPrev" title="' + ThemeOptions.lightbox_prev_text + '" href="javascript:;"></a></li><li><a class="btnPlay" title="' + ThemeOptions.lightbox_start_slide_text + '" href="javascript:;"></a></li><li><a class="btnNext" title="' + ThemeOptions.lightbox_next_text + '" href="javascript:;"></a></li><li><a class="btnToggle" title="' + ThemeOptions.lightbox_toggle_size_text + '" href="javascript:;"></a></li><li><a class="btnClose" title="' + ThemeOptions.lightbox_close_text + '" href="javascript:;"></a></li></ul></div>',
					},
				},
				beforeLoad: function() {
					this.title = getImageCaptionText( $( this.element ) );
				},
			});
			
			
			
			// For WP images
			$( '.image-box.no-slideshow' ).fancybox({
				padding: 0,
				helpers : {
					overlay: {
						locked: true, // to prevent page jumping to the top when clicking on the object
						css: { 'background': 'rgba(255,255,255,1)' },
					},
					title: {
						type : 'outside',
					},
				},
				beforeLoad: function() {
					this.title = getImageCaptionText( $( this.element ) );
				},
			});
			
		} else {
			console.log( 'Fancybox JS is disabled or missing.' );
		}
		
	}
	
	function getImageCaptionText( $element ) {
		
		// For WP gallery
		if ( $element.closest( '.gallery-item' ).length > 0 ) {
			return $element.closest( '.gallery-item' ).find( '.wp-caption-text' ).html();
		
		// For theme image
		} else if ( $element.closest( '.image-wrapper' ).length > 0 ) {
			return $element.closest( '.image-wrapper' ).find( '.image-caption' ).html();
			
		// For any other cases... it can be normal WP media file (image)
		} else {
			return $element.closest( '.wp-caption' ).find( '.wp-caption-text' ).html();
		}
		
	}
	
	
	
	/* #Misc
	 ================================================== */
	 
	// Make the embed video fit its container
	if ( jQuery().fitVids ) {
		$( '.video-wrapper' ).fitVids();
	} else {
		console.log( 'FitVids JS is disabled or missing.' );
	}
	
	// Hide the underline of the link that wraps around img
	var $wpImages = $( 'img[class*="wp-image-"], img[class*="attachment-"], .widget-item img' );
	if ( $wpImages.closest( 'a' ).length > 0 ) {
		$wpImages.closest( 'a' ).addClass( 'no-border' );
	}
	
	function randomizeNumberFromRange( min, max ) {
		return Math.floor( Math.random() * ( max - min + 1 ) + min );
	}
	
	function log( x ) {
		console.log( x );
	}
	
	function checkModernizr() {
	
		if ( 'undefined' !== typeof Modernizr ) {
			return true;
		} else {
			console.log( 'Modernizr JS is missing.' );
			return false;
		}
		
	}
	
	function getIntValurFromCSSAttribute( $attr ) {
		return parseInt( $attr.replace( 'px', '' ), 10 );
	}
	
		
	
	/* #Responsive Related
	 ================================================== */
	
	var windowWidth = $( window ).width();
	var timeoutId = 0;
	
	// Run this function right after the resizing is finished
	function doneResizing() {
		
		waitForFinalEvent(function() {
			
			if ( 'grid' === layout ) {
				initFlexImages();
			}
			
		}, 300, 'adjust_flex_grids');
		
	}
	
	$( window ).on( 'resize', function() {
		
		// Check window width has actually changed and it's not just iOS triggering a resize event on scroll
		if ( $( window).width() != windowWidth ) {
			
			// Update the window width for next time
			windowWidth = $( window ).width();
			
			setSideContainer();
			setSearchImageSize();
			setFooterWidgetSize();
			setCopyrightSocialIconsLocation();
			
			setPortfolioCategories();
			
			clearTimeout( timeoutId );
			timeoutId = setTimeout( doneResizing, 300 );
			
		}
	});
		
});