aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHakim El Hattab <hakim.elhattab@gmail.com>2014-09-09 16:50:23 +0200
committerHakim El Hattab <hakim.elhattab@gmail.com>2014-09-09 16:50:23 +0200
commit20e72df4bf3f284604e15c6384983055b3641baa (patch)
tree0abb7edf0e7c5cf5027155d5fb754b682f5149c4
parent8a50a46665b699236920dd7f0aca74beb3fb0077 (diff)
downloadperl-software-in-gnu-guix-20e72df4bf3f284604e15c6384983055b3641baa.tar
perl-software-in-gnu-guix-20e72df4bf3f284604e15c6384983055b3641baa.tar.gz
add is-background-light class to slides/backgrounds that are > 128 brightness
-rw-r--r--js/reveal.js16
1 files changed, 10 insertions, 6 deletions
diff --git a/js/reveal.js b/js/reveal.js
index f92eca9..df4e8a0 100644
--- a/js/reveal.js
+++ b/js/reveal.js
@@ -714,8 +714,11 @@
if( data.backgroundPosition ) element.style.backgroundPosition = data.backgroundPosition;
if( data.backgroundTransition ) element.setAttribute( 'data-background-transition', data.backgroundTransition );
- if( data.backgroundColor ) {
-
+ // If this slide has a background color, add a class that
+ // signals if it is light
+ if( element.style.backgroundColor && colorBrightness( element.style.backgroundColor ) > 128 ) {
+ slide.classList.add( 'is-background-light' );
+ element.classList.add( 'is-background-light' );
}
container.appendChild( element );
@@ -1122,7 +1125,11 @@
if( typeof color === 'string' ) color = colorToRgb( color );
- return ( color.r * 299 + color.g * 587 + color.b * 114 ) / 1000;
+ if( color ) {
+ return ( color.r * 299 + color.g * 587 + color.b * 114 ) / 1000;
+ }
+
+ return null;
}
@@ -4100,9 +4107,6 @@
addEventListeners: addEventListeners,
removeEventListeners: removeEventListeners,
- colorToRgb: colorToRgb,
- colorBrightness: colorBrightness,
-
// Facility for persisting and restoring the presentation state
getState: getState,
setState: setState,