Skip to content

Instantly share code, notes, and snippets.

@masak
Last active December 11, 2015 03:38
Show Gist options
  • Save masak/4539134 to your computer and use it in GitHub Desktop.
Save masak/4539134 to your computer and use it in GitHub Desktop.
A simple presentation framwork in HTML and jQuery
<!doctype html>
<html lang=en>
<head>
<meta charset=utf-8>
<titleExample presentation</title>
<link href='http://fonts.googleapis.com/css?family=IM+Fell+DW+Pica+SC' rel='stylesheet' type='text/css'>
<style>
body {
font-family: "IM Fell DW Pica SC", arial, serif;
font-size: 500%;
}
body, html {
height: 95%;
margin: none;
padding: none;
}
.slides {
height: 100%;
width: 100%;
display: table;
}
.slides div {
display: table-cell;
vertical-align: middle;
text-align: center;
}
</style>
</head>
<body>
<div class="slides">
<div>Slide 1</div>
<div>Slide 2</div>
<div>Slide 3</div>
</div>
<script src="jquery-1.8.0.min.js"></script>
<script>
"use strict";
$(document).ready(function() {
var currentSlide = 0;
var is_blanked = false;
var last_slide = $(".slides div").length - 1;
var hide_current_slide = function() {
$(".slides div").eq(currentSlide).hide();
};
var show_current_slide = function() {
$(".slides div").eq(currentSlide).show();
};
var change_slide_to = function(slide) {
hide_current_slide();
currentSlide = slide;
show_current_slide();
is_blanked = false;
};
var go_one_slide_forward = function() {
if (currentSlide < last_slide) {
change_slide_to(currentSlide + 1);
}
};
var go_one_slide_back = function() {
if (currentSlide > 0) {
change_slide_to(currentSlide - 1);
}
};
var go_to_first_slide = function() {
change_slide_to(0);
};
var go_to_last_slide = function() {
change_slide_to(last_slide);
};
var toggle_blank_slide = function() {
is_blanked = !is_blanked;
if (is_blanked) {
hide_current_slide();
}
else {
show_current_slide();
}
};
var key = {
PgUp: 33,
PgDn: 34,
Home: 36,
End: 35,
b: 66
};
$(".slides div").hide();
go_to_first_slide();
$(document).keydown(function(e) {
switch (e.keyCode) {
case key.PgUp: go_one_slide_back(); break;
case key.PgDn: go_one_slide_forward(); break;
case key.Home: go_to_first_slide(); break;
case key.End: go_to_last_slide(); break;
case key.b: toggle_blank_slide(); break;
}
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment