mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-03 12:39:25 +01:00
track top EGroupware window in egw object to be used as egw.top instead of window.top, which can throw a security exception
This commit is contained in:
parent
5b8e02fded
commit
588cd10043
@ -33,7 +33,7 @@ function et2_loadXMLFromURL(_url, _callback, _context, _fail_callback) {
|
||||
// catch security exception if opener is from a different domain
|
||||
}
|
||||
if (typeof win == "undefined") {
|
||||
win = top;
|
||||
win = egw.top;
|
||||
}
|
||||
win.jQuery.ajax({
|
||||
// we add the full url (protocol and domain) as sometimes just the path
|
||||
|
@ -39,7 +39,7 @@ function et2_loadXMLFromURL(_url : string, _callback : Function, _context : obje
|
||||
}
|
||||
if (typeof win == "undefined")
|
||||
{
|
||||
win = top;
|
||||
win = egw.top;
|
||||
}
|
||||
win.jQuery.ajax({
|
||||
// we add the full url (protocol and domain) as sometimes just the path
|
||||
|
@ -406,7 +406,7 @@ var et2_dataview = /** @class */ (function () {
|
||||
if (typeof this.scrollbarWidth === 'undefined') {
|
||||
// Clone the table and attach it to the outer body tag
|
||||
var clone = this.table.clone();
|
||||
jQuery(window.top.document.getElementsByTagName("body")[0])
|
||||
jQuery(egw.top.document.getElementsByTagName("body")[0])
|
||||
.append(clone);
|
||||
// Read the scrollbar width
|
||||
this.scrollbarWidth = this.constructor.prototype.scrollbarWidth =
|
||||
|
@ -571,7 +571,7 @@ export class et2_dataview
|
||||
{
|
||||
// Clone the table and attach it to the outer body tag
|
||||
var clone = this.table.clone();
|
||||
jQuery(window.top.document.getElementsByTagName("body")[0])
|
||||
jQuery(egw.top.document.getElementsByTagName("body")[0])
|
||||
.append(clone);
|
||||
|
||||
// Read the scrollbar width
|
||||
|
@ -145,6 +145,11 @@
|
||||
webserverUrl: egw_webserverUrl
|
||||
};
|
||||
}
|
||||
// set top window in egw object
|
||||
if (typeof window.egw.top === "undefined")
|
||||
{
|
||||
window.egw.top = window;
|
||||
}
|
||||
|
||||
// focus window / call window.focus(), if data-window-focus is specified
|
||||
var window_focus = egw_script.getAttribute('data-window-focus');
|
||||
|
@ -68,9 +68,9 @@ var EgwApp = /** @class */ (function () {
|
||||
}
|
||||
// Make sure we're running in the top window when we init sidebox
|
||||
//@ts-ignore
|
||||
if (window.app[this.appname] === this && window.top.app[this.appname] !== this && window.top.app[this.appname]) {
|
||||
if (window.app[this.appname] === this && egw.top.app[this.appname] !== this && egw.top.app[this.appname]) {
|
||||
//@ts-ignore
|
||||
window.top.app[this.appname]._init_sidebox(sidebox);
|
||||
egw.top.app[this.appname]._init_sidebox(sidebox);
|
||||
}
|
||||
else {
|
||||
this._init_sidebox(sidebox);
|
||||
|
@ -150,10 +150,10 @@ export abstract class EgwApp
|
||||
}
|
||||
// Make sure we're running in the top window when we init sidebox
|
||||
//@ts-ignore
|
||||
if(window.app[this.appname] === this && window.top.app[this.appname] !== this && window.top.app[this.appname])
|
||||
if(window.app[this.appname] === this && egw.top.app[this.appname] !== this && egw.top.app[this.appname])
|
||||
{
|
||||
//@ts-ignore
|
||||
window.top.app[this.appname]._init_sidebox(sidebox);
|
||||
egw.top.app[this.appname]._init_sidebox(sidebox);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
5
api/js/jsapi/egw_global.d.ts
vendored
5
api/js/jsapi/egw_global.d.ts
vendored
@ -59,6 +59,11 @@ declare interface IegwGlobal
|
||||
*/
|
||||
webserverUrl : string;
|
||||
|
||||
/**
|
||||
* Reference to top window of EGroupware (no need to check for security exceptions!)
|
||||
*/
|
||||
top : Window;
|
||||
|
||||
/**
|
||||
* implemented in egw_config.js
|
||||
*/
|
||||
|
@ -75,9 +75,9 @@ egw.extend('message', egw.MODULE_WND_LOCAL, function(_app, _wnd)
|
||||
}
|
||||
|
||||
// if we are NOT in a popup then call the message on top window
|
||||
if (!this.is_popup() && _wnd !== _wnd.top)
|
||||
if (!this.is_popup() && _wnd !== egw.top)
|
||||
{
|
||||
egw(_wnd.top).message(_msg, _type);
|
||||
egw(egw.top).message(_msg, _type);
|
||||
return;
|
||||
}
|
||||
// handle message display for non-framework templates, eg. idots or jerryr
|
||||
|
@ -366,7 +366,7 @@ egw.extend('open', egw.MODULE_WND_LOCAL, function(_egw, _wnd)
|
||||
if (typeof(_app) == 'undefined') _app = false;
|
||||
if (typeof(_returnID) == 'undefined') _returnID = false;
|
||||
|
||||
var $wnd = jQuery(_wnd.top);
|
||||
var $wnd = jQuery(egw.top);
|
||||
var positionLeft = ($wnd.outerWidth()/2)-(_width/2)+_wnd.screenX;
|
||||
var positionTop = ($wnd.outerHeight()/2)-(_height/2)+_wnd.screenY;
|
||||
|
||||
|
@ -149,17 +149,7 @@ function egw_insertJS(_html)
|
||||
*/
|
||||
function egw_topWindow()
|
||||
{
|
||||
if (typeof window.parent != "undefined" && typeof window.parent.top != "undefined")
|
||||
{
|
||||
return window.parent.top;
|
||||
}
|
||||
|
||||
if (typeof window.opener != "undefined" && typeof window.opener.top != "undefined")
|
||||
{
|
||||
return window.opener.top;
|
||||
}
|
||||
|
||||
return window.top;
|
||||
return egw.top;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -288,14 +278,15 @@ window.egw_getFramework = function()
|
||||
{
|
||||
return framework;
|
||||
}
|
||||
else if (typeof window.parent.egw_getFramework != "undefined" && window != window.parent)
|
||||
{
|
||||
return window.parent.egw_getFramework();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
try {
|
||||
if (typeof window.parent.egw_getFramework != "undefined" && window != window.parent)
|
||||
{
|
||||
return window.parent.egw_getFramework();
|
||||
}
|
||||
}
|
||||
catch (e) {}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user