diff --git a/www/docs/js/main.js b/www/docs/js/main.js index 6dd194a9f0..a543ddd684 100644 --- a/www/docs/js/main.js +++ b/www/docs/js/main.js @@ -423,6 +423,47 @@ function wrap_error($message){ return ''; } +function createAccordion(triggerSelector, contentSelector) { + var triggers = document.querySelectorAll(triggerSelector); + + triggers.forEach(function(trigger) { + var content = document.querySelector(trigger.getAttribute('href')); + + var openAccordion = function() { + content.style.maxHeight = content.scrollHeight + "px"; // Dynamically calculate height + content.setAttribute('aria-hidden', 'false'); + trigger.setAttribute('aria-expanded', 'true'); + }; + + var closeAccordion = function() { + content.style.maxHeight = null; // Collapse + content.setAttribute('aria-hidden', 'true'); + trigger.setAttribute('aria-expanded', 'false'); + }; + + trigger.addEventListener('click', function(e) { + e.preventDefault(); + + if (content.style.maxHeight) { + closeAccordion(); + } else { + openAccordion(); + } + }); + + // Accessibility + trigger.setAttribute('aria-controls', content.getAttribute('id')); + trigger.setAttribute('aria-expanded', 'false'); + content.setAttribute('aria-hidden', 'true'); + content.style.maxHeight = null; + }); +} + +// Initialize accordion when DOM is loaded +document.addEventListener('DOMContentLoaded', function() { + createAccordion('.accordion-trigger', '.accordion-content'); +}); + $(function() { $('#how-often-annually').click(function() { diff --git a/www/docs/style/sass/accordion.scss b/www/docs/style/sass/accordion.scss new file mode 100644 index 0000000000..4dce08ee58 --- /dev/null +++ b/www/docs/style/sass/accordion.scss @@ -0,0 +1,22 @@ +.accordion-content { + max-height: 0; + overflow: hidden; + transition: max-height 0.3s ease; +} + +.accordion-button[aria-expanded="true"] + .accordion-content { + max-height: 1000px; + transition: max-height 0.3s ease; +} + +.accordion-button { + display: block; + width: 100%; + text-align: left; + padding: 10px; + font-size: 1.2em; + cursor: pointer; + border: none; + background: #f0f0f0; +} + \ No newline at end of file diff --git a/www/docs/style/sass/app.scss b/www/docs/style/sass/app.scss index d356a39cd9..2c66610093 100644 --- a/www/docs/style/sass/app.scss +++ b/www/docs/style/sass/app.scss @@ -57,6 +57,7 @@ @import "compass/css3"; @import "_twfy-mixins.scss"; @import "accessible-autocomplete"; +@import "accordion"; @import url(https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,600,700,400italic&display=swap); @import url(https://fonts.googleapis.com/css2?family=Manrope:wght@700&family=Merriweather:wght@400;700&display=swap); diff --git a/www/includes/easyparliament/templates/html/alert/alert-mockup.php b/www/includes/easyparliament/templates/html/alert/alert-mockup.php new file mode 100644 index 0000000000..a7e59dfc5d --- /dev/null +++ b/www/includes/easyparliament/templates/html/alert/alert-mockup.php @@ -0,0 +1,26 @@ +
+ + +
+ +
+ + +
+ +
+ + +
diff --git a/www/includes/easyparliament/templates/html/alert/index.php b/www/includes/easyparliament/templates/html/alert/index.php index 11b567561c..a4a2c6d944 100644 --- a/www/includes/easyparliament/templates/html/alert/index.php +++ b/www/includes/easyparliament/templates/html/alert/index.php @@ -1,30 +1,31 @@
+ - - - - +
+ + + 0) || - ($alertsearch) - ) { + $members || + (isset($constituencies) && count($constituencies) > 0) || + ($alertsearch) + ) { /* We need to disambiguate the user's instructions */ $member_options = false; - ?> + ?>
-
- - +
+ +

%s speaks'), _htmlspecialchars($alertsearch)) ?>

    + ?>
  • -
    - - - - " method="post"> + + + +
    - -
  • - -
- - - 0) { - $member_options = true; ?> + + + + + + + 0) { + $member_options = true; ?>

%s speaks'), _htmlspecialchars($alertsearch)) ?>

    - $member) { ?> + $member) { ?>
  • -
    - - - - full_name() ?> - () -
    -
  • - -
- - - +
+ + + + full_name() ?> + () +
+ + + + + +

-

- -
    +

    + +
    • -
      - - - - - -
      +
      + + + + + +
      - - - + + - -
    • - + + + +
    • @@ -282,6 +284,7 @@
+

@@ -302,6 +305,7 @@

+