[Libreoffice-commits] online.git: loleaflet/src
Michael Meeks (via logerrit)
logerrit at kemper.freedesktop.org
Mon Feb 3 21:57:32 UTC 2020
loleaflet/src/control/Control.JSDialogBuilder.js | 32 ++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
New commits:
commit d7eaf756e8728b507b07e39c08051b446651d8cd
Author: Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Mon Feb 3 17:32:06 2020 +0100
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Mon Feb 3 22:57:14 2020 +0100
add class to unotoolbar buttons from parent id.
Necessary to add 'parent' member to parsed JSON structures to
allow walking up the hierarchy easily while building.
Change-Id: I52da1ba415e07bb7fef60a1c667e8c46cb0d640a
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/87902
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
diff --git a/loleaflet/src/control/Control.JSDialogBuilder.js b/loleaflet/src/control/Control.JSDialogBuilder.js
index 027934cb5..04a1abb0d 100644
--- a/loleaflet/src/control/Control.JSDialogBuilder.js
+++ b/loleaflet/src/control/Control.JSDialogBuilder.js
@@ -1177,10 +1177,27 @@ L.Control.JSDialogBuilder = L.Control.extend({
return 'images/lc_' + cleanName.toLowerCase() + '.svg';
},
+ // make a class identifier from parent's id by walking up the tree
+ _getParentId : function(it) {
+ while (it.parent && !it.id)
+ it = it.parent;
+ if (it && it.id)
+ return '-' + it.id;
+ else
+ return '';
+ },
+
+ // Create a DOM node with an identifiable parent class
+ _createIdentifiable : function(type, classNames, parentContainer, data) {
+ return L.DomUtil.create(
+ type, classNames + this._getParentId(data),
+ parentContainer);
+ },
+
_unoToolButton: function(parentContainer, data, builder) {
var button = null;
- var div = L.DomUtil.create('div', 'ui-content unospan', parentContainer);
+ var div = this._createIdentifiable('div', 'ui-content unospan', parentContainer, data);
if (data.command) {
var id = data.command.substr('.uno:'.length);
@@ -1530,9 +1547,22 @@ L.Control.JSDialogBuilder = L.Control.extend({
builder._explorableMenu(parentContainer, title, data.children, builder, content, data.id);
},
+ // link each node to its parent, should do one recursive descent
+ _parentize: function(data, parent) {
+ if (data.parent)
+ return;
+ if (data.children !== undefined) {
+ for (var idx in data.children) {
+ this._parentize(data.children[idx], data);
+ }
+ }
+ data.parent = parent;
+ },
+
build: function(parent, data) {
for (var childIndex in data) {
var childData = data[childIndex];
+ this._parentize(childData);
var childType = childData.type;
var processChildren = true;
var needsToCreateContainer =
More information about the Libreoffice-commits
mailing list