diff --git a/etemplate/inc/class.xul_io.inc.php b/etemplate/inc/class.xul_io.inc.php
index f905d8a16c..9370a2e09c 100644
--- a/etemplate/inc/class.xul_io.inc.php
+++ b/etemplate/inc/class.xul_io.inc.php
@@ -91,7 +91,12 @@ class xul_io
),
'image' => array(
'.name' => 'image',
- 'name' => 'src'
+ 'name' => 'src',
+ 'size' => 'href,extra_link_target,imagemap,extra_link_popup,id',
+ ),
+ 'progres' => array(
+ '.name' => 'progress',
+ 'size' => 'href,extra_link_target,,extra_link_popup',
),
'tab' => array(
'.name' => 'tabbox,tabs,tabpanels'
diff --git a/etemplate/js/et2_widget_description.js b/etemplate/js/et2_widget_description.js
index 807cf318a9..47dd48f38f 100644
--- a/etemplate/js/et2_widget_description.js
+++ b/etemplate/js/et2_widget_description.js
@@ -65,7 +65,7 @@ var et2_description = et2_baseWidget.extend([et2_IDetachedDOM], {
"extra_link_popup": {
"name": "Popup",
"type": "string",
- "description": "???"
+ "description": "widthxheight, if popup should be used, eg. 640x480"
},
"extra_link_title": {
"name": "Link Title",
diff --git a/etemplate/js/et2_widget_image.js b/etemplate/js/et2_widget_image.js
index 736e54681b..2063f1695c 100644
--- a/etemplate/js/et2_widget_image.js
+++ b/etemplate/js/et2_widget_image.js
@@ -29,27 +29,41 @@ var et2_image = et2_baseWidget.extend(et2_IDetachedDOM, {
"type": "string",
"description": "Displayed image"
},
- "link": {
+ "href": {
+ "name": "Link Target",
+ "type": "string",
+ "description": "Link URL, empty if you don't wan't to display a link."
},
- "link_target":{
+ "extra_link_target": {
+ "name": "Link target",
+ "type": "string",
+ "default": "_self",
+ "description": "Link target descriptor"
+ },
+ "extra_link_popup": {
+ "name": "Popup",
+ "type": "string",
+ "description": "widthxheight, if popup should be used, eg. 640x480"
},
"imagemap":{
},
- "link_size":{
+ "label": {
}
},
-
- legacyOptions: ["link", "link_target", "imagemap", "link_size"],
+ legacyOptions: ["href", "link_target", "imagemap", "extra_link_popup", "id"],
init: function() {
this._super.apply(this, arguments);
// Create the image or a/image tag
var node = this.image = $j(document.createElement("img"));
- if(this.options.link)
+ if (this.options.label)
{
- this._node = $j(document.createElement("a"));
- this.image.appendTo(node);
+ this.image.attr("alt", this.options.label).attr("title", this.options.label);
+ }
+ if (this.options.href)
+ {
+ this.image.addClass('et2_clickable');
}
if(this.options["class"])
{
@@ -57,6 +71,14 @@ var et2_image = et2_baseWidget.extend(et2_IDetachedDOM, {
}
this.setDOMNode(node[0]);
},
+
+ click: function()
+ {
+ if(this.options.href)
+ {
+ egw.call_link(this.options.href, this.options.extra_link_target, this.options.extra_link_popup);
+ }
+ },
transformAttributes: function(_attrs) {
this._super.apply(arguments);
@@ -76,8 +98,7 @@ var et2_image = et2_baseWidget.extend(et2_IDetachedDOM, {
if(_value == this.options.label) return;
this.options.label = _value;
// label is NOT the alt attribute in eTemplate, but the title/tooltip
- this.image.attr("alt", _value);
- this.set_statustext(_value);
+ this.image.attr("alt", _value).attr("title", _value);
},
setValue: function(_value) {
@@ -85,8 +106,6 @@ var et2_image = et2_baseWidget.extend(et2_IDetachedDOM, {
this.set_src(_value);
},
- percentagePreg: /^[0-9]+%$/,
-
set_src: function(_value) {
if(!this.isInTree())
{
@@ -101,6 +120,11 @@ var et2_image = et2_baseWidget.extend(et2_IDetachedDOM, {
{
this.image.attr("src", src).show();
}
+ // allow url's too
+ else if (_value[0] == '/' || _value.substr(0,4) == 'http')
+ {
+ this.image.attr('src', _value).show();
+ }
else
{
this.image.css("display","none");
diff --git a/etemplate/js/test/et2_test_basic_widgets.xet b/etemplate/js/test/et2_test_basic_widgets.xet
index c2d7ccd1aa..b020347a83 100644
--- a/etemplate/js/test/et2_test_basic_widgets.xet
+++ b/etemplate/js/test/et2_test_basic_widgets.xet
@@ -31,5 +31,8 @@
+
+
+
diff --git a/etemplate/js/test/test.css b/etemplate/js/test/test.css
index 55fb4223dc..48bbc379de 100644
--- a/etemplate/js/test/test.css
+++ b/etemplate/js/test/test.css
@@ -454,4 +454,6 @@ label input, label span, label div, label select, label textarea {
background-image: url(gfx/down.png);
}
-
+.et2_clickable {
+ cursor: pointer;
+}
\ No newline at end of file
diff --git a/phpgwapi/js/jsapi/egw.js b/phpgwapi/js/jsapi/egw.js
index b7d2642136..d82344cb9e 100644
--- a/phpgwapi/js/jsapi/egw.js
+++ b/phpgwapi/js/jsapi/egw.js
@@ -500,6 +500,46 @@ else
{
return typeof _name == 'undefined' || typeof this.userData.apps[_app] == 'undefined' ?
this.userData.apps[_app] : this.userData.apps[_app][_name];
+ },
+
+ /**
+ * Call a link, which can be either a menuaction, a EGroupware relative url or a full url
+ *
+ * @param string _link menuaction, EGroupware relative url or a full url (incl. "mailto:" or "javascript:")
+ * @param string _target optional target
+ * @param string _popup widthxheight, if a popup should be used
+ */
+ call_link: function(_link, _target, _popup)
+ {
+ var url = _link;
+ if (url.indexOf('javascript:') == 0)
+ {
+ eval(url.substr(11));
+ return;
+ }
+ // link is not necessary an url, it can also be a menuaction!
+ if (url.indexOf('/') == -1 &&
+ url.split('.').length >= 3 &&
+ url.indexOf('mailto:') == -1 ||
+ url.indexOf('://') == -1)
+ {
+ url = "/index.php?menuaction="+url;
+ }
+ if (url[0] == '/') // link relative to eGW
+ {
+ url = egw.webserverUrl + url;
+ }
+ if (_popup)
+ {
+ var w_h = _popup.split('x');
+ if (w_h[1] == 'egw_getWindowOuterHeight()') w_h[1] = egw_getWindowOuterHeight();
+ egw_openWindowCentered2(url, _target, w_h[0], w_h[1]);
+ }
+ else
+ {
+ window.open(url, _target);
+ }
+
}
};
}