regattas: scroll to today button
This commit is contained in:
@@ -14,6 +14,11 @@
|
|||||||
|
|
||||||
$sp['output'] .= $tpl->load('card', [$content]);
|
$sp['output'] .= $tpl->load('card', [$content]);
|
||||||
|
|
||||||
|
// To today
|
||||||
|
$content = $tpl->load('button', ['<i class="fas fa-arrow-down"></i> Heute <i class="fas fa-arrow-down"></i>', '#', 'html-id' => 'button-totoday']);
|
||||||
|
|
||||||
|
$sp['output'] .= $tpl->load('card', [$content]);
|
||||||
|
|
||||||
// Regattas
|
// Regattas
|
||||||
$content = '<p id="p-count" class="mb-0"></p>';
|
$content = '<p id="p-count" class="mb-0"></p>';
|
||||||
$content .= $tpl->load('input', ['html-id' => 'input-search', 'placeholder' => 'Suche', 'type' => 'text', 'css-class' => 'mt-2']);
|
$content .= $tpl->load('input', ['html-id' => 'input-search', 'placeholder' => 'Suche', 'type' => 'text', 'css-class' => 'mt-2']);
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
|
Element.prototype.documentOffsetTop = function() {
|
||||||
|
return this.offsetTop + (this.offsetParent ? this.offsetParent.documentOffsetTop() : 0);
|
||||||
|
};
|
||||||
|
function scrollToToday() {
|
||||||
|
window.scrollTo({ top: document.getElementById('div-today').documentOffsetTop() - (window.innerHeight / 2), behavior: 'smooth' });
|
||||||
|
}
|
||||||
|
|
||||||
function selectChange(callSiteScript = true) {
|
function selectChange(callSiteScript = true) {
|
||||||
var val = $('#select-year').val();
|
var val = $('#select-year').val();
|
||||||
if (val == "user") {
|
if (val == "user") {
|
||||||
@@ -60,7 +67,7 @@ async function drawList () {
|
|||||||
var list = '';
|
var list = '';
|
||||||
rows.forEach(function (entry) {
|
rows.forEach(function (entry) {
|
||||||
if (entry == null) {
|
if (entry == null) {
|
||||||
list += '<div><div align="center" class="color-highlight"><b>Heute ist der ' + formatDate('d.m.Y', today) + '</b></div></div>';
|
list += '<div><div id="div-today" align="center" class="color-highlight"><b>Heute ist der ' + formatDate('d.m.Y', today) + '</b></div></div>';
|
||||||
} else if (search($('#input-search').val(), entry.keywords)) {
|
} else if (search($('#input-search').val(), entry.keywords)) {
|
||||||
list += entry.content;
|
list += entry.content;
|
||||||
}
|
}
|
||||||
@@ -76,6 +83,7 @@ var siteScript = async function() {
|
|||||||
$('#select-year').change(selectChange);
|
$('#select-year').change(selectChange);
|
||||||
$('#button-show').click(buttonShowPressed);
|
$('#button-show').click(buttonShowPressed);
|
||||||
$('#input-search').on('input', drawList);
|
$('#input-search').on('input', drawList);
|
||||||
|
$('#button-totoday').click(scrollToToday);
|
||||||
}
|
}
|
||||||
|
|
||||||
today = getToday();
|
today = getToday();
|
||||||
@@ -84,6 +92,9 @@ var siteScript = async function() {
|
|||||||
var maxDate = parseDate($('#input-to').val());
|
var maxDate = parseDate($('#input-to').val());
|
||||||
var regattas = await dbGetRegattasRange(minDate, maxDate);
|
var regattas = await dbGetRegattasRange(minDate, maxDate);
|
||||||
|
|
||||||
|
if (minDate <= today && maxDate >= today) $('#button-totoday').parent().parent().show();
|
||||||
|
else $('#button-totoday').parent().parent().hide();
|
||||||
|
|
||||||
var selectedYear = $('#select-year').val();
|
var selectedYear = $('#select-year').val();
|
||||||
|
|
||||||
var years = await dbGetData('years');
|
var years = await dbGetData('years');
|
||||||
|
|||||||
Reference in New Issue
Block a user