'
+Vue.component('PretixWidgetEventForm', {
+ data: function () {
+ return {
+ is_items_selected: false,
+ }
+ },
+ computed: {
+ id_voucher_input: function () {
+ return this.$root.html_id + '-voucher-input'
+ },
+ aria_labelledby: function () {
+ return this.$root.html_id + '-voucher-headline'
+ },
+ display_event_info: function () {
+ return this.$root.display_event_info || (this.$root.display_event_info === null && (this.$root.events || this.$root.weeks || this.$root.days))
+ },
+ id_cart_exists_msg: function () {
+ return this.$root.html_id + '-cart-exists'
+ },
+ buy_label: function () {
+ let i, j, k, all_free = true
+ for (i = 0; i < this.$root.categories.length; i++) {
+ let cat = this.$root.categories[i]
+ for (j = 0; j < cat.items.length; j++) {
+ let item = cat.items[j]
+ for (k = 0; k < item.variations.length; k++) {
+ let v = item.variations[k]
+ if (v.price.gross !== '0.00') {
+ all_free = false
+ break
+ }
+ }
+ if ((item.variations.length === 0 && item.price.gross !== '0.00') || item.mandatory_priced_addons) {
+ all_free = false
+ break
+ }
+ }
+ if (!all_free) {
+ break
+ }
+ }
+ if (all_free) {
+ return strings.register
+ } else {
+ return strings.buy
+ }
+ },
+ hiddenParams: function () {
+ let params = new URL(this.$root.voucherFormTarget).searchParams
+ params.delete('iframe')
+ params.delete('take_cart_id')
+ return [...params.entries()]
+ },
+ },
+ watch: {
+ '$root.overlay.frame_shown': function (newValue) {
+ if (!newValue) {
+ this.$refs.form.reset()
+ this.calc_items_selected()
+ }
+ }
+ },
+ mounted: function () {
+ this.$root.$on('focus_voucher_field', this.focus_voucher_field)
+ this.$refs.form.addEventListener('change', this.calc_items_selected)
+ },
+ beforeUnmount: function () {
+ this.$root.$off('focus_voucher_field', this.focus_voucher_field)
+ this.$refs.form.removeEventListener('change', this.calc_items_selected)
+ },
+ methods: {
+ back_to_list: function () {
+ this.$root.target_url = this.$root.parent_stack.pop()
+ this.$root.error = null
+ if (!this.$root.subevent) {
+ // reset if we are not in a series
+ this.$root.name = null
+ this.$root.frontpage_text = null
+ }
+ this.$root.subevent = null
+ this.$root.offset = 0
+ this.$root.append_events = false
+ this.$root.trigger_load_callback()
+ if (this.$root.events !== undefined && this.$root.events !== null) {
+ this.$root.view = 'events'
+ } else if (this.$root.days !== undefined && this.$root.days !== null) {
+ this.$root.view = 'days'
+ } else {
+ this.$root.view = 'weeks'
+ }
- // Event name
- + ''
+ let $el = this.$root.$el
+ this.$root.$nextTick(function () {
+ // wait for redraw, then focus content element for better a11y
+ $el.focus()
+ })
+ },
+ calc_items_selected: function () {
+ this.is_items_selected = [...this.$refs.form.querySelectorAll('input[type=checkbox], input[type=radio]')].some(function (element) {
+ return element.checked
+ }) || [...this.$refs.form.querySelectorAll('.pretix-widget-item-count-group input')].some(function (element) {
+ return parseInt(element.value || '0') > 0
+ })
+ },
+ },
+ template: ('
'
+ // Back navigation
+ + '
'
- // Date range
- + '
'
- + '{{ $root.date_range }}'
- + '
'
+ // Event name
+ + ''
- // Location
- + '
'
+ // Date range
+ + '
'
+ + '{{ $root.date_range }}'
+ + '
'
- // Form start
- + '
'
- + '
'
+ // Buy button
+ + '
'
+ + ''
+ + ''
+ + '
'
- // Voucher form
- + '
'),
- methods: {
- onSubmit: function(e) {
- e.preventDefault();
- var formData = new FormData(this.$refs.filterform);
- var filterParams = new URLSearchParams(formData);
- formData.forEach(function (value, key) {
- if (value == "") {
- filterParams.delete(key);
- }
- });
+ this.$root.filter = filterParams.toString()
+ this.$root.loading++
+ this.$root.reload()
+ },
+ },
+ template: ('
'),
+})
- this.$root.filter = filterParams.toString();
- this.$root.loading++;
- this.$root.reload();
- },
- },
-});
+Vue.component('PretixWidgetEventListEntry', {
+ props: {
+ event: Object
+ },
+ computed: {
+ classObject: function () {
+ let o = {
+ 'pretix-widget-event-list-entry': true
+ }
+ o['pretix-widget-event-availability-' + this.event.availability.color] = true
+ if (this.event.availability.reason) {
+ o['pretix-widget-event-availability-' + this.event.availability.reason] = true
+ }
+ return o
+ },
+ location: function () {
+ return this.event.location.replace(/\s*\n\s*/g, ', ')
+ }
+ },
+ methods: {
+ select: function () {
+ this.$root.parent_stack.push(this.$root.target_url)
+ this.$root.target_url = this.event.event_url
+ this.$root.error = null
+ this.$root.subevent = this.event.subevent
+ this.$root.loading++
+ this.$root.reload()
+ }
+ },
+ template: ('
'
+ + '{{ event.name }}
'
+ + '{{ event.date_range }}
'
+ + '{{ location }}
' // hidden by css for now, but
+ // used by a few people
+ + '{{ event.availability.text }}
'
+ + '')
+})
-Vue.component('pretix-widget-event-list-entry', {
- template: ('
'
- + '{{ event.name }}
'
- + '{{ event.date_range }}
'
- + '{{ location }}
' // hidden by css for now, but
- // used by a few people
- + '{{ event.availability.text }}
'
- + ''),
- props: {
- event: Object
- },
- computed: {
- classObject: function () {
- var o = {
- 'pretix-widget-event-list-entry': true
- };
- o['pretix-widget-event-availability-' + this.event.availability.color] = true;
- if (this.event.availability.reason) {
- o['pretix-widget-event-availability-' + this.event.availability.reason] = true;
- }
- return o;
- },
- location: function () {
- return this.event.location.replace(/\s*\n\s*/g, ', ');
- }
- },
- methods: {
- select: function () {
- this.$root.parent_stack.push(this.$root.target_url);
- this.$root.target_url = this.event.event_url;
- this.$root.error = null;
- this.$root.subevent = this.event.subevent;
- this.$root.loading++;
- this.$root.reload();
- }
- }
-});
+Vue.component('PretixWidgetEventList', {
+ computed: {
+ display_event_info: function () {
+ return this.$root.display_event_info || (this.$root.display_event_info === null && this.$root.parent_stack.length > 0)
+ },
+ },
+ methods: {
+ back_to_calendar: function () {
+ // make sure to always focus content element
+ this.$nextTick(function () {
+ this.$root.$el.focus()
+ })
+ this.$root.offset = 0
+ this.$root.append_events = false
+ if (this.$root.weeks) {
+ this.$root.events = undefined
+ this.$root.view = 'weeks'
+ this.$root.name = null
+ this.$root.frontpage_text = null
+ } else {
+ this.$root.loading++
+ this.$root.target_url = this.$root.parent_stack.pop()
+ this.$root.error = null
+ this.$root.reload()
+ }
+ },
+ load_more: function () {
+ this.$root.append_events = true
+ this.$root.offset += 50
+ this.$root.loading++
+ this.$root.reload()
+ }
+ },
+ template: ('
')
+})
-Vue.component('pretix-widget-event-list', {
- template: ('
'),
- computed: {
- display_event_info: function () {
- return this.$root.display_event_info || (this.$root.display_event_info === null && this.$root.parent_stack.length > 0);
- },
- },
- methods: {
- back_to_calendar: function () {
- // make sure to always focus content element
- this.$nextTick(function () {
- this.$root.$el.focus();
- });
- this.$root.offset = 0;
- this.$root.append_events = false;
- if (this.$root.weeks) {
- this.$root.events = undefined;
- this.$root.view = "weeks";
- this.$root.name = null;
- this.$root.frontpage_text = null;
- } else {
- this.$root.loading++;
- this.$root.target_url = this.$root.parent_stack.pop();
- this.$root.error = null;
- this.$root.reload();
- }
- },
- load_more: function () {
- this.$root.append_events = true;
- this.$root.offset += 50;
- this.$root.loading++;
- this.$root.reload();
- }
- }
-});
+Vue.component('PretixWidgetEventCalendarEvent', {
+ props: {
+ event: Object,
+ describedby: String,
+ },
+ computed: {
+ classObject: function () {
+ let o = {
+ 'pretix-widget-event-calendar-event': true
+ }
+ o['pretix-widget-event-availability-' + this.event.availability.color] = true
+ if (this.event.availability.reason) {
+ o['pretix-widget-event-availability-' + this.event.availability.reason] = true
+ }
+ return o
+ }
+ },
+ methods: {
+ select: function () {
+ this.$root.parent_stack.push(this.$root.target_url)
+ this.$root.target_url = this.event.event_url
+ this.$root.error = null
+ this.$root.subevent = this.event.subevent
+ this.$root.loading++
+ this.$root.reload()
+ }
+ },
+ template: ('
'
+ + ''
+ + '{{ event.name }}'
+ + ''
+ + '{{ event.time }}
'
+ + '{{ event.availability.text }}
'
+ + '')
+})
-Vue.component('pretix-widget-event-calendar-event', {
- template: ('
'
- + ''
- + '{{ event.name }}'
- + ''
- + '{{ event.time }}
'
- + '{{ event.availability.text }}
'
- + ''),
- props: {
- event: Object,
- describedby: String,
- },
- computed: {
- classObject: function () {
- var o = {
- 'pretix-widget-event-calendar-event': true
- };
- o['pretix-widget-event-availability-' + this.event.availability.color] = true;
- if (this.event.availability.reason) {
- o['pretix-widget-event-availability-' + this.event.availability.reason] = true;
- }
- return o
- }
- },
- methods: {
- select: function () {
- this.$root.parent_stack.push(this.$root.target_url);
- this.$root.target_url = this.event.event_url;
- this.$root.error = null;
- this.$root.subevent = this.event.subevent;
- this.$root.loading++;
- this.$root.reload();
- }
- }
-});
+Vue.component('PretixWidgetEventWeekCell', {
+ props: {
+ day: Object,
+ },
+ computed: {
+ id: function () {
+ return this.day ? this.$root.html_id + '-' + this.day.date : ''
+ },
+ dayhead: function () {
+ if (!this.day) {
+ return
+ }
+ return this.day.day_formatted
+ },
+ classObject: function () {
+ let o = {}
+ if (this.day && this.day.events.length > 0) {
+ o['pretix-widget-has-events'] = true
+ let best = 'red'
+ let all_low = true
+ for (let i = 0; i < this.day.events.length; i++) {
+ let ev = this.day.events[i]
+ if (ev.availability.color === 'green') {
+ best = 'green'
+ if (ev.availability.reason !== 'low') {
+ all_low = false
+ }
+ } else if (ev.availability.color === 'orange' && best !== 'green') {
+ best = 'orange'
+ }
+ }
+ o['pretix-widget-day-availability-' + best] = true
+ if (best === 'green' && all_low) {
+ o['pretix-widget-day-availability-low'] = true
+ }
+ }
+ return o
+ }
+ },
+ methods: {
+ selectDay: function () {
+ if (!this.day || !this.day.events.length || !this.$parent.$parent.$parent.mobile) {
+ return
+ }
+ if (this.day.events.length === 1) {
+ let ev = this.day.events[0]
+ this.$root.parent_stack.push(this.$root.target_url)
+ this.$root.target_url = ev.event_url
+ this.$root.error = null
+ this.$root.subevent = ev.subevent
+ this.$root.loading++
+ this.$root.reload()
+ } else {
+ this.$root.events = this.day.events
+ this.$root.view = 'events'
+ }
+ }
+ },
+ template: ('
'
+ + '
'
+ + '{{ dayhead }}'
+ + '
'
+ + '
'
+ + '
')
+})
-Vue.component('pretix-widget-event-week-cell', {
- template: ('
'
- + '
'
- + '{{ dayhead }}'
- + '
'
- + '
'
- + '
'),
- props: {
- day: Object,
- },
- methods: {
- selectDay: function () {
- if (!this.day || !this.day.events.length || !this.$parent.$parent.$parent.mobile) {
- return;
- }
- if (this.day.events.length === 1) {
- var ev = this.day.events[0];
- this.$root.parent_stack.push(this.$root.target_url);
- this.$root.target_url = ev.event_url;
- this.$root.error = null;
- this.$root.subevent = ev.subevent;
- this.$root.loading++;
- this.$root.reload();
- } else {
- this.$root.events = this.day.events;
- this.$root.view = "events";
- }
- }
- },
- computed: {
- id: function () {
- return this.day ? this.$root.html_id + '-' + this.day.date : '';
- },
- dayhead: function () {
- if (!this.day) {
- return;
- }
- return this.day.day_formatted;
- },
- classObject: function () {
- var o = {};
- if (this.day && this.day.events.length > 0) {
- o['pretix-widget-has-events'] = true;
- var best = 'red';
- var all_low = true;
- for (var i = 0; i < this.day.events.length; i++) {
- var ev = this.day.events[i];
- if (ev.availability.color === 'green') {
- best = 'green';
- if (ev.availability.reason !== 'low') {
- all_low = false;
- }
- } else if (ev.availability.color === 'orange' && best !== 'green') {
- best = 'orange'
- }
- }
- o['pretix-widget-day-availability-' + best] = true;
- if (best === 'green' && all_low) {
- o['pretix-widget-day-availability-low'] = true;
- }
- }
- return o
- }
- }
-});
+Vue.component('PretixWidgetEventCalendarCell', {
+ props: {
+ day: Object,
+ },
+ computed: {
+ role: function () {
+ return (!this.day || !this.day.events.length || !this.$parent.$parent.$parent.mobile) ? 'cell' : 'button'
+ },
+ tabindex: function () {
+ return this.role == 'button' ? '0' : '-1'
+ },
+ daynum: function () {
+ if (!this.day) {
+ return
+ }
+ return this.day.date.substr(8)
+ },
+ date: function () {
+ return this.day ? (new Date(this.day.date)).toLocaleDateString() : ''
+ },
+ classObject: function () {
+ let o = {}
+ if (this.day && this.day.events.length > 0) {
+ o['pretix-widget-has-events'] = true
+ let best = 'red'
+ let all_low = true
+ for (let i = 0; i < this.day.events.length; i++) {
+ let ev = this.day.events[i]
+ if (ev.availability.color === 'green') {
+ best = 'green'
+ if (ev.availability.reason !== 'low') {
+ all_low = false
+ }
+ } else if (ev.availability.color === 'orange' && best !== 'green') {
+ best = 'orange'
+ }
+ }
+ o['pretix-widget-day-availability-' + best] = true
+ if (best === 'green' && all_low) {
+ o['pretix-widget-day-availability-low'] = true
+ }
+ }
+ return o
+ }
+ },
+ watch: {
+ role: function (newValue) {
+ if (newValue == 'button') {
+ this.$el.addEventListener('click', this.selectDay)
+ this.$el.addEventListener('keydown', this.onKeyDown)
+ } else {
+ this.$el.removeEventListener('click', this.selectDay)
+ this.$el.removeEventListener('keydown', this.onKeyDown)
+ }
+ }
+ },
+ mounted: function () {
+ if (this.role == 'button') {
+ this.$el.addEventListener('click', this.selectDay)
+ this.$el.addEventListener('keydown', this.onKeyDown)
+ }
+ },
+ methods: {
+ selectDay: function (e) {
+ if (!this.day || !this.day.events.length || !this.$parent.$parent.$parent.mobile) {
+ return
+ }
+ e.preventDefault()
+ e.stopPropagation()
+ if (this.day.events.length === 1) {
+ let ev = this.day.events[0]
+ this.$root.parent_stack.push(this.$root.target_url)
+ this.$root.target_url = ev.event_url
+ this.$root.error = null
+ this.$root.subevent = ev.subevent
+ this.$root.loading++
+ this.$root.reload()
+ } else {
+ this.$root.events = this.day.events
+ this.$root.view = 'events'
+ }
+ },
+ onKeyDown: function (e) {
+ let keyDown = e.key !== undefined ? e.key : e.keyCode
+ if ((keyDown === 'Enter' || keyDown === 13) || (['Spacebar', ' '].indexOf(keyDown) >= 0 || keyDown === 32)) {
+ // (prevent default so the page doesn't scroll when pressing space)
+ e.preventDefault()
+ this.selectDay(e)
+ }
+ },
+ },
+ template: ('
'
+ + ' '
+ + '{{ daynum }}'
+ + ' '
+ + ''
+ + ' | ')
+})
-Vue.component('pretix-widget-event-calendar-cell', {
- template: ('
'
- + ' '
- + '{{ daynum }}'
- + ' '
- + ''
- + ' | '),
- props: {
- day: Object,
- },
- methods: {
- selectDay: function (e) {
- if (!this.day || !this.day.events.length || !this.$parent.$parent.$parent.mobile) {
- return;
- }
- e.preventDefault();
- e.stopPropagation();
- if (this.day.events.length === 1) {
- var ev = this.day.events[0];
- this.$root.parent_stack.push(this.$root.target_url);
- this.$root.target_url = ev.event_url;
- this.$root.error = null;
- this.$root.subevent = ev.subevent;
- this.$root.loading++;
- this.$root.reload();
- } else {
- this.$root.events = this.day.events;
- this.$root.view = "events";
- }
- },
- onKeyDown: function (e) {
- var keyDown = e.key !== undefined ? e.key : e.keyCode;
- if ( (keyDown === 'Enter' || keyDown === 13) || (['Spacebar', ' '].indexOf(keyDown) >= 0 || keyDown === 32)) {
- // (prevent default so the page doesn't scroll when pressing space)
- e.preventDefault();
- this.selectDay(e);
- }
- },
- },
- mounted: function () {
- if (this.role == 'button') {
- this.$el.addEventListener("click", this.selectDay);
- this.$el.addEventListener("keydown", this.onKeyDown);
- }
- },
- watch: {
- role: function (newValue) {
- if (newValue == 'button') {
- this.$el.addEventListener("click", this.selectDay);
- this.$el.addEventListener("keydown", this.onKeyDown);
- } else {
- this.$el.removeEventListener("click", this.selectDay);
- this.$el.removeEventListener("keydown", this.onKeyDown);
- }
- }
- },
- computed: {
- role: function () {
- return (!this.day || !this.day.events.length || !this.$parent.$parent.$parent.mobile) ? 'cell' : 'button';
- },
- tabindex: function () {
- return this.role == 'button' ? '0' : '-1';
- },
- daynum: function () {
- if (!this.day) {
- return;
- }
- return this.day.date.substr(8);
- },
- date: function () {
- return this.day ? (new Date(this.day.date)).toLocaleDateString() : '';
- },
- classObject: function () {
- var o = {};
- if (this.day && this.day.events.length > 0) {
- o['pretix-widget-has-events'] = true;
- var best = 'red';
- var all_low = true;
- for (var i = 0; i < this.day.events.length; i++) {
- var ev = this.day.events[i];
- if (ev.availability.color === 'green') {
- best = 'green';
- if (ev.availability.reason !== 'low') {
- all_low = false;
- }
- } else if (ev.availability.color === 'orange' && best !== 'green') {
- best = 'orange'
- }
- }
- o['pretix-widget-day-availability-' + best] = true;
- if (best === 'green' && all_low) {
- o['pretix-widget-day-availability-low'] = true;
- }
- }
- return o
- }
- }
-});
+Vue.component('PretixWidgetEventCalendarRow', {
+ props: {
+ week: Array
+ },
+ template: ('
'
+ + ''
+ + '
'),
+})
-Vue.component('pretix-widget-event-calendar-row', {
- template: ('
'
- + ''
- + '
'),
- props: {
- week: Array
- },
-});
+Vue.component('PretixWidgetEventCalendar', {
+ computed: {
+ display_event_info: function () {
+ return this.$root.display_event_info || (this.$root.display_event_info === null && this.$root.parent_stack.length > 0)
+ },
+ monthname: function () {
+ return strings['months'][this.$root.date.substr(5, 2)] + ' ' + this.$root.date.substr(0, 4)
+ },
+ id: function () {
+ return this.$root.html_id + '-event-calendar-table'
+ },
+ aria_labelledby: function () {
+ return this.$root.html_id + '-event-calendar-table-label'
+ },
+ },
+ methods: {
+ back_to_list: function () {
+ this.$root.weeks = undefined
+ this.$root.view = 'events'
+ this.$root.name = null
+ this.$root.frontpage_text = null
+ },
+ prevmonth: function () {
+ let curMonth = parseInt(this.$root.date.substr(5, 2))
+ let curYear = parseInt(this.$root.date.substr(0, 4))
+ curMonth--
+ if (curMonth < 1) {
+ curMonth = 12
+ curYear--
+ }
+ this.$root.date = String(curYear) + '-' + padNumber(curMonth, 2) + '-01'
+ this.$root.loading++
+ this.$root.reload({ focus: '#' + this.id })
+ },
+ nextmonth: function () {
+ let curMonth = parseInt(this.$root.date.substr(5, 2))
+ let curYear = parseInt(this.$root.date.substr(0, 4))
+ curMonth++
+ if (curMonth > 12) {
+ curMonth = 1
+ curYear++
+ }
+ this.$root.date = String(curYear) + '-' + padNumber(curMonth, 2) + '-01'
+ this.$root.loading++
+ this.$root.reload({ focus: '#' + this.id })
+ }
+ },
+ template: ('
'),
- computed: {
- display_event_info: function () {
- return this.$root.display_event_info || (this.$root.display_event_info === null && this.$root.parent_stack.length > 0);
- },
- monthname: function () {
- return strings['months'][this.$root.date.substr(5, 2)] + ' ' + this.$root.date.substr(0, 4);
- },
- id: function () {
- return this.$root.html_id + "-event-calendar-table";
- },
- aria_labelledby: function () {
- return this.$root.html_id + "-event-calendar-table-label";
- },
- },
- methods: {
- back_to_list: function () {
- this.$root.weeks = undefined;
- this.$root.view = "events";
- this.$root.name = null;
- this.$root.frontpage_text = null;
- },
- prevmonth: function () {
- var curMonth = parseInt(this.$root.date.substr(5, 2));
- var curYear = parseInt(this.$root.date.substr(0, 4));
- curMonth--;
- if (curMonth < 1) {
- curMonth = 12;
- curYear--;
- }
- this.$root.date = String(curYear) + "-" + padNumber(curMonth, 2) + "-01";
- this.$root.loading++;
- this.$root.reload({focus: '#'+this.id});
- },
- nextmonth: function () {
- var curMonth = parseInt(this.$root.date.substr(5, 2));
- var curYear = parseInt(this.$root.date.substr(0, 4));
- curMonth++;
- if (curMonth > 12) {
- curMonth = 1;
- curYear++;
- }
- this.$root.date = String(curYear) + "-" + padNumber(curMonth, 2) + "-01";
- this.$root.loading++;
- this.$root.reload({focus: '#'+this.id});
- }
- },
-});
+Vue.component('PretixWidgetEventWeekCalendar', {
+ computed: {
+ display_event_info: function () {
+ return this.$root.display_event_info || (this.$root.display_event_info === null && this.$root.parent_stack.length > 0)
+ },
+ weekname: function () {
+ let curWeek = this.$root.week[1]
+ let curYear = this.$root.week[0]
+ return curWeek + ' / ' + curYear
+ },
+ id: function () {
+ return this.$root.html_id + '-event-week-table'
+ },
+ },
+ methods: {
+ back_to_list: function () {
+ this.$root.weeks = undefined
+ this.$root.name = null
+ this.$root.frontpage_text = null
+ this.$root.view = 'events'
+ },
+ prevweek: function () {
+ let curWeek = this.$root.week[1]
+ let curYear = this.$root.week[0]
+ curWeek--
+ if (curWeek < 1) {
+ curYear--
+ curWeek = getISOWeeks(curYear)
+ }
+ this.$root.week = [curYear, curWeek]
+ this.$root.loading++
+ this.$root.reload({ focus: '#' + this.id })
+ },
+ nextweek: function () {
+ let curWeek = this.$root.week[1]
+ let curYear = this.$root.week[0]
+ curWeek++
+ if (curWeek > getISOWeeks(curYear)) {
+ curWeek = 1
+ curYear++
+ }
+ this.$root.week = [curYear, curWeek]
+ this.$root.loading++
+ this.$root.reload({ focus: '#' + this.id })
+ }
+ },
+ template: ('
'),
+})
- + '