Skip to content

Instantly share code, notes, and snippets.

@imakewebthings
imakewebthings / gist:1976702
Created March 5, 2012 05:06
Dirty hack to fake overloading of next/prev to invoke arbitrary JS
/*
This is the same principle used in a previous gist: https://gist.github.com/1955854
In this case, we use blank elements in the slide to provide an animation "step."
The presenter explicitly hits next/prev to reveal and unravel the animation instead
of it happening automatically when the slide is made current and leaves the screen.
The HTML structure be:
<section class="slide">
<p>Some normal slide content...</p>
@imakewebthings
imakewebthings / gist:2136386
Created March 20, 2012 14:47
Boilerplate walkthrough for Stack View data types
(function($, window, undefined) {
/*
First we extend the defaults for the StackView options object.
This is a common pattern in all the modules, (infinite, navigation),
that each module extends the defaults to deal with the options that
pertain to its own code.
*/
$.extend(true, window.StackView.defaults, {
selectors: {
/* Our types only have this one extension, a selector that points to
@imakewebthings
imakewebthings / gist:2136632
Created March 20, 2012 15:04
Overriding and modifying Stack View type properties
(function($, window, undefined) {
/* Let's say we want to completely override the template and adapter
for the webpage type. Simple enough, just get the type and set each of
those proeprties to new values. */
var webpage = window.StackView.get_types().webpage;
webpage.template = '<li><%= id %></li>';
webpage.adapter = function(item, options) {
return {
id: item.id
}
@imakewebthings
imakewebthings / deck.processing.js
Created May 20, 2012 03:18
One possible way to run/destroy processing sketches on deck.change
$(document).bind('deck.init', function() {
$.each(Processing.instances, function(i, instance) {
instance.exit(); // Exit all drawings to start
});
});
$(document).bind('deck.change', function(event, from, to) {
var $exitingCanvases = $.deck('getSlide', from).find('canvas[data-processing-sources]');
var $enteringCanvases = $.deck('getSlide', to).find('canvas[data-processing-sources]');
@imakewebthings
imakewebthings / gist:2881369
Created June 6, 2012 11:29
Super quick and dirty, maybe not even functional, progress bar example for deck.js
/* Add this to bottom of deck container
<div class="deck-progress"><span></span></div>
And add this CSS wherever:
.deck-progress {
position:absolute;
left:0;
right:0;
bottom:0;
@imakewebthings
imakewebthings / gist:5658875
Created May 27, 2013 20:14
Super simple notify
var notify = function(message) {
var $message = $('<p style="display:none;">' + message + '</p>');
$('.notifications').append($message);
$message.slideDown(300, function() {
window.setTimeout(function() {
$message.slideUp(300, function() {
$message.remove();
});
}, 2000);
@imakewebthings
imakewebthings / gist:7016319
Last active December 25, 2015 17:49
deck revised extension example: goto
(function($, undefined) {
$.deck('extend', {
name: 'goto',
options: {
class: 'deck-goto',
datalistSelector: '#goto-datalist',
formSelector: '.goto-form',
inputSelector: '#goto-slide',
countNested: true
import random
class FileHandler(object):
def __init__(self, filename = "", query_type = ""):
self.filename = filename
self.query_type = query_type
def line_from_file(self, filename=None, query_type=None):
if filename != None
$(document).on('deck.beforeChange', function(event, from, to) {
var $slides = $.deck('getSlides');
var onLastSlide = from === $slides.length - 1;
var onFirstSlide = !from;
var goingForward = to > from;
var nextUrl = $('link[rel="next"]').attr('href');
var prevUrl = $('link[rel="prev"]').attr('href');
if (onLastSlide && goingForward && nextUrl) {
window.location = nextUrl;
$(document).on('deck.beforeChange', function(event, from, to) {
var $slides = $.deck('getSlides');
var onLastSlide = from === $slides.length - 1;
var onFirstSlide = !from;
var goingForward = to > from;
if (onLastSlide && goingForward) {
event.preventDefault();
$.deck('go', 0);
}