2019-09-23 02:25:02 -05:00
|
|
|
/////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// pgAdmin 4 - PostgreSQL Tools
|
|
|
|
//
|
2024-01-01 02:43:48 -06:00
|
|
|
// Copyright (C) 2013 - 2024, The pgAdmin Development Team
|
2019-09-23 02:25:02 -05:00
|
|
|
// This software is released under the PostgreSQL Licence
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
|
2020-01-30 23:50:45 -06:00
|
|
|
let getWindowOpener = (opener) => {
|
2024-01-25 05:21:40 -06:00
|
|
|
return opener.opener?.pgAdmin ? getWindowOpener(opener.opener) : opener;
|
2020-01-30 23:50:45 -06:00
|
|
|
};
|
|
|
|
|
2024-06-12 07:39:06 -05:00
|
|
|
const pgWindow = function() {
|
2020-07-03 04:03:30 -05:00
|
|
|
let localPgWindow = null;
|
2019-09-23 02:25:02 -05:00
|
|
|
try {
|
2024-01-25 05:21:40 -06:00
|
|
|
if(window.opener?.pgAdmin) {
|
2020-01-30 23:50:45 -06:00
|
|
|
/* Windows can be opened at multiple levels */
|
2020-07-03 04:03:30 -05:00
|
|
|
localPgWindow = getWindowOpener(window.opener);
|
2024-01-25 05:21:40 -06:00
|
|
|
} else if(window.parent?.pgAdmin){
|
2020-07-03 04:03:30 -05:00
|
|
|
localPgWindow = window.parent;
|
2024-01-25 05:21:40 -06:00
|
|
|
} else if(window.top?.pgAdmin){
|
2020-07-03 04:03:30 -05:00
|
|
|
localPgWindow = window.top;
|
2019-09-23 02:25:02 -05:00
|
|
|
} else {
|
2020-07-03 04:03:30 -05:00
|
|
|
localPgWindow = window;
|
2019-09-23 02:25:02 -05:00
|
|
|
}
|
2024-07-04 07:55:47 -05:00
|
|
|
} catch {
|
2020-07-03 04:03:30 -05:00
|
|
|
localPgWindow = window;
|
2019-09-23 02:25:02 -05:00
|
|
|
}
|
2020-07-03 04:03:30 -05:00
|
|
|
return localPgWindow;
|
2019-09-23 02:25:02 -05:00
|
|
|
}();
|
|
|
|
|
|
|
|
export default pgWindow;
|