From 4d10042728a961ac95c9cc42b79a756429ebbc2c Mon Sep 17 00:00:00 2001 From: Kathrin Osswald <kathrin.osswald@uni-ulm.de> Date: Mon, 28 Sep 2020 09:06:47 +0200 Subject: [PATCH] Added setting to be able to enable the initial Boost Campus back to top button instead of the new Boost Go to top button. --- CHANGES.md | 1 + README.md | 15 ++++++++++++ lang/en/theme_boost_campus.php | 15 ++++++++++++ layout/columns2.php | 7 +++++- settings.php | 13 ++++++++++ templates/columns2.mustache | 8 ++++++- templates/footer.mustache | 13 +++++++++- templates/footer.mustache.original | 6 +++++ ...eme_boost_campus_advanced_settings.feature | 24 +++++++++++++++++++ version.php | 2 +- 10 files changed, 100 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 75da3d7..72cbcdb 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ Changes ### Unreleased +* 2020-09-28 - Added setting to be able to enable the initial Boost Campus back to top button instead of the new Boost Go to top button. * 2020-09-25 - Fixed Bug that content bank view page cog icon showed course context menu entries. NOTE: This is just a kind of hacky interim solution until MDL-69793 is done. * 2020-09-23 - Updated referenced Bootstrap version to latest in upstream used version 4.5. diff --git a/README.md b/README.md index adcd9c3..7a10872 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,21 @@ This setting will catch the "Ctrl + Arrow down" shortcut (Windows), prevent the With this setting you can manage where the "Add a block" widget should be displayed. "At the bottom of the nav drawer" means the widget to add new blocks is displayed in the left sliding navigation panel like in theme Boost. "At the bottom of the default block region" means the widget to add new blocks will be displayed in the default block region. +##### Boost Campus "Back to top" button + +Since Moodle 3.9, a "Go to top" button was integrated into theme Boost and usually that would make our provided solution obsolete. +However, the core solution has still some little itches and that is the reason why we would like to provide the Boost Campus "Back to top" button as an optional setting. +If you enable this setting, the core "Go to top" button will not be displayed and instead the Boost Campus "Back to top" button will occur. The differences are: + +* Smooth scolling: Boost Campus "Back to top" button uses smooth scrolling whilst the core "Go to top" button jumps directly to the top. +* URL implications: Boost Campus "Back to top" button only uses Javascript and has no implication to the URL whilst the core "Go to top" button adds a "#" at the end of the URL by clicking the button. If you copy the URL the "#" will be copied along. +* Styling: The styling of both buttons differ. +* Accessibility: Boost Campus "Back to top" button is not improved in terms of accessibility whilst the core "Go to top" button is. + +Please note: + +This setting will be removed as soon a the core feature is improved so that no individual theme solution is needed anymore.'; + ### 3. Tab "Course Layout Settings" #### Section 0: Title diff --git a/lang/en/theme_boost_campus.php b/lang/en/theme_boost_campus.php index 448caf1..0f9c7e1 100644 --- a/lang/en/theme_boost_campus.php +++ b/lang/en/theme_boost_campus.php @@ -62,6 +62,21 @@ $string['catchctrlarrowdownsetting'] = 'Ctrl + Arrow down shortcut'; $string['catchctrlarrowdownsetting_desc'] = 'This setting will catch the "Ctrl + Arrow down" shortcut (Windows),'; $string['catchkeys_desc_addition'] = 'prevent the default scrolling to the bottom of the web page and changes the behavior to scroll only to the bottom of the main course content.'; +// ..."Back to top" button. +$string['bcbttbuttonheadingsetting'] = 'Boost Campus "Back to top" button'; +$string['bcbttbuttonsetting'] = 'Boost Campus "Back to top" button'; +$string['bcbttbuttonsetting_desc'] = 'Since Moodle 3.9, a "Go to top" button was integrated into theme Boost and usually that would make our provided solution obsolete.<br/> +However, the core solution has still some little itches and that is the reason why we would like to provide the Boost Campus "Back to top" button as an optional setting. <br/> +If you enable this setting, the core "Go to top" button will not be displayed and instead the Boost Campus "Back to top" button will occur. The differences are:<br/> +<ul> +<li>Smooth scolling: Boost Campus "Back to top" button uses smooth scrolling whilst the core "Go to top" button jumps directly to the top.</li> +<li>URL implications: Boost Campus "Back to top" button only uses Javascript and has no implication to the URL whilst the core "Go to top" button adds a "#" at the end of the URL by clicking the button. If you copy the URL the "#" will be copied along.</li> +<li>Styling: The styling of both buttons differ.</li> +<li>Accessibility: Boost Campus "Back to top" button is not improved in terms of accessibility whilst the core "Go to top" button is.</li> +</ul> +Please note:<br/> +This setting will be removed as soon a the core feature is improved so that no individual theme solution is needed anymore.'; + // Course layout settings. $string['courselayoutsettings'] = 'Course Layout Settings'; // ...Section 0. diff --git a/layout/columns2.php b/layout/columns2.php index bbfa238..b21373f 100644 --- a/layout/columns2.php +++ b/layout/columns2.php @@ -79,6 +79,10 @@ if (get_config('theme_boost_campus', 'darknavbar') == 'yes') { $navdrawerfullwidth = get_config('theme_boost_campus', 'navdrawerfullwidth'); // MODIFICATION END. +// MODIFICATION START: Setting 'bcbttbutton'. +$bcbttbutton = get_config('theme_boost_campus', 'bcbttbutton'); +// MODIFICATION END. + // MODIFICATION START: Set these variables in any case as it's needed in the columns2.mustache file. $perpinfobannershowonselectedpage = false; $timedinfobannershowonselectedpage = false; @@ -98,7 +102,8 @@ $templatecontext = [ 'navdrawerfullwidth' => $navdrawerfullwidth, 'darknavbar' => $darknavbar, 'perpinfobannershowonselectedpage' => $perpinfobannershowonselectedpage, - 'timedinfobannershowonselectedpage' => $timedinfobannershowonselectedpage + 'timedinfobannershowonselectedpage' => $timedinfobannershowonselectedpage, + 'bcbttbutton' => $bcbttbutton // MODIFICATION END. ]; diff --git a/settings.php b/settings.php index 7702db9..b49af13 100644 --- a/settings.php +++ b/settings.php @@ -226,6 +226,19 @@ if ($ADMIN->fulltree) { $setting->set_updatedcallback('theme_reset_all_caches'); $page->add($setting); + // Settings title for "Back to top" button. We don't need a description here. + $name = 'theme_boost_campus/bcbttbuttonheading'; + $title = get_string('bcbttbuttonheadingsetting', 'theme_boost_campus', null, true); + $setting = new admin_setting_heading($name, $title, null); + $page->add($setting); + + // Setting enabling the Boost Campus version of the "Back to top" button. + $name = 'theme_boost_campus/bcbttbutton'; + $title = get_string('bcbttbuttonsetting', 'theme_boost_campus', null, true); + $description = get_string('bcbttbuttonsetting_desc', 'theme_boost_campus', null, true); + $setting = new admin_setting_configcheckbox($name, $title, $description, 0); + $page->add($setting); + // Add tab to settings page. $settings->add($page); diff --git a/templates/columns2.mustache b/templates/columns2.mustache index 737ced9..cbbff71 100644 --- a/templates/columns2.mustache +++ b/templates/columns2.mustache @@ -38,6 +38,7 @@ * perpibcontent - The content that should be shown in the perpetual information banner. * perpibcss - The Bootstrap class that is used for the perpetual info banner. * perpibdismiss - true if the setting perpibdismiss is enabled. + * bcbttbutton - true if the setting bcbttbutton is enabled. Example context (json): { @@ -62,7 +63,8 @@ "perpibcontent": "This is a test content for perpetual info banner.", "perpibcss": primary, "perpibdismiss": true, - "infobannerconfirmationdialogue" : true + "infobannerconfirmationdialogue" : true, + "bcbttbutton": true } }} {{! MODIFICATION: @@ -74,6 +76,8 @@ * Use own footer instead of the theme_boost footer. * Add own additional layout elements: footnote or image area. * Added the possibility to show information banners. + * Added the possibility to show Boost Campus traditional "Back to top" button instead of Boost core "Go to top" button + located in footer.mustache file. }} {{> theme_boost/head }} @@ -159,9 +163,11 @@ require(['theme_boost/drawer'], function(drawer) { drawer.init(); M.util.js_complete('theme_boost/drawer'); }); +{{#bcbttbutton}} require(['theme_boost_campus/backtotop'], function(mod) { mod.init(); }); +{{/bcbttbutton}} require(['theme_boost_campus/catchshortcuts'], function(mod) { mod.init({{{catchshortcuts}}}); }); diff --git a/templates/footer.mustache b/templates/footer.mustache index e6f1ddc..3810e7c 100644 --- a/templates/footer.mustache +++ b/templates/footer.mustache @@ -24,18 +24,29 @@ * footerleftblocks - Code for the left footer region * footermiddleblocks - Code for the middle footer region * footerrightblocks - Code for the right footer region + * bcbttbutton - true if the setting bcbttbutton is enabled. Example context (json): { "footerblock3columns":true, "footerleftblocks": "<aside id='block-region-footer-left' class='block-region' data-blockregion='footer-left' data-droptarget='1'>This is the left footer region</aside>", "footermiddleblocks": "<aside id='block-region-footer-middle' class='block-region' data-blockregion='footer-middle' data-droptarget='1'>This is the middle footer region</aside>", - "footerrightblocks": "<aside id='block-region-footer-right' class='block-region' data-blockregion='footer-right' data-droptarget='1'>This is the right footer region</aside>" + "footerrightblocks": "<aside id='block-region-footer-right' class='block-region' data-blockregion='footer-right' data-droptarget='1'>This is the right footer region</aside>", + "bcbttbutton": true } }} {{! MODIFICATION: * Add footer blocks. + * Don't show Boost's core "Go to top" button if Boost Campus' "Back to top" button is enabled. }} +{{^bcbttbutton}} +<div id="goto-top-link"> + {{! go to top is sticky to footer so needs to be sibling }} + <a class="btn btn-light" role="button" href="#"> + {{#pix}} i/up, core, {{#str}} totop, theme_boost {{/str}}{{/pix}} + </a> +</div> +{{/bcbttbutton}} <footer id="page-footer" class="py-3 bg-dark text-light"> <div class="container-fluid"> <div class="row-fluid"> diff --git a/templates/footer.mustache.original b/templates/footer.mustache.original index 9827bbd..2655fd4 100644 --- a/templates/footer.mustache.original +++ b/templates/footer.mustache.original @@ -17,6 +17,12 @@ {{! Page footer. }} +<div id="goto-top-link"> + {{! go to top is sticky to footer so needs to be sibling }} + <a class="btn btn-light" role="button" href="#"> + {{#pix}} i/up, core, {{#str}} totop, theme_boost {{/str}}{{/pix}} + </a> +</div> <footer id="page-footer" class="py-3 bg-dark text-light"> <div class="container"> <div id="course-footer">{{{ output.course_footer }}}</div> diff --git a/tests/behat/theme_boost_campus_advanced_settings.feature b/tests/behat/theme_boost_campus_advanced_settings.feature index 28a96c9..2d32b5f 100644 --- a/tests/behat/theme_boost_campus_advanced_settings.feature +++ b/tests/behat/theme_boost_campus_advanced_settings.feature @@ -51,3 +51,27 @@ Feature: Configuring the theme_boost_campus plugin for the "Advanced settings" t And I am on "Course 1" course homepage with editing mode on Then I should see "Add a block" in the "#nav-drawer" "css_element" And "#block-region-side-pre" "css_element" should not exist + + @javascript + Scenario: Enable "Boost Campus "Back to top" button" + Given the following config values are set as admin: + | config | value | plugin | + | bcbttbutton | 1 | theme_boost_campus | + When I log in as "admin" + And I navigate to "Development > Purge caches" in site administration + And I press "Purge all caches" + Then "#back-to-top" "css_element" should exist + And "#page-footer" "css_element" should appear before "#back-to-top" "css_element" + And "#goto-top-link" "css_element" should not exist + + @javascript + Scenario: Counter check: Disable "Boost Campus "Back to top" button" + Given the following config values are set as admin: + | config | value | plugin | + | bcbttbutton | 0 | theme_boost_campus | + When I log in as "admin" + And I navigate to "Development > Purge caches" in site administration + And I press "Purge all caches" + Then "#goto-top-link" "css_element" should exist + And "#goto-top-link" "css_element" should appear before "#page-footer" "css_element" + And "#back-to-top" "css_element" should not exist diff --git a/version.php b/version.php index b18d8f8..78634d4 100644 --- a/version.php +++ b/version.php @@ -25,7 +25,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'theme_boost_campus'; -$plugin->version = 2020090101; +$plugin->version = 2020090102; $plugin->release = 'v3.8-r5'; $plugin->requires = 2020061502; $plugin->maturity = MATURITY_STABLE; -- GitLab