loleaflet/src/control/Control.MobileWizard.js |   75 +++++++++++++++++++++++++-
 loleaflet/src/layer/tile/TileLayer.js         |   42 --------------
 2 files changed, 74 insertions(+), 43 deletions(-)

New commits:
commit e1963de90547b636e0fc37d43747bb47679f34b0
Author:     Tamás Zolnai <tamas.zol...@collabora.com>
AuthorDate: Tue Oct 8 20:03:26 2019 +0200
Commit:     Tamás Zolnai <tamas.zol...@collabora.com>
CommitDate: Tue Oct 8 20:03:26 2019 +0200

    mobile-wizard: move sidebar layout modification code to MobileWizard.js
    
    Change-Id: Iedc1a5dc5ee021d19c1309652c86166d658d1aaa

diff --git a/loleaflet/src/control/Control.MobileWizard.js 
b/loleaflet/src/control/Control.MobileWizard.js
index 04def764b..b71a8c93f 100644
--- a/loleaflet/src/control/Control.MobileWizard.js
+++ b/loleaflet/src/control/Control.MobileWizard.js
@@ -119,12 +119,85 @@ L.Control.MobileWizard = L.Control.extend({
                        this._showWizard();
                        this._hideKeyboard();
 
+                       // We can change the sidebar as we want here
+                       if (!data.text) { // sidebar indicator
+                               this._modifySidebarLayout(data);
+                       }
+
                        L.control.jsDialogBuilder({mobileWizard: this, map: 
this.map}).build(this.content.get(0), [data]);
 
                        this._mainTitle = data.text ? data.text : '';
                        this._setTitle(this._mainTitle);
                }
-       }
+       },
+
+       _modifySidebarLayout: function (data) {
+               this._mergeStylesAndTextPropertyPanels(data);
+               this._removeItems(data, ['editcontour']);
+       },
+
+       _mergeStylesAndTextPropertyPanels: function (data) {
+               var stylesChildren = this._removeStylesPanelAndGetContent(data);
+               if (stylesChildren !== null) {
+                       this._addChildrenToTextPanel(data, stylesChildren);
+               }
+       },
+
+       _removeStylesPanelAndGetContent: function (data) {
+               if (data.children) {
+                       for (var i = 0; i < data.children.length; i++) {
+                               if (data.children[i].type === 'panel' && 
data.children[i].children &&
+                                       data.children[i].children.length > 0 && 
data.children[i].children[0].id === 'SidebarStylesPanel') {
+                                       var ret = 
data.children[i].children[0].children;
+                                       data.children.splice(i, 1);
+                                       return ret;
+                               }
+
+                               var childReturn = 
this._removeStylesPanelAndGetContent(data.children[i]);
+                               if (childReturn !== null) {
+                                       return childReturn;
+                               }
+                       }
+               }
+               return null;
+       },
+
+       _addChildrenToTextPanel: function (data, children) {
+               if (data.id === 'SidebarTextPanel') {
+                       data.children = children.concat(data.children);
+                       return 'success';
+               }
+
+               if (data.children) {
+                       for (var i = 0; i < data.children.length; i++) {
+                               var childReturn = 
this._addChildrenToTextPanel(data.children[i], children);
+                               if (childReturn !== null) {
+                                       return childReturn;
+                               }
+                       }
+               }
+               return null;
+       },
+
+       _removeItems: function (data, items) {
+               if (data.children) {
+                       var childRemoved = false;
+                       for (var i = 0; i < data.children.length; i++) {
+                               for (var j = 0; j < items.length; j++) {
+                                       if (data.children[i].id === items[j]) {
+                                               data.children.splice(i, 1);
+                                               childRemoved = true;
+                                               continue;
+                                       }
+                               }
+                               if (childRemoved === true) {
+                                       i = i - 1;
+                               } else {
+                                       this._removeItems(data.children[i], 
items);
+                               }
+                       }
+               }
+       },
 });
 
 L.control.mobileWizard = function (options) {
diff --git a/loleaflet/src/layer/tile/TileLayer.js 
b/loleaflet/src/layer/tile/TileLayer.js
index 91e5ed88b..1609b9ed0 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -756,80 +756,10 @@ L.TileLayer = L.GridLayer.extend({
        _onJSDialogMsg: function (textMsg) {
                if (window.mode.isMobile() && window.mobileWizard === true) {
                        var msgData = 
JSON.parse(textMsg.substring('jsdialog:'.length + 1));
-                       // by now jsdialog is used only for sidebar
-                       this._modifySidebarLayout(msgData);
                        this._openMobileWizard(msgData);
                }
        },
 
-       _modifySidebarLayout: function (data) {
-               this._mergeStylesAndTextPropertyPanels(data);
-               this._removeItems(data, ['editcontour']);
-       },
-
-       _mergeStylesAndTextPropertyPanels: function (data) {
-               var stylesChildren = this._removeStylesPanelAndGetContent(data);
-               if (stylesChildren !== null) {
-                       this._addChildrenToTextPanel(data, stylesChildren);
-               }
-       },
-
-       _removeStylesPanelAndGetContent: function (data) {
-               if (data.children) {
-                       for (var i = 0; i < data.children.length; i++) {
-                               if (data.children[i].type === 'panel' && 
data.children[i].children &&
-                                       data.children[i].children.length > 0 && 
data.children[i].children[0].id === 'SidebarStylesPanel') {
-                                       var ret = 
data.children[i].children[0].children;
-                                       data.children.splice(i, 1);
-                                       return ret;
-                               }
-
-                               var childReturn = 
this._removeStylesPanelAndGetContent(data.children[i]);
-                               if (childReturn !== null) {
-                                       return childReturn;
-                               }
-                       }
-               }
-               return null;
-       },
-
-       _addChildrenToTextPanel: function (data, children) {
-               if (data.id === 'SidebarTextPanel') {
-                       data.children = children.concat(data.children);
-                       return 'success';
-               }
-
-               if (data.children) {
-                       for (var i = 0; i < data.children.length; i++) {
-                               var childReturn = 
this._addChildrenToTextPanel(data.children[i], children);
-                               if (childReturn !== null) {
-                                       return childReturn;
-                               }
-                       }
-               }
-               return null;
-       },
-
-       _removeItems: function (data, items) {
-               if (data.children) {
-                       var childRemoved = false;
-                       for (var i = 0; i < data.children.length; i++) {
-                               for (var j = 0; j < items.length; j++) {
-                                       if (data.children[i].id === items[j]) {
-                                               data.children.splice(i, 1);
-                                               childRemoved = true;
-                                               continue;
-                                       }
-                               }
-                               if (childRemoved === true) {
-                                       i = i - 1;
-                               } else {
-                                       this._removeItems(data.children[i], 
items);
-                               }
-                       }
-               }
-       },
-
        _onGraphicSelectionMsg: function (textMsg) {
                if (textMsg.match('EMPTY')) {
                        this._resetSelectionRanges();
commit 2f2e1f5330ea161ed83c2f2c54dd30bd2aba6954
Author:     Tamás Zolnai <tamas.zol...@collabora.com>
AuthorDate: Tue Oct 8 15:28:06 2019 +0200
Commit:     Tamás Zolnai <tamas.zol...@collabora.com>
CommitDate: Tue Oct 8 19:52:19 2019 +0200

    Add a function to remove item by id from the mobile wizard
    
    Also remove 'editcontour' button which is for triggering a dialog.
    
    Change-Id: I3c1e6e95dcc5b564b647e32d3b1245376af5764a

diff --git a/loleaflet/src/layer/tile/TileLayer.js 
b/loleaflet/src/layer/tile/TileLayer.js
index eeadda445..91e5ed88b 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -756,14 +756,22 @@ L.TileLayer = L.GridLayer.extend({
        _onJSDialogMsg: function (textMsg) {
                if (window.mode.isMobile() && window.mobileWizard === true) {
                        var msgData = 
JSON.parse(textMsg.substring('jsdialog:'.length + 1));
-                       this._mergeStylesAndTextPropertyPanels(msgData);
+                       // by now jsdialog is used only for sidebar
+                       this._modifySidebarLayout(msgData);
                        this._openMobileWizard(msgData);
                }
        },
 
+       _modifySidebarLayout: function (data) {
+               this._mergeStylesAndTextPropertyPanels(data);
+               this._removeItems(data, ['editcontour']);
+       },
+
        _mergeStylesAndTextPropertyPanels: function (data) {
                var stylesChildren = this._removeStylesPanelAndGetContent(data);
-               this._addChildrenToTextPanel(data, stylesChildren);
+               if (stylesChildren !== null) {
+                       this._addChildrenToTextPanel(data, stylesChildren);
+               }
        },
 
        _removeStylesPanelAndGetContent: function (data) {
@@ -802,6 +810,26 @@ L.TileLayer = L.GridLayer.extend({
                return null;
        },
 
+       _removeItems: function (data, items) {
+               if (data.children) {
+                       var childRemoved = false;
+                       for (var i = 0; i < data.children.length; i++) {
+                               for (var j = 0; j < items.length; j++) {
+                                       if (data.children[i].id === items[j]) {
+                                               data.children.splice(i, 1);
+                                               childRemoved = true;
+                                               continue;
+                                       }
+                               }
+                               if (childRemoved === true) {
+                                       i = i - 1;
+                               } else {
+                                       this._removeItems(data.children[i], 
items);
+                               }
+                       }
+               }
+       },
+
        _onGraphicSelectionMsg: function (textMsg) {
                if (textMsg.match('EMPTY')) {
                        this._resetSelectionRanges();
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to