abbr-touch
Advanced tools
Comparing version 2.0.1 to 2.1.0
@@ -12,4 +12,4 @@ /** | ||
* Generates a touchtap event handler that calls the tap handler provided. | ||
* @param {Function} handler The tap handler to call. | ||
* @returns {Function} | ||
* @param {function} handler The tap handler to call. | ||
* @returns {function} | ||
*/ | ||
@@ -33,6 +33,9 @@ function generateTouchtapHandler(handler) { | ||
* elements. | ||
* @param {Function} customTapHandler (Optional) A custom touchtap handler to | ||
* @param {function} customTapHandler (Optional) A custom touchtap handler to | ||
* be used when abbr[title] elements are touched. | ||
* @param {function} listenToClick (Optional) Set to true to listen to the | ||
* click instead of the touchtap event, enabling the feature for non-touch | ||
* devices. | ||
*/ | ||
function init(elementScope, customTapHandler) { | ||
function init(elementScope, customTapHandler, listenToClick) { | ||
if (!elementScope) { | ||
@@ -47,3 +50,3 @@ elementScope = document; | ||
for (var i = 0; i < elements.length; i++) { | ||
elements[i].addEventListener('touchtap', touchtapHandler); | ||
elements[i].addEventListener(listenToClick ? 'click' : 'touchtap', touchtapHandler); | ||
} | ||
@@ -50,0 +53,0 @@ } |
{ | ||
"name": "abbr-touch", | ||
"main": "abbr-touch.js", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"homepage": "https://github.com/Tyriar/abbr-touch", | ||
@@ -9,3 +9,3 @@ "authors": [ | ||
], | ||
"description": "Library to make <abbr> element title attributes touch accessible.", | ||
"description": "Makes <abbr> element title attributes touch accessible", | ||
"keywords": [ | ||
@@ -12,0 +12,0 @@ "touch", |
{ | ||
"name": "abbr-touch", | ||
"version": "2.0.1", | ||
"description": "Library to make <abbr> element title attributes touch accessible.", | ||
"version": "2.1.0", | ||
"description": "Makes <abbr> element title attributes touch accessible", | ||
"main": "abbr-touch.js", | ||
@@ -6,0 +6,0 @@ "scripts": { |
@@ -6,3 +6,3 @@ # abbr-touch [![NPM version](http://img.shields.io/npm/v/abbr-touch.svg?style=flat)](https://www.npmjs.org/package/abbr-touch) | ||
A library to make <abbr> element title attributes touch accessible. | ||
abbr-touch is a tiny JavaScript library that makes the title attibute of `<abbr>` element touch accessible. It does so by utilising [touchtap-event][3] to only expose the functionality to touch-enabled devices, a custom touch handler can then be used to display `<abbr>`'s content any way you wish. | ||
@@ -30,3 +30,3 @@ [![Example usage: touching an <abbr> tag brings up a description](example.png)][1] | ||
<!-- NPM --> | ||
<script src="bower_components/abbr-touch/abbr-touch.js"></script> | ||
<script src="node_modules/abbr-touch/abbr-touch.js"></script> | ||
``` | ||
@@ -37,4 +37,2 @@ | ||
See [demo.html][2] for a deeper example. | ||
```javascript | ||
@@ -58,3 +56,5 @@ // default handler on document (alert) | ||
A deeper example of usage can be found in [demo.html][2]. A live demo can be viewed on [Growing with the Web][4]. | ||
## See also | ||
@@ -70,1 +70,2 @@ | ||
[3]: https://github.com/Tyriar/touchtap-event | ||
[4]: http://www.growingwiththeweb.com/projects/abbr-touch/ |
Sorry, the diff of this file is not supported yet
52254
101
67