Commit 854a647e authored by Jetha Chan's avatar Jetha Chan
Browse files

MDL-45893 user_menu: responsive approach; fixed minor issues

parent 6da0e4cf
......@@ -91,14 +91,13 @@ class behat_auth extends behat_base {
return $steps;
}
// If it is needed, it expands the navigation bar with the 'Log out' link.
if ($clicknavbar = $this->get_expand_navbar_step()) {
array_unshift($steps, $clicknavbar);
} else {
// Otherwise we need to expand the the user menu.
$xpath ="//div[@class='usermenu']//a[contains(concat(' ', @class, ' '), ' toggle-display ')]";
array_unshift($steps, new When('I click on "'.$xpath.'" "xpath_element"'));
}
// There is no longer any need to worry about whether the navigation
// bar needs to be expanded; user_menu now lives outside the
// hamburger.
// However, the user menu *always* needs to be expanded.
$xpath ="//div[@class='usermenu']//a[contains(concat(' ', @class, ' '), ' toggle-display ')]";
array_unshift($steps, new When('I click on "'.$xpath.'" "xpath_element"'));
return $steps;
}
......
......@@ -1896,6 +1896,7 @@ $string['userdescription_help'] = 'This box enables you to enter some text about
$string['userdetails'] = 'User details';
$string['userfiles'] = 'User files';
$string['userlist'] = 'User list';
$string['usermenu'] = 'User menu';
$string['username'] = 'Username';
$string['usernameemail'] = 'Username / email';
$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.
* @return string HTML fragment.
*/
public function user_menu($user = null, $withlinks = false) {
public function user_menu($user = null, $withlinks = null) {
global $USER, $CFG;
require_once($CFG->dirroot . '/user/lib.php');
if (is_null($user)) {
$user = $USER;
......@@ -2926,6 +2927,12 @@ EOD;
$withlinks = empty($this->page->layout_options['nologinlinks']);
}
// Add a class for when $withlinks is false.
$usermenuclasses = 'usermenu';
if (!$withlinks) {
$usermenuclasses .= ' withoutlinks';
}
$returnstr = "";
// If during initial install, return the empty return string.
......@@ -2941,10 +2948,14 @@ EOD;
if (!$loginpage) {
$returnstr .= " (<a href=\"$loginurl\">" . get_string('login') . '</a>)';
}
return html_writer::tag(
'span',
$returnstr
return html_writer::div(
html_writer::span(
$returnstr,
'login'
),
$usermenuclasses
);
}
// If logged in as a guest user, show a string to that effect.
......@@ -2953,14 +2964,17 @@ EOD;
if (!$loginpage && $withlinks) {
$returnstr .= " (<a href=\"$loginurl\">".get_string('login').'</a>)';
}
return html_writer::tag(
'span',
$returnstr
return html_writer::div(
html_writer::span(
$returnstr,
'login'
),
$usermenuclasses
);
}
// Get some navigation opts.
require_once($CFG->dirroot . '/user/lib.php');
$opts = user_get_user_navigation_info($user, $this->page, $this->page->course);
$avatarclasses = "avatars";
......@@ -3015,16 +3029,11 @@ EOD;
}
$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'
);
// Add a class for when $withlinks is false.
$usermenuclasses = 'usermenu';
if (!$withlinks) {
$usermenuclasses .= ' withoutlinks';
}
// Create a divider (well, a filler).
$divider = new action_menu_filler();
$divider->primary = false;
......@@ -3032,7 +3041,7 @@ EOD;
$am = new action_menu();
$am->initialise_js($this->page);
$am->set_menu_trigger(html_writer::span(
"User menu",
get_string('usermenu', 'moodle'),
"accesshide"
));
$am->set_alignment(action_menu::TR, action_menu::BR);
......@@ -3042,7 +3051,7 @@ EOD;
foreach ($opts->navitems as $key => $value) {
$pix = null;
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(
$value->url,
......
......@@ -46,11 +46,11 @@ echo $OUTPUT->doctype() ?>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<?php echo $OUTPUT->user_menu(); ?>
<div class="nav-collapse collapse">
<?php echo $OUTPUT->custom_menu(); ?>
<ul class="nav pull-right">
<li><?php echo $OUTPUT->page_heading_menu(); ?></li>
<li class="navbar-text"><?php echo $OUTPUT->user_menu() ?></li>
</ul>
</div>
</div>
......
......@@ -47,11 +47,11 @@ echo $OUTPUT->doctype() ?>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<?php echo $OUTPUT->user_menu(); ?>
<div class="nav-collapse collapse">
<?php echo $OUTPUT->custom_menu(); ?>
<ul class="nav pull-right">
<li><?php echo $OUTPUT->page_heading_menu(); ?></li>
<li class="navbar-text"><?php echo $OUTPUT->user_menu() ?></li>
</ul>
</div>
</div>
......
......@@ -52,11 +52,11 @@ echo $OUTPUT->doctype() ?>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<?php echo $OUTPUT->user_menu(); ?>
<div class="nav-collapse collapse">
<?php echo $OUTPUT->custom_menu(); ?>
<ul class="nav pull-right">
<li><?php echo $OUTPUT->page_heading_menu(); ?></li>
<li class="navbar-text"><?php echo $OUTPUT->user_menu(); ?></li>
</ul>
</div>
</div>
......
......@@ -343,12 +343,19 @@ div#dock {
// Usermenu
.usermenu {
font-size: 14px;
&.withoutlinks {
.withoutlinks {
display: none;
}
}
font-size: 14px;
.login {
color: @navbarText;
line-height: 40px;
a {
color: @navbarLinkColor;
}
}
> .moodle-actionmenu > .menubar {
display: block;
margin: -40px 0px 2px 0px;
......@@ -363,13 +370,15 @@ div#dock {
height: 40px;
}
.toggle-display {
color: #777;
color: @navbarLinkColor;
outline: none;
}
.userbutton {
height: 40px;
line-height: 40px;
.avatars{
display: inline-block;
height: 37px;
height: 36px;
vertical-align: middle;
margin-right: 6px;
......@@ -435,33 +444,57 @@ div#dock {
}
}
.jsenabled .navbar-inverse {
.usermenu:hover {
.usermenu {
.login {
color: @navbarInverseText;
a {
color: @navbarInverseLinkColor;
&:hover {
color: @navbarInverseLinkColorHover;
}
}
}
.toggle-display {
color: @navbarInverseLinkColor;
}
.userinfo .usertext {
color: @navbarInverseLinkColorHover;
color: @navbarInverseLinkColor;
.meta {
color: @navbarInverseText;
.value {
color: @navbarInverseLinkColorHover;
color: @navbarInverseLinkColor;
}
}
}
.moodle-actionmenu[data-enhanced] .toggle-display.textmenu {
.caret {
border-top-color: @navbarInverseLinkColorHover;
&:hover {
.userinfo .usertext {
color: @navbarInverseLinkColorHover;
.meta {
color: @navbarInverseText;
.value {
color: @navbarInverseLinkColorHover;
}
}
}
.moodle-actionmenu[data-enhanced] .toggle-display.textmenu {
.caret {
border-top-color: @navbarInverseLinkColorHover;
}
}
}
}
}
.dir-ltr {
.usermenu {
float: right;
.userinfo {
padding-left: 20px;
}
.userbutton {
margin-right: 4px;
padding-right: 16px;
padding-right: 8px;
.avatars{
margin-right: 6px;
margin-left: 6px;
}
}
> .moodle-actionmenu > .menubar li a {
......@@ -479,11 +512,12 @@ div#dock {
.dir-rtl {
.usermenu {
float: left;
.userbutton {
margin-left: 4px;
padding-left: 16px;
padding-left: 8px;
.avatars{
margin-left: 6px;
margin-right: 6px;
}
}
> .moodle-actionmenu > .menubar li a {
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -49,11 +49,11 @@ echo $OUTPUT->doctype() ?>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<?php echo $OUTPUT->user_menu(); ?>
<div class="nav-collapse collapse">
<?php echo $OUTPUT->custom_menu(); ?>
<ul class="nav pull-right">
<li><?php echo $OUTPUT->page_heading_menu(); ?></li>
<li class="navbar-text"><?php echo $OUTPUT->user_menu() ?></li>
</ul>
</div>
</div>
......
......@@ -50,11 +50,11 @@ echo $OUTPUT->doctype() ?>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<?php echo $OUTPUT->user_menu(); ?>
<div class="nav-collapse collapse">
<?php echo $OUTPUT->custom_menu(); ?>
<ul class="nav pull-right">
<li><?php echo $OUTPUT->page_heading_menu(); ?></li>
<li class="navbar-text"><?php echo $OUTPUT->user_menu() ?></li>
</ul>
</div>
</div>
......
......@@ -61,11 +61,11 @@ echo $OUTPUT->doctype() ?>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<?php echo $OUTPUT->user_menu(); ?>
<div class="nav-collapse collapse">
<?php echo $OUTPUT->custom_menu(); ?>
<ul class="nav pull-right">
<li><?php echo $OUTPUT->page_heading_menu(); ?></li>
<li class="navbar-text"><?php echo $OUTPUT->user_menu() ?></li>
</ul>
</div>
</div>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment