From 4489feb935ebec9ede3ae18ce296d5a26ae8ba15 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Tue, 5 Feb 2019 22:26:30 +0100 Subject: [PATCH] Added the text slide footer --- openlp/core/display/html/display.js | 21 ++++++++++++++++----- openlp/core/display/render.py | 2 +- openlp/core/lib/serviceitem.py | 2 ++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/openlp/core/display/html/display.js b/openlp/core/display/html/display.js index c684e3e0d..9c6eda634 100644 --- a/openlp/core/display/html/display.js +++ b/openlp/core/display/html/display.js @@ -384,10 +384,11 @@ var Display = { /** * Add a slides. If the slide exists but the HTML is different, update the slide. * @param {string} verse - The verse number, e.g. "v1" - * @param {string} html - The HTML for the verse, e.g. "line1
line2" + * @param {string} text - The HTML for the verse, e.g. "line1
line2" + * @param {string} footer_text - The HTML for the footer" * @param {bool} [reinit=true] - Re-initialize Reveal. Defaults to true. */ - addTextSlide: function (verse, text) { + addTextSlide: function (verse, text, footer_text) { var html = _prepareText(text); if (this._slides.hasOwnProperty(verse)) { var slide = $("#" + verse)[0]; @@ -403,11 +404,16 @@ var Display = { slidesDiv.appendChild(slide); var slides = $(".slides > section"); this._slides[verse] = slides.length - 1; + + console.debug(" footer_text: " + footer_text); + + var footerDiv = $(".footer")[0]; + footerDiv.innerHTML = footer_text; } - if ((arguments.length > 2) && (arguments[2] === true)) { + if ((arguments.length > 3) && (arguments[3] === true)) { this.reinit(); } - else if (arguments.length == 2) { + else if (arguments.length == 3) { this.reinit(); } }, @@ -418,7 +424,7 @@ var Display = { setTextSlides: function (slides) { Display.clearSlides(); slides.forEach(function (slide) { - Display.addTextSlide(slide.verse, slide.text, false); + Display.addTextSlide(slide.verse, slide.text, slide.footer, false); }); Display.reinit(); Display.goToSlide(0); @@ -590,6 +596,8 @@ var Display = { blankToTheme: function () { var slidesDiv = $(".slides")[0]; slidesDiv.style.visibility = "hidden"; + var footerDiv = $(".footer")[0]; + footerDiv.style.visibility = "hidden"; if (Reveal.isPaused()) { Reveal.togglePause(); } @@ -600,6 +608,8 @@ var Display = { show: function () { var slidesDiv = $(".slides")[0]; slidesDiv.style.visibility = "visible"; + var footerDiv = $(".footer")[0]; + footerDiv.style.visibility = "visible"; if (Reveal.isPaused()) { Reveal.togglePause(); } @@ -733,6 +743,7 @@ var Display = { }; footerStyle["position"] = "absolute"; footerStyle["left"] = "" + theme.font_footer_x + "px"; + footerStyle["top"] = "" + theme.font_footer_y + "px"; footerStyle["bottom"] = "" + (window.innerHeight - theme.font_footer_y - theme.font_footer_height) + "px"; footerStyle["width"] = "" + theme.font_footer_width + "px"; footerStyle["font-family"] = theme.font_footer_name; diff --git a/openlp/core/display/render.py b/openlp/core/display/render.py index 7f6967183..875c1b1d8 100644 --- a/openlp/core/display/render.py +++ b/openlp/core/display/render.py @@ -713,7 +713,7 @@ class Renderer(RegistryBase, LogMixin, RegistryProperties, DisplayWindow): :param text: The text to check. It may contain HTML tags. """ self.clear_slides() - self.run_javascript('Display.addTextSlide("v1", "{text}");'.format(text=text), is_sync=True) + self.run_javascript('Display.addTextSlide("v1", "{text}", "Dummy Footer");'.format(text=text), is_sync=True) does_text_fits = self.run_javascript('Display.doesContentFit();', is_sync=True) return does_text_fits diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index b8eede13c..bab9056f4 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -165,6 +165,7 @@ class ServiceItem(RegistryProperties): # the dict instead of rendering them again. previous_pages = {} index = 0 + self.foot_text = '
'.join([_f for _f in self.raw_footer if _f]) for raw_slide in self.slides: verse_tag = raw_slide['verse'] if verse_tag in previous_pages and previous_pages[verse_tag][0] == raw_slide: @@ -177,6 +178,7 @@ class ServiceItem(RegistryProperties): 'title': raw_slide['title'], 'text': render_tags(page), 'verse': index, + 'footer' : self.foot_text, } self._rendered_slides.append(rendered_slide) display_slide = {