|
2965 | 2965 | // check if event target (or any of its parents is a link)
|
2966 | 2966 | var target = event.target;
|
2967 | 2967 | try {
|
| 2968 | + while ( ( target.tagName !== "A" ) && |
| 2969 | + ( target !== document.documentElement ) ) { |
| 2970 | + target = target.parentNode; |
| 2971 | + } |
2968 | 2972 |
|
2969 |
| - // For example, when clicking on the button to launch speaker console, the button |
2970 |
| - // is immediately deleted from the DOM. In this case target is a DOM element when |
2971 |
| - // we get it, but turns out to be null if you try to actually do anything with it. |
2972 |
| - var foo = target.id; // jshint ignore:line |
2973 |
| - } |
2974 |
| - catch ( err ) { |
2975 |
| - return; |
2976 |
| - } |
2977 |
| - |
2978 |
| - while ( ( target.tagName !== "A" ) && |
2979 |
| - ( target !== document.documentElement ) ) { |
2980 |
| - target = target.parentNode; |
2981 |
| - } |
| 2973 | + if ( target.tagName === "A" ) { |
| 2974 | + var href = target.getAttribute( "href" ); |
2982 | 2975 |
|
2983 |
| - if ( target.tagName === "A" ) { |
2984 |
| - var href = target.getAttribute( "href" ); |
| 2976 | + // If it's a link to presentation step, target this step |
| 2977 | + if ( href && href[ 0 ] === "#" ) { |
| 2978 | + target = document.getElementById( href.slice( 1 ) ); |
| 2979 | + } |
| 2980 | + } |
2985 | 2981 |
|
2986 |
| - // If it's a link to presentation step, target this step |
2987 |
| - if ( href && href[ 0 ] === "#" ) { |
2988 |
| - target = document.getElementById( href.slice( 1 ) ); |
| 2982 | + if ( api.goto( target ) ) { |
| 2983 | + event.stopImmediatePropagation(); |
| 2984 | + event.preventDefault(); |
2989 | 2985 | }
|
2990 | 2986 | }
|
| 2987 | + catch ( err ) { |
2991 | 2988 |
|
2992 |
| - if ( api.goto( target ) ) { |
2993 |
| - event.stopImmediatePropagation(); |
2994 |
| - event.preventDefault(); |
| 2989 | + // For example, when clicking on the button to launch speaker console, the button |
| 2990 | + // is immediately deleted from the DOM. In this case target is a DOM element when |
| 2991 | + // we get it, but turns out to be null if you try to actually do anything with it. |
| 2992 | + if ( err instanceof TypeError && |
| 2993 | + err.message === "target is null" ) { |
| 2994 | + return; |
| 2995 | + } |
| 2996 | + throw err; |
2995 | 2997 | }
|
2996 | 2998 | }, false );
|
2997 | 2999 |
|
2998 | 3000 | // Delegated handler for clicking on step elements
|
2999 | 3001 | gc.addEventListener( document, "click", function( event ) {
|
3000 | 3002 | var target = event.target;
|
3001 | 3003 | try {
|
3002 |
| - var foo = target.id; // jshint ignore:line |
3003 |
| - } |
3004 |
| - catch ( err ) { |
3005 |
| - return; |
3006 |
| - } |
3007 | 3004 |
|
3008 |
| - // Find closest step element that is not active |
3009 |
| - while ( !( target.classList.contains( "step" ) && |
3010 |
| - !target.classList.contains( "active" ) ) && |
3011 |
| - ( target !== document.documentElement ) ) { |
3012 |
| - target = target.parentNode; |
| 3005 | + // Find closest step element that is not active |
| 3006 | + while ( !( target.classList.contains( "step" ) && |
| 3007 | + !target.classList.contains( "active" ) ) && |
| 3008 | + ( target !== document.documentElement ) ) { |
| 3009 | + target = target.parentNode; |
| 3010 | + } |
| 3011 | + |
| 3012 | + if ( api.goto( target ) ) { |
| 3013 | + event.preventDefault(); |
| 3014 | + } |
3013 | 3015 | }
|
| 3016 | + catch ( err ) { |
3014 | 3017 |
|
3015 |
| - if ( api.goto( target ) ) { |
3016 |
| - event.preventDefault(); |
| 3018 | + // For example, when clicking on the button to launch speaker console, the button |
| 3019 | + // is immediately deleted from the DOM. In this case target is a DOM element when |
| 3020 | + // we get it, but turns out to be null if you try to actually do anything with it. |
| 3021 | + if ( err instanceof TypeError && |
| 3022 | + err.message === "target is null" ) { |
| 3023 | + return; |
| 3024 | + } |
| 3025 | + throw err; |
3017 | 3026 | }
|
3018 | 3027 | }, false );
|
3019 | 3028 |
|
|
0 commit comments