From 4351bb2664576cb3c55e24e0155f4103618ef0ba Mon Sep 17 00:00:00 2001 From: Stephanie Hays Date: Mon, 24 Oct 2022 09:11:11 -0500 Subject: [PATCH 1/2] (#259) Add reusable function to truncate results In the packages area, there is a table with several results that should be truncated if the results are over a certain number. A new function has been added that can be referenced for instances like this by adding the class 'truncate-results` to the rows that are intended to be truncated. The ID of the button should be passed into the function for the click handler to be attached. --- js/chocolatey-packages.js | 5 ++++- js/util/chocolatey-functions.js | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/js/chocolatey-packages.js b/js/chocolatey-packages.js index f32fdd70..dce6e08f 100644 --- a/js/chocolatey-packages.js +++ b/js/chocolatey-packages.js @@ -1,7 +1,7 @@ import jQuery from 'jquery'; import EasyMDE from 'easymde'; import { Collapse, Modal } from 'bootstrap'; -import { getCookie, setCookieExpirationNever } from './util/chocolatey-functions'; +import { getCookie, setCookieExpirationNever, truncateResults } from './util/chocolatey-functions'; (() => { // Community Disclaimer @@ -373,4 +373,7 @@ import { getCookie, setCookieExpirationNever } from './util/chocolatey-functions } }); } + + // Show or hide truncated version history table results on click + truncateResults(document.querySelector('#versionTableTruncateResults')); })(); diff --git a/js/util/chocolatey-functions.js b/js/util/chocolatey-functions.js index fe2d19e0..ee75d9c3 100644 --- a/js/util/chocolatey-functions.js +++ b/js/util/chocolatey-functions.js @@ -167,3 +167,20 @@ deploymentMethods.forEach(el => { if (deploymentMethodHashArray.includes(deploymentMethodHash)) { document.cookie = `deployment_method=${deploymentMethodHash}; path=/`; } + +// Show more or hide truncated results on click +export const truncateResults = btnId => { + if (btnId) { + btnId.addEventListener('click', () => { + const results = document.querySelectorAll('tr.truncate-results'); + + for (const i of results) { + if (i.classList.contains('d-none')) { + i.classList.remove('d-none'); + } else { + i.classList.add('d-none'); + } + } + }); + } +}; From 4c138b3a460377e05a93c72aea378857933a0104 Mon Sep 17 00:00:00 2001 From: Stephanie Hays Date: Mon, 24 Oct 2022 09:22:37 -0500 Subject: [PATCH 2/2] Bump version to 0.1.4 --- getting-started/_package.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/getting-started/_package.json b/getting-started/_package.json index 65c52814..ad6fb5ab 100644 --- a/getting-started/_package.json +++ b/getting-started/_package.json @@ -12,7 +12,7 @@ }, "homepage": "https://github.com/chocolatey/chocolatey.org#readme", "devDependencies": { - "choco-theme": "^0.1.3" + "choco-theme": "^0.1.4" }, "resolutions": { "glob-parent": "^6.0.1", diff --git a/package.json b/package.json index e16eb1b2..7461b6e6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "choco-theme", - "version": "0.1.3", + "version": "0.1.4", "description": "The global theme for Chocolatey Software.", "repository": { "type": "git",