Skip to content

Commit

Permalink
MDL-39814 frontend: added options to disable new action menus
Browse files Browse the repository at this point in the history
Also:
 * Tidied up patch as per peer-reviews
  • Loading branch information
Sam Hemelryk committed Jul 30, 2013
1 parent 3665af7 commit 10fc156
Show file tree
Hide file tree
Showing 15 changed files with 65 additions and 36 deletions.
2 changes: 2 additions & 0 deletions admin/settings/appearance.php
Expand Up @@ -214,6 +214,8 @@
$setting->set_updatedcallback('js_reset_all_caches');
$temp->add($setting);
$temp->add(new admin_setting_configcheckbox('modchooserdefault', new lang_string('modchooserdefault', 'admin'), new lang_string('configmodchooserdefault', 'admin'), 1));
$temp->add(new admin_setting_configcheckbox('modeditingmenu', new lang_string('modeditingmenu', 'admin'), new lang_string('modeditingmenu_desc', 'admin'), 1));
$temp->add(new admin_setting_configcheckbox('blockeditingmenu', new lang_string('blockeditingmenu', 'admin'), new lang_string('blockeditingmenu_desc', 'admin'), 1));
$ADMIN->add('appearance', $temp);

// link to tag management interface
Expand Down
5 changes: 5 additions & 0 deletions course/renderer.php
Expand Up @@ -334,6 +334,8 @@ protected function course_modchooser_title($title, $identifier = null) {
* @return string
*/
public function course_section_cm_edit_actions($actions, cm_info $mod = null, $displayoptions = array()) {
global $CFG;

if (empty($actions)) {
return '';
}
Expand All @@ -351,6 +353,9 @@ public function course_section_cm_edit_actions($actions, cm_info $mod = null, $d
$menu->set_owner_selector($ownerselector);
$menu->set_contraint('.course-content');
$menu->set_alignment(action_menu::TL, action_menu::TR);
if (isset($CFG->modeditingmenu) && !$CFG->modeditingmenu) {
$menu->do_not_enhance();
}
foreach ($actions as $action) {
if ($action instanceof action_menu_link) {
$action->add_class('cm-edit-action');
Expand Down
2 changes: 1 addition & 1 deletion course/tests/behat/course_controls.feature
@@ -1,4 +1,4 @@
@core @core_course
@core @core_course @sam
Feature: Course activity controls works as expected
In order to manage my course's activities
As a teacher
Expand Down
24 changes: 12 additions & 12 deletions course/yui/toolboxes/toolboxes.js
Expand Up @@ -263,7 +263,7 @@ YUI.add('moodle-course-toolboxes', function(Y) {
}

// From the anchor we can get both the activity (added during initialisation) and the action being
// performed (added by the UI as a data attribute)
// performed (added by the UI as a data attribute).
var action = node.getData('action'),
activity = node.getData('activity');
if (!node.test('a') || !action || !activity) {
Expand Down Expand Up @@ -344,12 +344,12 @@ YUI.add('moodle-course-toolboxes', function(Y) {
'field' : 'indent',
'value' : newindent,
'id' : this.get_element_id(activity)
},
commands = activity.one(SELECTOR.COMMANDSPAN),
spinner = M.util.add_spinner(Y, commands).setStyles({
position: 'absolute',
top: 0
});
};
var commands = activity.one(SELECTOR.COMMANDSPAN);
var spinner = M.util.add_spinner(Y, commands).setStyles({
position: 'absolute',
top: 0
});
if (BODY.hasClass('dir-ltr')) {
spinner.setStyle('left', '100%');
} else {
Expand All @@ -361,7 +361,7 @@ YUI.add('moodle-course-toolboxes', function(Y) {
if (newindent == 0) {
button.addClass('hidden');
} else if (newindent == 1 && oldindent == 0) {
button.ancestor().one('> [data-action=moveleft]').removeClass('hidden');
button.ancestor('.menu').one('[data-action=moveleft]').removeClass('hidden');
}

// Handle massive indentation to match non-ajax display
Expand Down Expand Up @@ -458,7 +458,7 @@ YUI.add('moodle-course-toolboxes', function(Y) {
},

/**
* Handles the UI aspect of dimming the activity or resource
* Handles the UI aspect of dimming the activity or resource.
*
* @protected
* @method handle_resource_dim
Expand Down Expand Up @@ -581,7 +581,7 @@ YUI.add('moodle-course-toolboxes', function(Y) {
oldtitle = currenttitle.get('data'),
titletext = oldtitle,
thisevent,
anchor = instancename.ancestor('a'), // Grab the anchor so that we can swap it with the edit form
anchor = instancename.ancestor('a'),// Grab the anchor so that we can swap it with the edit form.
data = {
'class' : 'resource',
'field' : 'gettitle',
Expand Down Expand Up @@ -620,13 +620,13 @@ YUI.add('moodle-course-toolboxes', function(Y) {
// Focus and select the editor text
editor.focus().select();

// Cancel the edit if we lose focus or the escape key is pressed
// Cancel the edit if we lose focus or the escape key is pressed.
thisevent = editor.on('blur', this.edit_title_cancel, this, activity, false);
this.edittitleevents.push(thisevent);
thisevent = editor.on('key', this.edit_title_cancel, 'esc', this, activity, true);
this.edittitleevents.push(thisevent);

// Handle form submission
// Handle form submission.
thisevent = editform.on('submit', this.edit_title_submit, this, activity, oldtitle);
this.edittitleevents.push(thisevent);
},
Expand Down
4 changes: 4 additions & 0 deletions lang/en/admin.php
Expand Up @@ -74,6 +74,8 @@
$string['badwordsdefault'] = 'If the custom list is empty, a default list from the language pack will be used.';
$string['badwordslist'] = 'Custom bad words list';
$string['blockediplist'] = 'Blocked IP List';
$string['blockeditingmenu'] = 'Block editing menus';
$string['blockeditingmenu_desc'] = 'If enabled many of the block editing icons shown when editing is on will be displayed within a drop-down menu. This reduces the content on screen by hiding the icons until they are needed.';
$string['blockinstances'] = 'Instances';
$string['blockmultiple'] = 'Multiple';
$string['blockprotect'] = 'Protect instances';
Expand Down Expand Up @@ -728,6 +730,8 @@
$string['mobilecssurl'] = 'CSS';
$string['modchooserdefault'] = 'Activity chooser default';
$string['modeditdefaults'] = 'Default values for activity settings';
$string['modeditingmenu'] = 'Activitiy editing menus';
$string['modeditingmenu_desc'] = 'If enabled many of the activity editing icons shown when viewing a course with editing on will be displayed within a drop-down menu. This reduces the content on screen when editing a course by hiding the icons until they are needed.';
$string['modsettings'] = 'Manage activities';
$string['modulesecurity'] = 'Module security';
$string['multilangforceold'] = 'Force old multilang syntax: <span> without the class="multilang" and <lang>';
Expand Down
9 changes: 9 additions & 0 deletions lib/outputcomponents.php
Expand Up @@ -3274,6 +3274,15 @@ protected function get_align_string($align) {
public function set_contraint($ancestorselector) {
$this->attributessecondary['data-constraint'] = $ancestorselector;
}

/**
* If you call this method the action menu will be displayed but will not be enhanced.
*
* By not displaying the menu enhanced all items will be displayed in a single row.
*/
public function do_not_enhance() {
unset($this->attributes['data-enhance']);
}
}

/**
Expand Down
4 changes: 4 additions & 0 deletions lib/outputrenderers.php
Expand Up @@ -1033,6 +1033,7 @@ public function lang_menu() {
* @return string HTML fragment.
*/
public function block_controls($actions, $blockid = null) {
global $CFG;
if (empty($actions)) {
return '';
}
Expand All @@ -1041,6 +1042,9 @@ public function block_controls($actions, $blockid = null) {
$menu->set_owner_selector('#'.$blockid);
}
$menu->attributes['class'] .= ' block-control-actions commands';
if (isset($CFG->blockeditingmenu) && !$CFG->blockeditingmenu) {
$menu->do_not_enhance();
}
return $this->render($menu);
}

Expand Down
Expand Up @@ -191,7 +191,7 @@ ACTIONMENU.prototype = {
}

// Constrain X.
// First up if the width is more than the constrain its easily full width + full height
// First up if the width is more than the constrain its easily full width + full height.
if (nwidth > cwidth) {
// The width of the constraint.
newwidth = nwidth = cwidth;
Expand All @@ -208,7 +208,7 @@ ACTIONMENU.prototype = {
}

// Constrain Y.
// First up if the width is more than the constrain its easily full width + full height
// First up if the width is more than the constrain its easily full width + full height.
if (nheight > cheight) {
// The width of the constraint.
newheight = nheight = cheight;
Expand Down
Expand Up @@ -189,7 +189,7 @@ ACTIONMENU.prototype = {
}

// Constrain X.
// First up if the width is more than the constrain its easily full width + full height
// First up if the width is more than the constrain its easily full width + full height.
if (nwidth > cwidth) {
// The width of the constraint.
newwidth = nwidth = cwidth;
Expand All @@ -206,7 +206,7 @@ ACTIONMENU.prototype = {
}

// Constrain Y.
// First up if the width is more than the constrain its easily full width + full height
// First up if the width is more than the constrain its easily full width + full height.
if (nheight > cheight) {
// The width of the constraint.
newheight = nheight = cheight;
Expand Down
4 changes: 2 additions & 2 deletions lib/yui/src/actionmenu/js/actionmenu.js
Expand Up @@ -189,7 +189,7 @@ ACTIONMENU.prototype = {
}

// Constrain X.
// First up if the width is more than the constrain its easily full width + full height
// First up if the width is more than the constrain its easily full width + full height.
if (nwidth > cwidth) {
// The width of the constraint.
newwidth = nwidth = cwidth;
Expand All @@ -206,7 +206,7 @@ ACTIONMENU.prototype = {
}

// Constrain Y.
// First up if the width is more than the constrain its easily full width + full height
// First up if the width is more than the constrain its easily full width + full height.
if (nheight > cheight) {
// The width of the constraint.
newheight = nheight = cheight;
Expand Down
13 changes: 8 additions & 5 deletions theme/base/style/core.css
Expand Up @@ -1378,16 +1378,19 @@ div.badge .expireimage { width: 100px; height: 100px; left: 20px; top: 0px; }
.moodle-actionmenu > ul,
.moodle-actionmenu > ul > li {display: inline-block;}
.moodle-actionmenu ul {padding: 0;margin: 0;list-style-type: none;}
.moodle-actionmenu a.hidden {display: none;}
.moodle-actionmenu .toggle-display,
.moodle-actionmenu .menu-action-text {display: none;}

.jsenabled .block .editing_move {display: none;}
.jsenabled .moodle-actionmenu {display: block;}
.jsenabled .moodle-actionmenu .menu {display: none;}
.jsenabled .moodle-actionmenu .toggle-display {display: inline;opacity: 0.5;filter: alpha(opacity=50);}
.jsenabled .moodle-actionmenu[data-enhance] {display: block;}
.jsenabled .moodle-actionmenu[data-enhance] .menu {display: none;}
.jsenabled .moodle-actionmenu[data-enhance] .toggle-display {display: inline;opacity: 0.5;filter: alpha(opacity=50);}
.jsenabled .moodle-actionmenu[data-enhanced] .toggle-display {opacity: 1;filter: alpha(opacity=100);}
.jsenabled .moodle-actionmenu[data-enhanced] .menu-action-text {display: inline;}

.moodle-actionmenu[data-enhanced].show {position: relative;}
.moodle-actionmenu[data-enhanced].show .menu {position: absolute;z-index: 1000;display: block;background-color: #fff;border: 1px solid #ccc;-webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;-webkit-box-shadow: 5px 5px 20px 0 #666666;-moz-box-shadow: 5px 5px 20px 0 #666666;box-shadow: 5px 5px 20px 0 #666666;}
.moodle-actionmenu[data-enhanced].show .menu {position: absolute;text-align:left;z-index: 1000;display: block;background-color: #fff;border: 1px solid #ccc;-webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;-webkit-box-shadow: 5px 5px 20px 0 #666666;-moz-box-shadow: 5px 5px 20px 0 #666666;box-shadow: 5px 5px 20px 0 #666666;}
.moodle-actionmenu[data-enhanced].show .menu a {display: block;padding: 2px 1em 2px 0.5em;color: #333333;}
.moodle-actionmenu[data-enhanced].show .menu a:hover,
.moodle-actionmenu[data-enhanced].show .menu a:focus {color: #ffffff;background-color: #0088cc;}
Expand All @@ -1401,7 +1404,7 @@ div.badge .expireimage { width: 100px; height: 100px; left: 20px; top: 0px; }
.block .moodle-actionmenu {text-align: right;}

.dir-rtl .block .moodle-actionmenu {text-align: right;}
.dir-rtl .moodle-actionmenu[data-enhanced].show .menu {right: auto;left: 0;}
.dir-rtl .moodle-actionmenu[data-enhanced].show .menu {text-align: right;right: auto;left: 0;}
.dir-rtl .moodle-actionmenu[data-enhanced].show .menu .iconsmall {margin-right: 0;margin-left: 8px;}

.menu.align-tl-bl {top: 100%;left: 0;margin-top: 4px;}
Expand Down
2 changes: 1 addition & 1 deletion theme/base/style/course.css
Expand Up @@ -28,7 +28,7 @@
.dir-rtl .course-content .section .activity .activityinstance { padding-right: 0; padding-left: 3em;}
.sitetopic .section .activity .commands,
.course-content .section .activity .commands { white-space: nowrap; display: inline; }
.section .activity .moodle-actionmenu .iconsmall {ertical-align: baseline;width:16px;height:16px;width:1rem;height:1rem;padding:0 0.5em 0.3em;}
.section .activity .moodle-actionmenu .iconsmall {vertical-align: baseline;width:16px;height:16px;width:1rem;height:1rem;padding:0 0.5em 0.3em;}

.sitetopic .section li.activity,
.course-content .section li.activity {padding: .2em;}
Expand Down
20 changes: 11 additions & 9 deletions theme/bootstrapbase/less/moodle/core.less
Expand Up @@ -1933,7 +1933,7 @@ div.badge .expireimage {
.block .editing_move {
display:none;
}
.moodle-actionmenu {
.moodle-actionmenu[data-enhance] {
display: block;
.menu {
display:none;
Expand All @@ -1942,13 +1942,13 @@ div.badge .expireimage {
display: inline; /** JS is enabled, we'll be using it so return display to normal **/
.opacity(50);
}
&[data-enhanced] {
.toggle-display {
.opacity(100);
}
.menu-action-text {
display:inline;
}
}
.moodle-actionmenu[data-enhanced] {
.toggle-display {
.opacity(100);
}
.menu-action-text {
display:inline;
}
}
}
Expand All @@ -1961,6 +1961,7 @@ div.badge .expireimage {

display:block;
position: absolute;
text-align: left;
background-color: #fff;
border: 1px solid #ccc;
z-index:1000;
Expand All @@ -1984,7 +1985,7 @@ div.badge .expireimage {
}
}
a.hidden {
display: none;
display:none;
}
img {
vertical-align: middle;
Expand Down Expand Up @@ -2030,6 +2031,7 @@ div.badge .expireimage {
.dir-rtl {
.moodle-actionmenu[data-enhanced].show {
.menu {
text-align: right;
left: 0;
right: auto;
.iconsmall {
Expand Down
2 changes: 1 addition & 1 deletion theme/bootstrapbase/style/moodle.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion version.php
Expand Up @@ -29,7 +29,7 @@

defined('MOODLE_INTERNAL') || die();

$version = 2013072600.01; // YYYYMMDD = weekly release date of this DEV branch
$version = 2013072800.00; // YYYYMMDD = weekly release date of this DEV branch
// RR = release increments - 00 in DEV branches
// .XX = incremental changes

Expand Down

0 comments on commit 10fc156

Please sign in to comment.