loleaflet/src/control/Control.JSDialogBuilder.js | 27 ++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-)
New commits: commit e29e4c6531b25187664e13757e937550df2a511d Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Wed Oct 2 13:52:04 2019 +0200 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Wed Oct 2 14:13:56 2019 +0200 jsdialog: add change listener for controls Change-Id: Iaee867baee86addf03b027d40e61bb4393b4d0c9 Reviewed-on: https://gerrit.libreoffice.org/80031 Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Tested-by: Szymon Kłos <szymon.k...@collabora.com> diff --git a/loleaflet/src/control/Control.JSDialogBuilder.js b/loleaflet/src/control/Control.JSDialogBuilder.js index 0fec449a4..c00b1ce59 100644 --- a/loleaflet/src/control/Control.JSDialogBuilder.js +++ b/loleaflet/src/control/Control.JSDialogBuilder.js @@ -20,7 +20,11 @@ L.Control.JSDialogBuilder = L.Control.extend({ _currentDepth: 0, - _setup: function() { + _setup: function(options) { + this.wizard = options.mobileWizard; + this.map = options.map; + this.callback = options.callback ? options.callback : this._defaultCallbackHandler; + this._controlHandlers['radiobutton'] = this._radiobuttonControl; this._controlHandlers['checkbox'] = this._checkboxControl; this._controlHandlers['spinfield'] = this._spinfieldControl; @@ -61,6 +65,16 @@ L.Control.JSDialogBuilder = L.Control.extend({ return false; }, + // by default send new state to the core + _defaultCallbackHandler: function(objectType, eventType, object, data, builder) { + console.debug('control: \'' + objectType + '\' event: \'' + eventType + '\' state: \'' + data + '\''); + + if (objectType == 'toolbutton' && eventType == 'click') { + console.log(builder); + builder.map.sendUnoCommand(data); + } + }, + _cleanText: function(text) { return text.replace('~', ''); }, @@ -200,6 +214,10 @@ L.Control.JSDialogBuilder = L.Control.extend({ if (data.checked == 'true') $(checkbox).attr('checked', 'checked'); + checkbox.addEventListener('change', function() { + builder.callback('checkbox', 'change', checkbox, this.checked, builder); + }); + return false; }, @@ -282,8 +300,9 @@ L.Control.JSDialogBuilder = L.Control.extend({ button = L.DomUtil.create('button', '', parentContainer); button.innerHTML = builder._cleanText(data.text); } + $(button).click(function () { - builder.map.sendUnoCommand(data.command); + builder.callback('toolbutton', 'click', button, data.command, builder); }); if (data.enabled == 'false') @@ -368,8 +387,6 @@ L.Control.JSDialogBuilder = L.Control.extend({ L.control.jsDialogBuilder = function (options) { var builder = new L.Control.JSDialogBuilder(options); - builder._setup(); - builder.wizard = options.mobileWizard; - builder.map = options.map; + builder._setup(options); return builder; }; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits