0){let a=.9;t+=d.querySelectorAll(".fragment.visible").length/e.length*a}}return Math.min(t/(e-1),1)}function ut(){return!!window.location.search.match(/receiver/gi)}function pt(){let e=window.location.hash,t=e.slice(2).split("/"),n=e.replace(/#|\//gi,"");if(!/^[0-9]*$/.test(t[0])&&n.length){let e;try{e=document.getElementById(decodeURIComponent(n))}catch(e){}let t=!!d&&d.getAttribute("id")===n;if(e){if(!t){let t=a.getIndices(e);Re(t.h,t.v)}}else Re(o||0,s||0)}else{let e,a=g.hashOneBasedIndex?1:0,n=parseInt(t[0],10)-a||0,r=parseInt(t[1],10)-a||0;g.fragmentInURL&&(e=parseInt(t[2],10),isNaN(e)&&(e=void 0)),n===o&&r===s&&void 0===e||Re(n,r,e)}}function ft(e){clearTimeout(I),"number"==typeof e?I=setTimeout(ft,e):d&&(g.history||!window.history?window.location.hash=xe():g.hash?window.history.replaceState(null,null,"#"+xe()):window.history.replaceState(null,null,window.location.pathname+window.location.search))}function ht(e){let t,a=o,n=s;if(e){let t=Me(e),r=t?e.parentNode:e,i=ee(L.wrapper.querySelectorAll(".slides>section"));a=Math.max(i.indexOf(r),0),n=void 0,t&&(n=Math.max(ee(e.parentNode.querySelectorAll("section")).indexOf(e),0))}if(!e&&d){if(d.querySelectorAll(".fragment").length>0){let e=d.querySelector(".current-fragment");t=e&&e.hasAttribute("data-fragment-index")?parseInt(e.getAttribute("data-fragment-index"),10):d.querySelectorAll(".fragment.visible").length-1}}return{h:a,v:n,f:t}}function gt(){return ee(L.wrapper.querySelectorAll('.slides section:not(.stack):not([data-visibility="uncounted"])'))}function mt(){return ee(L.wrapper.querySelectorAll(".slides>section"))}function vt(){return ee(L.wrapper.querySelectorAll(".slides>section>section"))}function bt(){return mt().length>1}function yt(){return vt().length>1}function wt(){return gt().length}function At(e,t){let a=mt()[e],n=a&&a.querySelectorAll("section");return n&&n.length&&"number"==typeof t?n?n[t]:void 0:a}function kt(e,t){let a="number"==typeof e?At(e,t):e;if(a)return a.slideBackgroundElement}function Et(e=d){if(e.hasAttribute("data-notes"))return e.getAttribute("data-notes");let t=e.querySelector("aside.notes");return t?t.innerHTML:null}function St(){let e=ht();return{indexh:e.h,indexv:e.v,indexf:e.f,paused:Ce(),overview:Le()}}function Lt(e,t=!1){e=ee(e);let a=[],n=[],r=[];e.forEach(e=>{if(e.hasAttribute("data-fragment-index")){let t=parseInt(e.getAttribute("data-fragment-index"),10);a[t]||(a[t]=[]),a[t].push(e)}else n.push([e])}),a=a.concat(n);let i=0;return a.forEach(e=>{e.forEach(e=>{r.push(e),e.setAttribute("data-fragment-index",i)}),i++}),!0===t?a:r}function xt(e,t){let a={shown:[],hidden:[]};if(d&&g.fragments&&(t=t||Lt(d.querySelectorAll(".fragment"))).length){let n=0;if("number"!=typeof e){let t=Lt(d.querySelectorAll(".fragment.visible")).pop();t&&(e=parseInt(t.getAttribute("data-fragment-index")||0,10))}ee(t).forEach((t,r)=>{t.hasAttribute("data-fragment-index")&&(r=parseInt(t.getAttribute("data-fragment-index"),10)),n=Math.max(n,r),r<=e?(t.classList.contains("visible")||a.shown.push(t),t.classList.add("visible"),t.classList.remove("current-fragment"),L.statusDiv.textContent=V(t),r===e&&(t.classList.add("current-fragment"),it(t))):(t.classList.contains("visible")&&a.hidden.push(t),t.classList.remove("visible"),t.classList.remove("current-fragment"))}),e="number"==typeof e?e:-1,e=Math.max(Math.min(e,n),-1),d.setAttribute("data-fragment",e)}return a}function Mt(e,t=0){if(d&&g.fragments){let a=Lt(d.querySelectorAll(".fragment"));if(a.length){if("number"!=typeof e){let t=Lt(d.querySelectorAll(".fragment.visible")).pop();e=t?parseInt(t.getAttribute("data-fragment-index")||0,10):-1}let n=xt(e+=t,a);return n.hidden.length&&le("fragmenthidden",{fragment:n.hidden[0],fragments:n.hidden}),n.shown.length&&le("fragmentshown",{fragment:n.shown[0],fragments:n.shown}),Ve(),We(),g.fragmentInURL&&ft(),!(!n.shown.length&&!n.hidden.length)}}return!1}function Nt(){return Mt(null,1)}function qt(){return Mt(null,-1)}function It(){if(Pt(),d&&!1!==g.autoSlide){let e=d.querySelector(".current-fragment");e||(e=d.querySelector(".fragment"));let t=e?e.getAttribute("data-autoslide"):null,n=d.parentNode?d.parentNode.getAttribute("data-autoslide"):null,r=d.getAttribute("data-autoslide");R=t?parseInt(t,10):r?parseInt(r,10):n?parseInt(n,10):g.autoSlide,0===d.querySelectorAll(".fragment").length&&ee(d.querySelectorAll("video, audio")).forEach(e=>{e.hasAttribute("data-autoplay")&&R&&1e3*e.duration/e.playbackRate>R&&(R=1e3*e.duration/e.playbackRate+1e3)}),!R||H||Ce()||Le()||a.isLastSlide()&&!rt().next&&!0!==g.loop||(D=setTimeout(()=>{"function"==typeof g.autoSlideMethod?g.autoSlideMethod():zt(),It()},R),B=Date.now()),h&&h.setPlaying(-1!==D)}}function Pt(){clearTimeout(D),D=-1}function Tt(){R&&!H&&(H=!0,le("autoslidepaused"),clearTimeout(D),h&&h.setPlaying(!1))}function Ct(){R&&H&&(H=!1,le("autoslideresumed"),It())}function Ot(){w=!0,g.rtl?(Le()||!1===Nt())&&nt().left&&Re(o+1,"grid"===g.navigationMode?s:void 0):(Le()||!1===qt())&&nt().left&&Re(o-1,"grid"===g.navigationMode?s:void 0)}function Rt(){w=!0,g.rtl?(Le()||!1===qt())&&nt().right&&Re(o-1,"grid"===g.navigationMode?s:void 0):(Le()||!1===Nt())&&nt().right&&Re(o+1,"grid"===g.navigationMode?s:void 0)}function Dt(){(Le()||!1===qt())&&nt().up&&Re(o,s-1)}function Bt(){A=!0,(Le()||!1===Nt())&&nt().down&&Re(o,s+1)}function Ht(){if(!1===qt())if(nt().up)Dt();else{let e;if(e=g.rtl?ee(L.wrapper.querySelectorAll(".slides>section.future")).pop():ee(L.wrapper.querySelectorAll(".slides>section.past")).pop(),e){let t=e.querySelectorAll("section").length-1||void 0;Re(o-1,t)}}}function zt(){if(w=!0,A=!0,!1===Nt()){let e=nt();e.down&&e.right&&g.loop&&a.isLastVerticalSlide(d)&&(e.down=!1),e.down?Bt():g.rtl?Ot():Rt()}}function jt(e){for(;e&&"function"==typeof e.hasAttribute;){if(e.hasAttribute("data-prevent-swipe"))return!0;e=e.parentNode}return!1}function $t(e){g.autoSlideStoppable&&Tt()}function Wt(e){Ne(),clearTimeout(T),T=setTimeout(qe,g.hideCursorTime)}function Ft(e){e.shiftKey&&63===e.charCode&&pe()}function Ut(e){if("function"==typeof g.keyboardCondition&&!1===g.keyboardCondition(e))return!0;let t=e.keyCode,n=H;$t();let r=document.activeElement&&"inherit"!==document.activeElement.contentEditable,i=document.activeElement&&document.activeElement.tagName&&/input|textarea/i.test(document.activeElement.tagName),o=document.activeElement&&document.activeElement.className&&/speaker-notes/i.test(document.activeElement.className),s=e.shiftKey&&32===e.keyCode,l=e.shiftKey&&37===t,d=e.shiftKey&&39===t,c=!s&&!l&&!d&&(e.shiftKey||e.altKey||e.ctrlKey||e.metaKey);if(r||i||o||c)return;let u,p=[66,86,190,191];if("object"==typeof g.keyboard)for(u in g.keyboard)"togglePause"===g.keyboard[u]&&p.push(parseInt(u,10));if(Ce()&&-1===p.indexOf(t))return!1;let f="linear"===g.navigationMode||!bt()||!yt(),h=!1;if("object"==typeof g.keyboard)for(u in g.keyboard)if(parseInt(u,10)===t){var m=g.keyboard[u];"function"==typeof m?m.apply(null,[e]):"string"==typeof m&&"function"==typeof a[m]&&a[m].call(),h=!0}if(!1===h)for(u in $)if(parseInt(u,10)===t){let t=$[u].callback;"function"==typeof t?t.apply(null,[e]):"string"==typeof t&&"function"==typeof a[t]&&a[t].call(),h=!0}!1===h&&(h=!0,80===t||33===t?Ht():78===t||34===t?zt():72===t||37===t?l?Re(0):!Le()&&f?Ht():Ot():76===t||39===t?d?Re(Number.MAX_VALUE):!Le()&&f?zt():Rt():75===t||38===t?!Le()&&f?Ht():Dt():74===t||40===t?!Le()&&f?zt():Bt():36===t?Re(0):35===t?Re(Number.MAX_VALUE):32===t?(Le()&&Ee(),e.shiftKey?Ht():zt()):58===t||59===t||66===t||86===t||190===t||191===t?Te():70===t?function(){let e=document.documentElement,t=e.requestFullscreen||e.webkitRequestFullscreen||e.webkitRequestFullScreen||e.mozRequestFullScreen||e.msRequestFullscreen;t&&t.apply(e)}():65===t?g.autoSlideStoppable&&Oe(n):h=!1),h?e.preventDefault&&e.preventDefault():27!==t&&79!==t||(L.overlay?he():Se(),e.preventDefault&&e.preventDefault()),It()}function Vt(e){if(jt(e.target))return!0;z.startX=e.touches[0].clientX,z.startY=e.touches[0].clientY,z.startCount=e.touches.length}function Xt(e){if(jt(e.target))return!0;if(z.captured)r.match(/android/gi)&&e.preventDefault();else{$t();let t=e.touches[0].clientX,a=e.touches[0].clientY;if(1===e.touches.length&&2!==z.startCount){let n=t-z.startX,r=a-z.startY;n>z.threshold&&Math.abs(n)>Math.abs(r)?(z.captured=!0,"linear"===g.navigationMode?g.rtl?zt():Ht():Ot()):n<-z.threshold&&Math.abs(n)>Math.abs(r)?(z.captured=!0,"linear"===g.navigationMode?g.rtl?Ht():zt():Rt()):r>z.threshold?(z.captured=!0,"linear"===g.navigationMode?Ht():Dt()):r<-z.threshold&&(z.captured=!0,"linear"===g.navigationMode?zt():Bt()),g.embedded?(z.captured||Me(d))&&e.preventDefault():e.preventDefault()}}}function Yt(e){z.captured=!1}function Kt(e){e.pointerType!==e.MSPOINTER_TYPE_TOUCH&&"touch"!==e.pointerType||(e.touches=[{clientX:e.clientX,clientY:e.clientY}],Vt(e))}function _t(e){e.pointerType!==e.MSPOINTER_TYPE_TOUCH&&"touch"!==e.pointerType||(e.touches=[{clientX:e.clientX,clientY:e.clientY}],Xt(e))}function Jt(e){e.pointerType!==e.MSPOINTER_TYPE_TOUCH&&"touch"!==e.pointerType||(e.touches=[{clientX:e.clientX,clientY:e.clientY}],Yt())}function Qt(e){if(Date.now()-q>600){q=Date.now();let t=e.detail||-e.wheelDelta;t>0?zt():t<0&&Ht()}}function Zt(e){$t(),e.preventDefault();let t=mt().length,a=Math.floor(e.clientX/L.wrapper.offsetWidth*t);g.rtl&&(a=t-a),Re(a)}function Gt(e){e.preventDefault(),$t(),"linear"===g.navigationMode?Ht():Ot()}function ea(e){e.preventDefault(),$t(),"linear"===g.navigationMode?zt():Rt()}function ta(e){e.preventDefault(),$t(),Dt()}function aa(e){e.preventDefault(),$t(),Bt()}function na(e){e.preventDefault(),$t(),Ht()}function ra(e){e.preventDefault(),$t(),zt()}function ia(e){pt()}function oa(e){ge()}function sa(e){!1===document.hidden&&document.activeElement!==document.body&&("function"==typeof document.activeElement.blur&&document.activeElement.blur(),document.body.focus())}function la(e){if(C&&Le()){e.preventDefault();let t=e.target;for(;t&&!t.nodeName.match(/section/gi);)t=t.parentNode;if(t&&!t.classList.contains("disabled"))if(Ee(),t.nodeName.match(/section/gi))Re(parseInt(t.getAttribute("data-index-h"),10),parseInt(t.getAttribute("data-index-v"),10))}}function da(e){if(e.currentTarget&&e.currentTarget.hasAttribute("href")){let t=e.currentTarget.getAttribute("href");t&&(!function(e){he(),L.overlay=document.createElement("div"),L.overlay.classList.add("overlay"),L.overlay.classList.add("overlay-preview"),L.wrapper.appendChild(L.overlay),L.overlay.innerHTML=`\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\tUnable to load iframe. This is likely due to the site's policy (x-frame-options).\n\t\t\t\t\n\t\t\t
`,L.overlay.querySelector("iframe").addEventListener("load",e=>{L.overlay.classList.add("loaded")},!1),L.overlay.querySelector(".close").addEventListener("click",e=>{he(),e.preventDefault()},!1),L.overlay.querySelector(".external").addEventListener("click",e=>{he()},!1)}(t),e.preventDefault())}}function ca(e){a.isLastSlide()&&!1===g.loop?(Re(0,0),Ct()):H?Ct():Tt()}return a={VERSION:"4.0.0-dev",configure:J,sync:De,syncSlide:function(e=d){_(e),Be(e),tt(e),Xe(),$e()},syncFragments:Be,slide:Re,left:Ot,right:Rt,up:Dt,down:Bt,prev:Ht,next:zt,navigateTo:Re,navigateLeft:Ot,navigateRight:Rt,navigateUp:Dt,navigateDown:Bt,navigatePrev:Ht,navigateNext:zt,navigateFragment:Mt,prevFragment:qt,nextFragment:Nt,layout:ge,shuffle:He,availableRoutes:nt,availableFragments:rt,toggleHelp:pe,toggleOverview:Se,togglePause:Te,toggleAutoSlide:Oe,isOverview:Le,isPaused:Ce,isAutoSliding:function(){return!(!R||H)},isSpeakerNotes:ut,loadSlide:tt,unloadSlide:at,addEventListeners:Q,removeEventListeners:Z,getState:St,setState:function(e){if("object"==typeof e){Re(te(e.indexh),te(e.indexv),te(e.indexf));var t=te(e.paused),a=te(e.overview);"boolean"==typeof t&&t!==Ce()&&Te(t),"boolean"==typeof a&&a!==Le()&&Se(a)}},getSlidePastCount:dt,getProgress:ct,getIndices:ht,getSlides:gt,getSlidesAttributes:function(){return gt().map((function(e){let t={};for(let a=0;al,getCurrentSlide:()=>d,getScale:()=>E,getConfig:()=>g,getQueryHash:()=>{let e={};location.search.replace(/[A-Z0-9]+?=([\w\.%-]*)/gi,t=>{e[t.split("=").shift()]=t.split("=").pop()});for(let t in e){let a=e[t];e[t]=te(unescape(a))}return e},getRevealElement:()=>L.wrapper||document.querySelector(".reveal"),getPlugins:()=>x,isFirstSlide:()=>0===o&&0===s,isLastSlide:()=>!!d&&(!d.nextElementSibling&&(!Me(d)||!d.parentNode.nextElementSibling)),isLastVerticalSlide:()=>!(!d||!Me(d))&&!d.nextElementSibling,isReady:()=>m,addEventListener:(e,t,n)=>{"addEventListener"in window&&a.getRevealElement().addEventListener(e,t,n)},removeEventListener:(e,t,n)=>{"addEventListener"in window&&a.getRevealElement().removeEventListener(e,t,n)},triggerKey:e=>{Ut({keyCode:e})},registerKeyboardShortcut:(e,t)=>{j[e]=t}},function(){if(!e)return void console.warn("reveal.js must be instantiated with a valid .reveal element");!function(){u=/(iphone|ipod|ipad|android)/gi.test(r)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1,p=/chrome/i.test(r)&&!/edge/i.test(r);let e=document.createElement("div");N.zoom="zoom"in e.style&&!u&&(p||/Version\/[\d\.]+.*Safari/.test(r))}(),L.wrapper=e,L.slides=e.querySelector(".slides"),window.addEventListener("load",ge,!1);let n=a.getQueryHash();var i,o;return void 0!==n.dependencies&&delete n.dependencies,G(g,t),G(g,n),i=[],o=0,g.dependencies.forEach(e=>{e.condition&&!e.condition()||(e.async?M.push(e):i.push(e))}),i.length?(o=i.length,i.forEach(e=>{U(e.src,(function(){"function"==typeof e.callback&&e.callback(),0==--o&&W()}))})):W(),a}()};window.Reveal=r,window.Reveal.initialize=e=>{window.Reveal=new r(document.querySelector(".reveal"),e)}}]);
\ No newline at end of file
diff --git a/gulpfile.js b/gulpfile.js
index 721492a..9f7fce3 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -26,7 +26,7 @@ const license = `/*!
*/\n`
-gulp.task('js', () => gulp.src(['./js/app.js'])
+gulp.task('js', () => gulp.src(['./js/index.js'])
.pipe(babel({ presets: ['@babel/preset-env'] }))
.pipe(webpack({
mode: 'production'
@@ -90,7 +90,7 @@ gulp.task('serve', () => {
livereload: true
})
- gulp.watch(['js/*.js'], gulp.series('js'))
+ gulp.watch(['js/**/*'], gulp.series('js'))
gulp.watch([
'css/theme/source/*.{sass,scss}',
diff --git a/js/app.js b/js/app.js
deleted file mode 100644
index 027e3e4..0000000
--- a/js/app.js
+++ /dev/null
@@ -1,3 +0,0 @@
-import Reveal from './reveal.js'
-
-window.Reveal = Reveal();
\ No newline at end of file
diff --git a/js/index.js b/js/index.js
new file mode 100644
index 0000000..e9286e0
--- /dev/null
+++ b/js/index.js
@@ -0,0 +1,12 @@
+import _reveal from './reveal.js'
+
+// The Reveal class can be instantiated to run multiple
+// presentations on the same page
+window.Reveal = _reveal;
+
+// Simplified way to create a reveal.js instance on
+// a page with only one presentation, makes us backwards
+// compatible with reveal.js pre 4.0
+window.Reveal.initialize = options => {
+ window.Reveal = new _reveal( document.querySelector( '.reveal' ), options );
+}
\ No newline at end of file
diff --git a/js/reveal.js b/js/reveal.js
index 65df5a9..afa3567 100644
--- a/js/reveal.js
+++ b/js/reveal.js
@@ -7,7 +7,7 @@ import Playback from './components/playback.js'
*
* Copyright (C) 2020 Hakim El Hattab, http://hakim.se
*/
-export default function() {
+export default function( revealElement, options ) {
'use strict';
@@ -306,9 +306,6 @@ export default function() {
},
- // Flags if Reveal.initialize() has been called
- initialized = false,
-
// Flags if reveal.js is loaded (has dispatched the 'ready' event)
loaded = false,
@@ -412,18 +409,18 @@ export default function() {
/**
* Starts up the presentation if the client is capable.
*/
- function initialize( options ) {
+ function init() {
- // Make sure we only initialize once
- if( initialized === true ) return;
-
- initialized = true;
+ if( !revealElement ) {
+ console.warn( 'reveal.js must be instantiated with a valid .reveal element' );
+ return;
+ }
checkCapabilities();
// Cache references to key DOM elements
- dom.wrapper = document.querySelector( '.reveal' );
- dom.slides = document.querySelector( '.reveal .slides' );
+ dom.wrapper = revealElement;
+ dom.slides = revealElement.querySelector( '.slides' );
// Force a layout when the whole page, incl fonts, has loaded
window.addEventListener( 'load', layout, false );
@@ -441,6 +438,8 @@ export default function() {
// Loads dependencies and continues to #start() once done
load();
+ return Reveal;
+
}
/**
@@ -6175,7 +6174,6 @@ export default function() {
Reveal = {
VERSION: VERSION,
- initialize,
configure,
sync,
@@ -6404,6 +6402,6 @@ export default function() {
}
};
- return Reveal;
+ return init();
};
\ No newline at end of file