loleaflet/src/control/Control.JSDialogBuilder.js |   61 +++++++++++++++++++----
 loleaflet/src/control/Control.Menubar.js         |    1 
 2 files changed, 53 insertions(+), 9 deletions(-)

New commits:
commit c79f95ba1d103eed49d0eff68594ba24a22632d3
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Wed Oct 16 18:18:37 2019 +0200
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Wed Oct 16 18:18:44 2019 +0200

    Add insert table sub menu
    
    Change-Id: Ic524272a1ea48f04d1e959a6d71bed210c365a80

diff --git a/loleaflet/src/control/Control.JSDialogBuilder.js 
b/loleaflet/src/control/Control.JSDialogBuilder.js
index 08ae354a9..d3a88f055 100644
--- a/loleaflet/src/control/Control.JSDialogBuilder.js
+++ b/loleaflet/src/control/Control.JSDialogBuilder.js
@@ -213,7 +213,7 @@ L.Control.JSDialogBuilder = L.Control.extend({
                }
        },
 
-       _explorableMenu: function(parentContainer, title, children, builder) {
+       _explorableMenu: function(parentContainer, title, children, builder, 
customContent) {
                var sectionTitle = L.DomUtil.create('div', 'ui-header level-' + 
builder._currentDepth + ' mobile-wizard ui-widget', parentContainer);
                $(sectionTitle).css('justify-content', 'space-between');
 
@@ -225,11 +225,15 @@ L.Control.JSDialogBuilder = L.Control.extend({
                var contentDiv = L.DomUtil.create('div', 'ui-content level-' + 
builder._currentDepth + ' mobile-wizard', parentContainer);
                contentDiv.title = title;
 
-               builder._currentDepth++;
-               for (var i = 0; i < children.length; i++) {
-                       builder.build(contentDiv, [children[i]]);
+               if (customContent) {
+                       contentDiv.appendChild(customContent);
+               } else {
+                       builder._currentDepth++;
+                       for (var i = 0; i < children.length; i++) {
+                               builder.build(contentDiv, [children[i]]);
+                       }
+                       builder._currentDepth--;
                }
-               builder._currentDepth--;
 
                $(contentDiv).hide();
                if (builder.wizard) {
@@ -380,7 +384,12 @@ L.Control.JSDialogBuilder = L.Control.extend({
                return unit;
        },
 
-       _spinfieldControl: function(parentContainer, data, builder) {
+       _spinfieldControl: function(parentContainer, data, builder, 
customCallback) {
+               if (data.label) {
+                       var fixedTextData = { text: data.label };
+                       builder._fixedtextControl(parentContainer, 
fixedTextData, builder);
+               }
+
                var div = L.DomUtil.create('div', 'spinfieldcontainer', 
parentContainer);
                div.id = data.id;
 
@@ -417,7 +426,10 @@ L.Control.JSDialogBuilder = L.Control.extend({
                        $(spinfield).attr('value', 
builder._cleanValueFromUnits(data.children[0].text));
 
                spinfield.addEventListener('change', function() {
-                       builder.callback('spinfield', 'change', spinfield, 
this.value, builder);
+                       if (customCallback)
+                               customCallback();
+                       else
+                               builder.callback('spinfield', 'change', 
spinfield, this.value, builder);
                });
 
                if (data.hidden)
@@ -444,7 +456,7 @@ L.Control.JSDialogBuilder = L.Control.extend({
                return false;
        },
 
-       _pushbuttonControl: function(parentContainer, data, builder) {
+       _pushbuttonControl: function(parentContainer, data, builder, 
customCallback) {
                var pushbutton = L.DomUtil.create('button', '', 
parentContainer);
                pushbutton.innerHTML = builder._cleanText(data.text);
                pushbutton.id = data.id;
@@ -453,7 +465,10 @@ L.Control.JSDialogBuilder = L.Control.extend({
                        $(pushbutton).attr('disabled', 'disabled');
 
                $(pushbutton).click(function () {
-                       builder.callback('pushbutton', 'click', pushbutton, 
data.command, builder);
+                       if (customCallback)
+                               customCallback();
+                       else
+                               builder.callback('pushbutton', 'click', 
pushbutton, data.command, builder);
                });
 
                if (data.hidden)
@@ -694,7 +709,18 @@ L.Control.JSDialogBuilder = L.Control.extend({
 
        _insertTableMenuItem: function(parentContainer, data, builder) {
                var title = data.text;
-               builder._explorableMenu(parentContainer, title, data.children, 
builder);
+
+               var content = L.DomUtil.create('div', 'inserttablecontrols');
+
+               var rowsData = { min: 0, id: 'rows', label: _('Rows') };
+               var colsData = { min: 0, id: 'cols', label: _('Columns') };
+               builder._spinfieldControl(content, rowsData, builder, 
function() { });
+               builder._spinfieldControl(content, colsData, builder, 
function() { });
+
+               var buttonData = { text: _('Insert table') };
+               builder._pushbuttonControl(content, buttonData, builder, 
function() { });
+
+               builder._explorableMenu(parentContainer, title, data.children, 
builder, content);
        },
 
        _fontNameControl: function(parentContainer, data, builder) {
commit 1cc2f6a10974155769b25e15e0d8863732155f59
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Wed Oct 16 13:19:17 2019 +0200
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Wed Oct 16 18:18:44 2019 +0200

    Added 'Insert table' to the insert menu
    
    Change-Id: I0cb0e1b17e5e857fd33c123d345aaa031a861efc

diff --git a/loleaflet/src/control/Control.JSDialogBuilder.js 
b/loleaflet/src/control/Control.JSDialogBuilder.js
index db4991df6..08ae354a9 100644
--- a/loleaflet/src/control/Control.JSDialogBuilder.js
+++ b/loleaflet/src/control/Control.JSDialogBuilder.js
@@ -18,6 +18,7 @@ L.Control.JSDialogBuilder = L.Control.extend({
         */
        _controlHandlers: {},
        _toolitemHandlers: {},
+       _menuItemHandlers: {},
        _colorPickers: [],
 
        _currentDepth: 0,
@@ -56,6 +57,8 @@ L.Control.JSDialogBuilder = L.Control.extend({
                this._controlHandlers['submenu'] = this._subMenuHandler;
                this._controlHandlers['menuitem'] = this._menuItemHandler;
 
+               this._menuItemHandlers['inserttable'] = 
this._insertTableMenuItem;
+
                this._toolitemHandlers['.uno:XLineColor'] = this._colorControl;
                this._toolitemHandlers['.uno:SelectWidth'] = 
this._lineWidthControl;
                this._toolitemHandlers['.uno:CharFontName'] = 
this._fontNameControl;
@@ -648,6 +651,15 @@ L.Control.JSDialogBuilder = L.Control.extend({
                        return false;
                }
 
+               var id = data.id;
+               if (id) {
+                       var handler = builder._menuItemHandlers[id];
+                       if (handler) {
+                               handler(parentContainer, data, builder);
+                               return;
+                       }
+               }
+
                var menuEntry = L.DomUtil.create('div', 'ui-header level-' + 
builder._currentDepth + ' mobile-wizard ui-widget', parentContainer);
 
                var icon = null;
@@ -680,6 +692,11 @@ L.Control.JSDialogBuilder = L.Control.extend({
                return false;
        },
 
+       _insertTableMenuItem: function(parentContainer, data, builder) {
+               var title = data.text;
+               builder._explorableMenu(parentContainer, title, data.children, 
builder);
+       },
+
        _fontNameControl: function(parentContainer, data, builder) {
                var iconPath = 'images/lc_charfontname.svg';
                data.entries = [ 'Liberation Sans' ];
diff --git a/loleaflet/src/control/Control.Menubar.js 
b/loleaflet/src/control/Control.Menubar.js
index 5cddbc6b8..41f475be6 100644
--- a/loleaflet/src/control/Control.Menubar.js
+++ b/loleaflet/src/control/Control.Menubar.js
@@ -75,6 +75,7 @@ L.Control.Menubar = L.Control.extend({
                                {name: _UNO('.uno:InsertGraphic', 'text'), id: 
'insertgraphicremote', type: 'action'},
                                {name: _UNO('.uno:InsertAnnotation', 'text'), 
id: 'insertcomment', type: 'action'},
                                {uno: '.uno:InsertObjectChart'},
+                               {id: 'inserttable', type: 'action', name: 
_('Insert table'), desktop: false, tablet: false},
                                {type: 'separator'},
                                {uno: '.uno:InsertSection', id: 
'insertsection'},
                                {name: _UNO('.uno:InsertField', 'text'), type: 
'menu', menu: [
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to