No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 

258 líneas
8.1 KiB

  1. import {EtrackerUtils} from "./EtrackerUtils";
  2. export class UiUtils {
  3. static initUI() {
  4. UiUtils.initPrintDialog();
  5. UiUtils.initfileupload();
  6. UiUtils.initTrackEventElementAnalytics();
  7. UiUtils.disbaleInitialForNewsletterSubPage();
  8. UiUtils.initEtrackerOnCookiebotEvent();
  9. UiUtils.initEtrackerOnUsercentricsEvent();
  10. UiUtils.initEmptyAnchorLinks();
  11. }
  12. static initEtrackerOnCookiebotEvent() {
  13. if (typeof ihk !== "undefined" && ihk.settings && ihk.settings.etrackerCookieless === false) {
  14. window.addEventListener('CookiebotOnConsentReady', EtrackerUtils.initEtrackerCookies, false);
  15. }
  16. }
  17. static initEtrackerOnUsercentricsEvent() {
  18. window.addEventListener('onConsentStatusChange', EtrackerUtils.initEtrackerUsercentricsCookies, false);
  19. }
  20. static initTrackEventElementAnalytics() {
  21. if (!window.isPbe) {
  22. $(".trackEventElement").each(
  23. function () {
  24. const category = $(this).data(
  25. 'analytics-category');
  26. const object = $(this).data('analytics-object');
  27. const action = $(this).data('analytics-action');
  28. const tags = $(this).data('analytics-tags');
  29. window.setTimeout(EtrackerUtils.fireETrackerEvent, 250,
  30. category, object, action, tags);
  31. });
  32. }
  33. }
  34. static disbaleInitialForNewsletterSubPage() {
  35. const inxForm = $(".inxform");
  36. const inxHolderText = $(inxForm).closest(".detail-text");
  37. if (inxHolderText.length > 0) {
  38. inxHolderText.find(".text").first().addClass("no-initial");
  39. }
  40. }
  41. static initfileupload() {
  42. //todo: make great again
  43. if (typeof jQuery.fn.fileupload == 'function') {
  44. var filelist = [], uploadUrl = $('#fileupload')
  45. .data("url");
  46. $('#fileupload')
  47. .fileupload(
  48. {
  49. url: uploadUrl,
  50. previewMaxWidth: "90",
  51. previewMaxHeight: "90",
  52. previewCrop: true,
  53. singleFileUploads: false,
  54. filesContainer: $('#uploaded-files'),
  55. uploadTemplateId: null,
  56. downloadTemplateId: null,
  57. uploadTemplate: function (o) {
  58. var rows = $();
  59. $
  60. .each(
  61. o.files,
  62. function (
  63. index,
  64. file) {
  65. var row = $('<div class="mwf-upload-row thumbnail template-upload">'
  66. + ' <div class="mwf-upload-fileinfo">'
  67. + ' <div class="mwf-upload-preview"><div class="preview"><span></span></div></div>'
  68. + ' <div class="mwf-upload-metadata">'
  69. + ' <ul>'
  70. + ' <li>Name: <span class="name"></span></li>'
  71. + ' <li>Größe: <span class="size"></span></li>'
  72. + (file.error ? '<li>Fehler: <span class="error"></span></li>'
  73. : '')
  74. + ' </ul>'
  75. + ' </div>'
  76. + ' </div>'
  77. + ' <div class="mwf-upload-actions">'
  78. + ' <div class="cancel"><button>Löschen</button></div>'
  79. + ' </div>'
  80. + '</div>');
  81. row
  82. .find(
  83. '.name')
  84. .text(
  85. file.name);
  86. row
  87. .find(
  88. '.size')
  89. .text(
  90. o
  91. .formatFileSize(file.size));
  92. row
  93. .find(
  94. 'button')
  95. .click(
  96. function () {
  97. for (var i in filelist) {
  98. var fileEntry = filelist[i];
  99. if (fileEntry.name == file.name) {
  100. filelist
  101. .splice(
  102. i,
  103. 1);
  104. $(
  105. '.mwf-upload-error')
  106. .text(
  107. '');
  108. break;
  109. }
  110. }
  111. });
  112. rows = rows
  113. .add(row);
  114. });
  115. return rows;
  116. },
  117. dataType: 'json',
  118. progressall: function (e, data) {
  119. var progress = parseInt(
  120. data.loaded
  121. / data.total
  122. * 100, 10);
  123. $('#progress .bar').css(
  124. 'width',
  125. progress + '%');
  126. },
  127. dropZone: $('#dropzone')
  128. })
  129. .on(
  130. "fileuploadadd",
  131. function (e, data) {
  132. var maxFiles = $('#fileupload')
  133. .data('maxfiles'), maxFilesize = $(
  134. '#fileupload').data(
  135. 'maxfilesize');
  136. // letzt Meldung entfernen:
  137. $('.mwf-upload-error').text('');
  138. if (filelist.length > (maxFiles - 1)) {
  139. $('.mwf-upload-error')
  140. .text(
  141. 'Hinweis: Es dürfen maximal '
  142. + maxFiles
  143. + ' Dateien hochgeladen werden.');
  144. return false;
  145. } else {
  146. for (var i = 0; i < data.files.length; i++) {
  147. filelist
  148. .push(data.files[i])
  149. }
  150. var totalSize = 0;
  151. for (var pos in filelist) {
  152. totalSize += filelist[pos].size;
  153. }
  154. if (totalSize > (maxFilesize * 1024 * 1024)) {
  155. filelist.pop();
  156. $('.mwf-upload-error')
  157. .text(
  158. 'Hinweis: Die Größe der Dateien überschreitet die maximale Gesamtgröße von '
  159. + maxFilesize
  160. + 'MB.');
  161. return false;
  162. }
  163. }
  164. });
  165. $('#uploadbutton')
  166. .click(
  167. function () {
  168. $('#fileupload')
  169. .fileupload('send', {
  170. files: filelist
  171. }).done(
  172. function (
  173. result,
  174. textStatus,
  175. jqXHR) {
  176. if (result.success === true) {
  177. $(
  178. '.mwf-upload')
  179. .html(
  180. '<p><strong>Ihre Daten wurden erfolgreich hochgeladen.</strong></p>');
  181. } else {
  182. $(
  183. '.mwf-upload')
  184. .html(
  185. '<p><strong>Es ist ein Fehler aufgetreten: '
  186. + result.errors
  187. + '</strong></p>');
  188. }
  189. }).fail(
  190. function (
  191. jqXHR,
  192. textStatus,
  193. errorThrown) {
  194. $(
  195. '.mwf-upload')
  196. .html(
  197. '<p><strong>Es ist ein Fehler aufgetreten: '
  198. + errorThrown
  199. + '</strong></p>');
  200. })
  201. .always(
  202. function (
  203. result,
  204. textStatus,
  205. jqXHR) {
  206. filelist = [];
  207. })
  208. });
  209. }
  210. }
  211. static initPrintDialog() {
  212. if ((window.location.href.indexOf('print=true') !== -1)
  213. && (window.location.href.indexOf('printsrc=button') !== -1)
  214. && (window.print !== undefined)) {
  215. console.log("print load")
  216. global.$('body').trigger("lazyload-gallery-image");
  217. // todo: Workaround mit timeout, hier musste auf jedes Bild ein http response event gesetzt werden und async print aufrufen
  218. setTimeout(() => {
  219. // wartet auf letztes frame der sich gerade rendert
  220. requestAnimationFrame(() => {
  221. window.print()
  222. });
  223. }, 1000)
  224. }
  225. }
  226. // IHK-5928 missing link to root channel
  227. static initEmptyAnchorLinks(){
  228. $(".main-col .richtext .detail-text a[href='']").attr("href","/");
  229. }
  230. }