loleaflet/src/control/Control.JSDialogBuilder.js |   89 +++++++++++------------
 loleaflet/src/control/Control.MobileWizard.js    |   23 ++++-
 2 files changed, 62 insertions(+), 50 deletions(-)

New commits:
commit d9cbd9d6f673dc70bcaa873a51dd30a9e4f5be4e
Author:     mert <mert.tu...@collabora.com>
AuthorDate: Thu Apr 23 14:56:26 2020 +0300
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Thu Apr 23 19:35:06 2020 +0200

    mobilewizard: fix number format doesn't update properly
    
    Change-Id: I852dd79d9658f676e86b22cb1cb145264c9de2fe
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92762
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Andras Timar <andras.ti...@collabora.com>

diff --git a/loleaflet/src/control/Control.JSDialogBuilder.js 
b/loleaflet/src/control/Control.JSDialogBuilder.js
index 4deb8e296..97f416d25 100644
--- a/loleaflet/src/control/Control.JSDialogBuilder.js
+++ b/loleaflet/src/control/Control.JSDialogBuilder.js
@@ -252,33 +252,20 @@ L.Control.JSDialogBuilder = L.Control.extend({
                return false;
        },
 
-       _updateListBox: function(builder, contentDiv, contentNode, 
sectionTitle, data, state) {
-               if ($(sectionTitle).find('.entry-value')[0])
-                       sectionTitle = 
$($(sectionTitle).find('.entry-value')).get(0);
-               else
-                       sectionTitle = 
$(sectionTitle).find('.ui-header-left').find('span')[0];
-
+       _updateListBox: function(builder, sectionTitle, data, state) {
                if (!sectionTitle)
                        return;
 
-               $(contentDiv).find('.selected').removeClass('selected');
-
-               var hasChildren = $(contentDiv).children().length > 0 && 
contentNode.children && contentNode.children.length > 0;
                var updateBy = builder._getListBoxUpdateType(data.id);
-               if (updateBy === 'index') {
+
+               if (updateBy === 'index')
                        sectionTitle.innerHTML = data.entries[state];
-                       data.selectedEntries[0] = state;
-                       contentDiv.title = data.entries[state];
-                       if (hasChildren) {
-                               
$($(contentDiv).children().get(state)).addClass('selected');
-                       }
-               } else if (updateBy === 'value') {
+               else if (updateBy === 'value')
                        sectionTitle.innerHTML = state;
-                       if (hasChildren) {
-                               $(contentDiv).find('p').filter(function() {
-                                       return $(this).text() === state;
-                               }).addClass('selected');
-                       }
+
+               if (builder.refreshSidebar) {
+                       builder.wizard._refreshSidebar(0);
+                       builder.refreshSidebar = false;
                }
        },
 
@@ -301,6 +288,13 @@ L.Control.JSDialogBuilder = L.Control.extend({
                }
                var titleSpan = L.DomUtil.create('span', titleClass, leftDiv);
 
+               if (!valueNode && data.command) {
+                       var items = builder.map['stateChangeHandler'];
+                       var val = items.getItemValue(data.command);
+                       if (val)
+                               valueNode = L.DomUtil.create('div', '', null);
+               }
+
                var rightDiv = L.DomUtil.create('div', 'ui-header-right', 
sectionTitle);
                if (valueNode) {
                        var valueDiv = L.DomUtil.create('div', 'entry-value', 
rightDiv);
@@ -310,36 +304,14 @@ L.Control.JSDialogBuilder = L.Control.extend({
                var arrowSpan = L.DomUtil.create('span', 'sub-menu-arrow', 
rightDiv);
                arrowSpan.innerHTML = '>';
 
-               var contentDiv = L.DomUtil.create('div', 'ui-content level-' + 
builder._currentDepth + ' mobile-wizard', parentContainer);
-               contentDiv.title = data.text;
-
-               builder._currentDepth++;
-               builder.build(contentDiv, [contentNode]);
-               builder._currentDepth--;
-
-               if (!data.nosubmenu)
-               {
-                       $(contentDiv).hide();
-                       if (builder.wizard) {
-                               $(sectionTitle).click(function(event, data) {
-                                       builder.wizard.goLevelDown(contentDiv, 
data);
-                                       if (contentNode.onshow)
-                                               contentNode.onshow();
-                               });
-                       } else {
-                               console.debug('Builder used outside of mobile 
wizard: please implement the click handler');
-                       }
-               }
-               else
-                       $(sectionTitle).hide();
-
                var updateFunction = function(titleSpan) {
                        var state = null;
                        if (data.id)
                                state = builder._getUnoStateForItemId(data.id, 
builder);
 
-                       if (builder._getListBoxUpdateType(data.id)) {
-                               builder._updateListBox(builder, contentDiv, 
contentNode, sectionTitle, data, state);
+                       if (state && builder._getListBoxUpdateType(data.id)) {
+                               titleSpan.innerHTML = data.text;
+                               builder._updateListBox(builder, 
valueNode?valueDiv:titleSpan, data, state);
                        } else if (state) {
                                titleSpan.innerHTML = state;
                        } else {
@@ -359,6 +331,29 @@ L.Control.JSDialogBuilder = L.Control.extend({
                        }
 
                }, this);
+
+               var contentDiv = L.DomUtil.create('div', 'ui-content level-' + 
builder._currentDepth + ' mobile-wizard', parentContainer);
+               contentDiv.title = data.text;
+
+               builder._currentDepth++;
+               builder.build(contentDiv, [contentNode]);
+               builder._currentDepth--;
+
+               if (!data.nosubmenu)
+               {
+                       $(contentDiv).hide();
+                       if (builder.wizard) {
+                               $(sectionTitle).click(function(event, data) {
+                                       builder.wizard.goLevelDown(contentDiv, 
data);
+                                       if (contentNode.onshow)
+                                               contentNode.onshow();
+                               });
+                       } else {
+                               console.debug('Builder used outside of mobile 
wizard: please implement the click handler');
+                       }
+               }
+               else
+                       $(sectionTitle).hide();
        },
 
        _calcFunctionEntry: function(parentContainer, data, contentNode, 
builder) {
@@ -1244,6 +1239,7 @@ L.Control.JSDialogBuilder = L.Control.extend({
                        L.DomUtil.addClass(fixedtext, data.style);
 
                $(fixedtext).click(function () {
+                       builder.refreshSidebar = true;
                        builder.callback('combobox', 'selected', 
fixedtext.parent, data.pos + ';' + fixedtext.innerHTML, builder);
                });
        },
@@ -1349,6 +1345,7 @@ L.Control.JSDialogBuilder = L.Control.extend({
                }
 
                $(div).click(function () {
+                       builder.refreshSidebar = true;
                        builder.callback('toolbutton', 'click', button, 
data.command, builder);
                });
 
diff --git a/loleaflet/src/control/Control.MobileWizard.js 
b/loleaflet/src/control/Control.MobileWizard.js
index c45f25753..4de1cd537 100644
--- a/loleaflet/src/control/Control.MobileWizard.js
+++ b/loleaflet/src/control/Control.MobileWizard.js
@@ -266,21 +266,36 @@ L.Control.MobileWizard = L.Control.extend({
                if (this._tabs && path && path.length)
                        this._selectTab(path[0]);
 
+               var _path = [];
+               var goBack = false;
+
                for (var index in path) {
-                       $('[title=\'' + path[index] + 
'\'').prev().trigger('click', {animate: false});
+                       var elem = $('[title=\'' + path[index] + '\'').prev();
+                       if (elem.length) {
+                               $(elem).trigger('click', {animate: false});
+                               _path.push(path[index]);
+                       }
+                       else
+                               goBack = true;
+               }
+
+               if (goBack) {
+                       this._currentScrollPosition = 0;
+                       $('#mobile-wizard-content').animate({ scrollTop: 0 }, 
0);
                }
 
-               this._currentPath = path;
+               this._currentPath = _path;
        },
 
-       _refreshSidebar: function() {
+       _refreshSidebar: function(ms) {
+               ms = ms !== undefined ? ms : 400;
                var map = this.map;
                setTimeout(function () {
                        var message = 'dialogevent ' +
                            (window.sidebarId !== undefined ? window.sidebarId 
: -1) +
                            ' {\"id\":\"-1\"}';
                        map._socket.sendMessage(message);
-               }, 400);
+               }, ms);
        },
 
        _updateMapSize: function() {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to