Merge branch '48026-28' of git://github.com/samhemelryk/moodle
This commit is contained in:
@@ -3401,6 +3401,34 @@ class action_menu implements renderable {
|
||||
public function will_be_enhanced() {
|
||||
return isset($this->attributes['data-enhance']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets nowrap on items. If true menu items should not wrap lines if they are longer than the available space.
|
||||
*
|
||||
* This property can be useful when the action menu is displayed within a parent element that is either floated
|
||||
* or relatively positioned.
|
||||
* In that situation the width of the menu is determined by the width of the parent element which may not be large
|
||||
* enough for the menu items without them wrapping.
|
||||
* This disables the wrapping so that the menu takes on the width of the longest item.
|
||||
*
|
||||
* @param bool $value If true nowrap gets set, if false it gets removed. Defaults to true.
|
||||
*/
|
||||
public function set_nowrap_on_items($value = true) {
|
||||
$class = 'nowrap-items';
|
||||
if (!empty($this->attributes['class'])) {
|
||||
$pos = strpos($this->attributes['class'], $class);
|
||||
if ($value === true && $pos === false) {
|
||||
// The value is true and the class has not been set yet. Add it.
|
||||
$this->attributes['class'] .= ' '.$class;
|
||||
} else if ($value === false && $pos !== false) {
|
||||
// The value is false and the class has been set. Remove it.
|
||||
$this->attributes['class'] = substr($this->attributes['class'], $pos, strlen($class));
|
||||
}
|
||||
} else if ($value) {
|
||||
// The value is true and the class has not been set yet. Add it.
|
||||
$this->attributes['class'] = $class;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3044,6 +3044,7 @@ EOD;
|
||||
$returnstr
|
||||
);
|
||||
$am->set_alignment(action_menu::TR, action_menu::BR);
|
||||
$am->set_nowrap_on_items();
|
||||
if ($withlinks) {
|
||||
$navitemcount = count($opts->navitems);
|
||||
$idx = 0;
|
||||
|
||||
@@ -435,6 +435,9 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
$menu->set_constraint('.mod-quiz-edit-content');
|
||||
$trigger = html_writer::tag('span', get_string('add', 'quiz'), array('class' => 'add-menu'));
|
||||
$menu->set_menu_trigger($trigger);
|
||||
// The menu appears within an absolutely positioned element causing width problems.
|
||||
// Make sure no-wrap is set so that we don't get a squashed menu.
|
||||
$menu->set_nowrap_on_items(true);
|
||||
|
||||
// Disable the link if quiz has attempts.
|
||||
if (!$structure->can_be_edited()) {
|
||||
|
||||
@@ -556,10 +556,6 @@ table.quizreviewsummary td.cell {
|
||||
left: 0;
|
||||
}
|
||||
|
||||
#page-mod-quiz-edit .mod-quiz-edit-content .moodle-actionmenu[data-enhanced].show .menu a {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
#page-mod-quiz-edit .slotnumber {
|
||||
background-color: #D3D3D3;
|
||||
text-align: center;
|
||||
|
||||
@@ -2174,6 +2174,10 @@ img#persona_signin {
|
||||
&.align-bl-tr {bottom: 100%;left:100%;}
|
||||
&.align-br-tr {bottom: 100%;right: 0;margin-bottom: 4px;}
|
||||
}
|
||||
/** no wrap is set - prevent menu items from wrapping **/
|
||||
&.nowrap-items .menu > li {
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.block .moodle-actionmenu {
|
||||
|
||||
@@ -567,7 +567,6 @@ div#dock {
|
||||
}
|
||||
|
||||
a {
|
||||
white-space: nowrap;
|
||||
border-radius: 0;
|
||||
|
||||
&:focus {
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user