Skip to content
This repository has been archived by the owner on Dec 2, 2022. It is now read-only.

Commit

Permalink
Fix: #802.
Browse files Browse the repository at this point in the history
  • Loading branch information
gjb2048 committed Jan 25, 2017
1 parent 2b05629 commit c988cbf
Show file tree
Hide file tree
Showing 15 changed files with 107 additions and 61 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ New in 3.0.1.15
===============
- FIX: Issue #798: Slider title needs to support multi-lang filter.
- FIX: Issue #799: Message avatar overlap.
- FIX: Issue #802: My courses scroll not working.
- FIX: Issue #803: Embedded pdf files not displaying in IE 11.
- FIX: Course category multi-lang, ref: https://moodle.org/mod/forum/discuss.php?d=344426#p1389008.
- NEW: Issue #734: Unable to disable the new "page top" block region.
Expand Down
44 changes: 30 additions & 14 deletions classes/output/core_renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ protected function return_to_section() {
/**
* Defines the Moodle custom_menu
* @param string $custommenuitems
* @return render_custom_menu for $custommenu
* @return string Rendered custom menu.
*/
public function custom_menu($custommenuitems = '') {
global $CFG;
Expand All @@ -450,7 +450,7 @@ public function custom_menu($custommenuitems = '') {
$custommenuitems = $CFG->custommenuitems;
}
$custommenu = new custom_menu($custommenuitems, current_language());
return $this->render_custom_menu($custommenu);
return $this->render_the_custom_menu($custommenu, 'custom_menu', true);
}

/**
Expand Down Expand Up @@ -543,7 +543,7 @@ protected function render_custom_menu_item(custom_menu_item $menunode, $level =

/**
* Outputs the language menu
* @return custom_menu object
* @return string Rendered custom menu.
*/
public function custom_menu_language() {
global $CFG;
Expand Down Expand Up @@ -572,7 +572,7 @@ public function custom_menu_language() {
array('lang' => $langtype)), $langname);
}
}
return $this->render_custom_menu($langmenu);
return $this->render_the_custom_menu($langmenu, 'custom_menu_language');
}

protected static function timeaccesscompare($a, $b) {
Expand Down Expand Up @@ -603,7 +603,7 @@ protected static function timeaccesscompare($a, $b) {

/**
* Outputs the courses menu
* @return custom_menu object
* @return string Rendered custom menu.
*/
public function custom_menu_courses() {
global $CFG;
Expand Down Expand Up @@ -726,12 +726,12 @@ public function custom_menu_courses() {
}
}

$mycoursescatsubmenu = \theme_essential\toolbox::get_setting('mycoursescatsubmenu');
if ($courses) {
$mycoursesmax = \theme_essential\toolbox::get_setting('mycoursesmax');
if (!$mycoursesmax) {
$mycoursesmax = PHP_INT_MAX;
}
$mycoursescatsubmenu = \theme_essential\toolbox::get_setting('mycoursescatsubmenu');
if ($mycoursescatsubmenu) {
$enablecategoryicon = \theme_essential\toolbox::get_setting('enablecategoryicon');
$defaultcategoryicon = \theme_essential\toolbox::get_setting('defaultcategoryicon');
Expand Down Expand Up @@ -800,8 +800,10 @@ public function custom_menu_courses() {
$noenrolments = get_string('noenrolments', 'theme_essential');
$coursemenubranch->add('<em>' . $noenrolments . '</em>', new moodle_url('#'), $noenrolments);
}
return $this->render_the_custom_menu($coursemenu, 'custom_menu_courses', $mycoursescatsubmenu);
}
return $this->render_custom_menu($coursemenu);

return '';
}

/**
Expand Down Expand Up @@ -840,7 +842,7 @@ public function custom_menu_courses_add_course($branch, $course, $hasdisplayhidd

/**
* Outputs the alternative colours menu
* @return custom_menu object
* @return string Rendered custom menu.
*/
public function custom_menu_themecolours() {
$colourmenu = new custom_menu();
Expand Down Expand Up @@ -876,12 +878,12 @@ public function custom_menu_themecolours() {
}
}
}
return $this->render_custom_menu($colourmenu);
return $this->render_the_custom_menu($colourmenu, 'custom_menu_themecolours');
}

/**
* Outputs the Activity Stream menu
* @return custom_menu object
* @return string Rendered custom menu.
*/
public function custom_menu_activitystream() {
if (!isguestuser()) {
Expand Down Expand Up @@ -919,12 +921,23 @@ public function custom_menu_activitystream() {
array('id' => $this->page->course->id)));
}
}
return $this->render_custom_menu($activitystreammenu);
return $this->render_the_custom_menu($activitystreammenu, 'custom_menu_activitystream');
}
}
return '';
}

