// COMPLETE FIX FOR HEADER POSITIONING
$(document).ready(function() {
// 1. FIRST - Remove all default APEX header space
function removeApexHeaderSpace() {
$('.t-Header').remove();
$('.t-Body-header').remove();
$('.t-Body-title').remove();
// Remove any padding/margin from body and main containers
$('body').css({
'padding': '0',
'margin': '0',
'overflow-x': 'hidden'
});
$('.t-Body').css({
'margin-top': '0',
'padding-top': '0'
});
$('.t-Body-main, .t-Body-content, #main').css({
'padding-top': '0',
'margin-top': '0'
});
}
// 2. SECOND - Ensure header is at absolute top
function positionHeaderAtTop() {
// Move header to very top of body if not already
var header = $('.custom-sticky-header');
if (header.parent().is('.t-Body')) {
header.prependTo('body');
}
// Apply fixed positioning
header.css({
'position': 'fixed',
'top': '0',
'left': '0',
'width': '100vw',
'z-index': '10000',
'background': 'white'
});
}
// 3. THIRD - Set proper body padding
function setBodyPadding() {
var headerHeight = $('.custom-sticky-header').outerHeight();
$('body').css('padding-top', headerHeight + 'px');
}
// 4. FOURTH - Make images larger
function maximizeImages() {
$('.side-image').css({
'max-height': '80px',
'min-height': '60px',
'width': 'auto'
});
$('.banner-image').css({
'max-height': '90px',
'min-height': '70px',
'width': 'auto'
});
}
// Run all fixes
function applyAllFixes() {
removeApexHeaderSpace();
positionHeaderAtTop();
setBodyPadding();
maximizeImages();
}
// Initial application
applyAllFixes();
// Re-apply on resize and APEX events
$(window).resize(applyAllFixes);
$(document).on('apexafterrefresh', applyAllFixes);
// Force reflow after a short delay
setTimeout(applyAllFixes, 100);
setTimeout(applyAllFixes, 500);
// Nuclear option: Remove any element causing top space
$('*').each(function() {
var $this = $(this);
if ($this.offset().top < 50 && $this.height() < 50) {
var style = window.getComputedStyle($this);
if (parseInt(style.marginTop) > 20 || parseInt(style.paddingTop) > 20) {
$this.css({
'margin-top': '0',
'padding-top': '0'
});
}
}
});
});