Skip to content

Commit a324b49

Browse files
author
David Monllao
committed
Merge branch 'MDL-60079-33' of https://github.com/nashtechdev01/moodle into MOODLE_33_STABLE
2 parents 6340102 + c0f7537 commit a324b49

File tree

4 files changed

+81
-25
lines changed

4 files changed

+81
-25
lines changed

admin/tool/usertours/amd/build/tour.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

admin/tool/usertours/amd/src/tour.js

Lines changed: 59 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -619,26 +619,43 @@ Tour.prototype.addEventHandler = function (eventName, handler) {
619619
*/
620620
Tour.prototype.processStepListeners = function (stepConfig) {
621621
this.listeners.push(
622-
// Next/Previous buttons.
623-
{
624-
node: this.currentStepNode,
625-
args: ['click', '[data-role="next"]', $.proxy(this.next, this)]
626-
}, {
627-
node: this.currentStepNode,
628-
args: ['click', '[data-role="previous"]', $.proxy(this.previous, this)]
629-
},
630-
631-
// Close and end tour buttons.
632-
{
633-
node: this.currentStepNode,
634-
args: ['click', '[data-role="end"]', $.proxy(this.endTour, this)]
635-
},
636-
637-
// Keypresses.
638-
{
639-
node: $('body'),
640-
args: ['keydown', $.proxy(this.handleKeyDown, this)]
641-
});
622+
// Next/Previous buttons.
623+
{
624+
node: this.currentStepNode,
625+
args: ['click', '[data-role="next"]', $.proxy(this.next, this)]
626+
}, {
627+
node: this.currentStepNode,
628+
args: ['click', '[data-role="previous"]', $.proxy(this.previous, this)]
629+
},
630+
631+
// Close and end tour buttons.
632+
{
633+
node: this.currentStepNode,
634+
args: ['click', '[data-role="end"]', $.proxy(this.endTour, this)]
635+
},
636+
637+
// Click backdrop and hide tour.
638+
{
639+
node: $('[data-flexitour="backdrop"]'),
640+
args: ['click', $.proxy(this.hide, this)]
641+
},
642+
643+
// Click out and hide tour without backdrop.
644+
{
645+
node: $('body'),
646+
args: ['click', $.proxy(function (e) {
647+
// Handle click in or click out tour content,
648+
// if click out, hide tour.
649+
if (!this.currentStepNode.is(e.target) && $(e.target).closest('[data-role="flexitour-step"]').length === 0) {
650+
this.hide();
651+
}}, this)]
652+
},
653+
654+
// Keypresses.
655+
{
656+
node: $('body'),
657+
args: ['keydown', $.proxy(this.handleKeyDown, this)]
658+
});
642659

643660
if (stepConfig.moveOnClick) {
644661
var targetNode = this.getStepTarget(stepConfig);
@@ -904,7 +921,7 @@ Tour.prototype.announceStep = function (stepConfig) {
904921
* @param {EventFacade} e
905922
*/
906923
Tour.prototype.handleKeyDown = function (e) {
907-
var tabbableSelector = 'a[href], link[href], [draggable=true], [contenteditable=true], :input:enabled, [tabindex], button';
924+
var tabbableSelector = 'a[href], link[href], [draggable=true], [contenteditable=true], :input:enabled, [tabindex], button:enabled';
908925
switch (e.keyCode) {
909926
case 27:
910927
this.endTour();
@@ -923,8 +940,17 @@ Tour.prototype.handleKeyDown = function (e) {
923940
var activeElement = $(document.activeElement);
924941
var stepTarget = this.getStepTarget(this.currentStepConfig);
925942
var tabbableNodes = $(tabbableSelector);
943+
var dialogContainer = $('span[data-flexitour="container"]');
926944
var currentIndex = void 0;
927-
tabbableNodes.filter(function (index, element) {
945+
// Filter out element which is not belong to target section or dialogue.
946+
if (stepTarget) {
947+
tabbableNodes = tabbableNodes.filter(function (index, element) {
948+
return stepTarget != null && (stepTarget.has(element).length || dialogContainer.has(element).length || stepTarget.is(element) || dialogContainer.is(element));
949+
});
950+
}
951+
952+
// Find index of focusing element.
953+
tabbableNodes.each(function (index, element) {
928954
if (activeElement.is(element)) {
929955
currentIndex = index;
930956
return false;
@@ -934,7 +960,7 @@ Tour.prototype.handleKeyDown = function (e) {
934960
var nextIndex = void 0;
935961
var nextNode = void 0;
936962
var focusRelevant = void 0;
937-
if (currentIndex) {
963+
if (currentIndex != void 0) {
938964
var direction = 1;
939965
if (e.shiftKey) {
940966
direction = -1;
@@ -1090,6 +1116,16 @@ Tour.prototype.hide = function (transition) {
10901116
$(this).remove();
10911117
});
10921118

1119+
// Remove aria-describedby and tabindex attributes.
1120+
if (this.currentStepNode && this.currentStepNode.length) {
1121+
var stepId = this.currentStepNode.attr('id');
1122+
if (stepId) {
1123+
var currentStepElement = '[aria-describedby="' + stepId + '-body"]';
1124+
$(currentStepElement).removeAttr('tabindex');
1125+
$(currentStepElement).removeAttr('aria-describedby');
1126+
}
1127+
}
1128+
10931129
// Reset the listeners.
10941130
this.resetStepListeners();
10951131

admin/tool/usertours/tests/behat/tour_filter.feature

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,23 @@ Feature: Apply tour filters to a tour
5757
And I log in as "teacher1"
5858
And I am on "Course 1" course homepage
5959
And I should see "Welcome to your course tour."
60+
61+
@javascript
62+
Scenario: Aria tags should not exist
63+
Given I log in as "admin"
64+
And I open the User tour settings page
65+
# Turn on default tour for boost theme.
66+
And I click on "Enable" "link" in the "Boost - administrator" "table_row"
67+
And I am on site homepage
68+
When I click on "Next" "button"
69+
Then "button[aria-describedby^='tour-step-tool_usertours']" "css_element" should exist
70+
And "button[tabindex]" "css_element" should exist
71+
When I click on "Next" "button"
72+
Then "button[aria-describedby^='tour-step-tool_usertours']" "css_element" should not exist
73+
And "button[tabindex]" "css_element" should not exist
74+
When I click on "Previous" "button"
75+
Then "button[aria-describedby^='tour-step-tool_usertours']" "css_element" should exist
76+
And "button[tabindex]" "css_element" should exist
77+
When I click on "End tour" "button"
78+
Then "button[aria-describedby^='tour-step-tool_usertours']" "css_element" should not exist
79+
And "button[tabindex]" "css_element" should not exist

admin/tool/usertours/thirdpartylibs.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<location>amd/src/tour.js</location>
55
<name>Flexitour</name>
66
<license>GPLv3</license>
7-
<version>0.10.0</version>
7+
<version>0.12.0</version>
88
<licenseversion>3</licenseversion>
99
</library>
1010
<library>

0 commit comments

Comments
 (0)