Make WordPress Core

Changeset 23965

Timestamp:
04/11/2013 04:11:46 PM (11 years ago)
Author:
lancewillett
Message:

Twenty Thirteen: adjust JavaScript handling for scrolling and finding viewport heigh/width to better support various IE versions. Also consolidate variables at the top of the file per best practices. Fixes #23841, props obenland.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/themes/twentythirteen/js/functions.js

    r23891 r23965  
    66
    77( function( $ ) {
    8     var twentyThirteen = {
     8    var html          = $( 'html' ),
     9        body          = $( 'body' ),
     10        navbar        = $( '#navbar' ),
     11        _window       = $( window ),
     12        navbarOffset  = -1,
     13        toolbarOffset = body.is( '.admin-bar' ) ? 28 : 0,
     14
     15        twentyThirteen = {
    916        /**
    1017         * Adds a top margin to the footer if the sidebar widget area is
     
    1724                margin    = $( '#tertiary .widget-area' ).height() - $( '#content' ).height() - secondary;
    1825
    19             if ( margin > 0 && window.innerWidth > 999 )
     26            if ( margin > 0 && > 999 )
    2027                $( '#colophon' ).css( 'margin-top', margin + 'px' );
    2128        },
     
    3744            twentyThirteen.adjustFooter();
    3845    } );
    39     $( window ).on( 'hashchange', twentyThirteen.adjustAnchor );
     46    .on( 'hashchange', twentyThirteen.adjustAnchor );
    4047
    4148    /**
    4249     * Displays the fixed navbar based on screen position.
    4350     */
    44     var html          = $( 'html' ),
    45         body          = $( 'body' ),
    46         navbar        = $( '#navbar' ),
    47         navbarOffset  = -1,
    48         toolbarOffset = body.is( '.admin-bar' ) ? 28 : 0;
    49 
    50     $( window ).scroll( function() {
     51    _window.scroll( function() {
     52        var scrollOffset = ( typeof window.scrollY === 'undefined' ) ? document.documentElement.scrollTop : window.scrollY;
    5153        if ( navbarOffset < 0 )
    5254            navbarOffset = navbar.offset().top - toolbarOffset;
    5355
    54         if ( window.scrollY >= navbarOffset && 644 < window.innerWidth )
     56        if ( )
    5557            html.addClass( 'navbar-fixed' );
    5658        else
     
    98100     * @link http://www.nczonline.net/blog/2013/01/15/fixing-skip-to-content-links/
    99101     */
    100     $( window ).on( 'hashchange', function() {
     102    .on( 'hashchange', function() {
    101103        var element = $( location.hash );
    102104
Note: See TracChangeset for help on using the changeset viewer.