update style of notes plugin to match Slides

This commit is contained in:
Hakim El Hattab 2014-04-20 10:26:00 +02:00
parent 5b18c1f308
commit 3795ef1599
1 changed files with 152 additions and 131 deletions

View File

@ -10,128 +10,129 @@
font-family: Helvetica; font-family: Helvetica;
} }
#notes { #current-slide,
font-size: 24px; #next-slide,
width: 640px; #speaker-controls {
margin-top: 5px; padding: 6px;
clear: left; box-sizing: border-box;
-moz-box-sizing: border-box;
} }
#wrap-current-slide { #current-slide iframe,
width: 640px; #next-slide iframe {
height: 512px; width: 100%;
float: left; height: 100%;
overflow: hidden; border: 1px solid #ddd;
} }
#current-slide { #current-slide .label,
width: 1280px; #next-slide .label {
height: 1024px;
border: none;
-webkit-transform-origin: 0 0;
-moz-transform-origin: 0 0;
-ms-transform-origin: 0 0;
-o-transform-origin: 0 0;
transform-origin: 0 0;
-webkit-transform: scale(0.5);
-moz-transform: scale(0.5);
-ms-transform: scale(0.5);
-o-transform: scale(0.5);
transform: scale(0.5);
}
#wrap-next-slide {
width: 448px;
height: 358px;
float: left;
margin: 0 0 0 10px;
overflow: hidden;
}
#next-slide {
width: 1280px;
height: 1024px;
border: none;
-webkit-transform-origin: 0 0;
-moz-transform-origin: 0 0;
-ms-transform-origin: 0 0;
-o-transform-origin: 0 0;
transform-origin: 0 0;
-webkit-transform: scale(0.35);
-moz-transform: scale(0.35);
-ms-transform: scale(0.35);
-o-transform: scale(0.35);
transform: scale(0.35);
}
.slides {
position: relative;
margin-bottom: 10px;
border: 1px solid black;
border-radius: 2px;
background: rgb(28, 30, 32);
}
.slides span {
position: absolute; position: absolute;
top: 3px; top: 10px;
left: 3px; left: 10px;
font-weight: bold; font-weight: bold;
font-size: 14px; font-size: 14px;
z-index: 2; z-index: 2;
color: rgba( 255, 255, 255, 0.9 ); color: rgba( 255, 255, 255, 0.9 );
} }
.error { #current-slide {
font-weight: bold; position: absolute;
color: red; width: 65%;
font-size: 1.5em; height: 100%;
text-align: center; top: 0;
margin-top: 10%; left: 0;
padding-right: 0;
} }
.error code { #next-slide {
font-family: monospace; position: absolute;
width: 35%;
height: 40%;
right: 0;
top: 0;
} }
.time { #speaker-controls {
width: 448px; position: absolute;
margin: 30px 0 0 10px; top: 40%;
float: left; right: 0;
text-align: center; width: 35%;
opacity: 0; height: 60%;
-webkit-transition: opacity 0.4s; font-size: 18px;
-moz-transition: opacity 0.4s;
-o-transition: opacity 0.4s;
transition: opacity 0.4s;
} }
.elapsed, .speaker-controls-time.hidden,
.clock { .speaker-controls-notes.hidden {
color: #333; display: none;
font-size: 2em;
text-align: center;
display: inline-block;
padding: 0.5em;
background-color: #eee;
border-radius: 10px;
} }
.elapsed h2, .speaker-controls-time .label,
.clock h2 { .speaker-controls-notes .label {
font-size: 0.8em; text-transform: uppercase;
line-height: 100%; font-weight: normal;
font-size: 0.66em;
color: #666;
margin: 0; margin: 0;
color: #aaa;
} }
.elapsed .mute { .speaker-controls-time {
color: #ddd; border-bottom: 1px solid rgba( 200, 200, 200, 0.5 );
margin-bottom: 10px;
padding: 10px 16px;
padding-bottom: 20px;
}
.speaker-controls-time .timer,
.speaker-controls-time .clock {
width: 50%;
font-size: 1.9em;
}
.speaker-controls-time .timer {
float: left;
}
.speaker-controls-time .clock {
float: right;
text-align: right;
}
.speaker-controls-time span.mute {
color: #bbb;
}
.speaker-controls-notes {
padding: 10px 16px;
}
.speaker-controls-notes .value {
margin-top: 5px;
line-height: 1.4;
font-size: 1.2em;
}
.clear {
clear: both;
}
@media screen and (max-width: 1080px) {
#speaker-controls {
font-size: 16px;
}
}
@media screen and (max-width: 900px) {
#speaker-controls {
font-size: 14px;
}
}
@media screen and (max-width: 800px) {
#speaker-controls {
font-size: 12px;
}
} }
</style> </style>
@ -139,21 +140,25 @@
<body> <body>
<div id="wrap-current-slide" class="slides"></div> <div id="current-slide"></div>
<div id="wrap-next-slide" class="slides"><span>UPCOMING:</span></div> <div id="next-slide"><span class="label">UPCOMING:</span></div>
<div id="speaker-controls">
<div class="time"> <div class="speaker-controls-time">
<h4 class="label">Time</h4>
<div class="clock"> <div class="clock">
<h2>Time</h2> <span class="clock-value">0:00 AM</span>
<span id="clock">0:00:00 AM</span>
</div> </div>
<div class="elapsed"> <div class="timer">
<h2>Elapsed</h2> <span class="hours-value">00</span><span class="minutes-value">:00</span><span class="seconds-value">:00</span>
<span id="hours">00</span><span id="minutes">:00</span><span id="seconds">:00</span>
</div> </div>
<div class="clear"></div>
</div> </div>
<div id="notes"></div> <div class="speaker-controls-notes hidden">
<h4 class="label">Notes</h4>
<div class="value"></div>
</div>
</div>
<script src="../../plugin/markdown/marked.js"></script> <script src="../../plugin/markdown/marked.js"></script>
<script> <script>
@ -161,6 +166,7 @@
(function() { (function() {
var notes, var notes,
notesValue,
currentState, currentState,
currentSlide, currentSlide,
nextSlide, nextSlide,
@ -202,6 +208,7 @@
connected = true; connected = true;
setupIframes( data ); setupIframes( data );
setupNotes();
setupTimer(); setupTimer();
} }
@ -217,14 +224,18 @@
currentState = JSON.stringify( data.state ); currentState = JSON.stringify( data.state );
// No need for updating the notes in case of fragment changes // No need for updating the notes in case of fragment changes
if ( data.notes !== undefined) { if ( data.notes ) {
notes.classList.remove( 'hidden' );
if( data.markdown ) { if( data.markdown ) {
notes.innerHTML = marked( data.notes ); notesValue.innerHTML = marked( data.notes );
} }
else { else {
notes.innerHTML = data.notes; notesValue.innerHTML = data.notes;
} }
} }
else {
notes.classList.add( 'hidden' );
}
// Update the note slides // Update the note slides
currentSlide.contentWindow.postMessage( JSON.stringify({ method: 'setState', args: [ data.state ] }), '*' ); currentSlide.contentWindow.postMessage( JSON.stringify({ method: 'setState', args: [ data.state ] }), '*' );
@ -238,24 +249,30 @@
*/ */
function setupIframes( data ) { function setupIframes( data ) {
notes = document.getElementById( 'notes' );
var url = data.url + '?receiver&progress=false&overview=false&history=false'; var url = data.url + '?receiver&progress=false&overview=false&history=false';
var hash = '#/' + data.state.indexh + '/' + data.state.indexv; var hash = '#/' + data.state.indexh + '/' + data.state.indexv;
currentSlide = document.createElement( 'iframe' ); currentSlide = document.createElement( 'iframe' );
currentSlide.setAttribute( 'id', 'current-slide' );
currentSlide.setAttribute( 'width', 1280 ); currentSlide.setAttribute( 'width', 1280 );
currentSlide.setAttribute( 'height', 1024 ); currentSlide.setAttribute( 'height', 1024 );
currentSlide.setAttribute( 'src', url + '&postMessageEvents=true' + hash ); currentSlide.setAttribute( 'src', url + '&postMessageEvents=true' + hash );
document.querySelector( '#wrap-current-slide' ).appendChild( currentSlide ); document.querySelector( '#current-slide' ).appendChild( currentSlide );
nextSlide = document.createElement( 'iframe' ); nextSlide = document.createElement( 'iframe' );
nextSlide.setAttribute( 'id', 'next-slide' );
nextSlide.setAttribute( 'width', 640 ); nextSlide.setAttribute( 'width', 640 );
nextSlide.setAttribute( 'height', 512 ); nextSlide.setAttribute( 'height', 512 );
nextSlide.setAttribute( 'src', url + '&controls=false' + hash ); nextSlide.setAttribute( 'src', url + '&controls=false' + hash );
document.querySelector( '#wrap-next-slide' ).appendChild( nextSlide ); document.querySelector( '#next-slide' ).appendChild( nextSlide );
}
/**
* Setup the notes UI.
*/
function setupNotes() {
notes = document.querySelector( '.speaker-controls-notes' );
notesValue = document.querySelector( '.speaker-controls-notes .value' );
} }
@ -266,15 +283,13 @@
function setupTimer() { function setupTimer() {
var start = new Date(), var start = new Date(),
timeEl = document.querySelector( '.time' ), timeEl = document.querySelector( '.speaker-controls-time' ),
clockEl = document.getElementById( 'clock' ), clockEl = timeEl.querySelector( '.clock-value' ),
hoursEl = document.getElementById( 'hours' ), hoursEl = timeEl.querySelector( '.hours-value' ),
minutesEl = document.getElementById( 'minutes' ), minutesEl = timeEl.querySelector( '.minutes-value' ),
secondsEl = document.getElementById( 'seconds' ); secondsEl = timeEl.querySelector( '.seconds-value' );
setInterval( function() { function _updateTimer() {
timeEl.style.opacity = 1;
var diff, hours, minutes, seconds, var diff, hours, minutes, seconds,
now = new Date(); now = new Date();
@ -284,14 +299,20 @@
minutes = Math.floor( ( diff / ( 1000 * 60 ) ) % 60 ); minutes = Math.floor( ( diff / ( 1000 * 60 ) ) % 60 );
seconds = Math.floor( ( diff / 1000 ) % 60 ); seconds = Math.floor( ( diff / 1000 ) % 60 );
clockEl.innerHTML = now.toLocaleTimeString(); clockEl.innerHTML = now.toLocaleTimeString( 'en-US', { hour12: true, hour: '2-digit', minute:'2-digit' } );
hoursEl.innerHTML = zeroPadInteger( hours ); hoursEl.innerHTML = zeroPadInteger( hours );
hoursEl.className = hours > 0 ? '' : 'mute'; hoursEl.className = hours > 0 ? '' : 'mute';
minutesEl.innerHTML = ':' + zeroPadInteger( minutes ); minutesEl.innerHTML = ':' + zeroPadInteger( minutes );
minutesEl.className = minutes > 0 ? '' : 'mute'; minutesEl.className = minutes > 0 ? '' : 'mute';
secondsEl.innerHTML = ':' + zeroPadInteger( seconds ); secondsEl.innerHTML = ':' + zeroPadInteger( seconds );
}, 1000 ); }
// Update once directly
_updateTimer();
// Then update every second
setInterval( _updateTimer, 1000 );
} }