allow control over background color when using images (#453)

This commit is contained in:
Hakim El Hattab
2013-06-04 20:25:47 +02:00
parent 15f24f7a9a
commit 544e090bd1
5 changed files with 11 additions and 8 deletions

View File

@ -249,7 +249,8 @@ var Reveal = (function(){
/**
* Creates the slide background elements and appends them
* to the background container.
* to the background container. One element is created per
* slide no matter if the given slide has visible background.
*/
function createBackgrounds() {
@ -264,6 +265,7 @@ var Reveal = (function(){
var data = {
background: slide.getAttribute( 'data-background' ),
backgroundSize: slide.getAttribute( 'data-background-size' ),
backgroundColor: slide.getAttribute( 'data-background-color' ),
backgroundRepeat: slide.getAttribute( 'data-background-repeat' ),
backgroundPosition: slide.getAttribute( 'data-background-position' )
};
@ -272,7 +274,7 @@ var Reveal = (function(){
if( data.background ) {
// Auto-wrap image urls in url(...)
if( /\.(png|jpg|jpeg|gif|bmp|)$/gi.test( data.background ) ) {
if( /\.(png|jpg|jpeg|gif|bmp)$/gi.test( data.background ) ) {
element.style.backgroundImage = 'url('+ data.background +')';
}
else {
@ -282,6 +284,7 @@ var Reveal = (function(){
// Additional and optional background properties
if( data.backgroundSize ) element.style.backgroundSize = data.backgroundSize;
if( data.backgroundColor ) element.style.backgroundColor = data.backgroundColor;
if( data.backgroundRepeat ) element.style.backgroundRepeat = data.backgroundRepeat;
if( data.backgroundPosition ) element.style.backgroundPosition = data.backgroundPosition;

4
js/reveal.min.js vendored

File diff suppressed because one or more lines are too long