refactoring
parent
3d6212378a
commit
ac15678dea
|
@ -133,8 +133,8 @@ Here's a barebones example of a fully working reveal.js presentation:
|
|||
```html
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="css/reveal.css">
|
||||
<link rel="stylesheet" href="css/theme/white.css">
|
||||
<link rel="stylesheet" href="dist/reveal.css">
|
||||
<link rel="stylesheet" href="dist/theme/white.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="reveal">
|
||||
|
@ -143,7 +143,7 @@ Here's a barebones example of a fully working reveal.js presentation:
|
|||
<section>Slide 2</section>
|
||||
</div>
|
||||
</div>
|
||||
<script src="js/reveal.js"></script>
|
||||
<script src="dist/reveal.min.js"></script>
|
||||
<script>
|
||||
Reveal.initialize();
|
||||
</script>
|
||||
|
|
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 {
|
||||
|
||||
|
@ -21,30 +21,9 @@ export default class Keyboard {
|
|||
|
||||
}
|
||||
|
||||
refreshSortcuts() {
|
||||
|
||||
// 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';
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts listening for keyboard events.
|
||||
*/
|
||||
bind() {
|
||||
|
||||
document.addEventListener( 'keydown', this.onDocumentKeyDown, false );
|
||||
|
@ -52,6 +31,9 @@ export default class Keyboard {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops listening for keyboard events.
|
||||
*/
|
||||
unbind() {
|
||||
|
||||
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
|
||||
*
|
||||
|
|
28
js/reveal.js
28
js/reveal.js
|
@ -20,7 +20,8 @@ import {
|
|||
transformElement,
|
||||
createStyleSheet,
|
||||
closestParent,
|
||||
enterFullscreen
|
||||
enterFullscreen,
|
||||
getQueryHash
|
||||
} from './utils/util.js'
|
||||
import { isMobile, isChrome, isAndroid, supportsZoom } from './utils/device.js'
|
||||
import { colorToRgb, colorBrightness } from './utils/color.js'
|
||||
|
@ -146,7 +147,7 @@ export default function( revealElement, options ) {
|
|||
window.addEventListener( 'load', layout, false );
|
||||
|
||||
// Copy options over to our config object
|
||||
config = { ...defaultConfig, ...options, ...Reveal.getQueryHash() };
|
||||
config = { ...defaultConfig, ...options, ...getQueryHash() };
|
||||
|
||||
// Load plugins then move on to #start()
|
||||
plugins.load( config.dependencies ).then( start )
|
||||
|
@ -3896,27 +3897,8 @@ export default function( revealElement, options ) {
|
|||
// Returns the current configuration object
|
||||
getConfig: () => config,
|
||||
|
||||
// Helper method, retrieves query string as a key/value hash
|
||||
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;
|
||||
},
|
||||
// Helper method, retrieves query string as a key:value map
|
||||
getQueryHash,
|
||||
|
||||
// Returns the top-level DOM element
|
||||
getRevealElement: () => dom.wrapper || document.querySelector( '.reveal' ),
|
||||
|
|
|
@ -159,3 +159,29 @@ export const createStyleSheet = ( value ) => {
|
|||
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