Skip to content

Commit

Permalink
Review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
abias committed Nov 13, 2023
1 parent 515fdff commit 4ff4d02
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 54 deletions.
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Changes

### Unreleased

* 2023-11-12 - Improvement: Option to suppress footer button, solves #444.
* 2023-11-12 - Improvement: Option to suppress footer (circle containing the question mark) button, solves #444.

### v4.3-r2

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ Whatever you add to this textarea will be displayed at the end of a page, in the

###### Footer

With these settings, you can show where to show or whether to suppress the footer (circle containing the question mark) button.
With these settings, you can control whether to show or to suppress the footer (circle containing the question mark) button at the bottom of the page.

#### Tab "Static pages"

Expand Down
13 changes: 6 additions & 7 deletions lang/en/theme_boost_union.php
Original file line number Diff line number Diff line change
Expand Up @@ -441,14 +441,13 @@
$string['footnotesetting_desc'] = 'Whatever you add to this textarea will be displayed at the end of a page, in the footer (not the floating footer) on every page which uses the layouts "drawers", "columns2" or "login". Content in this area could be for example the copyright, the terms of use or the name of your organisation. <br/> If you want to remove the footnote again, just empty the text area.';
// ... Section: Footer.
$string['footerheading'] = 'Footer';
// ... ... Setting: Footer.
// ... ... Setting: Enable footer.
$string['enablefooterbutton'] = 'Enable footer';
$string['enablefooterbutton_desc'] = 'With "footer", the circle containing the question mark at the bottom of the page is meant.<br />Upon click, the user is presented with an overlay. Depending on the site configuration the links
Help and documentation, Services and support, Contact site support, Login information, Reset user tour on this page, Data retention summary, Get the mobile app, Policies and Powered by Moodle could be shown.<br />With this setting it is possible to choose on which device to show or entirely suppress this footer button.';
$string['enablefooterbuttonboth'] = 'Desktop and mobile';
$string['enablefooterbuttondesktop'] = 'Desktop only';
$string['enablefooterbuttonmobile'] = 'Mobile only';
$string['enablefooterbuttonhidden'] = 'Hidden';
$string['enablefooterbutton_desc'] = 'With "footer", the circle containing the question mark at the bottom of the page is meant.<br />Upon click, the user is presented with an overlay. Depending on the site configuration Moodle shows several links (like "Help and documentation" or "Data retention summary") are shown in this overlay.<br />With this setting, you can control whether to show or to suppress the footer button at the bottom of the page.';
$string['enablefooterbuttonboth'] = 'Enable on desktop and mobile';
$string['enablefooterbuttondesktop'] = 'Enable on desktop, hide on mobile';
$string['enablefooterbuttonmobile'] = 'Enable on mobile only, hide on desktop';
$string['enablefooterbuttonhidden'] = 'Hide on all devices';

// Settings: Static pages tab.
$string['staticpagestab'] = 'Static pages';
Expand Down
14 changes: 5 additions & 9 deletions layout/includes/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,11 @@

defined('MOODLE_INTERNAL') || die();

// Require the necessary libraries.
require_once($CFG->dirroot.'/theme/boost_union/locallib.php');
$footersetting = get_config('theme_boost_union', 'enablefooterbutton');

$config = get_config('theme_boost_union');

// If the footerbutton is enabled.
$footerquestionmark = isset($config->enablefooterbutton) ? $config->enablefooterbutton :
THEME_BOOST_UNION_SETTING_ENABLEFOOTER_BOTH;

