mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-45893 user_menu: responsive approach; fixed minor issues
This commit is contained in:
parent
6da0e4cfff
commit
854a647e62
11 changed files with 91 additions and 48 deletions
|
@ -91,14 +91,13 @@ class behat_auth extends behat_base {
|
||||||
return $steps;
|
return $steps;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it is needed, it expands the navigation bar with the 'Log out' link.
|
// There is no longer any need to worry about whether the navigation
|
||||||
if ($clicknavbar = $this->get_expand_navbar_step()) {
|
// bar needs to be expanded; user_menu now lives outside the
|
||||||
array_unshift($steps, $clicknavbar);
|
// hamburger.
|
||||||
} else {
|
|
||||||
// Otherwise we need to expand the the user menu.
|
// However, the user menu *always* needs to be expanded.
|
||||||
$xpath ="//div[@class='usermenu']//a[contains(concat(' ', @class, ' '), ' toggle-display ')]";
|
$xpath ="//div[@class='usermenu']//a[contains(concat(' ', @class, ' '), ' toggle-display ')]";
|
||||||
array_unshift($steps, new When('I click on "'.$xpath.'" "xpath_element"'));
|
array_unshift($steps, new When('I click on "'.$xpath.'" "xpath_element"'));
|
||||||
}
|
|
||||||
|
|
||||||
return $steps;
|
return $steps;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1896,6 +1896,7 @@ $string['userdescription_help'] = 'This box enables you to enter some text about
|
||||||
$string['userdetails'] = 'User details';
|
$string['userdetails'] = 'User details';
|
||||||
$string['userfiles'] = 'User files';
|
$string['userfiles'] = 'User files';
|
||||||
$string['userlist'] = 'User list';
|
$string['userlist'] = 'User list';
|
||||||
|
$string['usermenu'] = 'User menu';
|
||||||
$string['username'] = 'Username';
|
$string['username'] = 'Username';
|
||||||
$string['usernameemail'] = 'Username / email';
|
$string['usernameemail'] = 'Username / email';
|
||||||
$string['usernameemailmatch'] = 'The username and email address do not relate to the same user';
|
$string['usernameemailmatch'] = 'The username and email address do not relate to the same user';
|
||||||
|
|
|
@ -2912,8 +2912,9 @@ EOD;
|
||||||
* @param bool $withlinks true if a dropdown should be built.
|
* @param bool $withlinks true if a dropdown should be built.
|
||||||
* @return string HTML fragment.
|
* @return string HTML fragment.
|
||||||
*/
|
*/
|
||||||
public function user_menu($user = null, $withlinks = false) {
|
public function user_menu($user = null, $withlinks = null) {
|
||||||
global $USER, $CFG;
|
global $USER, $CFG;
|
||||||
|
require_once($CFG->dirroot . '/user/lib.php');
|
||||||
|
|
||||||
if (is_null($user)) {
|
if (is_null($user)) {
|
||||||
$user = $USER;
|
$user = $USER;
|
||||||
|
@ -2926,6 +2927,12 @@ EOD;
|
||||||
$withlinks = empty($this->page->layout_options['nologinlinks']);
|
$withlinks = empty($this->page->layout_options['nologinlinks']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add a class for when $withlinks is false.
|
||||||
|
$usermenuclasses = 'usermenu';
|
||||||
|
if (!$withlinks) {
|
||||||
|
$usermenuclasses .= ' withoutlinks';
|
||||||
|
}
|
||||||
|
|
||||||
$returnstr = "";
|
$returnstr = "";
|
||||||
|
|
||||||
// If during initial install, return the empty return string.
|
// If during initial install, return the empty return string.
|
||||||
|
@ -2941,10 +2948,14 @@ EOD;
|
||||||
if (!$loginpage) {
|
if (!$loginpage) {
|
||||||
$returnstr .= " (<a href=\"$loginurl\">" . get_string('login') . '</a>)';
|
$returnstr .= " (<a href=\"$loginurl\">" . get_string('login') . '</a>)';
|
||||||
}
|
}
|
||||||
return html_writer::tag(
|
return html_writer::div(
|
||||||
'span',
|
html_writer::span(
|
||||||
$returnstr
|
$returnstr,
|
||||||
|
'login'
|
||||||
|
),
|
||||||
|
$usermenuclasses
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If logged in as a guest user, show a string to that effect.
|
// If logged in as a guest user, show a string to that effect.
|
||||||
|
@ -2953,14 +2964,17 @@ EOD;
|
||||||
if (!$loginpage && $withlinks) {
|
if (!$loginpage && $withlinks) {
|
||||||
$returnstr .= " (<a href=\"$loginurl\">".get_string('login').'</a>)';
|
$returnstr .= " (<a href=\"$loginurl\">".get_string('login').'</a>)';
|
||||||
}
|
}
|
||||||
return html_writer::tag(
|
|
||||||
'span',
|
return html_writer::div(
|
||||||
$returnstr
|
html_writer::span(
|
||||||
|
$returnstr,
|
||||||
|
'login'
|
||||||
|
),
|
||||||
|
$usermenuclasses
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get some navigation opts.
|
// Get some navigation opts.
|
||||||
require_once($CFG->dirroot . '/user/lib.php');
|
|
||||||
$opts = user_get_user_navigation_info($user, $this->page, $this->page->course);
|
$opts = user_get_user_navigation_info($user, $this->page, $this->page->course);
|
||||||
|
|
||||||
$avatarclasses = "avatars";
|
$avatarclasses = "avatars";
|
||||||
|
@ -3015,16 +3029,11 @@ EOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
$returnstr .= html_writer::span(
|
$returnstr .= html_writer::span(
|
||||||
html_writer::span($avatarcontents, $avatarclasses) . html_writer::span($usertextcontents, 'usertext'),
|
html_writer::span($usertextcontents, 'usertext') .
|
||||||
|
html_writer::span($avatarcontents, $avatarclasses),
|
||||||
'userbutton'
|
'userbutton'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add a class for when $withlinks is false.
|
|
||||||
$usermenuclasses = 'usermenu';
|
|
||||||
if (!$withlinks) {
|
|
||||||
$usermenuclasses .= ' withoutlinks';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a divider (well, a filler).
|
// Create a divider (well, a filler).
|
||||||
$divider = new action_menu_filler();
|
$divider = new action_menu_filler();
|
||||||
$divider->primary = false;
|
$divider->primary = false;
|
||||||
|
@ -3032,7 +3041,7 @@ EOD;
|
||||||
$am = new action_menu();
|
$am = new action_menu();
|
||||||
$am->initialise_js($this->page);
|
$am->initialise_js($this->page);
|
||||||
$am->set_menu_trigger(html_writer::span(
|
$am->set_menu_trigger(html_writer::span(
|
||||||
"User menu",
|
get_string('usermenu', 'moodle'),
|
||||||
"accesshide"
|
"accesshide"
|
||||||
));
|
));
|
||||||
$am->set_alignment(action_menu::TR, action_menu::BR);
|
$am->set_alignment(action_menu::TR, action_menu::BR);
|
||||||
|
@ -3042,7 +3051,7 @@ EOD;
|
||||||
foreach ($opts->navitems as $key => $value) {
|
foreach ($opts->navitems as $key => $value) {
|
||||||
$pix = null;
|
$pix = null;
|
||||||
if (isset($value->pix)) {
|
if (isset($value->pix)) {
|
||||||
$pix = new pix_icon($value->pix, $value->title, null);
|
$pix = new pix_icon($value->pix, $value->title, null, array('class' => 'iconsmall'));
|
||||||
}
|
}
|
||||||
$al = new action_menu_link_secondary(
|
$al = new action_menu_link_secondary(
|
||||||
$value->url,
|
$value->url,
|
||||||
|
|
|
@ -46,11 +46,11 @@ echo $OUTPUT->doctype() ?>
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
</a>
|
</a>
|
||||||
|
<?php echo $OUTPUT->user_menu(); ?>
|
||||||
<div class="nav-collapse collapse">
|
<div class="nav-collapse collapse">
|
||||||
<?php echo $OUTPUT->custom_menu(); ?>
|
<?php echo $OUTPUT->custom_menu(); ?>
|
||||||
<ul class="nav pull-right">
|
<ul class="nav pull-right">
|
||||||
<li><?php echo $OUTPUT->page_heading_menu(); ?></li>
|
<li><?php echo $OUTPUT->page_heading_menu(); ?></li>
|
||||||
<li class="navbar-text"><?php echo $OUTPUT->user_menu() ?></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -47,11 +47,11 @@ echo $OUTPUT->doctype() ?>
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
</a>
|
</a>
|
||||||
|
<?php echo $OUTPUT->user_menu(); ?>
|
||||||
<div class="nav-collapse collapse">
|
<div class="nav-collapse collapse">
|
||||||
<?php echo $OUTPUT->custom_menu(); ?>
|
<?php echo $OUTPUT->custom_menu(); ?>
|
||||||
<ul class="nav pull-right">
|
<ul class="nav pull-right">
|
||||||
<li><?php echo $OUTPUT->page_heading_menu(); ?></li>
|
<li><?php echo $OUTPUT->page_heading_menu(); ?></li>
|
||||||
<li class="navbar-text"><?php echo $OUTPUT->user_menu() ?></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -52,11 +52,11 @@ echo $OUTPUT->doctype() ?>
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
</a>
|
</a>
|
||||||
|
<?php echo $OUTPUT->user_menu(); ?>
|
||||||
<div class="nav-collapse collapse">
|
<div class="nav-collapse collapse">
|
||||||
<?php echo $OUTPUT->custom_menu(); ?>
|
<?php echo $OUTPUT->custom_menu(); ?>
|
||||||
<ul class="nav pull-right">
|
<ul class="nav pull-right">
|
||||||
<li><?php echo $OUTPUT->page_heading_menu(); ?></li>
|
<li><?php echo $OUTPUT->page_heading_menu(); ?></li>
|
||||||
<li class="navbar-text"><?php echo $OUTPUT->user_menu(); ?></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -343,12 +343,19 @@ div#dock {
|
||||||
|
|
||||||
// Usermenu
|
// Usermenu
|
||||||
.usermenu {
|
.usermenu {
|
||||||
|
font-size: 14px;
|
||||||
&.withoutlinks {
|
&.withoutlinks {
|
||||||
.withoutlinks {
|
.withoutlinks {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
font-size: 14px;
|
.login {
|
||||||
|
color: @navbarText;
|
||||||
|
line-height: 40px;
|
||||||
|
a {
|
||||||
|
color: @navbarLinkColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
> .moodle-actionmenu > .menubar {
|
> .moodle-actionmenu > .menubar {
|
||||||
display: block;
|
display: block;
|
||||||
margin: -40px 0px 2px 0px;
|
margin: -40px 0px 2px 0px;
|
||||||
|
@ -363,13 +370,15 @@ div#dock {
|
||||||
height: 40px;
|
height: 40px;
|
||||||
}
|
}
|
||||||
.toggle-display {
|
.toggle-display {
|
||||||
color: #777;
|
color: @navbarLinkColor;
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
.userbutton {
|
.userbutton {
|
||||||
|
height: 40px;
|
||||||
|
line-height: 40px;
|
||||||
.avatars{
|
.avatars{
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
height: 37px;
|
height: 36px;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
margin-right: 6px;
|
margin-right: 6px;
|
||||||
|
|
||||||
|
@ -435,7 +444,29 @@ div#dock {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.jsenabled .navbar-inverse {
|
.jsenabled .navbar-inverse {
|
||||||
.usermenu:hover {
|
.usermenu {
|
||||||
|
.login {
|
||||||
|
color: @navbarInverseText;
|
||||||
|
a {
|
||||||
|
color: @navbarInverseLinkColor;
|
||||||
|
&:hover {
|
||||||
|
color: @navbarInverseLinkColorHover;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.toggle-display {
|
||||||
|
color: @navbarInverseLinkColor;
|
||||||
|
}
|
||||||
|
.userinfo .usertext {
|
||||||
|
color: @navbarInverseLinkColor;
|
||||||
|
.meta {
|
||||||
|
color: @navbarInverseText;
|
||||||
|
.value {
|
||||||
|
color: @navbarInverseLinkColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&:hover {
|
||||||
.userinfo .usertext {
|
.userinfo .usertext {
|
||||||
color: @navbarInverseLinkColorHover;
|
color: @navbarInverseLinkColorHover;
|
||||||
.meta {
|
.meta {
|
||||||
|
@ -452,16 +483,18 @@ div#dock {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
.dir-ltr {
|
.dir-ltr {
|
||||||
.usermenu {
|
.usermenu {
|
||||||
|
float: right;
|
||||||
.userinfo {
|
.userinfo {
|
||||||
padding-left: 20px;
|
padding-left: 20px;
|
||||||
}
|
}
|
||||||
.userbutton {
|
.userbutton {
|
||||||
margin-right: 4px;
|
margin-right: 4px;
|
||||||
padding-right: 16px;
|
padding-right: 8px;
|
||||||
.avatars{
|
.avatars{
|
||||||
margin-right: 6px;
|
margin-left: 6px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
> .moodle-actionmenu > .menubar li a {
|
> .moodle-actionmenu > .menubar li a {
|
||||||
|
@ -479,11 +512,12 @@ div#dock {
|
||||||
|
|
||||||
.dir-rtl {
|
.dir-rtl {
|
||||||
.usermenu {
|
.usermenu {
|
||||||
|
float: left;
|
||||||
.userbutton {
|
.userbutton {
|
||||||
margin-left: 4px;
|
margin-left: 4px;
|
||||||
padding-left: 16px;
|
padding-left: 8px;
|
||||||
.avatars{
|
.avatars{
|
||||||
margin-left: 6px;
|
margin-right: 6px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
> .moodle-actionmenu > .menubar li a {
|
> .moodle-actionmenu > .menubar li a {
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -49,11 +49,11 @@ echo $OUTPUT->doctype() ?>
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
</a>
|
</a>
|
||||||
|
<?php echo $OUTPUT->user_menu(); ?>
|
||||||
<div class="nav-collapse collapse">
|
<div class="nav-collapse collapse">
|
||||||
<?php echo $OUTPUT->custom_menu(); ?>
|
<?php echo $OUTPUT->custom_menu(); ?>
|
||||||
<ul class="nav pull-right">
|
<ul class="nav pull-right">
|
||||||
<li><?php echo $OUTPUT->page_heading_menu(); ?></li>
|
<li><?php echo $OUTPUT->page_heading_menu(); ?></li>
|
||||||
<li class="navbar-text"><?php echo $OUTPUT->user_menu() ?></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -50,11 +50,11 @@ echo $OUTPUT->doctype() ?>
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
</a>
|
</a>
|
||||||
|
<?php echo $OUTPUT->user_menu(); ?>
|
||||||
<div class="nav-collapse collapse">
|
<div class="nav-collapse collapse">
|
||||||
<?php echo $OUTPUT->custom_menu(); ?>
|
<?php echo $OUTPUT->custom_menu(); ?>
|
||||||
<ul class="nav pull-right">
|
<ul class="nav pull-right">
|
||||||
<li><?php echo $OUTPUT->page_heading_menu(); ?></li>
|
<li><?php echo $OUTPUT->page_heading_menu(); ?></li>
|
||||||
<li class="navbar-text"><?php echo $OUTPUT->user_menu() ?></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -61,11 +61,11 @@ echo $OUTPUT->doctype() ?>
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
</a>
|
</a>
|
||||||
|
<?php echo $OUTPUT->user_menu(); ?>
|
||||||
<div class="nav-collapse collapse">
|
<div class="nav-collapse collapse">
|
||||||
<?php echo $OUTPUT->custom_menu(); ?>
|
<?php echo $OUTPUT->custom_menu(); ?>
|
||||||
<ul class="nav pull-right">
|
<ul class="nav pull-right">
|
||||||
<li><?php echo $OUTPUT->page_heading_menu(); ?></li>
|
<li><?php echo $OUTPUT->page_heading_menu(); ?></li>
|
||||||
<li class="navbar-text"><?php echo $OUTPUT->user_menu() ?></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue