Code Monkey home page Code Monkey logo

koglossarylinks's Introduction

KOglossaryLinks jQuery plugin

This is a jQuery plugin that shows glossary-style tooltips when hovered (or tapped on touchscreen devices). You provide a json feed and add data attributes to any HTML element and it will do the rest.

The plugin handles different screen dimensions with ease; it repositions the tooltip horizintally so that it can keep it in view. It does not reposition the tooltip vertically if there is not enough vertical height.

A slightly older version of this plugin was used on http://www.goenergyshopping.co.uk/en-gb/why-shop

Getting the Library

Direct downloads

Bower

bower install KOglossaryLinks

NPM

npm install koglossarylinks --save

Usage

Include KOglossaryLinks in your JavaScript bundle or add it to your HTML page like this:

<script type='application/javascript' src='/path/to/KOglossaryLinks.js'></script>

Example HTML usage:

<a href="" data-koglossarylink='Glossary term'>Glossary term</a>

Example JS usage:

	$(document.body).KOglossaryLinks({
		sourceURL    : 'glossary.json',
		tooltipwidth : 260,
		debug        : true
	});

Default options:

sourceURL    : ''               [string]  - URL of the JSON file with format {"term": "", "description": ""}
tooltipwidth : 260,             [integer] - Width of tooltip. This should correspond to the CSS you are using for the tooltip
debug        : false            [boolean] - Show debug messages in the console

JSON feed

The json feed should look like this:

[
	{
		"term": "Glossary Term 1",
		"description": "Lorem ipsum dolor sit amet, consectetur adipisicing elit."
	},
	{
		"term": "Glossary Term 2",
		"description": "Non nemo totam a voluptatibus modi sunt earum."
	}
]

CSS Styling

As well as the bundled CSS there is a .scss file included which can be edited. If you use Sass, include it in your build and modify the styles.

Demo

View a demo at http://codepen.io/mrmartineau/pen/KweMqr

koglossarylinks's People

Contributors

mrmartineau avatar

Stargazers

Pietro Malerba avatar

Watchers

Pietro Malerba avatar James Cloos avatar  avatar

Forkers

ncou

koglossarylinks's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.