1/** 2 * Sticky mobile menu. 3 * 4 * @package Pen 5 */ 6 7;( function( $ ) { 8 9 'use strict'; 10 11 var $window = $( window ), 12 $body = $( 'body' ), 13 $wpadminbar = $( '#wpadminbar' ), 14 $header = $( '#pen_header' ), 15 $page_wrapper = $( '#page' ).children( '.pen_wrapper' ); 16 17 $window.on( 'load resize orientationchange pen_update_sticky_navigation_mobile pen_update_navigation_mobile', function() { 18 var $navigation_mobile = $( '#pen_navigation_mobile' ); 19 if ( $navigation_mobile.length ) { 20 var navigation_mobile_top = 0, 21 admin_toolbar_height = 0, 22 header_height = ( $header.css( 'position' ) === 'fixed' ) ? $header.outerHeight( true ) : 0, 23 navigation_mobile_height = $navigation_mobile.removeClass( 'pen_navigation_mobile_sticked' ).outerHeight( true ); 24 if ( $wpadminbar.length ) { 25 admin_toolbar_height = $wpadminbar.outerHeight( true ); 26 } 27 $navigation_mobile.css( { left: 0, position: 'fixed', top: admin_toolbar_height } ); 28 29 $page_wrapper.css( { paddingTop: navigation_mobile_height + header_height } ); 30 31 $window.on( 'scroll', function() { 32 if ( $window.scrollTop() ) { 33 var stick = false; 34 if ( pen_navigation_mobile_sticky_js.navigation_mobile === 'always' ) { 35 stick = true; 36 } else if ( pen_function_exists( typeof Modernizr ) ) { 37 var breakpoint = ''; 38 if ( pen_navigation_mobile_sticky_js.navigation_mobile === 'mobile' ) { 39 breakpoint = ' and (max-width:728px)'; 40 } else if ( pen_navigation_mobile_sticky_js.navigation_mobile === 'tablet' || pen_navigation_mobile_sticky_js.navigation_mobile === 'mobile_tablet' ) { 41 breakpoint = ' and (max-width:1024px)'; 42 } 43 if ( breakpoint && Modernizr.mq( 'only all' + breakpoint ) ) { 44 stick = true; 45 } 46 } 47 if ( stick ) { 48 $navigation_mobile.css( { 49 top: ( $wpadminbar.css( 'position' ) === 'fixed' ) ? admin_toolbar_height : 0 50 } ); 51 $navigation_mobile.addClass( 'pen_navigation_mobile_sticked' ); 52 $body.addClass( 'pen_navigation_mobile_sticked' ); 53 } 54 } else { 55 $navigation_mobile.removeClass( 'pen_navigation_mobile_sticked' ).css( { top: admin_toolbar_height } ); 56 $body.removeClass( 'pen_navigation_mobile_sticked' ); 57 } 58 }); 59 } 60 }); 61})( 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.