ponysmith.github.io

brevityDocumentation

brevity.js is a javascript plugin for wrapping registered abbreviations in abbr tags. This automates the repetitive task of supplying abbr tags for accessibility. Abbreviations are registered on initialization and are completely customizable.

Usage

Once you have included the javascript in your page, you can initialize the plugin by calling the brevity() function. The function takes two arguments:

  1. (required) - An array of abbreviations you want brevity to abbreviate
  2. (optional) - An options object
Since brevity can only modify abbreviations that exist in the DOM, it is best to call the brevity() function once the content is ready either via window.onLoad or $(document).ready (if you're using jQuery).

The abbreviation array

The abbreviation array defines all abbreviations you want registered with the plugin. Each item in the array is an object that should contain the following two properties:

Property Description
abbr The abbreviation string the plugin will search for and will wrap in abbr tags
title The expanded text for the abbreviation that will be used in the title attribute of the abbr tag

The options object

As a second, optional, parameter brevity takes an options object. The following options can be set:

Property Type Description
root DOM Node The root node from which to begin parsing for abbreviations. Only nodes within the root node will be converted to abbr tags