new attribute type "html", which is NOT run through (tags removing) html_entity_decode, used for value in et2_html(area)

This commit is contained in:
Ralf Becker 2014-02-14 10:14:28 +00:00
parent e60294fdf4
commit bd7980f0e8
3 changed files with 22 additions and 7 deletions

View File

@ -30,7 +30,7 @@ if (typeof Array.prototype.indexOf == "undefined")
/** /**
* Array with all types supported by the et2_checkType function. * 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 * 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 = { var et2_typeDefaults = {
"boolean": false, "boolean": false,
"string": "", "string": "",
"html": "",
"js": null, "js": null,
"float": 0.0, "float": 0.0,
"integer": 0, "integer": 0,
@ -152,11 +153,11 @@ function et2_checkType(_val, _type, _attr, _widget)
} }
// Check whether the given value is of the type "string" // Check whether the given value is of the type "string"
if (_type == "string") if (_type == "string" || _type == "html")
{ {
if (typeof _val == "string") if (typeof _val == "string")
{ {
return html_entity_decode(_val); return _type == "html" ? _val : html_entity_decode(_val);
} }
// Handle some less common possibilities // Handle some less common possibilities

View File

@ -21,7 +21,7 @@
/** /**
* @augments et2_valueWidget * @augments et2_valueWidget
*/ */
var et2_html = et2_valueWidget.extend([et2_IDetachedDOM], var et2_html = et2_valueWidget.extend([et2_IDetachedDOM],
{ {
attributes: { attributes: {
'label': { 'label': {
@ -30,16 +30,22 @@ var et2_html = et2_valueWidget.extend([et2_IDetachedDOM],
ignore: false, ignore: false,
name: "Label", name: "Label",
translate: true, translate: true,
type: "string", type: "string"
}, },
"needed": { "needed": {
"ignore": true "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 * Constructor
* *
* @memberOf et2_html * @memberOf et2_html
*/ */
init: function() { init: function() {
@ -84,6 +90,8 @@ var et2_html = et2_valueWidget.extend([et2_IDetachedDOM],
/** /**
* Code for implementing et2_IDetachedDOM * Code for implementing et2_IDetachedDOM
*
* @param {array} _attrs
*/ */
getDetachedAttributes: function(_attrs) getDetachedAttributes: function(_attrs)
{ {

View File

@ -65,6 +65,12 @@ var et2_htmlarea = et2_inputWidget.extend(
'description': 'Internal configuration - managed by preferences & framework, passed in here', 'description': 'Internal configuration - managed by preferences & framework, passed in here',
'translate': 'no_lang' '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'], legacyOptions: ['mode','height','width','expand_toolbar','base_href'],