chore: copy ep_products and ep_theme from EP/website@9593cc8

Copied unchanged from public/typo3conf/ext/ of EP/website at
9593cc8631354f8a363d6609de8b7433f669a9a0 (Git-tracked files only).
History stays in the old repository. Only composer.json files are
added so the extensions install as path packages.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
frommeandClaude Opus 5.5 committed 2026-10-21 14:01:20 +02:00
1 parent 59afaecea1
commit a46918de9d
778 files changed
+67000 -2

No files matched your search

@@ -0,0 +1,46 @@
// Polyfills
// import smoothscroll from 'smoothscroll-polyfill'
// smoothscroll.polyfill()
// Add pacode to external links
document.addEventListener('DOMContentLoaded', () => {
const configElement = document.getElementById('appconfig')
if (null === configElement) {
return {}
}
const appConfig = JSON.parse(configElement.innerHTML)
const paCode = appConfig.paCode
const externalDomains = appConfig.externalDomains
if (paCode) {
document.querySelectorAll('a').forEach(element => {
if (element.hostname === location.hostname) {
return
}
if (externalDomains.indexOf(element.hostname) === -1) {
return
}
let url = element.href
if (!url) {
return
}
if (url.indexOf('agenturcode=') !== -1) {
return
}
const separator = url.indexOf('?') === -1 ? '?' : '&'
url += separator + 'agenturcode=' + paCode
element.href = url
})
}
}, false)
import { Application } from '@hotwired/stimulus'
import { definitionsFromContext } from '@hotwired/stimulus-webpack-helpers'
const application = Application.start()
const context = require.context('./controllers', true, /\.js$/)
application.load(definitionsFromContext(context))
window.htmx = require('htmx.org')
htmx.config.includeIndicatorStyles = false
htmx.config.historyEnabled = false
htmx.config.allowScriptTags = false
@@ -0,0 +1,54 @@
import { Controller } from '@hotwired/stimulus'
export default class extends Controller {
static targets = [ 'sizer', 'container', 'button', 'bar' ]
static values = {
offset: {
type: Number,
default: 0,
},
height: {
type: Number,
default: 0,
},
expanded: {
type: Boolean,
default: true,
}
}
connect() {
// Determine height of element controlling max height if available
this.maxHeight = this.hasSizerTarget ? this.sizerTarget.offsetHeight : this.heightValue
// Determine rendered height of element holding content
this.contentHeight = this.containerTarget.offsetHeight
// Determine height of collapsed content element considering
// potential offset for button
this.collapsedHeight = this.maxHeight - this.offsetValue
// Set initial expanded/collapsed status and button visibility
this.expandedValue = this.contentHeight < this.maxHeight
this.buttonTarget.classList.toggle('hidden', this.expandedValue)
// Drop the space reserved for the toggle bar when the content fits anyway
if (this.expandedValue && this.hasBarTarget) {
this.barTarget.classList.add('hidden')
this.containerTarget.style.paddingBottom = '0'
}
}
toggle() {
this.expandedValue = !this.expandedValue
}
expandedValueChanged(expanded) {
this.containerTarget.style.height = expanded ? 'auto' : `${this.collapsedHeight}px`
this.containerTarget.style.overflowY = expanded ? 'none' : 'hidden'
this.buttonTarget.classList.toggle('toggle-more', false === expanded)
this.buttonTarget.classList.toggle('toggle-less', expanded)
}
}
@@ -0,0 +1,68 @@
import { Controller } from '@hotwired/stimulus'
import { useFetch } from '../mixins/use_fetch'
export default class extends Controller {
static targets = [
'container',
'field',
'loadingIndicator',
]
static values = {
loading: Boolean,
uri: String,
hotelUid: Number,
}
initialize() {
useFetch(this)
}
connect() {
let months = []
let today = new Date()
let year = today.getFullYear()
let month = today.getMonth()
for (let i = 0; i < 20; i++) {
let selectableDate = new Date(year, month, 1)
months.push(selectableDate)
if (month < 12) {
month++
} else {
month = 1
year++
}
this.fieldTarget.options[i] = new Option(selectableDate.toLocaleDateString('de-DE', {year: 'numeric', month: 'long'}), i.toString())
}
this.selectableMonths = months
this.load(0)
}
select(e) {
let selectedIndex = e.currentTarget.value
this.load(selectedIndex)
}
load(selectedIndex) {
this.loadingValue = true
let selectedMonth = this.selectableMonths[selectedIndex]
let data = new URLSearchParams()
data.set('tx_epproducts_ajax[hotel]', this.hotelUidValue)
data.set('tx_epproducts_ajax[month]', selectedMonth.getMonth() + 1)
data.set('tx_epproducts_ajax[year]', selectedMonth.getFullYear())
fetch(this.uriValue, { method: 'POST', body: data })
.then(this.checkStatus)
.then(this.parseHTML)
.then(html => (
this.containerTarget.innerHTML = html
))
.finally(() => {
this.loadingValue = false
})
}
loadingValueChanged() {
this.loadingIndicatorTarget.classList.toggle('hidden', this.loadingValue === false)
}
}
@@ -0,0 +1,58 @@
import { Controller } from '@hotwired/stimulus'
import { useWindowResize, useDebounce, useClickOutside } from 'stimulus-use'
export default class extends Controller {
static debounces = [ 'checkBreakpoints' ]
static values = {
collapsed: Boolean,
from: Number,
until: Number,
}
static targets = [ 'container', 'icon' ]
initialize() {
useWindowResize(this)
useDebounce(this)
useClickOutside(this)
}
connect() {
this.toggleByWindowWidth(window.innerWidth)
}
windowResize({ width, height, event }) {
this.toggleByWindowWidth(width)
}
toggle() {
this.collapsedValue = !this.collapsedValue
}
open() {
this.collapsedValue = false
}
close() {
this.collapsedValue = true
}
toggleByWindowWidth(width) {
if (0 !== this.untilValue) {
this.collapsedValue = width < this.untilValue
}
if (0 !== this.fromValue) {
this.collapsedValue = width > this.fromValue
}
}
collapsedValueChanged() {
this.containerTarget.classList.toggle('hidden', this.collapsedValue === true)
this.containerTarget.scrollTop = 0
if (this.hasIconTarget) {
this.iconTarget.classList.toggle('rotate-90', this.collapsedValue === false)
}
}
}
@@ -0,0 +1,14 @@
import { Controller } from '@hotwired/stimulus'
export default class extends Controller {
static values = { event: String }
trigger() {
window.dataLayer = window.dataLayer || []
dataLayer.push({
'event': this.eventValue,
})
}
}
@@ -0,0 +1,109 @@
import { Controller } from '@hotwired/stimulus'
import { useDispatch } from 'stimulus-use'
import flatpickr from 'flatpickr'
import { German } from 'flatpickr/dist/l10n/de'
export default class extends Controller {
static targets = [
'field',
'dateFrom',
'dateTo',
]
static values = {
inline: Boolean,
minDate: String,
dateFrom: String,
dateTo: String,
enabledDates: Array,
}
initialize() {
useDispatch(this)
const inline = this.hasInlineValue ? this.inlineValue : true
this.picker = flatpickr(this.fieldTarget, {
mode: 'range',
locale: German,
inline,
minDate: this.minDateValue,
altFormat: 'd.m.Y',
altInput: !inline,
onChange: selectedDates => {
if (selectedDates.length === 2) {
this.dateFromValue = flatpickr.formatDate(selectedDates[0], 'Y-m-d')
this.dateToValue = flatpickr.formatDate(selectedDates[1], 'Y-m-d')
this.update()
}
}
})
if (this.hasEnabledDatesValue) {
let enabledDates = this.enabledDatesValue
let minDate = enabledDates[0]
let maxDate = enabledDates[enabledDates.length - 1]
if (this.hasMinDateValue && this.minDateValue > minDate) {
minDate = this.minDateValue
}
this.picker.set('enable', enabledDates)
this.picker.set('minDate', minDate)
this.picker.set('maxDate', maxDate)
this.picker.jumpToDate(minDate)
this.picker.set('onDayCreate', (dObj, dStr, fp, dayElem) => {
let day = flatpickr.formatDate(dayElem.dateObj, 'Y-m-d')
if (day >= minDate && -1 !== this.enabledDatesValue.indexOf(day)) {
dayElem.classList.add('available')
}
})
}
}
connect() {
if ('' !== this.dateFromValue && '' !== this.dateToValue) {
let dateFrom = new Date(this.dateFromValue)
let dateTo = new Date(this.dateToValue)
this.picker.setDate([ dateFrom, dateTo ])
}
}
selectPreset(e) {
e.preventDefault()
const preset = JSON.parse(e.currentTarget.dataset.preset)
this.dateFromValue = preset.dateFrom
this.dateToValue = preset.dateTo
let dateFrom = new Date(preset.dateFrom)
let dateTo = new Date(preset.dateTo)
this.picker.setDate([ dateFrom, dateTo ])
this.update()
}
reset(e) {
e.preventDefault()
this.picker.clear()
this.picker.jumpToDate()
this.dateFromValue = ''
this.dateToValue = ''
this.update()
}
update() {
// Set values to form fields if applicable
if (this.hasDateFromTarget) {
this.dateFromTarget.value = this.dateFromValue
}
if (this.hasDateToTarget) {
this.dateToTarget.value = this.dateToValue
}
// Dispatch event with selected values and formatted range label
let label = ''
if (this.dateFromValue && this.dateToValue) {
let dateFrom = new Date(this.dateFromValue)
let dateTo = new Date(this.dateToValue)
label = `${flatpickr.formatDate(dateFrom, 'd.m.Y')}-${flatpickr.formatDate(dateTo, 'd.m.Y')}`
}
this.dispatch('range-select', {
from: this.dateFromValue,
to: this.dateToValue,
label
})
}
}
@@ -0,0 +1,62 @@
import { Controller } from '@hotwired/stimulus'
import { useFetch } from '../mixins/use_fetch'
export default class extends Controller {
static targets = [
'container',
'loadingIndicator',
'message',
]
static values = {
loading: Boolean,
contingentsUri: String,
roomsUri: String,
hotelUid: Number,
productUid: Number,
dateFrom: String,
dateTo: String,
}
initialize() {
useFetch(this)
}
openModal({ params }) {
let eventName = `${params.type}-modal:open`
this.dispatch(eventName, {
detail: {
type: params.type,
uid: params.uid
}
})
}
load(e) {
this.loadingValue = true
this.dateFromValue = e.detail.from
this.dateToValue = e.detail.to
this.containerTarget.innerHTML = ''
let data = new FormData()
data.set('tx_epproducts_ajax[hotel]', this.hotelUidValue)
data.set('tx_epproducts_ajax[product]', this.productUidValue)
data.set('tx_epproducts_ajax[dateFrom]', this.dateFromValue)
data.set('tx_epproducts_ajax[dateTo]', this.dateToValue)
fetch(this.roomsUriValue, { method: 'POST', body: data })
.then(this.checkStatus)
.then(this.parseHTML)
.then(html => {
this.containerTarget.innerHTML = html
this.messageTarget.classList.add('hidden')
})
.finally(() => {
this.loadingValue = false
})
}
loadingValueChanged(isLoading) {
this.loadingIndicatorTarget.classList.toggle('hidden', false === isLoading)
this.loadingIndicatorTarget.classList.toggle('flex', true === isLoading)
}
}
@@ -0,0 +1,42 @@
import { Controller } from '@hotwired/stimulus'
import { useDebounce } from 'stimulus-use'
export default class extends Controller {
static debounces = [ 'filter' ]
static targets = [ 'entry', 'category', 'empty' ]
initialize() {
useDebounce(this)
}
filter(e) {
let value = e.target.value
if (value.length < 3) {
this.entryTargets.forEach(entry => entry.classList.remove('hidden'))
this.categoryTargets.forEach(category => category.classList.remove('hidden'))
this.toggleEmpty(false)
return
}
const pattern = new RegExp(value, 'i')
this.entryTargets.forEach(entry => {
const question = entry.querySelector('button span').textContent
const answer = entry.querySelector('[data-rte-content]').textContent
entry.classList.toggle('hidden', !question.match(pattern) && !answer.match(pattern))
})
this.categoryTargets.forEach(category => {
const hasVisible = Array.from(category.querySelectorAll('[data-faq-target="entry"]'))
.some(entry => !entry.classList.contains('hidden'))
category.classList.toggle('hidden', !hasVisible)
})
const hasVisible = this.entryTargets.some(entry => !entry.classList.contains('hidden'))
this.toggleEmpty(!hasVisible)
}
toggleEmpty(show) {
if (this.hasEmptyTarget) {
this.emptyTarget.classList.toggle('hidden', !show)
}
}
}
@@ -0,0 +1,25 @@
import { Controller } from '@hotwired/stimulus'
export default class extends Controller {
static targets = ['button']
static classes = [ 'disabled' ]
static values = {
isSubmitting: Boolean,
submittingLabel: { type: String, default: 'wird versendet' }
}
debounce(e) {
if (true === this.isSubmittingValue) {
e.preventDefault()
e.stopPropagation()
return false
}
this.isSubmittingValue = true
this.buttonTarget.innerText = this.submittingLabelValue
if (this.hasDisabledClass) {
this.buttonTarget.classList.add(this.disabledClass)
}
}
}
@@ -0,0 +1,18 @@
import { Controller } from '@hotwired/stimulus';
import iframeResize from '@iframe-resizer/parent';
export default class extends Controller {
static values = {
license: {
type: String,
default: 'GPLv3',
}
}
connect() {
iframeResize({
license: this.licenseValue,
waitForLoad: true
}, this.element)
}
}
@@ -0,0 +1,45 @@
import { Controller } from '@hotwired/stimulus'
import Glightbox from 'glightbox'
export default class extends Controller {
static targets = [ 'thumb' ]
static values = { url: String, height: String, type: String }
connect() {
let elements = []
let type = this.hasTypeValue ? this.typeValue : 'image'
if (this.hasUrlValue) {
let element = { href: this.urlValue, type }
if (this.hasHeightValue) {
element.height = this.heightValue
}
elements.push(element)
} else if (this.element.hasAttribute('href')) {
let element = { href: this.element.href, type }
elements.push(element)
} else {
this.thumbTargets.forEach(thumb => {
let element = { href: thumb.href, type }
let caption = this.element.hasAttribute('data-lightbox-caption') ? this.element.dataset.lightboxCaption : null
if (null !== caption) {
element.title = caption
}
elements.push(element)
})
}
this.lightbox = Glightbox({
elements
})
}
open(e) {
e.preventDefault()
let index = 1
if (e.currentTarget.dataset.lightboxIndex) {
index = e.currentTarget.dataset.lightboxIndex
}
this.lightbox.openAt(index - 1)
}
}
@@ -0,0 +1,80 @@
import { Controller } from '@hotwired/stimulus'
import { useFetch} from '../mixins/use_fetch'
export default class extends Controller {
static targets = [
'form',
'container',
'loadingIndicator',
'dateFrom',
'dateTo',
]
static values = {
uri: String,
initUri: String,
loading: Boolean,
loaded: Boolean,
show: Boolean,
}
initialize() {
useFetch(this)
}
open(e) {
if (e.detail === 'mobile-search') {
this.showValue = true
if (false === this.loadedValue) {
this.load()
}
}
}
close() {
this.showValue = false
}
filter() {
this.load({
method: 'POST',
body: new FormData(this.formTarget)
})
}
reset() {
this.load({ method: 'POST' })
}
load(options) {
let uri = this.loadedValue ? this.uriValue : this.initUriValue
this.loadingValue = true
fetch(uri, options)
.then(this.checkStatus)
.then(this.parseHTML)
.then(html => {
this.containerTarget.innerHTML = html
this.loadedValue = true
})
.finally(() => {
this.loadingValue = false
})
}
selectDateRange(e) {
e.stopPropagation()
this.dateFromTarget.value = e.detail.from
this.dateToTarget.value = e.detail.to
this.filter()
}
showValueChanged() {
this.element.classList.toggle('hidden', false === this.showValue)
}
loadingValueChanged() {
this.containerTarget.classList.toggle('opacity-25', this.loadingValue === true)
this.loadingIndicatorTarget.classList.toggle('hidden', this.loadingValue === false)
}
}
@@ -0,0 +1,22 @@
import { Controller } from '@hotwired/stimulus'
export default class extends Controller {
static targets = [ 'content' ]
open({ detail: { uid } }) {
this.contentTargets.forEach(element => {
let elementUid = parseInt(element.dataset.uid)
element.classList.toggle('hidden', uid !== elementUid)
})
this.element.classList.remove('hidden')
}
close() {
this.element.classList.add('hidden', true)
}
remove() {
this.element.remove()
}
}
@@ -0,0 +1,36 @@
import { Controller } from '@hotwired/stimulus'
import { useClickOutside } from 'stimulus-use'
export default class extends Controller {
static classes = ['hidden']
static targets = ['button', 'subnav']
static values = { expanded: Boolean }
connect() {
useClickOutside(this)
}
toggle(e) {
e.preventDefault()
this.expandedValue = !this.expandedValue
}
clickOutside(e) {
this.expandedValue = false
}
expandedValueChanged(expanded) {
if (this.hasButtonTarget) {
this.buttonTarget.setAttribute('aria-expanded', expanded)
}
if (this.hasSubnavTarget) {
this.subnavTarget.setAttribute('aria-hidden', !expanded)
if (true === expanded) {
this.subnavTarget.classList.remove(...this.hiddenClasses)
} else {
this.subnavTarget.classList.add(...this.hiddenClasses)
}
}
}
}
@@ -0,0 +1,78 @@
import { Controller } from '@hotwired/stimulus'
import L from 'leaflet'
import iconUrl from 'leaflet/dist/images/marker-icon.png'
import iconRetinaUrl from 'leaflet/dist/images/marker-icon-2x.png'
import shadowUrl from 'leaflet/dist/images/marker-shadow.png'
// Icon.Default finds its images by reading the url() off .leaflet-default-icon-path and
// stripping a literal `marker-icon.png` off the end - which a content-hashed filename never
// matches, and the `link[href$="leaflet.css"]` fallback does not exist either because the
// CSS is inlined into the bundle. Dropping the _getIconUrl override falls back to plain
// option lookup, so the URLs Webpack emitted are used as they are.
delete L.Icon.Default.prototype._getIconUrl
L.Icon.Default.mergeOptions({ iconUrl, iconRetinaUrl, shadowUrl })
export default class extends Controller {
static values = {
lat: Number,
lng: Number,
zoom: Number,
externalLink: String,
markers: Array,
tileUrl: String,
apiKey: String,
attribution: String,
}
connect() {
this.map = L.map(this.element, {
scrollWheelZoom: false
})
const zoom = this.hasZoomValue ? this.zoomValue : 12
this.map.setZoom(zoom)
if (this.hasLatValue && this.hasLngValue) {
const position = L.latLng(this.latValue, this.lngValue)
const marker = L.marker(position)
if (this.hasExternalLinkValue && '' !== this.externalLinkValue) {
marker.on('click', () => {
window.open(this.externalLinkValue, '_blank')
})
} else {
marker.on('click', () => {
window.open('https://www.google.com/maps/search/?api=1&zoom=15&query=' + this.latValue + ',' + this.lngValue, '_blank')
})
}
marker.addTo(this.map)
this.map.setView(position)
} else if (this.hasMarkersValue && this.markersValue.length) {
const bounds = L.latLngBounds()
for (let item of this.markersValue) {
const position = L.latLng(item.lat, item.lng)
const marker = L.marker(position)
const popupContent = '<div data-rte-content=""><strong>' + item.name + '</strong><br>' + item.teaser +
'<br><a href="' + item.uri + '">zu den Details</a></div>'
marker.bindPopup(popupContent)
marker.addTo(this.map)
bounds.extend(position)
}
this.map.fitBounds(bounds)
}
L.tileLayer(this.tileUrl(), {
maxZoom: 19,
// The site sends Referrer-Policy: same-origin, which strips the Referer on
// cross-origin requests. The tile provider needs it to match its key against
// the allowed-domain list, so widen the policy for tile requests only.
referrerPolicy: 'strict-origin-when-cross-origin',
attribution: this.attributionValue
}).addTo(this.map)
}
tileUrl() {
if ('' === this.tileUrlValue || '' === this.apiKeyValue) {
return ''
}
const separator = -1 === this.tileUrlValue.indexOf('?') ? '?' : '&'
return this.tileUrlValue + separator + 'apiKey=' + encodeURIComponent(this.apiKeyValue)
}
}
@@ -0,0 +1,32 @@
import { Controller } from '@hotwired/stimulus'
import { useDispatch } from 'stimulus-use'
export default class extends Controller {
static values = {
id: String,
show: Boolean
}
static targets = [ 'overlay' ]
initialize() {
useDispatch(this)
}
invokeToggle() {
this.dispatch('toggle', this.idValue)
}
toggle(e) {
if (e.detail === this.idValue) {
this.showValue = !this.showValue
}
}
showValueChanged() {
if (this.hasOverlayTarget) {
this.overlayTarget.classList.toggle('hidden', this.showValue === false)
}
}
}
@@ -0,0 +1,185 @@
import { Controller } from '@hotwired/stimulus'
export default class extends Controller {
static targets = ['mount', 'error', 'message', 'button', 'resetButton', 'day', 'month', 'prevButton', 'nextButton']
static values = {
hotelCode: String,
groupsBookingUrl: String,
}
connect() {
this.startDate = null
this.endDate = null
this.currentIndex = 0
// mountTarget carries hx-get, so HTMX fires its events there; listening here
// scopes to this calendar instance and avoids catching events from other HTMX elements.
this.mountTarget.addEventListener('htmx:afterSwap', () => {
this.showMonths(0)
this.showButton()
})
this.mountTarget.addEventListener('htmx:responseError', () => this.showError())
}
showMonths(startIndex) {
this.currentIndex = startIndex
this.monthTargets.forEach((m, i) => {
m.classList.toggle('hidden', i < startIndex || i >= startIndex + 2)
})
if (this.hasPrevButtonTarget) this.prevButtonTarget.disabled = startIndex === 0
if (this.hasNextButtonTarget) this.nextButtonTarget.disabled = startIndex >= this.monthTargets.length - 2
}
prevMonths() {
this.showMonths(Math.max(0, this.currentIndex - 1))
}
nextMonths() {
this.showMonths(Math.min(this.currentIndex + 1, this.monthTargets.length - 2))
}
selectDate(event) {
const btn = event.currentTarget
// cooltipz shows on :focus as well as :hover; blurring dismisses it after a click.
btn.blur()
const date = btn.dataset.date
const status = btn.dataset.status
// All day buttons carry data-action for template simplicity; non-selectable ones are filtered here.
if (!status || status === 'blocked') return
if (this.startDate && this.endDate) {
this.resetSelection()
}
if (!this.startDate) {
// checkout-only days allow departure but not arrival
if (status === 'checkout-only') {
this.showMessage('Bitte wähle einen Anreisetag.')
return
}
this.startDate = date
this.endDate = null
this.updateDisplay()
this.showMessage('Bitte wähle das Abreisedatum.')
this.disableButton()
return
}
if (date === this.startDate) {
this.resetSelection()
return
}
// Normalize so from < to regardless of which date the user clicked first.
const [from, to] = date < this.startDate ? [date, this.startDate] : [this.startDate, date]
if (this.hasBlockedInRange(from, to)) {
this.resetSelection()
this.showMessage('Dieser Zeitraum enthält nicht verfügbare Daten.')
return
}
const startBtn = this.dayTargets.find(b => b.dataset.date === from)
const minNights = parseInt(startBtn?.dataset.minNights) || 0
const nights = (new Date(to) - new Date(from)) / 86400000 // ms → days
// Short-stay warning is advisory only; the booking link is still enabled below.
if (minNights > 0 && nights < minNights) {
this.showMessage(`Weniger als ${minNights} Nächte nur auf Anfrage.`)
} else {
this.hideMessage()
}
this.startDate = from
this.endDate = to
this.updateDisplay()
this.enableButton(from, to)
this.dispatch('range-select', { detail: { dateFrom: from, dateTo: to } })
}
hasBlockedInRange(from, to) {
for (const btn of this.dayTargets) {
const d = btn.dataset.date
// End date is exclusive: guests may check out of a blocked day, so it is not a hard blocker.
if (d >= from && d < to && btn.dataset.status === 'blocked') return true
}
return false
}
updateDisplay() {
for (const btn of this.dayTargets) {
const d = btn.dataset.date
btn.classList.remove('pc-day--pending-start', 'pc-day--selected-start', 'pc-day--selected-end', 'pc-day--in-range')
if (!this.startDate) continue
if (d === this.startDate) {
btn.classList.add(this.endDate ? 'pc-day--selected-start' : 'pc-day--pending-start')
} else if (this.endDate) {
if (d === this.endDate) btn.classList.add('pc-day--selected-end')
else if (d > this.startDate && d < this.endDate) btn.classList.add('pc-day--in-range')
}
}
}
resetSelection() {
this.startDate = null
this.endDate = null
this.updateDisplay()
this.hideMessage()
this.disableButton()
}
reset() {
this.resetSelection()
}
showButton() {
if (this.hasButtonTarget) this.buttonTarget.classList.remove('hidden')
}
enableButton(dateFrom, dateTo) {
if (!this.hasButtonTarget) return
const params = new URLSearchParams({
hotel_code: this.hotelCodeValue,
date_from: dateFrom,
date_to: dateTo,
})
this.buttonTarget.href = `${this.groupsBookingUrlValue}?${params}`
this.buttonTarget.textContent = `${this.formatDate(dateFrom)}–${this.formatDate(dateTo)} Anfragen / Buchen`
this.buttonTarget.classList.remove('opacity-50', 'cursor-not-allowed', 'pointer-events-none')
if (this.hasResetButtonTarget) this.resetButtonTarget.classList.remove('hidden')
}
disableButton() {
if (!this.hasButtonTarget) return
this.buttonTarget.removeAttribute('href')
this.buttonTarget.textContent = 'Anfragen / Buchen'
this.buttonTarget.classList.add('opacity-50', 'cursor-not-allowed', 'pointer-events-none')
if (this.hasResetButtonTarget) this.resetButtonTarget.classList.add('hidden')
}
formatDate(iso) {
const [y, m, d] = iso.split('-')
return `${d}.${m}.${y.slice(2)}`
}
showMessage(text) {
if (this.hasMessageTarget) {
this.messageTarget.textContent = text
}
}
hideMessage() {
if (this.hasMessageTarget) {
this.messageTarget.textContent = ''
}
}
showError() {
if (this.hasErrorTarget) {
this.errorTarget.classList.remove('hidden')
}
}
}
@@ -0,0 +1,106 @@
import { Controller } from '@hotwired/stimulus'
export default class extends Controller {
static targets = [
'row',
'price',
'busIcon',
'surchargeToggleLabel',
'discountToggleLabel',
'rowToggleLabel',
'rowToggleIcon',
]
static values = {
mode: String,
showAllRows: Boolean,
iconSpriteUrl: String,
}
toggleSurcharge() {
this.modeValue = this.modeValue === 'surcharge' ? '' : 'surcharge'
}
toggleDiscount() {
this.modeValue = this.modeValue === 'discount' ? '' : 'discount'
}
toggleRows() {
this.showAllRowsValue = !this.showAllRowsValue
}
openModal({ params }) {
let eventName = `${params.type}-modal:open`
this.dispatch(eventName, {
detail: {
type: params.type,
uid: params.uid
}
})
}
modeValueChanged() {
this.priceTargets.forEach(price => {
let room = parseFloat(price.dataset.room)
let bus = parseFloat(price.dataset.bus)
let discount = parseFloat(price.dataset.discount)
price.innerText = `${this.formatPrice(this.calculatePrice(room, bus, discount))} €`
})
this.busIconTargets.forEach(icon => {
let busPrice = parseFloat(icon.dataset.busPrice)
let busIncluded = !!icon.dataset.busIncluded
icon.classList.toggle('hidden', this.isHideBusIcon(busPrice, busIncluded))
})
if (this.hasSurchargeToggleLabelTarget) {
let labelDefault = this.surchargeToggleLabelTarget.dataset.labelDefault
let labelAlt = this.surchargeToggleLabelTarget.dataset.labelAlt
this.surchargeToggleLabelTarget.innerText = this.modeValue === 'surcharge' ? labelDefault : labelAlt
}
if (this.hasDiscountToggleLabelTarget) {
let labelDefault = this.discountToggleLabelTarget.dataset.labelDefault
let labelAlt = this.discountToggleLabelTarget.dataset.labelAlt
this.discountToggleLabelTarget.innerText = this.modeValue === 'discount' ? labelDefault : labelAlt
}
}
showAllRowsValueChanged() {
let additionalRows = this.rowTargets.slice(5)
if (additionalRows.length) {
additionalRows.forEach(row => {
row.classList.toggle('hidden', this.showAllRowsValue === false)
})
}
if (this.hasRowToggleLabelTarget && this.hasRowToggleIconTarget) {
this.rowToggleLabelTarget.innerText = this.showAllRowsValue ? 'weniger Termine anzeigen' : 'alle Termine anzeigen'
this.rowToggleIconTarget.setAttribute('href', this.showAllRowsValue ? `${this.iconSpriteUrlValue}#icon-minus-circle` : `${this.iconSpriteUrlValue}#icon-plus-circle`)
}
}
calculatePrice(minPrice, busPrice, discount) {
if ('surcharge' === this.modeValue) {
return minPrice + busPrice
}
if ('discount' === this.modeValue) {
return minPrice + discount
}
return minPrice
}
// Keep in sync with EP\EpTheme\ViewHelpers\PriceViewHelper: whole euros
// as before ("229"), German decimals where there are cents ("99,90").
formatPrice(amount) {
let cents = Math.round(amount * 100)
if (cents % 100 === 0) {
return String(cents / 100)
}
return (cents / 100).toFixed(2).replace('.', ',')
}
isHideBusIcon(busPrice, busIncluded) {
return (
busPrice && this.modeValue !== 'surcharge' ||
busIncluded && this.modeValue === 'discount'
)
}
}
@@ -0,0 +1,105 @@
import { Controller } from '@hotwired/stimulus'
import { useFetch } from '../mixins/use_fetch'
import { useConfig } from '../mixins/use_config'
export default class extends Controller {
static targets = [
'loadingIndicator',
'loadingMessage',
'datesTableContainer',
'priceTableContainer',
]
static values = {
datestableUri: String,
loading: Boolean,
loaded: Boolean,
mode: String,
disableTables: Boolean,
}
initialize() {
useFetch(this)
useConfig(this)
}
connect() {
if (false === this.disableTablesValue) {
this.loadDates()
}
}
showDates() {
this.modeValue = 'dates'
}
showPrices() {
this.modeValue = 'prices'
}
switchView(e) {
let selectedView = e.detail
if ('dates' === selectedView) {
this.loadDates()
}
}
loadDates() {
this.modeValue = 'dates'
if (true === this.loadedValue || true === this.disableTablesValue) {
return
}
this.loadingValue = true
let paCode = this.getConfig().paCode
const data = new URLSearchParams()
if (null !== paCode) {
data.append('pa', paCode)
}
this.datesTableContainerTarget.innerHTML = ''
fetch(`${this.datestableUriValue}&${data}`)
.then(this.checkStatus)
.then(this.parseHTML)
.then(html => {
this.datesTableContainerTarget.innerHTML = html
}).catch(() => {
}).finally(() => {
this.loadingValue = false
this.loadedValue = true
})
}
loadPrices({ params }) {
this.loadingValue = true
this.priceTableContainerTarget.innerHTML = ''
this.modeValue = 'prices'
let paCode = this.getConfig().paCode
const data = new URLSearchParams()
if (null !== paCode) {
data.append('pa', paCode)
}
fetch(`${params.pricesUrl}&${data}`)
.then(this.checkStatus)
.then(this.parseHTML)
.then(html => {
this.priceTableContainerTarget.innerHTML = html
}).catch(() => {
}).finally(() => {
this.loadingValue = false
})
}
loadingValueChanged() {
this.loadingMessageTarget.innerText = this.modeValue === 'prices' ? 'Lade Buchungsptionen...' : 'Lade Termine...'
this.loadingIndicatorTarget.classList.toggle('hidden', this.loadingValue === false)
}
modeValueChanged() {
if (this.hasDatesTableContainerTarget) {
this.datesTableContainerTarget.classList.toggle('hidden', this.modeValue === 'prices')
}
if (this.hasPriceTableContainerTarget) {
this.priceTableContainerTarget.classList.toggle('hidden', this.modeValue === 'dates')
}
}
}
@@ -0,0 +1,11 @@
import { Controller } from '@hotwired/stimulus'
export default class extends Controller {
static values = { target: String }
scroll(e) {
e.preventDefault()
document.getElementById(this.targetValue).scrollIntoView({ behavior: 'smooth' })
}
}
@@ -0,0 +1,29 @@
import { Controller } from '@hotwired/stimulus'
import { useDebounce } from 'stimulus-use'
export default class extends Controller {
static debounces = [ 'toggle' ]
static classes = [ 'hidden', 'visible' ]
initialize() {
useDebounce(this)
}
connect() {
window.addEventListener('scroll', () => {
this.toggle()
}, { passive: true })
this.toggle()
}
toggle() {
let isVisible = window.scrollY >= window.innerHeight / 3
this.element.classList.toggle(this.hiddenClass, false === isVisible)
this.element.classList.toggle(this.visibleClass, isVisible)
}
scroll() {
window.scroll({ top: 0, left: 0, behavior: 'smooth' })
}
}
@@ -0,0 +1,59 @@
import { Controller } from '@hotwired/stimulus'
import { useFetch } from '../mixins/use_fetch'
export default class extends Controller {
static values = {
loading: Boolean,
uri: String,
}
static targets = [
'form',
'resultsContainer',
'loadingIndicator',
'dateFrom',
'dateTo',
]
initialize() {
useFetch(this)
}
filter() {
this.load({
method: 'POST',
body: new FormData(this.formTarget)
})
}
reset() {
this.load({ method: 'POST' })
}
load(options) {
this.loadingValue = true
fetch(this.uriValue, options)
.then(this.checkStatus)
.then(this.parseHTML)
.then(html => {
this.resultsContainerTarget.innerHTML = html
window.scroll({ top: 0, left: 0, behavior: 'smooth' })
htmx.process(this.resultsContainerTarget)
})
.finally(() => {
this.loadingValue = false
})
}
selectDateRange(e) {
this.dateFromTarget.value = e.detail.from
this.dateToTarget.value = e.detail.to
this.filter()
}
loadingValueChanged() {
this.resultsContainerTarget.classList.toggle('opacity-25', this.loadingValue === true)
this.loadingIndicatorTarget.classList.toggle('hidden', this.loadingValue === false)
}
}
@@ -0,0 +1,82 @@
import { Controller } from '@hotwired/stimulus'
import { useDispatch } from 'stimulus-use'
export default class extends Controller {
static targets = [
'container',
'dateFrom',
'dateTo',
'destinationUid',
'destinationType',
'pax',
'priceRange',
'dateRangeLabel',
'paxLabel',
'destinationLabel',
'priceRangeLabel',
]
static values = { collapsed: Boolean }
initialize() {
useDispatch(this)
}
setDateRange(e) {
this.dateRangeLabelTarget.value = e.detail.label
this.dateFromTarget.value = e.detail.from
this.dateToTarget.value = e.detail.to
this.dispatch('input', this.getDetails())
}
setPax(e) {
e.preventDefault()
let pax = e.currentTarget.dataset.option
this.paxTarget.value = pax
this.paxLabelTarget.value = pax
this.dispatch('input', this.getDetails())
}
setDestination(e) {
e.preventDefault()
this.destinationUidTarget.value = e.currentTarget.dataset.optionUid
this.destinationTypeTarget.value = e.currentTarget.dataset.optionType
this.destinationLabelTarget.value = e.currentTarget.dataset.optionLabel
this.dispatch('input', this.getDetails())
}
resetDestination(e) {
e.preventDefault()
this.destinationUidTarget.value = ''
this.destinationTypeTarget.value = ''
this.destinationLabelTarget.value = ''
this.dispatch('input', this.getDetails())
}
setPriceRange(e) {
e.preventDefault()
this.priceRangeTarget.value = e.currentTarget.dataset.optionValue
this.priceRangeLabelTarget.value = e.currentTarget.dataset.labelValue
this.dispatch('input', this.getDetails())
}
getDetails() {
return {
dateFrom: this.dateFromTarget.value,
dateTo: this.dateToTarget.value,
pax: this.paxTarget.value,
destinationUid: this.destinationUidTarget.value,
destinationType: this.destinationTypeTarget.value,
priceRange: this.priceRangeTarget.value,
}
}
toggle() {
this.collapsedValue = !this.collapsedValue
}
collapsedValueChanged() {
this.containerTarget.classList.toggle('hidden', this.collapsedValue === true)
}
}
@@ -0,0 +1,14 @@
import { Controller } from '@hotwired/stimulus'
import { useDispatch } from 'stimulus-use'
export default class extends Controller {
initialize() {
useDispatch(this)
}
toggle(e) {
e.preventDefault()
this.dispatch('toggle')
}
}
@@ -0,0 +1,106 @@
import { Controller } from '@hotwired/stimulus'
import Splide from '@splidejs/splide'
const defaultOptions = {
arrows: false,
pagination: false,
perMove: 1,
gap: '1rem',
pauseOnHover: false,
pauseOnFocus: false,
}
const presets = {
header: {
...defaultOptions,
autoplay: true,
type: 'fade',
perPage: 1,
gap: 0,
rewind: true,
},
content: {
...defaultOptions,
rewind: true,
pagination: true,
arrows: true,
gap: 0,
classes: {
pagination: 'slider-pagination',
page: 'slider-pagination__dot',
},
breakpoints: {
768: {
pagination: false,
},
},
},
teasers: {
...defaultOptions,
perPage: 4,
padding: {
right: '2rem',
},
breakpoints: {
1200: {
perPage: 4,
},
1024: {
perPage: 3,
},
960: {
perPage: 2,
},
640: {
perPage: 1,
},
},
},
teasersEmbedded: {
...defaultOptions,
perPage: 2,
padding: {
right: '25%',
},
breakpoints: {
960: {
perPage: 3,
padding: {
right: '10%',
},
},
768: {
perPage: 2,
padding: {
right: '25%',
},
},
640: {
perPage: 2,
padding: {
right: '10%',
},
},
512: {
perPage: 1,
padding: {
right: '10%',
},
},
},
},
}
export default class extends Controller {
static values = { preset: String }
connect() {
let options = {}
let preset = this.presetValue
if (preset in presets) {
options = presets[preset]
}
new Splide(this.element, options).mount()
}
}
@@ -0,0 +1,54 @@
import { Controller } from '@hotwired/stimulus'
import { useDebounce } from 'stimulus-use'
export default class extends Controller {
static debounces = [ 'toggle' ]
static values = {
sticky: Boolean,
classes: String,
offset: Number,
padding: String,
disabled: Boolean,
}
initialize() {
useDebounce(this)
}
connect() {
window.addEventListener('scroll', () => {
this.toggle()
}, { passive: true })
}
disconnect() {
window.removeEventListener('scroll', () => {
this.toggle()
}, { passive: true })
}
toggle() {
if (true === this.disabledValue) {
return
}
this.stickyValue = window.scrollY > this.offsetValue
}
stickyValueChanged(value) {
if (this.hasPaddingValue) {
if (true === value) {
document.body.style.paddingTop = this.paddingValue
} else {
document.body.removeAttribute('style')
}
}
if (!this.hasClassesValue) {
return
}
this.classesValue.split(' ').forEach(className => {
this.element.classList.toggle(className, this.stickyValue)
})
}
}
@@ -0,0 +1,34 @@
import { Controller } from '@hotwired/stimulus'
export default class extends Controller {
static classes = [ 'button', 'buttonActive' ]
static targets = [ 'button', 'tab' ]
static values = { activeTab: String }
connect() {
this.activeTabValue = this.tabTargets[0].dataset.tab
}
select(e) {
let selectedTab = e.currentTarget.dataset.tab
this.activeTabValue = selectedTab
this.dispatch('selected', { detail: selectedTab })
this.dispatch('tab-' + selectedTab)
}
activeTabValueChanged() {
let activeTab = this.activeTabValue
this.tabTargets.forEach(element => {
let currentTab = element.dataset.tab
element.classList.toggle('hidden', activeTab !== currentTab)
})
this.buttonTargets.forEach(element => {
let currentButton = element.dataset.tab
element.classList.toggle(this.buttonClass, activeTab !== currentButton)
element.classList.toggle(this.buttonActiveClass, activeTab === currentButton)
})
}
}
@@ -0,0 +1,37 @@
import { Controller } from '@hotwired/stimulus'
export default class extends Controller {
static classes = [ 'grid' ]
static targets = [
'button',
'container',
]
static values = { disabled: Boolean }
grid(e) {
e.preventDefault()
this.disabledValue = false
this.toggleButtonClass(e)
}
block(e) {
e.preventDefault()
this.disabledValue = true
this.toggleButtonClass(e)
}
toggleButtonClass(e) {
this.buttonTargets.forEach(element => {
element.classList.toggle('opacity-50', element === e.currentTarget)
})
}
disabledValueChanged() {
if (this.hasContainerTarget) {
this.containerTarget.classList.toggle(this.gridClass, this.disabledValue === false)
}
}
}
@@ -0,0 +1,37 @@
import { Controller } from '@hotwired/stimulus'
import { useFetch } from '../mixins/use_fetch'
export default class extends Controller {
static targets = [ 'container', 'loadingIndicator' ]
static values = {
uri: String,
loading: Boolean,
}
initialize() {
useFetch(this)
}
connect() {
this.load()
}
load() {
this.loadingValue = true
let data = new URLSearchParams({
'tx_epproducts_ajax[watchlistUids]': sessionStorage.getItem('myep-watchlist'),
})
fetch(this.uriValue, { method: 'POST', body: data })
.then(this.checkStatus)
.then(this.parseHTML)
.then(html => {
this.containerTarget.innerHTML = html
htmx.process(this.containerTarget)
})
.finally(() => {
this.loadingValue = false
})
}
}
@@ -0,0 +1,30 @@
import { Controller } from '@hotwired/stimulus'
export default class extends Controller {
static values = { count: Number }
static targets = [ 'label', 'icon' ]
connect() {
this.watchlist = JSON.parse(sessionStorage.getItem('myep-watchlist')) || []
this.countValue = this.watchlist.length
}
update(e) {
let key = e.detail.key
let index = this.watchlist.indexOf(key)
if (-1 !== index) {
this.watchlist.splice(index, 1)
} else {
this.watchlist.push(key)
}
this.countValue = this.watchlist.length
sessionStorage.setItem('myep-watchlist', JSON.stringify(this.watchlist))
}
countValueChanged() {
this.iconTarget.setAttribute('fill', this.countValue > 0 ? 'currentColor' : 'none')
this.labelTarget.innerText = `Merkliste (${this.countValue})`
}
}
@@ -0,0 +1,45 @@
import { Controller } from '@hotwired/stimulus'
import { useDispatch } from 'stimulus-use'
export default class extends Controller {
static values = {
key: String,
onList: Boolean
}
static targets = [
'label',
'icon',
'ariaLabel',
]
initialize() {
useDispatch(this)
}
connect() {
let watchlist = JSON.parse(sessionStorage.getItem('myep-watchlist')) || []
this.onListValue = -1 !== watchlist.indexOf(this.keyValue)
}
toggle() {
this.onListValue = !this.onListValue
this.dispatch('toggle', {
key: this.keyValue,
onList: this.onListValue,
})
}
onListValueChanged() {
if (this.hasLabelTarget) {
this.labelTarget.innerText = true === this.onListValue ? 'von der Merkliste entfernen' : 'auf die Merkliste setzen'
}
if (this.hasIconTarget) {
this.iconTarget.setAttribute('fill', true === this.onListValue ? 'currentColor' : 'none')
}
if (this.hasAriaLabelTarget) {
this.ariaLabelTarget.setAttribute('aria-label', true === this.onListValue ? 'von der Merkliste entfernen' : 'auf die Merkliste setzen')
}
}
}
@@ -0,0 +1,5 @@
// Main app
require('./_app');
// Main styles
require('../scss/main.scss');
@@ -0,0 +1,11 @@
export const useConfig = controller => {
Object.assign(controller, {
getConfig() {
const configElement = document.getElementById('appconfig')
if (null === configElement) {
return {}
}
return JSON.parse(configElement.innerHTML)
}
})
}
@@ -0,0 +1,19 @@
export const useFetch = controller => {
Object.assign(controller, {
checkStatus(response) {
if (response.status >= 200 && response.status < 300) {
return response
} else {
const error = new Error(response.statusText)
error.response = response
throw error
}
},
parseJSON(response) {
return response.json()
},
parseHTML(response) {
return response.text()
}
})
}