[Libreoffice-commits] online.git: loleaflet/src
Henry Castro (via logerrit)
logerrit at kemper.freedesktop.org
Tue Apr 28 13:06:24 UTC 2020
loleaflet/src/control/Control.JSDialogBuilder.js | 28 +++++++++++++++++++++++
1 file changed, 28 insertions(+)
New commits:
commit 4d82903a269ca2c38ebbd913d5027f2da8d9bc37
Author: Henry Castro <hcastro at collabora.com>
AuthorDate: Thu Apr 23 12:09:56 2020 -0400
Commit: Henry Castro <hcastro at collabora.com>
CommitDate: Tue Apr 28 15:06:06 2020 +0200
jsdialog: add metric field handler
Change-Id: I87212e56cdfa3c85ddfa56e8aa0f814290fa49d6
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92799
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Henry Castro <hcastro at collabora.com>
diff --git a/loleaflet/src/control/Control.JSDialogBuilder.js b/loleaflet/src/control/Control.JSDialogBuilder.js
index 96decadca..4b8138933 100644
--- a/loleaflet/src/control/Control.JSDialogBuilder.js
+++ b/loleaflet/src/control/Control.JSDialogBuilder.js
@@ -109,6 +109,7 @@ L.Control.JSDialogBuilder = L.Control.extend({
this._controlHandlers['radiobutton'] = this._radiobuttonControl;
this._controlHandlers['checkbox'] = this._checkboxControl;
this._controlHandlers['spinfield'] = this._spinfieldControl;
+ this._controlHandlers['metricfield'] = this._metricfieldControl;
this._controlHandlers['edit'] = this._editControl;
this._controlHandlers['multilineedit'] = this._multiLineEditControl;
this._controlHandlers['pushbutton'] = this._pushbuttonControl;
@@ -1172,6 +1173,33 @@ L.Control.JSDialogBuilder = L.Control.extend({
return false;
},
+ _metricfieldControl: function(parentContainer, data, builder, customCallback) {
+ var value;
+ var controls = L.Control.JSDialogBuilder.baseSpinField(parentContainer, data, builder, customCallback);
+
+ // It listens server state changes using GetControlState
+ // to avoid unit conversion
+ builder.map.on('commandstatechanged', function(e) {
+ value = e.state[data.id];
+ if (value) {
+ value = parseFloat(value);
+ $(controls.spinfield).attr('value', value);
+ }
+ }, this);
+
+ controls.spinfield.addEventListener('change', function() {
+ if (customCallback)
+ customCallback();
+ else
+ builder.callback('spinfield', 'value', controls.container, this.value, builder);
+ });
+
+ value = parseFloat(data.value);
+ $(controls.spinfield).attr('value', value);
+
+ return false;
+ },
+
_editControl: function(parentContainer, data, builder, callback) {
var edit = L.DomUtil.create('input', 'ui-edit mobile-wizard', parentContainer);
edit.value = builder._cleanText(data.text);
More information about the Libreoffice-commits
mailing list