2019-09-23 02:25:02 -05:00
|
|
|
/////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// pgAdmin 4 - PostgreSQL Tools
|
|
|
|
//
|
2023-01-02 00:23:55 -06:00
|
|
|
// Copyright (C) 2013 - 2023, 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) => {
|
|
|
|
return opener.opener && opener.opener.pgAdmin ? getWindowOpener(opener.opener) : opener;
|
|
|
|
};
|
|
|
|
|
2019-09-23 02:25:02 -05:00
|
|
|
let pgWindow = function() {
|
2020-07-03 04:03:30 -05:00
|
|
|
let localPgWindow = null;
|
2019-09-23 02:25:02 -05:00
|
|
|
try {
|
|
|
|
if(window.opener && 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);
|
2019-09-23 02:25:02 -05:00
|
|
|
} else if(window.parent && window.parent.pgAdmin){
|
2020-07-03 04:03:30 -05:00
|
|
|
localPgWindow = window.parent;
|
2019-09-23 02:25:02 -05:00
|
|
|
} else if(window.top && 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
|
|
|
}
|
|
|
|
} catch (error) {
|
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;
|