[Libreoffice-commits] online.git: 2 commits - loleaflet/src
Szymon Kłos (via logerrit)
logerrit at kemper.freedesktop.org
Fri Sep 27 15:05:16 UTC 2019
loleaflet/src/control/Control.JSDialogBuilder.js | 77 ++++++++++++++++++++---
loleaflet/src/control/Control.MobileWizard.js | 1
2 files changed, 71 insertions(+), 7 deletions(-)
New commits:
commit ea71d18825df0422fdd7c7d40839f19dc0e070bd
Author: Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Wed Sep 25 16:28:57 2019 +0200
Commit: Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Fri Sep 27 17:05:06 2019 +0200
jsdialogs: better grid handling
Change-Id: I497325cb31a9d88a734eebba0046fbffb0505f25
Reviewed-on: https://gerrit.libreoffice.org/79736
Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
Tested-by: Szymon Kłos <szymon.klos at collabora.com>
diff --git a/loleaflet/src/control/Control.JSDialogBuilder.js b/loleaflet/src/control/Control.JSDialogBuilder.js
index 3bc5c84ea..164f1aaaa 100644
--- a/loleaflet/src/control/Control.JSDialogBuilder.js
+++ b/loleaflet/src/control/Control.JSDialogBuilder.js
@@ -29,6 +29,7 @@ L.Control.JSDialogBuilder = L.Control.extend({
this._controlHandlers['combobox'] = this._comboboxControl;
this._controlHandlers['listbox'] = this._comboboxControl;
this._controlHandlers['fixedtext'] = this._fixedtextControl;
+ this._controlHandlers['grid'] = this._gridHandler;
this._controlHandlers['frame'] = this._frameHandler;
this._controlHandlers['panel'] = this._panelHandler;
this._controlHandlers['container'] = this._containerHandler;
@@ -70,6 +71,66 @@ L.Control.JSDialogBuilder = L.Control.extend({
return false;
},
+ _getGridColumns: function(children) {
+ var columns = 0;
+ for (var index in children) {
+ if (parseInt(children[index].left) > columns)
+ columns = parseInt(children[index].left);
+ }
+ return columns + 1;
+ },
+
+ _getGridRows: function(children) {
+ var rows = 0;
+ for (var index in children) {
+ if (parseInt(children[index].top) > rows)
+ rows = parseInt(children[index].top);
+ }
+ return rows + 1;
+ },
+
+ _getGridChild: function(children, row, col) {
+ for (var index in children) {
+ if (parseInt(children[index].top) == row
+ && parseInt(children[index].left) == col)
+ return children[index];
+ }
+ return null;
+ },
+
+ _gridHandler: function(parentContainer, data, builder) {
+ var columns = builder._getGridColumns(data.children);
+ var rows = builder._getGridRows(data.children);
+ var index = 0;
+
+ var table = L.DomUtil.create('table', '', parentContainer);
+ for (var row = 0; row < rows; row++) {
+ var tr = L.DomUtil.create('tr', '', table);
+ for (var col = 0; col < columns; col++) {
+ var td = L.DomUtil.create('td', '', tr);
+ var child = builder._getGridChild(data.children, row, col);
+
+ if (child) {
+ var childObject = null;
+ if (child.type == 'container')
+ childObject = L.DomUtil.create('table', '', td);
+ else
+ childObject = td;
+
+ builder.build(childObject, [child], data.type);
+ index++;
+ }
+
+ if (index > data.children.length) {
+ console.warn('index > data.children.length');
+ return false;
+ }
+ }
+ }
+
+ return false;
+ },
+
_explorableEntry: function(parentContainer, title, contentNode, builder) {
var sectionTitle = L.DomUtil.create('div', 'ui-header level-' + builder._currentDepth + ' mobile-wizard ui-widget', parentContainer);
sectionTitle.innerHTML = title;
@@ -171,6 +232,9 @@ L.Control.JSDialogBuilder = L.Control.extend({
},
_comboboxControl: function(parentContainer, data, builder) {
+ if (!data.entries || data.entries.length == 0)
+ return false;
+
var listbox = L.DomUtil.create('select', '', parentContainer);
listbox.value = builder._cleanText(data.text);
@@ -219,9 +283,10 @@ L.Control.JSDialogBuilder = L.Control.extend({
return false;
},
- build: function(parent, data, currentIsContainer, currentIsVertival, columns) {
+ build: function(parent, data, currentType, currentIsVertival) {
var currentInsertPlace = parent;
var currentHorizontalRow = parent;
+ var currentIsContainer = currentType == 'container';
if (currentIsContainer && !currentIsVertival)
currentHorizontalRow = L.DomUtil.create('tr', '', parent);
@@ -232,18 +297,16 @@ L.Control.JSDialogBuilder = L.Control.extend({
var processChildren = true;
if (currentIsContainer) {
- var horizontalOverflow = (childIndex > 0 && columns && (childIndex % columns == 0));
- var newRow = currentIsVertival || horizontalOverflow;
- if (newRow) {
+ if (currentIsVertival) {
currentHorizontalRow = L.DomUtil.create('tr', '', parent);
currentInsertPlace = L.DomUtil.create('td', '', currentHorizontalRow);
} else
currentInsertPlace = L.DomUtil.create('td', '', currentHorizontalRow);
}
- var childIsContainer = (childType == 'container' || childType == 'borderwindow') && childData.children.length > 1;
+ var childIsContainer = (childType == 'container' || childType == 'borderwindow')
+ && childData.children.length > 1;
var childIsVertical = childData.vertical == 'true';
- var childColumns = childData.cols;
var childObject = null;
if (childIsContainer && childType != 'borderwindow')
@@ -259,7 +322,7 @@ L.Control.JSDialogBuilder = L.Control.extend({
console.warn('Unsupported control type: \"' + childType + '\"');
if (processChildren && childData.children != undefined)
- this.build(childObject, childData.children, childIsContainer, childIsVertical, childColumns);
+ this.build(childObject, childData.children, childType, childIsVertical);
}
}
});
commit 08f065733ee1b4391698c1ef5fa3d5598a917952
Author: Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Wed Sep 25 13:42:05 2019 +0200
Commit: Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Fri Sep 27 17:04:57 2019 +0200
jsdialogs: set current depth to 0 on reset
Change-Id: I8e445d8b22e5f6eec7683588b70599c55c61ed8e
Reviewed-on: https://gerrit.libreoffice.org/79735
Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
Tested-by: Szymon Kłos <szymon.klos at collabora.com>
diff --git a/loleaflet/src/control/Control.MobileWizard.js b/loleaflet/src/control/Control.MobileWizard.js
index dfbea872d..0a1498e67 100644
--- a/loleaflet/src/control/Control.MobileWizard.js
+++ b/loleaflet/src/control/Control.MobileWizard.js
@@ -56,6 +56,7 @@ L.Control.MobileWizard = L.Control.extend({
_onMobileWizard: function(data) {
if (data) {
this._isActive = true;
+ this._currentDepth = 0;
this._showWizard();
this._hideKeyboard();
More information about the Libreoffice-commits
mailing list