Merge branch 'MDL-51799-master' of git://github.com/ryanwyllie/moodle

This commit is contained in:
Andrew Nicols
2015-10-29 13:16:15 +08:00
4 changed files with 92 additions and 53 deletions
@@ -109,6 +109,16 @@ Y.extend(DIALOGUE, Y.Panel, {
*/
_originalPosition: null,
/**
* The list of elements that have been aria hidden when displaying
* this dialogue.
*
* @property _hiddenSiblings
* @protected
* @type Array
*/
_hiddenSiblings: null,
/**
* Initialise the dialogue.
*
@@ -117,6 +127,9 @@ Y.extend(DIALOGUE, Y.Panel, {
initializer : function() {
var bb;
// Initialise the element cache.
this._hiddenSiblings = [];
if (this.get('render')) {
this.render();
}
@@ -243,6 +256,7 @@ Y.extend(DIALOGUE, Y.Panel, {
var titlebar, bb;
if (e.attrName === 'visible') {
this.get('maskNode').addClass(CSS.LIGHTBOX);
// Going from visible to hidden.
if (e.prevVal && !e.newVal) {
bb = this.get('boundingBox');
if (this._resizeevent) {
@@ -254,7 +268,13 @@ Y.extend(DIALOGUE, Y.Panel, {
this._orientationevent = null;
}
bb.detach('key', this.keyDelegation);
if (this.get('modal')) {
// Hide this dialogue from screen readers.
this.setAccessibilityHidden();
}
}
// Going from hidden to visible.
if (!e.prevVal && e.newVal) {
// This needs to be done each time the dialog is shown as new dialogs may have been opened.
this.applyZIndex();
@@ -268,6 +288,13 @@ Y.extend(DIALOGUE, Y.Panel, {
}
}
this.keyDelegation();
// Only do accessibility hiding for modals because the ARIA spec
// says that all ARIA dialogues should be modal.
if (this.get('modal')) {
// Make this dialogue visible to screen readers.
this.setAccessibilityVisible();
}
}
if (this.get('center') && !e.prevVal && e.newVal) {
this.centerDialogue();
@@ -367,13 +394,6 @@ Y.extend(DIALOGUE, Y.Panel, {
this.lockScroll.enableScrollLock(this.shouldResizeFullscreen());
}
// Only do accessibility hiding for modals because the ARIA spec
// says that all ARIA dialogues should be modal.
if (this.get('modal')) {
// Make this dialogue visible to screen readers.
this.setAccessibilityVisible();
}
// Try and find a node to focus on using the focusOnShowSelector attribute.
if (focusSelector !== null) {
focusNode = this.get('boundingBox').one(focusSelector);
@@ -401,11 +421,6 @@ Y.extend(DIALOGUE, Y.Panel, {
}
}
if (this.get('modal')) {
// Hide this dialogue from screen readers.
this.setAccessibilityHidden();
}
// Unlock scroll if the plugin is present.
if (this.lockScroll) {
this.lockScroll.disableScrollLock();
@@ -463,8 +478,6 @@ Y.extend(DIALOGUE, Y.Panel, {
// Get the element that contains this dialogue because we need it
// to filter out from the document.body child elements.
var container = this.get(BASE);
// Keep a record of any elements we change so that they can be reverted later.
this.hiddenSiblings = [];
// We need to get a list containing each sibling element and the shallowest
// non-ancestral nodes in the DOM. We can shortcut this a little by leveraging
@@ -479,7 +492,7 @@ Y.extend(DIALOGUE, Y.Panel, {
if (hidden !== 'true') {
// Save their current state.
node.setData('previous-aria-hidden', hidden);
this.hiddenSiblings.push(node);
this._hiddenSiblings.push(node);
// Hide this node from screen readers.
node.set('aria-hidden', 'true');
@@ -503,7 +516,7 @@ Y.extend(DIALOGUE, Y.Panel, {
container.set('aria-hidden', 'true');
// Restore the sibling nodes back to their original values.
Y.Array.each(this.hiddenSiblings, function(node) {
Y.Array.each(this._hiddenSiblings, function(node) {
var previousValue = node.getData('previous-aria-hidden');
// If the element didn't previously have an aria-hidden attribute
// then we can just remove the one we set.
@@ -516,7 +529,7 @@ Y.extend(DIALOGUE, Y.Panel, {
});
// Clear the cache. No longer need to store these.
this.hiddenSiblings = [];
this._hiddenSiblings = [];
}
}, {
NAME : DIALOGUE_NAME,
File diff suppressed because one or more lines are too long
@@ -109,6 +109,16 @@ Y.extend(DIALOGUE, Y.Panel, {
*/
_originalPosition: null,
/**
* The list of elements that have been aria hidden when displaying
* this dialogue.
*
* @property _hiddenSiblings
* @protected
* @type Array
*/
_hiddenSiblings: null,
/**
* Initialise the dialogue.
*
@@ -117,6 +127,9 @@ Y.extend(DIALOGUE, Y.Panel, {
initializer : function() {
var bb;
// Initialise the element cache.
this._hiddenSiblings = [];
if (this.get('render')) {
this.render();
}
@@ -243,6 +256,7 @@ Y.extend(DIALOGUE, Y.Panel, {
var titlebar, bb;
if (e.attrName === 'visible') {
this.get('maskNode').addClass(CSS.LIGHTBOX);
// Going from visible to hidden.
if (e.prevVal && !e.newVal) {
bb = this.get('boundingBox');
if (this._resizeevent) {
@@ -254,7 +268,13 @@ Y.extend(DIALOGUE, Y.Panel, {
this._orientationevent = null;
}
bb.detach('key', this.keyDelegation);
if (this.get('modal')) {
// Hide this dialogue from screen readers.
this.setAccessibilityHidden();
}
}
// Going from hidden to visible.
if (!e.prevVal && e.newVal) {
// This needs to be done each time the dialog is shown as new dialogs may have been opened.
this.applyZIndex();
@@ -268,6 +288,13 @@ Y.extend(DIALOGUE, Y.Panel, {
}
}
this.keyDelegation();
// Only do accessibility hiding for modals because the ARIA spec
// says that all ARIA dialogues should be modal.
if (this.get('modal')) {
// Make this dialogue visible to screen readers.
this.setAccessibilityVisible();
}
}
if (this.get('center') && !e.prevVal && e.newVal) {
this.centerDialogue();
@@ -367,13 +394,6 @@ Y.extend(DIALOGUE, Y.Panel, {
this.lockScroll.enableScrollLock(this.shouldResizeFullscreen());
}
// Only do accessibility hiding for modals because the ARIA spec
// says that all ARIA dialogues should be modal.
if (this.get('modal')) {
// Make this dialogue visible to screen readers.
this.setAccessibilityVisible();
}
// Try and find a node to focus on using the focusOnShowSelector attribute.
if (focusSelector !== null) {
focusNode = this.get('boundingBox').one(focusSelector);
@@ -401,11 +421,6 @@ Y.extend(DIALOGUE, Y.Panel, {
}
}
if (this.get('modal')) {
// Hide this dialogue from screen readers.
this.setAccessibilityHidden();
}
// Unlock scroll if the plugin is present.
if (this.lockScroll) {
this.lockScroll.disableScrollLock();
@@ -463,8 +478,6 @@ Y.extend(DIALOGUE, Y.Panel, {
// Get the element that contains this dialogue because we need it
// to filter out from the document.body child elements.
var container = this.get(BASE);
// Keep a record of any elements we change so that they can be reverted later.
this.hiddenSiblings = [];
// We need to get a list containing each sibling element and the shallowest
// non-ancestral nodes in the DOM. We can shortcut this a little by leveraging
@@ -479,7 +492,7 @@ Y.extend(DIALOGUE, Y.Panel, {
if (hidden !== 'true') {
// Save their current state.
node.setData('previous-aria-hidden', hidden);
this.hiddenSiblings.push(node);
this._hiddenSiblings.push(node);
// Hide this node from screen readers.
node.set('aria-hidden', 'true');
@@ -503,7 +516,7 @@ Y.extend(DIALOGUE, Y.Panel, {
container.set('aria-hidden', 'true');
// Restore the sibling nodes back to their original values.
Y.Array.each(this.hiddenSiblings, function(node) {
Y.Array.each(this._hiddenSiblings, function(node) {
var previousValue = node.getData('previous-aria-hidden');
// If the element didn't previously have an aria-hidden attribute
// then we can just remove the one we set.
@@ -516,7 +529,7 @@ Y.extend(DIALOGUE, Y.Panel, {
});
// Clear the cache. No longer need to store these.
this.hiddenSiblings = [];
this._hiddenSiblings = [];
}
}, {
NAME : DIALOGUE_NAME,
+30 -17
View File
@@ -80,6 +80,16 @@ Y.extend(DIALOGUE, Y.Panel, {
*/
_originalPosition: null,
/**
* The list of elements that have been aria hidden when displaying
* this dialogue.
*
* @property _hiddenSiblings
* @protected
* @type Array
*/
_hiddenSiblings: null,
/**
* Initialise the dialogue.
*
@@ -88,6 +98,9 @@ Y.extend(DIALOGUE, Y.Panel, {
initializer : function() {
var bb;
// Initialise the element cache.
this._hiddenSiblings = [];
if (this.get('render')) {
this.render();
}
@@ -214,6 +227,7 @@ Y.extend(DIALOGUE, Y.Panel, {
var titlebar, bb;
if (e.attrName === 'visible') {
this.get('maskNode').addClass(CSS.LIGHTBOX);
// Going from visible to hidden.
if (e.prevVal && !e.newVal) {
bb = this.get('boundingBox');
if (this._resizeevent) {
@@ -225,7 +239,13 @@ Y.extend(DIALOGUE, Y.Panel, {
this._orientationevent = null;
}
bb.detach('key', this.keyDelegation);
if (this.get('modal')) {
// Hide this dialogue from screen readers.
this.setAccessibilityHidden();
}
}
// Going from hidden to visible.
if (!e.prevVal && e.newVal) {
// This needs to be done each time the dialog is shown as new dialogs may have been opened.
this.applyZIndex();
@@ -239,6 +259,13 @@ Y.extend(DIALOGUE, Y.Panel, {
}
}
this.keyDelegation();
// Only do accessibility hiding for modals because the ARIA spec
// says that all ARIA dialogues should be modal.
if (this.get('modal')) {
// Make this dialogue visible to screen readers.
this.setAccessibilityVisible();
}
}
if (this.get('center') && !e.prevVal && e.newVal) {
this.centerDialogue();
@@ -338,13 +365,6 @@ Y.extend(DIALOGUE, Y.Panel, {
this.lockScroll.enableScrollLock(this.shouldResizeFullscreen());
}
// Only do accessibility hiding for modals because the ARIA spec
// says that all ARIA dialogues should be modal.
if (this.get('modal')) {
// Make this dialogue visible to screen readers.
this.setAccessibilityVisible();
}
// Try and find a node to focus on using the focusOnShowSelector attribute.
if (focusSelector !== null) {
focusNode = this.get('boundingBox').one(focusSelector);
@@ -372,11 +392,6 @@ Y.extend(DIALOGUE, Y.Panel, {
}
}
if (this.get('modal')) {
// Hide this dialogue from screen readers.
this.setAccessibilityHidden();
}
// Unlock scroll if the plugin is present.
if (this.lockScroll) {
this.lockScroll.disableScrollLock();
@@ -434,8 +449,6 @@ Y.extend(DIALOGUE, Y.Panel, {
// Get the element that contains this dialogue because we need it
// to filter out from the document.body child elements.
var container = this.get(BASE);
// Keep a record of any elements we change so that they can be reverted later.
this.hiddenSiblings = [];
// We need to get a list containing each sibling element and the shallowest
// non-ancestral nodes in the DOM. We can shortcut this a little by leveraging
@@ -450,7 +463,7 @@ Y.extend(DIALOGUE, Y.Panel, {
if (hidden !== 'true') {
// Save their current state.
node.setData('previous-aria-hidden', hidden);
this.hiddenSiblings.push(node);
this._hiddenSiblings.push(node);
// Hide this node from screen readers.
node.set('aria-hidden', 'true');
@@ -474,7 +487,7 @@ Y.extend(DIALOGUE, Y.Panel, {
container.set('aria-hidden', 'true');
// Restore the sibling nodes back to their original values.
Y.Array.each(this.hiddenSiblings, function(node) {
Y.Array.each(this._hiddenSiblings, function(node) {
var previousValue = node.getData('previous-aria-hidden');
// If the element didn't previously have an aria-hidden attribute
// then we can just remove the one we set.
@@ -487,7 +500,7 @@ Y.extend(DIALOGUE, Y.Panel, {
});
// Clear the cache. No longer need to store these.
this.hiddenSiblings = [];
this._hiddenSiblings = [];
}
}, {
NAME : DIALOGUE_NAME,