From 239bff06ced19752926e51e2cd3055194f99f342 Mon Sep 17 00:00:00 2001 From: Jorit Tijsen Date: Fri, 19 Apr 2024 15:46:16 +0200 Subject: [PATCH] Retry calculate add size if is not working --- public/js/functions.js | 13 ++++++++++--- public/js/functions.min.js | 2 +- resources/assets/js/functions/advertisement.js | 13 ++++++++++--- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/public/js/functions.js b/public/js/functions.js index 6082a4dd..6b50be88 100644 --- a/public/js/functions.js +++ b/public/js/functions.js @@ -1,7 +1,14 @@ -function calculateSize(targetId) { +function calculateSize(targetId, tries) { + if (tries == undefined) { + tries = 0; + } setTimeout(function(){ - $('#' + targetId).height($('#' + targetId).children(":first").height()); - $('#' + targetId).width($('#' + targetId).children(":first").width()); + if (($('#' + targetId).children(":first").height() == 0 || $('#' + targetId).children(":first").width() == 0) && tries < 4) { + calculateSize(targetId, tries + 1); + } else { + $('#' + targetId).height($('#' + targetId).children(":first").height()); + $('#' + targetId).width($('#' + targetId).children(":first").width()); + } }, 500); $('#' + targetId).css({backgroundColor: 'transparent'}); } diff --git a/public/js/functions.min.js b/public/js/functions.min.js index 650e0c9b..10480c25 100644 --- a/public/js/functions.min.js +++ b/public/js/functions.min.js @@ -1,2 +1,2 @@ /*! 2024-04-19 */ -function calculateSize(e){setTimeout(function(){$("#"+e).height($("#"+e).children(":first").height()),$("#"+e).width($("#"+e).children(":first").width())},500),$("#"+e).css({backgroundColor:"transparent"})}$(document).ready(function(){$("#changePreferences, .cc_b_cp").click(function(){$("#title_targeting").parent("li").hide(),$("#content_targeting").hide()})}),function(a){a.fn.loadMoreNews=function(e){var t=!1,o={loadingElementId:"#loading",container:"",url:document.location.pathname,nextPage:2},s=(a.extend(o,e),a(o.loadingElementId,this));s.hide(),this.click(function(e){var n,i;e.preventDefault(),t||(t=1,s.show(),n=a(this).attr("disabled","disabled"),i=a(o.container),a.ajax({url:o.url+(0<=o.url.indexOf("?")?"&":"?")+"pagina="+o.nextPage}).always(function(){t=0,s.hide(),n.removeAttr("disabled")}).done(function(t){t?(i.each(function(){var e=this.toString();a(e).append(a("
"+t+"
").find(e).length?a("
"+t+"
").find(e).children():a(t))}),++o.nextPage):n.attr("disabled","disabled").text("Geen nieuws meer.")}))})}}(jQuery),$(function(){$("[data-loadmorenews]").each(function(){$(this).loadMoreNews($(this).data("loadmorenews"))})}),function(o){o.fn.menu=function(e){var t={menuSubmenuClass:"has_submenu"},e=(o.extend(t,e),o(this).children("."+t.menuSubmenuClass)),i=o(this);e.on("mouseenter",function(){var e=o(this),t=(o(".menu-submenu > ul.submenu").slideUp(400,function(){o(this).closest(".menu-submenu").remove()}),o(".hover",i).removeClass("hover"),e.addClass("hover"),o('
').append(e.children("ul.submenu").clone())),n=e.offset();t.addClass("menu-submenu").css({top:n.top,left:n.left}),t.on("mouseleave",function(){o(".menu-submenu > ul.submenu").slideUp(400,function(){o(this).closest(".menu-submenu").remove()}),e.removeClass("hover")}),o("body").append(t),t.children("ul.submenu").slideDown(),t.find("ul.submenu").subMenu({}),openPlayerInNewScreen()})},o.fn.subMenu=function(e){var t={menuSubmenuClass:"has_submenu"};o.extend(t,e),o(this).find("li."+t.menuSubmenuClass+" > a").click(function(e){e.preventDefault();e=o(this).closest("li");e.children("ul.submenu").slideToggle(),e.toggleClass("opened")})}}(jQuery),$(function(){$(".menu").menu({}),$(".mobile-menu").subMenu({}),$(".mobile_menu_button a").click(function(){$(".mobile_menu_container").show()}),$(".mobile_close_menu_button a").click(function(){$(".mobile_menu_container").hide()}),$(".mobile_menu_container").click(function(e){!$(e.target).closest("#mobile_menu_nav").length&&$(".mobile_menu_container").is(":visible")&&$(".mobile_menu_container").hide()})}),$(function(){$(".prettyPhoto[rel^='prettyPhoto']").prettyPhoto({show_title:!1,slideshow:3e3,overlay_gallery:!0,social_tools:""})}),$(function(){$(".scroll_top").click(function(e){e.preventDefault(),$("html, body").stop().animate({scrollTop:0},500,"swing")})}),function(o){o.fn.share=function(e){var i={type:"",types:{facebook:{url:"https://www.facebook.com/sharer/sharer.php?u=",textOption:!1},twitter_x:{url:"https://twitter.com/share?url=",textOption:"text="}},excerptClass:"excerpt"};o.extend(i,e),this.click(function(e){e.preventDefault();var t,n,e=i.types[i.type];void 0!==e?(t="",e.textOption&&(278<(n=o("."+i.excerptClass).text().trim()).length+location.href.length&&(n=n.substring(0,278-(location.href.length+3))+"..."),t="&"+e.textOption+encodeURI(n)),window.open(e.url+encodeURI(location.href)+t,"pop","width=600, height=400, scrollbars=no")):console.error(i.type+" is unknown")})}}(jQuery),$(function(){$("[data-share]").each(function(){$(this).share({type:$(this).data("share")})})}),function(u){u.fn.snapTo=function(e){var t={elementClass:"post"},n=(u.extend(t,e),u(this)),i=n.find("."+t.elementClass+":visible"),o=!1,s=null,a=function(){var t;o||(o=!0,t=n.scrollLeft(),i.each(function(){var e=u(this).offset();if(e.left>-window.screen.width/2&&e.left"+t+"").find(e).length?a("
"+t+"
").find(e).children():a(t))}),++o.nextPage):n.attr("disabled","disabled").text("Geen nieuws meer.")}))})}}(jQuery),$(function(){$("[data-loadmorenews]").each(function(){$(this).loadMoreNews($(this).data("loadmorenews"))})}),function(o){o.fn.menu=function(e){var t={menuSubmenuClass:"has_submenu"},e=(o.extend(t,e),o(this).children("."+t.menuSubmenuClass)),i=o(this);e.on("mouseenter",function(){var e=o(this),t=(o(".menu-submenu > ul.submenu").slideUp(400,function(){o(this).closest(".menu-submenu").remove()}),o(".hover",i).removeClass("hover"),e.addClass("hover"),o('
').append(e.children("ul.submenu").clone())),n=e.offset();t.addClass("menu-submenu").css({top:n.top,left:n.left}),t.on("mouseleave",function(){o(".menu-submenu > ul.submenu").slideUp(400,function(){o(this).closest(".menu-submenu").remove()}),e.removeClass("hover")}),o("body").append(t),t.children("ul.submenu").slideDown(),t.find("ul.submenu").subMenu({}),openPlayerInNewScreen()})},o.fn.subMenu=function(e){var t={menuSubmenuClass:"has_submenu"};o.extend(t,e),o(this).find("li."+t.menuSubmenuClass+" > a").click(function(e){e.preventDefault();e=o(this).closest("li");e.children("ul.submenu").slideToggle(),e.toggleClass("opened")})}}(jQuery),$(function(){$(".menu").menu({}),$(".mobile-menu").subMenu({}),$(".mobile_menu_button a").click(function(){$(".mobile_menu_container").show()}),$(".mobile_close_menu_button a").click(function(){$(".mobile_menu_container").hide()}),$(".mobile_menu_container").click(function(e){!$(e.target).closest("#mobile_menu_nav").length&&$(".mobile_menu_container").is(":visible")&&$(".mobile_menu_container").hide()})}),$(function(){$(".prettyPhoto[rel^='prettyPhoto']").prettyPhoto({show_title:!1,slideshow:3e3,overlay_gallery:!0,social_tools:""})}),$(function(){$(".scroll_top").click(function(e){e.preventDefault(),$("html, body").stop().animate({scrollTop:0},500,"swing")})}),function(o){o.fn.share=function(e){var i={type:"",types:{facebook:{url:"https://www.facebook.com/sharer/sharer.php?u=",textOption:!1},twitter_x:{url:"https://twitter.com/share?url=",textOption:"text="}},excerptClass:"excerpt"};o.extend(i,e),this.click(function(e){e.preventDefault();var t,n,e=i.types[i.type];void 0!==e?(t="",e.textOption&&(278<(n=o("."+i.excerptClass).text().trim()).length+location.href.length&&(n=n.substring(0,278-(location.href.length+3))+"..."),t="&"+e.textOption+encodeURI(n)),window.open(e.url+encodeURI(location.href)+t,"pop","width=600, height=400, scrollbars=no")):console.error(i.type+" is unknown")})}}(jQuery),$(function(){$("[data-share]").each(function(){$(this).share({type:$(this).data("share")})})}),function(u){u.fn.snapTo=function(e){var t={elementClass:"post"},n=(u.extend(t,e),u(this)),i=n.find("."+t.elementClass+":visible"),o=!1,s=null,a=function(){var t;o||(o=!0,t=n.scrollLeft(),i.each(function(){var e=u(this).offset();if(e.left>-window.screen.width/2&&e.left