forked from mirror/_s
_s: First pass at keyboard navigation in image templates
git-svn-id: https://wpcom-themes.svn.automattic.com/_s/@8845 d957f892-c61d-0410-b221-f235e6eecf30
This commit is contained in:
parent
2428d6a051
commit
293458cbd7
|
@ -6,7 +6,9 @@
|
||||||
* @since _s 1.0
|
* @since _s 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
get_header(); ?>
|
get_header();
|
||||||
|
wp_enqueue_script( 'keyboard-navigation', get_template_directory_uri() . '/js/keyboard-navigation.js', array( 'jquery' ), '02-02-2012' );
|
||||||
|
?>
|
||||||
|
|
||||||
<div id="primary" class="site-content" class="image-attachment">
|
<div id="primary" class="site-content" class="image-attachment">
|
||||||
<div id="content" role="main">
|
<div id="content" role="main">
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
jQuery( document ).ready( function( $ ) {
|
||||||
|
$( document ).keydown( function( e ) {
|
||||||
|
var url = false;
|
||||||
|
if ( e.which == 37 ) { // Left arrow key code
|
||||||
|
url = $( '.previous-image a' ).attr( 'href' );
|
||||||
|
}
|
||||||
|
else if ( e.which == 39 ) { // Right arrow key code
|
||||||
|
url = $( '.next-image a' ).attr( 'href' );
|
||||||
|
}
|
||||||
|
if ( url && ( !$( 'textarea, input' ).is( ':focus' ) ) ) {
|
||||||
|
window.location = url;
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
} );
|
Reference in New Issue