Skip to content
This repository has been archived by the owner on Mar 14, 2020. It is now read-only.

Commit

Permalink
[Widgets] Add displayName attribute to widget HTML properties
Browse files Browse the repository at this point in the history
In js/widgets.js there are some widget properties have displayName
attribute, it use for custom the label, but it is not functional.

See List.divider, OrderedList.divider, Collapsible.content_theme
and Accordion.content_theme in js/widgets.js.

The patch implemented the BWdiget.getPropertyDisplayName() to
make the attribute work.
  • Loading branch information
Xuqing Kuang authored and sbryan committed Jun 15, 2012
1 parent 39bbd9c commit 9f6b362
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/js/adm.js
Original file line number Diff line number Diff line change
Expand Up @@ -1901,6 +1901,17 @@ ADMNode.prototype.getPropertyDefault = function (property) {
return BWidget.getPropertyDefault(this.getType(), property);
};

/**
* Gets the display name for the named property for this widget type.
*
* @param {String} property The name of the requested property.
* @return {String} The display name of the property, or the property instance
* name if the property has no the attribute.
*/
ADMNode.prototype.getPropertyDisplayName = function (property) {
return BWidget.getPropertyDisplayName(this.getType(), property);
};

/**
* Returns whether the property is explicitly set or not. Properties that are
* explicitly set should be serialized to disk.
Expand Down
2 changes: 1 addition & 1 deletion src/js/views/property.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
options = node.getPropertyOptions();
// iterate property of node
for (p in props) {
labelVal = p.replace(/_/g,'-');
labelVal = node.getPropertyDisplayName(p);
valueId = p+'-value';
valueVal = props[p];
propType = BWidget.getPropertyType(type, p);
Expand Down
17 changes: 17 additions & 0 deletions src/js/widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -2147,6 +2147,23 @@ var BWidget = {
return schema;
},

/**
* Gets the display name for a given instance property.
*
* @param {String} widgetType The type of the widget.
* @param {String} property The name of the requested property.
* @return {String} The display name for the given property, or
* the property instance name if this property has
* no the attribute.
*/
getPropertyDisplayName: function (widgetType, property) {
var schema = BWidget.getPropertySchema(widgetType, property);
if (schema && schema.displayName) {
return schema.displayName;
}
return property.replace(/_/g,'-');
},

/**
* Gets the HTML attribute associated with this property.
*
Expand Down

0 comments on commit 9f6b362

Please sign in to comment.