Created
November 15, 2011 00:46
-
-
Save trepmal/1365731 to your computer and use it in GitHub Desktop.
WordPress - Scroll-To-Top Admin Bar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Scroll-To-Top Admin Bar | |
Description: Click anywhere on the Admin Bar that doesn't have a predefined purpose (links, input), and it'll scroll you to the top | |
Author: Kailey Lampert | |
Author URI: http://kaileylampert.com | |
*/ | |
add_action( 'wp_head', 'add_jq' ); | |
add_action( 'admin_head', 'add_jq' ); | |
function add_jq() { | |
wp_enqueue_script( 'jquery' ); | |
} | |
add_action( 'wp_footer', 'add_jq_init' ); | |
add_action( 'admin_footer', 'add_jq_init' ); | |
function add_jq_init() { | |
?> | |
<script type="text/javascript"> | |
jQuery(document).ready( function($) { | |
$('#wpadminbar').click( function(e) { | |
tag = e.target.tagName; | |
if ( tag == 'DIV' ) { | |
$('html, body').animate({scrollTop:0}, 'fast'); | |
return false; | |
} | |
}); | |
}); | |
</script> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment