loleaflet/src/control/Control.JSDialogBuilder.js |   50 ++++++++++++++++++-----
 1 file changed, 41 insertions(+), 9 deletions(-)

New commits:
commit 83bda09b91b7ec2358e086de66768e2e45dd0b38
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Thu Nov 7 16:08:42 2019 +0100
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Thu Nov 7 16:08:53 2019 +0100

    jsdialogs: send .uno:LineWidth to the core
    
    Change-Id: Ib09c4b8b5f5d22b66330ad96ec917646ff2189e2

diff --git a/loleaflet/src/control/Control.JSDialogBuilder.js 
b/loleaflet/src/control/Control.JSDialogBuilder.js
index e50138b84..b7c9cb9a6 100644
--- a/loleaflet/src/control/Control.JSDialogBuilder.js
+++ b/loleaflet/src/control/Control.JSDialogBuilder.js
@@ -787,15 +787,47 @@ L.Control.JSDialogBuilder = L.Control.extend({
        },
 
        _lineWidthControl: function(parentContainer, data, builder) {
-               data.children = [ { text: '0.5' },
-                                                       { text: '0.8' },
-                                                       { text: '1.0' },
-                                                       { text: '1.5' },
-                                                       { text: '2.3' },
-                                                       { text: '3.0' },
-                                                       { text: '4.5' },
-                                                       { text: '6.0' } ];
-               builder._spinfieldControl(parentContainer, data, builder);
+               var values = [ 0.0,
+                       0.5,
+                       0.8,
+                       1.0,
+                       1.5,
+                       2.3,
+                       3.0,
+                       4.5,
+                       6.0 ];
+
+               var lineData = { min: 0.5, max: 5, id: 'linewidth', text: '0.5' 
};
+
+               var callbackFunction = function(objectType, eventType, object) {
+                       var newValue = 0;
+                       if (eventType == 'plus') {
+                               $(object).find('input').val(function(i, oldVal) 
{
+                                       var index = 1;
+                                       newValue = values[0];
+                                       while (newValue <= oldVal && index < 
values.length)
+                                               newValue = values[index++];
+                                       return newValue;
+                               });
+                       } else if (eventType == 'minus') {
+                               $(object).find('input').val(function(i, oldVal) 
{
+                                       if (oldVal > 0.0)
+                                       {
+                                               var index = values.length - 1;
+                                               newValue = values[index];
+                                               while (newValue >= oldVal && 
index > 0)
+                                                       newValue = 
values[index--];
+                                       }
+                                       else
+                                               newValue = 0.0;
+                                       return newValue;
+                               });
+                       }
+                       var command = '.uno:LineWidth?Width:double=' + 
newValue.toFixed(1);
+                       builder.map.sendUnoCommand(command);
+               };
+
+               builder._spinfieldControl(parentContainer, lineData, builder, 
callbackFunction);
        },
 
        _subMenuHandler: function(parentContainer, data, builder) {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to