mirror of
https://github.com/moodle/moodle.git
synced 2025-04-24 18:04:43 +02:00
MDL-39814 frontend: pre-integration fixes:
* Fixed IE8 display of icons. * Fixed blocks using course renderer. * Fixed behat tests. * codecheckers fixes * Removed alt from icons with descriptive text * Tweaked actionmenu initialisation for performance
This commit is contained in:
parent
10fc156933
commit
ea5a01fbe5
blocks
course
lib
theme/bootstrapbase
@ -59,7 +59,8 @@ class block_site_main_menu extends block_list {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/// slow & hacky editing mode
|
||||
// Slow & hacky editing mode.
|
||||
/** @var core_course_renderer $courserenderer */
|
||||
$courserenderer = $this->page->get_renderer('core', 'course');
|
||||
$ismoving = ismoving($course->id);
|
||||
course_create_sections_if_missing($course, 0);
|
||||
@ -72,7 +73,7 @@ class block_site_main_menu extends block_list {
|
||||
$strcancel= get_string('cancel');
|
||||
$stractivityclipboard = $USER->activitycopyname;
|
||||
}
|
||||
/// Casting $course->modinfo to string prevents one notice when the field is null
|
||||
// Casting $course->modinfo to string prevents one notice when the field is null.
|
||||
$editbuttons = '';
|
||||
|
||||
if ($ismoving) {
|
||||
@ -90,7 +91,7 @@ class block_site_main_menu extends block_list {
|
||||
if (!$ismoving) {
|
||||
$actions = course_get_cm_edit_actions($mod, -1);
|
||||
$editbuttons = html_writer::tag('div',
|
||||
$courserenderer->course_section_cm_edit_actions($actions),
|
||||
$courserenderer->course_section_cm_edit_actions($actions, $mod),
|
||||
array('class' => 'buttons'));
|
||||
} else {
|
||||
$editbuttons = '';
|
||||
|
@ -62,7 +62,8 @@ class block_social_activities extends block_list {
|
||||
}
|
||||
|
||||
|
||||
/// slow & hacky editing mode
|
||||
// Slow & hacky editing mode.
|
||||
/** @var core_course_renderer $courserenderer */
|
||||
$courserenderer = $this->page->get_renderer('core', 'course');
|
||||
$ismoving = ismoving($course->id);
|
||||
$modinfo = get_fast_modinfo($course);
|
||||
@ -74,7 +75,7 @@ class block_social_activities extends block_list {
|
||||
$strcancel= get_string('cancel');
|
||||
$stractivityclipboard = $USER->activitycopyname;
|
||||
}
|
||||
/// Casting $course->modinfo to string prevents one notice when the field is null
|
||||
// Casting $course->modinfo to string prevents one notice when the field is null.
|
||||
$editbuttons = '';
|
||||
|
||||
if ($ismoving) {
|
||||
@ -92,7 +93,7 @@ class block_social_activities extends block_list {
|
||||
if (!$ismoving) {
|
||||
$actions = course_get_cm_edit_actions($mod, -1);
|
||||
$editbuttons = '<br />'.
|
||||
$courserenderer->course_section_cm_edit_actions($actions);
|
||||
$courserenderer->course_section_cm_edit_actions($actions, $mod);
|
||||
} else {
|
||||
$editbuttons = '';
|
||||
}
|
||||
|
@ -744,11 +744,11 @@ class dndupload_ajax_processor {
|
||||
$resp->content = $mod->get_content();
|
||||
$resp->elementid = 'module-'.$mod->id;
|
||||
$actions = course_get_cm_edit_actions($mod, 0, $mod->sectionnum);
|
||||
$resp->commands = ' '. $courserenderer->course_section_cm_edit_actions($actions);
|
||||
$resp->commands = ' '. $courserenderer->course_section_cm_edit_actions($actions, $mod);
|
||||
$resp->onclick = $mod->get_on_click();
|
||||
$resp->visible = $mod->visible;
|
||||
|
||||
// if using groupings, then display grouping name
|
||||
// If using groupings, then display grouping name.
|
||||
if (!empty($mod->groupingid) && has_capability('moodle/course:managegroups', $this->context)) {
|
||||
$groupings = groups_get_all_groupings($this->course->id);
|
||||
$resp->groupingname = format_string($groupings[$mod->groupingid]->name);
|
||||
|
@ -1,4 +1,4 @@
|
||||
@core @core_course @sam
|
||||
@core @core_course
|
||||
Feature: Course activity controls works as expected
|
||||
In order to manage my course's activities
|
||||
As a teacher
|
||||
|
@ -919,27 +919,27 @@ class action_link implements renderable {
|
||||
/**
|
||||
* @var moodle_url Href url
|
||||
*/
|
||||
var $url;
|
||||
public $url;
|
||||
|
||||
/**
|
||||
* @var string Link text HTML fragment
|
||||
*/
|
||||
var $text;
|
||||
public $text;
|
||||
|
||||
/**
|
||||
* @var array HTML attributes
|
||||
*/
|
||||
var $attributes;
|
||||
public $attributes;
|
||||
|
||||
/**
|
||||
* @var array List of actions attached to link
|
||||
*/
|
||||
var $actions;
|
||||
public $actions;
|
||||
|
||||
/**
|
||||
* @var pix_icon Optional pix icon to render with the link
|
||||
*/
|
||||
var $icon;
|
||||
public $icon;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -3071,13 +3071,13 @@ class action_menu implements renderable {
|
||||
protected $instance = 0;
|
||||
|
||||
/**
|
||||
* An array of primary actions. Please use {@see action_menu::add_primary_action()} to add actions.
|
||||
* An array of primary actions. Please use {@link action_menu::add_primary_action()} to add actions.
|
||||
* @var array
|
||||
*/
|
||||
protected $primaryactions = array();
|
||||
|
||||
/**
|
||||
* An array of secondary actions. Please use {@see action_menu::add_secondary_action()} to add actions.
|
||||
* An array of secondary actions. Please use {@link action_menu::add_secondary_action()} to add actions.
|
||||
* @var array
|
||||
*/
|
||||
protected $secondaryactions = array();
|
||||
@ -3128,6 +3128,7 @@ class action_menu implements renderable {
|
||||
'aria-labelledby' => 'action-menu-toggle-'.$this->instance,
|
||||
'role' => 'menu'
|
||||
);
|
||||
$this->set_alignment(self::TR, self::BR);
|
||||
foreach ($actions as $action) {
|
||||
$this->add($action);
|
||||
}
|
||||
@ -3150,7 +3151,7 @@ class action_menu implements renderable {
|
||||
/**
|
||||
* Adds an action to this action menu.
|
||||
*
|
||||
* @param $action
|
||||
* @param action_menu_link|pix_icon|string $action
|
||||
*/
|
||||
public function add($action) {
|
||||
if ($action instanceof action_menu_link) {
|
||||
@ -3243,8 +3244,15 @@ class action_menu implements renderable {
|
||||
* @param int $button One of action_menu::TL, action_menu::TR, action_menu::BL, action_menu::BR.
|
||||
*/
|
||||
public function set_alignment($dialogue, $button) {
|
||||
if (isset($this->attributessecondary['data-align'])) {
|
||||
// We've already got one set, lets remove the old class so as to avoid troubles.
|
||||
$class = $this->attributessecondary['class'];
|
||||
$search = 'align-'.$this->attributessecondary['data-align'];
|
||||
$this->attributessecondary['class'] = str_replace($search, '', $class);
|
||||
}
|
||||
$align = $this->get_align_string($dialogue) . '-' . $this->get_align_string($button);
|
||||
$this->attributessecondary['data-align'] = $align;
|
||||
$this->attributessecondary['class'] .= ' align-'.$align;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3255,11 +3263,16 @@ class action_menu implements renderable {
|
||||
*/
|
||||
protected function get_align_string($align) {
|
||||
switch ($align) {
|
||||
case self::TL : return 'tl';
|
||||
case self::TR : return 'tr';
|
||||
case self::BL : return 'bl';
|
||||
case self::BR : return 'br';
|
||||
default : return 'tl';
|
||||
case self::TL :
|
||||
return 'tl';
|
||||
case self::TR :
|
||||
return 'tr';
|
||||
case self::BL :
|
||||
return 'bl';
|
||||
case self::BR :
|
||||
return 'br';
|
||||
default :
|
||||
return 'tl';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1098,39 +1098,42 @@ class core_renderer extends renderer_base {
|
||||
*/
|
||||
protected function render_action_menu_link(action_menu_link $action) {
|
||||
|
||||
$iconrendered = false;
|
||||
|
||||
$comparetoalt = '';
|
||||
$text = '';
|
||||
if ($action->icon) {
|
||||
$icon = $action->icon;
|
||||
if ($action->primary) {
|
||||
$action->attributes['title'] = $action->text;
|
||||
}
|
||||
$text .= $this->render($icon);
|
||||
$iconrendered = true;
|
||||
}
|
||||
|
||||
if (!$iconrendered || $action->primary === false) {
|
||||
if (!$action->icon || $action->primary === false) {
|
||||
$text .= html_writer::start_tag('span', array('class'=>'menu-action-text'));
|
||||
if ($action->text instanceof renderable) {
|
||||
$text .= $this->render($action->text);
|
||||
} else {
|
||||
$text .= $action->text;
|
||||
$comparetoalt = $action->text;
|
||||
}
|
||||
$text .= html_writer::end_tag('span');
|
||||
}
|
||||
|
||||
$icon = '';
|
||||
if ($action->icon) {
|
||||
$icon = $action->icon;
|
||||
if ($action->primary) {
|
||||
$action->attributes['title'] = $action->text;
|
||||
}
|
||||
if ($icon->attributes['alt'] === $comparetoalt) {
|
||||
$icon->attributes['alt'] = ' ';
|
||||
}
|
||||
$icon = $this->render($icon);
|
||||
}
|
||||
|
||||
// A disabled link is rendered as formatted text.
|
||||
if (!empty($action->attributes['disabled'])) {
|
||||
// Do not use div here due to nesting restriction in xhtml strict.
|
||||
return html_writer::tag('span', $text, array('class'=>'currentlink', 'role' => 'menuitem'));
|
||||
return html_writer::tag('span', $icon.$text, array('class'=>'currentlink', 'role' => 'menuitem'));
|
||||
}
|
||||
|
||||
$attributes = $action->attributes;
|
||||
unset($action->attributes['disabled']);
|
||||
$attributes['href'] = $action->url;
|
||||
|
||||
return html_writer::tag('a', $text, $attributes);
|
||||
return html_writer::tag('a', $icon.$text, $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,13 +68,16 @@ ACTIONMENU.prototype = {
|
||||
var defaultalign = this.get('align').join('-');
|
||||
Y.all(SELECTOR.MENU).each(function() {
|
||||
var menucontent = this.one(SELECTOR.MENUCONTENT),
|
||||
toggle = this.one(SELECTOR.TOGGLE),
|
||||
align = menucontent.getData('align') || defaultalign;
|
||||
align;
|
||||
if (!menucontent) {
|
||||
return false;
|
||||
}
|
||||
toggle.set('aria-haspopup', true);
|
||||
menucontent.set('aria-hidden', true).addClass('align-'+align);
|
||||
align = menucontent.getData('align') || defaultalign;
|
||||
this.one(SELECTOR.TOGGLE).set('aria-haspopup', true);
|
||||
menucontent.set('aria-hidden', true);
|
||||
if (!menucontent.hasClass('align-'+align)) {
|
||||
menucontent.addClass('align-'+align);
|
||||
}
|
||||
if (menucontent.hasChildNodes()) {
|
||||
this.setAttribute('data-enhanced', '1');
|
||||
}
|
||||
@ -176,7 +179,6 @@ ACTIONMENU.prototype = {
|
||||
newleft = null,
|
||||
newtop = null;
|
||||
|
||||
|
||||
if (selector) {
|
||||
selector = node.ancestor(selector);
|
||||
}
|
||||
@ -276,5 +278,4 @@ M.core.actionmenu.init = M.core.actionmenu.init || function(params) {
|
||||
M.core.actionmenu.instance = M.core.actionmenu.instance || new ACTIONMENU(params);
|
||||
};
|
||||
|
||||
|
||||
}, '@VERSION@', {"requires": ["base", "event"]});
|
||||
|
@ -1 +1 @@
|
||||
YUI.add("moodle-core-actionmenu",function(e,t){var n=e.one(e.config.doc.body),r={MENUSHOWN:"action-menu-shown"},i={MENU:".moodle-actionmenu[data-enhance=moodle-core-actionmenu]",MENUCONTENT:".menu[data-rel=menu-content]",TOGGLE:".toggle-display"},s,o={TL:"tl",TR:"tr",BL:"bl",BR:"br"};s=function(){s.superclass.constructor.apply(this,arguments)},s.prototype={dialogue:null,events:[],owner:null,initializer:function(){var t=this.get("align").join("-");e.all(i.MENU).each(function(){var e=this.one(i.MENUCONTENT),n=this.one(i.TOGGLE),r=e.getData("align")||t;if(!e)return!1;n.set("aria-haspopup",!0),e.set("aria-hidden",!0).addClass("align-"+r),e.hasChildNodes()&&this.setAttribute("data-enhanced","1")}),n.delegate("click",this.toggleMenu,i.MENU+" "+i.TOGGLE,this),n.delegate("key",this.toggleMenu,"enter,space",i.MENU+" "+i.TOGGLE,this)},hideMenu:function(){this.dialogue&&(this.dialogue.removeClass("show"),this.dialogue.one(i.MENUCONTENT).set("aria-hidden",!0),this.dialogue=null),this.owner&&(this.owner.removeClass(r.MENUSHOWN),this.owner=null);for(var e in this.events)this.events[e].detach&&this.events[e].detach();this.events=[]},toggleMenu:function(e){e.halt(!0),this.hideMenu(),this.showMenu(e.target.ancestor(i.MENU)),this.events.push(n.on("key",this.hideMenu,"esc",this)),this.events.push(n.on("click",this.hideIfOutside,this)),this.events.push(n.delegate("focus",this.hideIfOutside,"*",this))},hideIfOutside:function(e){!e.target.test(i.MENU)&&!e.target.ancestor(i.MENU)&&this.hideMenu()},showMenu:function(e){var t=e.getData("owner"),n=e.one(i.MENUCONTENT);return this.owner=t?e.ancestor(t):null,this.dialogue=e,e.addClass("show"),this.owner.addClass(r.MENUSHOWN),this.constrain(n.set("aria-hidden",!1)),!0},constrain:function(e){var t=e.getData("constraint"),n=e.getX(),r=e.getY(),i=e.get("offsetWidth"),s=e.get("offsetHeight"),o=0,u=0,a,f,l=null,c=null,h=null,p=null;t&&(t=e.ancestor(t)),t?(a=t.get("offsetWidth"),f=t.get("offsetHeight"),o=t.getX(),u=t.getY()):(a=e.get("docWidth"),f=e.get("docHeight")),i>a?(l=i=a,h=n=o):n<o?h=n=o:n+i>o+a&&(h=o+a-i),s>f?(c=s=f,p=r=u):r<u?p=r=u:r+s>u+f&&(p=u+f-s),h!==null&&e.setX(h),p!==null&&e.setY(p),l!==null&&e.setStyle("width",l.toString()+"px"),c!==null&&e.setStyle("height",c.toString()+"px")}},e.extend(s,e.Base,s.prototype,{NAME:"moodle-core-actionmenu",ATTRS:{align:{value:[o.TR,o.BR]}}}),M.core=M.core||{},M.core.actionmenu=M.core.actionmenu||{},M.core.actionmenu.init=M.core.actionmenu.init||function(e){M.core.actionmenu.instance=M.core.actionmenu.instance||new s(e)}},"@VERSION@",{requires:["base","event"]});
|
||||
YUI.add("moodle-core-actionmenu",function(e,t){var n=e.one(e.config.doc.body),r={MENUSHOWN:"action-menu-shown"},i={MENU:".moodle-actionmenu[data-enhance=moodle-core-actionmenu]",MENUCONTENT:".menu[data-rel=menu-content]",TOGGLE:".toggle-display"},s,o={TL:"tl",TR:"tr",BL:"bl",BR:"br"};s=function(){s.superclass.constructor.apply(this,arguments)},s.prototype={dialogue:null,events:[],owner:null,initializer:function(){var t=this.get("align").join("-");e.all(i.MENU).each(function(){var e=this.one(i.MENUCONTENT),n;if(!e)return!1;n=e.getData("align")||t,this.one(i.TOGGLE).set("aria-haspopup",!0),e.set("aria-hidden",!0),e.hasClass("align-"+n)||e.addClass("align-"+n),e.hasChildNodes()&&this.setAttribute("data-enhanced","1")}),n.delegate("click",this.toggleMenu,i.MENU+" "+i.TOGGLE,this),n.delegate("key",this.toggleMenu,"enter,space",i.MENU+" "+i.TOGGLE,this)},hideMenu:function(){this.dialogue&&(this.dialogue.removeClass("show"),this.dialogue.one(i.MENUCONTENT).set("aria-hidden",!0),this.dialogue=null),this.owner&&(this.owner.removeClass(r.MENUSHOWN),this.owner=null);for(var e in this.events)this.events[e].detach&&this.events[e].detach();this.events=[]},toggleMenu:function(e){e.halt(!0),this.hideMenu(),this.showMenu(e.target.ancestor(i.MENU)),this.events.push(n.on("key",this.hideMenu,"esc",this)),this.events.push(n.on("click",this.hideIfOutside,this)),this.events.push(n.delegate("focus",this.hideIfOutside,"*",this))},hideIfOutside:function(e){!e.target.test(i.MENU)&&!e.target.ancestor(i.MENU)&&this.hideMenu()},showMenu:function(e){var t=e.getData("owner"),n=e.one(i.MENUCONTENT);return this.owner=t?e.ancestor(t):null,this.dialogue=e,e.addClass("show"),this.owner.addClass(r.MENUSHOWN),this.constrain(n.set("aria-hidden",!1)),!0},constrain:function(e){var t=e.getData("constraint"),n=e.getX(),r=e.getY(),i=e.get("offsetWidth"),s=e.get("offsetHeight"),o=0,u=0,a,f,l=null,c=null,h=null,p=null;t&&(t=e.ancestor(t)),t?(a=t.get("offsetWidth"),f=t.get("offsetHeight"),o=t.getX(),u=t.getY()):(a=e.get("docWidth"),f=e.get("docHeight")),i>a?(l=i=a,h=n=o):n<o?h=n=o:n+i>o+a&&(h=o+a-i),s>f?(c=s=f,p=r=u):r<u?p=r=u:r+s>u+f&&(p=u+f-s),h!==null&&e.setX(h),p!==null&&e.setY(p),l!==null&&e.setStyle("width",l.toString()+"px"),c!==null&&e.setStyle("height",c.toString()+"px")}},e.extend(s,e.Base,s.prototype,{NAME:"moodle-core-actionmenu",ATTRS:{align:{value:[o.TR,o.BR]}}}),M.core=M.core||{},M.core.actionmenu=M.core.actionmenu||{},M.core.actionmenu.init=M.core.actionmenu.init||function(e){M.core.actionmenu.instance=M.core.actionmenu.instance||new s(e)}},"@VERSION@",{requires:["base","event"]});
|
||||
|
@ -67,13 +67,16 @@ ACTIONMENU.prototype = {
|
||||
var defaultalign = this.get('align').join('-');
|
||||
Y.all(SELECTOR.MENU).each(function() {
|
||||
var menucontent = this.one(SELECTOR.MENUCONTENT),
|
||||
toggle = this.one(SELECTOR.TOGGLE),
|
||||
align = menucontent.getData('align') || defaultalign;
|
||||
align;
|
||||
if (!menucontent) {
|
||||
return false;
|
||||
}
|
||||
toggle.set('aria-haspopup', true);
|
||||
menucontent.set('aria-hidden', true).addClass('align-'+align);
|
||||
align = menucontent.getData('align') || defaultalign;
|
||||
this.one(SELECTOR.TOGGLE).set('aria-haspopup', true);
|
||||
menucontent.set('aria-hidden', true);
|
||||
if (!menucontent.hasClass('align-'+align)) {
|
||||
menucontent.addClass('align-'+align);
|
||||
}
|
||||
if (menucontent.hasChildNodes()) {
|
||||
this.setAttribute('data-enhanced', '1');
|
||||
}
|
||||
@ -174,7 +177,6 @@ ACTIONMENU.prototype = {
|
||||
newleft = null,
|
||||
newtop = null;
|
||||
|
||||
|
||||
if (selector) {
|
||||
selector = node.ancestor(selector);
|
||||
}
|
||||
@ -274,5 +276,4 @@ M.core.actionmenu.init = M.core.actionmenu.init || function(params) {
|
||||
M.core.actionmenu.instance = M.core.actionmenu.instance || new ACTIONMENU(params);
|
||||
};
|
||||
|
||||
|
||||
}, '@VERSION@', {"requires": ["base", "event"]});
|
||||
|
14
lib/yui/src/actionmenu/js/actionmenu.js
vendored
14
lib/yui/src/actionmenu/js/actionmenu.js
vendored
@ -66,13 +66,16 @@ ACTIONMENU.prototype = {
|
||||
var defaultalign = this.get('align').join('-');
|
||||
Y.all(SELECTOR.MENU).each(function() {
|
||||
var menucontent = this.one(SELECTOR.MENUCONTENT),
|
||||
toggle = this.one(SELECTOR.TOGGLE),
|
||||
align = menucontent.getData('align') || defaultalign;
|
||||
align;
|
||||
if (!menucontent) {
|
||||
return false;
|
||||
}
|
||||
toggle.set('aria-haspopup', true);
|
||||
menucontent.set('aria-hidden', true).addClass('align-'+align);
|
||||
align = menucontent.getData('align') || defaultalign;
|
||||
this.one(SELECTOR.TOGGLE).set('aria-haspopup', true);
|
||||
menucontent.set('aria-hidden', true);
|
||||
if (!menucontent.hasClass('align-'+align)) {
|
||||
menucontent.addClass('align-'+align);
|
||||
}
|
||||
if (menucontent.hasChildNodes()) {
|
||||
this.setAttribute('data-enhanced', '1');
|
||||
}
|
||||
@ -174,7 +177,6 @@ ACTIONMENU.prototype = {
|
||||
newleft = null,
|
||||
newtop = null;
|
||||
|
||||
|
||||
if (selector) {
|
||||
selector = node.ancestor(selector);
|
||||
}
|
||||
@ -272,4 +274,4 @@ M.core.actionmenu = M.core.actionmenu || {};
|
||||
*/
|
||||
M.core.actionmenu.init = M.core.actionmenu.init || function(params) {
|
||||
M.core.actionmenu.instance = M.core.actionmenu.instance || new ACTIONMENU(params);
|
||||
};
|
||||
};
|
@ -597,6 +597,7 @@ span.editinstructions {
|
||||
}
|
||||
|
||||
.section .activity .moodle-actionmenu .iconsmall {
|
||||
max-width: none !important; /** reset sets 100% !important which breaks on IE8 without this !important */
|
||||
width:16px;
|
||||
height:16px;
|
||||
width:1rem;
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user