Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/mgalgs/jquery-yallipsis

Yet Another Ellipsis Plugin for jQuery
https://github.com/mgalgs/jquery-yallipsis

Last synced: 5 days ago
JSON representation

Yet Another Ellipsis Plugin for jQuery

Awesome Lists containing this project

README

        

What is Yallipsis?
==================
Yallipsis is **Yet Another Ellipsis Plugin** for jQuery. It is tiny and very simple to use. It turns text like this:
> Hi I love stuff and stuff and I really love to eat pizza and stuff yes.

into this:
> Hi I love stuff and...

or this:
> ...and stuff yes.

or this:
> Hi I lov...stuff yes.

or this:
> ...I really love...

Usage
=====
First, include `jquery.yallipsis.js` in your html document:

Basic Usage
-----------
$(function() {
$(".short").yallipsis();
});

Options
-------


maxChars

The maximum number of characters to allow before we ellipsify. Default: 50

replaceText

Text to insert to indicate ellipsification. Default: '...'

where

Where to truncate. Possible values: 'front', 'back', 'sides', 'middle'. Default: 'back'

##### Examples #####
If we had a div in our document like so:


This is my really long sentence.

Then this:
$(function() {
$(".short").yallipsis({maxChars:7, replaceText:'***'});
});

would result in this:


This is***

and this:
$(function() {
$(".short").yallipsis({maxChars:10, where: 'sides'});
});

would result in this:


...really long...

Tips
----
If the `title` attribute of the element being ellipsified is empty,
the original text will get put there. So, you can combine yallipsis
with [tipTip] [1] (or any other jQuery quicktip plugin):
$(function() {
$(".short").yallipsis({maxChars:25}).tipTip({maxWidth:'auto'});
});

[1]: http://code.drewwilson.com/entry/tiptip-jquery-plugin "tipTip jQuery Plugin"