From bede9a22e86bb1c8debb945ccdfb22265393297d Mon Sep 17 00:00:00 2001 From: Frazer Kirkman Date: Sun, 5 Feb 2017 18:42:59 +0100 Subject: added toggleHelp function this way a key can be given ability to toggleHelp on and off. Previously Reveal.showHelp could open the help screen, but no way to close it. --- js/reveal.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/js/reveal.js b/js/reveal.js index 9251dc0..290097f 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -1628,6 +1628,18 @@ } + /** + * Open or close help overlay window. + */ + function toggleHelp(){ + if( dom.overlay ) { + closeOverlay(); + } + else { + showHelp( true ); + } + } + /** * Opens an overlay window with help material. */ @@ -4113,12 +4125,7 @@ // Check if the pressed key is question mark if( event.shiftKey && event.charCode === 63 ) { - if( dom.overlay ) { - closeOverlay(); - } - else { - showHelp( true ); - } + toggleHelp(); } } @@ -4818,6 +4825,7 @@ // Shows a help overlay with keyboard shortcuts showHelp: showHelp, + toggleHelp: toggleHelp, // Forces an update in slide layout layout: layout, -- cgit v1.2.3 From 2a1303f3c1861d12ff27f401c0f5d421f7c5133b Mon Sep 17 00:00:00 2001 From: Frazer Kirkman Date: Tue, 7 Feb 2017 19:53:58 +0100 Subject: added override parameter to toggleHelp function --- js/reveal.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/js/reveal.js b/js/reveal.js index 290097f..2e4e978 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -1630,15 +1630,26 @@ /** * Open or close help overlay window. + * + * @param {Boolean} [override] Flag which overrides the + * toggle logic and forcibly sets the desired state. True means + * help is open, false means it's closed. */ - function toggleHelp(){ - if( dom.overlay ) { - closeOverlay(); + function toggleHelp( override ){ + + if( typeof override === 'boolean' ) { + override ? showHelp( true ) : closeOverlay(); } - else { - showHelp( true ); + else { + if( dom.overlay ) { + closeOverlay(); + } + else { + showHelp( true ); + } } } + /** * Opens an overlay window with help material. -- cgit v1.2.3