Minor refactoring
Removed some code duplication
This commit is contained in:
parent
7d19b4f7ce
commit
04b9e444d9
57
js/reveal.js
57
js/reveal.js
|
@ -193,49 +193,26 @@ var Reveal = (function(){
|
||||||
dom.slides = document.querySelector( '.reveal .slides' );
|
dom.slides = document.querySelector( '.reveal .slides' );
|
||||||
|
|
||||||
// Background element
|
// Background element
|
||||||
if( !document.querySelector( '.reveal .backgrounds' ) ) {
|
dom.background = initializeNode(dom.wrapper, 'div', 'backgrounds', null);
|
||||||
dom.background = document.createElement( 'div' );
|
|
||||||
dom.background.classList.add( 'backgrounds' );
|
|
||||||
dom.wrapper.appendChild( dom.background );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Progress bar
|
// Progress bar
|
||||||
if( !dom.wrapper.querySelector( '.progress' ) ) {
|
dom.progress = initializeNode(dom.wrapper, 'div', 'progress', '<span></span>');
|
||||||
var progressElement = document.createElement( 'div' );
|
dom.progressbar = dom.progress.querySelector('span');
|
||||||
progressElement.classList.add( 'progress' );
|
|
||||||
progressElement.innerHTML = '<span></span>';
|
|
||||||
dom.wrapper.appendChild( progressElement );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Arrow controls
|
// Arrow controls
|
||||||
if( !dom.wrapper.querySelector( '.controls' ) ) {
|
initializeNode(dom.wrapper, 'aside', 'controls',
|
||||||
var controlsElement = document.createElement( 'aside' );
|
'<div class="navigate-left"></div>' +
|
||||||
controlsElement.classList.add( 'controls' );
|
|
||||||
controlsElement.innerHTML = '<div class="navigate-left"></div>' +
|
|
||||||
'<div class="navigate-right"></div>' +
|
'<div class="navigate-right"></div>' +
|
||||||
'<div class="navigate-up"></div>' +
|
'<div class="navigate-up"></div>' +
|
||||||
'<div class="navigate-down"></div>';
|
'<div class="navigate-down"></div>');
|
||||||
dom.wrapper.appendChild( controlsElement );
|
|
||||||
}
|
|
||||||
|
|
||||||
// State background element [DEPRECATED]
|
// State background element [DEPRECATED]
|
||||||
if( !dom.wrapper.querySelector( '.state-background' ) ) {
|
initializeNode(dom.wrapper, 'div', 'state-background', null);
|
||||||
var stateBackgroundElement = document.createElement( 'div' );
|
|
||||||
stateBackgroundElement.classList.add( 'state-background' );
|
|
||||||
dom.wrapper.appendChild( stateBackgroundElement );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Overlay graphic which is displayed during the paused mode
|
// Overlay graphic which is displayed during the paused mode
|
||||||
if( !dom.wrapper.querySelector( '.pause-overlay' ) ) {
|
initializeNode(dom.wrapper, 'div', 'pause-overlay', null);
|
||||||
var pausedElement = document.createElement( 'div' );
|
|
||||||
pausedElement.classList.add( 'pause-overlay' );
|
|
||||||
dom.wrapper.appendChild( pausedElement );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cache references to elements
|
// Cache references to elements
|
||||||
dom.progress = document.querySelector( '.reveal .progress' );
|
|
||||||
dom.progressbar = document.querySelector( '.reveal .progress span' );
|
|
||||||
|
|
||||||
if ( config.controls ) {
|
if ( config.controls ) {
|
||||||
dom.controls = document.querySelector( '.reveal .controls' );
|
dom.controls = document.querySelector( '.reveal .controls' );
|
||||||
|
|
||||||
|
@ -250,6 +227,24 @@ var Reveal = (function(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function initializeNode(container, tagname, classname, innerHTML){
|
||||||
|
var node = container.querySelector('.' + classname);
|
||||||
|
if( !node ){
|
||||||
|
node = buildNode(tagname, classname, innerHTML);
|
||||||
|
container.appendChild(node);
|
||||||
|
}
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildNode(tagname, classname, innerHTML){
|
||||||
|
var node = document.createElement(tagname);
|
||||||
|
node.classList.add(classname);
|
||||||
|
if(innerHTML !== null){
|
||||||
|
node.innerHTML = innerHTML;
|
||||||
|
}
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the slide background elements and appends them
|
* Creates the slide background elements and appends them
|
||||||
* to the background container. One element is created per
|
* to the background container. One element is created per
|
||||||
|
|
4
js/reveal.min.js
vendored
4
js/reveal.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user