1.0.5 • Published 7 years ago

colby-tooltips v1.0.5

Weekly downloads
2
License
ISC
Repository
github
Last release
7 years ago

Tooltips

A simple ES6 class for handling hover tooltips.

Usage

In the HTML:

<div data-tooltip="The content of the tooltip box">The hover text.</div>

In the JavaScript:

import Tooltips from 'colby-tooltips';

...

window.addEventListener('load', () => new Tooltips(settings));

The settings object

PropertyTypeDescriptionDefault
tooltipClassstringThe CSS namespace'tooltip'
tooltipWidthintThe width (in pixels) of each tooltip box.200

Recommended WordPress shortcode

[tooltip text="The hover text."]The content of the tooltip box[/tooltip]
add_shortcode( 'tooltip', function( $atts, $content ) {
		if ( ! isset( $atts['text'] ) || empty( $content ) ) {
			return '';
		}

		ob_start(); ?>
		<div data-tooltip="<?php echo esc_attr( $content ); ?>">
			<?php echo wp_kses_post( $atts['text'] ); ?>
		</div>
		<?php
		return ob_get_clean();
} );
1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago