UNPKG

bespoke

Version:
2 lines 1.72 kB
/*! Bespoke.js v1.0.0 © Mark Dalgleish, MIT License */ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;"undefined"!=typeof window?n=window:"undefined"!=typeof global?n=global:"undefined"!=typeof self&&(n=self),n.bespoke=e()}}(function(){return function e(n,r,t){function i(f,u){if(!r[f]){if(!n[f]){var d="function"==typeof require&&require;if(!u&&d)return d(f,!0);if(o)return o(f,!0);throw new Error("Cannot find module '"+f+"'")}var l=r[f]={exports:{}};n[f][0].call(l.exports,function(e){var r=n[f][1][e];return i(r?r:e)},l,l.exports,e,n,r,t)}return r[f].exports}for(var o="function"==typeof require&&require,f=0;f<t.length;f++)i(t[f]);return i}({1:[function(e,n){var r=function(e,n){var r=1===(e.parent||e).nodeType?e.parent||e:document.querySelector(e.parent||e),t=[].filter.call("string"==typeof e.slides?r.querySelectorAll(e.slides):e.slides||r.children,function(e){return"SCRIPT"!==e.nodeName}),i=t[0],o={},f=function(e,n){t[e]&&(s("deactivate",a(i,n)),i=t[e],s("activate",a(i,n)))},u=function(e,n){return arguments.length?(s("slide",a(t[e],n))&&f(e,n),void 0):t.indexOf(i)},d=function(e,n){var r=t.indexOf(i)+e;s(e>0?"next":"prev",a(i,n))&&f(r,n)},l=function(e,n){return(o[e]||(o[e]=[])).push(n),c.bind(null,e,n)},c=function(e,n){o[e]=(o[e]||[]).filter(function(e){return e!==n})},s=function(e,n){return(o[e]||[]).reduce(function(e,r){return e&&r(n)!==!1},!0)},a=function(e,n){return n=n||{},n.index=t.indexOf(e),n.slide=e,n},p={on:l,off:c,fire:s,slide:u,next:d.bind(null,1),prev:d.bind(null,-1),parent:r,slides:t};return(n||[]).forEach(function(e){e(p)}),f(0),p};n.exports={from:r}},{}]},{},[1])(1)});