protected function render_the_custom_menu(custom_menu $custommenu, $id, $usessubmenus = false, $additionalclasses = '') {
if (\theme_essential\toolbox::get_setting('dropdownmenuscroll')) {
if ($usessubmenus) {
$additionalclasses .= ' dropdownsubmenuscroll';
} else {
$additionalclasses .= ' dropdownmenuscroll';
}
}
return '<div id="'.$id.'" class="custom_menu'.$additionalclasses.'">'.$this->render_custom_menu($custommenu).'</div>';
}

private function get_course_activities() {
// A copy of block_activity_modules.
$course = $this->page->course;
Expand Down Expand Up @@ -1330,7 +1343,7 @@ protected function render_user_picture(\user_picture $userpicture) {

/**
* Outputs the user menu.
* @return custom_menu object
* @return string Rendered custom menu.
*/
public function custom_menu_user() {
// Die if executed during install.
Expand Down Expand Up @@ -2041,8 +2054,11 @@ public function standard_footer_html() {
$output = parent::standard_footer_html();
$output .= html_writer::start_tag('div', array ('class' => 'themecredit')).
get_string('credit', 'theme_essential',
array('name' => html_writer::link('https://moodle.org/plugins/theme_essential', 'Essential', array('target' => '_blank')))).
html_writer::link('//about.me/gjbarnard', 'Gareth J Barnard', array('target' => '_blank')).html_writer::end_tag('div');
array('name' => html_writer::link('https://moodle.org/plugins/theme_essential', 'Essential', array(
'target' => '_blank',
'title' => get_string('download', 'theme_essential'))))).
html_writer::link('//about.me/gjbarnard', 'Gareth J Barnard', array(
'target' => '_blank', 'title' => get_string('aboutme', 'theme_essential'))).html_writer::end_tag('div');

return $output;
}
Expand Down
13 changes: 12 additions & 1 deletion classes/toolbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ static public function get_csswww() {
* Finds the given setting in the theme from the themes' configuration object.
* @param string $setting Setting name.
* @param string $format false|'format_text'|'format_html'.
* @param theme_config $theme null|theme_config object.
* @return any false|value of setting.
*/
static public function get_setting($setting, $format = false) {
Expand Down Expand Up @@ -767,6 +766,18 @@ static public function set_logodimensions($css, $logowidth, $logoheight) {
return $css;
}

static public function set_integer($css, $setting, $integer, $default) {
$tag = '[[setting:'.$setting.']]';
if (!($integer)) {
$replacement = $default;
} else {
$replacement = $integer;
}
$css = str_replace($tag, $replacement, $css);

return $css;
}

static public function set_pagewidth($css, $pagewidth) {
$tag = '[[setting:pagewidth]]';
$imagetag = '[[setting:pagewidthimage]]';
Expand Down
7 changes: 7 additions & 0 deletions lang/en/theme_essential.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@
$string['logodimerror'] = ' is invalid. Please state \'px\' or \'em\' immediately after the unit value and nothing before the unit value.';

$string['credit'] = 'The {$a->name} theme for Moodle is developed by ';
$string['download'] = 'Go to the download page';
$string['aboutme'] = 'About me';

$string['profilebarcustomtitle'] = 'Profile bar custom block title';
$string['profilebarcustomtitledesc'] = 'Title for custom profile bar block.';
Expand Down Expand Up @@ -692,6 +694,11 @@
$string['navbarabove'] = 'Navbar above the header';
$string['navbarbelow'] = 'Navbar below the header';

$string['dropdownmenuscroll'] = 'Scrollbars on the dropdown menus';
$string['dropdownmenuscrolldesc'] = 'Have a scrollbar on the dropdown menu where the height of the menu is limited.';
$string['dropdownmenumaxheight'] = 'Dropdown menu maximum height';
$string['dropdownmenumaxheightdesc'] = 'Dropdown menu maximum height when scrollbars are enabled. Between {$a->lower} and {$a->upper} pixels.';

$string['usesiteicon'] = 'Use site icon';
$string['usesiteicondesc'] = 'Use the site icon if there is no logo.';

Expand Down
28 changes: 9 additions & 19 deletions layout/tiles/navbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,15 @@
</div>
</div>
<div id='essentialmenus' class="nav-collapse collapse pull-<?php echo ($left) ? 'left' : 'right'; ?>">
<div id="custom_menu_language">
<?php echo $OUTPUT->custom_menu_language(); ?>
</div>
<div id="custom_menu_courses">
<?php echo $OUTPUT->custom_menu_courses(); ?>
</div>
<?php if ($colourswitcher) { ?>
<div id="custom_menu_themecolours">
<?php echo $OUTPUT->custom_menu_themecolours(); ?>
</div>
<?php
}
?>
<div id="custom_menu">
<?php echo $OUTPUT->custom_menu(); ?>
</div>
<div id="custom_menu_activitystream">
<?php echo $OUTPUT->custom_menu_activitystream(); ?>
</div>
<?php
echo $OUTPUT->custom_menu_language();
echo $OUTPUT->custom_menu_courses();
if ($colourswitcher) {
echo $OUTPUT->custom_menu_themecolours();
}
echo $OUTPUT->custom_menu();
echo $OUTPUT->custom_menu_activitystream();
?>
</div>
</div>
</div>
Expand Down
24 changes: 8 additions & 16 deletions less/essential/navigation.less
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@
div.dropdown-menu > ul {
list-style: inherit;
margin: 0;
max-height: 384px;
overflow-y: auto;
white-space: nowrap;
li a {
display: block;
}
#custom_menu &, #custom_menu_courses & {
max-height: none;
overflow-y: visible;
}
}

.dropdownmenuscroll div.dropdown-menu > ul,
.dropdownsubmenuscroll li.dropdown-submenu > ul {
max-height: 384px;
overflow-y: auto;
}

.navbar {
Expand Down Expand Up @@ -87,11 +87,7 @@ div.dropdown-menu > ul {
}
}

#custom_menu_language,
#custom_menu_courses,
#custom_menu_themecolours,
#custom_menu_activitystream,
#custom_menu {
.custom_menu {
display: inline-block;
vertical-align: top;
}
Expand Down Expand Up @@ -320,11 +316,7 @@ div.dropdown-menu > ul {
@media (max-width: @navbarCollapseWidth) {
.navbar {
.navbar-inner {
#custom_menu_language,
#custom_menu_courses,
#custom_menu_themecolours,
#custom_menu_activitystream,
#custom_menu {
.custom_menu {
display: inline;
}
}
Expand Down
6 changes: 1 addition & 5 deletions less/essential/responsive.less
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@
.nav > li {
float: left;
}
#custom_menu_language,
#custom_menu_courses,
#custom_menu_themecolours,
#custom_menu_activitystream,
#custom_menu {
.custom_menu {
vertical-align: top;
clear: both;
width: 100%;
Expand Down
5 changes: 5 additions & 0 deletions less/essential/settings/navigation.less
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,9 @@
}
}

.dropdownmenuscroll div.dropdown-menu > ul,
.dropdownsubmenuscroll li.dropdown-submenu > ul {
max-height: ~"[[setting:dropdownmenumaxheight]]px";
}

/* @end */
4 changes: 4 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,10 @@ function theme_essential_process_css($css, $theme) {
$logoheight = \theme_essential\toolbox::get_setting('logoheight');
$css = \theme_essential\toolbox::set_logodimensions($css, $logowidth, $logoheight);

// Set the dropdown menu maximum height.
$dropdownmenumaxheight = \theme_essential\toolbox::get_setting('dropdownmenumaxheight');
$css = \theme_essential\toolbox::set_integer($css, 'dropdownmenumaxheight', $dropdownmenumaxheight, 384);

// Set the background image for the header.
$headerbackground = \theme_essential\toolbox::setting_file_url('headerbackground', 'headerbackground');
$css = \theme_essential\toolbox::set_headerbackground($css, $headerbackground);
Expand Down
20 changes: 20 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,26 @@
$setting->set_updatedcallback('theme_reset_all_caches');
$essentialsettingsheader->add($setting);

// Scrollbars on the dropdown menus.
$name = 'theme_essential/dropdownmenuscroll';
$title = get_string('dropdownmenuscroll', 'theme_essential');
$description = get_string('dropdownmenuscrolldesc', 'theme_essential');
$default = false;
$setting = new admin_setting_configcheckbox($name, $title, $description, $default, true, false);
$essentialsettingsheader->add($setting);

// Dropdown menu maximum height.
$name = 'theme_essential/dropdownmenumaxheight';
$title = get_string('dropdownmenumaxheight', 'theme_essential');
$default = 384;
$lower = 100;
$upper = 800;
$description = get_string('dropdownmenumaxheightdesc', 'theme_essential',
array('lower' => $lower, 'upper' => $upper));
$setting = new essential_admin_setting_configinteger($name, $title, $description, $default, $lower, $upper);
$setting->set_updatedcallback('theme_reset_all_caches');
$essentialsettingsheader->add($setting);

// Use the site icon if there is no logo.
$name = 'theme_essential/usesiteicon';
$title = get_string('usesiteicon', 'theme_essential');
Expand Down
2 changes: 1 addition & 1 deletion style/essential-rtl.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions style/essential-rtl_ie9.css

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions style/essential-settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,10 @@ button.website:focus {
border-top-color: [[setting:themenavcolor]];
}
}
.dropdownmenuscroll div.dropdown-menu > ul,
.dropdownsubmenuscroll li.dropdown-submenu > ul {
max-height: [[setting:dropdownmenumaxheight]]px;
}
/* @end */
/* @group Print Styling */
@media print {
Expand Down
2 changes: 1 addition & 1 deletion style/essential.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions style/essential_ie9.css

Large diffs are not rendered by default.

0 comments on commit c988cbf

Please sign in to comment.