if ($footerquestionmark != THEME_BOOST_UNION_SETTING_ENABLEFOOTER_HIDDEN) {
// If the footer button is enabled.
$footerquestionmark = isset($footersetting) ? $footersetting : THEME_BOOST_UNION_SETTING_ENABLEFOOTER_ALL;
if ($footerquestionmark != THEME_BOOST_UNION_SETTING_ENABLEFOOTER_NONE) {
// Add marker to show the footer button to templatecontext.
$templatecontext['footerbutton'] = true;
}
33 changes: 4 additions & 29 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@
define('THEME_BOOST_UNION_SETTING_OUTSIDEREGIONSWITH_COURSECONTENTWIDTH', 'coursecontentwidth');
define('THEME_BOOST_UNION_SETTING_OUTSIDEREGIONSWITH_HEROWIDTH', 'herowidth');

define('THEME_BOOST_UNION_SETTING_ENABLEFOOTER_BOTH', 'enablefooterbuttonall');
define('THEME_BOOST_UNION_SETTING_ENABLEFOOTER_ALL', 'enablefooterbuttonall');
define('THEME_BOOST_UNION_SETTING_ENABLEFOOTER_DESKTOP', 'enablefooterbuttondesktop');
define('THEME_BOOST_UNION_SETTING_ENABLEFOOTER_MOBILE', 'enablefooterbuttonmobile');
define('THEME_BOOST_UNION_SETTING_ENABLEFOOTER_HIDDEN', 'enablefooterbuttonhidden');
define('THEME_BOOST_UNION_SETTING_ENABLEFOOTER_NONE', 'enablefooterbuttonnone');

/**
* Returns the main SCSS content.
Expand Down Expand Up @@ -294,33 +294,8 @@ function theme_boost_union_get_extra_scss($theme) {
// Setting: Mark external links.
$content .= theme_boost_union_get_scss_to_mark_external_links($theme);

// If the footerbutton is enabled.
$footerquestionmark = get_config('theme_boost_union', 'enablefooterbutton');

switch ($footerquestionmark) {
case THEME_BOOST_UNION_SETTING_ENABLEFOOTER_BOTH:
$content .= '@media (max-width: 575px) { #page-footer [data-region="footer-container-popover"] .btn-footer-popover ' .
'{ display: block !important; } }' . PHP_EOL;
break;
case THEME_BOOST_UNION_SETTING_ENABLEFOOTER_DESKTOP:
$content .= '@media (min-width: 576px) { #page-footer [data-region="footer-container-popover"] .btn-footer-popover ' .
'{ display: block !important; } }' . PHP_EOL;
$content .= '#page-footer .footer-content-popover.container { display: none !important; }' . PHP_EOL;
break;
case THEME_BOOST_UNION_SETTING_ENABLEFOOTER_MOBILE:
$content .= '@media (min-width: 576px) { #page-footer [data-region="footer-container-popover"] .btn-footer-popover ' .
'{ display: none !important; } }' . PHP_EOL;
$content .= '@media (max-width: 575px) { #page-footer [data-region="footer-container-popover"] .btn-footer-popover ' .
'{ display: block !important; bottom: 5rem; } }' . PHP_EOL;
$content .= '#page-footer .footer-content-popover.container { display: none !important; }' . PHP_EOL;
break;
default:
$content .= '@media (max-width: 575px) { #page-footer [data-region="footer-container-popover"] .btn-footer-popover ' .
'{ display: none !important; } }' . PHP_EOL;
$content .= '@media (max-width: 575px) { #page-footer .footer-content-popover.container ' .
'{ display: none !important; } }' . PHP_EOL;
break;
}
// Setting: Footer button.
$content .= theme_boost_union_get_scss_to_hide_footer_button($theme);

return $content;
}
Expand Down
63 changes: 63 additions & 0 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1394,3 +1394,66 @@ function theme_boost_union_get_scss_to_mark_external_links($theme) {
}
return $scss;
}

/**
* Returns the SCSS code to show or hide the footer button.
*
* @param theme_config $theme The theme config object.
* @return string
*/
function theme_boost_union_get_scss_to_hide_footer_button($theme) {
// Initialize SCSS snippet.
$scss = '';

// Add SCSS code depending on the footer button setting.
switch ($theme->settings->enablefooterbutton) {
case THEME_BOOST_UNION_SETTING_ENABLEFOOTER_ALL:
$scss .= '@include media-breakpoint-down(xs) {
#page-footer [data-region="footer-container-popover"] .btn-footer-popover {
display: block !important;
}
}';
break;
case THEME_BOOST_UNION_SETTING_ENABLEFOOTER_DESKTOP:
$scss .= '@media (min-width: 576px) {
#page-footer [data-region="footer-container-popover"] .btn-footer-popover {
display: block !important;
}
}';
$scss .= '#page-footer .footer-content-popover.container {
display: none !important;
}';
break;
case THEME_BOOST_UNION_SETTING_ENABLEFOOTER_MOBILE:
$scss .= '@include media-breakpoint-up(xs) {
#page-footer [data-region="footer-container-popover"] .btn-footer-popover {
display: none !important;
}
}';
$scss .= '@include media-breakpoint-down(xs) {
#page-footer [data-region="footer-container-popover"] .btn-footer-popover {
display: block !important;
bottom: 5rem;
}
}';
$scss .= '#page-footer .footer-content-popover.container {
display: none !important;
}';
break;
case THEME_BOOST_UNION_SETTING_ENABLEFOOTER_NONE:
default:
$scss .= '@include media-breakpoint-down(xs) {
#page-footer [data-region="footer-container-popover"] .btn-footer-popover {
display: none !important;
}
}';
$scss .= '@include media-breakpoint-down(xs) {
#page-footer .footer-content-popover.container {
display: none !important;
}
}';
break;
}

return $scss;
}
8 changes: 7 additions & 1 deletion settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -1381,6 +1381,12 @@
$setting = new admin_setting_confightmleditor($name, $title, $description, '');
$tab->add($setting);

// Create footer heading.
$name = 'theme_boost_union/footerheading';
$title = get_string('footerheading', 'theme_boost_union', null, true);
$setting = new admin_setting_heading($name, $title, null);
$tab->add($setting);

// Setting: Footer.
$enablefooterbuttonoptions = [
'enablefooterbuttonboth' => get_string('enablefooterbuttonboth', 'theme_boost_union', null, true),
Expand All @@ -1392,7 +1398,7 @@
$title = get_string('enablefooterbutton', 'theme_boost_union', null, true);
$description = get_string('enablefooterbutton_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configselect($name, $title, $description, 'enablefooterbuttonboth',
$enablefooterbuttonoptions);
$enablefooterbuttonoptions);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);

Expand Down
10 changes: 5 additions & 5 deletions templates/theme_boost/footer.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@
{{#pix}}t/messages-o, core{{/pix}}
</button>
{{/output.has_communication_links}}
{{# footerbutton }}
<button class="btn btn-icon bg-secondary icon-no-margin btn-footer-popover" data-action="footer-popover" aria-label="{{#str}}showfooter, theme_boost{{/str}}">
{{#pix}}e/question, core{{/pix}}
</button>
{{/ footerbutton }}
{{#footerbutton }}
<button class="btn btn-icon bg-secondary icon-no-margin btn-footer-popover" data-action="footer-popover" aria-label="{{#str}}showfooter, theme_boost{{/str}}">
{{#pix}}e/question, core{{/pix}}
</button>
{{/footerbutton }}
</div>
<div class="footer-content-popover container" data-region="footer-content-popover">
{{#output.has_communication_links}}
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();

$plugin->component = 'theme_boost_union';
$plugin->version = 2023102003;
$plugin->version = 2023102004;
$plugin->release = 'v4.3-r2';
$plugin->requires = 2023100900;
$plugin->supported = [403, 403];
Expand Down

0 comments on commit 4ff4d02

Please sign in to comment.