import {EtrackerUtils} from "./EtrackerUtils"; export class UiUtils { static initUI() { UiUtils.initPrintDialog(); UiUtils.initfileupload(); UiUtils.initTrackEventElementAnalytics(); UiUtils.disbaleInitialForNewsletterSubPage(); UiUtils.initEtrackerOnCookiebotEvent(); } static initEtrackerOnCookiebotEvent() { if (typeof ihk !== "undefined" && ihk.settings && ihk.settings.etrackerCookieless === false) { window.addEventListener('CookiebotOnConsentReady', EtrackerUtils.initEtrackerCookies, false); } } static initTrackEventElementAnalytics() { if (!window.isPbe) { $(".trackEventElement").each( function () { const category = $(this).data( 'analytics-category'); const object = $(this).data('analytics-object'); const action = $(this).data('analytics-action'); const tags = $(this).data('analytics-tags'); window.setTimeout(EtrackerUtils.fireETrackerEvent, 250, category, object, action, tags); }); } } static disbaleInitialForNewsletterSubPage() { const inxForm = $(".inxform"); const inxHolderText = $(inxForm).closest(".detail-text"); if (inxHolderText.length > 0) { inxHolderText.find(".text").first().addClass("no-initial"); } } static initfileupload() { //todo: make great again if (typeof jQuery.fn.fileupload == 'function') { var filelist = [], uploadUrl = $('#fileupload') .data("url"); $('#fileupload') .fileupload( { url: uploadUrl, previewMaxWidth: "90", previewMaxHeight: "90", previewCrop: true, singleFileUploads: false, filesContainer: $('#uploaded-files'), uploadTemplateId: null, downloadTemplateId: null, uploadTemplate: function (o) { var rows = $(); $ .each( o.files, function ( index, file) { var row = $('
Ihre Daten wurden erfolgreich hochgeladen.
'); } else { $( '.mwf-upload') .html( 'Es ist ein Fehler aufgetreten: ' + result.errors + '
'); } }).fail( function ( jqXHR, textStatus, errorThrown) { $( '.mwf-upload') .html( 'Es ist ein Fehler aufgetreten: ' + errorThrown + '
'); }) .always( function ( result, textStatus, jqXHR) { filelist = []; }) }); } } static initPrintDialog() { if ((window.location.href.indexOf('print=true') !== -1) && (window.location.href.indexOf('printsrc=button') !== -1) && (window.print !== undefined)) { console.log("print load") global.$('body').trigger("lazyload-gallery-image"); // todo: Workaround mit timeout, hier musste auf jedes Bild ein http response event gesetzt werden und async print aufrufen setTimeout(() => { // wartet auf letztes frame der sich gerade rendert requestAnimationFrame(() => { window.print() }); }, 1000) } } }