Fix JSHint-reported issues

interceptAnchorClicks only if window and document are available in the
current environment.