From 255c8b724e036d9d38e1dab4540974d11fc00bfa Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Tue, 3 Nov 2020 22:30:20 -0500 Subject: Pitch accents preview (#987) * Add public preparePitchAccents function to DisplayGenerator * Add pitch accents preview HTML, CSS, and JS --- ext/mixed/js/display-generator.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'ext/mixed/js') diff --git a/ext/mixed/js/display-generator.js b/ext/mixed/js/display-generator.js index 926eb25d..910d45da 100644 --- a/ext/mixed/js/display-generator.js +++ b/ext/mixed/js/display-generator.js @@ -34,6 +34,13 @@ class DisplayGenerator { this._templates = new HtmlTemplateCollection(html); } + preparePitchAccents() { + if (this._termPitchAccentStaticTemplateIsSetup) { return; } + this._termPitchAccentStaticTemplateIsSetup = true; + const t = this._templates.instantiate('term-pitch-accent-static'); + document.head.appendChild(t); + } + createTermEntry(details) { const node = this._templates.instantiate('term-entry'); @@ -357,11 +364,7 @@ class DisplayGenerator { } _createPitches(details) { - if (!this._termPitchAccentStaticTemplateIsSetup) { - this._termPitchAccentStaticTemplateIsSetup = true; - const t = this._templates.instantiate('term-pitch-accent-static'); - document.head.appendChild(t); - } + this.preparePitchAccents(); const {dictionary, pitches} = details; -- cgit v1.2.3