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.
 
 
 
 

49 líneas
1.5 KiB

  1. import $ from 'jquery';
  2. class IHKAnchorLinks {
  3. constructor(section) {
  4. this.section = section.addClass('initiated');
  5. this.headlines = [];
  6. this.initHeadlines();
  7. this.buildLinks();
  8. // IHK-5928 missing link to root channel
  9. $(".main-col .richtext .detail-text a[href='']").attr("href","/");
  10. }
  11. initHeadlines() {
  12. $('.main-col h2, article.col h2, .action-col .richtext h2').each((i, element) => {
  13. const h2 = $(element);
  14. const closestActionContent = h2.closest('.action-content');
  15. const hideOnlineMagazineContactH2 = h2.closest('.online-magazine-contact').length;
  16. if (!h2.closest('.accordion-content').length && !closestActionContent.closest(".richtext").length && !hideOnlineMagazineContactH2 && h2.text().length > 0) {
  17. if (h2.is(".showInTableOfContents") || !h2.closest(".link-collection").length) {
  18. this.headlines.push(h2);
  19. }
  20. }
  21. });
  22. }
  23. buildLinks() {
  24. const t = this;
  25. const ul = t.section.find('ul li a');
  26. $(ul).each((i) => {
  27. // Add Ids to text h2
  28. const textH2 = $(this.headlines[i]);
  29. if(textH2.length) {
  30. $(textH2).addClass('has-anchor');
  31. $(textH2).append($('<span class="anchor" />').attr('id', 'titleInText' + i));
  32. }
  33. });
  34. }
  35. }
  36. export default IHKAnchorLinks;
  37. $('body').on('ihk-init dynamic-component-loaded gfi-dynamic-init', function () {
  38. $('.anchor-links:not(.initiated)').each(() => {
  39. new IHKAnchorLinks($(this));
  40. });
  41. });