forked from extern/egroupware
Get all button images working (in timesheet & infolog list at least)
This commit is contained in:
parent
df1d9e81b2
commit
390bb1f6f0
@ -785,7 +785,9 @@ var et2_widget = Class.extend({
|
|||||||
this._template_application = this.getParent().getTemplateApp();
|
this._template_application = this.getParent().getTemplateApp();
|
||||||
return this._template_application;
|
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;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -59,6 +59,7 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM], {
|
|||||||
|
|
||||||
set_image: function(_image) {
|
set_image: function(_image) {
|
||||||
if(!this.isInTree()) return;
|
if(!this.isInTree()) return;
|
||||||
|
|
||||||
this.options.image = _image;
|
this.options.image = _image;
|
||||||
|
|
||||||
var found_image = false;
|
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});
|
this.image = et2_createWidget("image",{label: this.options.label});
|
||||||
}
|
}
|
||||||
found_image = this.image.set_src(this.options.image);
|
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);
|
jQuery(this.image.getDOMNode()).appendTo(this.btn);
|
||||||
}
|
}
|
||||||
if(found_image)
|
if(!found_image)
|
||||||
{
|
{
|
||||||
// No label if there's an image
|
this.set_label(this.options.label);
|
||||||
this.options.label = "";
|
|
||||||
this.btn.removeClass("et2_button_text").addClass("et2_button_icon");
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ var et2_image = et2_baseWidget.extend(et2_IDetachedDOM, {
|
|||||||
set_src: function(_value) {
|
set_src: function(_value) {
|
||||||
if(!this.isInTree())
|
if(!this.isInTree())
|
||||||
{
|
{
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.options.src = _value;
|
this.options.src = _value;
|
||||||
|
@ -415,27 +415,47 @@ else
|
|||||||
*/
|
*/
|
||||||
image: function (_name, _app)
|
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
|
// own instance specific images in vfs have highest precedence
|
||||||
|
tries['vfs']=_name;
|
||||||
if (typeof this.images['vfs'] != 'undefined' && typeof this.images['vfs'][_name] != 'undefined')
|
if (typeof this.images['vfs'] != 'undefined' && typeof this.images['vfs'][_name] != 'undefined')
|
||||||
{
|
{
|
||||||
return this.webserverUrl+this.images['vfs'][_name];
|
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')
|
if (typeof this.images[_app] != 'undefined' && typeof this.images[_app][_name] != 'undefined')
|
||||||
{
|
{
|
||||||
return this.webserverUrl+this.images[_app][_name];
|
return this.webserverUrl+this.images[_app][_name];
|
||||||
}
|
}
|
||||||
|
tries['phpgwapi'] = _name;
|
||||||
if (typeof this.images['phpgwapi'] != 'undefined' && typeof this.images['phpgwapi'][_name] != 'undefined')
|
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 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);
|
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;
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user