Make impress-console-button actually clickable (#651)

Changed the onclick handler to trigger the impress:console:open event
and not use the impressConsole() global function any more. The latter
is considered deprecated now that impressConsole is integrated into
impress.js itself.

Also catch some errors that appear in event handlers when the target
for the click event was immediately removed from DOM.

Fixes #651
This commit is contained in:
Henrik Ingo
2018-01-01 15:05:55 +02:00
parent b86214c6e9
commit e92e02ccb4
10 changed files with 57 additions and 12 deletions

View File

@@ -124,6 +124,16 @@
// Event delegation with "bubbling"
// check if event target (or any of its parents is a link)
var target = event.target;
try {
// For example, when clicking on the button to launch speaker console, the button
// is immediately deleted from the DOM. In this case target is a DOM element when
// we get it, but turns out to be null if you try to actually do anything with it.
foo = target.id;
}
catch(err) {
return;
}
while ( ( target.tagName !== "A" ) &&
( target !== document.documentElement ) ) {
target = target.parentNode;
@@ -147,6 +157,12 @@
// Delegated handler for clicking on step elements
gc.addEventListener( document, "click", function( event ) {
var target = event.target;
try {
foo = target.id;
}
catch(err) {
return;
}
// Find closest step element that is not active
while ( !( target.classList.contains( "step" ) &&