From f96461558d094caf53f2215187117bfaa9170996 Mon Sep 17 00:00:00 2001 From: Szymon Kłos Date: Thu, 14 Nov 2019 13:55:53 +0100 Subject: jsdialog: add uno listener for checkboxes Change-Id: I207456330503c8900524f746411e0005434beb11 --- loleaflet/src/control/Control.JSDialogBuilder.js | 52 ++++++++++++++++++++++-- 1 file 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) { -- cgit v1.2.3