JS add-on to show/hide parts of a page.
Project description
Introduction
collective.js.showmore provides a JQuery plugin.
The plugin hides a set of nodes and replaces them with a “Show more…” link. When the link is clicked, the hidden nodes are made visible again.
API
The plugin defines a new showMore function. It requires a dictionary as parameter.
The dictionary parameter has one required value:
- expression
The expression is a JQuery selector used to select which children nodes will be hidden. In case no nodes are hidden, the link is not created.
The dictionary parameter can optionally define four other values:
- link_text
Defines the text of the link; default value is “Show more…”.
- link_class
Defines the class added on the link; default value is showMoreLink.
- hidden_class
Defines the class set on the hidden nodes; default value is showMoreHidden.
- grace_count
Defines how many items should not be hidden; default value is 1. In the default case, if there is only one item that would be hidden, do not hide and replace it with the link.
Example
The function can be called like the following:
jq(function() { jq('ul').showMore({expression:'li:gt(1)'}); });
li children nodes of all ul’s of the document will be hidden (except the two first li`s of each `ul). A “Show more…” link will be added at the end of each ul. ul’s with two or less li’s will remain untouched.
Miscellaneous
The Javacript code is registered as a Z3 resource:
++resource++collective.showmore.js
Changelog
1.0a2 - 2009-04-20
Add grace_count option to avoid replacing small numbers of items (i.e. one) with a “show more…” link, effectively not saving any space. [gotcha]
1.0a1 - 2009-04-08
Initial release [gotcha]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file collective.js.showmore-1.0a2.zip
.
File metadata
- Download URL: collective.js.showmore-1.0a2.zip
- Upload date:
- Size: 55.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0627c8a2378f4382129ce19c3c4e9caafb6f30f7655ea09849610edc7504a4c6 |
|
MD5 | 8239adafbfb85726ec62933856ae0458 |
|
BLAKE2b-256 | 37e49ffe5c6c342fadccc350956df220735e4caf45386b56246d607dd42c07d7 |