From 1e7b17203f4ad342ecbd3d25bd7d5e952a4afff6 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 31 Aug 2011 06:26:05 +0000 Subject: [PATCH] - if image not found, check if it might contain extension and try without (better is not to use extension at all!) - changed default to current app as in API, but it is not yet working, because egw object runs in framework for jdots :-( --- phpgwapi/js/jsapi/egw.js | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/phpgwapi/js/jsapi/egw.js b/phpgwapi/js/jsapi/egw.js index 6d379f71bd..486ccbb651 100644 --- a/phpgwapi/js/jsapi/egw.js +++ b/phpgwapi/js/jsapi/egw.js @@ -329,12 +329,12 @@ else * Get image URL for a given image-name and application * * @param string _name image-name without extension - * @param string _app application name, default phpgwapi + * @param string _app application name, default current app of window * @return string with URL of image */ image: function (_name, _app) { - if (typeof _app == 'undefined') _app = 'phpgwapi'; + if (typeof _app == 'undefined') _app = this.getAppName(); // own instance specific images in vfs have highest precedence if (typeof this.images['vfs'] != 'undefined' && typeof this.images['vfs'][_name] != 'undefined') @@ -349,8 +349,30 @@ else { return this.webserverUrl+this.images['vfs'][_name]; } + // if no match, check if it might contain an extension + if (_name.match(/\.(png|gif|jpg)$/i)) + { + return this.image(_name.replace(/.(png|gif|jpg)$/i,''), _app); + } console.log('egw.image("'+_name+'", "'+_app+'") image NOT found!'); return null; + }, + + /** + * Returns the name of the currently active application + * + * @ToDo: fixme: does not work, as egw object runs in framework for jdots + */ + getAppName: function () + { + if (typeof egw_appName == 'undefined') + { + return 'egroupware'; + } + else + { + return egw_appName; + } } }; }