Adapt transit demo support to new sidebar

This commit is contained in:
Norbert Renner 2018-03-15 14:59:53 +01:00
parent 208041c3d8
commit ce279fd464
5 changed files with 27 additions and 10 deletions

View file

@ -1,18 +1,14 @@
BR.Itinerary = L.Class.extend({
options: {
heading: 'Itinerary'
},
onAdd: function (map) {
initialize: function () {
this._content = document.getElementById('itinerary');
document.getElementById('tab_itinerary').hidden = false;
this.update();
},
update: function (polyline, segments) {
var i, j, iter, html = '';
html += '<pre>';
html += '<pre class="flexgrow">';
for (i = 0; segments && i < segments.length; i++)
{
iter = segments[i].feature.iternity;

View file

@ -220,11 +220,15 @@
trackMessages.onAdd(map);
sidebar = BR.sidebar({
defaultTabId: BR.conf.transit ? 'tab_itinerary' : 'tab_profile',
listeningTabs: {
'tab_profile': profile,
'tab_data': trackMessages
}
}).addTo(map);
if (BR.conf.transit) {
sidebar.showPanel('tab_itinerary');
}
nogos.addTo(map);
nogos.preventRoutePointOnCreate(routing);

View file

@ -6,6 +6,7 @@ BR.Sidebar = L.Control.Sidebar.extend({
container: 'sidebar',
tabContainer: 'sidebarTabs',
autopan: false,
defaultTabId: '',
// Tabs to be notified when shown or hidden
// (tab div id -> object implementing show/hide methods)
@ -33,7 +34,14 @@ BR.Sidebar = L.Control.Sidebar.extend({
return this;
},
showPanel: function(id) {
var tab = this._getTab(id);
tab.hidden = false;
return this;
},
_rememberTabState: function () {
if (BR.Util.localStorageAvailable()) {
this.on('content closing', this._storeActiveTab, this);
@ -43,7 +51,7 @@ BR.Sidebar = L.Control.Sidebar.extend({
// not set: open sidebar by default for new users
// 'true': legacy value for toggling old sidebar
if (tabId === null || tabId === 'true') {
tabId = 'tab_profile';
tabId = this.options.defaultTabId;
}
if (tabId !== '') {
this.open(tabId);