Add set_href function to image widget,which wraps the image with <a> tag and binds a click handler to it

This commit is contained in:
Hadi Nategh 2014-01-17 15:58:58 +00:00
parent 2d4dd6d5d6
commit bb07598beb

View File

@ -130,6 +130,29 @@ var et2_image = et2_baseWidget.extend([et2_IDetachedDOM],
this.set_src(_value);
},
set_href: function (_value)
{
if (!this.isInTree())
{
return false;
}
this.options.href = _value;
this.image.wrapAll('<a href="'+_value+'"></a>"');
var href = this.options.href;
var popup = this.options.extra_link_popup;
var target = this.options.extra_link_target;
this.image.parent().click(function(e)
{
egw.open_link(href,target,popup);
e.preventDefault();
return false;
});
return true;
},
set_src: function(_value) {
if(!this.isInTree())
{
@ -186,6 +209,7 @@ var et2_image = et2_baseWidget.extend([et2_IDetachedDOM],
if(_values["href"])
{
this.image.addClass('et2_clickable');
this.set_href(_values["href"]);
}
}
});