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