loleaflet/src/control/Control.JSDialogBuilder.js |   49 +++++++++++++++++++++--
 1 file changed, 45 insertions(+), 4 deletions(-)

New commits:
commit 0a25b8f555a31774bff89321ac0ae2d7fd829318
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Wed Sep 25 11:57:34 2019 +0200
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Fri Sep 27 17:04:47 2019 +0200

    jsdialogs: add toolitems, color item support
    
    Change-Id: I3391196eeb3cf94e31e4ae5f2bae15ad70f5470c
    Reviewed-on: https://gerrit.libreoffice.org/79734
    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 2d86683de..3bc5c84ea 100644
--- a/loleaflet/src/control/Control.JSDialogBuilder.js
+++ b/loleaflet/src/control/Control.JSDialogBuilder.js
@@ -4,7 +4,7 @@
  * from the JSON description provided by the server.
  */
 
-/* global $ */
+/* global $ w2ui */
 L.Control.JSDialogBuilder = L.Control.extend({
 
        /* Handler is a function which takes three parameters:
@@ -16,6 +16,7 @@ L.Control.JSDialogBuilder = L.Control.extend({
         * and false otherwise
         */
        _controlHandlers: {},
+       _toolitemHandlers: {},
 
        _currentDepth: 0,
 
@@ -35,10 +36,28 @@ L.Control.JSDialogBuilder = L.Control.extend({
                this._controlHandlers['borderwindow'] = this._containerHandler;
                this._controlHandlers['control'] = this._containerHandler;
                this._controlHandlers['scrollbar'] = this._ignoreHandler;
-               this._controlHandlers['toolbox'] = this._ignoreHandler;
+               this._controlHandlers['toolbox'] = this._containerHandler;
+               this._controlHandlers['toolitem'] = this._toolitemHandler;
+
+               this._toolitemHandlers['.uno:SelectWidth'] = 
this._ignoreHandler;
+               this._toolitemHandlers['.uno:XLineColor'] = this._colorControl;
+
                this._currentDepth = 0;
        },
 
+       _toolitemHandler: function(parentContainer, data, builder) {
+               if (data.command) {
+                       var handler = builder._toolitemHandlers[data.command];
+
+                       if (handler)
+                               handler(parentContainer, data, this);
+                       else
+                               console.warn('Unsupported toolitem type: \"' + 
data.command + '\"');
+               }
+
+               return false;
+       },
+
        _cleanText: function(text) {
                return text.replace('~', '');
        },
@@ -182,6 +201,24 @@ L.Control.JSDialogBuilder = L.Control.extend({
                return false;
        },
 
+       _colorControl: function(parentContainer, data) {
+               var colorContainer = L.DomUtil.create('div', '', 
parentContainer);
+
+               if (data.enabled == 'false')
+                       $(colorContainer).attr('disabled', 'disabled');
+
+               var toolbar = $(colorContainer);
+               var items = [{type: 'color',  id: 'color'}];
+               toolbar.w2toolbar({
+                       name: 'colorselector',
+                       tooltip: 'bottom',
+                       items: items
+               });
+               w2ui['colorselector'].set('color', {color: '#ff0033'});
+
+               return false;
+       },
+
        build: function(parent, data, currentIsContainer, currentIsVertival, 
columns) {
                var currentInsertPlace = parent;
                var currentHorizontalRow = parent;
commit c32bd0441d8b842a5c458757e5a97d0c45e8161b
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Wed Sep 25 10:42:01 2019 +0200
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Fri Sep 27 17:04:36 2019 +0200

    jsdialogs: set spinfield value
    
    Change-Id: I4ae47734b0667b7aa32e63b6cdfafa6e6355cebd
    Reviewed-on: https://gerrit.libreoffice.org/79733
    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 c5e498a1d..2d86683de 100644
--- a/loleaflet/src/control/Control.JSDialogBuilder.js
+++ b/loleaflet/src/control/Control.JSDialogBuilder.js
@@ -116,14 +116,18 @@ L.Control.JSDialogBuilder = L.Control.extend({
                return false;
        },
 
-       _spinfieldControl: function(parentContainer, data, builder) {
+       _spinfieldControl: function(parentContainer, data) {
                var spinfield = L.DomUtil.create('input', '', parentContainer);
                spinfield.type = 'number';
-               spinfield.value = builder._cleanText(data.text);
 
                if (data.enabled == 'false')
                        $(spinfield).attr('disabled', 'disabled');
 
+               if (data.children && data.children.length) {
+                       // TODO: units
+                       $(spinfield).attr('value', 
data.children[0].text.replace('%', ''));
+               }
+
                return false;
        },
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to