From 189a1e510d2bc6e2e296a7284d3ec406afc2ac9b Mon Sep 17 00:00:00 2001 From: Derek P Sifford Date: Thu, 19 Jan 2017 20:33:09 -0500 Subject: [PATCH] fix: fix typo in frontend.ts that resulted in duplicate elements Closes #279 --- src/lib/css/citations.styl | 4 ++-- src/lib/css/frontend.styl | 6 ++++++ src/lib/js/Frontend.ts | 13 +++++++------ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/lib/css/citations.styl b/src/lib/css/citations.styl index 4b5322ff..ca066260 100644 --- a/src/lib/css/citations.styl +++ b/src/lib/css/citations.styl @@ -101,8 +101,8 @@ body:not(#tinymce) position: relative font-size: 30px top: 5px - &.abt-hidden:before - content: '\f139' + .abt-bibliography__heading_toggle--closed:before + content: '\f139' // Deprecations // @stylint off diff --git a/src/lib/css/frontend.styl b/src/lib/css/frontend.styl index 05dd059f..c5096fd9 100644 --- a/src/lib/css/frontend.styl +++ b/src/lib/css/frontend.styl @@ -2,6 +2,12 @@ @require 'collections/variables' @require 'citations' +.abt-bibligraphy__container + display: block + +.abt-bibligraphy__container--hidden + display: none + .abt-tooltip border-radius: 3px box-shadow: $citation-tooltip diff --git a/src/lib/js/Frontend.ts b/src/lib/js/Frontend.ts index 1105f97b..bb135db7 100644 --- a/src/lib/js/Frontend.ts +++ b/src/lib/js/Frontend.ts @@ -109,22 +109,23 @@ class Citations { private enableToggle(): void { const citations = document.querySelectorAll('#abt-bibliography>div, #abt-smart-bib>div'); const heading = document.querySelector('.abt-bibliography__heading_toggle, #abt-smart-bib>h3.toggle'); - let container = document.getElementById('abt-bibibliography__container'); + let container = document.getElementById('abt-bibliography__container'); if (!container) { container = document.createElement('div'); - container.id = 'abt-bibibliography__container'; + container.id = 'abt-bibliography__container'; this.bibliography.appendChild(container); for (const el of citations) { container.appendChild(el); } } - container.style.display = 'none'; - heading.classList.toggle('abt-hidden'); + + container.classList.toggle('abt-bibligraphy__container--hidden'); + heading.classList.toggle('abt-bibliography__heading_toggle--closed'); heading.addEventListener('click', () => { - container.style.display = container.style.display === 'none' ? '' : 'none'; - heading.classList.toggle('abt-hidden'); + container.classList.toggle('abt-bibligraphy__container--hidden'); + heading.classList.toggle('abt-bibliography__heading_toggle--closed'); }); } }