Add hover_action for detached description widget

This commit is contained in:
Hadi Nategh 2018-02-26 17:52:40 +01:00
parent 69f91de4a7
commit b7582fa9a0
2 changed files with 45 additions and 2 deletions

View File

@ -164,7 +164,7 @@ var et2_nextmatch_rowProvider = (function(){ "use strict"; return ClassWithAttri
entry.widget.transformAttributes.call(entry.widget,data); entry.widget.transformAttributes.call(entry.widget,data);
// Call the setDetachedAttributes function // Call the setDetachedAttributes function
entry.widget.setDetachedAttributes(nodes, data); entry.widget.setDetachedAttributes(nodes, data, _data);
} }
// Insert the row into the tr // Insert the row into the tr

View File

@ -93,7 +93,14 @@ var et2_description = (function(){ "use strict"; return expose(et2_baseWidget.ex
type: "string", type: "string",
default: '', default: '',
description: "hash for data stored on service-side with egw_link::(get|set)_data()" description: "hash for data stored on service-side with egw_link::(get|set)_data()"
},
hover_action: {
"name": "hover action",
"type": "js",
"default": et2_no_init,
"description": "JS code which is executed when clicking on action button. This action is explicitly for attached nodes, like in nm."
} }
}, },
legacyOptions: ["font_style", "href", "activate_links", "for", legacyOptions: ["font_style", "href", "activate_links", "for",
@ -300,7 +307,7 @@ var et2_description = (function(){ "use strict"; return expose(et2_baseWidget.ex
return [this.span[0]]; return [this.span[0]];
}, },
setDetachedAttributes: function(_nodes, _values) setDetachedAttributes: function(_nodes, _values, _data)
{ {
// Update the properties // Update the properties
var updateLink = false; var updateLink = false;
@ -320,6 +327,42 @@ var et2_description = (function(){ "use strict"; return expose(et2_baseWidget.ex
{ {
_nodes[0].setAttribute("class", _values["class"]); _nodes[0].setAttribute("class", _values["class"]);
} }
// Add hover action button (Edit)
if (this.options.hover_action)
{
var content = _data.content;
var widget = this;
this.span.on('mouseenter', jQuery.proxy(function(event) {
event.stopImmediatePropagation();
var self = this;
this.span.tooltip({
items: 'span.et2_label',
position: {my:"right top", at:"left top", collision:"flipfit"},
tooltipClass: "et2_email_popup",
content: function()
{
return jQuery('<a href="#" class= "et2_url_email_contactPlus" title="'+egw.lang('Edit')+'"><img src="'
+egw.image("edit") +'"/></a>')
.on('click', function() {
widget.options.hover_action.call(self, self.widget, content);
});
},
close: function( event, ui )
{
ui.tooltip.hover(
function () {
jQuery(this).stop(true).fadeTo(400, 1);
},
function () {
jQuery(this).fadeOut("400", function(){ jQuery(this).remove();});
}
);
}
})
.tooltip("open");
}, {widget: this, span: this.span}));
}
} }
}));}).call(this); }));}).call(this);
et2_register_widget(et2_description, ["description", "label"]); et2_register_widget(et2_description, ["description", "label"]);