diff --git a/static/bargraph/style.css b/static/bargraph/style.css index 13dbb1af..4513e56d 100644 --- a/static/bargraph/style.css +++ b/static/bargraph/style.css @@ -64,7 +64,7 @@ path.domain { display: inline-block; } -#faq-text { +.faq-text { width: 100%; max-width: 750px; padding: 5px 10px 0px 10px; diff --git a/static/pie/pie.css b/static/pie/pie.css index 6b712c7c..ac8696fe 100644 --- a/static/pie/pie.css +++ b/static/pie/pie.css @@ -2,3 +2,7 @@ max-width: 800px; width: 100%; } + +#pie-wrapper { + max-width: 800px; +} diff --git a/templates/bargraph/barchart-interactive-nonblocking.html b/templates/bargraph/barchart-interactive-nonblocking.html index 52c34bc1..b436362e 100644 --- a/templates/bargraph/barchart-interactive-nonblocking.html +++ b/templates/bargraph/barchart-interactive-nonblocking.html @@ -2,96 +2,9 @@ diff --git a/templates/pie/pie.html b/templates/pie/pie.html index 8c740660..c77b6852 100644 --- a/templates/pie/pie.html +++ b/templates/pie/pie.html @@ -1,9 +1,18 @@ +{% load static %} +{% load compress %} + +{% compress css file %} + +{% endcompress %} {{ rawData|json_script:"rawDataId" }} +{% include "visualizer/round-describer.html" with prefix="pie" %}
+ +{% include "visualizer/round-faq.html" with prefix="pie" %} diff --git a/templates/tabular/tabular-by-round-interactive-nonblocking.html b/templates/tabular/tabular-by-round-interactive-nonblocking.html index 8fb7d161..f3499e05 100644 --- a/templates/tabular/tabular-by-round-interactive-nonblocking.html +++ b/templates/tabular/tabular-by-round-interactive-nonblocking.html @@ -5,12 +5,15 @@ // For slider TODO sync with barchart-interactive.html var numRounds = {{ tabularByRoundInteractive.rounds|length }}; +const tabularIds = makeRoundComponentIds("tabular"); function showRound(round) { - for (let i = 0; i < numRounds; i++) { + for (let i = 0; i < numRounds; i++) { document.getElementById("tabular_round_container_"+i).style.display = "none"; } document.getElementById("tabular_round_container_"+round).style.display = "block"; + showTextOnRoundDescriber(descriptionOfCurrRound(round), false, tabularIds); + updateFaqText(round, tabularIds); } showRound(numRounds-1) @@ -20,5 +23,12 @@ totalRounds: numRounds, onChange: showRound, }); +activeRoundPlayer = roundPlayer; + +// Show summary text and last-round FAQ on load +showTextOnRoundDescriber(humanFriendlySummary, false, tabularIds); +if (window.self === window.top) { + makeFaqSectionVisible(tabularIds); +} diff --git a/templates/tabular/tabular-by-round-interactive.html b/templates/tabular/tabular-by-round-interactive.html index 4af15789..a81ba8ab 100644 --- a/templates/tabular/tabular-by-round-interactive.html +++ b/templates/tabular/tabular-by-round-interactive.html @@ -1,8 +1,12 @@ {% load static %} +{% include "visualizer/round-describer.html" with prefix="tabular" %} +
+{% include "visualizer/round-faq.html" with prefix="tabular" %} +
{% for round in tabularByRoundInteractive.rounds %}
@@ -15,7 +19,7 @@

Round {{ forloop.counter }}

