merge and tweak key shortcuts overlay #943

This commit is contained in:
Hakim El Hattab 2014-06-09 17:35:46 +02:00
parent d539c645c3
commit 9ff00a72ae
2 changed files with 192 additions and 188 deletions

View File

@ -1626,7 +1626,7 @@ body {
* LINK PREVIEW OVERLAY
*********************************************/
.reveal .preview-link-overlay {
.reveal .overlay {
position: absolute;
top: 0;
left: 0;
@ -1641,12 +1641,12 @@ body {
-moz-transition: all 0.3s ease;
transition: all 0.3s ease;
}
.reveal .preview-link-overlay.visible {
.reveal .overlay.visible {
opacity: 1;
visibility: visible;
}
.reveal .preview-link-overlay .spinner {
.reveal .overlay .spinner {
position: absolute;
display: block;
top: 50%;
@ -1665,7 +1665,7 @@ body {
transition: all 0.3s ease;
}
.reveal .preview-link-overlay header {
.reveal .overlay header {
position: absolute;
left: 0;
top: 0;
@ -1674,7 +1674,7 @@ body {
z-index: 2;
border-bottom: 1px solid #222;
}
.reveal .preview-link-overlay header a {
.reveal .overlay header a {
display: inline-block;
width: 40px;
height: 40px;
@ -1684,10 +1684,10 @@ body {
box-sizing: border-box;
}
.reveal .preview-link-overlay header a:hover {
.reveal .overlay header a:hover {
opacity: 1;
}
.reveal .preview-link-overlay header a .icon {
.reveal .overlay header a .icon {
display: inline-block;
width: 20px;
height: 20px;
@ -1696,14 +1696,14 @@ body {
background-size: 100%;
background-repeat: no-repeat;
}
.reveal .preview-link-overlay header a.close .icon {
.reveal .overlay header a.close .icon {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAABkklEQVRYR8WX4VHDMAxG6wnoJrABZQPYBCaBTWAD2g1gE5gg6OOsXuxIlr40d81dfrSJ9V4c2VLK7spHuTJ/5wpM07QXuXc5X0opX2tEJcadjHuV80li/FgxTIEK/5QBCICBD6xEhSMGHgQPgBgLiYVAB1dpSqKDawxTohFw4JSEA3clzgIBPCURwE2JucBR7rhPJJv5OpJwDX+SfDjgx1wACQeJG1aChP9K/IMmdZ8DtESV1WyP3Bt4MwM6sj4NMxMYiqUWHQu4KYA/SYkIjOsm3BXYWMKFDwU2khjCQ4ELJUJ4SmClRArOCmSXGuKma0fYD5CbzHxFpCSGAhfAVSSUGDUk2BWZaff2g6GE15BsBQ9nwmpIGDiyHQddwNTMKkbZaf9fajXQca1EX44puJZUsnY0ObGmITE3GVLCbEhQUjGVt146j6oasWN+49Vph2w1pZ5EansNZqKBm1txbU57iRRcZ86RWMDdWtBJUHBHwoQPi1GV+JCbntmvok7iTX4/Up9mgyTc/FJYDTcndgH/AA5A/CHsyEkVAAAAAElFTkSuQmCC);
}
.reveal .preview-link-overlay header a.external .icon {
.reveal .overlay header a.external .icon {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAcElEQVRYR+2WSQoAIQwEzf8f7XiOMkUQxUPlGkM3hVmiQfQR9GYnH1SsAQlI4DiBqkCMoNb9y2e90IAEJPAcgdznU9+engMaeJ7Azh5Y1U67gAho4DqBqmB1buAf0MB1AlVBek83ZPkmJMGc1wAR+AAqod/B97TRpQAAAABJRU5ErkJggg==);
}
.reveal .preview-link-overlay .viewport {
.reveal .overlay .viewport {
position: absolute;
top: 40px;
right: 0;
@ -1711,7 +1711,7 @@ body {
left: 0;
}
.reveal .preview-link-overlay .viewport iframe {
.reveal .overlay.overlay-preview .viewport iframe {
width: 100%;
height: 100%;
max-width: 100%;
@ -1726,12 +1726,12 @@ body {
transition: all 0.3s ease;
}
.reveal .preview-link-overlay.loaded .viewport iframe {
.reveal .overlay.overlay-preview.loaded .viewport iframe {
opacity: 1;
visibility: visible;
}
.reveal .preview-link-overlay.loaded .spinner {
.reveal .overlay.overlay-preview.loaded .spinner {
opacity: 0;
visibility: hidden;
@ -1742,36 +1742,35 @@ body {
}
.reveal .preview-link-overlay .viewport .shortcuts {
-webkit-column-count: 2;
-moz-column-count: 2;
column-count: 2;
font-size: 20px;
.reveal .overlay.overlay-help .viewport .viewport-inner {
width: 600px;
height: 100%;
margin-left: 35%;
margin-top: 20px;
margin: 0 auto;
text-align: center;
letter-spacing: normal;
}
.reveal .preview-link-overlay .viewport .shortcuts table {
.reveal .overlay.overlay-help .viewport .viewport-inner .title {
font-size: 20px;
margin-top: 60px;
}
.reveal .overlay.overlay-help .viewport .viewport-inner table {
border: 1px solid #fff;
border-collapse: collapse;
font-size: 14px;
}
.reveal .preview-link-overlay .viewport .shortcuts table th{
border: 1px solid #fff;
.reveal .overlay.overlay-help .viewport .viewport-inner table th {
height: 30px;
width: 200px;
padding: 10px;
vertical-align: middle;
}
.reveal .preview-link-overlay .viewport .shortcuts table tr td{
.reveal .overlay.overlay-help .viewport .viewport-inner table th,
.reveal .overlay.overlay-help .viewport .viewport-inner table td {
width: 200px;
padding: 10px;
border: 1px solid #fff;
height: 30px;
vertical-align: middle;
padding: 5px;
}

View File

@ -199,13 +199,13 @@
},
// Holds information about the keyboard shortcuts
keyboard_shortcuts = {
'p': 'Previous slide',
'n': 'Next slide',
'h': 'Navigate left',
'l': 'Navigate right',
'k': 'Navigate up',
'j': 'Navigate down',
keyboardShortcuts = {
'P': 'Previous slide',
'N': 'Next slide',
'H': 'Navigate left',
'L': 'Navigate right',
'K': 'Navigate up',
'J': 'Navigate down',
'Home': 'First slide',
'End': 'Last slide',
'b': 'Pause',
@ -1233,15 +1233,16 @@
/**
* Opens a preview window for the target URL.
*/
function openPreview( url ) {
function showPreview( url ) {
closePreview();
closeOverlay();
dom.preview = document.createElement( 'div' );
dom.preview.classList.add( 'preview-link-overlay' );
dom.wrapper.appendChild( dom.preview );
dom.overlay = document.createElement( 'div' );
dom.overlay.classList.add( 'overlay' );
dom.overlay.classList.add( 'overlay-preview' );
dom.wrapper.appendChild( dom.overlay );
dom.preview.innerHTML = [
dom.overlay.innerHTML = [
'<header>',
'<a class="close" href="#"><span class="icon"></span></a>',
'<a class="external" href="'+ url +'" target="_blank"><span class="icon"></span></a>',
@ -1252,76 +1253,79 @@
'</div>'
].join('');
dom.preview.querySelector( 'iframe' ).addEventListener( 'load', function( event ) {
dom.preview.classList.add( 'loaded' );
dom.overlay.querySelector( 'iframe' ).addEventListener( 'load', function( event ) {
dom.overlay.classList.add( 'loaded' );
}, false );
dom.preview.querySelector( '.close' ).addEventListener( 'click', function( event ) {
closePreview();
dom.overlay.querySelector( '.close' ).addEventListener( 'click', function( event ) {
closeOverlay();
event.preventDefault();
}, false );
dom.preview.querySelector( '.external' ).addEventListener( 'click', function( event ) {
closePreview();
dom.overlay.querySelector( '.external' ).addEventListener( 'click', function( event ) {
closeOverlay();
}, false );
setTimeout( function() {
dom.preview.classList.add( 'visible' );
dom.overlay.classList.add( 'visible' );
}, 1 );
}
/**
* Closes the iframe preview window.
* Opens a overlay window with help material.
*/
function closePreview() {
function showHelp() {
if( dom.preview ) {
dom.preview.setAttribute( 'src', '' );
dom.preview.parentNode.removeChild( dom.preview );
dom.preview = null;
}
closeOverlay();
}
dom.overlay = document.createElement( 'div' );
dom.overlay.classList.add( 'overlay' );
dom.overlay.classList.add( 'overlay-help' );
dom.wrapper.appendChild( dom.overlay );
/**
* Opens a overlay window for the keyboard shortcuts.
*/
function openShortcutsOverlay() {
var html = '<p class="title">Keyboard Shortcuts</p><br/>';
closePreview();
dom.preview = document.createElement( 'div' );
dom.preview.classList.add( 'preview-link-overlay' );
dom.wrapper.appendChild( dom.preview );
var html = '<h5>Keyboard Shortcuts</h5><br/>';
html += '<table><th>KEY</th><th>ACTION</th>';
for( var key in keyboard_shortcuts ) {
html += '<tr> <td>' + key + '</td> <td>' + keyboard_shortcuts[key] + '</td> </tr>'
for( var key in keyboardShortcuts ) {
html += '<tr><td>' + key + '</td><td>' + keyboardShortcuts[ key ] + '</td></tr>';
}
html += '</table>';
dom.preview.innerHTML = [
dom.overlay.innerHTML = [
'<header>',
'<a class="close" href="#"><span class="icon"></span></a>',
'</header>',
'<div class="viewport">',
'<div class="shortcuts">'+html+'</div>',
'<div class="viewport-inner">'+ html +'</div>',
'</div>'
].join('');
dom.preview.querySelector( '.close' ).addEventListener( 'click', function( event ) {
closePreview();
dom.overlay.querySelector( '.close' ).addEventListener( 'click', function( event ) {
closeOverlay();
event.preventDefault();
}, false );
setTimeout( function() {
dom.preview.classList.add( 'visible' );
dom.overlay.classList.add( 'visible' );
}, 1 );
}
/**
* Closes any currently open overlay.
*/
function closeOverlay() {
if( dom.overlay ) {
dom.overlay.setAttribute( 'src', '' );
dom.overlay.parentNode.removeChild( dom.overlay );
dom.overlay = null;
}
}
/**
* Applies JavaScript-controlled layout rules to the
* presentation.
@ -3289,12 +3293,13 @@
/**
* Handler for the document level 'keypress' event.
*/
function onDocumentKeyPress( event ) {
// Check if the pressed key is question mark
if( event.shiftKey && event.charCode == 63 ) {
openShortcutsOverlay();
if( event.shiftKey && event.charCode === 63 ) {
showHelp();
}
}
/**
@ -3402,8 +3407,8 @@
}
// ESC or O key
else if ( ( event.keyCode === 27 || event.keyCode === 79 ) && features.transforms3d ) {
if( dom.preview ) {
closePreview();
if( dom.overlay ) {
closeOverlay();
}
else {
toggleOverview();
@ -3701,7 +3706,7 @@
var url = event.target.getAttribute( 'href' );
if( url ) {
openPreview( url );
showPreview( url );
event.preventDefault();
}