From 39325533bb6a147878ab8a44211af9c08df9e9ac Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 18 Oct 2011 16:04:47 +0000 Subject: [PATCH] Implement detached interface for read only, used by custom fields --- etemplate/js/et2_widget_textbox.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/etemplate/js/et2_widget_textbox.js b/etemplate/js/et2_widget_textbox.js index e148c3f87c..d06a4e5313 100644 --- a/etemplate/js/et2_widget_textbox.js +++ b/etemplate/js/et2_widget_textbox.js @@ -138,7 +138,7 @@ et2_register_widget(et2_textbox, ["textbox"]); /** * et2_textbox_ro is the dummy readonly implementation of the textbox. */ -var et2_textbox_ro = et2_valueWidget.extend({ +var et2_textbox_ro = et2_valueWidget.extend([et2_IDetachedDOM], { /** * Ignore all more advanced attributes. @@ -164,8 +164,28 @@ var et2_textbox_ro = et2_valueWidget.extend({ if(!_value) _value = ""; this.span.text(_value); - } + }, + /** + * Code for implementing et2_IDetachedDOM + */ + getDetachedAttributes: function(_attrs) + { + _attrs.push("value"); + }, + getDetachedNodes: function() + { + return [this.span[0]]; + }, + + setDetachedAttributes: function(_nodes, _values) + { + this.span = jQuery(_nodes[0]); + if(typeof _values["value"] != 'undefined') + { + this.set_value(_values["value"]); + } + } }); et2_register_widget(et2_textbox_ro, ["textbox_ro", "int_ro", "float_ro"]);