diff --git a/etemplate/js/et2_core_widget.js b/etemplate/js/et2_core_widget.js index ca234899e6..0c71403186 100644 --- a/etemplate/js/et2_core_widget.js +++ b/etemplate/js/et2_core_widget.js @@ -785,7 +785,9 @@ var et2_widget = Class.extend({ this._template_application = this.getParent().getTemplateApp(); return this._template_application; } - return "phpgwapi"; + app = egw.getAppName() == 'egroupware' ? 'phpgwapi' : egw.getAppName(); + //console.warn("Unable to find template application, using %s", app); + return app; } }); diff --git a/etemplate/js/et2_widget_button.js b/etemplate/js/et2_widget_button.js index 7682693e56..4d8c5f97fd 100644 --- a/etemplate/js/et2_widget_button.js +++ b/etemplate/js/et2_widget_button.js @@ -59,6 +59,7 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM], { set_image: function(_image) { if(!this.isInTree()) return; + this.options.image = _image; var found_image = false; @@ -69,13 +70,16 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM], { this.image = et2_createWidget("image",{label: this.options.label}); } found_image = this.image.set_src(this.options.image); + if(found_image) { + // No label if there's an image + this.set_label(""); + this.btn.removeClass("et2_button_text").addClass("et2_button_icon"); + } jQuery(this.image.getDOMNode()).appendTo(this.btn); } - if(found_image) + if(!found_image) { - // No label if there's an image - this.options.label = ""; - this.btn.removeClass("et2_button_text").addClass("et2_button_icon"); + this.set_label(this.options.label); } }, diff --git a/etemplate/js/et2_widget_image.js b/etemplate/js/et2_widget_image.js index b64e720f9e..5e01849a88 100644 --- a/etemplate/js/et2_widget_image.js +++ b/etemplate/js/et2_widget_image.js @@ -112,7 +112,7 @@ var et2_image = et2_baseWidget.extend(et2_IDetachedDOM, { set_src: function(_value) { if(!this.isInTree()) { - return; + return false; } this.options.src = _value; diff --git a/phpgwapi/js/jsapi/egw.js b/phpgwapi/js/jsapi/egw.js index 81c31d32c0..4675c94882 100644 --- a/phpgwapi/js/jsapi/egw.js +++ b/phpgwapi/js/jsapi/egw.js @@ -415,27 +415,47 @@ else */ image: function (_name, _app) { - if (typeof _app == 'undefined') _app = this.getAppName(); + // For logging all paths tried + var tries = {}; + + if (typeof _app == 'undefined') + { + if(_name.indexOf('/') > 0) + { + var split = et2_csvSplit(_value, 2,"/"); + var _app = split[0]; + _name = split[1]; + } + else + { + _app = this.getAppName(); + } + } // own instance specific images in vfs have highest precedence + tries['vfs']=_name; if (typeof this.images['vfs'] != 'undefined' && typeof this.images['vfs'][_name] != 'undefined') { return this.webserverUrl+this.images['vfs'][_name]; } + tries[_app + (_app == 'phpgwapi' ? " (current app)" : "")] = _name; if (typeof this.images[_app] != 'undefined' && typeof this.images[_app][_name] != 'undefined') { return this.webserverUrl+this.images[_app][_name]; } + tries['phpgwapi'] = _name; if (typeof this.images['phpgwapi'] != 'undefined' && typeof this.images['phpgwapi'][_name] != 'undefined') { - return this.webserverUrl+this.images['vfs'][_name]; + return this.webserverUrl+this.images['phpgwapi'][_name]; } // if no match, check if it might contain an extension - if (_name.match(/\.(png|gif|jpg)$/i)) + var matches = []; + if (matches = _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!'); + if(matches != null) tries[_app + " (matched)"]= matches; + console.log('egw.image("'+_name+'", "'+_app+'") image NOT found! Tried ', tries); return null; },