- Pull application name from template ID for image

- Use label as tooltip
- Apply CSS classes to image
This commit is contained in:
Nathan Gray 2011-08-31 16:00:45 +00:00
parent c5c90fbce0
commit 0dea78ab2e
3 changed files with 42 additions and 3 deletions

View File

@ -745,6 +745,26 @@ var et2_widget = Class.extend({
return this._parent.getInstanceManager();
}
return null;
},
/**
* Returns the application for the template the widget is in.
* If a sub-template is used, this may be different from the current app.
*/
getTemplateApp: function() {
if(this._template_application)
{
return this._template_application;
}
else if(this._type == 'template' && this.id)
{
var parts = this.id.split(".",2);
return parts[0];
} else if (this.getParent()) {
this._template_application = this.getParent().getTemplateApp();
return this._template_application;
}
return null;
}
});

View File

@ -50,6 +50,10 @@ var et2_image = et2_baseWidget.extend({
this.node = $j(document.createElement("a"));
this.image.appendTo(this.node);
}
if(this.options.class)
{
this.node.addClass(this.options.class);
}
this.setDOMNode(this.node[0]);
},
@ -58,12 +62,27 @@ var et2_image = et2_baseWidget.extend({
this.options.label = _value;
// label is NOT the alt attribute in eTemplate, but the title/tooltip
this.image.attr("alt", _value);
this.image.set_statustext(_value);
},
set_src: function(_value) {
if(!this.isInTree())
{
console.warn(this.image[0], " not in tree");
return;
}
this.options.src = _value;
// using current app (default) is not exactly right, it should be the app of the template, eg. "addressbook" for "addressbook.edit"
this.image.attr("src", egw.image(_value, egw_appName) || _value);
// Get application to use from template ID
var appname = this.getTemplateApp();
var src = egw.image(_value,appname || "phpgwapi");
if(src )
{
this.image.attr("src", src).show();
}
else
{
this.image.css("display","none");
}
}
});

View File

@ -12,7 +12,7 @@
<radio label="Radio" id="radio_value"/>
<buttononly label="Button" id="button_value"/>
<hrule label="HR"/>
<image label="Image" src="phpgwapi/templates/default/images/edit.png"/>
<image label="Image" src="edit"/>
<menulist>
<menupopup label="Selectbox" id="selectbox_value" options="No value">
<option value="1">Test 1</option>