Initial commit.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
.goto-form {
|
||||
position: absolute;
|
||||
z-index: 3;
|
||||
bottom: 10px;
|
||||
left: 50%;
|
||||
height: 1.75em;
|
||||
margin: 0 0 0 -9.125em;
|
||||
line-height: 1.75em;
|
||||
padding: 0.625em;
|
||||
display: none;
|
||||
background: #ccc;
|
||||
overflow: hidden;
|
||||
border-radius: 10px;
|
||||
}
|
||||
.goto-form label {
|
||||
font-weight: bold;
|
||||
}
|
||||
.goto-form label, .goto-form input {
|
||||
display: inline-block;
|
||||
font-family: inherit;
|
||||
}
|
||||
.deck-goto .goto-form {
|
||||
display: block;
|
||||
}
|
||||
|
||||
#goto-slide {
|
||||
width: 8.375em;
|
||||
margin: 0 0.625em;
|
||||
height: 1.4375em;
|
||||
}
|
||||
|
||||
@media print {
|
||||
.goto-form, #goto-slide {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<!-- Place the following snippet at the bottom of the deck container. -->
|
||||
<form action="." method="get" class="goto-form">
|
||||
<label for="goto-slide">Go to slide:</label>
|
||||
<input type="text" name="slidenum" id="goto-slide" list="goto-datalist">
|
||||
<datalist id="goto-datalist"></datalist>
|
||||
<input type="submit" value="Go">
|
||||
</form>
|
||||
@@ -0,0 +1,190 @@
|
||||
/*!
|
||||
Deck JS - deck.goto
|
||||
Copyright (c) 2011-2014 Caleb Troughton
|
||||
Dual licensed under the MIT license.
|
||||
https://github.com/imakewebthings/deck.js/blob/master/MIT-license.txt
|
||||
*/
|
||||
|
||||
/*
|
||||
This module adds the necessary methods and key bindings to show and hide a form
|
||||
for jumping to any slide number/id in the deck (and processes that form
|
||||
accordingly). The form-showing state is indicated by the presence of a class on
|
||||
the deck container.
|
||||
*/
|
||||
(function($, undefined) {
|
||||
var $document = $(document);
|
||||
var rootCounter;
|
||||
|
||||
var bindKeyEvents = function() {
|
||||
$document.unbind('keydown.deckgoto');
|
||||
$document.bind('keydown.deckgoto', function(event) {
|
||||
var key = $.deck('getOptions').keys.goto;
|
||||
if (event.which === key || $.inArray(event.which, key) > -1) {
|
||||
event.preventDefault();
|
||||
$.deck('toggleGoTo');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var populateDatalist = function() {
|
||||
var options = $.deck('getOptions');
|
||||
var $datalist = $(options.selectors.gotoDatalist);
|
||||
|
||||
$.each($.deck('getSlides'), function(i, $slide) {
|
||||
var id = $slide.attr('id');
|
||||
if (id) {
|
||||
$datalist.append('<option value="' + id + '">');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var markRootSlides = function() {
|
||||
var options = $.deck('getOptions');
|
||||
var slideTest = $.map([
|
||||
options.classes.before,
|
||||
options.classes.previous,
|
||||
options.classes.current,
|
||||
options.classes.next,
|
||||
options.classes.after
|
||||
], function(el, i) {
|
||||
return '.' + el;
|
||||
}).join(', ');
|
||||
|
||||
rootCounter = 0;
|
||||
$.each($.deck('getSlides'), function(i, $slide) {
|
||||
var $parentSlides = $slide.parentsUntil(
|
||||
options.selectors.container,
|
||||
slideTest
|
||||
);
|
||||
|
||||
if ($parentSlides.length) {
|
||||
$slide.removeData('rootIndex');
|
||||
}
|
||||
else if (!options.countNested) {
|
||||
++rootCounter;
|
||||
$slide.data('rootIndex', rootCounter);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var handleFormSubmit = function() {
|
||||
var options = $.deck('getOptions');
|
||||
var $form = $(options.selectors.gotoForm);
|
||||
|
||||
$form.unbind('submit.deckgoto');
|
||||
$form.bind('submit.deckgoto', function(event) {
|
||||
var $field = $(options.selectors.gotoInput);
|
||||
var indexOrId = $field.val();
|
||||
var index = parseInt(indexOrId, 10);
|
||||
|
||||
if (!options.countNested) {
|
||||
if (!isNaN(index) && index >= rootCounter) {
|
||||
return false;
|
||||
}
|
||||
$.each($.deck('getSlides'), function(i, $slide) {
|
||||
if ($slide.data('rootIndex') === index) {
|
||||
index = i + 1;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$.deck('go', isNaN(index) ? indexOrId : index - 1);
|
||||
$.deck('hideGoTo');
|
||||
$field.val('');
|
||||
event.preventDefault();
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
Extends defaults/options.
|
||||
|
||||
options.classes.goto
|
||||
This class is added to the deck container when showing the Go To Slide
|
||||
form.
|
||||
|
||||
options.selectors.gotoDatalist
|
||||
The element that matches this selector is the datalist element that will
|
||||
be populated with options for each of the slide ids. In browsers that
|
||||
support the datalist element, this provides a drop list of slide ids to
|
||||
aid the user in selecting a slide.
|
||||
|
||||
options.selectors.gotoForm
|
||||
The element that matches this selector is the form that is submitted
|
||||
when a user hits enter after typing a slide number/id in the gotoInput
|
||||
element.
|
||||
|
||||
options.selectors.gotoInput
|
||||
The element that matches this selector is the text input field for
|
||||
entering a slide number/id in the Go To Slide form.
|
||||
|
||||
options.keys.goto
|
||||
The numeric keycode used to show the Go To Slide form.
|
||||
|
||||
options.countNested
|
||||
If false, only top level slides will be counted when entering a
|
||||
slide number.
|
||||
*/
|
||||
$.extend(true, $.deck.defaults, {
|
||||
classes: {
|
||||
goto: 'deck-goto'
|
||||
},
|
||||
|
||||
selectors: {
|
||||
gotoDatalist: '#goto-datalist',
|
||||
gotoForm: '.goto-form',
|
||||
gotoInput: '#goto-slide'
|
||||
},
|
||||
|
||||
keys: {
|
||||
goto: 71 // g
|
||||
},
|
||||
|
||||
countNested: true
|
||||
});
|
||||
|
||||
/*
|
||||
jQuery.deck('showGoTo')
|
||||
|
||||
Shows the Go To Slide form by adding the class specified by the goto class
|
||||
option to the deck container.
|
||||
*/
|
||||
$.deck('extend', 'showGoTo', function() {
|
||||
var options = $.deck('getOptions');
|
||||
$.deck('getContainer').addClass(options.classes.goto);
|
||||
$(options.selectors.gotoForm).attr('aria-hidden', false);
|
||||
$(options.selectors.gotoInput).focus();
|
||||
});
|
||||
|
||||
/*
|
||||
jQuery.deck('hideGoTo')
|
||||
|
||||
Hides the Go To Slide form by removing the class specified by the goto class
|
||||
option from the deck container.
|
||||
*/
|
||||
$.deck('extend', 'hideGoTo', function() {
|
||||
var options = $.deck('getOptions');
|
||||
$(options.selectors.gotoInput).blur();
|
||||
$.deck('getContainer').removeClass(options.classes.goto);
|
||||
$(options.selectors.gotoForm).attr('aria-hidden', true);
|
||||
});
|
||||
|
||||
/*
|
||||
jQuery.deck('toggleGoTo')
|
||||
|
||||
Toggles between showing and hiding the Go To Slide form.
|
||||
*/
|
||||
$.deck('extend', 'toggleGoTo', function() {
|
||||
var options = $.deck('getOptions');
|
||||
var hasGotoClass = $.deck('getContainer').hasClass(options.classes.goto);
|
||||
$.deck(hasGotoClass ? 'hideGoTo' : 'showGoTo');
|
||||
});
|
||||
|
||||
$document.bind('deck.init', function() {
|
||||
bindKeyEvents();
|
||||
populateDatalist();
|
||||
markRootSlides();
|
||||
handleFormSubmit();
|
||||
});
|
||||
})(jQuery);
|
||||
|
||||
Executable
+39
@@ -0,0 +1,39 @@
|
||||
.goto-form {
|
||||
position:absolute;
|
||||
z-index:3;
|
||||
bottom:10px;
|
||||
left:50%;
|
||||
height:1.75em;
|
||||
margin:0 0 0 -9.125em;
|
||||
line-height:1.75em;
|
||||
padding:0.625em;
|
||||
display:none;
|
||||
background:#ccc;
|
||||
overflow:hidden;
|
||||
border-radius:10px;
|
||||
|
||||
label {
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
label, input {
|
||||
display:inline-block;
|
||||
font-family:inherit;
|
||||
}
|
||||
|
||||
.deck-goto & {
|
||||
display:block;
|
||||
}
|
||||
}
|
||||
|
||||
#goto-slide {
|
||||
width:8.375em;
|
||||
margin:0 0.625em;
|
||||
height:1.4375em;
|
||||
}
|
||||
|
||||
@media print {
|
||||
.goto-form, #goto-slide {
|
||||
display:none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
.deck-menu {
|
||||
overflow: auto;
|
||||
}
|
||||
.deck-menu .slide {
|
||||
background: #eee;
|
||||
position: relative;
|
||||
left: 0;
|
||||
top: 0;
|
||||
visibility: visible;
|
||||
cursor: pointer;
|
||||
}
|
||||
.no-csstransforms .deck-menu > .slide {
|
||||
float: left;
|
||||
width: 22%;
|
||||
height: 22%;
|
||||
min-height: 0;
|
||||
margin: 1%;
|
||||
font-size: 0.22em;
|
||||
overflow: hidden;
|
||||
padding: 0 0.5%;
|
||||
}
|
||||
.csstransforms .deck-menu > .slide {
|
||||
-webkit-transform: scale(0.22) !important;
|
||||
-ms-transform: scale(0.22) !important;
|
||||
transform: scale(0.22) !important;
|
||||
-webkit-transform-origin: 0 0;
|
||||
-ms-transform-origin: 0 0;
|
||||
transform-origin: 0 0;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
padding: 0 48px;
|
||||
margin: 12px;
|
||||
}
|
||||
.deck-menu iframe, .deck-menu img, .deck-menu video {
|
||||
max-width: 100%;
|
||||
}
|
||||
.deck-menu .deck-current, .no-touch .deck-menu .slide:hover {
|
||||
background: #ddf;
|
||||
}
|
||||
.deck-menu.deck-container:hover .deck-prev-link, .deck-menu.deck-container:hover .deck-next-link {
|
||||
display: none;
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
/*!
|
||||
Deck JS - deck.menu
|
||||
Copyright (c) 2011-2014 Caleb Troughton
|
||||
Dual licensed under the MIT license.
|
||||
https://github.com/imakewebthings/deck.js/blob/master/MIT-license.txt
|
||||
*/
|
||||
|
||||
/*
|
||||
This module adds the methods and key binding to show and hide a menu of all
|
||||
slides in the deck. The deck menu state is indicated by the presence of a class
|
||||
on the deck container.
|
||||
*/
|
||||
(function($, undefined) {
|
||||
var $document = $(document);
|
||||
var $html = $('html');
|
||||
var rootSlides;
|
||||
|
||||
var populateRootSlidesArray = function() {
|
||||
var options = $.deck('getOptions');
|
||||
var slideTest = $.map([
|
||||
options.classes.before,
|
||||
options.classes.previous,
|
||||
options.classes.current,
|
||||
options.classes.next,
|
||||
options.classes.after
|
||||
], function(el, i) {
|
||||
return '.' + el;
|
||||
}).join(', ');
|
||||
|
||||
rootSlides = [];
|
||||
$.each($.deck('getSlides'), function(i, $slide) {
|
||||
var $parentSlides = $slide.parentsUntil(
|
||||
options.selectors.container,
|
||||
slideTest
|
||||
);
|
||||
if (!$parentSlides.length) {
|
||||
rootSlides.push($slide);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var bindKeyEvents = function() {
|
||||
var options = $.deck('getOptions');
|
||||
$document.unbind('keydown.deckmenu');
|
||||
$document.bind('keydown.deckmenu', function(event) {
|
||||
var isMenuKey = event.which === options.keys.menu;
|
||||
isMenuKey = isMenuKey || $.inArray(event.which, options.keys.menu) > -1;
|
||||
if (isMenuKey && !event.ctrlKey) {
|
||||
$.deck('toggleMenu');
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var bindTouchEvents = function() {
|
||||
var $container = $.deck('getContainer');
|
||||
var options = $.deck('getOptions');
|
||||
var touchEndTime = 0;
|
||||
var currentSlide;
|
||||
|
||||
$container.unbind('touchstart.deckmenu');
|
||||
$container.bind('touchstart.deckmenu', function() {
|
||||
currentSlide = $.deck('getSlide');
|
||||
});
|
||||
$container.unbind('touchend.deckmenu');
|
||||
$container.bind('touchend.deckmenu', function(event) {
|
||||
var now = Date.now();
|
||||
var isDoubletap = now - touchEndTime < options.touch.doubletapWindow;
|
||||
|
||||
// Ignore this touch event if it caused a nav change (swipe)
|
||||
if (currentSlide !== $.deck('getSlide')) {
|
||||
return;
|
||||
}
|
||||
if (isDoubletap) {
|
||||
$.deck('toggleMenu');
|
||||
event.preventDefault();
|
||||
}
|
||||
touchEndTime = now;
|
||||
});
|
||||
};
|
||||
|
||||
var setupMenuSlideSelection = function() {
|
||||
var options = $.deck('getOptions');
|
||||
|
||||
$.each($.deck('getSlides'), function(i, $slide) {
|
||||
$slide.unbind('click.deckmenu');
|
||||
$slide.bind('click.deckmenu', function(event) {
|
||||
if (!$.deck('getContainer').hasClass(options.classes.menu)) {
|
||||
return;
|
||||
}
|
||||
$.deck('go', i);
|
||||
$.deck('hideMenu');
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
Extends defaults/options.
|
||||
|
||||
options.classes.menu
|
||||
This class is added to the deck container when showing the slide menu.
|
||||
|
||||
options.keys.menu
|
||||
The numeric keycode used to toggle between showing and hiding the slide
|
||||
menu.
|
||||
|
||||
options.touch.doubletapWindow
|
||||
Two consecutive touch events within this number of milliseconds will
|
||||
be considered a double tap, and will toggle the menu on touch devices.
|
||||
*/
|
||||
$.extend(true, $.deck.defaults, {
|
||||
classes: {
|
||||
menu: 'deck-menu'
|
||||
},
|
||||
|
||||
keys: {
|
||||
menu: 77 // m
|
||||
},
|
||||
|
||||
touch: {
|
||||
doubletapWindow: 400
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
jQuery.deck('showMenu')
|
||||
|
||||
Shows the slide menu by adding the class specified by the menu class option
|
||||
to the deck container.
|
||||
*/
|
||||
$.deck('extend', 'showMenu', function() {
|
||||
var $container = $.deck('getContainer');
|
||||
var options = $.deck('getOptions');
|
||||
|
||||
if ($container.hasClass(options.classes.menu)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Hide through loading class to short-circuit transitions (perf)
|
||||
$container.addClass([
|
||||
options.classes.loading,
|
||||
options.classes.menu
|
||||
].join(' '));
|
||||
|
||||
/* Forced to do this in JS until CSS learns second-grade math. Save old
|
||||
style value for restoration when menu is hidden. */
|
||||
if (Modernizr.csstransforms) {
|
||||
$.each(rootSlides, function(i, $slide) {
|
||||
$slide.data('oldStyle', $slide.attr('style'));
|
||||
$slide.css({
|
||||
'position': 'absolute',
|
||||
'left': ((i % 4) * 25) + '%',
|
||||
'top': (Math.floor(i / 4) * 25) + '%'
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Need to ensure the loading class renders first, then remove
|
||||
window.setTimeout(function() {
|
||||
$container.removeClass(options.classes.loading);
|
||||
$container.scrollTop($.deck('getSlide').position().top);
|
||||
}, 0);
|
||||
});
|
||||
|
||||
/*
|
||||
jQuery.deck('hideMenu')
|
||||
|
||||
Hides the slide menu by removing the class specified by the menu class
|
||||
option from the deck container.
|
||||
*/
|
||||
$.deck('extend', 'hideMenu', function() {
|
||||
var $container = $.deck('getContainer');
|
||||
var options = $.deck('getOptions');
|
||||
|
||||
if (!$container.hasClass(options.classes.menu)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$container.removeClass(options.classes.menu);
|
||||
$container.addClass(options.classes.loading);
|
||||
|
||||
/* Restore old style value */
|
||||
if (Modernizr.csstransforms) {
|
||||
$.each(rootSlides, function(i, $slide) {
|
||||
var oldStyle = $slide.data('oldStyle');
|
||||
$slide.attr('style', oldStyle ? oldStyle : '');
|
||||
});
|
||||
}
|
||||
|
||||
window.setTimeout(function() {
|
||||
$container.removeClass(options.classes.loading);
|
||||
$container.scrollTop(0);
|
||||
}, 0);
|
||||
});
|
||||
|
||||
/*
|
||||
jQuery.deck('toggleMenu')
|
||||
|
||||
Toggles between showing and hiding the slide menu.
|
||||
*/
|
||||
$.deck('extend', 'toggleMenu', function() {
|
||||
$.deck('getContainer').hasClass($.deck('getOptions').classes.menu) ?
|
||||
$.deck('hideMenu') : $.deck('showMenu');
|
||||
});
|
||||
|
||||
$document.bind('deck.init', function() {
|
||||
populateRootSlidesArray();
|
||||
bindKeyEvents();
|
||||
bindTouchEvents();
|
||||
setupMenuSlideSelection();
|
||||
});
|
||||
|
||||
$document.bind('deck.change', function(event, from, to) {
|
||||
var $container = $.deck('getContainer');
|
||||
var containerScroll, slideTop;
|
||||
|
||||
if ($container.hasClass($.deck('getOptions').classes.menu)) {
|
||||
containerScroll = $container.scrollTop();
|
||||
slideTop = $.deck('getSlide', to).position().top;
|
||||
$container.scrollTop(containerScroll + slideTop);
|
||||
}
|
||||
});
|
||||
})(jQuery);
|
||||
Executable
+55
@@ -0,0 +1,55 @@
|
||||
.deck-menu {
|
||||
overflow:auto;
|
||||
|
||||
.slide {
|
||||
background:#eee;
|
||||
position:relative;
|
||||
left:0;
|
||||
top:0;
|
||||
visibility:visible;
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
> .slide {
|
||||
.no-csstransforms & {
|
||||
float:left;
|
||||
width:22%;
|
||||
height:22%;
|
||||
min-height:0;
|
||||
margin:1%;
|
||||
font-size:0.22em;
|
||||
overflow:hidden;
|
||||
padding:0 0.5%;
|
||||
}
|
||||
|
||||
.csstransforms & {
|
||||
-webkit-transform:scale(.22) !important;
|
||||
-ms-transform:scale(.22) !important;
|
||||
transform:scale(.22) !important;
|
||||
-webkit-transform-origin:0 0;
|
||||
-ms-transform-origin:0 0;
|
||||
transform-origin:0 0;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
width:100%;
|
||||
height:100%;
|
||||
overflow:hidden;
|
||||
padding:0 48px;
|
||||
margin:12px;
|
||||
}
|
||||
}
|
||||
|
||||
iframe, img, video {
|
||||
max-width:100%;
|
||||
}
|
||||
|
||||
.deck-current, .no-touch & .slide:hover {
|
||||
background:#ddf;
|
||||
}
|
||||
|
||||
&.deck-container:hover {
|
||||
.deck-prev-link, .deck-next-link {
|
||||
display:none;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
.deck-prev-link, .deck-next-link {
|
||||
display: none;
|
||||
position: absolute;
|
||||
z-index: 3;
|
||||
top: 50%;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
margin-top: -16px;
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
line-height: 32px;
|
||||
vertical-align: middle;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
color: #fff;
|
||||
background: #888;
|
||||
border-radius: 16px;
|
||||
}
|
||||
.deck-prev-link:hover, .deck-prev-link:focus, .deck-prev-link:active, .deck-prev-link:visited, .deck-next-link:hover, .deck-next-link:focus, .deck-next-link:active, .deck-next-link:visited {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.deck-prev-link {
|
||||
left: 8px;
|
||||
}
|
||||
|
||||
.deck-next-link {
|
||||
right: 8px;
|
||||
}
|
||||
|
||||
.deck-container:hover .deck-prev-link, .deck-container:hover .deck-next-link {
|
||||
display: block;
|
||||
}
|
||||
.deck-container:hover .deck-prev-link.deck-nav-disabled, .touch .deck-container:hover .deck-prev-link, .deck-container:hover .deck-next-link.deck-nav-disabled, .touch .deck-container:hover .deck-next-link {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media print {
|
||||
.deck-prev-link, .deck-next-link {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<!-- Place the following snippet at the bottom of the deck container. -->
|
||||
<div aria-role="navigation">
|
||||
<a href="#" class="deck-prev-link" title="Previous">←</a>
|
||||
<a href="#" class="deck-next-link" title="Next">→</a>
|
||||
</div>
|
||||
@@ -0,0 +1,94 @@
|
||||
/*!
|
||||
Deck JS - deck.navigation
|
||||
Copyright (c) 2011-2014 Caleb Troughton
|
||||
Dual licensed under the MIT license.
|
||||
https://github.com/imakewebthings/deck.js/blob/master/MIT-license.txt
|
||||
*/
|
||||
|
||||
/*
|
||||
This module adds clickable previous and next links to the deck.
|
||||
*/
|
||||
(function($, undefined) {
|
||||
var $document = $(document);
|
||||
|
||||
/* Updates link hrefs, and disabled states if last/first slide */
|
||||
var updateButtons = function(event, from, to) {
|
||||
var options = $.deck('getOptions');
|
||||
var lastIndex = $.deck('getSlides').length - 1;
|
||||
var $prevSlide = $.deck('getSlide', to - 1);
|
||||
var $nextSlide = $.deck('getSlide', to + 1);
|
||||
var hrefBase = window.location.href.replace(/#.*/, '');
|
||||
var prevId = $prevSlide ? $prevSlide.attr('id') : undefined;
|
||||
var nextId = $nextSlide ? $nextSlide.attr('id') : undefined;
|
||||
var $prevButton = $(options.selectors.previousLink);
|
||||
var $nextButton = $(options.selectors.nextLink);
|
||||
|
||||
$prevButton.toggleClass(options.classes.navDisabled, to === 0);
|
||||
$prevButton.attr('aria-disabled', to === 0);
|
||||
$prevButton.attr('href', hrefBase + '#' + (prevId ? prevId : ''));
|
||||
$nextButton.toggleClass(options.classes.navDisabled, to === lastIndex);
|
||||
$nextButton.attr('aria-disabled', to === lastIndex);
|
||||
$nextButton.attr('href', hrefBase + '#' + (nextId ? nextId : ''));
|
||||
};
|
||||
|
||||
/*
|
||||
Extends defaults/options.
|
||||
|
||||
options.classes.navDisabled
|
||||
This class is added to a navigation link when that action is disabled.
|
||||
It is added to the previous link when on the first slide, and to the
|
||||
next link when on the last slide.
|
||||
|
||||
options.selectors.nextLink
|
||||
The elements that match this selector will move the deck to the next
|
||||
slide when clicked.
|
||||
|
||||
options.selectors.previousLink
|
||||
The elements that match this selector will move to deck to the previous
|
||||
slide when clicked.
|
||||
*/
|
||||
$.extend(true, $.deck.defaults, {
|
||||
classes: {
|
||||
navDisabled: 'deck-nav-disabled'
|
||||
},
|
||||
|
||||
selectors: {
|
||||
nextLink: '.deck-next-link',
|
||||
previousLink: '.deck-prev-link'
|
||||
}
|
||||
});
|
||||
|
||||
$document.bind('deck.init', function() {
|
||||
var options = $.deck('getOptions');
|
||||
var slides = $.deck('getSlides');
|
||||
var $current = $.deck('getSlide');
|
||||
var $prevButton = $(options.selectors.previousLink);
|
||||
var $nextButton = $(options.selectors.nextLink);
|
||||
var index;
|
||||
|
||||
// Setup prev/next link events
|
||||
$prevButton.unbind('click.decknavigation');
|
||||
$prevButton.bind('click.decknavigation', function(event) {
|
||||
$.deck('prev');
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
$nextButton.unbind('click.decknavigation');
|
||||
$nextButton.bind('click.decknavigation', function(event) {
|
||||
$.deck('next');
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
// Find where we started in the deck and set initial states
|
||||
$.each(slides, function(i, $slide) {
|
||||
if ($slide === $current) {
|
||||
index = i;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
updateButtons(null, index, index);
|
||||
});
|
||||
|
||||
$document.bind('deck.change', updateButtons);
|
||||
})(jQuery);
|
||||
|
||||
Executable
+44
@@ -0,0 +1,44 @@
|
||||
.deck-prev-link, .deck-next-link {
|
||||
display:none;
|
||||
position:absolute;
|
||||
z-index:3;
|
||||
top:50%;
|
||||
width:32px;
|
||||
height:32px;
|
||||
margin-top:-16px;
|
||||
font-size:20px;
|
||||
font-weight:bold;
|
||||
line-height:32px;
|
||||
vertical-align:middle;
|
||||
text-align:center;
|
||||
text-decoration:none;
|
||||
color:#fff;
|
||||
background:#888;
|
||||
border-radius:16px;
|
||||
|
||||
&:hover, &:focus, &:active, &:visited {
|
||||
color:#fff;
|
||||
}
|
||||
}
|
||||
|
||||
.deck-prev-link {
|
||||
left:8px;
|
||||
}
|
||||
|
||||
.deck-next-link {
|
||||
right:8px;
|
||||
}
|
||||
|
||||
.deck-container:hover .deck-prev-link, .deck-container:hover .deck-next-link {
|
||||
display:block;
|
||||
|
||||
&.deck-nav-disabled, .touch & {
|
||||
display:none;
|
||||
}
|
||||
}
|
||||
|
||||
@media print {
|
||||
.deck-prev-link, .deck-next-link {
|
||||
display:none !important;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
.csstransforms .deck-container.deck-scale:not(.deck-menu) {
|
||||
overflow: hidden;
|
||||
}
|
||||
.csstransforms .deck-container.deck-scale:not(.deck-menu) > .slide {
|
||||
-moz-box-sizing: padding-box;
|
||||
box-sizing: padding-box;
|
||||
width: 100%;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
.csstransforms .deck-container.deck-scale:not(.deck-menu) > .slide > .deck-slide-scaler {
|
||||
-webkit-transform-origin: 50% 0;
|
||||
-ms-transform-origin: 50% 0;
|
||||
transform-origin: 50% 0;
|
||||
}
|
||||
|
||||
.csstransforms .deck-container.deck-menu .deck-slide-scaler {
|
||||
-webkit-transform: none !important;
|
||||
-ms-transform: none !important;
|
||||
transform: none !important;
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
/*!
|
||||
Deck JS - deck.scale
|
||||
Copyright (c) 2011-2014 Caleb Troughton
|
||||
Dual licensed under the MIT license.
|
||||
https://github.com/imakewebthings/deck.js/blob/master/MIT-license.txt
|
||||
*/
|
||||
|
||||
/*
|
||||
This module adds automatic scaling to the deck. Slides are scaled down
|
||||
using CSS transforms to fit within the deck container. If the container is
|
||||
big enough to hold the slides without scaling, no scaling occurs. The user
|
||||
can disable and enable scaling with a keyboard shortcut.
|
||||
|
||||
Note: CSS transforms may make Flash videos render incorrectly. Presenters
|
||||
that need to use video may want to disable scaling to play them. HTML5 video
|
||||
works fine.
|
||||
*/
|
||||
(function($, undefined) {
|
||||
var $document = $(document);
|
||||
var $window = $(window);
|
||||
var baseHeight, timer, rootSlides;
|
||||
|
||||
/*
|
||||
Internal function to do all the dirty work of scaling the slides.
|
||||
*/
|
||||
var scaleDeck = function() {
|
||||
var options = $.deck('getOptions');
|
||||
var $container = $.deck('getContainer');
|
||||
var baseHeight = options.baseHeight;
|
||||
|
||||
if (!baseHeight) {
|
||||
baseHeight = $container.height();
|
||||
}
|
||||
|
||||
// Scale each slide down if necessary (but don't scale up)
|
||||
$.each(rootSlides, function(i, $slide) {
|
||||
var slideHeight = $slide.innerHeight();
|
||||
var $scaler = $slide.find('.' + options.classes.scaleSlideWrapper);
|
||||
var shouldScale = $container.hasClass(options.classes.scale);
|
||||
var scale = shouldScale ? baseHeight / slideHeight : 1;
|
||||
|
||||
if (scale === 1) {
|
||||
$scaler.css('transform', '');
|
||||
}
|
||||
else {
|
||||
$scaler.css('transform', 'scale(' + scale + ')');
|
||||
window.setTimeout(function() {
|
||||
$container.scrollTop(0)
|
||||
}, 1);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var populateRootSlides = function() {
|
||||
var options = $.deck('getOptions');
|
||||
var slideTest = $.map([
|
||||
options.classes.before,
|
||||
options.classes.previous,
|
||||
options.classes.current,
|
||||
options.classes.next,
|
||||
options.classes.after
|
||||
], function(el, i) {
|
||||
return '.' + el;
|
||||
}).join(', ');
|
||||
|
||||
rootSlides = [];
|
||||
$.each($.deck('getSlides'), function(i, $slide) {
|
||||
var $parentSlides = $slide.parentsUntil(
|
||||
options.selectors.container,
|
||||
slideTest
|
||||
);
|
||||
if (!$parentSlides.length) {
|
||||
rootSlides.push($slide);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var wrapRootSlideContent = function() {
|
||||
var options = $.deck('getOptions');
|
||||
var wrap = '<div class="' + options.classes.scaleSlideWrapper + '"/>';
|
||||
$.each(rootSlides, function(i, $slide) {
|
||||
$slide.children().wrapAll(wrap);
|
||||
});
|
||||
};
|
||||
|
||||
var scaleOnResizeAndLoad = function() {
|
||||
var options = $.deck('getOptions');
|
||||
|
||||
$window.unbind('resize.deckscale');
|
||||
$window.bind('resize.deckscale', function() {
|
||||
window.clearTimeout(timer);
|
||||
timer = window.setTimeout(scaleDeck, options.scaleDebounce);
|
||||
});
|
||||
$.deck('enableScale');
|
||||
$window.unbind('load.deckscale');
|
||||
$window.bind('load.deckscale', scaleDeck);
|
||||
};
|
||||
|
||||
var bindKeyEvents = function() {
|
||||
var options = $.deck('getOptions');
|
||||
$document.unbind('keydown.deckscale');
|
||||
$document.bind('keydown.deckscale', function(event) {
|
||||
var isKey = event.which === options.keys.scale;
|
||||
isKey = isKey || $.inArray(event.which, options.keys.scale) > -1;
|
||||
if (isKey) {
|
||||
$.deck('toggleScale');
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
Extends defaults/options.
|
||||
|
||||
options.classes.scale
|
||||
This class is added to the deck container when scaling is enabled.
|
||||
It is enabled by default when the module is included.
|
||||
|
||||
options.classes.scaleSlideWrapper
|
||||
Scaling is done using a wrapper around the contents of each slide. This
|
||||
class is applied to that wrapper.
|
||||
|
||||
options.keys.scale
|
||||
The numeric keycode used to toggle enabling and disabling scaling.
|
||||
|
||||
options.baseHeight
|
||||
When baseHeight is falsy, as it is by default, the deck is scaled in
|
||||
proportion to the height of the deck container. You may instead specify
|
||||
a height as a number of px, and slides will be scaled against this
|
||||
height regardless of the container size.
|
||||
|
||||
options.scaleDebounce
|
||||
Scaling on the browser resize event is debounced. This number is the
|
||||
threshold in milliseconds. You can learn more about debouncing here:
|
||||
http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/
|
||||
|
||||
*/
|
||||
$.extend(true, $.deck.defaults, {
|
||||
classes: {
|
||||
scale: 'deck-scale',
|
||||
scaleSlideWrapper: 'deck-slide-scaler'
|
||||
},
|
||||
|
||||
keys: {
|
||||
scale: 83 // s
|
||||
},
|
||||
|
||||
baseHeight: null,
|
||||
scaleDebounce: 200
|
||||
});
|
||||
|
||||
/*
|
||||
jQuery.deck('disableScale')
|
||||
|
||||
Disables scaling and removes the scale class from the deck container.
|
||||
*/
|
||||
$.deck('extend', 'disableScale', function() {
|
||||
$.deck('getContainer').removeClass($.deck('getOptions').classes.scale);
|
||||
scaleDeck();
|
||||
});
|
||||
|
||||
/*
|
||||
jQuery.deck('enableScale')
|
||||
|
||||
Enables scaling and adds the scale class to the deck container.
|
||||
*/
|
||||
$.deck('extend', 'enableScale', function() {
|
||||
$.deck('getContainer').addClass($.deck('getOptions').classes.scale);
|
||||
scaleDeck();
|
||||
});
|
||||
|
||||
/*
|
||||
jQuery.deck('toggleScale')
|
||||
|
||||
Toggles between enabling and disabling scaling.
|
||||
*/
|
||||
$.deck('extend', 'toggleScale', function() {
|
||||
var $container = $.deck('getContainer');
|
||||
var isScaled = $container.hasClass($.deck('getOptions').classes.scale);
|
||||
$.deck(isScaled? 'disableScale' : 'enableScale');
|
||||
});
|
||||
|
||||
$document.bind('deck.init', function() {
|
||||
populateRootSlides();
|
||||
wrapRootSlideContent();
|
||||
scaleOnResizeAndLoad();
|
||||
bindKeyEvents();
|
||||
});
|
||||
})(jQuery, 'deck', this);
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
.csstransforms .deck-container.deck-scale:not(.deck-menu) {
|
||||
overflow:hidden;
|
||||
|
||||
> .slide {
|
||||
-moz-box-sizing: padding-box;
|
||||
box-sizing: padding-box;
|
||||
width:100%;
|
||||
padding-bottom:20px;
|
||||
|
||||
> .deck-slide-scaler {
|
||||
-webkit-transform-origin: 50% 0;
|
||||
-ms-transform-origin: 50% 0;
|
||||
transform-origin: 50% 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.csstransforms .deck-container.deck-menu .deck-slide-scaler {
|
||||
-webkit-transform:none !important;
|
||||
-ms-transform:none !important;
|
||||
transform:none !important;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
.deck-status {
|
||||
position: absolute;
|
||||
bottom: 10px;
|
||||
right: 5px;
|
||||
color: #888;
|
||||
z-index: 3;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
body > .deck-container .deck-status {
|
||||
position: fixed;
|
||||
}
|
||||
|
||||
@media print {
|
||||
.deck-status {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<!-- Place the following snippet at the bottom of the deck container. -->
|
||||
<p class="deck-status" aria-role="status">
|
||||
<span class="deck-status-current"></span>
|
||||
/
|
||||
<span class="deck-status-total"></span>
|
||||
</p>
|
||||
@@ -0,0 +1,108 @@
|
||||
/*!
|
||||
Deck JS - deck.status
|
||||
Copyright (c) 2011-2014 Caleb Troughton
|
||||
Dual licensed under the MIT license.
|
||||
https://github.com/imakewebthings/deck.js/blob/master/MIT-license.txt
|
||||
*/
|
||||
|
||||
/*
|
||||
This module adds a (current)/(total) style status indicator to the deck.
|
||||
*/
|
||||
(function($, undefined) {
|
||||
var $document = $(document);
|
||||
var rootCounter;
|
||||
|
||||
var updateCurrent = function(event, from, to) {
|
||||
var options = $.deck('getOptions');
|
||||
var currentSlideNumber = to + 1;
|
||||
if (!options.countNested) {
|
||||
currentSlideNumber = $.deck('getSlide', to).data('rootSlide');
|
||||
}
|
||||
$(options.selectors.statusCurrent).text(currentSlideNumber);
|
||||
};
|
||||
|
||||
var markRootSlides = function() {
|
||||
var options = $.deck('getOptions');
|
||||
var slideTest = $.map([
|
||||
options.classes.before,
|
||||
options.classes.previous,
|
||||
options.classes.current,
|
||||
options.classes.next,
|
||||
options.classes.after
|
||||
], function(el, i) {
|
||||
return '.' + el;
|
||||
}).join(', ');
|
||||
|
||||
rootCounter = 0;
|
||||
$.each($.deck('getSlides'), function(i, $slide) {
|
||||
var $parentSlides = $slide.parentsUntil(
|
||||
options.selectors.container,
|
||||
slideTest
|
||||
);
|
||||
|
||||
if ($parentSlides.length) {
|
||||
$slide.data('rootSlide', $parentSlides.last().data('rootSlide'));
|
||||
}
|
||||
else {
|
||||
++rootCounter;
|
||||
$slide.data('rootSlide', rootCounter);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var setInitialSlideNumber = function() {
|
||||
var slides = $.deck('getSlides');
|
||||
var $currentSlide = $.deck('getSlide');
|
||||
var index;
|
||||
|
||||
$.each(slides, function(i, $slide) {
|
||||
if ($slide === $currentSlide) {
|
||||
index = i;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
updateCurrent(null, index, index);
|
||||
};
|
||||
|
||||
var setTotalSlideNumber = function() {
|
||||
var options = $.deck('getOptions');
|
||||
var slides = $.deck('getSlides');
|
||||
|
||||
if (options.countNested) {
|
||||
$(options.selectors.statusTotal).text(slides.length);
|
||||
}
|
||||
else {
|
||||
$(options.selectors.statusTotal).text(rootCounter);
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
Extends defaults/options.
|
||||
|
||||
options.selectors.statusCurrent
|
||||
The element matching this selector displays the current slide number.
|
||||
|
||||
options.selectors.statusTotal
|
||||
The element matching this selector displays the total number of slides.
|
||||
|
||||
options.countNested
|
||||
If false, only top level slides will be counted in the current and
|
||||
total numbers.
|
||||
*/
|
||||
$.extend(true, $.deck.defaults, {
|
||||
selectors: {
|
||||
statusCurrent: '.deck-status-current',
|
||||
statusTotal: '.deck-status-total'
|
||||
},
|
||||
|
||||
countNested: true
|
||||
});
|
||||
|
||||
$document.bind('deck.init', function() {
|
||||
markRootSlides();
|
||||
setInitialSlideNumber();
|
||||
setTotalSlideNumber();
|
||||
});
|
||||
$document.bind('deck.change', updateCurrent);
|
||||
})(jQuery, 'deck');
|
||||
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
.deck-status {
|
||||
position:absolute;
|
||||
bottom:10px;
|
||||
right:5px;
|
||||
color:#888;
|
||||
z-index:3;
|
||||
margin:0;
|
||||
}
|
||||
|
||||
body > .deck-container .deck-status {
|
||||
position:fixed;
|
||||
}
|
||||
|
||||
@media print {
|
||||
.deck-status {
|
||||
display:none;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user