[Libreoffice-commits] online.git: Branch 'feature/jsdialogs' - 3 commits - loleaflet/src
Szymon Kłos (via logerrit)
logerrit at kemper.freedesktop.org
Wed Sep 25 09:59:12 UTC 2019
loleaflet/src/control/Control.JSDialogBuilder.js | 58 +++++++++++++++++++++--
1 file changed, 54 insertions(+), 4 deletions(-)
New commits:
commit afbfaeada35d0b596a23d4d9d33edeb44c20b4f2
Author: Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Wed Sep 25 11:57:34 2019 +0200
Commit: Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Wed Sep 25 11:57:34 2019 +0200
jsdialogs: add toolitems, color item support
Change-Id: I3391196eeb3cf94e31e4ae5f2bae15ad70f5470c
diff --git a/loleaflet/src/control/Control.JSDialogBuilder.js b/loleaflet/src/control/Control.JSDialogBuilder.js
index 2d86683de..3bc5c84ea 100644
--- a/loleaflet/src/control/Control.JSDialogBuilder.js
+++ b/loleaflet/src/control/Control.JSDialogBuilder.js
@@ -4,7 +4,7 @@
* from the JSON description provided by the server.
*/
-/* global $ */
+/* global $ w2ui */
L.Control.JSDialogBuilder = L.Control.extend({
/* Handler is a function which takes three parameters:
@@ -16,6 +16,7 @@ L.Control.JSDialogBuilder = L.Control.extend({
* and false otherwise
*/
_controlHandlers: {},
+ _toolitemHandlers: {},
_currentDepth: 0,
@@ -35,10 +36,28 @@ L.Control.JSDialogBuilder = L.Control.extend({
this._controlHandlers['borderwindow'] = this._containerHandler;
this._controlHandlers['control'] = this._containerHandler;
this._controlHandlers['scrollbar'] = this._ignoreHandler;
- this._controlHandlers['toolbox'] = this._ignoreHandler;
+ this._controlHandlers['toolbox'] = this._containerHandler;
+ this._controlHandlers['toolitem'] = this._toolitemHandler;
+
+ this._toolitemHandlers['.uno:SelectWidth'] = this._ignoreHandler;
+ this._toolitemHandlers['.uno:XLineColor'] = this._colorControl;
+
this._currentDepth = 0;
},
+ _toolitemHandler: function(parentContainer, data, builder) {
+ if (data.command) {
+ var handler = builder._toolitemHandlers[data.command];
+
+ if (handler)
+ handler(parentContainer, data, this);
+ else
+ console.warn('Unsupported toolitem type: \"' + data.command + '\"');
+ }
+
+ return false;
+ },
+
_cleanText: function(text) {
return text.replace('~', '');
},
@@ -182,6 +201,24 @@ L.Control.JSDialogBuilder = L.Control.extend({
return false;
},
+ _colorControl: function(parentContainer, data) {
+ var colorContainer = L.DomUtil.create('div', '', parentContainer);
+
+ if (data.enabled == 'false')
+ $(colorContainer).attr('disabled', 'disabled');
+
+ var toolbar = $(colorContainer);
+ var items = [{type: 'color', id: 'color'}];
+ toolbar.w2toolbar({
+ name: 'colorselector',
+ tooltip: 'bottom',
+ items: items
+ });
+ w2ui['colorselector'].set('color', {color: '#ff0033'});
+
+ return false;
+ },
+
build: function(parent, data, currentIsContainer, currentIsVertival, columns) {
var currentInsertPlace = parent;
var currentHorizontalRow = parent;
commit c0a915f77b7f9dcbdb94028de2a7291286ee49c4
Author: Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Wed Sep 25 10:42:01 2019 +0200
Commit: Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Wed Sep 25 10:42:01 2019 +0200
jsdialogs: set spinfield value
Change-Id: I4ae47734b0667b7aa32e63b6cdfafa6e6355cebd
diff --git a/loleaflet/src/control/Control.JSDialogBuilder.js b/loleaflet/src/control/Control.JSDialogBuilder.js
index c5e498a1d..2d86683de 100644
--- a/loleaflet/src/control/Control.JSDialogBuilder.js
+++ b/loleaflet/src/control/Control.JSDialogBuilder.js
@@ -116,14 +116,18 @@ L.Control.JSDialogBuilder = L.Control.extend({
return false;
},
- _spinfieldControl: function(parentContainer, data, builder) {
+ _spinfieldControl: function(parentContainer, data) {
var spinfield = L.DomUtil.create('input', '', parentContainer);
spinfield.type = 'number';
- spinfield.value = builder._cleanText(data.text);
if (data.enabled == 'false')
$(spinfield).attr('disabled', 'disabled');
+ if (data.children && data.children.length) {
+ // TODO: units
+ $(spinfield).attr('value', data.children[0].text.replace('%', ''));
+ }
+
return false;
},
commit b05ac95a63a302fa3e70393127ec8d33d12ea2eb
Author: Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Wed Sep 25 10:27:15 2019 +0200
Commit: Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Wed Sep 25 10:27:15 2019 +0200
jsdialog: current selection in listbox
Change-Id: I652b196787dc9323c09681c4b4101b9474633c80
diff --git a/loleaflet/src/control/Control.JSDialogBuilder.js b/loleaflet/src/control/Control.JSDialogBuilder.js
index 66931a071..c5e498a1d 100644
--- a/loleaflet/src/control/Control.JSDialogBuilder.js
+++ b/loleaflet/src/control/Control.JSDialogBuilder.js
@@ -154,9 +154,18 @@ L.Control.JSDialogBuilder = L.Control.extend({
if (data.enabled == 'false')
$(listbox).attr('disabled', 'disabled');
+ var selected = null;
+ if (parseInt(data.selectedCount) > 0) {
+ // TODO: multiselection listbox
+ selected = data.selectedEntries[0];
+ }
+
for (var index in data.entries) {
var option = L.DomUtil.create('option', '', listbox);
option.innerHTML = data.entries[index];
+
+ if (selected == index)
+ $(option).attr('selected', 'selected');
}
return false;
More information about the Libreoffice-commits
mailing list