From 6db3f7c87727edd66293d5d42624ecff68e174c5 Mon Sep 17 00:00:00 2001 From: Guilherme I F L Weizenmann Date: Wed, 6 Feb 2019 08:25:11 -0300 Subject: [PATCH] Add support for "." to enter/exit blackout screen (#716) * Add support for "." to enter/exit blackout screen - This is the default on Power Point - THis add support for remote controller presentation blackout key * Rename autoplay event call from resume to play --- js/impress.js | 21 ++++++++++++++++----- src/plugins/blackout/blackout.js | 21 ++++++++++++++++----- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/js/impress.js b/js/impress.js index ea023d9..59eda87 100644 --- a/js/impress.js +++ b/js/impress.js @@ -1419,7 +1419,7 @@ /** * Blackout plugin * - * Press Ctrl+b to hide all slides, and Ctrl+b again to show them. + * Press b or . to hide all slides, and b or . again to show them. * Also navigating to a different slide will show them again (impress:stepleave). * * Copyright 2014 @Strikeskids @@ -1432,6 +1432,9 @@ var canvas = null; var blackedOut = false; + var util = null; + var root = null; + var api = null; // While waiting for a shared library of utilities, copying these 2 from main impress.js var css = function( el, props ) { @@ -1480,6 +1483,7 @@ display: "block" } ); blackedOut = false; + util.triggerEvent( root, "impress:autoplay:play", {} ); } }; @@ -1491,18 +1495,23 @@ display: ( blackedOut = !blackedOut ) ? "none" : "block" } ); blackedOut = true; + util.triggerEvent( root, "impress:autoplay:pause", {} ); } }; // Wait for impress.js to be initialized document.addEventListener( "impress:init", function( event ) { - var api = event.detail.api; - var root = event.target; + api = event.detail.api; + util = api.lib.util; + root = event.target; canvas = root.firstElementChild; var gc = api.lib.gc; + var util = api.lib.util; gc.addEventListener( document, "keydown", function( event ) { - if ( event.keyCode === 66 ) { + + // Accept b or . -> . is sent by presentation remote controllers + if ( event.keyCode === 66 || event.keyCode === 190 ) { event.preventDefault(); if ( !blackedOut ) { blackout(); @@ -1513,7 +1522,9 @@ }, false ); gc.addEventListener( document, "keyup", function( event ) { - if ( event.keyCode === 66 ) { + + // Accept b or . -> . is sent by presentation remote controllers + if ( event.keyCode === 66 || event.keyCode === 190 ) { event.preventDefault(); } }, false ); diff --git a/src/plugins/blackout/blackout.js b/src/plugins/blackout/blackout.js index 625b7af..caa44c6 100644 --- a/src/plugins/blackout/blackout.js +++ b/src/plugins/blackout/blackout.js @@ -1,7 +1,7 @@ /** * Blackout plugin * - * Press Ctrl+b to hide all slides, and Ctrl+b again to show them. + * Press b or . to hide all slides, and b or . again to show them. * Also navigating to a different slide will show them again (impress:stepleave). * * Copyright 2014 @Strikeskids @@ -14,6 +14,9 @@ var canvas = null; var blackedOut = false; + var util = null; + var root = null; + var api = null; // While waiting for a shared library of utilities, copying these 2 from main impress.js var css = function( el, props ) { @@ -62,6 +65,7 @@ display: "block" } ); blackedOut = false; + util.triggerEvent( root, "impress:autoplay:play", {} ); } }; @@ -73,18 +77,23 @@ display: ( blackedOut = !blackedOut ) ? "none" : "block" } ); blackedOut = true; + util.triggerEvent( root, "impress:autoplay:pause", {} ); } }; // Wait for impress.js to be initialized document.addEventListener( "impress:init", function( event ) { - var api = event.detail.api; - var root = event.target; + api = event.detail.api; + util = api.lib.util; + root = event.target; canvas = root.firstElementChild; var gc = api.lib.gc; + var util = api.lib.util; gc.addEventListener( document, "keydown", function( event ) { - if ( event.keyCode === 66 ) { + + // Accept b or . -> . is sent by presentation remote controllers + if ( event.keyCode === 66 || event.keyCode === 190 ) { event.preventDefault(); if ( !blackedOut ) { blackout(); @@ -95,7 +104,9 @@ }, false ); gc.addEventListener( document, "keyup", function( event ) { - if ( event.keyCode === 66 ) { + + // Accept b or . -> . is sent by presentation remote controllers + if ( event.keyCode === 66 || event.keyCode === 190 ) { event.preventDefault(); } }, false );