MDL-40975 ActionMenu: Add support for fillers in primary menus
This is required to maintain horizontal alignment of primary menus in rows.
This commit is contained in:
+27
-23
@@ -2044,30 +2044,34 @@ function course_get_cm_edit_actions(cm_info $mod, $indent = -1, $sr = null) {
|
||||
}
|
||||
|
||||
// Groupmode.
|
||||
if ($hasmanageactivities && !$mod->coursegroupmodeforce && plugin_supports('mod', $mod->modname, FEATURE_GROUPS, 0)) {
|
||||
if ($mod->effectivegroupmode == SEPARATEGROUPS) {
|
||||
$nextgroupmode = VISIBLEGROUPS;
|
||||
$grouptitle = $str->groupsseparate;
|
||||
$actionname = 'groupsseparate';
|
||||
$groupimage = 't/groups';
|
||||
} else if ($mod->effectivegroupmode == VISIBLEGROUPS) {
|
||||
$nextgroupmode = NOGROUPS;
|
||||
$grouptitle = $str->groupsvisible;
|
||||
$actionname = 'groupsvisible';
|
||||
$groupimage = 't/groupv';
|
||||
} else {
|
||||
$nextgroupmode = SEPARATEGROUPS;
|
||||
$grouptitle = $str->groupsnone;
|
||||
$actionname = 'groupsnone';
|
||||
$groupimage = 't/groupn';
|
||||
}
|
||||
if ($hasmanageactivities && !$mod->coursegroupmodeforce) {
|
||||
if (plugin_supports('mod', $mod->modname, FEATURE_GROUPS, 0)) {
|
||||
if ($mod->effectivegroupmode == SEPARATEGROUPS) {
|
||||
$nextgroupmode = VISIBLEGROUPS;
|
||||
$grouptitle = $str->groupsseparate;
|
||||
$actionname = 'groupsseparate';
|
||||
$groupimage = 't/groups';
|
||||
} else if ($mod->effectivegroupmode == VISIBLEGROUPS) {
|
||||
$nextgroupmode = NOGROUPS;
|
||||
$grouptitle = $str->groupsvisible;
|
||||
$actionname = 'groupsvisible';
|
||||
$groupimage = 't/groupv';
|
||||
} else {
|
||||
$nextgroupmode = SEPARATEGROUPS;
|
||||
$grouptitle = $str->groupsnone;
|
||||
$actionname = 'groupsnone';
|
||||
$groupimage = 't/groupn';
|
||||
}
|
||||
|
||||
$actions[$actionname] = new action_menu_link_primary(
|
||||
new moodle_url($baseurl, array('id' => $mod->id, 'groupmode' => $nextgroupmode)),
|
||||
new pix_icon($groupimage, $grouptitle, 'moodle', array('class' => 'iconsmall', 'title' => '')),
|
||||
$grouptitle,
|
||||
array('class' => 'editing_'. $actionname, 'data-action' => $actionname, 'data-nextgroupmode' => $nextgroupmode)
|
||||
);
|
||||
$actions[$actionname] = new action_menu_link_primary(
|
||||
new moodle_url($baseurl, array('id' => $mod->id, 'groupmode' => $nextgroupmode)),
|
||||
new pix_icon($groupimage, $grouptitle, 'moodle', array('class' => 'iconsmall', 'title' => '')),
|
||||
$grouptitle,
|
||||
array('class' => 'editing_'. $actionname, 'data-action' => $actionname, 'data-nextgroupmode' => $nextgroupmode)
|
||||
);
|
||||
} else {
|
||||
$actions['nogroupsupport'] = new action_menu_filler();
|
||||
}
|
||||
}
|
||||
|
||||
// Assign.
|
||||
|
||||
@@ -3182,7 +3182,7 @@ class action_menu implements renderable {
|
||||
* @param action_menu_link|pix_icon|string $action
|
||||
*/
|
||||
public function add($action) {
|
||||
if ($action instanceof action_menu_link) {
|
||||
if ($action instanceof action_link) {
|
||||
if ($action->primary) {
|
||||
$this->add_primary_action($action);
|
||||
} else {
|
||||
@@ -3371,6 +3371,29 @@ class action_menu implements renderable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An action menu filler
|
||||
*
|
||||
* @package core
|
||||
* @category output
|
||||
* @copyright 2013 Andrew Nicols
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class action_menu_filler extends action_link implements renderable {
|
||||
|
||||
/**
|
||||
* True if this is a primary action. False if not.
|
||||
* @var bool
|
||||
*/
|
||||
public $primary = true;
|
||||
|
||||
/**
|
||||
* Constructs the object.
|
||||
*/
|
||||
public function __construct() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An action menu action
|
||||
*
|
||||
|
||||
@@ -1161,6 +1161,16 @@ class core_renderer extends renderer_base {
|
||||
return html_writer::tag('a', $icon.$text, $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a primary action_menu_filler item.
|
||||
*
|
||||
* @param action_menu_link_filler $action
|
||||
* @return string HTML fragment
|
||||
*/
|
||||
protected function render_action_menu_filler(action_menu_filler $action) {
|
||||
return html_writer::span(' ', 'filler');
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a primary action_menu_link item.
|
||||
*
|
||||
|
||||
@@ -32,6 +32,14 @@
|
||||
.course-content .section .activity .activityinstance form { display: inline;}
|
||||
.sitetopic .section .activity .activityinstance,
|
||||
.course-content .section .activity .activityinstance { padding-right: 1em; }
|
||||
.course-content .section .activity .filler {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
margin: 4px;
|
||||
display: inline-block;
|
||||
vertical-align: text-bottom;
|
||||
}
|
||||
|
||||
.dir-rtl .sitetopic .section .activity .activityinstance,
|
||||
.dir-rtl .course-content .section .activity .activityinstance { padding-right: 0; padding-left: 3em;}
|
||||
.sitetopic .section .activity .commands,
|
||||
|
||||
@@ -51,6 +51,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
.filler {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
padding: 0.3em;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.activity.editor_displayed {
|
||||
a.editing_title,
|
||||
.moodle-actionmenu {
|
||||
|
||||
Reference in New Issue
Block a user