use tab instead of separate control for transit demo

This commit is contained in:
Norbert Renner 2016-06-03 21:08:48 +02:00
parent 8bd8fc3256
commit 4f558a0956
11 changed files with 52 additions and 24 deletions

View file

@ -1,18 +1,18 @@
BR.Iternity = BR.Control.extend({
BR.Iternity = L.Class.extend({
options: {
heading: 'Iternity'
},
onAdd: function (map) {
var container = BR.Control.prototype.onAdd.call(this, map);
this._content = document.getElementById('iternity');
L.DomUtil.removeClass(this._content.parentElement, 'hidden');
this.update();
return container;
},
update: function (polyline, segments) {
var i, j, iter, html = '';
html += '<small><pre>';
html += '<pre>';
for (i = 0; segments && i < segments.length; i++)
{
iter = segments[i].feature.iternity;
@ -21,7 +21,7 @@ BR.Iternity = BR.Control.extend({
html += iter[j] + '\n';
}
}
html += '</pre></small>';
html += '</pre>';
this._content.innerHTML = html;
}

View file

@ -1,4 +1,8 @@
BR.Profile = L.Class.extend({
options: {
heading: 'Profile'
},
cache: {},
initialize: function () {

View file

@ -13,6 +13,8 @@ BR.Tabs = BR.Control.extend({
var tabs = this.options.tabs;
for (var key in tabs) {
$('<li><a href="' + key + '" role="tab">' + tabs[key].options.heading + '</a></li>').appendTo('#tab');
if (tabs[key].onAdd) {
tabs[key].onAdd(map);
}
@ -27,7 +29,7 @@ BR.Tabs = BR.Control.extend({
// e.relatedTarget = previous tab
$('#tab a').on('shown.bs.tab', L.bind(function (e) {
var tab = this.options.tabs[e.target.hash],
prevTab = this.options.tabs[e.relatedTarget.hash];
prevTab = e.relatedTarget ? this.options.tabs[e.relatedTarget.hash] : null;
if (tab && tab.show) {
tab.show();
@ -37,6 +39,9 @@ BR.Tabs = BR.Control.extend({
}
}, this));
// activate first tab (instead of setting 'active' class in html)
$('#tab li:not(.hidden) a:first').tab('show');
return BR.Control.prototype.onAdd.call(this, map);
}
});

View file

@ -1,6 +1,7 @@
BR.TrackMessages = L.Class.extend({
options: {
heading: 'Data',
edgeStyle: {
color: 'yellow',
opacity: 0.8,