From bd7980f0e8fceaed8cb76737ab72bc3898a2c4db Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 14 Feb 2014 10:14:28 +0000 Subject: [PATCH] new attribute type "html", which is NOT run through (tags removing) html_entity_decode, used for value in et2_html(area) --- etemplate/js/et2_core_common.js | 7 ++++--- etemplate/js/et2_widget_html.js | 16 ++++++++++++---- etemplate/js/et2_widget_htmlarea.js | 6 ++++++ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/etemplate/js/et2_core_common.js b/etemplate/js/et2_core_common.js index c0c001513d..346016272f 100644 --- a/etemplate/js/et2_core_common.js +++ b/etemplate/js/et2_core_common.js @@ -30,7 +30,7 @@ if (typeof Array.prototype.indexOf == "undefined") /** * Array with all types supported by the et2_checkType function. */ -var et2_validTypes = ["boolean", "string", "float", "integer", "any", "js", "dimension"]; +var et2_validTypes = ["boolean", "string", "html", "float", "integer", "any", "js", "dimension"]; /** * Object whith default values for the above types. Do not specify array or @@ -40,6 +40,7 @@ var et2_validTypes = ["boolean", "string", "float", "integer", "any", "js", "dim var et2_typeDefaults = { "boolean": false, "string": "", + "html": "", "js": null, "float": 0.0, "integer": 0, @@ -152,11 +153,11 @@ function et2_checkType(_val, _type, _attr, _widget) } // Check whether the given value is of the type "string" - if (_type == "string") + if (_type == "string" || _type == "html") { if (typeof _val == "string") { - return html_entity_decode(_val); + return _type == "html" ? _val : html_entity_decode(_val); } // Handle some less common possibilities diff --git a/etemplate/js/et2_widget_html.js b/etemplate/js/et2_widget_html.js index 19015946c4..f85550e3a7 100644 --- a/etemplate/js/et2_widget_html.js +++ b/etemplate/js/et2_widget_html.js @@ -21,7 +21,7 @@ /** * @augments et2_valueWidget */ -var et2_html = et2_valueWidget.extend([et2_IDetachedDOM], +var et2_html = et2_valueWidget.extend([et2_IDetachedDOM], { attributes: { 'label': { @@ -30,16 +30,22 @@ var et2_html = et2_valueWidget.extend([et2_IDetachedDOM], ignore: false, name: "Label", translate: true, - type: "string", + type: "string" }, "needed": { "ignore": true + }, + value: { + name: "Value", + description: "The value of the widget", + type: "html", // "string" would remove html tags by running html_entity_decode + default: et2_no_init } }, - + /** * Constructor - * + * * @memberOf et2_html */ init: function() { @@ -84,6 +90,8 @@ var et2_html = et2_valueWidget.extend([et2_IDetachedDOM], /** * Code for implementing et2_IDetachedDOM + * + * @param {array} _attrs */ getDetachedAttributes: function(_attrs) { diff --git a/etemplate/js/et2_widget_htmlarea.js b/etemplate/js/et2_widget_htmlarea.js index 9465bcc2cd..46a9362358 100644 --- a/etemplate/js/et2_widget_htmlarea.js +++ b/etemplate/js/et2_widget_htmlarea.js @@ -65,6 +65,12 @@ var et2_htmlarea = et2_inputWidget.extend( 'description': 'Internal configuration - managed by preferences & framework, passed in here', 'translate': 'no_lang' }, + value: { + name: "Value", + description: "The value of the widget", + type: "html", // "string" would remove html tags by running html_entity_decode + default: et2_no_init + } }, legacyOptions: ['mode','height','width','expand_toolbar','base_href'],