mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-14 09:58:16 +01:00
Window dependant api modules do now get reinstanciated, if the window location changes
This commit is contained in:
parent
c8bf9ed6ef
commit
292f18bc1a
@ -40,6 +40,17 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deleteWhere(_arr, _cond)
|
||||||
|
{
|
||||||
|
for (var i = _arr.length - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
if (_cond(_arr[i]))
|
||||||
|
{
|
||||||
|
_arr.splice(i, 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The getAppModules function returns all application specific api modules
|
* The getAppModules function returns all application specific api modules
|
||||||
* for the given application. If those application specific api instances
|
* for the given application. If those application specific api instances
|
||||||
@ -87,10 +98,11 @@
|
|||||||
* @param _modules is the hash map which contains all module descriptors.
|
* @param _modules is the hash map which contains all module descriptors.
|
||||||
* @param _moduleInstances is the the object which contains the application
|
* @param _moduleInstances is the the object which contains the application
|
||||||
* and window specific module instances.
|
* and window specific module instances.
|
||||||
|
* @param _instances refers to all api instances.
|
||||||
* @param _wnd is the window for which the module instances should get
|
* @param _wnd is the window for which the module instances should get
|
||||||
* created.
|
* created.
|
||||||
*/
|
*/
|
||||||
function getWndModules(_egw, _modules, _moduleInstances, _window)
|
function getWndModules(_egw, _modules, _moduleInstances, _instances, _window)
|
||||||
{
|
{
|
||||||
// Search for the specific window instance
|
// Search for the specific window instance
|
||||||
for (var i = 0; i < _moduleInstances.wnd.length; i++)
|
for (var i = 0; i < _moduleInstances.wnd.length; i++)
|
||||||
@ -110,6 +122,13 @@
|
|||||||
'modules': mods
|
'modules': mods
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Add an eventlistener for the "onunload" event -- if "onunload" gets
|
||||||
|
// called, we have to delete the module slot created above
|
||||||
|
_window.addEventListener('beforeunload', function() {
|
||||||
|
cleanupEgwInstances(_instances, _moduleInstances, function(_w) {
|
||||||
|
return _w.window === _window});
|
||||||
|
}, false);
|
||||||
|
|
||||||
// Otherwise create the window specific instances
|
// Otherwise create the window specific instances
|
||||||
for (var key in _modules)
|
for (var key in _modules)
|
||||||
{
|
{
|
||||||
@ -133,11 +152,12 @@
|
|||||||
* and window specific module instances.
|
* and window specific module instances.
|
||||||
* @param _list is the overall instances list, to which the module should be
|
* @param _list is the overall instances list, to which the module should be
|
||||||
* added.
|
* added.
|
||||||
|
* @param _instances refers to all api instances.
|
||||||
* @param _app is the application for which the instance should be created.
|
* @param _app is the application for which the instance should be created.
|
||||||
* @param _wnd is the window for which the instance should be created.
|
* @param _wnd is the window for which the instance should be created.
|
||||||
*/
|
*/
|
||||||
function createEgwInstance(_egw, _modules, _moduleInstances, _list, _app,
|
function createEgwInstance(_egw, _modules, _moduleInstances, _list,
|
||||||
_window)
|
_instances, _app, _window)
|
||||||
{
|
{
|
||||||
// Clone the global object
|
// Clone the global object
|
||||||
var instance = cloneObject(_egw);
|
var instance = cloneObject(_egw);
|
||||||
@ -173,7 +193,7 @@
|
|||||||
if (_window)
|
if (_window)
|
||||||
{
|
{
|
||||||
var wndModules = getWndModules(_egw, _modules, _moduleInstances,
|
var wndModules = getWndModules(_egw, _modules, _moduleInstances,
|
||||||
_window);
|
_instances, _window);
|
||||||
|
|
||||||
for (var key in wndModules)
|
for (var key in wndModules)
|
||||||
{
|
{
|
||||||
@ -213,7 +233,7 @@
|
|||||||
{
|
{
|
||||||
_instances[hash] = [];
|
_instances[hash] = [];
|
||||||
return createEgwInstance(_egw, _modules, _moduleInstances,
|
return createEgwInstance(_egw, _modules, _moduleInstances,
|
||||||
_instances[hash], _app, _window);
|
_instances[hash], _instances, _app, _window);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -231,27 +251,16 @@
|
|||||||
// If we're still here, no API instance for the given window has been
|
// If we're still here, no API instance for the given window has been
|
||||||
// found -- create a new entry
|
// found -- create a new entry
|
||||||
return createEgwInstance(_egw, _modules, _moduleInstances,
|
return createEgwInstance(_egw, _modules, _moduleInstances,
|
||||||
_instances[hash], _app, _window);
|
_instances[hash], _instances, _app, _window);
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanupEgwInstances(_instances, _moduleInstances)
|
function cleanupEgwInstances(_instances, _moduleInstances, _cond)
|
||||||
{
|
{
|
||||||
function deleteClosedWindows(_arr)
|
|
||||||
{
|
|
||||||
for (var i = _arr.length - 1; i >= 0; i--)
|
|
||||||
{
|
|
||||||
if (_arr[i].window && _arr[i].window.closed)
|
|
||||||
{
|
|
||||||
_arr.splice(i, 1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Iterate over the instances
|
// Iterate over the instances
|
||||||
for (var key in _instances)
|
for (var key in _instances)
|
||||||
{
|
{
|
||||||
// Delete all entries corresponding to closed windows
|
// Delete all entries corresponding to closed windows
|
||||||
deleteClosedWindows(_instances[key]);
|
deleteWhere(_instances[key], _cond);
|
||||||
|
|
||||||
// Delete the complete instance key if the array is empty
|
// Delete the complete instance key if the array is empty
|
||||||
if (_instances[key].length === 0)
|
if (_instances[key].length === 0)
|
||||||
@ -262,7 +271,7 @@
|
|||||||
|
|
||||||
// Delete all entries corresponding to non existing elements in the
|
// Delete all entries corresponding to non existing elements in the
|
||||||
// module instances
|
// module instances
|
||||||
deleteClosedWindows(_moduleInstances.wnd);
|
deleteWhere(_moduleInstances.wnd, _cond);
|
||||||
}
|
}
|
||||||
|
|
||||||
function mergeGlobalModule(_module, _code, _instances, _moduleInstances)
|
function mergeGlobalModule(_module, _code, _instances, _moduleInstances)
|
||||||
@ -371,7 +380,9 @@
|
|||||||
* seconds.
|
* seconds.
|
||||||
*/
|
*/
|
||||||
window.setInterval(function() {
|
window.setInterval(function() {
|
||||||
cleanupEgwInstances(instances, moduleInstances);
|
cleanupEgwInstances(instances, moduleInstances, function(w) {
|
||||||
|
return w.window && w.window.closed
|
||||||
|
});
|
||||||
}, 10000);
|
}, 10000);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,6 +16,11 @@
|
|||||||
egw_core;
|
egw_core;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module which allows to add stylesheet rules at runtime. Exports the following
|
||||||
|
* functions:
|
||||||
|
* - css
|
||||||
|
*/
|
||||||
egw.extend('css', egw.MODULE_WND_LOCAL, function(_egw, _wnd) {
|
egw.extend('css', egw.MODULE_WND_LOCAL, function(_egw, _wnd) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -143,6 +143,8 @@ egw.extend('utils', egw.MODULE_GLOBAL, function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var uid_counter = 0;
|
||||||
|
|
||||||
// Create the utils object which contains references to all functions
|
// Create the utils object which contains references to all functions
|
||||||
// covered by it.
|
// covered by it.
|
||||||
var utils = {
|
var utils = {
|
||||||
@ -156,6 +158,10 @@ egw.extend('utils', egw.MODULE_GLOBAL, function() {
|
|||||||
_elem.ownerDocument.parentNode ||
|
_elem.ownerDocument.parentNode ||
|
||||||
_elem.ownerDocument.defaultView;
|
_elem.ownerDocument.defaultView;
|
||||||
return res;
|
return res;
|
||||||
|
},
|
||||||
|
|
||||||
|
uid: function() {
|
||||||
|
return (uid_counter++).toString(16);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -11,6 +11,16 @@
|
|||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Loading of the egw object, if it already is loaded in an upper window
|
||||||
|
if (window.opener && typeof window.opener.egw !== 'undefined')
|
||||||
|
{
|
||||||
|
window['egw'] = window.opener.egw;
|
||||||
|
}
|
||||||
|
else if (window.top && typeof window.top.egw !== 'undefined')
|
||||||
|
{
|
||||||
|
window['egw'] = window.top.egw;
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************\
|
/***********************************************\
|
||||||
* INITIALIZATION *
|
* INITIALIZATION *
|
||||||
\***********************************************/
|
\***********************************************/
|
||||||
|
Loading…
Reference in New Issue
Block a user