1
0
Fork 0

tidying up

This commit is contained in:
Hakim El Hattab 2020-04-21 09:36:43 +02:00
parent 6ff28af1b3
commit d22c7bfad1
7 changed files with 63 additions and 73 deletions

4
dist/reveal.es5.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

4
dist/reveal.js vendored

File diff suppressed because one or more lines are too long

2
dist/reveal.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -15,22 +15,14 @@ import Touch from './controllers/touch.js'
import Notes from './controllers/notes.js' import Notes from './controllers/notes.js'
import Playback from './components/playback.js' import Playback from './components/playback.js'
import defaultConfig from './config.js' import defaultConfig from './config.js'
import { isMobile, isChrome, supportsZoom } from './utils/device.js' import * as Util from './utils/util.js'
import * as Device from './utils/device.js'
import { import {
SLIDES_SELECTOR, SLIDES_SELECTOR,
HORIZONTAL_SLIDES_SELECTOR, HORIZONTAL_SLIDES_SELECTOR,
VERTICAL_SLIDES_SELECTOR, VERTICAL_SLIDES_SELECTOR,
POST_MESSAGE_METHOD_BLACKLIST POST_MESSAGE_METHOD_BLACKLIST
} from './utils/constants.js' } from './utils/constants.js'
import {
extend,
queryAll,
deserialize,
transformElement,
createSingletonNode,
getQueryHash,
getRemainingHeight
} from './utils/util.js'
/** /**
* reveal.js * reveal.js
@ -80,25 +72,6 @@ export default function( revealElement, options ) {
// The current scale of the presentation (see width/height config) // The current scale of the presentation (see width/height config)
scale = 1, scale = 1,
// Controllers for different aspects of our presentation. They're
// all given direct references to this Reveal instance since there
// may be multiple presentations running in parallel.
slideContent = new SlideContent( Reveal ),
slideNumber = new SlideNumber( Reveal ),
autoAnimate = new AutoAnimate( Reveal ),
backgrounds = new Backgrounds( Reveal ),
fragments = new Fragments( Reveal ),
overview = new Overview( Reveal ),
keyboard = new Keyboard( Reveal ),
location = new Location( Reveal ),
controls = new Controls( Reveal ),
progress = new Progress( Reveal ),
pointer = new Pointer( Reveal ),
plugins = new Plugins( Reveal ),
print = new Print( Reveal ),
touch = new Touch( Reveal ),
notes = new Notes( Reveal ),
// CSS transform that is currently applied to the slides container, // CSS transform that is currently applied to the slides container,
// split into two groups // split into two groups
slidesTransform = { layout: '', overview: '' }, slidesTransform = { layout: '', overview: '' },
@ -116,7 +89,26 @@ export default function( revealElement, options ) {
autoSlidePlayer, autoSlidePlayer,
autoSlideTimeout = 0, autoSlideTimeout = 0,
autoSlideStartTime = -1, autoSlideStartTime = -1,
autoSlidePaused = false; autoSlidePaused = false,
// Controllers for different aspects of our presentation. They're
// all given direct references to this Reveal instance since there
// may be multiple presentations running in parallel.
slideContent = new SlideContent( Reveal ),
slideNumber = new SlideNumber( Reveal ),
autoAnimate = new AutoAnimate( Reveal ),
backgrounds = new Backgrounds( Reveal ),
fragments = new Fragments( Reveal ),
overview = new Overview( Reveal ),
keyboard = new Keyboard( Reveal ),
location = new Location( Reveal ),
controls = new Controls( Reveal ),
progress = new Progress( Reveal ),
pointer = new Pointer( Reveal ),
plugins = new Plugins( Reveal ),
print = new Print( Reveal ),
touch = new Touch( Reveal ),
notes = new Notes( Reveal );
/** /**
* Starts up the presentation if the client is capable. * Starts up the presentation if the client is capable.
@ -128,7 +120,7 @@ export default function( revealElement, options ) {
dom.slides = revealElement.querySelector( '.slides' ); dom.slides = revealElement.querySelector( '.slides' );
// Copy options over to our config object // Copy options over to our config object
config = { ...defaultConfig, ...options, ...getQueryHash() }; config = { ...defaultConfig, ...options, ...Util.getQueryHash() };
// Embedded decks use the reveal element as their viewport // Embedded decks use the reveal element as their viewport
if( config.embedded === true ) { if( config.embedded === true ) {
@ -224,7 +216,7 @@ export default function( revealElement, options ) {
// Prevent transitions while we're loading // Prevent transitions while we're loading
dom.slides.classList.add( 'no-transition' ); dom.slides.classList.add( 'no-transition' );
if( isMobile ) { if( Device.isMobile ) {
dom.wrapper.classList.add( 'no-hover' ); dom.wrapper.classList.add( 'no-hover' );
} }
else { else {
@ -238,7 +230,7 @@ export default function( revealElement, options ) {
notes.render(); notes.render();
// Overlay graphic which is displayed during the paused mode // Overlay graphic which is displayed during the paused mode
dom.pauseOverlay = createSingletonNode( dom.wrapper, 'div', 'pause-overlay', config.controls ? '<button class="resume-button">Resume presentation</button>' : null ); dom.pauseOverlay = Util.createSingletonNode( dom.wrapper, 'div', 'pause-overlay', config.controls ? '<button class="resume-button">Resume presentation</button>' : null );
dom.statusElement = createStatusElement(); dom.statusElement = createStatusElement();
@ -389,7 +381,7 @@ export default function( revealElement, options ) {
// New config options may be passed when this method // New config options may be passed when this method
// is invoked through the API after initialization // is invoked through the API after initialization
if( typeof options === 'object' ) extend( config, options ); if( typeof options === 'object' ) Util.extend( config, options );
// Abort if reveal.js hasn't finished loading, config // Abort if reveal.js hasn't finished loading, config
// changes will be applied automatically once ready // changes will be applied automatically once ready
@ -552,10 +544,10 @@ export default function( revealElement, options ) {
// Apply the transforms to the slides container // Apply the transforms to the slides container
if( slidesTransform.layout ) { if( slidesTransform.layout ) {
transformElement( dom.slides, slidesTransform.layout + ' ' + slidesTransform.overview ); Util.transformElement( dom.slides, slidesTransform.layout + ' ' + slidesTransform.overview );
} }
else { else {
transformElement( dom.slides, slidesTransform.overview ); Util.transformElement( dom.slides, slidesTransform.overview );
} }
} }
@ -568,7 +560,7 @@ export default function( revealElement, options ) {
let event = document.createEvent( 'HTMLEvents', 1, 2 ); let event = document.createEvent( 'HTMLEvents', 1, 2 );
event.initEvent( type, bubbles, true ); event.initEvent( type, bubbles, true );
extend( event, data ); Util.extend( event, data );
target.dispatchEvent( event ); target.dispatchEvent( event );
if( target === dom.wrapper ) { if( target === dom.wrapper ) {
@ -591,7 +583,7 @@ export default function( revealElement, options ) {
state: getState() state: getState()
}; };
extend( message, data ); Util.extend( message, data );
window.parent.postMessage( JSON.stringify( message ), '*' ); window.parent.postMessage( JSON.stringify( message ), '*' );
} }
@ -769,7 +761,7 @@ export default function( revealElement, options ) {
// property where 100x adds up to the correct height. // property where 100x adds up to the correct height.
// //
// https://css-tricks.com/the-trick-to-viewport-units-on-mobile/ // https://css-tricks.com/the-trick-to-viewport-units-on-mobile/
if( isMobile ) { if( Device.isMobile ) {
document.documentElement.style.setProperty( '--vh', ( window.innerHeight * 0.01 ) + 'px' ); document.documentElement.style.setProperty( '--vh', ( window.innerHeight * 0.01 ) + 'px' );
} }
@ -805,7 +797,7 @@ export default function( revealElement, options ) {
// effects are minor differences in text layout and iframe // effects are minor differences in text layout and iframe
// viewports changing size. A 200x200 iframe viewport in a // viewports changing size. A 200x200 iframe viewport in a
// 2x zoomed presentation ends up having a 400x400 viewport. // 2x zoomed presentation ends up having a 400x400 viewport.
if( scale > 1 && supportsZoom && window.devicePixelRatio < 2 ) { if( scale > 1 && Device.supportsZoom && window.devicePixelRatio < 2 ) {
dom.slides.style.zoom = scale; dom.slides.style.zoom = scale;
dom.slides.style.left = ''; dom.slides.style.left = '';
dom.slides.style.top = ''; dom.slides.style.top = '';
@ -887,10 +879,10 @@ export default function( revealElement, options ) {
function layoutSlideContents( width, height ) { function layoutSlideContents( width, height ) {
// Handle sizing of elements with the 'stretch' class // Handle sizing of elements with the 'stretch' class
queryAll( dom.slides, 'section > .stretch' ).forEach( element => { Util.queryAll( dom.slides, 'section > .stretch' ).forEach( element => {
// Determine how much vertical space we can use // Determine how much vertical space we can use
let remainingHeight = getRemainingHeight( element, height ); let remainingHeight = Util.getRemainingHeight( element, height );
// Consider the aspect ratio of media elements // Consider the aspect ratio of media elements
if( /(img|video)/gi.test( element.nodeName ) ) { if( /(img|video)/gi.test( element.nodeName ) ) {
@ -1405,7 +1397,7 @@ export default function( revealElement, options ) {
getHorizontalSlides().forEach( horizontalSlide => { getHorizontalSlides().forEach( horizontalSlide => {
queryAll( horizontalSlide, 'section' ).forEach( ( verticalSlide, y ) => { Util.queryAll( horizontalSlide, 'section' ).forEach( ( verticalSlide, y ) => {
if( y > 0 ) { if( y > 0 ) {
verticalSlide.classList.remove( 'present' ); verticalSlide.classList.remove( 'present' );
@ -1452,7 +1444,7 @@ export default function( revealElement, options ) {
// Select all slides and convert the NodeList result to // Select all slides and convert the NodeList result to
// an array // an array
let slides = queryAll( dom.wrapper, selector ), let slides = Util.queryAll( dom.wrapper, selector ),
slidesLength = slides.length; slidesLength = slides.length;
let printMode = print.isPrintingPDF(); let printMode = print.isPrintingPDF();
@ -1499,7 +1491,7 @@ export default function( revealElement, options ) {
if( config.fragments ) { if( config.fragments ) {
// Show all fragments in prior slides // Show all fragments in prior slides
queryAll( element, '.fragment' ).forEach( fragment => { Util.queryAll( element, '.fragment' ).forEach( fragment => {
fragment.classList.add( 'visible' ); fragment.classList.add( 'visible' );
fragment.classList.remove( 'current-fragment' ); fragment.classList.remove( 'current-fragment' );
} ); } );
@ -1511,7 +1503,7 @@ export default function( revealElement, options ) {
if( config.fragments ) { if( config.fragments ) {
// Hide all fragments in future slides // Hide all fragments in future slides
queryAll( element, '.fragment.visible' ).forEach( fragment => { Util.queryAll( element, '.fragment.visible' ).forEach( fragment => {
fragment.classList.remove( 'visible', 'current-fragment' ); fragment.classList.remove( 'visible', 'current-fragment' );
} ); } );
} }
@ -1574,7 +1566,7 @@ export default function( revealElement, options ) {
// Shorten the view distance on devices that typically have // Shorten the view distance on devices that typically have
// less resources // less resources
if( isMobile ) { if( Device.isMobile ) {
viewDistance = overview.isActive() ? 6 : config.mobileViewDistance; viewDistance = overview.isActive() ? 6 : config.mobileViewDistance;
} }
@ -1586,7 +1578,7 @@ export default function( revealElement, options ) {
for( let x = 0; x < horizontalSlidesLength; x++ ) { for( let x = 0; x < horizontalSlidesLength; x++ ) {
let horizontalSlide = horizontalSlides[x]; let horizontalSlide = horizontalSlides[x];
let verticalSlides = queryAll( horizontalSlide, 'section' ), let verticalSlides = Util.queryAll( horizontalSlide, 'section' ),
verticalSlidesLength = verticalSlides.length; verticalSlidesLength = verticalSlides.length;
// Determine how far away this slide is from the present // Determine how far away this slide is from the present
@ -1813,7 +1805,7 @@ export default function( revealElement, options ) {
// If this is a vertical slide, grab the vertical index // If this is a vertical slide, grab the vertical index
if( isVertical ) { if( isVertical ) {
v = Math.max( queryAll( slide.parentNode, 'section' ).indexOf( slide ), 0 ); v = Math.max( Util.queryAll( slide.parentNode, 'section' ).indexOf( slide ), 0 );
} }
} }
@ -1839,7 +1831,7 @@ export default function( revealElement, options ) {
*/ */
function getSlides() { function getSlides() {
return queryAll( dom.wrapper, SLIDES_SELECTOR + ':not(.stack):not([data-visibility="uncounted"])' ); return Util.queryAll( dom.wrapper, SLIDES_SELECTOR + ':not(.stack):not([data-visibility="uncounted"])' );
} }
@ -1850,7 +1842,7 @@ export default function( revealElement, options ) {
*/ */
function getHorizontalSlides() { function getHorizontalSlides() {
return queryAll( dom.wrapper, HORIZONTAL_SLIDES_SELECTOR ); return Util.queryAll( dom.wrapper, HORIZONTAL_SLIDES_SELECTOR );
} }
@ -1859,7 +1851,7 @@ export default function( revealElement, options ) {
*/ */
function getVerticalSlides() { function getVerticalSlides() {
return queryAll( dom.wrapper, '.slides>section>section' ); return Util.queryAll( dom.wrapper, '.slides>section>section' );
} }
@ -1868,7 +1860,7 @@ export default function( revealElement, options ) {
*/ */
function getVerticalStacks() { function getVerticalStacks() {
return queryAll( dom.wrapper, HORIZONTAL_SLIDES_SELECTOR + '.stack'); return Util.queryAll( dom.wrapper, HORIZONTAL_SLIDES_SELECTOR + '.stack');
} }
@ -1989,10 +1981,10 @@ export default function( revealElement, options ) {
function setState( state ) { function setState( state ) {
if( typeof state === 'object' ) { if( typeof state === 'object' ) {
slide( deserialize( state.indexh ), deserialize( state.indexv ), deserialize( state.indexf ) ); slide( Util.deserialize( state.indexh ), Util.deserialize( state.indexv ), Util.deserialize( state.indexf ) );
let pausedFlag = deserialize( state.paused ), let pausedFlag = Util.deserialize( state.paused ),
overviewFlag = deserialize( state.overview ); overviewFlag = Util.deserialize( state.overview );
if( typeof pausedFlag === 'boolean' && pausedFlag !== isPaused() ) { if( typeof pausedFlag === 'boolean' && pausedFlag !== isPaused() ) {
togglePause( pausedFlag ); togglePause( pausedFlag );
@ -2048,7 +2040,7 @@ export default function( revealElement, options ) {
// is divided up into fragments. // is divided up into fragments.
// playbackRate is accounted for in the duration. // playbackRate is accounted for in the duration.
if( currentSlide.querySelectorAll( '.fragment' ).length === 0 ) { if( currentSlide.querySelectorAll( '.fragment' ).length === 0 ) {
queryAll( currentSlide, 'video, audio' ).forEach( el => { Util.queryAll( currentSlide, 'video, audio' ).forEach( el => {
if( el.hasAttribute( 'data-autoplay' ) ) { if( el.hasAttribute( 'data-autoplay' ) ) {
if( autoSlide && (el.duration * 1000 / el.playbackRate ) > autoSlide ) { if( autoSlide && (el.duration * 1000 / el.playbackRate ) > autoSlide ) {
autoSlide = ( el.duration * 1000 / el.playbackRate ) + 1000; autoSlide = ( el.duration * 1000 / el.playbackRate ) + 1000;
@ -2190,10 +2182,10 @@ export default function( revealElement, options ) {
let previousSlide; let previousSlide;
if( config.rtl ) { if( config.rtl ) {
previousSlide = queryAll( dom.wrapper, HORIZONTAL_SLIDES_SELECTOR + '.future' ).pop(); previousSlide = Util.queryAll( dom.wrapper, HORIZONTAL_SLIDES_SELECTOR + '.future' ).pop();
} }
else { else {
previousSlide = queryAll( dom.wrapper, HORIZONTAL_SLIDES_SELECTOR + '.past' ).pop(); previousSlide = Util.queryAll( dom.wrapper, HORIZONTAL_SLIDES_SELECTOR + '.past' ).pop();
} }
if( previousSlide ) { if( previousSlide ) {
@ -2500,7 +2492,7 @@ export default function( revealElement, options ) {
getConfig: () => config, getConfig: () => config,
// Helper method, retrieves query string as a key:value map // Helper method, retrieves query string as a key:value map
getQueryHash, getQueryHash: Util.getQueryHash,
// Returns reveal.js DOM elements // Returns reveal.js DOM elements
getRevealElement: () => revealElement, getRevealElement: () => revealElement,
@ -2516,7 +2508,7 @@ export default function( revealElement, options ) {
}; };
// Our internal API which controllers have access to // Our internal API which controllers have access to
extend( Reveal, { Util.extend( Reveal, {
...API, ...API,
// Methods for announcing content to screen readers // Methods for announcing content to screen readers

3
package-lock.json generated
View File

@ -2267,7 +2267,8 @@
"core-js": { "core-js": {
"version": "3.6.5", "version": "3.6.5",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.6.5.tgz", "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.6.5.tgz",
"integrity": "sha512-vZVEEwZoIsI+vPEuoF9Iqf5H7/M3eeQqWlQnYa8FSKKePuYTf5MWnxb5SDAzCa60b3JBRS5g9b+Dq7b1y/RCrA==" "integrity": "sha512-vZVEEwZoIsI+vPEuoF9Iqf5H7/M3eeQqWlQnYa8FSKKePuYTf5MWnxb5SDAzCa60b3JBRS5g9b+Dq7b1y/RCrA==",
"dev": true
}, },
"core-js-compat": { "core-js-compat": {
"version": "3.6.5", "version": "3.6.5",

View File

@ -28,6 +28,7 @@
"@babel/preset-env": "^7.8.7", "@babel/preset-env": "^7.8.7",
"@rollup/plugin-node-resolve": "^7.1.3", "@rollup/plugin-node-resolve": "^7.1.3",
"babel-eslint": "^10.1.0", "babel-eslint": "^10.1.0",
"core-js": "^3.6.5",
"colors": "^1.4.0", "colors": "^1.4.0",
"express": "^4.17.1", "express": "^4.17.1",
"glob": "^7.1.6", "glob": "^7.1.6",
@ -41,10 +42,10 @@
"gulp-tap": "^2.0.0", "gulp-tap": "^2.0.0",
"gulp-zip": "^5.0.1", "gulp-zip": "^5.0.1",
"mustache": "^4.0.0", "mustache": "^4.0.0",
"node-qunit-puppeteer": "^2.0.1",
"rollup": "^2.6.1", "rollup": "^2.6.1",
"rollup-plugin-babel": "^4.4.0", "rollup-plugin-babel": "^4.4.0",
"rollup-plugin-terser": "^5.3.0", "rollup-plugin-terser": "^5.3.0",
"node-qunit-puppeteer": "^2.0.1",
"socket.io": "^2.3.0", "socket.io": "^2.3.0",
"yargs": "^15.1.0" "yargs": "^15.1.0"
}, },
@ -60,7 +61,6 @@
"allowImportExportEverywhere": true "allowImportExportEverywhere": true
}, },
"globals": { "globals": {
"head": false,
"module": false, "module": false,
"console": false, "console": false,
"unescape": false, "unescape": false,
@ -86,8 +86,5 @@
"no-eq-null": 2, "no-eq-null": 2,
"no-unused-expressions": 0 "no-unused-expressions": 0
} }
},
"dependencies": {
"core-js": "^3.6.5"
} }
} }