/*****************************************************************
** Author: Asvin Goel, goel@telematique.eu
**
** A plugin replacing the default controls by custom controls.
**
** Version: 2.0.0
**
** 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 || {};
var collapseIcon = config.collapseIcon || '';
var expandIcon = config.expandIcon || '';
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 = '' + collapseIcon + '' + '' + expandIcon + '';
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');
}
});
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 = '';
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;
};