bmstu-mt-wp/scripts/script.js

56 lines
1.3 KiB
JavaScript
Raw Normal View History

2010-10-30 04:16:19 +04:00
$(function() {
var slides = $( 'section.slide' );
function fullScreen() {
return (
window.screenX == 0 &&
window.screenY == 0 &&
screen.width == window.outerWidth &&
screen.height == window.outerHeight
) ? true : false;
}
function turnSlide( e ) {
if( !fullScreen() ) return;
var current = $( document.location.hash );
switch ( e.which ) {
case 33 : // PgUp
case 38 : // Up
case 37 : // Left
var target = current.prev( slides );
break;
case 34 : // PgDown
case 40 : // Down
case 39 : // Right
var target = current.next( slides );
break;
2010-10-31 08:57:17 +03:00
case 32 : // Space
var target = current[ e.shiftKey ? 'prev' : 'next' ]( slides );
2010-10-31 08:57:17 +03:00
break;
2010-10-30 04:16:19 +04:00
default:
return;
}
e.preventDefault();
2010-10-31 08:59:04 +03:00
if( !target.length ) return;
2010-10-30 04:16:19 +04:00
else document.location.hash = '#' + target.attr( 'id' );
}
function updateView() {
var screen = $( 'link[title=screen]' ),
projection = $( 'link[title=projection]' ),
fullscreen = fullScreen();
screen.attr( 'disabled', fullscreen );
projection.attr( 'disabled', !fullscreen );
if( !fullscreen || $( document.location.hash ).length ) return;
else document.location.hash = '#' + slides.first().attr( 'id' );
}
$( document ).
keyup( turnSlide );
$( window ).
ready( updateView ).
resize( updateView );
});