Untitled

mail@pastecode.io avatar
unknown
plain_text
3 months ago
2.1 kB
4
Indexable
Never
<script>
  //adds event ready for accordion widget and keep it closed if has class 'dont-open'
	jQuery( window ).on( 'elementor/frontend/init', () => {
			var $ = jQuery;
			const addHandler = ( $element ) => {
			 window.acc = $element;
			 if($element[0].classList.contains("dont-open")){
				 setTimeout(function(){
						$('.elementor-tab-title', $element).removeClass('elementor-active');
						$('.elementor-tab-content', $element).css('display', 'none');
				 }, 1);
			 }
		 };
		 elementorFrontend.hooks.addAction( 'frontend/element_ready/accordion.default', addHandler );
	} );

	//set size ratio to iframe videos
	jQuery( document ).ready(function() {
    var $ = jQuery;
    $(".wp-block-embed-youtube iframe, .auto-youtube-iframe").each(function(){
			var iNode = $(this);
			function windowResize(){
				iNode.css("height", parseInt(iNode.width()/1.779, 10) + "px");
			}			
			
			$( window ).on( "resize", windowResize);			
			windowResize()
			 
			
		});
		
		//blank links
			$(".form-info-panel a").each(function(){
			var elem = $(this);
						if(elem.attr("href") && elem.attr("href")[0] == "#"){
			} else {
				elem.attr("target", "_blank");
			} 
		}); 
		
		
		//fix contact forms inside elementor pop-ups
 jQuery( document ).on( 'elementor/popup/show', () => {
     // do your tracking here
     $(".wpcf7-form .wpcf7-spinner").remove();
     $(".wpcf7-form").each(function(){
			 var elem = $(this);
			if (!elem.is(":visible")) {
				return;
			}
			 	if(elem.hasClass("form-initialised")){
				  return;
			 	}
			  elem.addClass("form-initialised")
			  wpcf7cf_forms.push(new Wpcf7cfForm(elem));
			  wpcf7.init(elem[0]);
		 })
	 wpcf7cf_forms.forEach(function(f){
		 f.displayFields();
	 });
	 			 //trigger preset forms
				$(window).trigger('preset-forms');
 });

		 //this links will open the cookie banner
    $("a[href*='#open-cookie-banner']").on("click", function(e){
      e.preventDefault();
      if(window.OneTrust){
        OneTrust.ToggleInfoDisplay();
      }

      return false;
    });
		
		
		
} );
		
</script>
Leave a Comment