Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions assets/js/bookingFilters.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
function initBookingFilters() {
const filterGroups = document.querySelectorAll(".o-booking-filters");

filterGroups.forEach((group) => {
const chips = group.querySelectorAll(".a-booking-filter-chip");
const bookings = group.parentElement.querySelectorAll(
".o-expander--booking",
);

chips.forEach((chip) => {
chip.addEventListener("click", () => {
const isPressed = chip.getAttribute("aria-pressed") === "true";
chip.setAttribute("aria-pressed", String(!isPressed));
applyFilters(group, bookings);
});
});
});
}

function applyFilters(group, bookings) {
const activeFilters = [];
group.querySelectorAll(".a-booking-filter-chip").forEach((chip) => {
if (chip.getAttribute("aria-pressed") === "true") {
activeFilters.push(chip.dataset.filter);
}
});

bookings.forEach((booking) => {
if (activeFilters.length === 0) {
booking.hidden = false;
return;
}

const matches = activeFilters.every((filter) => {
return booking.getAttribute(`data-booking-${filter}`) === "true";
});

booking.hidden = !matches;
});
}

document.addEventListener("DOMContentLoaded", initBookingFilters);
1 change: 1 addition & 0 deletions assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ import "./expander.js";
import "./dialog.js";
import "./fipValidityComparison.js";
import "./search.js";
import "./bookingFilters.js";
50 changes: 50 additions & 0 deletions assets/sass/bookingFilters.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
.o-booking-filters {
display: flex;
flex-wrap: wrap;
gap: 0.8rem;
margin-bottom: 1.5rem;
}

.a-booking-filter-chip {
display: inline-flex;
align-items: center;
gap: 0.4rem;
padding: 0.6rem 1.2rem;
border-radius: var(--border-radius-l);
border: var(--border-visible);
background-color: transparent;
color: var(--color-body);
font-family: var(--font-family);
font-size: 1.4rem;
font-weight: 500;
cursor: pointer;
transition:
background-color 0.2s ease,
border-color 0.2s ease,
color 0.2s ease;
user-select: none;

&:hover {
background-color: var(--bg-neutral);
}

&:focus-visible {
outline: var(--outline-focus-indicator) solid 2px;
outline-offset: 2px;
}

&[aria-pressed="true"] {
background-color: var(--link-default);
border-color: var(--link-default);
color: #ffffff;

&:hover {
background-color: var(--link-hovered);
border-color: var(--link-hovered);
}
}

> .a-icon {
font-size: 1.6rem;
}
}
1 change: 1 addition & 0 deletions assets/sass/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@
@import "dialog.scss";
@import "fip-validity.scss";
@import "404.scss";
@import "bookingFilters.scss";
5 changes: 5 additions & 0 deletions content/operator/bdz/index.de.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ Regionalbahnen im innerbulgarischen Verkehr mit Halt an meist allen Stationen, d

## Ticket- und Reservierungskauf

{{% booking-filters
reservations=true
fip_50=true
%}}

### Vor Ort

{{% booking id="bdz-ticket-office" /%}}
Expand Down
5 changes: 5 additions & 0 deletions content/operator/bdz/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ Regional trains in domestic traffic stopping at most stations, often running mor

## Ticket and Reservation Purchase

{{% booking-filters
reservations=true
fip_50=true
%}}

### On-Site

{{% booking id="bdz-ticket-office" /%}}
Expand Down
5 changes: 5 additions & 0 deletions content/operator/bdz/index.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ Les prix de r茅servation pour les couchettes ou voitures-lits sont plus 茅lev茅s

## Achat de billets et r茅servations

{{% booking-filters
reservations=true
fip_50=true
%}}

### En gare

{{% booking id="bdz-ticket-office" /%}}
Expand Down
5 changes: 5 additions & 0 deletions content/operator/bls/index.de.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ FIP ist auf den Schiffen der BLS auf dem Thunersee und Brienzersee g眉ltig.

## Ticket- und Reservierungskauf

{{% booking-filters
reservations=true
fip_50=true
%}}

### Online

{{% booking id="sbb-website"/%}}
Expand Down
5 changes: 5 additions & 0 deletions content/operator/bls/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ FIP is valid on BLS ships on Lake Thun and Lake Brienz.

## Ticket and Reservation Purchase

{{% booking-filters
reservations=true
fip_50=true
%}}

### Online

{{% booking id="sbb-website"/%}}
Expand Down
5 changes: 5 additions & 0 deletions content/operator/bls/index.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ Le FIP est valable sur les bateaux de la BLS sur le lac de Thoune et le lac de B

## Achat de billets et r茅servations

{{% booking-filters
reservations=true
fip_50=true
%}}

### En ligne

{{% booking id="sbb-website"/%}}
Expand Down
5 changes: 5 additions & 0 deletions content/operator/cd/index.de.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ Ein Ticket (Reservierung verpflichtend) muss sp盲testens 15 Minuten vor Abfahrt

## Ticket- und Reservierungskauf

{{% booking-filters
reservations=true
fip_50=true
%}}

### Online

{{% booking id="cd-website" /%}}
Expand Down
5 changes: 5 additions & 0 deletions content/operator/cd/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ A ticket (reservation mandatory) must be purchased at the latest 15 minutes befo

## Ticket and Reservation Purchase

{{% booking-filters
reservations=true
fip_50=true
%}}

### Online

{{% booking id="cd-website" /%}}
Expand Down
5 changes: 5 additions & 0 deletions content/operator/cd/index.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ Un billet (r茅servation obligatoire) doit 锚tre achet茅 au plus tard 15 minutes

