]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-content/themes/twentyfourteen/js/functions.js
WordPress 4.0
[autoinstalls/wordpress.git] / wp-content / themes / twentyfourteen / js / functions.js
index add41087b2c16974f59efc5a5861c7422f78c3fb..7eddd83ef3750f71e7b298e81f18b06b197ed60e 100644 (file)
         * @link http://www.nczonline.net/blog/2013/01/15/fixing-skip-to-content-links/
         */
        _window.on( 'hashchange.twentyfourteen', function() {
-               var element = document.getElementById( location.hash.substring( 1 ) );
+               var hash = location.hash.substring( 1 ), element;
+
+               if ( ! hash ) {
+                       return;
+               }
+
+               element = document.getElementById( hash );
 
                if ( element ) {
                        if ( ! /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) {
@@ -88,7 +94,7 @@
                                mastheadOffset = $( '#masthead' ).offset().top - toolbarOffset;
 
                                _window.on( 'scroll.twentyfourteen', function() {
-                                       if ( ( window.scrollY > mastheadOffset ) && ( mastheadHeight < 49 ) ) {
+                                       if ( _window.scrollTop() > mastheadOffset && mastheadHeight < 49 ) {
                                                body.addClass( 'masthead-fixed' );
                                        } else {
                                                body.removeClass( 'masthead-fixed' );
                } );
        } );
 
-       // Arrange footer widgets vertically.
-       if ( $.isFunction( $.fn.masonry ) ) {
-               $( '#footer-sidebar' ).masonry( {
-                       itemSelector: '.widget',
-                       columnWidth: function( containerWidth ) {
-                               return containerWidth / 4;
-                       },
-                       gutterWidth: 0,
-                       isResizable: true,
-                       isRTL: $( 'body' ).is( '.rtl' )
-               } );
-       }
-
-       // Initialize Featured Content slider.
        _window.load( function() {
+               // Arrange footer widgets vertically.
+               if ( $.isFunction( $.fn.masonry ) ) {
+                       $( '#footer-sidebar' ).masonry( {
+                               itemSelector: '.widget',
+                               columnWidth: function( containerWidth ) {
+                                       return containerWidth / 4;
+                               },
+                               gutterWidth: 0,
+                               isResizable: true,
+                               isRTL: $( 'body' ).is( '.rtl' )
+                       } );
+               }
+
+               // Initialize Featured Content slider.
                if ( body.is( '.slider' ) ) {
                        $( '.featured-content' ).featuredslider( {
                                selector: '.featured-content-inner > article',