From b7582fa9a08c55b66ae9585e09af185298ded9b7 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Mon, 26 Feb 2018 17:52:40 +0100 Subject: [PATCH] Add hover_action for detached description widget --- .../et2_extension_nextmatch_rowProvider.js | 2 +- api/js/etemplate/et2_widget_description.js | 45 ++++++++++++++++++- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/api/js/etemplate/et2_extension_nextmatch_rowProvider.js b/api/js/etemplate/et2_extension_nextmatch_rowProvider.js index f054254464..b09c354966 100644 --- a/api/js/etemplate/et2_extension_nextmatch_rowProvider.js +++ b/api/js/etemplate/et2_extension_nextmatch_rowProvider.js @@ -164,7 +164,7 @@ var et2_nextmatch_rowProvider = (function(){ "use strict"; return ClassWithAttri entry.widget.transformAttributes.call(entry.widget,data); // Call the setDetachedAttributes function - entry.widget.setDetachedAttributes(nodes, data); + entry.widget.setDetachedAttributes(nodes, data, _data); } // Insert the row into the tr diff --git a/api/js/etemplate/et2_widget_description.js b/api/js/etemplate/et2_widget_description.js index b12534b110..36d26f537b 100644 --- a/api/js/etemplate/et2_widget_description.js +++ b/api/js/etemplate/et2_widget_description.js @@ -93,7 +93,14 @@ var et2_description = (function(){ "use strict"; return expose(et2_baseWidget.ex type: "string", default: '', 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", @@ -300,7 +307,7 @@ var et2_description = (function(){ "use strict"; return expose(et2_baseWidget.ex return [this.span[0]]; }, - setDetachedAttributes: function(_nodes, _values) + setDetachedAttributes: function(_nodes, _values, _data) { // Update the properties var updateLink = false; @@ -320,6 +327,42 @@ var et2_description = (function(){ "use strict"; return expose(et2_baseWidget.ex { _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('') + .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); et2_register_widget(et2_description, ["description", "label"]);