mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-12 19:14:10 +01:00
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
d100187584
commit
48fa4c1857
@ -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];
|
||||
|
@ -101,25 +101,40 @@ 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)
|
||||
{
|
||||
var event = e;
|
||||
var self = this;
|
||||
var excess_height = false;
|
||||
|
||||
|
||||
// Check if the framework has an specific excess height calculation
|
||||
if (typeof window.framework != 'undefined' && typeof window.framework.get_wExcessHeight != 'undefined')
|
||||
{
|
||||
excess_height = window.framework.get_wExcessHeight(window);
|
||||
}
|
||||
|
||||
//@TODO implement getaccess height for other framework and remove
|
||||
|
||||
//@TODO implement getaccess height for other framework and remove
|
||||
if (typeof event != 'undefined' && event.type == 'resize')
|
||||
{
|
||||
setTimeout(function(){
|
||||
@ -181,19 +196,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -449,7 +451,7 @@ etemplate2.prototype.load = function(_name, _url, _data, _callback)
|
||||
// Wait for everything to be loaded, then finish it up
|
||||
jQuery.when.apply(jQuery, deferred).done(jQuery.proxy(function() {
|
||||
egw.debug("log", "Finished loading %s, triggering load event", _name);
|
||||
|
||||
|
||||
if (typeof window.framework != 'undefined' && typeof window.framework.et2_loadingFinished != 'undefined')
|
||||
{
|
||||
//Call loading finished method of the framework with local window
|
||||
@ -470,7 +472,7 @@ etemplate2.prototype.load = function(_name, _url, _data, _callback)
|
||||
return !$this.attr('tabindex') || $this.attr('tabIndex')>=0;
|
||||
}).first().focus();
|
||||
};
|
||||
|
||||
|
||||
// Tell others about it
|
||||
if(typeof _callback == "function")
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user