[Libreoffice-commits] online.git: loleaflet/src
Michael Meeks (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jan 9 22:31:36 UTC 2020
loleaflet/src/control/Control.JSDialogBuilder.js | 12 +--
loleaflet/src/control/Control.MobileWizard.js | 81 +++++++++--------------
2 files changed, 40 insertions(+), 53 deletions(-)
New commits:
commit 7c29eb06ea2b8dad91a7836be3c387565658ad45
Author: Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Thu Jan 9 14:56:43 2020 +0000
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Thu Jan 9 23:31:18 2020 +0100
panel/wizard: adapt to new simpler 'deck' and 'panel' hierarchy.
Avoid lots of indirection and complexity based on the new,
simplified sidebar JSON hierarchy from the core.
Change-Id: I73d5c6af30d40e9a430e0f3df3b78b620f425e39
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/86510
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
Tested-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 b704ddfdf..d4f58b470 100644
--- a/loleaflet/src/control/Control.JSDialogBuilder.js
+++ b/loleaflet/src/control/Control.JSDialogBuilder.js
@@ -1518,16 +1518,14 @@ L.Control.JSDialogBuilder = L.Control.extend({
var childObject = needsToCreateContainer ? L.DomUtil.createWithId('div', childData.id, parent) : parent;
var handler = this._controlHandlers[childType];
- var twoPanelsAsChildren = childData.children
- && (childData.children.length == 4 || childData.children.length == 5)
- && childData.children[0] && childData.children[0].type == 'panel'
- && childData.children[2] && childData.children[2].type == 'panel';
+ var twoPanelsAsChildren =
+ childData.children && childData.children.length == 2
+ && childData.children[0] && childData.children[0].type == 'panel'
+ && childData.children[1] && childData.children[1].type == 'panel';
if (twoPanelsAsChildren) {
- var tabsData = [childData.children[0], childData.children[2]];
-
handler = this._controlHandlers['paneltabs'];
- processChildren = handler(childObject, tabsData, this);
+ processChildren = handler(childObject, childData.children, this);
} else {
if (handler)
processChildren = handler(childObject, childData, this);
diff --git a/loleaflet/src/control/Control.MobileWizard.js b/loleaflet/src/control/Control.MobileWizard.js
index d8145c05a..f07da4911 100644
--- a/loleaflet/src/control/Control.MobileWizard.js
+++ b/loleaflet/src/control/Control.MobileWizard.js
@@ -248,9 +248,8 @@ L.Control.MobileWizard = L.Control.extend({
_onMobileWizard: function(data) {
if (data) {
- var isSidebar = data.id !== 'insert' && data.id !== 'menubar'
- && data.id !== 'insertshape' && data.id !== 'funclist'
- && data.executionType !== 'menu';
+ var isSidebar = (data.children && data.children.length >= 1 &&
+ data.children[0].type == 'deck');
if (!this._isActive && isSidebar) {
if (this.map.showSidebar == false)
@@ -271,10 +270,9 @@ L.Control.MobileWizard = L.Control.extend({
this._showWizard();
this._hideKeyboard();
- // We can change the sidebar as we want here
- if (data.id === '') { // sidebar indicator
+ // Morph the sidebar into something prettier
+ if (isSidebar)
this._modifySidebarLayout(data);
- }
L.control.jsDialogBuilder({mobileWizard: this, map: this.map}).build(this.content.get(0), [data]);
@@ -309,53 +307,44 @@ L.Control.MobileWizard = L.Control.extend({
},
_modifySidebarLayout: function (data) {
- this._mergeStylesAndTextPropertyPanels(data);
- this._removeItems(data, ['editcontour']);
- },
-
- _mergeStylesAndTextPropertyPanels: function (data) {
- var stylesChildren = this._removeStylesPanelAndGetContent(data);
- if (stylesChildren !== null) {
- this._addChildrenToTextPanel(data, stylesChildren);
- }
- },
-
- _removeStylesPanelAndGetContent: function (data) {
- if (data.children) {
- for (var i = 0; i < data.children.length; i++) {
- if (data.children[i].type === 'panel' && data.children[i].children &&
- data.children[i].children.length > 0 && data.children[i].children[0].id === 'SidebarStylesPanel') {
- var ret = data.children[i].children[0].children;
- data.children.splice(i, 2);
- return ret;
- }
-
- var childReturn = this._removeStylesPanelAndGetContent(data.children[i]);
- if (childReturn !== null) {
- return childReturn;
- }
+ var deck = this._findItemByTypeRecursive(data, 'deck');
+ if (deck)
+ {
+ // merge styles into text-panel for elegance
+ var stylesIdx = this._findIdxInParentById(deck, 'SidebarStylesPanel');
+ var textIdx = this._findIdxInParentById(deck, 'SidebarTextPanel');
+ if (stylesIdx >= 0 && textIdx >= 0)
+ {
+ var moveContent = deck.children[stylesIdx].children;
+ deck.children.splice(stylesIdx, 1); // remove
+ textIdx = this._findIdxInParentById(deck, 'SidebarTextPanel'); // re-lookup
+ deck.children[textIdx].children = moveContent.concat(deck.children[textIdx].children);
}
}
- return null;
+
+ this._removeItems(data, ['editcontour']);
},
- _addChildrenToTextPanel: function (data, children) {
- if (data.id === 'SidebarTextPanel' && data.children && data.children.length > 0 &&
- data.children[0].children && data.children[0].children.length > 0) {
- data.children[0].children = children.concat(data.children[0].children);
- data.children[0].children[0].id = 'box42';
- return 'success';
+ _findItemByTypeRecursive: function(data, t) {
+ var found = null;
+ if (data.type === t)
+ return data;
+ if (data.children)
+ {
+ for (var i = 0; !found && i < data.children.length; i++)
+ found = this._findItemByTypeRecursive(data.children[i], t);
}
+ return found;
+ },
- if (data.children) {
- for (var i = 0; i < data.children.length; i++) {
- var childReturn = this._addChildrenToTextPanel(data.children[i], children);
- if (childReturn !== null) {
- return childReturn;
- }
- }
+ _findIdxInParentById: function(data, id) {
+ if (data.children)
+ {
+ for (var i = 0; i < data.children.length; i++)
+ if (data.children[i].id === id)
+ return i;
}
- return null;
+ return -1;
},
_removeItems: function (data, items) {
More information about the Libreoffice-commits
mailing list