foundation.mozilla.org/source/js/dropdowns.js

35 строки
1.0 KiB
JavaScript
Исходник Постоянная ссылка Обычный вид История

5075 publication and chapter page frontend (#5134) * create inital model & factory * docs update * add fields for publication page, sans authors * add fields to publication factory * add article model, template, docstring tweaks * start on factories basic factory with child objects variable names for publication factory Update network-api/networkapi/wagtailpages/factory/publication.py Co-authored-by: Kalob Taulien <4743971+KalobTaulien@users.noreply.github.com> * add article fields, move template, 'squash' migrations * Migration dependency fix * List child pages with chapter numbers * Filter only Article Pages * Chapter Page via second level Publication Page * clean up duplicate translation registry * messy but fancy ordered list styling * never say I'm not full stack ;-p * remove extra methods * link to stuff about counters * [5076] Publication Page Authors (#5135) * Blog authors come from child Article Pages * Lovelier formatting * PublicationPage uses explicit BlogAuthors * Moved panels * Additional author text copy * Conditional around authors * 5070 frontend summary style (#5165) * tighten up styling/html class for summary * template, style magic * more layout stuff, not perfect * little bit of template cleanup * clean up migration files * Rebase & factory fix * Publication/Chapter Hero * styles/template edits for hero * more style tweaks * code cleanup * remove patch * make CI pass, cleanup patch * dont include authors if we aren't using them in the factory yet * fix for node/style tests * Moved to bootstrap layouts * Publication Page * Chapter page * WIP: Publication Page Notes * Moved template to fragments; code cleanup * Better flex alignment * [5143] ArticlePage Frontend (#5166) * create inital model & factory * add fields for publication page, sans authors * add fields to publication factory * add article model, template, docstring tweaks * start on factories basic factory with child objects variable names for publication factory Update network-api/networkapi/wagtailpages/factory/publication.py Co-authored-by: Kalob Taulien <4743971+KalobTaulien@users.noreply.github.com> * add article fields, move template, 'squash' migrations * register translations to prevent errors * Filter only Article Pages * [5076] Publication Page Authors (#5135) * Blog authors come from child Article Pages * Lovelier formatting * PublicationPage uses explicit BlogAuthors * Moved panels * Additional author text copy * Conditional around authors * WIP: Article Richtext Block * Cleanup * WIP: Adding footnotes * Article Footnotes (Desktop Only) * Prev/next Articles * Callout block (Desktop) * Callout block style (Desktop) * Table block (Desktop) * Aligning article components (Desktop) * Double image block (Desktop) * Full width image block (Desktop) * Article Summary (Desktop) * Prev/next arrows * Misc. Polish (Desktop) * WIP: Subnav dropdown (Desktop) * clean up branch, consolidate migrations * Moved chevron to glyph dir * Use color vars * Dont show summary block if there are no headers * Simplified next/prev functions * Removed 500 font weight * IndexError fix * Article Page Dropdown * Mobile goodness * Mobile summary menu * Cleanup * Wrap long titles in dropdown * Make subnav nicer when no summary items are present * Review suggestion updates Co-authored-by: Eric Sherman <ericandrewsherman@gmail.com> * Share icons & article hero * Article page tweaks * Fragmentsgs! * Bump content into hero * Spacing tweak * Peer review updates * TODO cleanup * I'll get the vacuum for these breadcrumbs * No summary, no problem (spacing fix) * Use styleguide on breadcrumbs * Split out PublicationPage styling * Use apostrophes to lessen the git diff * Migration fix * Flake8 fixes & template tag docs * Prettier formatting * Fixed js * Fix scss * [5170] Article Page Factories (#5281) * Article page factories * Enabled legacy richtext for Wagtail 2.10 * Review suggestion changes * Next/prev block buttons * Design tweaks * i18n footnootes labels * Fixed faker sentence * Removed summary title field; added hero bg image * Publication hero fixes * Article page StreamField style tweaks * Minor sass cleanup * Publication feature flag * Vertically center titles when no child pages exist * Center titles on ChapterPages * Resolving code suggestions * Moved method to utils * Resolving review suggestions * Stylelint fixes * Fix broken previews * Offset internal links using CSS to account for the sticky nav * Fixed block display & anchor offset by using a width declaration * Prettier formatting Co-authored-by: Kalob Taulien <4743971+KalobTaulien@users.noreply.github.com> Co-authored-by: Kalob Taulien <kalob.taulien@gmail.com>
2020-10-07 21:26:15 +03:00
const Dropdowns = {
init: function () {
// Toggle dropdowns when dropdown is clicked
document.querySelectorAll(".dropdown-toggle").forEach((element) =>
element.addEventListener("click", (_) => {
element.classList.toggle("show");
const target = document.querySelector(
`[aria-labelledby="${element.id}"]`
);
target.classList.toggle("d-block");
const toggleText = document.querySelector(".toggle-text");
if (!toggleText) {
return;
}
if (element.classList.contains("show")) {
toggleText.innerText = toggleText.getAttribute("data-close");
} else {
toggleText.innerText = toggleText.getAttribute("data-open");
}
5075 publication and chapter page frontend (#5134) * create inital model & factory * docs update * add fields for publication page, sans authors * add fields to publication factory * add article model, template, docstring tweaks * start on factories basic factory with child objects variable names for publication factory Update network-api/networkapi/wagtailpages/factory/publication.py Co-authored-by: Kalob Taulien <4743971+KalobTaulien@users.noreply.github.com> * add article fields, move template, 'squash' migrations * Migration dependency fix * List child pages with chapter numbers * Filter only Article Pages * Chapter Page via second level Publication Page * clean up duplicate translation registry * messy but fancy ordered list styling * never say I'm not full stack ;-p * remove extra methods * link to stuff about counters * [5076] Publication Page Authors (#5135) * Blog authors come from child Article Pages * Lovelier formatting * PublicationPage uses explicit BlogAuthors * Moved panels * Additional author text copy * Conditional around authors * 5070 frontend summary style (#5165) * tighten up styling/html class for summary * template, style magic * more layout stuff, not perfect * little bit of template cleanup * clean up migration files * Rebase & factory fix * Publication/Chapter Hero * styles/template edits for hero * more style tweaks * code cleanup * remove patch * make CI pass, cleanup patch * dont include authors if we aren't using them in the factory yet * fix for node/style tests * Moved to bootstrap layouts * Publication Page * Chapter page * WIP: Publication Page Notes * Moved template to fragments; code cleanup * Better flex alignment * [5143] ArticlePage Frontend (#5166) * create inital model & factory * add fields for publication page, sans authors * add fields to publication factory * add article model, template, docstring tweaks * start on factories basic factory with child objects variable names for publication factory Update network-api/networkapi/wagtailpages/factory/publication.py Co-authored-by: Kalob Taulien <4743971+KalobTaulien@users.noreply.github.com> * add article fields, move template, 'squash' migrations * register translations to prevent errors * Filter only Article Pages * [5076] Publication Page Authors (#5135) * Blog authors come from child Article Pages * Lovelier formatting * PublicationPage uses explicit BlogAuthors * Moved panels * Additional author text copy * Conditional around authors * WIP: Article Richtext Block * Cleanup * WIP: Adding footnotes * Article Footnotes (Desktop Only) * Prev/next Articles * Callout block (Desktop) * Callout block style (Desktop) * Table block (Desktop) * Aligning article components (Desktop) * Double image block (Desktop) * Full width image block (Desktop) * Article Summary (Desktop) * Prev/next arrows * Misc. Polish (Desktop) * WIP: Subnav dropdown (Desktop) * clean up branch, consolidate migrations * Moved chevron to glyph dir * Use color vars * Dont show summary block if there are no headers * Simplified next/prev functions * Removed 500 font weight * IndexError fix * Article Page Dropdown * Mobile goodness * Mobile summary menu * Cleanup * Wrap long titles in dropdown * Make subnav nicer when no summary items are present * Review suggestion updates Co-authored-by: Eric Sherman <ericandrewsherman@gmail.com> * Share icons & article hero * Article page tweaks * Fragmentsgs! * Bump content into hero * Spacing tweak * Peer review updates * TODO cleanup * I'll get the vacuum for these breadcrumbs * No summary, no problem (spacing fix) * Use styleguide on breadcrumbs * Split out PublicationPage styling * Use apostrophes to lessen the git diff * Migration fix * Flake8 fixes & template tag docs * Prettier formatting * Fixed js * Fix scss * [5170] Article Page Factories (#5281) * Article page factories * Enabled legacy richtext for Wagtail 2.10 * Review suggestion changes * Next/prev block buttons * Design tweaks * i18n footnootes labels * Fixed faker sentence * Removed summary title field; added hero bg image * Publication hero fixes * Article page StreamField style tweaks * Minor sass cleanup * Publication feature flag * Vertically center titles when no child pages exist * Center titles on ChapterPages * Resolving code suggestions * Moved method to utils * Resolving review suggestions * Stylelint fixes * Fix broken previews * Offset internal links using CSS to account for the sticky nav * Fixed block display & anchor offset by using a width declaration * Prettier formatting Co-authored-by: Kalob Taulien <4743971+KalobTaulien@users.noreply.github.com> Co-authored-by: Kalob Taulien <kalob.taulien@gmail.com>
2020-10-07 21:26:15 +03:00
})
);
// Close dropdowns when item is clicked
document.querySelectorAll(".dropdown-item").forEach((element) => {
element.addEventListener("click", (_) => {
element.parentElement.classList.remove("d-block", "show");
});
});
},
};
export default Dropdowns;