PageSourceSearch

https://simplelogin.io/assets/js/components/hs.header.js

js simplelogin.io collected 2026-09-24 08:43:02 UTC 45,803 bytes, 2,194 lines download raw bytes

1/**
2 * Header Component.
3 *
4 * @author Htmlstream
5 * @version 1.0
6 *
7 */
8;(function ($) {
9  'use strict';
10
11  $.HSCore.components.HSHeader = {
12
13    /**
14     * Base configuration.
15     *
16     * @var Object _baseConfig
17     */
18    _baseConfig: {
19      headerFixMoment: 0,
20      headerFixEffect: 'slide',
21      breakpointsMap: {
22        'md': 768,
23        'sm': 576,
24        'lg': 992,
25        'xl': 1200
26      }
27    },
28
29    /**
30     * Initializtion of header.
31     *
32     * @param jQuery element
33     *
34     * @return jQuery
35     */
36    init: function (element) {
37
38      if (!element || element.length !== 1 || element.data('HSHeader')) return;
39
40      var self = this;
41
42      this.element = element;
43      this.config = $.extend(true, {}, this._baseConfig, element.data());
44
45      this.observers = this._detectObservers();
46      this.fixMediaDifference(this.element);
47      this.element.data('HSHeader', new HSHeader(this.element, this.config, this.observers));
48
49      $(window)
50        .on('scroll.uHeader', function (e) {
51
52          if ($(window).scrollTop() < ($(element).data('header-fix-moment') - 100) && $(element).data('effect-compensation') === true) {
53            $(element).css({
54              top: -($(window).scrollTop())
55            })
56              .addClass($(element).data('effect-compensation-start-class'))
57              .removeClass($(element).data('effect-compensation-end-class'));
58          } else if ($(element).data('effect-compensation') === true) {
59            $(element).css({
60              top: 0
61            })
62              .addClass($(element).data('effect-compensation-end-class'))
63              .removeClass($(element).data('effect-compensation-start-class'));
64          }
65
66          if ($(window).scrollTop() > 5 && !$(element).hasClass('.u-scrolled')) {
67            $(element).addClass('u-scrolled')
68          } else {
69            $(element).removeClass('u-scrolled')
70          }
71
72          element
73            .data('HSHeader')
74            .notify();
75
76        })
77        .on('resize.uHeader', function (e) {
78
79          if (self.resizeTimeOutId) clearTimeout(self.resizeTimeOutId);
80
81          self.resizeTimeOutId = setTimeout(function () {
82
83            element
84              .data('HSHeader')
85              .checkViewport()
86              .update();
87
88          }, 100);
89
90        })
91        .trigger('scroll.uHeader');
92
93      return this.element;
94
95    },
96
97    /**
98     *
99     *
100     * @param
101     *
102     * @return
103     */
104    _detectObservers: function () {
105
106      if (!this.element || !this.element.length) return;
107
108      var observers = {
109        'xs': [],
110        'sm': [],
111        'md': [],
112        'lg': [],
113        'xl': []
114      };
115
116      /* ------------------------ xs -------------------------*/
117
118      // Has Hidden Element
119      if (this.element.hasClass('u-header--has-hidden-element')) {
120        observers['xs'].push(
121          new HSHeaderHasHiddenElement(this.element)
122        );
123      }
124
125      // Sticky top
126
127      if (this.element.hasClass('u-header--sticky-top')) {
128
129        if (this.element.hasClass('u-header--show-hide')) {
130
131          observers['xs'].push(
132            new HSHeaderMomentShowHideObserver(this.element)
133          );
134
135        }
136        else if (this.element.hasClass('u-header--toggle-section')) {
137
138          observers['xs'].push(
139            new HSHeaderHideSectionObserver(this.element)
140          );
141
142        }
143
144        if (this.element.hasClass('u-header--change-logo')) {
145
146          observers['xs'].push(
147            new HSHeaderChangeLogoObserver(this.element)
148          );
149
150        }
151
152        if (this.element.hasClass('u-header--change-appearance')) {
153
154          observers['xs'].push(
155            new HSHeaderChangeAppearanceObserver(this.element)
156          );
157
158        }
159
160      }
161
162      // Floating
163
164      if (this.element.hasClass('u-header--floating')) {
165
166        observers['xs'].push(
167          new HSHeaderFloatingObserver(this.element)
168        );
169
170      }
171
172      if (this.element.hasClass('u-header--invulnerable')) {
173        observers['xs'].push(
174          new HSHeaderWithoutBehaviorObserver(this.element)
175        );
176      }
177
178      // Sticky bottom
179
180      if (this.element.hasClass('u-header--sticky-bottom')) {
181
182        if (this.element.hasClass('u-header--change-appearance')) {
183          observers['xs'].push(
184            new HSHeaderChangeAppearanceObserver(this.element)
185          );
186        }
187
188        if (this.element.hasClass('u-header--change-logo')) {
189
190          observers['xs'].push(
191            new HSHeaderChangeLogoObserver(this.element)
192          );
193
194        }
195
196      }
197
198      // Abs top & Static
199
200      if (this.element.hasClass('u-header--abs-top') || this.element.hasClass('u-header--static')) {
201
202        if (this.element.hasClass('u-header--show-hide')) {
203
204          observers['xs'].push(
205            new HSHeaderShowHideObserver(this.element)
206          );
207
208        }
209
210        if (this.element.hasClass('u-header--change-logo')) {
211
212          observers['xs'].push(
213            new HSHeaderChangeLogoObserver(this.element)
214          );
215
216        }
217
218        if (this.element.hasClass('u-header--change-appearance')) {
219
220          observers['xs'].push(
221            new HSHeaderChangeAppearanceObserver(this.element)
222          );
223
224        }
225
226      }
227
228      // Abs bottom & Abs top 2nd screen
229
230      if (this.element.hasClass('u-header--abs-bottom') || this.element.hasClass('u-header--abs-top-2nd-screen')) {
231
232        observers['xs'].push(
233          new HSHeaderStickObserver(this.element)
234        );
235
236        if (this.element.hasClass('u-header--change-appearance')) {
237
238          observers['xs'].push(
239            new HSHeaderChangeAppearanceObserver(this.element, {
240              fixPointSelf: true
241            })
242          );
243
244        }
245
246        if (this.element.hasClass('u-header--change-logo')) {
247
248          observers['xs'].push(
249            new HSHeaderChangeLogoObserver(this.element, {
250              fixPointSelf: true
251            })
252          );
253
254        }
255
256      }
257
258      /* ------------------------ sm -------------------------*/
259
260      // Sticky top
261
262      // Has Hidden Element
263      if (this.element.hasClass('u-header--has-hidden-element-sm')) {
264        observers['sm'].push(
265          new HSHeaderHasHiddenElement(this.element)
266        );
267      }
268
269      if (this.element.hasClass('u-header--sticky-top-sm')) {
270
271        if (this.element.hasClass('u-header--show-hide-sm')) {
272
273          observers['sm'].push(
274            new HSHeaderMomentShowHideObserver(this.element)
275          );
276
277        }
278        else if (this.element.hasClass('u-header--toggle-section-sm')) {
279
280          observers['sm'].push(
281            new HSHeaderHideSectionObserver(this.element)
282          );
283
284        }
285
286        if (this.element.hasClass('u-header--change-logo-sm')) {
287
288          observers['sm'].push(
289            new HSHeaderChangeLogoObserver(this.element)
290          );
291
292        }
293
294        if (this.element.hasClass('u-header--change-appearance-sm')) {
295
296          observers['sm'].push(
297            new HSHeaderChangeAppearanceObserver(this.element)
298          );
299
300        }
301
302      }
303
304      // Floating
305
306      if (this.element.hasClass('u-header--floating-sm')) {
307
308        observers['sm'].push(
309          new HSHeaderFloatingObserver(this.element)
310        );
311
312      }
313
314      if (this.element.hasClass('u-header--invulnerable-sm')) {
315        observers['sm'].push(
316          new HSHeaderWithoutBehaviorObserver(this.element)
317        );
318      }
319
320      // Sticky bottom
321
322      if (this.element.hasClass('u-header--sticky-bottom-sm')) {
323
324        if (this.element.hasClass('u-header--change-appearance-sm')) {
325          observers['sm'].push(
326            new HSHeaderChangeAppearanceObserver(this.element)
327          );
328        }
329
330        if (this.element.hasClass('u-header--change-logo-sm')) {
331
332          observers['sm'].push(
333            new HSHeaderChangeLogoObserver(this.element)
334          );
335
336        }
337
338      }
339
340      // Abs top & Static
341
342      if (this.element.hasClass('u-header--abs-top-sm') || this.element.hasClass('u-header--static-sm')) {
343
344        if (this.element.hasClass('u-header--show-hide-sm')) {
345
346          observers['sm'].push(
347            new HSHeaderShowHideObserver(this.element)
348          );
349
350        }
351
352        if (this.element.hasClass('u-header--change-logo-sm')) {
353
354          observers['sm'].push(
355            new HSHeaderChangeLogoObserver(this.element)
356          );
357
358        }
359
360        if (this.element.hasClass('u-header--change-appearance-sm')) {
361
362          observers['sm'].push(
363            new HSHeaderChangeAppearanceObserver(this.element)
364          );
365
366        }
367
368      }
369
370      // Abs bottom & Abs top 2nd screen
371
372      if (this.element.hasClass('u-header--abs-bottom-sm') || this.element.hasClass('u-header--abs-top-2nd-screen-sm')) {
373
374        observers['sm'].push(
375          new HSHeaderStickObserver(this.element)
376        );
377
378        if (this.element.hasClass('u-header--change-appearance-sm')) {
379
380          observers['sm'].push(
381            new HSHeaderChangeAppearanceObserver(this.element, {
382              fixPointSelf: true
383            })
384          );
385
386        }
387
388        if (this.element.hasClass('u-header--change-logo-sm')) {
389
390          observers['sm'].push(
391            new HSHeaderChangeLogoObserver(this.element, {
392              fixPointSelf: true
393            })
394          );
395
396        }
397
398      }
399
400      /* ------------------------ md -------------------------*/
401
402      // Has Hidden Element
403      if (this.element.hasClass('u-header--has-hidden-element-md')) {
404        observers['md'].push(
405          new HSHeaderHasHiddenElement(this.element)
406        );
407      }
408
409      // Sticky top
410
411      if (this.element.hasClass('u-header--sticky-top-md')) {
412
413        console.log(1);
414
415        if (this.element.hasClass('u-header--show-hide-md')) {
416
417          observers['md'].push(
418            new HSHeaderMomentShowHideObserver(this.element)
419          );
420
421        }
422        else if (this.element.hasClass('u-header--toggle-section-md')) {
423
424          observers['md'].push(
425            new HSHeaderHideSectionObserver(this.element)
426          );
427
428        }
429
430        if (this.element.hasClass('u-header--change-logo-md')) {
431
432          observers['md'].push(
433            new HSHeaderChangeLogoObserver(this.element)
434          );
435
436        }
437
438        if (this.element.hasClass('u-header--change-appearance-md')) {
439
440          observers['md'].push(
441            new HSHeaderChangeAppearanceObserver(this.element)
442          );
443
444        }
445
446      }
447
448      // Floating
449
450      if (this.element.hasClass('u-header--floating-md')) {
451
452        observers['md'].push(
453          new HSHeaderFloatingObserver(this.element)
454        );
455
456      }
457
458      if (this.element.hasClass('u-header--invulnerable-md')) {
459        observers['md'].push(
460          new HSHeaderWithoutBehaviorObserver(this.element)
461        );
462      }
463
464      // Sticky bottom
465
466      if (this.element.hasClass('u-header--sticky-bottom-md')) {
467
468        if (this.element.hasClass('u-header--change-appearance-md')) {
469          observers['md'].push(
470            new HSHeaderChangeAppearanceObserver(this.element)
471          );
472        }
473
474        if (this.element.hasClass('u-header--change-logo-md')) {
475
476          observers['md'].push(
477            new HSHeaderChangeLogoObserver(this.element)
478          );
479
480        }
481
482      }
483
484      // Abs top & Static
485
486      if (this.element.hasClass('u-header--abs-top-md') || this.element.hasClass('u-header--static-md')) {
487
488        if (this.element.hasClass('u-header--show-hide-md')) {
489
490          observers['md'].push(
491            new HSHeaderShowHideObserver(this.element)
492          );
493
494        }
495
496        if (this.element.hasClass('u-header--change-logo-md')) {
497
498          observers['md'].push(
499            new HSHeaderChangeLogoObserver(this.element)
500          );
501
502        }
503
504        if (this.element.hasClass('u-header--change-appearance-md')) {
505
506          observers['md'].push(
507            new HSHeaderChangeAppearanceObserver(this.element)
508          );
509
510        }
511
512      }
513
514      // Abs bottom & Abs top 2nd screen
515
516      if (this.element.hasClass('u-header--abs-bottom-md') || this.element.hasClass('u-header--abs-top-2nd-screen-md')) {
517
518        observers['md'].push(
519          new HSHeaderStickObserver(this.element)
520        );
521
522        if (this.element.hasClass('u-header--change-appearance-md')) {
523
524          observers['md'].push(
525            new HSHeaderChangeAppearanceObserver(this.element, {
526              fixPointSelf: true
527            })
528          );
529
530        }
531
532        if (this.element.hasClass('u-header--change-logo-md')) {
533
534          observers['md'].push(
535            new HSHeaderChangeLogoObserver(this.element, {
536              fixPointSelf: true
537            })
538          );
539
540        }
541
542      }
543
544
545      /* ------------------------ lg -------------------------*/
546
547      // Has Hidden Element
548      if (this.element.hasClass('u-header--has-hidden-element-lg')) {
549        observers['lg'].push(
550          new HSHeaderHasHiddenElement(this.element)
551        );
552      }
553
554      // Sticky top
555
556      if (this.element.hasClass('u-header--sticky-top-lg')) {
557
558        if (this.element.hasClass('u-header--show-hide-lg')) {
559
560          observers['lg'].push(
561            new HSHeaderMomentShowHideObserver(this.element)
562          );
563
564        }
565        else if (this.element.hasClass('u-header--toggle-section-lg')) {
566
567          observers['lg'].push(
568            new HSHeaderHideSectionObserver(this.element)
569          );
570
571        }
572
573        if (this.element.hasClass('u-header--change-logo-lg')) {
574
575          observers['lg'].push(
576            new HSHeaderChangeLogoObserver(this.element)
577          );
578
579        }
580
581        if (this.element.hasClass('u-header--change-appearance-lg')) {
582
583          observers['lg'].push(
584            new HSHeaderChangeAppearanceObserver(this.element)
585          );
586
587        }
588
589      }
590
591      // Floating
592
593      if (this.element.hasClass('u-header--floating-lg')) {
594
595        observers['lg'].push(
596          new HSHeaderFloatingObserver(this.element)
597        );
598
599      }
600
601      if (this.element.hasClass('u-header--invulnerable-lg')) {
602        observers['lg'].push(
603          new HSHeaderWithoutBehaviorObserver(this.element)
604        );
605      }
606
607      // Sticky bottom
608
609      if (this.element.hasClass('u-header--sticky-bottom-lg')) {
610
611        if (this.element.hasClass('u-header--change-appearance-lg')) {
612          observers['lg'].push(
613            new HSHeaderChangeAppearanceObserver(this.element)
614          );
615        }
616
617        if (this.element.hasClass('u-header--change-logo-lg')) {
618
619          observers['lg'].push(
620            new HSHeaderChangeLogoObserver(this.element)
621          );
622
623        }
624
625      }
626
627      // Abs top & Static
628
629      if (this.element.hasClass('u-header--abs-top-lg') || this.element.hasClass('u-header--static-lg')) {
630
631        if (this.element.hasClass('u-header--show-hide-lg')) {
632
633          observers['lg'].push(
634            new HSHeaderShowHideObserver(this.element)
635          );
636
637        }
638
639        if (this.element.hasClass('u-header--change-logo-lg')) {
640
641          observers['lg'].push(
642            new HSHeaderChangeLogoObserver(this.element)
643          );
644
645        }
646
647        if (this.element.hasClass('u-header--change-appearance-lg')) {
648
649          observers['lg'].push(
650            new HSHeaderChangeAppearanceObserver(this.element)
651          );
652
653        }
654
655      }
656
657      // Abs bottom & Abs top 2nd screen
658
659      if (this.element.hasClass('u-header--abs-bottom-lg') || this.element.hasClass('u-header--abs-top-2nd-screen-lg')) {
660
661        observers['lg'].push(
662          new HSHeaderStickObserver(this.element)
663        );
664
665        if (this.element.hasClass('u-header--change-appearance-lg')) {
666
667          observers['lg'].push(
668            new HSHeaderChangeAppearanceObserver(this.element, {
669              fixPointSelf: true
670            })
671          );
672
673        }
674
675        if (this.element.hasClass('u-header--change-logo-lg')) {
676
677          observers['lg'].push(
678            new HSHeaderChangeLogoObserver(this.element, {
679              fixPointSelf: true
680            })
681          );
682
683        }
684
685      }
686
687      /* ------------------------ xl -------------------------*/
688
689      // Has Hidden Element
690      if (this.element.hasClass('u-header--has-hidden-element-xl')) {
691        observers['xl'].push(
692          new HSHeaderHasHiddenElement(this.element)
693        );
694      }
695
696      // Sticky top
697
698      if (this.element.hasClass('u-header--sticky-top-xl')) {
699
700        if (this.element.hasClass('u-header--show-hide-xl')) {
701
702          observers['xl'].push(
703            new HSHeaderMomentShowHideObserver(this.element)
704          );
705
706        }
707        else if (this.element.hasClass('u-header--toggle-section-xl')) {
708
709          observers['xl'].push(
710            new HSHeaderHideSectionObserver(this.element)
711          );
712
713        }
714
715        if (this.element.hasClass('u-header--change-logo-xl')) {
716
717          observers['xl'].push(
718            new HSHeaderChangeLogoObserver(this.element)
719          );
720
721        }
722
723        if (this.element.hasClass('u-header--change-appearance-xl')) {
724
725          observers['xl'].push(
726            new HSHeaderChangeAppearanceObserver(this.element)
727          );
728
729        }
730
731      }
732
733      // Floating
734
735      if (this.element.hasClass('u-header--floating-xl')) {
736
737        observers['xl'].push(
738          new HSHeaderFloatingObserver(this.element)
739        );
740
741      }
742
743      // Sticky bottom
744
745      if (this.element.hasClass('u-header--invulnerable-xl')) {
746        observers['xl'].push(
747          new HSHeaderWithoutBehaviorObserver(this.element)
748        );
749      }
750
751      // Sticky bottom
752
753      if (this.element.hasClass('u-header--sticky-bottom-xl')) {
754
755        if (this.element.hasClass('u-header--change-appearance-xl')) {
756          observers['xl'].push(
757            new HSHeaderChangeAppearanceObserver(this.element)
758          );
759        }
760
761        if (this.element.hasClass('u-header--change-logo-xl')) {
762
763          observers['xl'].push(
764            new HSHeaderChangeLogoObserver(this.element)
765          );
766
767        }
768
769      }
770
771      // Abs top & Static
772
773      if (this.element.hasClass('u-header--abs-top-xl') || this.element.hasClass('u-header--static-xl')) {
774
775        if (this.element.hasClass('u-header--show-hide-xl')) {
776
777          observers['xl'].push(
778            new HSHeaderShowHideObserver(this.element)
779          );
780
781        }
782
783        if (this.element.hasClass('u-header--change-logo-xl')) {
784
785          observers['xl'].push(
786            new HSHeaderChangeLogoObserver(this.element)
787          );
788
789        }
790
791        if (this.element.hasClass('u-header--change-appearance-xl')) {
792
793          observers['xl'].push(
794            new HSHeaderChangeAppearanceObserver(this.element)
795          );
796
797        }
798
799      }
800
801      // Abs bottom & Abs top 2nd screen
802
803      if (this.element.hasClass('u-header--abs-bottom-xl') || this.element.hasClass('u-header--abs-top-2nd-screen-xl')) {
804
805        observers['xl'].push(
806          new HSHeaderStickObserver(this.element)
807        );
808
809        if (this.element.hasClass('u-header--change-appearance-xl')) {
810
811          observers['xl'].push(
812            new HSHeaderChangeAppearanceObserver(this.element, {
813              fixPointSelf: true
814            })
815          );
816
817        }
818
819        if (this.element.hasClass('u-header--change-logo-xl')) {
820
821          observers['xl'].push(
822            new HSHeaderChangeLogoObserver(this.element, {
823              fixPointSelf: true
824            })
825          );
826
827        }
828
829      }
830
831
832      return observers;
833
834    },
835
836    /**
837     *
838     *
839     * @param
840     *
841     * @return
842     */
843    fixMediaDifference: function (element) {
844
845      if (!element || !element.length || !element.filter('[class*="u-header--side"]').length) return;
846
847      var toggleable;
848
849      if (element.hasClass('u-header--side-left-xl') || element.hasClass('u-header--side-right-xl')) {
850
851        toggleable = element.find('.navbar-expand-xl');
852
853        if (toggleable.length) {
854          toggleable
855            .removeClass('navbar-expand-xl')
856            .addClass('navbar-expand-lg');
857        }
858
859      }
860      else if (element.hasClass('u-header--side-left-lg') || element.hasClass('u-header--side-right-lg')) {
861
862        toggleable = element.find('.navbar-expand-lg');
863
864        if (toggleable.length) {
865          toggleable
866            .removeClass('navbar-expand-lg')
867            .addClass('navbar-expand-md');
868        }
869
870      }
871      else if (element.hasClass('u-header--side-left-md') || element.hasClass('u-header--side-right-md')) {
872
873        toggleable = element.find('.navbar-expand-md');
874
875        if (toggleable.length) {
876          toggleable
877            .removeClass('navbar-expand-md')
878            .addClass('navbar-expand-sm');
879        }
880
881      }
882      else if (element.hasClass('u-header--side-left-sm') || element.hasClass('u-header--side-right-sm')) {
883
884        toggleable = element.find('.navbar-expand-sm');
885
886        if (toggleable.length) {
887          toggleable
888            .removeClass('navbar-expand-sm')
889            .addClass('navbar-expand');
890        }
891
892      }
893
894    }
895
896  };
897
898  /**
899   * HSHeader constructor function.
900   *
901   * @param jQuery element
902   * @param Object config
903   * @param Object observers
904   *
905   * @return undefined
906   */
907  function HSHeader(element, config, observers) {
908
909    if (!element || !element.length) return;
910
911    this.element = element;
912    this.config = config;
913
914    this.observers = observers && $.isPlainObject(observers) ? observers : {};
915
916    this.viewport = 'xs';
917    this.checkViewport();
918
919  }
920
921  /**
922   *
923   *
924   * @return Object
925   */
926  HSHeader.prototype.checkViewport = function () {
927
928    var $w = $(window);
929
930    if ($w.width() > this.config.breakpointsMap['sm'] && this.observers['sm'].length) {
931      this.prevViewport = this.viewport;
932      this.viewport = 'sm';
933
934      if(this.element[0].dataset.headerFixMoment && $w.scrollTop() > this.element[0].dataset.headerFixMoment) {
935
936        if(typeof this.config.breakpointsMap['sm'] === 'undefined') {
937          this.element.removeClass('js-header-fix-moment');
938        } else {
939          this.element.addClass('js-header-fix-moment');
940        }
941
942      }
943
944      return this;
945    }
946
947    if ($w.width() > this.config.breakpointsMap['md'] && this.observers['md'].length) {
948      this.prevViewport = this.viewport;
949      this.viewport = 'md';
950
951      if(this.element[0].dataset.headerFixMoment && $w.scrollTop() > this.element[0].dataset.headerFixMoment) {
952
953        if (typeof this.config.breakpointsMap['md'] === 'undefined') {
954          this.element.removeClass('js-header-fix-moment');
955        } else {
956          this.element.addClass('js-header-fix-moment');
957        }
958
959      }
960
961      return this;
962    }
963
964    if ($w.width() > this.config.breakpointsMap['lg'] && this.observers['lg'].length) {
965      this.prevViewport = this.viewport;
966      this.viewport = 'lg';
967
968      if(this.element[0].dataset.headerFixMoment && $w.scrollTop() > this.element[0].dataset.headerFixMoment) {
969
970        if (typeof this.config.breakpointsMap['lg'] === 'undefined') {
971          this.element.removeClass('js-header-fix-moment');
972        } else {
973          this.element.addClass('js-header-fix-moment');
974        }
975
976      }
977
978      return this;
979    }
980
981    if ($w.width() > this.config.breakpointsMap['xl'] && this.observers['xl'].length) {
982      this.prevViewport = this.viewport;
983      this.viewport = 'xl';
984
985      if(this.element[0].dataset.headerFixMoment && $w.scrollTop() > this.element[0].dataset.headerFixMoment) {
986
987        if (typeof this.config.breakpointsMap['xl'] === 'undefined') {
988          this.element.removeClass('js-header-fix-moment');
989        } else {
990          this.element.addClass('js-header-fix-moment');
991        }
992
993      }
994
995      return this;
996    }
997
998
999    if (this.prevViewport) this.prevViewport = this.viewport;
1000
1001    if(this.element[0].dataset.headerFixMoment && $w.scrollTop() > this.element[0].dataset.headerFixMoment) {
1002
1003      if (typeof this.config.breakpointsMap['xs'] === 'undefined') {
1004        this.element.removeClass('js-header-fix-moment');
1005      } else {
1006        this.element.addClass('js-header-fix-moment');
1007      }
1008
1009    }
1010
1011    this.viewport = 'xs';
1012
1013
1014    return this;
1015
1016  };
1017
1018  /**
1019   * Notifies all observers.
1020   *
1021   * @return Object
1022   */
1023  HSHeader.prototype.notify = function () {
1024
1025    if (this.prevViewport) {
1026      this.observers[this.prevViewport].forEach(function (observer) {
1027        observer.destroy();
1028      });
1029      this.prevViewport = null;
1030    }
1031
1032    this.observers[this.viewport].forEach(function (observer) {
1033      observer.check();
1034    });
1035
1036    return this;
1037
1038  };
1039
1040  /**
1041   * Reinit all header's observers.
1042   *
1043   * @return Object
1044   */
1045  HSHeader.prototype.update = function () {
1046
1047    for (var viewport in this.observers) {
1048
1049      this.observers[viewport].forEach(function (observer) {
1050        observer.destroy();
1051      });
1052
1053    }
1054
1055    this.prevViewport = null;
1056
1057    this.observers[this.viewport].forEach(function (observer) {
1058      observer.reinit();
1059    });
1060
1061    return this;
1062
1063  };
1064
1065  /**
1066   * Abstract constructor function for each observer.
1067   *
1068   * @param jQuery element
1069   *
1070   * @return Boolean|undefined
1071   */
1072  function HSAbstractObserver(element) {
1073    if (!element || !element.length) return;
1074
1075    this.element = element;
1076    this.defaultState = true;
1077
1078    this.reinit = function () {
1079
1080      this
1081        .destroy()
1082        .init()
1083        .check();
1084    };
1085
1086    return true;
1087  }
1088
1089  /**
1090   * Header's observer which is responsible for 'sticky' behavior.
1091   *
1092   * @param jQuery element
1093   */
1094  function HSHeaderStickObserver(element) {
1095    if (!HSAbstractObserver.call(this, element)) return;
1096
1097    this.init();
1098
1099  }
1100
1101  /**
1102   *
1103   *
1104   * @param
1105   *
1106   * @return
1107   */
1108  HSHeaderStickObserver.prototype.init = function () {
1109    this.defaultState = true;
1110    this.offset = this.element.offset().top;
1111
1112    return this;
1113  };
1114
1115  /**
1116   *
1117   *
1118   * @param
1119   *
1120   * @return
1121   */
1122  HSHeaderStickObserver.prototype.destroy = function () {
1123    this.toDefaultState();
1124
1125    return this;
1126  };
1127
1128  /**
1129   *
1130   *
1131   * @param
1132   *
1133   * @return
1134   */
1135  HSHeaderStickObserver.prototype.check = function () {
1136
1137    var $w = $(window),
1138      docScrolled = $w.scrollTop();
1139
1140    if (docScrolled > this.offset && this.defaultState) {
1141      this.changeState();
1142    }
1143    else if (docScrolled < this.offset && !this.defaultState) {
1144      this.toDefaultState();
1145    }
1146
1147    return this;
1148
1149  };
1150
1151  /**
1152   *
1153   *
1154   * @param
1155   *
1156   * @return
1157   */
1158  HSHeaderStickObserver.prototype.changeState = function () {
1159
1160    this.element.addClass('js-header-fix-moment');
1161    this.defaultState = !this.defaultState;
1162
1163    return this;
1164
1165  };
1166
1167  /**
1168   *
1169   *
1170   * @param
1171   *
1172   * @return
1173   */
1174  HSHeaderStickObserver.prototype.toDefaultState = function () {
1175
1176    this.element.removeClass('js-header-fix-moment');
1177    this.defaultState = !this.defaultState;
1178
1179    return this;
1180
1181  };
1182
1183
1184  /**
1185   * Header's observer which is responsible for 'show/hide' behavior which is depended on scroll direction.
1186   *
1187   * @param jQuery element
1188   */
1189  function HSHeaderMomentShowHideObserver(element) {
1190    if (!HSAbstractObserver.call(this, element)) return;
1191
1192    this.init();
1193  }
1194
1195  /**
1196   *
1197   *
1198   * @return Object
1199   */
1200  HSHeaderMomentShowHideObserver.prototype.init = function () {
1201    this.direction = 'down';
1202    this.delta = 0;
1203    this.defaultState = true;
1204
1205    this.offset = isFinite(this.element.data('header-fix-moment')) && this.element.data('header-fix-moment') !== 0 ? this.element.data('header-fix-moment') : 5;
1206    this.effect = this.element.data('header-fix-effect') ? this.element.data('header-fix-effect') : 'show-hide';
1207
1208    return this;
1209  };
1210
1211  /**
1212   *
1213   *
1214   * @return Object
1215   */
1216  HSHeaderMomentShowHideObserver.prototype.destroy = function () {
1217    this.toDefaultState();
1218
1219    return this;
1220  };
1221
1222  /**
1223   *
1224   *
1225   * @param
1226   *
1227   * @return Object
1228   */
1229  HSHeaderMomentShowHideObserver.prototype.checkDirection = function () {
1230
1231    if ($(window).scrollTop() > this.delta) {
1232      this.direction = 'down';
1233    }
1234    else {
1235      this.direction = 'up';
1236    }
1237
1238    this.delta = $(window).scrollTop();
1239
1240    return this;
1241
1242  };
1243
1244  /**
1245   *
1246   *
1247   * @return Object
1248   */
1249  HSHeaderMomentShowHideObserver.prototype.toDefaultState = function () {
1250
1251    switch (this.effect) {
1252      case 'slide' :
1253        this.element.removeClass('u-header--moved-up');
1254        break;
1255
1256      case 'fade' :
1257        this.element.removeClass('u-header--faded');
1258        break;
1259
1260      default:
1261        this.element.removeClass('u-header--invisible');
1262    }
1263
1264    this.defaultState = !this.defaultState;
1265
1266    return this;
1267  };
1268
1269  /**
1270   *
1271   *
1272   * @return Object
1273   */
1274  HSHeaderMomentShowHideObserver.prototype.changeState = function () {
1275
1276    switch (this.effect) {
1277      case 'slide' :
1278        this.element.addClass('u-header--moved-up');
1279        break;
1280
1281      case 'fade' :
1282        this.element.addClass('u-header--faded');
1283        break;
1284
1285      default:
1286        this.element.addClass('u-header--invisible');
1287    }
1288
1289    this.defaultState = !this.defaultState;
1290
1291    return this;
1292  };
1293
1294  /**
1295   *
1296   *
1297   * @return Object
1298   */
1299  HSHeaderMomentShowHideObserver.prototype.check = function () {
1300
1301    var docScrolled = $(window).scrollTop();
1302    this.checkDirection();
1303
1304
1305    if (docScrolled >= this.offset && this.defaultState && this.direction === 'down') {
1306      this.changeState();
1307    }
1308    else if (!this.defaultState && this.direction === 'up') {
1309      this.toDefaultState();
1310    }
1311
1312    return this;
1313
1314  };
1315
1316  /**
1317   *
1318   *
1319   * @param
1320   *
1321   * @return
1322   */
1323  function HSHeaderShowHideObserver(element) {
1324    if (!HSAbstractObserver.call(this, element)) return;
1325
1326    this.init();
1327  }
1328
1329  /**
1330   *
1331   *
1332   * @param
1333   *
1334   * @return Object
1335   */
1336  HSHeaderShowHideObserver.prototype.init = function () {
1337    if (!this.defaultState && $(window).scrollTop() > this.offset) return this;
1338
1339    this.defaultState = true;
1340    this.transitionDuration = parseFloat(getComputedStyle(this.element.get(0))['transition-duration'], 10) * 1000;
1341
1342    this.offset = isFinite(this.element.data('header-fix-moment')) && this.element.data('header-fix-moment') > this.element.outerHeight() ? this.element.data('header-fix-moment') : this.element.outerHeight() + 100;
1343    this.effect = this.element.data('header-fix-effect') ? this.element.data('header-fix-effect') : 'show-
1343hide';
1344
1345    return this;
1346  };
1347
1348  /**
1349   *
1350   *
1351   * @param
1352   *
1353   * @return Object
1354   */
1355  HSHeaderShowHideObserver.prototype.destroy = function () {
1356    if (!this.defaultState && $(window).scrollTop() > this.offset) return this;
1357
1358    this.element.removeClass('u-header--untransitioned');
1359    this._removeCap();
1360
1361    return this;
1362  };
1363
1364  /**
1365   *
1366   *
1367   * @param
1368   *
1369   * @return
1370   */
1371  HSHeaderShowHideObserver.prototype._insertCap = function () {
1372
1373    this.element.addClass('js-header-fix-moment u-header--untransitioned');
1374
1375    if (this.element.hasClass('u-header--static')) {
1376
1377      $('html').css('padding-top', this.element.outerHeight());
1378
1379    }
1380
1381    switch (this.effect) {
1382      case 'fade' :
1383        this.element.addClass('u-header--faded');
1384        break;
1385
1386      case 'slide' :
1387        this.element.addClass('u-header--moved-up');
1388        break;
1389
1390      default :
1391        this.element.addClass('u-header--invisible')
1392    }
1393
1394    this.capInserted = true;
1395
1396  };
1397
1398  /**
1399   *
1400   *
1401   * @param
1402   *
1403   * @return
1404   */
1405  HSHeaderShowHideObserver.prototype._removeCap = function () {
1406
1407    var self = this;
1408
1409    this.element.removeClass('js-header-fix-moment');
1410
1411    if (this.element.hasClass('u-header--static')) {
1412
1413      $('html').css('padding-top', 0);
1414
1415    }
1416
1417    if (this.removeCapTimeOutId) clearTimeout(this.removeCapTimeOutId);
1418
1419    this.removeCapTimeOutId = setTimeout(function () {
1420      self.element.removeClass('u-header--moved-up u-header--faded u-header--invisible');
1421    }, 10);
1422
1423    this.capInserted = false;
1424
1425  };
1426
1427
1428  /**
1429   *
1430   *
1431   * @param
1432   *
1433   * @return
1434   */
1435  HSHeaderShowHideObserver.prototype.check = function () {
1436
1437    var $w = $(window);
1438
1439    if ($w.scrollTop() > this.element.outerHeight() && !this.capInserted) {
1440      this._insertCap();
1441    }
1442    else if ($w.scrollTop() <= this.element.outerHeight() && this.capInserted) {
1443      this._removeCap();
1444    }
1445
1446    if ($w.scrollTop() > this.offset && this.defaultState) {
1447      this.changeState();
1448    }
1449    else if ($w.scrollTop() <= this.offset && !this.defaultState) {
1450      this.toDefaultState();
1451    }
1452
1453  };
1454
1455  /**
1456   *
1457   *
1458   * @param
1459   *
1460   * @return
1461   */
1462  HSHeaderShowHideObserver.prototype.changeState = function () {
1463
1464    this.element.removeClass('u-header--untransitioned');
1465
1466    if (this.animationTimeoutId) clearTimeout(this.animationTimeoutId);
1467
1468    switch (this.effect) {
1469      case 'fade' :
1470        this.element.removeClass('u-header--faded');
1471        break;
1472
1473      case 'slide' :
1474        this.element.removeClass('u-header--moved-up');
1475        break;
1476
1477      default:
1478        this.element.removeClass('u-header--invisible');
1479    }
1480
1481    this.defaultState = !this.defaultState;
1482
1483  };
1484
1485  /**
1486   *
1487   *
1488   * @param
1489   *
1490   * @return
1491   */
1492  HSHeaderShowHideObserver.prototype.toDefaultState = function () {
1493
1494    var self = this;
1495
1496    this.animationTimeoutId = setTimeout(function () {
1497      self.element.addClass('u-header--untransitioned');
1498    }, this.transitionDuration);
1499
1500
1501    switch (this.effect) {
1502      case 'fade' :
1503        this.element.addClass('u-header--faded');
1504        break;
1505      case 'slide' :
1506        this.element.addClass('u-header--moved-up');
1507        break;
1508      default:
1509        this.element.addClass('u-header--invisible');
1510    }
1511
1512    this.defaultState = !this.defaultState;
1513
1514  };
1515
1516  /**
1517   *
1518   *
1519   * @param
1520   *
1521   * @return
1522   */
1523  function HSHeaderChangeLogoObserver(element, config) {
1524
1525    if (!HSAbstractObserver.call(this, element)) return;
1526
1527    this.config = {
1528      fixPointSelf: false
1529    };
1530
1531    if (config && $.isPlainObject(config)) this.config = $.extend(true, {}, this.config, config);
1532
1533    this.init();
1534
1535  }
1536
1537  /**
1538   *
1539   *
1540   * @param
1541   *
1542   * @return
1543   */
1544  HSHeaderChangeLogoObserver.prototype.init = function () {
1545
1546    if (this.element.hasClass('js-header-fix-moment')) {
1547      this.hasFixedClass = true;
1548      this.element.removeClass('js-header-fix-moment');
1549    }
1550    if (this.config.fixPointSelf) {
1551      this.offset = this.element.offset().top;
1552    }
1553    else {
1554      this.offset = isFinite(this.element.data('header-fix-moment')) ? this.element.data('header-fix-moment') : 0;
1555    }
1556    if (this.hasFixedClass) {
1557      this.hasFixedClass = false;
1558      this.element.addClass('js-header-fix-moment');
1559    }
1560
1561    this.imgs = this.element.find('.u-header__logo-img');
1562    this.defaultState = true;
1563
1564    this.mainLogo = this.imgs.filter('.u-header__logo-img--main');
1565    this.additionalLogo = this.imgs.not('.u-header__logo-img--main');
1566
1567    if (!this.imgs.length) return this;
1568
1569    return this;
1570  };
1571
1572  /**
1573   *
1574   *
1575   * @param
1576   *
1577   * @return
1578   */
1579  HSHeaderChangeLogoObserver.prototype.destroy = function () {
1580    this.toDefaultState();
1581
1582    return this;
1583  };
1584
1585  /**
1586   *
1587   *
1588   * @param
1589   *
1590   * @return
1591   */
1592  HSHeaderChangeLogoObserver.prototype.check = function () {
1593
1594    var $w = $(window);
1595
1596    if (!this.imgs.length) return this;
1597
1598    if ($w.scrollTop() > this.offset && this.defaultState) {
1599      this.changeState();
1600    }
1601    else if ($w.scrollTop() <= this.offset && !this.defaultState) {
1602      this.toDefaultState();
1603    }
1604
1605    return this;
1606
1607  };
1608
1609  /**
1610   *
1611   *
1612   * @param
1613   *
1614   * @return
1615   */
1616  HSHeaderChangeLogoObserver.prototype.changeState = function () {
1617
1618    if (this.mainLogo.length) {
1619      this.mainLogo.removeClass('u-header__logo-img--main');
1620    }
1621    if (this.additionalLogo.length) {
1622      this.additionalLogo.addClass('u-header__logo-img--main');
1623    }
1624
1625    this.defaultState = !this.defaultState;
1626
1627    return this;
1628  };
1629
1630  /**
1631   *
1632   *
1633   * @param
1634   *
1635   * @return
1636   */
1637  HSHeaderChangeLogoObserver.prototype.toDefaultState = function () {
1638
1639    if (this.mainLogo.length) {
1640      this.mainLogo.addClass('u-header__logo-img--main');
1641    }
1642    if (this.additionalLogo.length) {
1643      this.additionalLogo.removeClass('u-header__logo-img--main');
1644    }
1645
1646    this.defaultState = !this.defaultState;
1647
1648    return this;
1649  };
1650
1651  /**
1652   *
1653   *
1654   * @param
1655   *
1656   * @return
1657   */
1658  function HSHeaderHideSectionObserver(element) {
1659    if (!HSAbstractObserver.call(this, element)) return;
1660
1661    this.init();
1662  }
1663
1664  /**
1665   *
1666   *
1667   * @param
1668   *
1669   * @return Object
1670   */
1671  HSHeaderHideSectionObserver.prototype.init = function () {
1672
1673    this.offset = isFinite(this.element.data('header-fix-moment')) ? this.element.data('header-fix-moment') : 5;
1674    this.section = this.element.find('.u-header__section--hidden');
1675    this.defaultState = true;
1676
1677    this.sectionHeight = this.section.length ? this.section.outerHeight() : 0;
1678
1679
1680    return this;
1681
1682  };
1683
1684  /**
1685   *
1686   *
1687   * @param
1688   *
1689   * @return
1690   */
1691  HSHeaderHideSectionObserver.prototype.destroy = function () {
1692
1693    if (this.section.length) {
1694
1695      this.element.css({
1696        'margin-top': 0
1697      });
1698
1699    }
1700
1701    return this;
1702
1703  };
1704
1705  /**
1706   *
1707   *
1708   * @param
1709   *
1710   * @return
1711   */
1712  HSHeaderHideSectionObserver.prototype.check = function () {
1713
1714    if (!this.section.length) return this;
1715
1716    var $w = $(window),
1717      docScrolled = $w.scrollTop();
1718
1719    if (docScrolled > this.offset && this.defaultState) {
1720      this.changeState();
1721    }
1722    else if (docScrolled <= this.offset && !this.defaultState) {
1723      this.toDefaultState();
1724    }
1725
1726    return this;
1727
1728  };
1729
1730  /**
1731   *
1732   *
1733   * @param
1734   *
1735   * @return
1736   */
1737  HSHeaderHideSectionObserver.prototype.changeState = function () {
1738
1739    var self = this;
1740
1741    this.element.stop().animate({
1742      'margin-top': self.sectionHeight * -1 - 1 // last '-1' is a small fix
1743    });
1744
1745    this.defaultState = !this.defaultState;
1746    return this;
1747
1748  };
1749
1750  /**
1751   *
1752   *
1753   * @param
1754   *
1755   * @return
1756   */
1757  HSHeaderHideSectionObserver.prototype.toDefaultState = function () {
1758
1759    this.element.stop().animate({
1760      'margin-top': 0
1761    });
1762
1763    this.defaultState = !this.defaultState;
1764    return this;
1765
1766  };
1767
1768  /**
1769   *
1770   *
1771   * @param
1772   *
1773   * @return
1774   */
1775  function HSHeaderChangeAppearanceObserver(element, config) {
1776    if (!HSAbstractObserver.call(this, element)) return;
1777
1778    this.config = {
1779      fixPointSelf: false
1780    };
1781
1782    if (config && $.isPlainObject(config)) this.config = $.extend(true, {}, this.config, config);
1783
1784    this.init();
1785  }
1786
1787  /**
1788   *
1789   *
1790   * @param
1791   *
1792   * @return
1793   */
1794  HSHeaderChangeAppearanceObserver.prototype.init = function () {
1795
1796    if (this.element.hasClass('js-header-fix-moment')) {
1797      this.hasFixedClass = true;
1798      this.element.removeClass('js-header-fix-moment');
1799    }
1800
1801    if (this.config.fixPointSelf) {
1802      this.offset = this.element.offset().top;
1803    }
1804    else {
1805      this.offset = isFinite(this.element.data('header-fix-moment')) ? this.element.data('header-fix-moment') : 5;
1806    }
1807
1808    if (this.hasFixedClass) {
1809      this.hasFixedClass = false;
1810      this.element.addClass('js-header-fix-moment');
1811    }
1812
1813    this.sections = this.element.find('[data-header-fix-moment-classes]');
1814
1815    this.defaultState = true;
1816
1817
1818    return this;
1819
1820  };
1821
1822  /**
1823   *
1824   *
1825   * @param
1826   *
1827   * @return
1828   */
1829  HSHeaderChangeAppearanceObserver.prototype.destroy = function () {
1830
1831    this.toDefaultState();
1832
1833    return this;
1834
1835  };
1836
1837  /**
1838   *
1839   *
1840   * @param
1841   *
1842   * @return
1843   */
1844  HSHeaderChangeAppearanceObserver.prototype.check = function () {
1845
1846    if (!this.sections.length) return this;
1847
1848    var $w = $(window),
1849      docScrolled = $w.scrollTop();
1850
1851    if (docScrolled > this.offset && this.defaultState) {
1852      this.changeState();
1853    }
1854    else if (docScrolled <= this.offset && !this.defaultState) {
1855      this.toDefaultState();
1856    }
1857
1858    return this;
1859
1860  };
1861
1862  /**
1863   *
1864   *
1865   * @param
1866   *
1867   * @return
1868   */
1869  HSHeaderChangeAppearanceObserver.prototype.changeState = function () {
1870
1871    this.sections.each(function (i, el) {
1872
1873      var $this = $(el),
1874        classes = $this.data('header-fix-moment-classes'),
1875        exclude = $this.data('header-fix-moment-exclude');
1876
1877      if (!classes && !exclude) return;
1878
1879      $this.addClass(classes + ' js-header-change-moment');
1880      $this.removeClass(exclude);
1881
1882    });
1883
1884    this.defaultState = !this.defaultState;
1885    return this;
1886
1887  };
1888
1889  /**
1890   *
1891   *
1892   * @param
1893   *
1894   * @return
1895   */
1896  HSHeaderChangeAppearanceObserver.prototype.toDefaultState = function () {
1897
1898    this.sections.each(function (i, el) {
1899
1900      var $this = $(el),
1901        classes = $this.data('header-fix-moment-classes'),
1902        exclude = $this.data('header-fix-moment-exclude');
1903
1904      if (!classes && !exclude) return;
1905
1906      $this.removeClass(classes + ' js-header-change-moment');
1907      $this.addClass(exclude);
1908
1909    });
1910
1911    this.defaultState = !this.defaultState;
1912    return this;
1913
1914  };
1915
1916  /**
1917   *
1918   *
1919   * @param
1920   *
1921   * @return
1922   */
1923  function HSHeaderHasHiddenElement(element, config) {
1924    if (!HSAbstractObserver.call(this, element)) return;
1925
1926    this.config = {
1927      animated: true
1928    };
1929
1930    if (config && $.isPlainObject(config)) this.config = $.extend(true, {}, this.config, config);
1931
1932    this.init();
1933  }
1934
1935  /**
1936   *
1937   *
1938   * @param
1939   *
1940   * @return
1941   */
1942  HSHeaderHasHiddenElement.prototype.init = function () {
1943    this.offset = isFinite(this.element.data('header-fix-moment')) ? this.element.data('header-fix-moment') : 5;
1944    this.elements = this.element.find('.u-header--hidden-element');
1945    this.defaultState = true;
1946    return this;
1947  };
1948
1949  /**
1950   *
1951   *
1952   * @param
1953   *
1954   * @return
1955   */
1956  HSHeaderHasHiddenElement.prototype.destroy = function () {
1957
1958    this.toDefaultState();
1959
1960    return this;
1961
1962  };
1963
1964  /**
1965   *
1966   *
1967   * @param
1968   *
1969   * @return
1970   */
1971  HSHeaderHasHiddenElement.prototype.check = function () {
1972
1973    if (!this.elements.length) return this;
1974
1975    var $w = $(window),
1976      docScrolled = $w.scrollTop();
1977
1978    if (docScrolled > this.offset && this.defaultState) {
1979      this.changeState();
1980    }
1981    else if (docScrolled <= this.offset && !this.defaultState) {
1982      this.toDefaultState();
1983    }
1984
1985    return this;
1986
1987  };
1988
1989  /**
1990   *
1991   *
1992   * @param
1993   *
1994   * @return
1995   */
1996  HSHeaderHasHiddenElement.prototype.changeState = function () {
1997
1998    if (this.config.animated) {
1999      this.elements.stop().slideUp();
2000    }
2001    else {
2002      this.elements.hide();
2003    }
2004
2005    this.defaultState = !this.defaultState;
2006    return this;
2007
2008  };
2009
2010  /**
2011   *
2012   *
2013   * @param
2014   *
2015   * @return
2016   */
2017  HSHeaderHasHiddenElement.prototype.toDefaultState = function () {
2018
2019    if (this.config.animated) {
2020      this.elements.stop().slideDown();
2021    }
2022    else {
2023      this.elements.show();
2024    }
2025
2026    this.defaultState = !this.defaultState;
2027    return this;
2028
2029  };
2030
2031  /**
2032   *
2033   *
2034   * @param
2035   *
2036   * @return
2037   */
2038  function HSHeaderFloatingObserver(element, config) {
2039    if (!HSAbstractObserver.call(this, element)) return;
2040
2041    this.config = config && $.isPlainObject(config) ? $.extend(true, {}, this.config, config) : {};
2042    this.init();
2043  }
2044
2045  /**
2046   *
2047   *
2048   * @param
2049   *
2050   * @return
2051   */
2052  HSHeaderFloatingObserver.prototype.init = function () {
2053
2054    this.offset = this.element.offset().top;
2055    this.sections = this.element.find('.u-header__section');
2056
2057    this.defaultState = true;
2058
2059    return this;
2060
2061  };
2062
2063  /**
2064   *
2065   *
2066   * @param
2067   *
2068   * @return
2069   */
2070  HSHeaderFloatingObserver.prototype.destroy = function () {
2071
2072    this.toDefaultState();
2073
2074    return this;
2075
2076  };
2077
2078  /**
2079   *
2080   *
2081   * @param
2082   *
2083   * @return
2084   */
2085  HSHeaderFloatingObserver.prototype.check = function () {
2086
2087    var $w = $(window),
2088      docScrolled = $w.scrollTop();
2089
2090    if (docScrolled > this.offset && this.defaultState) {
2091      this.changeState();
2092    }
2093    else if (docScrolled <= this.offset && !this.defaultState) {
2094      this.toDefaultState();
2095    }
2096
2097    return this;
2098
2099  };
2100
2101  /**
2102   *
2103   *
2104   * @param
2105   *
2106   * @return
2107   */
2108  HSHeaderFloatingObserver.prototype.changeState = function () {
2109
2110    this.element
2111      .addClass('js-header-fix-moment')
2112      .addClass(this.element.data('header-fix-moment-classes'))
2113      .removeClass(this.element.data('header-fix-moment-exclude'));
2114
2115    if (this.sections.length) {
2116      this.sections.each(function (i, el) {
2117
2118        var $section = $(el);
2119
2120        $section.addClass($section.data('header-fix-moment-classes'))
2121          .removeClass($section.data('header-fix-moment-exclude'));
2122
2123      });
2124    }
2125
2126    this.defaultState = !this.defaultState;
2127    return this;
2128
2129  };
2130
2131  /**
2132   *
2133   *
2134   * @param
2135   *
2136   * @return
2137   */
2138  HSHeaderFloatingObserver.prototype.toDefaultState = function () {
2139
2140    this.element
2141      .removeClass('js-header-fix-moment')
2142      .removeClass(this.element.data('header-fix-moment-classes'))
2143      .addClass(this.element.data('header-fix-moment-exclude'));
2144
2145    if (this.sections.length) {
2146      this.sections.each(function (i, el) {
2147
2148        var $section = $(el);
2149
2150        $section.removeClass($section.data('header-fix-moment-classes'))
2151          .addClass($section.data('header-fix-moment-exclude'));
2152
2153      });
2154    }
2155
2156    this.defaultState = !this.defaultState;
2157    return this;
2158
2159  };
2160
2161
2162  /**
2163   *
2164   *
2165   * @param
2166   *
2167   * @return
2168   */
2169  function HSHeaderWithoutBehaviorObserver(element) {
2170    if (!HSAbstractObserver.call(this, element)) return;
2171  }
2172
2173  HSHeaderWithoutBehaviorObserver.prototype.check = function () {
2174    return this;
2175  };
2176
2177  HSHeaderWithoutBehaviorObserver.prototype.init = function () {
2178    return this;
2179  };
2180
2181  HSHeaderWithoutBehaviorObserver.prototype.destroy = function () {
2182    return this;
2183  };
2184
2185  HSHeaderWithoutBehaviorObserver.prototype.changeState = function () {
2186    return this;
2187  };
2188
2189  HSHeaderWithoutBehaviorObserver.prototype.toDefaultState = function () {
2190    return this;
2191  }
2192
2193
2194})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.