loleaflet/src/control/Control.JSDialogBuilder.js    |   20 +++++--
 loleaflet/src/control/Control.NotebookbarBuilder.js |   54 +-------------------
 2 files changed, 19 insertions(+), 55 deletions(-)

New commits:
commit 0995fb5a54510a2ceb13edb2b2f8ef2221c2951e
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Thu Apr 23 12:27:39 2020 +0200
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Fri May 1 15:28:26 2020 +0200

    notebookbar: use options to modify building
    
    Change-Id: I8c6c21c4605201a5393a8f8cd0640774b62d074b
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/93265
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-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 ce7e24da7..de526eeeb 100644
--- a/loleaflet/src/control/Control.JSDialogBuilder.js
+++ b/loleaflet/src/control/Control.JSDialogBuilder.js
@@ -9,7 +9,15 @@
 L.Control.JSDialogBuilder = L.Control.extend({
 
        options: {
-               cssClass: 'mobile-wizard'
+               // reference to map
+               map: null,
+               // reference to the parent container
+               mobileWizard: null,
+               // css class name added to the html nodes
+               cssClass: 'mobile-wizard',
+
+               // create only icon without label
+               noLabelsForUnoButtons: false
        },
 
        /* Handler is a function which takes three parameters:
@@ -1505,7 +1513,7 @@ L.Control.JSDialogBuilder = L.Control.extend({
        _unoToolButton: function(parentContainer, data, builder) {
                var button = null;
 
-               var div = this._createIdentifiable('div', 'unotoolbutton ' + 
builder.cssClass + ' ui-content unospan', parentContainer, data);
+               var div = this._createIdentifiable('div', 'unotoolbutton ' + 
builder.options.cssClass + ' ui-content unospan', parentContainer, data);
 
                if (data.command) {
                        var id = data.command.substr('.uno:'.length);
@@ -1518,9 +1526,11 @@ L.Control.JSDialogBuilder = L.Control.extend({
                        button.src = icon;
                        button.id = buttonId;
 
-                       var label = L.DomUtil.create('span', 'ui-content 
unolabel', div);
-                       label.for = buttonId;
-                       label.innerHTML = data.text;
+                       if (builder.options.noLabelsForUnoButtons !== true) {
+                               var label = L.DomUtil.create('span', 
'ui-content unolabel', div);
+                               label.for = buttonId;
+                               label.innerHTML = data.text;
+                       }
 
                        var updateFunction = function() {
                                var items = builder.map['stateChangeHandler'];
diff --git a/loleaflet/src/control/Control.NotebookbarBuilder.js 
b/loleaflet/src/control/Control.NotebookbarBuilder.js
index 2a0b7b8cf..4c200ec04 100644
--- a/loleaflet/src/control/Control.NotebookbarBuilder.js
+++ b/loleaflet/src/control/Control.NotebookbarBuilder.js
@@ -6,8 +6,9 @@
 /* global $ */
 L.Control.NotebookbarBuilder = L.Control.JSDialogBuilder.extend({
 
-       onAdd: function (map) {
-               this.map = map;
+       _customizeOptions: function() {
+               this.options.noLabelsForUnoButtons = true;
+               this.options.cssClass = 'notebookbar';
        },
 
        _overrideHandlers: function() {
@@ -26,54 +27,6 @@ L.Control.NotebookbarBuilder = 
L.Control.JSDialogBuilder.extend({
                this._toolitemHandlers['.uno:ResetAttributes'] = function() {};
        },
 
-       _unoToolButton: function(parentContainer, data, builder) {
-               var button = null;
-
-               var div = this._createIdentifiable('div', 'unotoolbutton ' + 
builder.options.cssClass + ' ui-content unospan', parentContainer, data);
-
-               if (data.command) {
-                       var id = data.command.substr('.uno:'.length);
-                       div.id = id;
-
-                       var icon = builder._createIconPath(data.command);
-                       var buttonId = id + 'img';
-
-                       button = L.DomUtil.create('img', 'ui-content 
unobutton', div);
-                       button.src = icon;
-                       button.id = buttonId;
-
-                       var updateFunction = function() {
-                               var items = builder.map['stateChangeHandler'];
-                               var state = items.getItemValue(data.command);
-
-                               if (state && state === 'true')
-                                       $(button).addClass('selected');
-                               else
-                                       $(button).removeClass('selected');
-                       };
-
-                       updateFunction();
-
-                       builder.map.on('commandstatechanged', function(e) {
-                               if (e.commandName === data.command)
-                                       updateFunction();
-                       }, this);
-
-               } else {
-                       button = L.DomUtil.create('label', 'ui-content 
unolabel', div);
-                       button.innerHTML = builder._cleanText(data.text);
-               }
-
-               $(div).click(function () {
-                       builder.callback('toolbutton', 'click', button, 
data.command, builder);
-               });
-
-               if (data.enabled == 'false')
-                       $(button).attr('disabled', 'disabled');
-
-               return false;
-       },
-
        build: function(parent, data, hasVerticalParent, parentHasManyChildren) 
{
                this._amendJSDialogData(data);
 
@@ -149,5 +102,6 @@ L.control.notebookbarBuilder = function (options) {
        var builder = new L.Control.NotebookbarBuilder(options);
        builder._setup(options);
        builder._overrideHandlers();
+       builder._customizeOptions();
        return builder;
 };
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to