Skip to content

Commit

Permalink
Footnotes: Fully disabled plugin in wbdisable mode.
Browse files Browse the repository at this point in the history
Previously, when basic HTML (wbdisable) mode was engaged, the footnotes plugin's init event wouldn't run, but its click events would remain in effect, resulting in the plugin being in a partially-functional state.

This commit fully disables the plugin in that scenario by moving its click events into init.
  • Loading branch information
EricDunsworth committed May 11, 2017
1 parent c9ddc36 commit 9fa926e
Showing 1 changed file with 41 additions and 41 deletions.
82 changes: 41 additions & 41 deletions src/plugins/footnotes/footnotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,47 @@ var componentName = "wb-fnote",
// Remove "first/premier/etc"-style text from certain footnote return links (via the child spans that hold those bits of text)
$elm.find( "dd p.fn-rtn a span span" ).remove();

// Listen for footnote reference links that get clicked
$document.on( "click vclick", "main :not(" + selector + ") sup a.fn-lnk", function( event ) {
var eventTarget = event.target,
which = event.which,
refId, $refLinkDest;

// Ignore middle/right mouse button
if ( !which || which === 1 ) {
refId = "#" + wb.jqEscape( eventTarget.getAttribute( "href" ).substring( 1 ) );
$refLinkDest = $document.find( refId );

$refLinkDest.find( "p.fn-rtn a" )
.attr( "href", "#" + eventTarget.parentNode.id );

// Assign focus to $refLinkDest
$refLinkDest.trigger( setFocusEvent );
return false;
}
} );

// Listen for footnote return links that get clicked
$document.on( "click vclick", selector + " dd p.fn-rtn a", function( event ) {
var which = event.which,
ref,
refId;

// Ignore middle/right mouse button
if ( !which || which === 1 ) {
ref = event.target.getAttribute( "href" );

// Focus on associated referrer link (if the return link points to an ID)
if ( ref.charAt( 0 ) === "#" ) {
refId = "#" + wb.jqEscape( ref.substring( 1 ) );

// Assign focus to the link
$document.find( refId + " a" ).trigger( setFocusEvent );
return false;
}
}
} );

// Identify that initialization has completed
wb.ready( $elm, componentName );
}
Expand All @@ -58,47 +99,6 @@ var componentName = "wb-fnote",
// Bind the init event of the plugin
$document.on( "timerpoke.wb " + initEvent, selector, init );

// Listen for footnote reference links that get clicked
$document.on( "click vclick", "main :not(" + selector + ") sup a.fn-lnk", function( event ) {
var eventTarget = event.target,
which = event.which,
refId, $refLinkDest;

// Ignore middle/right mouse button
if ( !which || which === 1 ) {
refId = "#" + wb.jqEscape( eventTarget.getAttribute( "href" ).substring( 1 ) );
$refLinkDest = $document.find( refId );

$refLinkDest.find( "p.fn-rtn a" )
.attr( "href", "#" + eventTarget.parentNode.id );

// Assign focus to $refLinkDest
$refLinkDest.trigger( setFocusEvent );
return false;
}
} );

// Listen for footnote return links that get clicked
$document.on( "click vclick", selector + " dd p.fn-rtn a", function( event ) {
var which = event.which,
ref,
refId;

// Ignore middle/right mouse button
if ( !which || which === 1 ) {
ref = event.target.getAttribute( "href" );

// Focus on associated referrer link (if the return link points to an ID)
if ( ref.charAt( 0 ) === "#" ) {
refId = "#" + wb.jqEscape( ref.substring( 1 ) );

// Assign focus to the link
$document.find( refId + " a" ).trigger( setFocusEvent );
return false;
}
}
} );

// Add the timer poke to initialize the plugin
wb.add( selector );

Expand Down

0 comments on commit 9fa926e

Please sign in to comment.