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