mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-14 09:58:16 +01:00
fix not working 2. loading of a popup in IE, caused by IE freeing the cached template in top window, working around that by a getter/setter method in top etemplate2 doing a clone when storing templates
This commit is contained in:
parent
3b1de579f4
commit
43afc55932
@ -87,9 +87,8 @@ var et2_template = et2_DOMWidget.extend(
|
|||||||
var template_name = parts.pop();
|
var template_name = parts.pop();
|
||||||
|
|
||||||
// Check to see if the template is known
|
// Check to see if the template is known
|
||||||
var template = null;
|
var template = etemplate2.prototype.get_template_cache(template_name);
|
||||||
var templates = etemplate2.prototype.templates; // use global eTemplate cache
|
if(!template)
|
||||||
if(!(template = templates[template_name]))
|
|
||||||
{
|
{
|
||||||
// Check to see if ID is short form --> prepend parent/top-level name
|
// Check to see if ID is short form --> prepend parent/top-level name
|
||||||
if(template_name.indexOf('.') < 0)
|
if(template_name.indexOf('.') < 0)
|
||||||
@ -98,13 +97,13 @@ var et2_template = et2_DOMWidget.extend(
|
|||||||
var top_name = root && root._inst ? root._inst.name : null;
|
var top_name = root && root._inst ? root._inst.name : null;
|
||||||
if (top_name && template_name.indexOf('.') < 0) template_name = top_name+'.'+template_name;
|
if (top_name && template_name.indexOf('.') < 0) template_name = top_name+'.'+template_name;
|
||||||
}
|
}
|
||||||
template = templates[template_name];
|
template = etemplate2.prototype.get_template_cache(template_name);
|
||||||
if(!template)
|
if(!template)
|
||||||
{
|
{
|
||||||
// Ask server
|
// Ask server
|
||||||
var splitted = template_name.split('.');
|
var splitted = template_name.split('.');
|
||||||
// use template base url from initial template, to continue using webdav, if that was loaded via webdav
|
// use template base url from initial template, to continue using webdav, if that was loaded via webdav
|
||||||
var path = this.getRoot()._inst.template_base_url +
|
var path = this.getRoot()._inst.template_base_url +
|
||||||
splitted.join('.') + (cache_buster ? '&download='+cache_buster :
|
splitted.join('.') + (cache_buster ? '&download='+cache_buster :
|
||||||
// if server did not give a cache-buster, fall back to current time
|
// if server did not give a cache-buster, fall back to current time
|
||||||
'&download='+(new Date).valueOf());
|
'&download='+(new Date).valueOf());
|
||||||
@ -121,9 +120,9 @@ var et2_template = et2_DOMWidget.extend(
|
|||||||
{
|
{
|
||||||
var template = _data.children[i];
|
var template = _data.children[i];
|
||||||
if(template.tag !== "template") continue;
|
if(template.tag !== "template") continue;
|
||||||
templates[template.attributes.id] = template;
|
etemplate2.prototype.set_template_cache(template.attributes.id, template);
|
||||||
}// Read the structure of the requested template
|
}// Read the structure of the requested template
|
||||||
if (typeof templates[template_name] != 'undefined') this.loadFromJSON(templates[template_name]);
|
if (template.id == template_name) this.loadFromJSON(template);
|
||||||
|
|
||||||
// Update flag
|
// Update flag
|
||||||
this.loading.resolve();
|
this.loading.resolve();
|
||||||
@ -143,7 +142,7 @@ var et2_template = et2_DOMWidget.extend(
|
|||||||
{
|
{
|
||||||
this.loadFromJSON(template);
|
this.loadFromJSON(template);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't call this here - done by caller, or on whole widget tree
|
// Don't call this here - done by caller, or on whole widget tree
|
||||||
//this.loadingFinished();
|
//this.loadingFinished();
|
||||||
|
|
||||||
|
@ -100,22 +100,67 @@ function etemplate2(_container, _menuaction)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// List of templates (XML) that are known, not always used. Indexed by id.
|
/**
|
||||||
// We share list of templates with iframes and popups
|
* Return template from global cache, or undefined if not cached
|
||||||
try {
|
*
|
||||||
if (opener && opener.etemplate2)
|
* @param {string} _name
|
||||||
{
|
* @returns {object|undefined}
|
||||||
etemplate2.prototype.templates = opener.etemplate2.prototype.templates;
|
*/
|
||||||
}
|
etemplate2.prototype.get_template_cache = function(_name)
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
// catch security exception if opener is from a different domain
|
|
||||||
}
|
|
||||||
if (typeof etemplate2.prototype.templates == "undefined")
|
|
||||||
{
|
{
|
||||||
etemplate2.prototype.templates = top.etemplate2.prototype.templates || {};
|
try {
|
||||||
}
|
if (opener && opener.etemplate2)
|
||||||
|
{
|
||||||
|
return opener.etemplate2.prototype.get_template_cache(_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
// catch security exception if opener is from a different domain
|
||||||
|
}
|
||||||
|
// use top window, if we are in an iframe
|
||||||
|
if (top !== window)
|
||||||
|
{
|
||||||
|
return top.etemplate2.prototype.get_template_cache(_name);
|
||||||
|
}
|
||||||
|
// we are the top window
|
||||||
|
if (typeof etemplate2.prototype.templates == "undefined")
|
||||||
|
{
|
||||||
|
etemplate2.prototype.templates = {};
|
||||||
|
}
|
||||||
|
return etemplate2.prototype.templates[_name];
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store template object in global cache
|
||||||
|
*
|
||||||
|
* @param {string} _name
|
||||||
|
* @param {object} _template
|
||||||
|
*/
|
||||||
|
etemplate2.prototype.set_template_cache = function(_name, _template)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
if (opener && opener.etemplate2)
|
||||||
|
{
|
||||||
|
return opener.etemplate2.prototype.set_template_cache(_name, _template);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
// catch security exception if opener is from a different domain
|
||||||
|
}
|
||||||
|
// use top window, if we are in an iframe
|
||||||
|
if (top !== window)
|
||||||
|
{
|
||||||
|
return top.etemplate2.prototype.set_template_cache(_name, _template);
|
||||||
|
}
|
||||||
|
// we are the top window
|
||||||
|
if (typeof etemplate2.prototype.templates == "undefined")
|
||||||
|
{
|
||||||
|
etemplate2.prototype.templates = {};
|
||||||
|
}
|
||||||
|
// for IE we need to do a clone of template-object, as it might be from context of a different window
|
||||||
|
// and will become unavailable if that window closes
|
||||||
|
etemplate2.prototype.templates[_name] = jQuery.extend(true, {}, _template);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls the resize event of all widgets
|
* Calls the resize event of all widgets
|
||||||
@ -202,9 +247,8 @@ etemplate2.prototype.clear = function()
|
|||||||
$j(this.DOMContainer).empty();
|
$j(this.DOMContainer).empty();
|
||||||
|
|
||||||
// Remove self from the index
|
// Remove self from the index
|
||||||
for(name in this.templates)
|
for(name in etemplate2._byTemplate)
|
||||||
{
|
{
|
||||||
if(typeof etemplate2._byTemplate[name] == "undefined") continue;
|
|
||||||
for(var i = 0; i < etemplate2._byTemplate[name].length; i++)
|
for(var i = 0; i < etemplate2._byTemplate[name].length; i++)
|
||||||
{
|
{
|
||||||
if(etemplate2._byTemplate[name][i] == this)
|
if(etemplate2._byTemplate[name][i] == this)
|
||||||
@ -447,9 +491,10 @@ etemplate2.prototype.load = function(_name, _url, _data, _callback)
|
|||||||
etemplate2._byTemplate[_name].push(this);
|
etemplate2._byTemplate[_name].push(this);
|
||||||
|
|
||||||
// Read the structure of the requested template
|
// Read the structure of the requested template
|
||||||
if (this.templates[this.name].children)
|
var template = this.get_template_cache(this.name);
|
||||||
|
if (template && template.children)
|
||||||
{
|
{
|
||||||
this.widgetContainer.loadFromJSON(this.templates[this.name]);
|
this.widgetContainer.loadFromJSON(template);
|
||||||
}
|
}
|
||||||
|
|
||||||
// List of Promises from widgets that are not quite fully loaded
|
// List of Promises from widgets that are not quite fully loaded
|
||||||
@ -544,7 +589,8 @@ etemplate2.prototype.load = function(_name, _url, _data, _callback)
|
|||||||
|
|
||||||
|
|
||||||
// Load & process
|
// Load & process
|
||||||
if(!this.templates[_name])
|
var template = this.get_template_cache(_name);
|
||||||
|
if(!template)
|
||||||
{
|
{
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
url: _url,
|
url: _url,
|
||||||
@ -556,7 +602,7 @@ etemplate2.prototype.load = function(_name, _url, _data, _callback)
|
|||||||
{
|
{
|
||||||
var template = _data.children[i];
|
var template = _data.children[i];
|
||||||
if(template.tag !== "template") continue;
|
if(template.tag !== "template") continue;
|
||||||
this.templates[template.attributes.id] = template;
|
this.set_template_cache(template.attributes.id, template);
|
||||||
if(!_name) this.name = template.attributes.id;
|
if(!_name) this.name = template.attributes.id;
|
||||||
}
|
}
|
||||||
_load.apply(this,[]);
|
_load.apply(this,[]);
|
||||||
|
Loading…
Reference in New Issue
Block a user