$(function () {
let $noticesDiv = $('#noticeWidget2');
if ($noticesDiv?.noticeWidget) {
$noticesDiv.noticeWidget();
}
var container = $('#redesignedNoticeTopPanel');
var importantNoticeTopPanel = container.find('.redesigned-notice-important');
var noticeNoticeTopPanel = container.find('.redesigned-notice-notice');
var successNoticeTopPanel = container.find('.redesigned-notice-success');
var warningNoticeTopPanel = container.find('.redesigned-notice-warning');
container.find('.redesigned-notice-top-panel').detach();
successNoticeTopPanel.prependTo(container);
noticeNoticeTopPanel.prependTo(container);
warningNoticeTopPanel.prependTo(container);
importantNoticeTopPanel.prependTo(container);
const informersHeights = []
function calculateIndent() {
const totalHeight = informersHeights.reduce((acc, item, index) => {
return index === 0 ? (acc += item) : (acc += 8);
}, 0);
const maxDefault = 48;
if (totalHeight > maxDefault) {
const difference = totalHeight - maxDefault;
const pageContainer = $('.gc-main-content > .container');
const profilePageContainer = $('.main-page-block ');
setTopIndent(pageContainer, difference, 'margin-top');
setTopIndent(profilePageContainer, difference, 'padding-top');
}
}
function setTopIndent(nodeWithIndent, extra, prop) {
nodeWithIndent?.css(prop, (36 + extra) + 'px');
}
const informers = $('#redesignedNoticeTopPanel').children();
if (informers.length) {
informers.each(function() {
if ($(this).hasClass('notice-top-panel')) {
informersHeights.push($(this).outerHeight());
}
});
}
calculateIndent();
});