103 lines
3.8 KiB
TypeScript
103 lines
3.8 KiB
TypeScript
import * as Communication from "./communication";
|
|
import * as UI from "./ui";
|
|
import { config } from "./config";
|
|
import * as XMLHelper from "./xmlhelper";
|
|
import * as I from "../types/types";
|
|
import * as JSC from "./jsc";
|
|
import * as Cart from "./cart";
|
|
|
|
export function addCloseModal(): void {
|
|
const btnCloseModal: HTMLElement | undefined = jQuery("#btnCloseModal").get(0);
|
|
if (btnCloseModal)
|
|
btnCloseModal.addEventListener("click", () => Communication.sendEventToParent("child_closeDialog"));
|
|
}
|
|
|
|
export function addDropdownSeatmap(inPanzoom: any): void {
|
|
const dropdownSeatmap: HTMLElement | null = document.getElementById("dropdownSeatmap");
|
|
|
|
if (dropdownSeatmap) {
|
|
dropdownSeatmap.addEventListener("change", function (this: HTMLSelectElement) {
|
|
UI.controlLoftloader("show"); // todo: rewrite?
|
|
UI.destroyCurrentSeatmap("#containerSeatmapInner", inPanzoom);
|
|
Communication.needSeatmapXML(this.value);
|
|
});
|
|
}
|
|
}
|
|
|
|
export function addModalCart(): void {
|
|
const btnCart: HTMLElement | undefined = jQuery("#modalCart .uabb-button").get(0);
|
|
|
|
if (btnCart) {
|
|
btnCart.addEventListener("click", () => {
|
|
if (!config.state.selectedSeatsArr.length)
|
|
UI.showJBoxNotice(`Sie haben bislang keinen Platz ausgewählt.`);
|
|
else if (config.state.cartChanged)
|
|
XMLHelper.isValidSeatSelection();
|
|
else if (!config.state.cartChanged && config.state.isValidSeatSelection)
|
|
UI.showModalCart();
|
|
else if (!config.state.cartChanged && !config.state.isValidSeatSelection)
|
|
UI.showJBoxNotice(`Auswahl nicht möglich: Bitte lassen Sie keinen einzelnen Platz frei.`);
|
|
});
|
|
}
|
|
}
|
|
|
|
export function addRedirectCheckout(inUrl: string | undefined): void {
|
|
if (!inUrl)
|
|
return;
|
|
|
|
const btnCheckout = jQuery("#modalCart-overlay #checkout .fl-button").get(0);
|
|
if (btnCheckout) {
|
|
btnCheckout.addEventListener("click", () => {
|
|
const message: I.Message = {
|
|
message: {
|
|
url: inUrl,
|
|
},
|
|
from: "child",
|
|
event: "child_click_checkout",
|
|
date: Date.now()
|
|
};
|
|
Communication.sendMessage(message, "parent");
|
|
});
|
|
}
|
|
}
|
|
|
|
export function addCartClose(): void {
|
|
const btnClose: HTMLElement = jQuery("#modalCart-overlay .uabb-close-icon").get(0);
|
|
if (btnClose)
|
|
btnClose.addEventListener("click", () => Communication.sendEventToParent("child_show_dialog_titlebar"));
|
|
}
|
|
|
|
export function addCartBack(): void {
|
|
const btnBack: HTMLElement = jQuery("#modalCart-overlay #goBack .fl-button").get(0);
|
|
if (btnBack)
|
|
btnBack.addEventListener("click", () => jQuery("#modalCart-overlay .uabb-close-icon").trigger("click"));
|
|
}
|
|
|
|
export function dropdownLegendOnChange(inSelector: string): void {
|
|
const seatmap: any = config.state.seatmap;
|
|
const dropdownLegend: HTMLElement = jQuery(inSelector).get(0);
|
|
|
|
dropdownLegend.addEventListener("change", function (this: HTMLSelectElement) {
|
|
const value: string = this.value;
|
|
const className: string = `._${value}`;
|
|
|
|
UI.changeDropdownLegendBGColor(inSelector, value, className);
|
|
|
|
if (value === "all") {
|
|
seatmap.find('unavailable').status('available');
|
|
JSC.setUnavailableSeats();
|
|
}
|
|
else {
|
|
seatmap.find('available').status('unavailable');
|
|
JSC.activateSeatsBySectionID(value);
|
|
JSC.setUnavailableSeats();
|
|
}
|
|
});
|
|
}
|
|
|
|
export function addCartDropdownBuyerTypes(inSelector: string, inSeatObj: I.JSCSelectedSeat): void {
|
|
// todo: which variant is not deprecated?
|
|
jQuery(inSelector).on('change', function (this: HTMLSelectElement) {
|
|
Cart.changedDropdownBuyerType(this, inSeatObj);
|
|
});
|
|
} |