Merge branch 'MDL-60079-master' of https://github.com/nashtechdev01/moodle

This commit is contained in:
David Monllao 2018-01-09 08:09:15 +01:00
commit 1679485693
4 changed files with 79 additions and 23 deletions

File diff suppressed because one or more lines are too long

View File

@ -619,26 +619,43 @@ Tour.prototype.addEventHandler = function (eventName, handler) {
*/
Tour.prototype.processStepListeners = function (stepConfig) {
this.listeners.push(
// Next/Previous buttons.
{
node: this.currentStepNode,
args: ['click', '[data-role="next"]', $.proxy(this.next, this)]
}, {
node: this.currentStepNode,
args: ['click', '[data-role="previous"]', $.proxy(this.previous, this)]
},
// Next/Previous buttons.
{
node: this.currentStepNode,
args: ['click', '[data-role="next"]', $.proxy(this.next, this)]
}, {
node: this.currentStepNode,
args: ['click', '[data-role="previous"]', $.proxy(this.previous, this)]
},
// Close and end tour buttons.
{
node: this.currentStepNode,
args: ['click', '[data-role="end"]', $.proxy(this.endTour, this)]
},
// Close and end tour buttons.
{
node: this.currentStepNode,
args: ['click', '[data-role="end"]', $.proxy(this.endTour, this)]
},
// Keypresses.
{
node: $('body'),
args: ['keydown', $.proxy(this.handleKeyDown, this)]
});
// Click backdrop and hide tour.
{
node: $('[data-flexitour="backdrop"]'),
args: ['click', $.proxy(this.hide, this)]
},
// Click out and hide tour without backdrop.
{
node: $('body'),
args: ['click', $.proxy(function (e) {
// Handle click in or click out tour content,
// if click out, hide tour.
if (!this.currentStepNode.is(e.target) && $(e.target).closest('[data-role="flexitour-step"]').length === 0) {
this.hide();
}}, this)]
},
// Keypresses.
{
node: $('body'),
args: ['keydown', $.proxy(this.handleKeyDown, this)]
});
if (stepConfig.moveOnClick) {
var targetNode = this.getStepTarget(stepConfig);
@ -904,7 +921,7 @@ Tour.prototype.announceStep = function (stepConfig) {
* @param {EventFacade} e
*/
Tour.prototype.handleKeyDown = function (e) {
var tabbableSelector = 'a[href], link[href], [draggable=true], [contenteditable=true], :input:enabled, [tabindex], button';
var tabbableSelector = 'a[href], link[href], [draggable=true], [contenteditable=true], :input:enabled, [tabindex], button:enabled';
switch (e.keyCode) {
case 27:
this.endTour();
@ -923,8 +940,17 @@ Tour.prototype.handleKeyDown = function (e) {
var activeElement = $(document.activeElement);
var stepTarget = this.getStepTarget(this.currentStepConfig);
var tabbableNodes = $(tabbableSelector);
var dialogContainer = $('span[data-flexitour="container"]');
var currentIndex = void 0;
tabbableNodes.filter(function (index, element) {
// Filter out element which is not belong to target section or dialogue.
if (stepTarget) {
tabbableNodes = tabbableNodes.filter(function (index, element) {
return stepTarget != null && (stepTarget.has(element).length || dialogContainer.has(element).length || stepTarget.is(element) || dialogContainer.is(element));
});
}
// Find index of focusing element.
tabbableNodes.each(function (index, element) {
if (activeElement.is(element)) {
currentIndex = index;
return false;
@ -934,7 +960,7 @@ Tour.prototype.handleKeyDown = function (e) {
var nextIndex = void 0;
var nextNode = void 0;
var focusRelevant = void 0;
if (currentIndex) {
if (currentIndex != void 0) {
var direction = 1;
if (e.shiftKey) {
direction = -1;
@ -1090,6 +1116,16 @@ Tour.prototype.hide = function (transition) {
$(this).remove();
});
// Remove aria-describedby and tabindex attributes.
if (this.currentStepNode && this.currentStepNode.length) {
var stepId = this.currentStepNode.attr('id');
if (stepId) {
var currentStepElement = '[aria-describedby="' + stepId + '-body"]';
$(currentStepElement).removeAttr('tabindex');
$(currentStepElement).removeAttr('aria-describedby');
}
}
// Reset the listeners.
this.resetStepListeners();

View File

@ -157,3 +157,23 @@ Feature: Apply tour filters to a tour
When I am on "Course 2" course homepage
And I wait until the page is ready
Then I should not see "Welcome to your course tour."
@javascript
Scenario: Aria tags should not exist
Given I log in as "admin"
And I open the User tour settings page
# Turn on default tour for boost theme.
And I click on "Enable" "link" in the "Boost - administrator" "table_row"
And I am on site homepage
When I click on "Next" "button"
Then "button[aria-describedby^='tour-step-tool_usertours']" "css_element" should exist
And "button[tabindex]" "css_element" should exist
When I click on "Next" "button"
Then "button[aria-describedby^='tour-step-tool_usertours']" "css_element" should not exist
And "button[tabindex]" "css_element" should not exist
When I click on "Previous" "button"
Then "button[aria-describedby^='tour-step-tool_usertours']" "css_element" should exist
And "button[tabindex]" "css_element" should exist
When I click on "End tour" "button"
Then "button[aria-describedby^='tour-step-tool_usertours']" "css_element" should not exist
And "button[tabindex]" "css_element" should not exist

View File

@ -4,7 +4,7 @@
<location>amd/src/tour.js</location>
<name>Flexitour</name>
<license>GPLv3</license>
<version>0.10.0</version>
<version>0.12.0</version>
<licenseversion>3</licenseversion>
</library>
<library>