Merge branch '42452-26' of git://github.com/samhemelryk/moodle

This commit is contained in:
Damyon Wiese
2013-11-04 10:37:59 +08:00
10 changed files with 74 additions and 48 deletions
+1 -1
View File
@@ -363,7 +363,7 @@ class core_course_renderer extends plugin_renderer_base {
$menu = new action_menu();
$menu->set_owner_selector($ownerselector);
$menu->set_contraint($constraint);
$menu->set_constraint($constraint);
$menu->set_alignment(action_menu::TL, action_menu::TR);
if (isset($CFG->modeditingmenu) && !$CFG->modeditingmenu || !empty($displayoptions['donotenhance'])) {
$menu->do_not_enhance();
+1 -1
View File
@@ -3312,7 +3312,7 @@ class action_menu implements renderable {
*
* @param string $ancestorselector A snippet of CSS used to identify the ancestor to contrain the dialogue to.
*/
public function set_contraint($ancestorselector) {
public function set_constraint($ancestorselector) {
$this->attributessecondary['data-constraint'] = $ancestorselector;
}
+1
View File
@@ -1057,6 +1057,7 @@ class core_renderer extends renderer_base {
if ($blockid !== null) {
$menu->set_owner_selector('#'.$blockid);
}
$menu->set_constraint('.block-region');
$menu->attributes['class'] .= ' block-control-actions commands';
if (isset($CFG->blockeditingmenu) && !$CFG->blockeditingmenu) {
$menu->do_not_enhance();
@@ -190,10 +190,12 @@ ACTIONMENU.prototype = {
cy = 0,
cwidth,
cheight,
coverflow = 'auto',
newwidth = null,
newheight = null,
newleft = null,
newtop = null;
newtop = null,
boxshadow = null;
if (selector) {
selector = node.ancestor(selector);
@@ -203,6 +205,7 @@ ACTIONMENU.prototype = {
cheight = selector.get('offsetHeight');
cx = selector.getX();
cy = selector.getY();
coverflow = selector.getStyle('overflow') || 'auto';
} else {
cwidth = node.get('docWidth');
cheight = node.get('docHeight');
@@ -226,19 +229,24 @@ ACTIONMENU.prototype = {
}
// Constrain Y.
// First up if the width is more than the constrain its easily full width + full height.
if (nheight > cheight) {
// The width of the constraint.
if (nheight > cheight && coverflow.toLowerCase() === 'hidden') {
// The node extends over the constrained area and would be clipped.
// Reduce the height of the node and force its overflow to scroll.
newheight = nheight = cheight;
// The constraints xpoint.
newtop = ny = cy;
} else {
if (ny < cy) {
// If ny is less than cy we need to move it right.
newtop = ny = cy;
} else if (ny + nheight > cy + cheight) {
// The top right of the node is outside of the constraint, move it in.
newtop = cy + cheight - nheight;
node.setStyle('overflow', 'auto');
}
// If the node is below the top of the constraint AND
// the node is longer than the constraint allows.
if (ny >= cy && ny + nheight > cy + cheight) {
// Move it up.
newtop = cy + cheight - nheight;
try {
boxshadow = node.getStyle('boxShadow').replace(/.*? (\d+)px \d+px$/, '$1');
if (new RegExp(/^\d+$/).test(boxshadow) && newtop - cy > boxshadow) {
newtop -= boxshadow;
}
} catch (ex) {
Y.log('Failed to determine box-shadow margin.', 'warn', ACTIONMENU.NAME);
}
}
@@ -314,4 +322,5 @@ M.core.actionmenu.newDOMNode = function(node) {
node.all(SELECTOR.MENU).each(M.core.actionmenu.instance.enhance, M.core.actionmenu.instance);
};
}, '@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(){e.all(i.MENU).each(this.enhance,this),n.delegate("click",this.toggleMenu,i.MENU+" "+i.TOGGLE,this),n.delegate("key",this.toggleMenu,"enter,space",i.MENU+" "+i.TOGGLE,this)},enhance:function(e){var t=e.one(i.MENUCONTENT),n;if(!t)return!1;n=t.getData("align")||this.get("align").join("-"),e.one(i.TOGGLE).set("aria-haspopup",!0),t.set("aria-hidden",!0),t.hasClass("align-"+n)||t.addClass("align-"+n),t.hasChildNodes()&&e.setAttribute("data-enhanced","1")},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){var t=e.target.ancestor(i.MENU),r=t.hasClass("show");e.halt(!0),this.hideMenu();if(r)return;this.showMenu(t),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&&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.instance=null,M.core.actionmenu.init=M.core.actionmenu.init||function(e){M.core.actionmenu.instance=M.core.actionmenu.instance||new s(e)},M.core.actionmenu.newDOMNode=function(e){if(M.core.actionmenu.instance===null)return!0;e.all(i.MENU).each(M.core.actionmenu.instance.enhance,M.core.actionmenu.instance)}},"@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(){e.all(i.MENU).each(this.enhance,this),n.delegate("click",this.toggleMenu,i.MENU+" "+i.TOGGLE,this),n.delegate("key",this.toggleMenu,"enter,space",i.MENU+" "+i.TOGGLE,this)},enhance:function(e){var t=e.one(i.MENUCONTENT),n;if(!t)return!1;n=t.getData("align")||this.get("align").join("-"),e.one(i.TOGGLE).set("aria-haspopup",!0),t.set("aria-hidden",!0),t.hasClass("align-"+n)||t.addClass("align-"+n),t.hasChildNodes()&&e.setAttribute("data-enhanced","1")},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){var t=e.target.ancestor(i.MENU),r=t.hasClass("show");e.halt(!0),this.hideMenu();if(r)return;this.showMenu(t),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&&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="auto",c=null,h=null,p=null,d=null,v=null;t&&(t=e.ancestor(t)),t?(a=t.get("offsetWidth"),f=t.get("offsetHeight"),o=t.getX(),u=t.getY(),l=t.getStyle("overflow")||"auto"):(a=e.get("docWidth"),f=e.get("docHeight")),i>a?(c=i=a,p=n=o):n<o?p=n=o:n+i>=o+a&&(p=o+a-i),s>f&&l.toLowerCase()==="hidden"&&(h=s=f,e.setStyle("overflow","auto"));if(r>=u&&r+s>u+f){d=u+f-s;try{v=e.getStyle("boxShadow").replace(/.*? (\d+)px \d+px$/,"$1"),(new RegExp(/^\d+$/)).test(v)&&d-u>v&&(d-=v)}catch(m){}}p!==null&&e.setX(p),d!==null&&e.setY(d),c!==null&&e.setStyle("width",c.toString()+"px"),h!==null&&e.setStyle("height",h.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.instance=null,M.core.actionmenu.init=M.core.actionmenu.init||function(e){M.core.actionmenu.instance=M.core.actionmenu.instance||new s(e)},M.core.actionmenu.newDOMNode=function(e){if(M.core.actionmenu.instance===null)return!0;e.all(i.MENU).each(M.core.actionmenu.instance.enhance,M.core.actionmenu.instance)}},"@VERSION@",{requires:["base","event"]});
@@ -187,10 +187,12 @@ ACTIONMENU.prototype = {
cy = 0,
cwidth,
cheight,
coverflow = 'auto',
newwidth = null,
newheight = null,
newleft = null,
newtop = null;
newtop = null,
boxshadow = null;
if (selector) {
selector = node.ancestor(selector);
@@ -200,6 +202,7 @@ ACTIONMENU.prototype = {
cheight = selector.get('offsetHeight');
cx = selector.getX();
cy = selector.getY();
coverflow = selector.getStyle('overflow') || 'auto';
} else {
cwidth = node.get('docWidth');
cheight = node.get('docHeight');
@@ -223,19 +226,23 @@ ACTIONMENU.prototype = {
}
// Constrain Y.
// First up if the width is more than the constrain its easily full width + full height.
if (nheight > cheight) {
// The width of the constraint.
if (nheight > cheight && coverflow.toLowerCase() === 'hidden') {
// The node extends over the constrained area and would be clipped.
// Reduce the height of the node and force its overflow to scroll.
newheight = nheight = cheight;
// The constraints xpoint.
newtop = ny = cy;
} else {
if (ny < cy) {
// If ny is less than cy we need to move it right.
newtop = ny = cy;
} else if (ny + nheight > cy + cheight) {
// The top right of the node is outside of the constraint, move it in.
newtop = cy + cheight - nheight;
node.setStyle('overflow', 'auto');
}
// If the node is below the top of the constraint AND
// the node is longer than the constraint allows.
if (ny >= cy && ny + nheight > cy + cheight) {
// Move it up.
newtop = cy + cheight - nheight;
try {
boxshadow = node.getStyle('boxShadow').replace(/.*? (\d+)px \d+px$/, '$1');
if (new RegExp(/^\d+$/).test(boxshadow) && newtop - cy > boxshadow) {
newtop -= boxshadow;
}
} catch (ex) {
}
}
@@ -311,4 +318,5 @@ M.core.actionmenu.newDOMNode = function(node) {
node.all(SELECTOR.MENU).each(M.core.actionmenu.instance.enhance, M.core.actionmenu.instance);
};
}, '@VERSION@', {"requires": ["base", "event"]});
+22 -14
View File
@@ -188,10 +188,12 @@ ACTIONMENU.prototype = {
cy = 0,
cwidth,
cheight,
coverflow = 'auto',
newwidth = null,
newheight = null,
newleft = null,
newtop = null;
newtop = null,
boxshadow = null;
if (selector) {
selector = node.ancestor(selector);
@@ -201,6 +203,7 @@ ACTIONMENU.prototype = {
cheight = selector.get('offsetHeight');
cx = selector.getX();
cy = selector.getY();
coverflow = selector.getStyle('overflow') || 'auto';
} else {
cwidth = node.get('docWidth');
cheight = node.get('docHeight');
@@ -224,19 +227,24 @@ ACTIONMENU.prototype = {
}
// Constrain Y.
// First up if the width is more than the constrain its easily full width + full height.
if (nheight > cheight) {
// The width of the constraint.
if (nheight > cheight && coverflow.toLowerCase() === 'hidden') {
// The node extends over the constrained area and would be clipped.
// Reduce the height of the node and force its overflow to scroll.
newheight = nheight = cheight;
// The constraints xpoint.
newtop = ny = cy;
} else {
if (ny < cy) {
// If ny is less than cy we need to move it right.
newtop = ny = cy;
} else if (ny + nheight > cy + cheight) {
// The top right of the node is outside of the constraint, move it in.
newtop = cy + cheight - nheight;
node.setStyle('overflow', 'auto');
}
// If the node is below the top of the constraint AND
// the node is longer than the constraint allows.
if (ny >= cy && ny + nheight > cy + cheight) {
// Move it up.
newtop = cy + cheight - nheight;
try {
boxshadow = node.getStyle('boxShadow').replace(/.*? (\d+)px \d+px$/, '$1');
if (new RegExp(/^\d+$/).test(boxshadow) && newtop - cy > boxshadow) {
newtop -= boxshadow;
}
} catch (ex) {
Y.log('Failed to determine box-shadow margin.', 'warn', ACTIONMENU.NAME);
}
}
@@ -310,4 +318,4 @@ M.core.actionmenu.newDOMNode = function(node) {
return true;
}
node.all(SELECTOR.MENU).each(M.core.actionmenu.instance.enhance, M.core.actionmenu.instance);
};
};
+2 -1
View File
@@ -1478,7 +1478,8 @@ img#persona_signin { cursor: pointer; }
.moodle-actionmenu[data-enhanced].show {position: relative;}
.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 {white-space:nowrap;display: block;padding: 2px 1em 2px 0.5em;color: #333333;}
.moodle-actionmenu[data-enhanced].show .menu a {display: block;padding: 2px 1em 2px 24px;color: #333333;}
.moodle-actionmenu[data-enhanced].show .menu a > img {margin-left:-20px;}
.moodle-actionmenu[data-enhanced].show .menu a:hover,
.moodle-actionmenu[data-enhanced].show .menu a:focus {color: #ffffff;background-color: #0088cc;}
.moodle-actionmenu[data-enhanced].show .menu a:first-child {-webkit-border-top-right-radius: 4px;border-top-right-radius: 4px;-webkit-border-top-left-radius: 4px;border-top-left-radius: 4px;-moz-border-radius-topright: 4px;-moz-border-radius-topleft: 4px;}
+2 -3
View File
@@ -2053,10 +2053,9 @@ img#persona_signin {
.box-shadow(5px 5px 20px 0 #666);
a {
white-space:nowrap;
display: block;
color: @dropdownLinkColor;
padding:2px 1em 2px 0.5em;
padding:2px 1em 2px 24px;
&:hover,
&:focus {
color: @dropdownLinkColorHover;
@@ -2076,7 +2075,7 @@ img#persona_signin {
vertical-align: middle;
}
.iconsmall {
margin-right:8px;
margin-left:-20px;
}
> li {
display:block;
File diff suppressed because one or more lines are too long