diff options
Diffstat (limited to 'resources/views/modules/statistics-chart/page.phtml')
| -rw-r--r-- | resources/views/modules/statistics-chart/page.phtml | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/resources/views/modules/statistics-chart/page.phtml b/resources/views/modules/statistics-chart/page.phtml new file mode 100644 index 0000000000..a78f389ab2 --- /dev/null +++ b/resources/views/modules/statistics-chart/page.phtml @@ -0,0 +1,50 @@ +<?php use Fisharebest\Webtrees\I18N; ?> +<?php use Fisharebest\Webtrees\View; ?> + +<h2 class="wt-page-title"> + <?= $title ?> +</h2> + +<div class="wt-page-content wt-chart wt-statistics-chart" id="statistics-tabs"> + <ul class="nav nav-tabs" role="tablist"> + <?php foreach ($tabs as $label => $url) : ?> + <li class="nav-item"> + <a class="nav-link" href="#tab-<?= e(md5($url)) ?>" data-toggle="tab" data-href="<?= e($url) ?>" role="tab"> + <?= $label ?> + </a> + </li> + <?php endforeach ?> + </ul> + + <div class="tab-content"> + <?php foreach ($tabs as $label => $url) : ?> + <div class="tab-pane fade wt-ajax-load" role="tabpanel" id="tab-<?= e(md5($url)) ?>"></div> + <?php endforeach ?> + </div> +</div> + +<?php View::push('javascript') ?> +<script> + "use strict"; + + // Bootstrap tabs - load content dynamically using AJAX + $('a[data-toggle="tab"][data-href]').on('show.bs.tab', function () { + $(this.getAttribute('href') + ':empty').load($(this).data('href')); + }); + + // If the URL contains a fragment, then activate the corresponding tab. + // Use a prefix on the fragment, to prevent scrolling to the element. + var target = window.location.hash.replace("tab-", ""); + var tab = $("#statistics-tabs .nav-link[href='" + target + "']"); + // If not, then activate the first tab. + if (tab.length === 0) { + tab = $("#statistics-tabs .nav-link:first"); + } + tab.tab("show"); + + // If the user selects a tab, update the URL to reflect this + $('#statistics-tabs a[data-toggle="tab"]').on('shown.bs.tab', function (e) { + window.location.hash = "tab-" + e.target.href.substring(e.target.href.indexOf('#') + 1); + }); +</script> +<?php View::endpush() ?> |
