loleaflet/src/control/Control.JSDialogBuilder.js | 7 +++- loleaflet/src/control/Control.MobileWizard.js | 35 +++++++++++++++++++++-- 2 files changed, 37 insertions(+), 5 deletions(-)
New commits: commit 3809b9ab6f2092589f9ffccdc46a3073d2ef3af9 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Mon Dec 9 11:06:14 2019 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Mon Dec 9 11:06:23 2019 +0100 jsdialog: remember last opened tab when rebuilding Change-Id: Ia1c06275fade580c559cd4a96bf649a65c028af4 diff --git a/loleaflet/src/control/Control.JSDialogBuilder.js b/loleaflet/src/control/Control.JSDialogBuilder.js index cde756651..3ec85405d 100644 --- a/loleaflet/src/control/Control.JSDialogBuilder.js +++ b/loleaflet/src/control/Control.JSDialogBuilder.js @@ -403,6 +403,7 @@ L.Control.JSDialogBuilder = L.Control.extend({ var title1 = builder._cleanText(data[0].text); var tab1 = L.DomUtil.create('div', 'ui-tab mobile-wizard', tabsContainer); + tab1.id = title1; var label = L.DomUtil.create('span', 'ui-tab-content mobile-wizard unolabel', tab1); label.innerHTML = title1; @@ -418,10 +419,10 @@ L.Control.JSDialogBuilder = L.Control.extend({ $(contentDiv).hide(); + var title2 = builder._cleanText(data[1].text); var tab2 = L.DomUtil.create('div', 'ui-tab mobile-wizard', tabsContainer); - - var title2 = builder._cleanText(data[1].text); + tab2.id = title2; var label2 = L.DomUtil.create('span', 'ui-tab-content mobile-wizard unolabel', tab2); label2.innerHTML = title2; @@ -444,6 +445,7 @@ L.Control.JSDialogBuilder = L.Control.extend({ $(tab2).removeClass('selected'); $(contentDiv).show(); $(contentDiv2).hide(); + builder.wizard.selectedTab(label.innerHTML); }); $(tab2).click(function() { @@ -451,6 +453,7 @@ L.Control.JSDialogBuilder = L.Control.extend({ $(tab1).removeClass('selected'); $(contentDiv).hide(); $(contentDiv2).show(); + builder.wizard.selectedTab(label2.innerHTML); }); } else { console.debug('Builder used outside of mobile wizard: please implement the click handler'); diff --git a/loleaflet/src/control/Control.MobileWizard.js b/loleaflet/src/control/Control.MobileWizard.js index f9df62535..a66479c33 100644 --- a/loleaflet/src/control/Control.MobileWizard.js +++ b/loleaflet/src/control/Control.MobileWizard.js @@ -15,6 +15,7 @@ L.Control.MobileWizard = L.Control.extend({ _mainTitle: '', _isTabMode: false, _currentPath: [], + _tabs: [], _currentScrollPosition: 0, initialize: function (options) { @@ -41,6 +42,8 @@ L.Control.MobileWizard = L.Control.extend({ $('#mobile-wizard').removeClass('menuwizard'); this._isTabMode = false; this._currentPath = []; + this._tabs = []; + this._currentScrollPosition = 0; }, _setupBackButton: function() { @@ -87,6 +90,7 @@ L.Control.MobileWizard = L.Control.extend({ }, setTabs: function(tabs) { + this._tabs = tabs; $('#mobile-wizard-tabs').show(); $('#mobile-wizard-tabs').empty(); $('#mobile-wizard-tabs').append(tabs); @@ -178,16 +182,37 @@ L.Control.MobileWizard = L.Control.extend({ right.text(title); }, - _scrollToLastPosition: function() { + _scrollToPosition: function(position) { if (this._currentScrollPosition) { - $('#mobile-wizard-content').animate({ scrollTop: this._currentScrollPosition }, 0); + $('#mobile-wizard-content').animate({ scrollTop: position }, 0); + } + }, + + selectedTab: function(tabText) { + if (this._currentPath && this._currentPath.length) { + this._currentPath[0] = tabText; + } + }, + + _selectTab: function(tabId) { + if (this._tabs && tabId) { + for (var index in this._tabs.children) { + if (this._tabs.children[index].id === tabId) { + $(this._tabs.children[index]).trigger('click', {animate: false}); + break; + } + } } }, _goToPath: function(path) { + if (this._tabs && path && path.length) + this._selectTab(path[0]); + for (var index in path) { $('[title=\'' + path[index] + '\'').prev().trigger('click', {animate: false}); } + this._currentPath = path; }, @@ -208,8 +233,12 @@ L.Control.MobileWizard = L.Control.extend({ this._isActive = true; var currentPath = null; + var lastScrollPosition = null; + if (this._currentPath) currentPath = this._currentPath; + if (this._currentScrollPosition) + lastScrollPosition = this._currentScrollPosition; this._reset(); @@ -248,7 +277,7 @@ L.Control.MobileWizard = L.Control.extend({ if (this._isActive && currentPath.length) { this._goToPath(currentPath); - this._scrollToLastPosition(); + this._scrollToPosition(lastScrollPosition); } } }, _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits