Package Exports
- ellipsis-verily
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ellipsis-verily) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Ellipsis Verily 2
JQuery plugin for text truncation supporting inner tags. Also supports Chinese text. See demo.
Usage
- Add JQuery script to page
- Add Ellipsis Verily script to page
- Add CSS styles to page:
.display-none {
display: none;
}
.display-inline {
display: inline;
}- Call plugin on the to be truncated element, examples:
$('.to-be-truncated').EllipsisVerily();
$('.to-be-truncated').EllipsisVerily({ min: 200, tags: ['span', 'p'] });
$('.to-be-truncated').EllipsisVerily({ min: 50, handler: '#toggle-truncated'});Warning
This has been changed from the previous versions 1.x.x, however it contains some significant bug fixes, including:
- Fix truncation of attributed tags
- Added Chinese text truncation support
- Fixed dumping of tags separated by truncation
Changelog from v1.x.x
The following API options were removed or refactored:
max- This was renamed, now calledminsincemaxname was semantically incorrect.normalTagsandattributedTags- These were removed and replaced with one listtags.ellipsis-handler- This default classname was renamed to.js-ellipsis-handler.open- This default classname was renamed to.is-open
API
min (int): Minimum onscreen characters. The point of truncation is dependent on the first occurence of the delimiter; default is 300tags (array): List of tags to support; other tags are strippedmoreText (string): The text to show on the handler when text is truncated; default is Read morelessText (string): The text to show on the handler when all text is visible; default is Show lessparent (string): The element selector (class/id) of the parent where the handler can be found. This is useful if multiple containers on the same page are to be truncated which all have the same handler class name. default is null; (Do not set this if the text to be truncated and the handler do not have the same parent container)handler (string): The element selector (class/id) that toggles between the truncation; default is .js-ellipsis-handlerselfClosingTags (array): List of self closing tagsdelimiters (object): An object of 3 delimiters:
tag (string): An internal delimiter used to replace the space between tag attributes (don't set this if you don't know what it does)break (string): After the firstmincharacters, the first occurrence of this creates the truncation point; default is(space)nonEnglishBreak (string): Additional break delimiter for non-English texts; e.g. Chinese texts do not contain English character spaces, so we can break at。
Other API
There is infact no real need to tamper with these, but they are here if needed.visible (string): The element selector (class/id) that is visible after truncation; default is .visible-texttruncated (string): The element selector (class/id) that is truncated; default is .truncated-textellipsis (string): The element selector (class/id) that holds the ellipsis symbol; default is .ellipsis-texthiddenClass (string): The class name (do not include the .) whose style is set to display: none;; default is display-noneshowClass (string): The class name (do not include the .) whose style is set to display: inline-inline;; default is display-inline
Troubleshoot
- Make sure you added the
hiddenClassandshowClassstyles to your page. If you change these two default class names in the plugin options, make sure the change is reflected in the CSS. - As
hiddenClassandshowClasswill be applied as classes, they should not have the.in the name.handler,visible,truncatedandellipsiscould either be a class or id selector and should include either.or#respectively.