vault backup: 2025-09-07 20:45:17

This commit is contained in:
CrazyJasonwell committed 2025-09-07 20:45:18 +08:00
1 parent a85fb49160
commit d0b9f7a051
262 files changed
+32442 -6584

No files matched your search

@@ -0,0 +1,60 @@
# Custom controls
This plugin allows to add responsive custom controls to reveal.js which allow arbitrary positioning, layout, and behaviour of the controls.
[Check out the demo](https://rajgoel.github.io/reveal.js-demos/)
## Setup
To use the plugin include
```html
<!-- Font awesome is used by several plugins -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/js/all.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<!-- Custom controls plugin -->
<script src="https://cdn.jsdelivr.net/npm/reveal.js-plugins@latest/customcontrols/plugin.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/reveal.js-plugins@latest/customcontrols/style.css">
```
to the header of your presentation and configure reveal.js and the plugin by
```js
Reveal.initialize({
customcontrols: {
// add configuration here
},
// ...
plugins: [ RevealCustomControls ],
// ...
});
```
## Configuration
The plugin can be configured by adding custom controls and changing the layout of the slide number, e.g., by:
```javascript
Reveal.initialize({
// ...
customcontrols: {
controls: [
{
id: 'toggle-overview',
title: 'Toggle overview (O)',
icon: '<i class="fa fa-th"></i>',
action: 'Reveal.toggleOverview();'
}
]
},
// ...
});
```
The `id` and `title` are optional. The configuration should be self explaining and any number of controls can be added. The style file can be altered to control the layout and responsiveness of the custom controls.
## License
MIT licensed
Copyright (C) 2023 Asvin Goel
@@ -0,0 +1,73 @@
/*****************************************************************
** Author: Asvin Goel, goel@telematique.eu
**
** A plugin replacing the default controls by custom controls.
**
** Version: 2.0.1
**
** License: MIT license (see LICENSE.md)
**
******************************************************************/
window.RevealCustomControls = window.RevealCustomControls || {
id: 'RevealCustomControls',
init: function(deck) {
initCustomControls(deck);
}
};
const initCustomControls = function(Reveal){
var config = Reveal.getConfig().customcontrols || {};
if (Reveal.isSpeakerNotes() && new URLSearchParams(location.search).get('controls') == 'false') return;
if (!config?.controls?.length) return this;
var collapseIcon = config.collapseIcon || '<i class="fa fa-chevron-down"></i>';
var expandIcon = config.expandIcon || '<i class="fa fa-chevron-up"></i>';
var tooltip = config.tooltip || 'Show/hide controls';
var div = document.createElement( 'div' );
div.id = 'customcontrols';
var toggleButton = document.createElement( 'button' );
toggleButton.title = tooltip;
toggleButton.innerHTML = '<span id="collapse-customcontrols">' + collapseIcon + '</span>' + '<span id="expand-customcontrols">' + expandIcon + '</span>';
toggleButton.addEventListener('click', function( event ) {
var div = document.querySelector("div#customcontrols");
if ( div.classList.contains('collapsed') ) {
div.classList.remove('collapsed');
}
else {
div.classList.add('collapsed');
}
toggleButton.blur(); // unfocus button
});
div.appendChild(toggleButton);
var controls = document.createElement( 'ul' );
for (var i = 0; i < config.controls.length; i++ ) {
var control = document.createElement( 'li' );
if ( config.controls[i].id ) {
control.id = config.controls[i].id;
}
control.innerHTML = '<button ' + ( config.controls[i].title ? 'title="' + config.controls[i].title + '" ': '' ) + 'onclick="' + config.controls[i].action + '">' + config.controls[i].icon + '</button>';
controls.appendChild( control );
}
div.appendChild( controls );
document.querySelector(".reveal").appendChild( div );
document.addEventListener( 'resize', function( event ) {
// expand controls to make sure they are visible
var div = document.querySelector("div#customcontrols.collapsed");
if ( div ) {
div.classList.remove('collapsed');
}
} );
return this;
};
@@ -0,0 +1,70 @@
#customcontrols {
z-index: 40;
position: fixed;
left: 70px;
bottom: 30px;
text-align: center;
font-size: 24px;
}
#customcontrols button {
background: none;
color: var(--r-link-color);
border: none;
padding: 0;
font: inherit;
cursor: pointer;
outline: inherit;
z-index: 40;
}
#customcontrols button:hover {
color: var(--r-link-color-hover);
}
#customcontrols > ul {
position: fixed;
left: 54px;
bottom: 64px;
list-style-type: none;
overflow: hidden;
margin: 0;
border: 1px solid var(--r-link-color);
border-radius: 5px;
padding: 10px;
background-color: var(--r-background-color)
}
#customcontrols ul > li {
margin: 0px 5px;
padding: 0px 5px;
float: left;
}
#customcontrols.collapsed #collapse-customcontrols, #customcontrols.collapsed > ul {
display: none;
}
#customcontrols:not(.collapsed) #expand-customcontrols {
display: none;
}
@media only screen and (min-width: 500px) {
#customcontrols > button {
display: none;
}
#customcontrols > ul {
padding-top: 0px;
padding-bottom: 0px;
bottom: 30px;
border: none;
background: none;
}
}
@media print {
#customcontrols {
display: none!important;
}
}