summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2019-11-14 13:55:53 +0100
committerSzymon Kłos <szymon.klos@collabora.com>2019-11-14 13:56:59 +0100
commitf96461558d094caf53f2215187117bfaa9170996 (patch)
tree1047b7f3c59057417f84da4c62d9264eb03252d3
parent31c5769abdedb4c703ee059fa92330a0256e6976 (diff)
jsdialog: add uno listener for checkboxes
Change-Id: I207456330503c8900524f746411e0005434beb11
-rw-r--r--loleaflet/src/control/Control.JSDialogBuilder.js52
1 files changed, 49 insertions, 3 deletions
diff --git a/loleaflet/src/control/Control.JSDialogBuilder.js b/loleaflet/src/control/Control.JSDialogBuilder.js
index af13ab70a..fca8f9f14 100644
--- a/loleaflet/src/control/Control.JSDialogBuilder.js
+++ b/loleaflet/src/control/Control.JSDialogBuilder.js
@@ -395,13 +395,35 @@ L.Control.JSDialogBuilder = L.Control.extend({
if (data.enabled == 'false')
$(checkbox).attr('disabled', 'disabled');
- if (data.checked == 'true')
- $(checkbox).attr('checked', 'checked');
-
checkbox.addEventListener('change', function() {
builder.callback('checkbox', 'change', checkbox, this.checked, builder);
});
+ var customCommand = builder._mapWindowIdToUnoCommand(data.id);
+
+ var updateFunction = function() {
+ var state = builder._getUnoStateForItemId(data.id, builder);
+
+ if (!state) {
+ var items = builder.map['stateChangeHandler'];
+ state = items.getItemValue(data.command);
+ }
+ if (!state)
+ state = data.checked;
+
+ if (state && state === 'true' || state === 1 || state === '1')
+ $(checkbox).attr('checked', 'checked');
+ else if (state)
+ $(checkbox).removeAttr('checked', 'checked');
+ }
+
+ updateFunction();
+
+ builder.map.on('commandstatechanged', function(e) {
+ if (e.commandName === customCommand ? customCommand : data.command)
+ updateFunction();
+ }, this);
+
if (data.hidden)
$(checkbox).hide();
@@ -448,6 +470,12 @@ L.Control.JSDialogBuilder = L.Control.extend({
case 'leadingzeros':
return '.uno:NumberFormat';
+ case 'negativenumbersred':
+ return '.uno:NumberFormat';
+
+ case 'thousandseparator':
+ return '.uno:NumberFormat';
+
case 'linetransparency':
return '.uno:LineTransparence';
@@ -527,6 +555,24 @@ L.Control.JSDialogBuilder = L.Control.extend({
}
break;
+ case 'negativenumbersred':
+ state = items.getItemValue('.uno:NumberFormat');
+ if (state) {
+ state = state.split(',');
+ if (state.length > 1)
+ return state[1];
+ }
+ return;
+
+ case 'thousandseparator':
+ state = items.getItemValue('.uno:NumberFormat');
+ if (state) {
+ state = state.split(',');
+ if (state.length > 0)
+ return state[0];
+ }
+ return;
+
case 'linetransparency':
state = items.getItemValue('.uno:LineTransparence');
if (state) {