Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 

116 wiersze
3.0 KiB

  1. import $ from 'jquery';
  2. export class IHKSearchTiles {
  3. constructor(tileWrapper) {
  4. this.tiles = tileWrapper.find('.tile a');
  5. this.tiles.each((i, el) => {
  6. const tile = $(el);
  7. if (tile.text().length > 48) {
  8. tile.text( tile.text().substr(0, 48) + '…' );
  9. }
  10. })
  11. }
  12. }
  13. class IHKExtendedSearch {
  14. constructor(section) {
  15. this.section = section.addClass('initiated');
  16. $('#search-expand-collapse').on('click', (e) => {
  17. e.preventDefault();
  18. $(e.currentTarget).toggleClass('open');
  19. this.section.stop().slideToggle(500, 'swing');
  20. });
  21. section.find('.ev-search-btn').on('click', (e) => {
  22. e.preventDefault();
  23. console.log('click');
  24. const target = $(e.currentTarget);
  25. target.next('.ev-filter').stop().slideToggle(400, 'easeOutQuad');
  26. window.requestAnimationFrame(() => {
  27. target.toggleClass('open');
  28. })
  29. });
  30. section.find('label.acc a').each((i, el) => {
  31. new FormAccordion($(el));
  32. });
  33. section.find('.reset').on('click', (e) => {
  34. e.preventDefault();
  35. const form = $(e.currentTarget).closest('form');
  36. form[0].reset();
  37. form.find('.half-checked').removeClass('half-checked');
  38. $('html, body').animate({
  39. scrollTop: form.offset().top - 120
  40. }, 500, 'easeOutQuad');
  41. });
  42. /*
  43. $('.datepicker').each((i, el) => {
  44. $(el).datepicker({ changeYear: true, changeMonth: true});
  45. });
  46. */
  47. }
  48. }
  49. class FormAccordion{
  50. constructor(toggle) {
  51. const t = this;
  52. this.toggle = toggle;
  53. this.label = this.toggle.parent('label');
  54. this.checkbox = this.label.prev('input[type="checkbox"]');
  55. this.subs = this.label.next('.ev-filter');
  56. this.toggle.on('click', (e) => {
  57. e.preventDefault();
  58. e.stopPropagation();
  59. this.label.toggleClass('open');
  60. this.subs.stop().slideToggle(400, 'swing');
  61. })
  62. this.subs.find('input[type="checkbox"]').on('change', () => {
  63. this.checkSelection();
  64. })
  65. this.checkbox.on('change', (e) => {
  66. const isChecked = $(e.currentTarget).removeClass('half-checked').prop('checked');
  67. this.subs.find('input[type="checkbox"]').prop('checked', isChecked);
  68. })
  69. this.checkSelection();
  70. }
  71. checkSelection() {
  72. const checked = this.subs.find('input[type="checkbox"]:checked').length;
  73. const unchecked = this.subs.find('input[type="checkbox"]:not(:checked)').length;
  74. if (checked+unchecked === 0) {
  75. this.checkbox.removeClass('half-checked');
  76. return;
  77. }
  78. if (checked === 0) {
  79. this.checkbox.prop('checked', false).removeClass('half-checked');
  80. }
  81. else if (unchecked === 0) {
  82. this.checkbox.prop('checked', true).removeClass('half-checked');
  83. }
  84. else {
  85. this.checkbox.prop('checked', false).addClass('half-checked');
  86. }
  87. }
  88. }
  89. export default IHKExtendedSearch;
  90. $('body').on('ihk-init dynamic-component-loaded', function () {
  91. $('.extended-search:not(.initiated)').each(function (i) {
  92. new IHKExtendedSearch($(this));
  93. });
  94. });