Skip to content

Commit

Permalink
Mohin/fix notification (#140)
Browse files Browse the repository at this point in the history
Signed-off-by: mohin7 <[email protected]>
  • Loading branch information
mohin7 authored Mar 24, 2024
1 parent bcb9dd3 commit adde3ac
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
30 changes: 15 additions & 15 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,21 +138,21 @@
var iframe = document.getElementById("notification");
iframe.style.height = iframe.contentWindow.document.body.scrollHeight + 'px';
}
// window.addEventListener("message", receiveMessageFromIframe, false);

// function receiveMessageFromIframe(event) {
// // Check the origin of the message for security purposes
// let baseURL = "{{$.Site.BaseURL}}"

// if (baseURL.endsWith("/")) {
// baseURL = baseURL.slice(0, -1);
// }
// if (event.origin !== baseURL) {
// return;
// }
// const notification = document.querySelector("#notification");
// notification.style.height = `${event.data}px`
// }
window.addEventListener("message", receiveMessageFromIframe, false);

function receiveMessageFromIframe(event) {
// Check the origin of the message for security purposes
let baseURL = "{{$.Site.BaseURL}}"

if (baseURL.endsWith("/")) {
baseURL = baseURL.slice(0, -1);
}
if (event.origin !== baseURL) {
return;
}
const notification = document.querySelector("#notification");
notification.style.height = `${event.data}px`
}
</script>
<!-- iframe for top notification -->
<div class="navbar-area navbar-fixed">
Expand Down
8 changes: 4 additions & 4 deletions layouts/_default/notification_top.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@
</div>
</div>
<script>
// var notificationWrapper = document.getElementById("notificationWrapper");
// var parentWindow = window.parent;
// // Send a message to the parent window
// parentWindow.postMessage(notificationWrapper.scrollHeight);
var notificationWrapper = document.getElementById("notificationWrapper");
var parentWindow = window.parent;
// Send a message to the parent window
parentWindow.postMessage(notificationWrapper.scrollHeight);
</script>
</body>
</html>

0 comments on commit adde3ac

Please sign in to comment.