Fixed bug with etemplate2 not working properly especially in idots: JS files only get included if they really have not already been included; egw object gets included before 'lang' in idots

This commit is contained in:
Andreas Stöckel 2012-03-12 09:20:24 +00:00
parent 1575434535
commit 36314a077e
2 changed files with 28 additions and 25 deletions

View File

@ -27,37 +27,35 @@ egw.extend('files', egw.MODULE_WND_LOCAL, function(_app, _wnd) {
*/ */
var files = {}; var files = {};
function addFile(src)
{
if (src)
{
// Remove everything after the "?"
src = src.split('?').shift();
files[src] = true;
}
}
/** /**
* Gather all already loaded JavaScript and CSS files on document load. * Gather all already loaded JavaScript and CSS files on document load.
* *
* TODO: Currently this can only contain the JS files present in the main * TODO: Currently this can only contain the JS files present in the main
* window. * window.
*/ */
this.module('ready', _wnd).ready(function() { // Iterate over the script tags
// Iterate over the script tags var scripts = _wnd.document.getElementsByTagName('script');
var scripts = _wnd.document.getElementsByTagName('script'); for (var i = 0; i < scripts.length; i++)
for (var i = 0; i < scripts.length; i++) {
{ addFile(scripts[i].getAttribute('src'));
var src = scripts[i].getAttribute('src'); }
if (src) // Iterate over the link tags
{ var links = _wnd.document.getElementsByTagName('link');
files[src] = true; for (var i = 0; i < links.length; i++)
} {
} addFile(links[i].getAttribute('href'));
}
// Iterate over the link tags
var links = _wnd.document.getElementsByTagName('link');
for (var i = 0; i < links.length; i++)
{
var src = links[i].getAttribute('href');
if (src)
{
files[src] = true;
}
}
});
function includeJSFile(_jsFile, _callback, _context) function includeJSFile(_jsFile, _callback, _context)
{ {
@ -105,6 +103,10 @@ egw.extend('files', egw.MODULE_WND_LOCAL, function(_app, _wnd) {
// Request the given javascript file // Request the given javascript file
egw.debug('info', 'Requested JS file "%s" from server', _jsFile); egw.debug('info', 'Requested JS file "%s" from server', _jsFile);
} }
else
{
alreadyLoaded = true;
}
// If the file is already loaded, call the callback // If the file is already loaded, call the callback
if (alreadyLoaded) if (alreadyLoaded)

View File

@ -90,6 +90,8 @@ class idots_framework extends egw_framework
self::$header_done = true; self::$header_done = true;
// load translations // load translations
self::validate_file('jsapi', 'egw', 'phpgwapi');
translation::add_app('etemplate'); translation::add_app('etemplate');
foreach(translation::$loaded_apps as $app => $lang) foreach(translation::$loaded_apps as $app => $lang)
{ {
@ -99,7 +101,6 @@ class idots_framework extends egw_framework
)); ));
} }
self::validate_file('jsapi', 'egw', 'phpgwapi');
if ($this->isTop(false)) if ($this->isTop(false))
{ {
self::validate_file('.', 'etemplate2', 'etemplate'); self::validate_file('.', 'etemplate2', 'etemplate');