選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 

110 行
3.4 KiB

  1. import './ihk-switch.scss';
  2. import $ from 'jquery';
  3. import {createElement} from "../../_global/scripts/helpers";
  4. import IHKSwitch from "./ihk-switch";
  5. import {createButton} from "../../atoms/button/ButtonComponent";
  6. import {createInputText} from "../../atoms/input-text/InputTextComponent";
  7. import {createSearchButton} from "../../atoms/search-button/SearchButtonComponent";
  8. const Cookies = require('js-cookie');
  9. export const createIhkSwitch = ({
  10. currentIHK = 'Musterstadt',
  11. myIHK = 'Hamburg',
  12. zip = false,
  13. zipPlaceholder = 'z.B. 20146 Hamburg'
  14. }) => {
  15. const wrap = createElement('div', ['ihk-switch']);
  16. const step1 = createElement('div', ['step'], null, wrap);
  17. if (!zip) {
  18. const step2 = createElement('div', ['step'], null, wrap);
  19. const step3 = createElement('div', ['step'], null, wrap);
  20. const p1 = 'Sie befinden sich auf der Seite der <strong class="current-ihk" data-ihknr="118">' + currentIHK + '</strong>. Möchten Sie diese Seite in einem Cookie als Ihre Heimat-IHK setzen?';
  21. const p2 = 'Sie befinden sich auf der Seite der <strong class="current-ihk" data-ihknr="118">' + currentIHK + '</strong>. Bisher ist die <strong><span class="my-ihk">' + myIHK + '</span></strong> als Ihre Heimat-IHK hinterlegt. Wollen Sie die Seite der <strong class="current-ihk" data-ihknr="118">' + currentIHK + '</strong> in einem Cookie als Ihre neue Heimat-IHK setzen?';
  22. const p3 = 'Sie werden zum Angebot der <strong class="large my-ihk">' + myIHK + '</strong> weitergeleitet.';
  23. createElement('button', ['closer'], null, wrap);
  24. step1.dataset.step = 'form';
  25. createElement('p', [], p1, step1);
  26. step1.appendChild(buildButtons());
  27. step2.dataset.step = 'switch';
  28. createElement('p', [], p2, step2);
  29. step2.appendChild(buildButtons());
  30. step3.dataset.step = 'success';
  31. createElement('p', [], p3, step3);
  32. window.sessionStorage.removeItem('my-ihk-ignore');
  33. Cookies.remove('my-ihk', {expires: 365});
  34. } else {
  35. const p1 = 'Geben Sie Ihre Postleitzahl ein, um zu dem Angebot Ihrer IHK zu gelangen:';
  36. createElement('button', ['closer'], null, wrap);
  37. step1.dataset.step = 'zip';
  38. createElement('p', [], p1, step1);
  39. const inputWrapper = createElement('div', ['input-wrapper'], null, step1);
  40. inputWrapper.appendChild(createInputText({
  41. placeholder: zipPlaceholder,
  42. isRequired: true,
  43. id: 'switch-zip',
  44. name: 'switch-zip',
  45. }));
  46. inputWrapper.appendChild(createButton({
  47. label: '',
  48. link: '#',
  49. iconPosition: 'icon-inline',
  50. icon: 'lokalisierung',
  51. }));
  52. step1.appendChild(buildOKButton());
  53. }
  54. $(document).ready(() => {
  55. new IHKSwitch($(wrap));
  56. })
  57. return wrap;
  58. }
  59. const buildButtons = () => {
  60. const buttons = createElement('div', ['buttons']);
  61. const yes = createButton({
  62. elementType: 'button',
  63. label: 'Ja',
  64. color: 'primary-extra-light',
  65. })
  66. const no = createButton({
  67. elementType: 'button',
  68. label: 'Nein',
  69. color: 'primary-extra-light',
  70. })
  71. yes.classList.add('stay-here');
  72. no.classList.add('set-session-cookie');
  73. buttons.appendChild(yes);
  74. buttons.appendChild(no);
  75. return buttons;
  76. }
  77. const buildOKButton = () => {
  78. const buttons = createElement('div', ['buttons', 'align-right']);
  79. const ok = createButton({
  80. elementType: 'button',
  81. label: 'OK',
  82. color: 'secondary',
  83. icon: 'check',
  84. iconPosition: 'icon-right'
  85. })
  86. ok.classList.add('stay-here');
  87. buttons.appendChild(ok);
  88. return buttons;
  89. }