From 34a382be2b667f1470e8b951a7cd3b6586f5331d Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 12 May 2014 21:49:48 +0000 Subject: [PATCH] Implement detached labels --- etemplate/js/et2_widget_link.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/etemplate/js/et2_widget_link.js b/etemplate/js/et2_widget_link.js index 5e20411b66..9c0bd257e5 100644 --- a/etemplate/js/et2_widget_link.js +++ b/etemplate/js/et2_widget_link.js @@ -1317,7 +1317,7 @@ var et2_link_string = et2_valueWidget.extend([et2_IDetachedDOM], * @param {Array} _attrs an array of attributes */ getDetachedAttributes: function(_attrs) { - _attrs.push("value"); + _attrs.push("label", "value"); }, /** @@ -1325,7 +1325,7 @@ var et2_link_string = et2_valueWidget.extend([et2_IDetachedDOM], * passed to the "setDetachedAttributes" function in the same order. */ getDetachedNodes: function() { - return [this.list[0]]; + return [this.list[0], this._labelContainer[0]]; }, /** @@ -1340,7 +1340,18 @@ var et2_link_string = et2_valueWidget.extend([et2_IDetachedDOM], */ setDetachedAttributes: function(_nodes, _values) { this.list = $j(_nodes[0]); + this.set_value(_values["value"]); + + // Special detached, to prevent DOM node modification of the normal method + this._labelContainer = $j(_nodes[1]) || null; + if(_values['label']) + { + this.set_label(_values['label']); + } + else { + this._labelContainer.contents().not(this.list).remove(); + } } }); et2_register_widget(et2_link_string, ["link-string"]);