Changeset 24004
- Timestamp:
- 04/16/2013 09:51:07 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-content/themes/twentythirteen/js/functions.js
r23965 r24004 12 12 navbarOffset = -1, 13 13 toolbarOffset = body.is( '.admin-bar' ) ? 28 : 0, 14 adjustFooter, 15 adjustAnchor; 14 16 15 twentyThirteen = { 16 /** 17 * Adds a top margin to the footer if the sidebar widget area is 18 * higher than the rest of the page, to help the footer always 19 * visually clear the sidebar. 20 */ 21 adjustFooter : function() { 22 var sidebar = $( '#secondary .widget-area' ), 23 secondary = ( 0 == sidebar.length ) ? -40 : sidebar.height(), 24 margin = $( '#tertiary .widget-area' ).height() - $( '#content' ).height() - secondary; 17 /** 18 * Adds a top margin to the footer if the sidebar widget area is 19 * higher than the rest of the page, to help the footer always 20 * visually clear the sidebar. 21 */ 22 adjustFooter = function() { 23 var sidebar = $( '#secondary .widget-area' ), 24 secondary = ( 0 == sidebar.length ) ? -40 : sidebar.height(), 25 margin = $( '#tertiary .widget-area' ).height() - $( '#content' ).height() - secondary; 25 26 26 27 28 },27 if ( margin > 0 && _window.innerWidth() > 999 ) 28 $( '#colophon' ).css( 'margin-top', margin + 'px' ); 29 }; 29 30 30 /** 31 * Repositions the window on jump-to-anchor to account for navbar 32 * height. 33 */ 34 adjustAnchor : function() { 35 if ( window.location.hash ) 36 window.scrollBy( 0, -49 ); 37 } 31 /** 32 * Repositions the window on jump-to-anchor to account for navbar 33 * height. 34 */ 35 adjustAnchor = function() { 36 if ( window.location.hash ) 37 window.scrollBy( 0, -49 ); 38 38 }; 39 39 40 40 $( function() { 41 twentyThirteen.adjustAnchor();41 adjustAnchor(); 42 42 43 43 if ( body.is( '.sidebar' ) ) 44 twentyThirteen.adjustFooter();44 adjustFooter(); 45 45 } ); 46 _window.on( 'hashchange ', twentyThirteen.adjustAnchor );46 _window.on( 'hashchange.twentythirteen', adjustAnchor ); 47 47 48 48 /** 49 49 * Displays the fixed navbar based on screen position. 50 50 */ 51 _window. scroll(function() {51 _window.on( 'scroll.twentythirteen', function() { 52 52 var scrollOffset = ( typeof window.scrollY === 'undefined' ) ? document.documentElement.scrollTop : window.scrollY; 53 53 if ( navbarOffset < 0 ) … … 63 63 * Allows clicking the navbar to scroll to top. 64 64 */ 65 navbar.on( 'click ', function( event ) {65 navbar.on( 'click.twentythirteen', function( event ) { 66 66 // Ensure that the navbar element was the target of the click. 67 67 if ( 'navbar' == event.target.id || 'site-navigation' == event.target.id ) … … 88 88 } 89 89 90 $( '.menu-toggle' ).on( 'click ', function() {90 $( '.menu-toggle' ).on( 'click.twentythirteen', function() { 91 91 nav.toggleClass( 'toggled-on' ); 92 92 } ); 93 93 } )(); 94 95 94 96 95 /** … … 100 99 * @link http://www.nczonline.net/blog/2013/01/15/fixing-skip-to-content-links/ 101 100 */ 102 _window.on( 'hashchange ', function() {101 _window.on( 'hashchange.twentythirteen', function() { 103 102 var element = $( location.hash ); 104 103
Note: See TracChangeset
for help on using the changeset viewer.