Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ethagnawl/ellipsify

ellipsify is a jQuery plugin that truncates text and appends an ellipsis after a character/word limit.
https://github.com/ethagnawl/ellipsify

Last synced: about 10 hours ago
JSON representation

ellipsify is a jQuery plugin that truncates text and appends an ellipsis after a character/word limit.

Awesome Lists containing this project

README

        

ellipsify truncates a text node if a given character/word count is reached, appends an ellipsis (or user specified characters/HTML) and removes any subsequent siblings from the DOM.

Optional arguments:
count: number - supply a character/word count to use as the break point at which text will be truncated and an ellipsis will be appended (25 is the default count value and '...' is the default ellipsis)
ellip: string - supply custom ellipsis (i.e. ***) or hmtl (i.e. View More...)
type: 'chars' or 'words' - truncate text based on character or word count (word count is the default)
ellipsify_class: string - supply a class to override the default class, 'ellipsis' that is added to text node being truncated

Use:

default:

$('p').ellipsify();

- truncates text in the

containing the 25th word, appends an ellipsis and removes any subsequent sibling elements in the jQuery object from the DOM

count argument:

$('p').ellipsify({
count: 75
});

- truncates text in the

containing the 75th word, appends an ellipsis and removes any subsequent sibling elements in the jQuery object from the DOM

type argument:

$('p').ellipsify({
type: 'chars'
});

- truncates text in the

containing the 25th character, appends an ellipsis and removes any subsequent sibling elements in the jQuery object from the DOM

ellip argument:

$('p').ellipsify({
ellip: 'View More...'
});

- truncates text in the

containing the 25th word, appends a link to http:/yourdomain.com/article-something-99 and removes any subsequent sibling elements in the jQuery object from the DOM

ellipsify_class argument:

$('#single_p_new_class').find('p').ellipsify({
ellipsify_class:'new-ellipsis'
});

- truncates text in the

containing the 25th word, adds a user defined class (in place of the default 'ellipsis' class) to the text node being truncated and removes any subsequent sibling elements in the jQuery object from the DOM