diff options
| author | luccioman <luccioman@users.noreply.github.com> | 2017-10-09 14:13:46 +0200 |
|---|---|---|
| committer | luccioman <luccioman@users.noreply.github.com> | 2017-10-09 14:13:46 +0200 |
| commit | dbff7b14fcc405d8b8ab75e1d784595459ae00c1 (patch) | |
| tree | 66d6b114e640b7dad23f7dbfd21b1ad3e4967b6f /htroot/js/yacysearch.js | |
| parent | f8c7d0265e169be435df4f922f91143b6ce28e99 (diff) | |
Add a configurable limit to tags initially displayed in search results
When the limit is reached, a button allow expanding/collapsing remaining
tags.
When this feature is activated without a limit to the number of
displayed tags, when encountering search results with a very large
number of keywords, the results page can become almost unusable (very
long vertical scrollbar)
Diffstat (limited to 'htroot/js/yacysearch.js')
| -rw-r--r-- | htroot/js/yacysearch.js | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/htroot/js/yacysearch.js b/htroot/js/yacysearch.js index 263e2e536..f9927f3bd 100644 --- a/htroot/js/yacysearch.js +++ b/htroot/js/yacysearch.js @@ -264,4 +264,25 @@ function statistics(offset, itemscount, itemsperpage, totalcount, localIndexCoun } } - +/** + * Toggle visibility on a block of tags (keywords) beyond the initial limit of tags to display. + * @param {HTMLButtonElement} button the button used to expand the tags + * @param {String} moreTagsId the id of the container of tags which visibility has to be toggled + */ +function toggleMoreTags(button, moreTagsId) { + var moreTagsContainer = document.getElementById(moreTagsId); + if(button != null && moreTagsContainer != null) { + if(button.getAttribute("aria-expanded") == "true") { + /* Additionnaly we modify the aria-expanded state for improved accessiblity */ + button.setAttribute("aria-expanded", "false"); + button.title = "Show all"; + moreTagsContainer.className = "hidden"; + } else { + /* Additionnaly we modify the aria-expanded state for improved accessiblity */ + button.setAttribute("aria-expanded", "true"); + button.title = "Show only the first elements"; + moreTagsContainer.className = ""; + } + } + +}
\ No newline at end of file |
