/*!
* kontext
* http://lab.hakim.se/kontext
* MIT licensed
*
* Copyright (C) 2013 Hakim El Hattab, http://hakim.se
*/
window.kontext = function( container ) {
// Dispatched when the current layer changes
var changed = new kontext.Signal();
// All layers in this instance of kontext
var layers = Array.prototype.slice.call( container.querySelectorAll( '.layer' ) );
// Flag if the browser is capable of handling our fancy transition
var capable = 'WebkitPerspective' in document.body.style ||
'MozPerspective' in document.body.style ||
'msPerspective' in document.body.style ||
'OPerspective' in document.body.style ||
'perspective' in document.body.style;
if( capable ) {
container.classList.add( 'capable' );
}
// Create dimmer elements to fade out preceding slides
layers.forEach( function( el, i ) {
if( !el.querySelector( '.dimmer' ) ) el.innerHTML += '<div class="dimmer"></div>';
} );
/**
* Transitions to and shows the target layer.
*
* @param target index of layer or layer DOM element
*/
function show( target, direction ) {
// Make sure our listing of available layers is up to date
layers = Array.prototype.slice.call( container.querySelectorAll( '.layer' ) );
// Flag to CSS that we're ready to animate transitions
container.classList.add( 'animate' );
// Flag which direction
direction = direction || ( target > getIndex() ? 'right' : 'left' );
// Accept multiple types of targets
if( typeof target === 'string' ) target = parseInt( target );
if( typeof target !== 'number' ) target = getIndex( target );
// Enforce index bounds
target = Math.max( Math.min( target, layers.length ), 0 );
// Only navigate if were able to locate the target
if( layers[ target ] && !layers[ target ].classList.contains( 'show' ) ) {
layers.forEach( function( el, i ) {
el.classList.remove( 'left', 'right' );
el.classList.add( direction );
if( el.classList.contains( 'show' ) )...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.