1/** 2 * Functionality specific to Revised. 3 * 4 * Provides helper functions to enhance the theme experience. 5 * 6 * The following function is adopted from the original theme Twenty Thirteen 7 */ 8 9( function( $ ) { 10 var body = $( 'body' ), 11 _window = $( window ); 12 13 /** 14 * Adds a top margin to the footer if the sidebar widget area is higher 15 * than the rest of the page, to help the footer always visually clear 16 * the sidebar. 17 */ 18 $( function() { 19 if ( body.is( '.sidebar' ) ) { 20 var sidebar = $( '#secondary .widget-area' ), 21 secondary = ( 0 == sidebar.length ) ? -40 : sidebar.height(), 22 margin = $( '#tertiary .widget-area' ).height() - $( '#content' ).height(); 23 24 if ( margin > 0 && _window.innerWidth() > 999 ) 25 $( '#colophon' ).css( 'margin-top', margin + 'px' ); 26 } 27 } ); 28 29 /** 30 * Enables menu toggle for small screens. 31 */ 32 ( function() { 33 var nav = $( '#site-navigation' ), button, menu; 34 if ( ! nav ) 35 return; 36 37 button = nav.find( '.menu-toggle' ); 38 if ( ! button ) 39 return; 40 41 // Hide button if menu is missing or empty. 42 menu = nav.find( '.nav-menu' ); 43 if ( ! menu || ! menu.children().length ) { 44 button.hide(); 45 return; 46 } 47 48 $( '.menu-toggle' ).on( 'click.revised', function() { 49 nav.toggleClass( 'toggled-on' ); 50 } ); 51 } )(); 52 53 /** 54 * Makes "skip to content" link work correctly in IE9 and Chrome for better 55 * accessibility. 56 * 57 * @link http://www.nczonline.net/blog/2013/01/15/fixing-skip-to-content-links/ 58 */ 59 _window.on( 'hashchange.revised', function() { 60 var element = document.getElementById( location.hash.substring( 1 ) ); 61 62 if ( element ) { 63 if ( ! /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) 64 element.tabIndex = -1; 65 66 element.focus(); 67 } 68 } ); 69 70 /** 71 * Arranges footer widgets vertically. 72 */ 73 if ( $.isFunction( $.fn.masonry ) ) { 74 var columnWidth = body.is( '.sidebar' ) ? 228 : 245; 75 76 $( '#secondary .widget-area' ).masonry( { 77 itemSelector: '.widget', 78 columnWidth: columnWidth, 79 gutterWidth: 20, 80 isRTL: body.is( '.rtl' ) 81 } ); 82 } 83} )( jQuery ); 84 85 /** 86 * Make menu stick at the top of the screen when user scrolls down the page. 87 * Adopted from the plugin T&P Navigation Menu - http://wordpress.org/plugins/tp-navigation-menu/ 88 * Copyright 2011 Peyman Shadpour and Tzahi Raz ([email protected]) 89 * Modified for use with Revised by Zulfikar Nore - http://www.wpstrapcode.com ([email protected]) 90 */ 91 jQuery(function() { 92 93 // grab the initial top offset of the navigation 94 var revised_navigation_offset_top = jQuery('#navbar').offset().top; 95 96 // our function that decides weather the navigation bar should have "fixed" css position or not. 97 var revised_navigation = function(){ 98 var scroll_top = jQuery(window).scrollTop(); // our current vertical position from the top 99 100 // if we've scrolled more than the navigation, change its position to fixed to stick to top, otherwise change it back to relative 101 if (scroll_top > revised_navigation_offset_top) { 102 jQuery('#navbar').css({ 'position': 'fixed', 'z-index': 9999, 'top':0 }); 103 jQuery('body.admin-bar #navbar').css({ 'position': 'fixed', 'z-index': 9999, 'top':28 }); 104 jQuery('#navbar').css({ 'box-shadow': '0 0 5px #999999' }); 105 } else { 106 jQuery('#navbar').css({ 'position': 'relative', 'top':0 }); 107 jQuery('#navbar').css({ 'background': '#F7F5E7' }); 108 jQuery('#navbar').css({ 'box-shadow': 'none' }); 109 } 110 }; 111 112 // run our function on load 113 revised_navigation(); 114 115 // and run it again every time you scroll 116 jQuery(window).scroll(function() { 117 revised_navigation(); 118 }); 119 120}); 121 122/** 123 * Revised Theme Scroll Top Script - Copyright: WP Strap Code - 2013 wpstrapcode.com. License: GPL3 124*/ 125jQuery(document).ready(function($){ 126 $(window).scroll(function(){ 127 if ($(this).scrollTop() > 50) { 128 $('.backToTop').fadeIn('slow'); 129 } else { 130 $('.backToTop').fadeOut('slow'); 131 } 132 });
133 $('.backToTop').click(function(){ 134 $("html, body").animate({ scrollTop: 0 }, 500); 135 return false; 136 }); 137});
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.