Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

118 linhas
2.9 KiB

  1. // import $ from 'jquery';
  2. const $ = require('jquery');
  3. class Social {
  4. constructor(socialBox) {
  5. this.box = socialBox.addClass('initiated')
  6. this.tabindexSet = false;
  7. this.checkIframe();
  8. }
  9. checkIframe() {
  10. setTimeout(() => {
  11. const iframe = this.box.find('iframe');
  12. if (iframe.length) {
  13. iframe.attr('tabindex', '-1');
  14. }
  15. else {
  16. this.checkIframe();
  17. }
  18. }, 1000)
  19. }
  20. }
  21. /*
  22. ihk.Social = function (socialBox) {
  23. const t = this;
  24. t.socialBox = socialBox.addClass('initiated');
  25. t.section = socialBox.closest('section');
  26. t.isSocialSection = t.section.hasClass('social');
  27. t.preventTabFocus();
  28. //t.preventMobileScroll();
  29. }
  30. ihk.Social.prototype.preventTabFocus = function(first_argument) {
  31. const t = this;
  32. t.prevFocusable = $('<a href="#" />').insertBefore(t.socialBox);
  33. t.nextFocusable = $('<a href="#" />').insertAfter(t.socialBox);
  34. t.prevFocusable.on('focus', function () {
  35. if (t.isSocialSection) {
  36. t.focusNextSection();
  37. }
  38. else {
  39. const nextCol = t.socialBox.closest('.col').next('.col');
  40. if (nextCol.length) {
  41. nextCol.find('.teaser').focus();
  42. }
  43. else {
  44. t.focusNextSection();
  45. }
  46. }
  47. })
  48. t.nextFocusable.on('focus', function () {
  49. if (t.isSocialSection) {
  50. t.section.find('.social-icons a').last().focus();
  51. }
  52. else {
  53. const prevCol = t.socialBox.closest('.col').prev('.col');
  54. if (prevCol.length) {
  55. prevCol.find('.teaser').focus();
  56. }
  57. else {
  58. t.focusPrevSection();
  59. }
  60. }
  61. })
  62. };
  63. ihk.Social.prototype.preventMobileScroll = function() {
  64. const t = this;
  65. t.socialBox.on('touchmove', function (e) {
  66. console.log(e.targetTouches.length);
  67. if (e.targetTouches.length == 1) {
  68. t.socialBox.addClass('prevent-scroll');
  69. }
  70. else {
  71. t.socialBox.addClass('allow-scroll');
  72. }
  73. })
  74. t.socialBox.on('touchend', function (e) {
  75. t.socialBox.removeClass('prevent-scroll').removeClass('allow-scroll');
  76. })
  77. };
  78. ihk.Social.prototype.focusNextSection = function() {
  79. const t = this;
  80. if (t.section.nextAll('section').length > 0) {
  81. t.section.nextAll('section').find('a, input, button, select, textarea').not(':disabled').not('[tabindex="-1"]').first().focus();
  82. }
  83. else {
  84. $('footer').find('a, input, button, select, textarea').not(':disabled').not('[tabindex="-1"]').first().focus();
  85. }
  86. };
  87. ihk.Social.prototype.focusPrevSection = function(first_argument) {
  88. const t = this;
  89. if (t.section.prevAll('section').length > 0) {
  90. t.section.prevAll('section').find('a, input, button, select, textarea').not(':disabled').not('[tabindex="-1"]').last().focus();
  91. }
  92. else {
  93. $('header .toggle-nav').focus();
  94. }
  95. };
  96. */
  97. $('body').on('ihk-init dynamic-component-loaded gfi-dynamic-init', function () {
  98. $('.social-box:not(.initiated)').each(function () {
  99. new Social($(this));
  100. })
  101. })