refactoring
This commit is contained in:
parent
3d6212378a
commit
ac15678dea
@ -133,8 +133,8 @@ Here's a barebones example of a fully working reveal.js presentation:
|
|||||||
```html
|
```html
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<link rel="stylesheet" href="css/reveal.css">
|
<link rel="stylesheet" href="dist/reveal.css">
|
||||||
<link rel="stylesheet" href="css/theme/white.css">
|
<link rel="stylesheet" href="dist/theme/white.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="reveal">
|
<div class="reveal">
|
||||||
@ -143,7 +143,7 @@ Here's a barebones example of a fully working reveal.js presentation:
|
|||||||
<section>Slide 2</section>
|
<section>Slide 2</section>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="js/reveal.js"></script>
|
<script src="dist/reveal.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
Reveal.initialize();
|
Reveal.initialize();
|
||||||
</script>
|
</script>
|
||||||
|
2
dist/reveal.min.js
vendored
2
dist/reveal.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1,7 +1,7 @@
|
|||||||
import { extend, toArray, enterFullscreen } from '../utils/util.js'
|
import { enterFullscreen } from '../utils/util.js'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Handles all reveal.js keyboard interactions.
|
||||||
*/
|
*/
|
||||||
export default class Keyboard {
|
export default class Keyboard {
|
||||||
|
|
||||||
@ -21,30 +21,9 @@ export default class Keyboard {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshSortcuts() {
|
/**
|
||||||
|
* Starts listening for keyboard events.
|
||||||
// Define our contextual list of keyboard shortcuts
|
*/
|
||||||
if( this.Reveal.getConfig().navigationMode === 'linear' ) {
|
|
||||||
this.shortcuts['→ , ↓ , SPACE , N , L , J'] = 'Next slide';
|
|
||||||
this.shortcuts['← , ↑ , P , H , K'] = 'Previous slide';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.shortcuts['N , SPACE'] = 'Next slide';
|
|
||||||
this.shortcuts['P'] = 'Previous slide';
|
|
||||||
this.shortcuts['← , H'] = 'Navigate left';
|
|
||||||
this.shortcuts['→ , L'] = 'Navigate right';
|
|
||||||
this.shortcuts['↑ , K'] = 'Navigate up';
|
|
||||||
this.shortcuts['↓ , J'] = 'Navigate down';
|
|
||||||
}
|
|
||||||
|
|
||||||
this.shortcuts['Home , Shift ←'] = 'First slide';
|
|
||||||
this.shortcuts['End , Shift →'] = 'Last slide';
|
|
||||||
this.shortcuts['B , .'] = 'Pause';
|
|
||||||
this.shortcuts['F'] = 'Fullscreen';
|
|
||||||
this.shortcuts['ESC, O'] = 'Slide overview';
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bind() {
|
bind() {
|
||||||
|
|
||||||
document.addEventListener( 'keydown', this.onDocumentKeyDown, false );
|
document.addEventListener( 'keydown', this.onDocumentKeyDown, false );
|
||||||
@ -52,6 +31,9 @@ export default class Keyboard {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stops listening for keyboard events.
|
||||||
|
*/
|
||||||
unbind() {
|
unbind() {
|
||||||
|
|
||||||
document.removeEventListener( 'keydown', this.onDocumentKeyDown, false );
|
document.removeEventListener( 'keydown', this.onDocumentKeyDown, false );
|
||||||
@ -91,6 +73,32 @@ export default class Keyboard {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates our keyboard shortcuts based on current settings.
|
||||||
|
*/
|
||||||
|
refreshSortcuts() {
|
||||||
|
|
||||||
|
if( this.Reveal.getConfig().navigationMode === 'linear' ) {
|
||||||
|
this.shortcuts['→ , ↓ , SPACE , N , L , J'] = 'Next slide';
|
||||||
|
this.shortcuts['← , ↑ , P , H , K'] = 'Previous slide';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.shortcuts['N , SPACE'] = 'Next slide';
|
||||||
|
this.shortcuts['P'] = 'Previous slide';
|
||||||
|
this.shortcuts['← , H'] = 'Navigate left';
|
||||||
|
this.shortcuts['→ , L'] = 'Navigate right';
|
||||||
|
this.shortcuts['↑ , K'] = 'Navigate up';
|
||||||
|
this.shortcuts['↓ , J'] = 'Navigate down';
|
||||||
|
}
|
||||||
|
|
||||||
|
this.shortcuts['Home , Shift ←'] = 'First slide';
|
||||||
|
this.shortcuts['End , Shift →'] = 'Last slide';
|
||||||
|
this.shortcuts['B , .'] = 'Pause';
|
||||||
|
this.shortcuts['F'] = 'Fullscreen';
|
||||||
|
this.shortcuts['ESC, O'] = 'Slide overview';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Programmatically triggers a keyboard event
|
* Programmatically triggers a keyboard event
|
||||||
*
|
*
|
||||||
|
28
js/reveal.js
28
js/reveal.js
@ -20,7 +20,8 @@ import {
|
|||||||
transformElement,
|
transformElement,
|
||||||
createStyleSheet,
|
createStyleSheet,
|
||||||
closestParent,
|
closestParent,
|
||||||
enterFullscreen
|
enterFullscreen,
|
||||||
|
getQueryHash
|
||||||
} from './utils/util.js'
|
} from './utils/util.js'
|
||||||
import { isMobile, isChrome, isAndroid, supportsZoom } from './utils/device.js'
|
import { isMobile, isChrome, isAndroid, supportsZoom } from './utils/device.js'
|
||||||
import { colorToRgb, colorBrightness } from './utils/color.js'
|
import { colorToRgb, colorBrightness } from './utils/color.js'
|
||||||
@ -146,7 +147,7 @@ export default function( revealElement, options ) {
|
|||||||
window.addEventListener( 'load', layout, false );
|
window.addEventListener( 'load', layout, false );
|
||||||
|
|
||||||
// Copy options over to our config object
|
// Copy options over to our config object
|
||||||
config = { ...defaultConfig, ...options, ...Reveal.getQueryHash() };
|
config = { ...defaultConfig, ...options, ...getQueryHash() };
|
||||||
|
|
||||||
// Load plugins then move on to #start()
|
// Load plugins then move on to #start()
|
||||||
plugins.load( config.dependencies ).then( start )
|
plugins.load( config.dependencies ).then( start )
|
||||||
@ -3896,27 +3897,8 @@ export default function( revealElement, options ) {
|
|||||||
// Returns the current configuration object
|
// Returns the current configuration object
|
||||||
getConfig: () => config,
|
getConfig: () => config,
|
||||||
|
|
||||||
// Helper method, retrieves query string as a key/value hash
|
// Helper method, retrieves query string as a key:value map
|
||||||
getQueryHash: () => {
|
getQueryHash,
|
||||||
let query = {};
|
|
||||||
|
|
||||||
location.search.replace( /[A-Z0-9]+?=([\w\.%-]*)/gi, a => {
|
|
||||||
query[ a.split( '=' ).shift() ] = a.split( '=' ).pop();
|
|
||||||
} );
|
|
||||||
|
|
||||||
// Basic deserialization
|
|
||||||
for( let i in query ) {
|
|
||||||
let value = query[ i ];
|
|
||||||
|
|
||||||
query[ i ] = deserialize( unescape( value ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do not accept new dependencies via query config to avoid
|
|
||||||
// the potential of malicious script injection
|
|
||||||
if( typeof query['dependencies'] !== 'undefined' ) delete query['dependencies'];
|
|
||||||
|
|
||||||
return query;
|
|
||||||
},
|
|
||||||
|
|
||||||
// Returns the top-level DOM element
|
// Returns the top-level DOM element
|
||||||
getRevealElement: () => dom.wrapper || document.querySelector( '.reveal' ),
|
getRevealElement: () => dom.wrapper || document.querySelector( '.reveal' ),
|
||||||
|
@ -158,4 +158,30 @@ export const createStyleSheet = ( value ) => {
|
|||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a key:value hash of all query params.
|
||||||
|
*/
|
||||||
|
export const getQueryHash = () => {
|
||||||
|
|
||||||
|
let query = {};
|
||||||
|
|
||||||
|
location.search.replace( /[A-Z0-9]+?=([\w\.%-]*)/gi, a => {
|
||||||
|
query[ a.split( '=' ).shift() ] = a.split( '=' ).pop();
|
||||||
|
} );
|
||||||
|
|
||||||
|
// Basic deserialization
|
||||||
|
for( let i in query ) {
|
||||||
|
let value = query[ i ];
|
||||||
|
|
||||||
|
query[ i ] = deserialize( unescape( value ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do not accept new dependencies via query config to avoid
|
||||||
|
// the potential of malicious script injection
|
||||||
|
if( typeof query['dependencies'] !== 'undefined' ) delete query['dependencies'];
|
||||||
|
|
||||||
|
return query;
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user