Make WordPress Core

Ticket #23841: 23841.2.diff

File 23841.2.diff, 2.2 KB (added by obenland, 13 years ago)
  • wp-content/themes/twentythirteen/js/functions.js

     
    55 */
    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
    1118                 * higher than the rest of the page, to help the footer always
     
    1623                            secondary = ( 0 == sidebar.length ) ? -40 : sidebar.height(),
    1724                            margin    = $( '#tertiary .widget-area' ).height() - $( '#content' ).height() - secondary;
    1825
    19                         if ( margin > 0 && window.innerWidth > 999 )
     26                        if ( margin > 0 && _window.innerWidth() > 999 )
    2027                                $( '#colophon' ).css( 'margin-top', margin + 'px' );
    2128                },
    2229
     
    3643                if ( body.is( '.sidebar' ) )
    3744                        twentyThirteen.adjustFooter();
    3845        } );
    39         $( window ).on( 'hashchange', twentyThirteen.adjustAnchor );
     46        _window.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 ( scrollOffset >= navbarOffset && _window.innerWidth() > 644 )
    5557                        html.addClass( 'navbar-fixed' );
    5658                else
    5759                        html.removeClass( 'navbar-fixed' );
     
    9799         *
    98100         * @link http://www.nczonline.net/blog/2013/01/15/fixing-skip-to-content-links/
    99101         */
    100         $( window ).on( 'hashchange', function() {
     102        _window.on( 'hashchange', function() {
    101103                var element = $( location.hash );
    102104
    103105                if ( element ) {