forked from extern/egroupware
share loaded eTemplates with iframes and popups, this way they dont need to load templates in same EGroupware session again (unless main window get reloaded), also adding now a cache-buster by default, if server dont supply one
This commit is contained in:
parent
d56b92af8b
commit
cf61d38137
@ -88,7 +88,7 @@ var et2_template = et2_DOMWidget.extend(
|
||||
|
||||
// Check to see if XML is known
|
||||
var xml = null;
|
||||
var templates = etemplate2.prototype.templates || this.getRoot().getInstanceManager().templates;
|
||||
var templates = etemplate2.prototype.templates; // use global eTemplate cache
|
||||
if(!(xml = templates[template_name]))
|
||||
{
|
||||
// Check to see if ID is short form --> prepend parent/top-level name
|
||||
@ -105,12 +105,13 @@ var et2_template = et2_DOMWidget.extend(
|
||||
var splitted = template_name.split('.');
|
||||
// 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 + splitted.shift() + "/templates/default/" +
|
||||
splitted.join('.')+ ".xet" + (cache_buster ? '?'+cache_buster : '');
|
||||
splitted.join('.')+ ".xet" + (cache_buster ? '?'+cache_buster :
|
||||
// if server did not give a cache-buster, fall back to current time
|
||||
'?download='+(new Date).valueOf());
|
||||
|
||||
if(splitted.length)
|
||||
{
|
||||
et2_loadXMLFromURL(path, function(_xmldoc) {
|
||||
var templates = this.getInstanceManager().templates || {};
|
||||
// Scan for templates and store them
|
||||
for(var i = 0; i < _xmldoc.childNodes.length; i++) {
|
||||
var template = _xmldoc.childNodes[i];
|
||||
|
@ -100,11 +100,26 @@ function etemplate2(_container, _menuaction)
|
||||
}
|
||||
|
||||
// List of templates (XML) that are known, not always used. Indexed by id.
|
||||
etemplate2.prototype.templates = {};
|
||||
// We share list of templates with iframes and popups
|
||||
try {
|
||||
if (opener && opener.etemplate2)
|
||||
{
|
||||
etemplate2.prototype.templates = opener.etemplate2.prototype.templates;
|
||||
}
|
||||
}
|
||||
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 || {};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calls the resize event of all widgets
|
||||
*
|
||||
* @param {jQuery.event} e
|
||||
*/
|
||||
etemplate2.prototype.resize = function(e)
|
||||
{
|
||||
@ -180,19 +195,6 @@ etemplate2.prototype.clear = function()
|
||||
this.widgetContainer = null;
|
||||
}
|
||||
$j(this.DOMContainer).empty();
|
||||
|
||||
// Remove self from the index
|
||||
for(name in this.templates)
|
||||
{
|
||||
if(typeof etemplate2._byTemplate[name] == "undefined") continue;
|
||||
for(var i = 0; i < etemplate2._byTemplate[name].length; i++)
|
||||
{
|
||||
if(etemplate2._byTemplate[name][i] == this)
|
||||
{
|
||||
etemplate2._byTemplate[name].splice(i,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user