Update select widget to support style.* attributes

This commit is contained in:
Jeremy Ruston
2023-11-13 09:47:18 +00:00
parent 980022a6e7
commit 65b3b18e1f
3 changed files with 20 additions and 16 deletions
+1 -1
View File
@@ -169,7 +169,7 @@ SelectWidget.prototype.execute = function() {
if(this.selectTooltip) {
$tw.utils.addAttributeToParseTreeNode(selectNode,"title",this.selectTooltip);
}
this.updateParseTreeDataAttributes(selectNode);
this.assignAttributesToParseTreeNode(selectNode);
this.makeChildWidgets([selectNode]);
};
+15 -14
View File
@@ -458,6 +458,21 @@ Widget.prototype.assignAttributes = function(domNode,options) {
});
};
/*
Set the data- and style. attributes of a parse tree node according to the attributes of the widget
domNode: optional domNode to be assigned
*/
Widget.prototype.assignAttributesToParseTreeNode = function(parseTreeNode) {
var self = this;
var DATA_ATTRIBUTE_PREFIX = "data-",
STYLE_ATTRIBUTE_PREFIX = "style.";
$tw.utils.each(this.attributes,function(value,name) {
if(name.substr(0,DATA_ATTRIBUTE_PREFIX.length) === DATA_ATTRIBUTE_PREFIX || name.substr(0,STYLE_ATTRIBUTE_PREFIX.length) === STYLE_ATTRIBUTE_PREFIX) {
$tw.utils.addAttributeToParseTreeNode(parseTreeNode,name,value);
}
});
};
/*
Get the number of ancestor widgets for this widget
*/
@@ -813,20 +828,6 @@ Widget.evaluateVariable = function(widget,name,options) {
return result;
};
/*
Set the data- attributes of a parse tree node according to the attributes of the widget
domNode: optional domNode to be assigned
*/
Widget.prototype.updateParseTreeDataAttributes = function(parseTreeNode) {
var self = this;
var DATA_ATTRIBUTE_PREFIX = "data-";
$tw.utils.each(this.attributes,function(value,name) {
if(name.substr(0,DATA_ATTRIBUTE_PREFIX.length) === DATA_ATTRIBUTE_PREFIX) {
$tw.utils.addAttributeToParseTreeNode(parseTreeNode,name,value);
}
});
};
exports.widget = Widget;
})();