Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

196 lignes
7.9 KiB

  1. import './marketingheader.scss';
  2. import '../../components/artwork/artwork.scss';
  3. import '../slider/slider.scss';
  4. import $ from 'jquery';
  5. import {createElement, createImage} from "../../_global/scripts/helpers";
  6. import {createArtwork} from "../../components/artwork/ArtworkComponent";
  7. import {createSearchInput} from "../../atoms/search-input/SearchInputComponent";
  8. import {createSearchButton} from "../../atoms/search-button/SearchButtonComponent";
  9. import IHKSearchTypeahead from "./marketingheader-typeahead";
  10. import {createButton} from "../../atoms/button/ButtonComponent";
  11. import IHKMHSlider from "./marketingheaderslider";
  12. import {searchData, teaserData, sliderData} from "./MarketingHeaderData";
  13. import {createMiniTeaser} from "../../components/mini-teaser/MiniTeaserComponent";
  14. import IHKSearchAccordion from "./searchAccordion";
  15. export const createMarketingHeader =
  16. ({
  17. artworkStyle = 'artwork-both-sides',
  18. placeholder = 'Hier Ihr Thema finden',
  19. api = 'services/search/{SEARCHTERM}.json',
  20. tiles = searchData,
  21. kicker = 'Noch 7 Tage offen',
  22. headline = 'Jetzt und digital mitreden',
  23. copy = 'Mit der digitalen Beteiligung erhalten Mitgliedsunternehmen die Möglichkeit, sich einfach und schnell über laufende Verfahren und Abstimmungen zu informieren und sich aktiv daran zu beteiligen.',
  24. moreCta = {
  25. label: 'Mehr Infos',
  26. link: '#',
  27. target: '_self',
  28. },
  29. buttonCta = {
  30. label: 'Jetzt beteiligen',
  31. link: '#',
  32. target: '_self',
  33. },
  34. showProgress = true,
  35. progress = 60,
  36. backgroundImage = null,
  37. pictoImage = null,
  38. pictoImageMobile = null,
  39. isFirstElement = false,
  40. searchAllButton = false,
  41. slides = sliderData,
  42. teasers = teaserData,
  43. maxItems = 3,
  44. type = 'infoteaser',
  45. }) => {
  46. const section = createElement('section', ['marketingheader', type], null);
  47. const search = createElement('div', ['search'], null, section);
  48. if (searchAllButton) {
  49. search.classList.add('has-button-wrapper');
  50. }
  51. if (backgroundImage && backgroundImage.length > 0) {
  52. search.style = 'background-image: url(' + backgroundImage + ');';
  53. search.classList.add('background-image');
  54. }
  55. if (pictoImage && pictoImage.length > 0 && pictoImageMobile && pictoImageMobile.length > 0) {
  56. search.classList.add('picto-image');
  57. const styleElement = document.createElement('style');
  58. styleElement.textContent = `
  59. .picto-image {background-image: url("${pictoImage}");}
  60. @media (max-width: 767px) {
  61. .picto-image {background-image: url("${pictoImageMobile}");}
  62. }
  63. `;
  64. search.parentNode.insertBefore(styleElement, search.nextSibling);
  65. }
  66. const artwork = createArtwork({type: artworkStyle});
  67. search.appendChild(artwork);
  68. search.dataset.type = artworkStyle;
  69. const container = createElement('div', ['container', 'small'], null, search);
  70. const row = createElement('div', ['row'], null, container);
  71. const col = createElement('div', ['col'], null, row);
  72. const form = createElement('form', [], null, col);
  73. const label = createElement('label', ['visually-hidden'], 'IHK durchsuchen', form);
  74. label.for = 'search-term';
  75. form.appendChild(createSearchInput({api: api, placeholder: placeholder}));
  76. form.appendChild(createSearchButton({}));
  77. form.action = '#';
  78. const tilesContainer = createElement('div', ['tiles'], null, col);
  79. tiles.map((tile) => {
  80. const div = createElement('div', ['tile'], null, tilesContainer);
  81. const a = createElement('a', [], tile.title, div);
  82. a.href = tile.link;
  83. });
  84. if (searchAllButton) {
  85. const allButtonWrapper = createElement('span', ['all-button-wrapper'], null, col);
  86. const searchAllBtn = createElement('div', ['btn', 'has-icon', 'icon-small-arrow-right-simple'], 'Alle Suchergebnisse', allButtonWrapper);
  87. }
  88. if (api) {
  89. new IHKSearchTypeahead($(form).find('input.typeahead'));
  90. }
  91. /* Accordion */
  92. const sc = createElement('div', ['container','sc'], null, search);
  93. $(document).ready(() => {
  94. new IHKSearchAccordion($(search));
  95. })
  96. createElement('button', ['close-search'], '', sc);
  97. /* SLIDER */
  98. const container2 = createElement('div', ['container', 'mainstage'], null, section);
  99. const row2 = createElement('div', ['row'], null, container2);
  100. const colslider = createElement('div', ['col', 'slidercontainer', 'rotation'], null, row2);
  101. const sliderComponent = createElement('div', ['slider', 'btnanimation'], null, colslider);
  102. slides.map((slideData, index) => {
  103. const slide = createElement('div', ['slide'], null, sliderComponent);
  104. const outer = createElement('outer', ['outer'], null, slide);
  105. const contextBoxContent = slideData.context ? slideData.context : '';
  106. const contextBoxContentImg = slideData.contextImg ? slideData.contextImg : '';
  107. if (slideData.imageSrc && slideData.imageSrc.length > 0) {
  108. const imageBox = createElement('div', ['image-box'], null, outer);
  109. const picture = createElement('picture', [], null, imageBox);
  110. const src1 = createElement('source', [], null, picture);
  111. src1.setAttribute('media','(min-width: 1000px)');
  112. src1.setAttribute('srcset',slideData.imageSrc);
  113. const src2 = createElement('source', [], null, picture);
  114. src2.setAttribute('media','(min-width: 901px)');
  115. src2.setAttribute('srcset',slideData.imageSrc);
  116. createImage(slideData.imageSrc, 900, 600, 'Slide ' + index, [], picture);
  117. const copyright = createElement('span', ['copyright'], 'Copyright-Angabe', imageBox);
  118. copyright.setAttribute("aria-hidden", "true");
  119. createElement('span', ['sr-only'], 'Copyright-Angabe', imageBox);
  120. if (contextBoxContentImg) {
  121. const contentBoxImg = createElement('div', ['context-box', 'context-box--image'], null, imageBox);
  122. createImage(contextBoxContentImg, 200, 50, '', [], contentBoxImg);
  123. } else if (contextBoxContent) {
  124. createElement('div', ['context-box'], contextBoxContent, imageBox);
  125. }
  126. }
  127. const textBox = createElement('div', ['text-box'], null, outer);
  128. if (slideData.kicker && slideData.kicker.length > 0) {
  129. createElement('span', ['kicker'], slideData.kicker, textBox);
  130. }
  131. if (slideData.headline && slideData.headline.length > 0) {
  132. createElement('div', ['like-h2'], slideData.headline, textBox);
  133. }
  134. if (slideData.kicker && slideData.kicker.length > 0) {
  135. createElement('p', [], slideData.copy, textBox);
  136. }
  137. if (slideData.cta && slideData.link) {
  138. const buttonP = createElement('p', [], '', textBox);
  139. const btn = createButton({
  140. color: 'white', icon: 'pfeil-simple-rechts', iconPosition: 'icon-right', label: slideData.cta, size: 'small',
  141. });
  142. buttonP.appendChild(btn);
  143. }
  144. if (!slideData.imageSrc || slideData.imageSrc.length <= 0) {
  145. if (contextBoxContent) {
  146. textBox.classList.add('context');
  147. if (contextBoxContentImg) {
  148. const contentBox = createElement('div', ['context-box', 'context-box--image'], null, textBox);
  149. createImage(contextBoxContentImg, 200, 50, '', [], contentBox);
  150. } else if (contextBoxContent) {
  151. createElement('div', ['context-box'], contextBoxContent, textBox);
  152. }
  153. }
  154. }
  155. });
  156. new IHKMHSlider($(sliderComponent));
  157. if (type === 'infoteaser') {
  158. const col3 = createElement('div', ['col'], null, row2);
  159. teasers.map((t, i) => {
  160. if (i < maxItems) {
  161. var typ = 'standard';
  162. if (i == 0 && t.type == 'infoteaser'){
  163. typ = 'infoteaser';
  164. section.classList.add('miniinfoteaser');
  165. }
  166. const col4 = createElement('div', ['mt'], null, col3);
  167. const tea = createMiniTeaser({
  168. type : typ,
  169. })
  170. col4.appendChild(tea);
  171. }
  172. })
  173. }
  174. return section;
  175. }