Skip to content

Commit 6db3f7c

Browse files
giflwhenrikingo
authored andcommitted
Add support for "." to enter/exit blackout screen (impress#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
1 parent 6776a0d commit 6db3f7c

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

js/impress.js

+16-5
Original file line numberDiff line numberDiff line change
@@ -1419,7 +1419,7 @@
14191419
/**
14201420
* Blackout plugin
14211421
*
1422-
* Press Ctrl+b to hide all slides, and Ctrl+b again to show them.
1422+
* Press b or . to hide all slides, and b or . again to show them.
14231423
* Also navigating to a different slide will show them again (impress:stepleave).
14241424
*
14251425
* Copyright 2014 @Strikeskids
@@ -1432,6 +1432,9 @@
14321432

14331433
var canvas = null;
14341434
var blackedOut = false;
1435+
var util = null;
1436+
var root = null;
1437+
var api = null;
14351438

14361439
// While waiting for a shared library of utilities, copying these 2 from main impress.js
14371440
var css = function( el, props ) {
@@ -1480,6 +1483,7 @@
14801483
display: "block"
14811484
} );
14821485
blackedOut = false;
1486+
util.triggerEvent( root, "impress:autoplay:play", {} );
14831487
}
14841488
};
14851489

@@ -1491,18 +1495,23 @@
14911495
display: ( blackedOut = !blackedOut ) ? "none" : "block"
14921496
} );
14931497
blackedOut = true;
1498+
util.triggerEvent( root, "impress:autoplay:pause", {} );
14941499
}
14951500
};
14961501

14971502
// Wait for impress.js to be initialized
14981503
document.addEventListener( "impress:init", function( event ) {
1499-
var api = event.detail.api;
1500-
var root = event.target;
1504+
api = event.detail.api;
1505+
util = api.lib.util;
1506+
root = event.target;
15011507
canvas = root.firstElementChild;
15021508
var gc = api.lib.gc;
1509+
var util = api.lib.util;
15031510

15041511
gc.addEventListener( document, "keydown", function( event ) {
1505-
if ( event.keyCode === 66 ) {
1512+
1513+
// Accept b or . -> . is sent by presentation remote controllers
1514+
if ( event.keyCode === 66 || event.keyCode === 190 ) {
15061515
event.preventDefault();
15071516
if ( !blackedOut ) {
15081517
blackout();
@@ -1513,7 +1522,9 @@
15131522
}, false );
15141523

15151524
gc.addEventListener( document, "keyup", function( event ) {
1516-
if ( event.keyCode === 66 ) {
1525+
1526+
// Accept b or . -> . is sent by presentation remote controllers
1527+
if ( event.keyCode === 66 || event.keyCode === 190 ) {
15171528
event.preventDefault();
15181529
}
15191530
}, false );

src/plugins/blackout/blackout.js

+16-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Blackout plugin
33
*
4-
* Press Ctrl+b to hide all slides, and Ctrl+b again to show them.
4+
* Press b or . to hide all slides, and b or . again to show them.
55
* Also navigating to a different slide will show them again (impress:stepleave).
66
*
77
* Copyright 2014 @Strikeskids
@@ -14,6 +14,9 @@
1414

1515
var canvas = null;
1616
var blackedOut = false;
17+
var util = null;
18+
var root = null;
19+
var api = null;
1720

1821
// While waiting for a shared library of utilities, copying these 2 from main impress.js
1922
var css = function( el, props ) {
@@ -62,6 +65,7 @@
6265
display: "block"
6366
} );
6467
blackedOut = false;
68+
util.triggerEvent( root, "impress:autoplay:play", {} );
6569
}
6670
};
6771

@@ -73,18 +77,23 @@
7377
display: ( blackedOut = !blackedOut ) ? "none" : "block"
7478
} );
7579
blackedOut = true;
80+
util.triggerEvent( root, "impress:autoplay:pause", {} );
7681
}
7782
};
7883

7984
// Wait for impress.js to be initialized
8085
document.addEventListener( "impress:init", function( event ) {
81-
var api = event.detail.api;
82-
var root = event.target;
86+
api = event.detail.api;
87+
util = api.lib.util;
88+
root = event.target;
8389
canvas = root.firstElementChild;
8490
var gc = api.lib.gc;
91+
var util = api.lib.util;
8592

8693
gc.addEventListener( document, "keydown", function( event ) {
87-
if ( event.keyCode === 66 ) {
94+
95+
// Accept b or . -> . is sent by presentation remote controllers
96+
if ( event.keyCode === 66 || event.keyCode === 190 ) {
8897
event.preventDefault();
8998
if ( !blackedOut ) {
9099
blackout();
@@ -95,7 +104,9 @@
95104
}, false );
96105

97106
gc.addEventListener( document, "keyup", function( event ) {
98-
if ( event.keyCode === 66 ) {
107+
108+
// Accept b or . -> . is sent by presentation remote controllers
109+
if ( event.keyCode === 66 || event.keyCode === 190 ) {
99110
event.preventDefault();
100111
}
101112
}, false );

0 commit comments

Comments
 (0)