## Achat de billets et r茅servations

{{% booking-filters
reservations=true
fip_50=true
%}}

### En ligne

{{% booking id="cd-website" /%}}
Expand Down
5 changes: 5 additions & 0 deletions content/operator/cfl/index.de.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ Die Standseilbahn verbindet die Bahnhaltestelle Pfaffenthal-Kirchberg mit der Um

## Ticket- und Reservierungskauf

{{% booking-filters
reservations=true
fip_50=true
%}}

Der Ticketkauf ist nur f眉r die erste Klasse relevant.

{{% highlight tip %}}
Expand Down
5 changes: 5 additions & 0 deletions content/operator/cfl/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ The funicular connects the Pfaffenthal-Kirchberg railway stop with the interchan

## Ticket and Reservation Purchase

{{% booking-filters
reservations=true
fip_50=true
%}}

Ticket purchase is only relevant for first class.

{{% highlight tip %}}
Expand Down
5 changes: 5 additions & 0 deletions content/operator/cfl/index.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ Le funiculaire relie la halte ferroviaire Pfaffenthal-Kirchberg 脿 la plateforme

## Achat de billets et r茅servations

{{% booking-filters
reservations=true
fip_50=true
%}}

L鈥檃chat de billets n鈥檈st pertinent que pour la premi猫re classe.

{{% highlight tip %}}
Expand Down
5 changes: 5 additions & 0 deletions content/operator/cfr/index.de.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ Eine Reservierung ist f眉r einige Z眉ge erforderlich, diese sind mit _R_ gekennz

## Ticket- und Reservierungskauf

{{% booking-filters
reservations=true
fip_50=true
%}}

### Online

{{% booking id="db-website"
Expand Down
5 changes: 5 additions & 0 deletions content/operator/cfr/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ A reservation is required for some trains, indicated by an _R_.

## Ticket and Reservation Purchase

{{% booking-filters
reservations=true
fip_50=true
%}}

### Online

{{% booking id="db-website"
Expand Down
5 changes: 5 additions & 0 deletions content/operator/cfr/index.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ Une r茅servation est n茅cessaire pour certains trains, indiqu茅s par un _R_.

## Achat de billets et r茅servations

{{% booking-filters
reservations=true
fip_50=true
%}}

### En ligne

{{% booking id="db-website"
Expand Down
6 changes: 6 additions & 0 deletions content/operator/cie/index.de.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ FIP ist auf Busverbindungen von Dublin Bus nicht g眉ltig.

## Ticket- und Reservierungskauf

{{% booking-filters
reservations=true
fip_50=true
fip_75=true
%}}

### Online

FIP 50 / FIP 75 Tickets sind online nicht buchbar.
Expand Down
6 changes: 6 additions & 0 deletions content/operator/cie/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ FIP is not valid on Dublin Bus bus services.

## Ticket and Reservation Purchase

{{% booking-filters
reservations=true
fip_50=true
fip_75=true
%}}

### Online

FIP 50 / FIP 75 Tickets cannot be booked online.
Expand Down
6 changes: 6 additions & 0 deletions content/operator/cie/index.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ Le FIP n鈥檈st pas valable sur les liaisons en bus de Dublin Bus.

## Achat de billets et r茅servations

{{% booking-filters
reservations=true
fip_50=true
fip_75=true
%}}

### En ligne

Les Billets FIP 50 / FIP 75 ne peuvent pas 锚tre r茅serv茅s en ligne.
Expand Down
5 changes: 5 additions & 0 deletions content/operator/db/index.de.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,11 @@ FIP-Verg眉nstigungen gelten nicht in Bussen. In Bussen des Schienenersatzverkehr

## Ticket- und Reservierungskauf

{{% booking-filters
reservations=true
fip_50=true
%}}

### Online

{{% booking id="db-website" /%}}
Expand Down
5 changes: 5 additions & 0 deletions content/operator/db/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,11 @@ FIP discounts do not apply on buses. On rail replacement buses, FIP discounts ap

## Ticket and Reservation Purchase

{{% booking-filters
reservations=true
fip_50=true
%}}

### Online

{{% booking id="db-website" /%}}
Expand Down
5 changes: 5 additions & 0 deletions content/operator/db/index.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,11 @@ Les r茅ductions FIP ne sont pas valables dans les bus. Dans les bus de remplacem

## Achat de billets et r茅servations

{{% booking-filters
reservations=true
fip_50=true
%}}

### En ligne

{{% booking id="db-website" /%}}
Expand Down
5 changes: 5 additions & 0 deletions content/operator/dsb/index.de.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ Die S-Bahn Kopenhagen wird ebenfalls von der DSB betrieben und kann daher auch m

## Ticket- und Reservierungskauf

{{% booking-filters
reservations=true
fip_50=true
%}}

### Online

{{% booking id="dsb-website"
Expand Down
5 changes: 5 additions & 0 deletions content/operator/dsb/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ The Copenhagen S-train is also operated by DSB and can therefore be used with FI

## Ticket and Reservation Purchase

{{% booking-filters
reservations=true
fip_50=true
%}}

### Online

{{% booking id="dsb-website"
Expand Down
5 changes: 5 additions & 0 deletions content/operator/dsb/index.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ Le r茅seau S-tog de Copenhague est 茅galement exploit茅 par DSB. Trains fr茅quen

## Achat de billets et r茅servations

{{% booking-filters
reservations=true
fip_50=true
%}}

### En ligne

{{% booking id="dsb-website"
Expand Down
Loading
Loading