Skip to content

Commit

Permalink
only save screen size when not iframed
Browse files Browse the repository at this point in the history
  • Loading branch information
sni committed Oct 14, 2024
1 parent 2e6379a commit 31c064b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,7 @@ var TP = {
/* called on body unload */
unload: function() {
TP.isUnloading = true;
cookieSave("thruk_screen", JSON.stringify(getScreenData()));
cookieSaveScreenSize();
},
deleteDowntime: function(id, panelId, type) {
var panel = Ext.getCmp(panelId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Ext.QuickTips.init();

Ext.onReady(function() {
cookieSave("thruk_tz", getBrowserTimezone());
cookieSave("thruk_screen", JSON.stringify(getScreenData()));
cookieSaveScreenSize();

/* main viewport */
if(one_tab_only) {
Expand Down
21 changes: 18 additions & 3 deletions root/thruk/javascript/thruk-3.18.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ function init_page() {

// store browsers timezone in a cookie so we can use it in later requests
cookieSave("thruk_tz", getBrowserTimezone());
cookieSave("thruk_screen", JSON.stringify(getScreenData()));
cookieSaveScreenSize();
jQuery(document).off("resize").on("resize", function() {
cookieSave("thruk_screen", JSON.stringify(getScreenData()));
cookieSaveScreenSize();
});
jQuery(window).off("resize").on("resize", function() {
cookieSave("thruk_screen", JSON.stringify(getScreenData()));
cookieSaveScreenSize();
});

/* show calendar popups for these */
Expand Down Expand Up @@ -287,6 +287,21 @@ function init_page() {
} catch(err) { console.log(err); }
}

function cookieSaveScreenSize() {
if(inIframe()) {
return;
}
cookieSave("thruk_screen", JSON.stringify(getScreenData()));
}

function inIframe () {
try {
return window.self !== window.top;
} catch (e) {
return true;
}
}

function initLastUserInteraction() {
jQuery(window)
.off("mousewheel DOMMouseScroll click keyup")
Expand Down

0 comments on commit 31c064b

Please sign in to comment.