123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800 |
- (function ( document, window ) {
- 'use strict';
-
-
-
-
-
-
- var pfx = (function () {
-
- var style = document.createElement('dummy').style,
- prefixes = 'Webkit Moz O ms Khtml'.split(' '),
- memory = {};
-
- return function ( prop ) {
- if ( typeof memory[ prop ] === "undefined" ) {
-
- var ucProp = prop.charAt(0).toUpperCase() + prop.substr(1),
- props = (prop + ' ' + prefixes.join(ucProp + ' ') + ucProp).split(' ');
-
- memory[ prop ] = null;
- for ( var i in props ) {
- if ( style[ props[i] ] !== undefined ) {
- memory[ prop ] = props[i];
- break;
- }
- }
-
- }
-
- return memory[ prop ];
- };
-
- })();
-
-
-
- var arrayify = function ( a ) {
- return [].slice.call( a );
- };
-
-
-
-
- var css = function ( el, props ) {
- var key, pkey;
- for ( key in props ) {
- if ( props.hasOwnProperty(key) ) {
- pkey = pfx(key);
- if ( pkey !== null ) {
- el.style[pkey] = props[key];
- }
- }
- }
- return el;
- };
-
-
-
-
- var toNumber = function (numeric, fallback) {
- return isNaN(numeric) ? (fallback || 0) : Number(numeric);
- };
-
-
- var byId = function ( id ) {
- return document.getElementById(id);
- };
-
-
-
- var $ = function ( selector, context ) {
- context = context || document;
- return context.querySelector(selector);
- };
-
-
-
- var $$ = function ( selector, context ) {
- context = context || document;
- return arrayify( context.querySelectorAll(selector) );
- };
-
-
-
- var triggerEvent = function (el, eventName, detail) {
- var event = document.createEvent("CustomEvent");
- event.initCustomEvent(eventName, true, true, detail);
- el.dispatchEvent(event);
- };
-
-
- var translate = function ( t ) {
- return " translate3d(" + t.x + "px," + t.y + "px," + t.z + "px) ";
- };
-
-
-
-
- var rotate = function ( r, revert ) {
- var rX = " rotateX(" + r.x + "deg) ",
- rY = " rotateY(" + r.y + "deg) ",
- rZ = " rotateZ(" + r.z + "deg) ";
-
- return revert ? rZ+rY+rX : rX+rY+rZ;
- };
-
-
- var scale = function ( s ) {
- return " scale(" + s + ") ";
- };
-
-
- var perspective = function ( p ) {
- return " perspective(" + p + "px) ";
- };
-
-
-
- var getElementFromHash = function () {
-
-
- return byId( window.location.hash.replace(/^#\/?/,"") );
- };
-
-
-
- var computeWindowScale = function ( config ) {
- var hScale = window.innerHeight / config.height,
- wScale = window.innerWidth / config.width,
- scale = hScale > wScale ? wScale : hScale;
-
- if (config.maxScale && scale > config.maxScale) {
- scale = config.maxScale;
- }
-
- if (config.minScale && scale < config.minScale) {
- scale = config.minScale;
- }
-
- return scale;
- };
-
-
- var body = document.body;
-
- var ua = navigator.userAgent.toLowerCase();
- var impressSupported =
-
- ( pfx("perspective") !== null ) &&
-
-
- ( body.classList ) &&
- ( body.dataset ) &&
-
-
-
-
- ( ua.search(/(iphone)|(ipod)|(android)/) === -1 );
-
- if (!impressSupported) {
-
- body.className += " impress-not-supported ";
- } else {
- body.classList.remove("impress-not-supported");
- body.classList.add("impress-supported");
- }
-
-
-
-
-
-
- var roots = {};
-
-
- var defaults = {
- width: 1024,
- height: 768,
- maxScale: 1,
- minScale: 0,
-
- perspective: 1000,
-
- transitionDuration: 1000
- };
-
-
- var empty = function () { return false; };
-
-
-
-
-
-
-
- var impress = window.impress = function ( rootId ) {
-
-
-
-
- if (!impressSupported) {
- return {
- init: empty,
- goto: empty,
- prev: empty,
- next: empty
- };
- }
-
- rootId = rootId || "impress";
-
-
- if (roots["impress-root-" + rootId]) {
- return roots["impress-root-" + rootId];
- }
-
-
- var stepsData = {};
-
-
- var activeStep = null;
-
-
- var currentState = null;
-
-
- var steps = null;
-
-
- var config = null;
-
-
- var windowScale = null;
-
-
- var root = byId( rootId );
- var canvas = document.createElement("div");
-
- var initialized = false;
-
-
-
-
-
-
-
-
-
-
- var lastEntered = null;
-
-
-
-
- var onStepEnter = function (step) {
- if (lastEntered !== step) {
- triggerEvent(step, "impress:stepenter");
- lastEntered = step;
- }
- };
-
-
-
-
- var onStepLeave = function (step) {
- if (lastEntered === step) {
- triggerEvent(step, "impress:stepleave");
- lastEntered = null;
- }
- };
-
-
-
- var initStep = function ( el, idx ) {
- var data = el.dataset,
- step = {
- translate: {
- x: toNumber(data.x),
- y: toNumber(data.y),
- z: toNumber(data.z)
- },
- rotate: {
- x: toNumber(data.rotateX),
- y: toNumber(data.rotateY),
- z: toNumber(data.rotateZ || data.rotate)
- },
- scale: toNumber(data.scale, 1),
- el: el
- };
-
- if ( !el.id ) {
- el.id = "step-" + (idx + 1);
- }
-
- stepsData["impress-" + el.id] = step;
-
- css(el, {
- position: "absolute",
- transform: "translate(-50%,-50%)" +
- translate(step.translate) +
- rotate(step.rotate) +
- scale(step.scale),
- transformStyle: "preserve-3d"
- });
- };
-
-
- var init = function () {
- if (initialized) { return; }
-
-
-
- var meta = $("meta[name='viewport']") || document.createElement("meta");
- meta.content = "width=device-width, minimum-scale=1, maximum-scale=1, user-scalable=no";
- if (meta.parentNode !== document.head) {
- meta.name = 'viewport';
- document.head.appendChild(meta);
- }
-
-
- var rootData = root.dataset;
- config = {
- width: toNumber( rootData.width, defaults.width ),
- height: toNumber( rootData.height, defaults.height ),
- maxScale: toNumber( rootData.maxScale, defaults.maxScale ),
- minScale: toNumber( rootData.minScale, defaults.minScale ),
- perspective: toNumber( rootData.perspective, defaults.perspective ),
- transitionDuration: toNumber( rootData.transitionDuration, defaults.transitionDuration )
- };
-
- windowScale = computeWindowScale( config );
-
-
- arrayify( root.childNodes ).forEach(function ( el ) {
- canvas.appendChild( el );
- });
- root.appendChild(canvas);
-
-
- document.documentElement.style.height = "100%";
-
- css(body, {
- height: "100%",
- overflow: "hidden"
- });
-
- var rootStyles = {
- position: "absolute",
- transformOrigin: "top left",
- transition: "all 0s ease-in-out",
- transformStyle: "preserve-3d"
- };
-
- css(root, rootStyles);
- css(root, {
- top: "50%",
- left: "50%",
- transform: perspective( config.perspective/windowScale ) + scale( windowScale )
- });
- css(canvas, rootStyles);
-
- body.classList.remove("impress-disabled");
- body.classList.add("impress-enabled");
-
-
- steps = $$(".step", root);
- steps.forEach( initStep );
-
-
- currentState = {
- translate: { x: 0, y: 0, z: 0 },
- rotate: { x: 0, y: 0, z: 0 },
- scale: 1
- };
-
- initialized = true;
-
- triggerEvent(root, "impress:init", { api: roots[ "impress-root-" + rootId ] });
- };
-
-
-
-
-
- var getStep = function ( step ) {
- if (typeof step === "number") {
- step = step < 0 ? steps[ steps.length + step] : steps[ step ];
- } else if (typeof step === "string") {
- step = byId(step);
- }
- return (step && step.id && stepsData["impress-" + step.id]) ? step : null;
- };
-
-
- var stepEnterTimeout = null;
-
-
-
- var goto = function ( el, duration ) {
-
- if ( !initialized || !(el = getStep(el)) ) {
-
- return false;
- }
-
-
-
-
-
-
-
-
-
- window.scrollTo(0, 0);
-
- var step = stepsData["impress-" + el.id];
-
- if ( activeStep ) {
- activeStep.classList.remove("active");
- body.classList.remove("impress-on-" + activeStep.id);
- }
- el.classList.add("active");
-
- body.classList.add("impress-on-" + el.id);
-
-
- var target = {
- rotate: {
- x: -step.rotate.x,
- y: -step.rotate.y,
- z: -step.rotate.z
- },
- translate: {
- x: -step.translate.x,
- y: -step.translate.y,
- z: -step.translate.z
- },
- scale: 1 / step.scale
- };
-
-
-
-
-
-
-
- var zoomin = target.scale >= currentState.scale;
-
- duration = toNumber(duration, config.transitionDuration);
- var delay = (duration / 2);
-
-
-
- if (el === activeStep) {
- windowScale = computeWindowScale(config);
- }
-
- var targetScale = target.scale * windowScale;
-
-
- if (activeStep && activeStep !== el) {
- onStepLeave(activeStep);
- }
-
-
-
-
-
-
-
-
-
- css(root, {
-
-
- transform: perspective( config.perspective / targetScale ) + scale( targetScale ),
- transitionDuration: duration + "ms",
- transitionDelay: (zoomin ? delay : 0) + "ms"
- });
-
- css(canvas, {
- transform: rotate(target.rotate, true) + translate(target.translate),
- transitionDuration: duration + "ms",
- transitionDelay: (zoomin ? 0 : delay) + "ms"
- });
-
-
-
-
-
-
-
-
-
-
- if ( currentState.scale === target.scale ||
- (currentState.rotate.x === target.rotate.x && currentState.rotate.y === target.rotate.y &&
- currentState.rotate.z === target.rotate.z && currentState.translate.x === target.translate.x &&
- currentState.translate.y === target.translate.y && currentState.translate.z === target.translate.z) ) {
- delay = 0;
- }
-
-
- currentState = target;
- activeStep = el;
-
-
-
-
-
-
-
-
-
-
-
-
-
- window.clearTimeout(stepEnterTimeout);
- stepEnterTimeout = window.setTimeout(function() {
- onStepEnter(activeStep);
- }, duration + delay);
-
- return el;
- };
-
-
- var prev = function () {
- var prev = steps.indexOf( activeStep ) - 1;
- prev = prev >= 0 ? steps[ prev ] : steps[ steps.length-1 ];
-
- return goto(prev);
- };
-
-
- var next = function () {
- var next = steps.indexOf( activeStep ) + 1;
- next = next < steps.length ? steps[ next ] : steps[ 0 ];
-
- return goto(next);
- };
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- root.addEventListener("impress:init", function(){
-
- steps.forEach(function (step) {
- step.classList.add("future");
- });
-
- root.addEventListener("impress:stepenter", function (event) {
- event.target.classList.remove("past");
- event.target.classList.remove("future");
- event.target.classList.add("present");
- }, false);
-
- root.addEventListener("impress:stepleave", function (event) {
- event.target.classList.remove("present");
- event.target.classList.add("past");
- }, false);
-
- }, false);
-
-
- root.addEventListener("impress:init", function(){
-
-
- var lastHash = "";
-
-
-
-
-
-
-
- root.addEventListener("impress:stepenter", function (event) {
- window.location.hash = lastHash = "#/" + event.target.id;
- }, false);
-
- window.addEventListener("hashchange", function () {
-
-
-
-
-
- if (window.location.hash !== lastHash) {
- goto( getElementFromHash() );
- }
- }, false);
-
-
-
- goto(getElementFromHash() || steps[0], 0);
- }, false);
-
- body.classList.add("impress-disabled");
-
-
- return (roots[ "impress-root-" + rootId ] = {
- init: init,
- goto: goto,
- next: next,
- prev: prev
- });
- };
-
-
- impress.supported = impressSupported;
-
- })(document, window);
- (function ( document, window ) {
- 'use strict';
-
-
-
- var throttle = function (fn, delay) {
- var timer = null;
- return function () {
- var context = this, args = arguments;
- clearTimeout(timer);
- timer = setTimeout(function () {
- fn.apply(context, args);
- }, delay);
- };
- };
-
-
- document.addEventListener("impress:init", function (event) {
-
-
-
-
- var api = event.detail.api;
-
-
-
-
- document.addEventListener("keydown", function ( event ) {
- if ( event.keyCode === 9 || ( event.keyCode >= 32 && event.keyCode <= 34 ) || (event.keyCode >= 37 && event.keyCode <= 40) ) {
- event.preventDefault();
- }
- }, false);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- document.addEventListener("keyup", function ( event ) {
- if ( event.keyCode === 9 || ( event.keyCode >= 32 && event.keyCode <= 34 ) || (event.keyCode >= 37 && event.keyCode <= 40) ) {
- switch( event.keyCode ) {
- case 33:
- case 37:
- case 38:
- api.prev();
- break;
- case 9:
- case 32:
- case 34:
- case 39:
- case 40:
- api.next();
- break;
- }
-
- event.preventDefault();
- }
- }, false);
-
-
- document.addEventListener("click", function ( event ) {
-
-
- var target = event.target;
- while ( (target.tagName !== "A") &&
- (target !== document.documentElement) ) {
- target = target.parentNode;
- }
-
- if ( target.tagName === "A" ) {
- var href = target.getAttribute("href");
-
-
- if ( href && href[0] === '#' ) {
- target = document.getElementById( href.slice(1) );
- }
- }
-
- if ( api.goto(target) ) {
- event.stopImmediatePropagation();
- event.preventDefault();
- }
- }, false);
-
-
- document.addEventListener("click", function ( event ) {
- var target = event.target;
-
- while ( !(target.classList.contains("step") && !target.classList.contains("active")) &&
- (target !== document.documentElement) ) {
- target = target.parentNode;
- }
-
- if ( api.goto(target) ) {
- event.preventDefault();
- }
- }, false);
-
-
-
- document.addEventListener("touchstart", function ( event ) {
- if (event.touches.length === 1) {
- var x = event.touches[0].clientX,
- width = window.innerWidth * 0.3,
- result = null;
-
- if ( x < width ) {
- result = api.prev();
- } else if ( x > window.innerWidth - width ) {
- result = api.next();
- }
-
- if (result) {
- event.preventDefault();
- }
- }
- }, false);
-
-
- window.addEventListener("resize", throttle(function () {
-
- api.goto( document.querySelector(".active"), 500 );
- }, 250), false);
-
- }, false);
-
- })(document, window);
|