Skip to content

Tiny jQuery plugin to truncate text with a knockout js binding handler.

License

Notifications You must be signed in to change notification settings

GlassUmbrella/gutruncate

Repository files navigation

gutruncate

Tiny jQuery plugin to truncate text with a knockout js binding handler.

Example

Truncated

Expanded

jQuery

Usage

$(".my-long-text").gutruncate();

Advanced Usage

$(".my-long-text").gutruncate({
  minLength: 50,
  readMoreText: "click me",
});

Knockout.js

Usage

<p data-bind="gutruncate: myText"></p>

Advanced Usage

<p data-bind="gutruncate: { text: myText, options: { minLength: 10, readMoreText: 'click me' } }"></p>

Settings

  • minLength - the minimum amount of text to display. default: 150
  • tolerance - the amount of tolerance between the minLength and actual shown characters. default: 80
  • readMoreText - the text to display on the show more link. default: "more"
  • readLessText - the text to display on the show less link. default: "less"
  • ellipsisText - the text to show for the ellipsis. default: "..."
  • blockLevelMore - if true the read more link will be on a new line. default: true
  • reapply - if set to true gutruncate will be deleted and recreated. default: false
  • togglePosition - sets if the show/hide link should appear above (top) or below (bottom) the message. default: bottom

Install

bower install gutruncate --save

About

Tiny jQuery plugin to truncate text with a knockout js binding handler.

Resources

License

Stars

Watchers

Forks

Packages

No packages published