From 5a774ef6f3b38b19b26913a34b1388530c72334e Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Tue, 9 Apr 2013 14:31:22 +0200 Subject: Initial Commit --- deck.js/extensions/navigation/deck.navigation.css | 43 ++++++++++ deck.js/extensions/navigation/deck.navigation.html | 3 + deck.js/extensions/navigation/deck.navigation.js | 92 ++++++++++++++++++++++ deck.js/extensions/navigation/deck.navigation.scss | 56 +++++++++++++ 4 files changed, 194 insertions(+) create mode 100644 deck.js/extensions/navigation/deck.navigation.css create mode 100644 deck.js/extensions/navigation/deck.navigation.html create mode 100644 deck.js/extensions/navigation/deck.navigation.js create mode 100755 deck.js/extensions/navigation/deck.navigation.scss (limited to 'deck.js/extensions/navigation') diff --git a/deck.js/extensions/navigation/deck.navigation.css b/deck.js/extensions/navigation/deck.navigation.css new file mode 100644 index 0000000..e1ebad8 --- /dev/null +++ b/deck.js/extensions/navigation/deck.navigation.css @@ -0,0 +1,43 @@ +.deck-container .deck-prev-link, .deck-container .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; +} +.borderradius .deck-container .deck-prev-link, .borderradius .deck-container .deck-next-link { + -webkit-border-radius: 16px; + -moz-border-radius: 16px; + border-radius: 16px; +} +.deck-container .deck-prev-link:hover, .deck-container .deck-prev-link:focus, .deck-container .deck-prev-link:active, .deck-container .deck-prev-link:visited, .deck-container .deck-next-link:hover, .deck-container .deck-next-link:focus, .deck-container .deck-next-link:active, .deck-container .deck-next-link:visited { + color: #fff; +} +.deck-container .deck-prev-link { + left: 8px; +} +.deck-container .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; + } +} diff --git a/deck.js/extensions/navigation/deck.navigation.html b/deck.js/extensions/navigation/deck.navigation.html new file mode 100644 index 0000000..c756624 --- /dev/null +++ b/deck.js/extensions/navigation/deck.navigation.html @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/deck.js/extensions/navigation/deck.navigation.js b/deck.js/extensions/navigation/deck.navigation.js new file mode 100644 index 0000000..a07f7ea --- /dev/null +++ b/deck.js/extensions/navigation/deck.navigation.js @@ -0,0 +1,92 @@ +/*! +Deck JS - deck.navigation +Copyright (c) 2011 Caleb Troughton +Dual licensed under the MIT license and GPL license. +https://github.com/imakewebthings/deck.js/blob/master/MIT-license.txt +https://github.com/imakewebthings/deck.js/blob/master/GPL-license.txt +*/ + +/* +This module adds clickable previous and next links to the deck. +*/ +(function($, deck, undefined) { + var $d = $(document), + + /* Updates link hrefs, and disabled states if last/first slide */ + updateButtons = function(e, from, to) { + var opts = $[deck]('getOptions'), + last = $[deck]('getSlides').length - 1, + prevSlide = $[deck]('getSlide', to - 1), + nextSlide = $[deck]('getSlide', to + 1), + hrefBase = window.location.href.replace(/#.*/, ''), + prevId = prevSlide ? prevSlide.attr('id') : undefined, + nextId = nextSlide ? nextSlide.attr('id') : undefined; + + $(opts.selectors.previousLink) + .toggleClass(opts.classes.navDisabled, !to) + .attr('href', hrefBase + '#' + (prevId ? prevId : '')); + $(opts.selectors.nextLink) + .toggleClass(opts.classes.navDisabled, to === last) + .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' + } + }); + + $d.bind('deck.init', function() { + var opts = $[deck]('getOptions'), + slides = $[deck]('getSlides'), + $current = $[deck]('getSlide'), + ndx; + + // Setup prev/next link events + $(opts.selectors.previousLink) + .unbind('click.decknavigation') + .bind('click.decknavigation', function(e) { + $[deck]('prev'); + e.preventDefault(); + }); + + $(opts.selectors.nextLink) + .unbind('click.decknavigation') + .bind('click.decknavigation', function(e) { + $[deck]('next'); + e.preventDefault(); + }); + + // Find where we started in the deck and set initial states + $.each(slides, function(i, $slide) { + if ($slide === $current) { + ndx = i; + return false; + } + }); + updateButtons(null, ndx, ndx); + }) + .bind('deck.change', updateButtons); +})(jQuery, 'deck'); + diff --git a/deck.js/extensions/navigation/deck.navigation.scss b/deck.js/extensions/navigation/deck.navigation.scss new file mode 100755 index 0000000..815602f --- /dev/null +++ b/deck.js/extensions/navigation/deck.navigation.scss @@ -0,0 +1,56 @@ +@mixin border-radius($r) { + -webkit-border-radius:$r; + -moz-border-radius:$r; + border-radius:$r; +} + +.deck-container { + .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; + + .borderradius & { + @include border-radius(16px); + } + + &:hover, &:focus, &:active, &:visited { + color:#fff; + } + } + + .deck-prev-link { + left:8px; + } + + .deck-next-link { + right:8px; + } + + &:hover .deck-prev-link, &:hover .deck-next-link { + display:block; + + &.deck-nav-disabled, .touch & { + display:none; + } + } +} + + +@media print { + .deck-prev-link, .deck-next-link { + display:none !important; + } +} -- cgit v1.2.1