Current total votes - + {% for candidate in round %} {% if candidate.wonThisRound %} diff --git a/templates/visualizer/round-describer-nonblocking.html b/templates/visualizer/round-describer-nonblocking.html new file mode 100644 index 00000000..b375359f --- /dev/null +++ b/templates/visualizer/round-describer-nonblocking.html @@ -0,0 +1,81 @@ + diff --git a/templates/visualizer/round-describer.html b/templates/visualizer/round-describer.html new file mode 100644 index 00000000..d9d37398 --- /dev/null +++ b/templates/visualizer/round-describer.html @@ -0,0 +1,11 @@ +
+ +
diff --git a/templates/visualizer/round-faq-nonblocking.html b/templates/visualizer/round-faq-nonblocking.html new file mode 100644 index 00000000..b70691ee --- /dev/null +++ b/templates/visualizer/round-faq-nonblocking.html @@ -0,0 +1,38 @@ + diff --git a/templates/visualizer/round-faq.html b/templates/visualizer/round-faq.html new file mode 100644 index 00000000..04f23a4a --- /dev/null +++ b/templates/visualizer/round-faq.html @@ -0,0 +1 @@ +
diff --git a/templates/visualizer/visualize-ballotpedia.html b/templates/visualizer/visualize-ballotpedia.html index a7c7d228..84408377 100644 --- a/templates/visualizer/visualize-ballotpedia.html +++ b/templates/visualizer/visualize-ballotpedia.html @@ -50,6 +50,8 @@
{% include "visualizer/common-visualizer-nonblocking.html" %} + {% include "visualizer/round-describer-nonblocking.html" %} + {% include "visualizer/round-faq-nonblocking.html" %} {% include "bargraph/barchart-common-nonblocking.html" %} {% include "bargraph/barchart-interactive-nonblocking.html" %} diff --git a/templates/visualizer/visualize-embedded.html b/templates/visualizer/visualize-embedded.html index 84c9260b..6b20b75f 100644 --- a/templates/visualizer/visualize-embedded.html +++ b/templates/visualizer/visualize-embedded.html @@ -45,6 +45,8 @@
{% include "visualizer/common-visualizer-nonblocking.html" %} + {% include "visualizer/round-describer-nonblocking.html" %} + {% include "visualizer/round-faq-nonblocking.html" %} {% if vistype == "sankey" %} {% include "sankey/sankey-nonblocking.html" %} {% elif vistype == "pie" %} diff --git a/templates/visualizer/visualize.html b/templates/visualizer/visualize.html index a647dcdc..4a67a2b1 100644 --- a/templates/visualizer/visualize.html +++ b/templates/visualizer/visualize.html @@ -165,6 +165,8 @@
{% block afterMaincontent %} {% include "visualizer/common-visualizer-nonblocking.html" %} + {% include "visualizer/round-describer-nonblocking.html" %} + {% include "visualizer/round-faq-nonblocking.html" %} {% include "sankey/sankey-nonblocking.html" %} {% include "pie/pie-nonblocking.html" %} {% include "bargraph/barchart-common-nonblocking.html" %} diff --git a/visualizer/tests/testLiveBrowserWithHead.py b/visualizer/tests/testLiveBrowserWithHead.py index 2b94c300..f52e945f 100644 --- a/visualizer/tests/testLiveBrowserWithHead.py +++ b/visualizer/tests/testLiveBrowserWithHead.py @@ -191,7 +191,7 @@ def test_faq(self): self.browser.execute_script("showFaqButtonNow();") # Starts at 65px - div = self.browser.find_element(By.ID, 'round-description-wrapper') + div = self.browser.find_element(By.CSS_SELECTOR, '.round-description-wrapper') self._ensure_eventually_asserts(lambda: self.assertEqual(div.size['height'], 65)) faqHeader = self.browser.find_element(By.CSS_SELECTOR, '.faq-description-header') @@ -291,7 +291,7 @@ def test_faq_visibility_wrt_iframes(self): self._upload_something_if_needed() # Ensure that the FAQs are visible outside an iframe - faq = self.browser.find_element(By.ID, 'faq-text') + faq = self.browser.find_element(By.ID, 'bargraph-interactive-faq-text') self.assertEqual(faq.value_of_css_property("display"), "block") # Get the iframe HTML @@ -310,7 +310,7 @@ def test_faq_visibility_wrt_iframes(self): # Check that the FAQs are hidden WebDriverWait(self.browser, 3).until( EC.visibility_of_element_located((By.ID, "embedded-body"))) - faq = self.browser.find_element(By.ID, 'faq-text') + faq = self.browser.find_element(By.ID, 'bargraph-interactive-faq-text') self.assertEqual(faq.value_of_css_property("display"), "none") # After clicking "Read a detailed explanation" it becomes visible