Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Andrew Seales
Kubernetes Presentation
Commits
ac15678d
Commit
ac15678d
authored
Mar 10, 2020
by
Hakim El Hattab
Browse files
refactoring
parent
3d621237
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
ac15678d
...
...
@@ -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>
...
...
dist/reveal.min.js
View file @
ac15678d
This diff is collapsed.
Click to expand it.
js/controllers/keyboard.js
View file @
ac15678d
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
*
...
...
js/reveal.js
View file @
ac15678d
...
...
@@ -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
'
),
...
...
js/utils/util.js
View file @
ac15678d
...
...
@@ -158,4 +158,30 @@ 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
;
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment