Merge branch 'MDL-68390-master' of git://github.com/andrewnicols/moodle into master
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -594,7 +594,7 @@ export default class Tour {
|
||||
});
|
||||
}
|
||||
|
||||
this.listeners.forEach(function (listener) {
|
||||
this.listeners.forEach(function(listener) {
|
||||
listener.node.on.apply(listener.node, listener.args);
|
||||
});
|
||||
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -33,6 +33,7 @@ define(
|
||||
'core_course/events',
|
||||
'block_myoverview/selectors',
|
||||
'core/paged_content_events',
|
||||
'core/aria',
|
||||
],
|
||||
function(
|
||||
$,
|
||||
@@ -44,7 +45,8 @@ function(
|
||||
Templates,
|
||||
CourseEvents,
|
||||
Selectors,
|
||||
PagedContentEvents
|
||||
PagedContentEvents,
|
||||
Aria
|
||||
) {
|
||||
|
||||
var SELECTORS = {
|
||||
@@ -174,12 +176,14 @@ function(
|
||||
*/
|
||||
var hideFavouriteIcon = function(root, courseId) {
|
||||
var iconContainer = getFavouriteIconContainer(root, courseId);
|
||||
|
||||
var isFavouriteIcon = iconContainer.find(SELECTORS.ICON_IS_FAVOURITE);
|
||||
isFavouriteIcon.addClass('hidden');
|
||||
isFavouriteIcon.attr('aria-hidden', true);
|
||||
Aria.hide(isFavouriteIcon);
|
||||
|
||||
var notFavourteIcon = iconContainer.find(SELECTORS.ICON_NOT_FAVOURITE);
|
||||
notFavourteIcon.removeClass('hidden');
|
||||
notFavourteIcon.attr('aria-hidden', false);
|
||||
Aria.unhide(notFavourteIcon);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -190,12 +194,14 @@ function(
|
||||
*/
|
||||
var showFavouriteIcon = function(root, courseId) {
|
||||
var iconContainer = getFavouriteIconContainer(root, courseId);
|
||||
|
||||
var isFavouriteIcon = iconContainer.find(SELECTORS.ICON_IS_FAVOURITE);
|
||||
isFavouriteIcon.removeClass('hidden');
|
||||
isFavouriteIcon.attr('aria-hidden', false);
|
||||
Aria.unhide(isFavouriteIcon);
|
||||
|
||||
var notFavourteIcon = iconContainer.find(SELECTORS.ICON_NOT_FAVOURITE);
|
||||
notFavourteIcon.addClass('hidden');
|
||||
notFavourteIcon.attr('aria-hidden', true);
|
||||
Aria.hide(notFavourteIcon);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
function _typeof(a){"@babel/helpers - typeof";if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(a){return typeof a}}else{_typeof=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a}}return _typeof(a)}define ("block_navigation/ajax_response_renderer",["jquery","core/templates","core/notification","core/url"],function(a,b,c,d){var f={ACTIVITY:40,RESOURCE:50};function e(g,h){var i=a("<ul></ul>");i.attr("role","group");i.attr("aria-hidden",!0);a.each(h,function(g,h){if("object"!==_typeof(h)){return}var j=a("<li></li>"),k=a("<p></p>"),l=h.id||h.key+"_tree_item",m=null,n=h.expandable||h.haschildren?!0:!1;k.addClass("tree_item");k.attr("id",l);k.attr("role","treeitem");k.attr("tabindex","-1");if(h.requiresajaxloading){k.attr("data-requires-ajax",!0);k.attr("data-node-id",h.id);k.attr("data-node-key",h.key);k.attr("data-node-type",h.type)}if(n){j.addClass("collapsed contains_branch");k.attr("aria-expanded",!1);k.addClass("branch")}var o=null;if(h.link){var p=a("<a title=\""+h.title+"\" href=\""+h.link+"\"></a>");o=p;p.append("<span class=\"item-content-wrap\">"+h.name+"</span>");if(h.hidden){p.addClass("dimmed")}k.append(p)}else{var q=a("<span></span>");o=q;q.append("<span class=\"item-content-wrap\">"+h.name+"</span>");if(h.hidden){q.addClass("dimmed")}k.append(q)}if(h.icon&&(!n||h.type===f.ACTIVITY||h.type===f.RESOURCE)){j.addClass("item_with_icon");k.addClass("hasicon");if(h.type===f.ACTIVITY||h.type===f.RESOURCE){m=a("<img/>");m.attr("alt",h.icon.alt);m.attr("title",h.icon.title);m.attr("src",d.imageUrl(h.icon.pix,h.icon.component));a.each(h.icon.classes,function(a,b){m.addClass(b)});o.prepend(m)}else{if("moodle"==h.icon.component){h.icon.component="core"}b.renderPix(h.icon.pix,h.icon.component,h.icon.title).then(function(a){o.prepend(a)}).catch(c.exception)}}j.append(k);i.append(j);if(h.children&&h.children.length){e(k,h.children)}else if(n&&!h.requiresajaxloading){j.removeClass("contains_branch");k.addClass("emptybranch")}});g.parent().append(i);var j=g.attr("id")+"_group";i.attr("id",j);g.attr("aria-owns",j);g.attr("role","treeitem")}return{render:function render(a,b){if(b.children&&b.children.length){e(a,b.children);var c=a.children("[role='treeitem']").first(),d=a.find("#"+c.attr("aria-owns"));c.attr("aria-expanded",!0);d.attr("aria-hidden",!1)}else{if(a.parent().hasClass("contains_branch")){a.parent().removeClass("contains_branch");a.addClass("emptybranch")}}}}});
|
||||
function _typeof(a){"@babel/helpers - typeof";if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(a){return typeof a}}else{_typeof=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a}}return _typeof(a)}define ("block_navigation/ajax_response_renderer",["jquery","core/templates","core/notification","core/url","core/aria"],function(a,b,c,d,e){var g={ACTIVITY:40,RESOURCE:50};function f(h,i){var j=a("<ul></ul>");j.attr("role","group");e.hide(j);a.each(i,function(e,h){if("object"!==_typeof(h)){return}var i=a("<li></li>"),k=a("<p></p>"),l=h.id||h.key+"_tree_item",m=null,n=h.expandable||h.haschildren?!0:!1;k.addClass("tree_item");k.attr("id",l);k.attr("role","treeitem");k.attr("tabindex","-1");if(h.requiresajaxloading){k.attr("data-requires-ajax",!0);k.attr("data-node-id",h.id);k.attr("data-node-key",h.key);k.attr("data-node-type",h.type)}if(n){i.addClass("collapsed contains_branch");k.attr("aria-expanded",!1);k.addClass("branch")}var o=null;if(h.link){var p=a("<a title=\""+h.title+"\" href=\""+h.link+"\"></a>");o=p;p.append("<span class=\"item-content-wrap\">"+h.name+"</span>");if(h.hidden){p.addClass("dimmed")}k.append(p)}else{var q=a("<span></span>");o=q;q.append("<span class=\"item-content-wrap\">"+h.name+"</span>");if(h.hidden){q.addClass("dimmed")}k.append(q)}if(h.icon&&(!n||h.type===g.ACTIVITY||h.type===g.RESOURCE)){i.addClass("item_with_icon");k.addClass("hasicon");if(h.type===g.ACTIVITY||h.type===g.RESOURCE){m=a("<img/>");m.attr("alt",h.icon.alt);m.attr("title",h.icon.title);m.attr("src",d.imageUrl(h.icon.pix,h.icon.component));a.each(h.icon.classes,function(a,b){m.addClass(b)});o.prepend(m)}else{if("moodle"==h.icon.component){h.icon.component="core"}b.renderPix(h.icon.pix,h.icon.component,h.icon.title).then(function(a){o.prepend(a)}).catch(c.exception)}}i.append(k);j.append(i);if(h.children&&h.children.length){f(k,h.children)}else if(n&&!h.requiresajaxloading){i.removeClass("contains_branch");k.addClass("emptybranch")}});h.parent().append(j);var k=h.attr("id")+"_group";j.attr("id",k);h.attr("aria-owns",k);h.attr("role","treeitem")}return{render:function render(a,b){if(b.children&&b.children.length){f(a,b.children);var c=a.children("[role='treeitem']").first(),d=a.find("#"+c.attr("aria-owns"));c.attr("aria-expanded",!0);e.unhide(d)}else{if(a.parent().hasClass("contains_branch")){a.parent().removeClass("contains_branch");a.addClass("emptybranch")}}}}});
|
||||
//# sourceMappingURL=ajax_response_renderer.min.js.map
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -22,7 +22,19 @@
|
||||
* @copyright 2015 John Okely <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['jquery', 'core/templates', 'core/notification', 'core/url'], function($, Templates, Notification, Url) {
|
||||
define([
|
||||
'jquery',
|
||||
'core/templates',
|
||||
'core/notification',
|
||||
'core/url',
|
||||
'core/aria',
|
||||
], function(
|
||||
$,
|
||||
Templates,
|
||||
Notification,
|
||||
Url,
|
||||
Aria
|
||||
) {
|
||||
|
||||
// Mappings for the different types of nodes coming from the navigation.
|
||||
// Copied from lib/navigationlib.php navigation_node constants.
|
||||
@@ -43,7 +55,7 @@ define(['jquery', 'core/templates', 'core/notification', 'core/url'], function($
|
||||
function buildDOM(rootElement, nodes) {
|
||||
var ul = $('<ul></ul>');
|
||||
ul.attr('role', 'group');
|
||||
ul.attr('aria-hidden', true);
|
||||
Aria.hide(ul);
|
||||
|
||||
$.each(nodes, function(index, node) {
|
||||
if (typeof node !== 'object') {
|
||||
@@ -153,7 +165,7 @@ define(['jquery', 'core/templates', 'core/notification', 'core/url'], function($
|
||||
var group = element.find('#' + item.attr('aria-owns'));
|
||||
|
||||
item.attr('aria-expanded', true);
|
||||
group.attr('aria-hidden', false);
|
||||
Aria.unhide(group);
|
||||
} else {
|
||||
if (element.parent().hasClass('contains_branch')) {
|
||||
element.parent().removeClass('contains_branch');
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
define ("block_recentlyaccessedcourses/main",["jquery","core/custom_interaction_events","core/notification","core/pubsub","core/paged_content_paging_bar","core/templates","core_course/events","core_course/repository"],function(a,b,c,d,e,f,g,h){var i={BLOCK_CONTAINER:"[data-region=\"recentlyaccessedcourses\"]",CARD_CONTAINER:"[data-region=\"card-deck\"]",COURSE_IS_FAVOURITE:"[data-region=\"is-favourite\"]",CONTENT:"[data-region=\"view-content\"]",EMPTY_MESSAGE:"[data-region=\"empty-message\"]",LOADING_PLACEHOLDER:"[data-region=\"loading-placeholder\"]",PAGING_BAR:"[data-region=\"paging-bar\"]",PAGING_BAR_NEXT:"[data-control=\"next\"]",PAGING_BAR_PREVIOUS:"[data-control=\"previous\"]"},j=!1,k=[],l=null,m=null,n=0,o=1,p=function(a){a.find(i.EMPTY_MESSAGE).removeClass("hidden");a.find(i.LOADING_PLACEHOLDER).addClass("hidden");a.find(i.CONTENT).addClass("hidden")},q=function(a){a.find(i.CONTENT).removeClass("hidden");a.find(i.EMPTY_MESSAGE).addClass("hidden");a.find(i.LOADING_PLACEHOLDER).addClass("hidden")},r=function(a){var b=a.find(i.PAGING_BAR);b.css("opacity",1);b.css("visibility","visible");b.attr("aria-hidden","false")},s=function(a){var b=a.find(i.PAGING_BAR);b.css("opacity",0);b.css("visibility","hidden");b.attr("aria-hidden","true")},t=function(a,b){k.forEach(function(a){if(a.attr("data-course-id")==b){a.find(i.COURSE_IS_FAVOURITE).removeClass("hidden")}})},u=function(a,b){k.forEach(function(a){if(a.attr("data-course-id")==b){a.find(i.COURSE_IS_FAVOURITE).addClass("hidden")}})},v=function(b){var d=a(i.BLOCK_CONTAINER).data("displaycoursecategory"),e=b.map(function(a){a.showcoursecategory=d;return f.render("block_recentlyaccessedcourses/course-card",a)});return a.when.apply(null,e).then(function(){var b=[];e.forEach(function(d){d.then(function(c){b.push(a(c))}).catch(c.exception)});return b})},w=function(a){return h.getLastAccessedCourses(a,10).then(function(a){return v(a)})},x=function(a){var b=a.find(i.CONTENT).find(i.CARD_CONTAINER),c=parseFloat(a.css("width")),d=k.length,f=0;if(!m){b.html(k[0]);m=k[0].outerWidth(!0)}o=Math.floor(c/m);if(n+o<d){f=n}else{var g=n+o-d;f=n-g;f=0<=f?f:0}var h=k.slice(f,f+o),j=h.reduce(function(a,b){return a+b.attr("data-course-id")},"");if(k.length>h.length){b.addClass("justify-content-center");b.removeClass("justify-content-start")}else{b.removeClass("justify-content-center");b.addClass("justify-content-start")}if(l!=j){var p=a.find(e.rootSelector);b.html(h);l=j;if(o>=k.length){s(a)}else{r(a);if(0===n){e.disablePreviousControlButtons(p)}else{e.enablePreviousControlButtons(p)}if(n+o>=k.length){e.disableNextControlButtons(p)}else{e.enableNextControlButtons(p)}}}},y=function(c){var e=null,f=!1;d.subscribe(g.favourited,function(a){t(c,a)});d.subscribe(g.unfavorited,function(a){u(c,a)});d.subscribe("nav-drawer-toggle-start",function(){if(!j||!k.length||f){return}f=!0;var a=0,b=function(){setTimeout(function(){x(c);a++;if(5>a&&f){b()}},100)};b(c)});d.subscribe("nav-drawer-toggle-end",function(){f=!1});a(window).on("resize",function(){if(!j||!k.length){return}if(!e){e=setTimeout(function(){e=null;x(c)},66)}});b.define(c,[b.events.activate]);c.on(b.events.activate,i.PAGING_BAR_NEXT,function(b,d){var e=a(b.target).closest(i.PAGING_BAR_NEXT);if(!e.hasClass("disabled")){n=n+o;x(c)}d.originalEvent.preventDefault()});c.on(b.events.activate,i.PAGING_BAR_PREVIOUS,function(b,d){var e=a(b.target).closest(i.PAGING_BAR_PREVIOUS);if(!e.hasClass("disabled")){n=n-o;n=0>n?0:n;x(c)}d.originalEvent.preventDefault()})};return{init:function init(b,d){d=a(d);y(d);w(b).then(function(a){k=a;j=!0;if(k.length){q(d);x(d)}else{p(d)}}).catch(c.exception)}}});
|
||||
define ("block_recentlyaccessedcourses/main",["jquery","core/custom_interaction_events","core/notification","core/pubsub","core/paged_content_paging_bar","core/templates","core_course/events","core_course/repository","core/aria"],function(a,b,c,d,e,f,g,h,i){var j={BLOCK_CONTAINER:"[data-region=\"recentlyaccessedcourses\"]",CARD_CONTAINER:"[data-region=\"card-deck\"]",COURSE_IS_FAVOURITE:"[data-region=\"is-favourite\"]",CONTENT:"[data-region=\"view-content\"]",EMPTY_MESSAGE:"[data-region=\"empty-message\"]",LOADING_PLACEHOLDER:"[data-region=\"loading-placeholder\"]",PAGING_BAR:"[data-region=\"paging-bar\"]",PAGING_BAR_NEXT:"[data-control=\"next\"]",PAGING_BAR_PREVIOUS:"[data-control=\"previous\"]"},k=!1,l=[],m=null,n=null,o=0,p=1,q=function(a){a.find(j.EMPTY_MESSAGE).removeClass("hidden");a.find(j.LOADING_PLACEHOLDER).addClass("hidden");a.find(j.CONTENT).addClass("hidden")},r=function(a){a.find(j.CONTENT).removeClass("hidden");a.find(j.EMPTY_MESSAGE).addClass("hidden");a.find(j.LOADING_PLACEHOLDER).addClass("hidden")},s=function(a){var b=a.find(j.PAGING_BAR);b.css("opacity",1);b.css("visibility","visible");i.unhide(b)},t=function(a){var b=a.find(j.PAGING_BAR);b.css("opacity",0);b.css("visibility","hidden");i.hide(b)},u=function(a,b){l.forEach(function(a){if(a.attr("data-course-id")==b){a.find(j.COURSE_IS_FAVOURITE).removeClass("hidden")}})},v=function(a,b){l.forEach(function(a){if(a.attr("data-course-id")==b){a.find(j.COURSE_IS_FAVOURITE).addClass("hidden")}})},w=function(b){var d=a(j.BLOCK_CONTAINER).data("displaycoursecategory"),e=b.map(function(a){a.showcoursecategory=d;return f.render("block_recentlyaccessedcourses/course-card",a)});return a.when.apply(null,e).then(function(){var b=[];e.forEach(function(d){d.then(function(c){b.push(a(c))}).catch(c.exception)});return b})},x=function(a){return h.getLastAccessedCourses(a,10).then(function(a){return w(a)})},y=function(a){var b=a.find(j.CONTENT).find(j.CARD_CONTAINER),c=parseFloat(a.css("width")),d=l.length,f=0;if(!n){b.html(l[0]);n=l[0].outerWidth(!0)}p=Math.floor(c/n);if(o+p<d){f=o}else{var g=o+p-d;f=o-g;f=0<=f?f:0}var h=l.slice(f,f+p),i=h.reduce(function(a,b){return a+b.attr("data-course-id")},"");if(l.length>h.length){b.addClass("justify-content-center");b.removeClass("justify-content-start")}else{b.removeClass("justify-content-center");b.addClass("justify-content-start")}if(m!=i){var k=a.find(e.rootSelector);b.html(h);m=i;if(p>=l.length){t(a)}else{s(a);if(0===o){e.disablePreviousControlButtons(k)}else{e.enablePreviousControlButtons(k)}if(o+p>=l.length){e.disableNextControlButtons(k)}else{e.enableNextControlButtons(k)}}}},z=function(c){var e=null,f=!1;d.subscribe(g.favourited,function(a){u(c,a)});d.subscribe(g.unfavorited,function(a){v(c,a)});d.subscribe("nav-drawer-toggle-start",function(){if(!k||!l.length||f){return}f=!0;var a=0,b=function(){setTimeout(function(){y(c);a++;if(5>a&&f){b()}},100)};b(c)});d.subscribe("nav-drawer-toggle-end",function(){f=!1});a(window).on("resize",function(){if(!k||!l.length){return}if(!e){e=setTimeout(function(){e=null;y(c)},66)}});b.define(c,[b.events.activate]);c.on(b.events.activate,j.PAGING_BAR_NEXT,function(b,d){var e=a(b.target).closest(j.PAGING_BAR_NEXT);if(!e.hasClass("disabled")){o=o+p;y(c)}d.originalEvent.preventDefault()});c.on(b.events.activate,j.PAGING_BAR_PREVIOUS,function(b,d){var e=a(b.target).closest(j.PAGING_BAR_PREVIOUS);if(!e.hasClass("disabled")){o=o-p;o=0>o?0:o;y(c)}d.originalEvent.preventDefault()})};return{init:function init(b,d){d=a(d);z(d);x(b).then(function(a){l=a;k=!0;if(l.length){r(d);y(d)}else{q(d)}}).catch(c.exception)}}});
|
||||
//# sourceMappingURL=main.min.js.map
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -32,6 +32,7 @@ define(
|
||||
'core/templates',
|
||||
'core_course/events',
|
||||
'core_course/repository',
|
||||
'core/aria',
|
||||
],
|
||||
function(
|
||||
$,
|
||||
@@ -41,7 +42,8 @@ define(
|
||||
PagedContentPagingBar,
|
||||
Templates,
|
||||
CourseEvents,
|
||||
CoursesRepository
|
||||
CoursesRepository,
|
||||
Aria
|
||||
) {
|
||||
|
||||
// Constants.
|
||||
@@ -96,7 +98,7 @@ define(
|
||||
var pagingBar = root.find(SELECTORS.PAGING_BAR);
|
||||
pagingBar.css('opacity', 1);
|
||||
pagingBar.css('visibility', 'visible');
|
||||
pagingBar.attr('aria-hidden', 'false');
|
||||
Aria.unhide(pagingBar);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -108,7 +110,7 @@ define(
|
||||
var pagingBar = root.find(SELECTORS.PAGING_BAR);
|
||||
pagingBar.css('opacity', 0);
|
||||
pagingBar.css('visibility', 'hidden');
|
||||
pagingBar.attr('aria-hidden', 'true');
|
||||
Aria.hide(pagingBar);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
define ("core/aria",["exports","./local/aria/aria-hidden"],function(a,b){"use strict";Object.defineProperty(a,"__esModule",{value:!0});Object.defineProperty(a,"hide",{enumerable:!0,get:function get(){return b.hide}});Object.defineProperty(a,"unhide",{enumerable:!0,get:function get(){return b.unhide}});Object.defineProperty(a,"hideSiblings",{enumerable:!0,get:function get(){return b.hideSiblings}});Object.defineProperty(a,"unhideSiblings",{enumerable:!0,get:function get(){return b.unhideSiblings}})});
|
||||
//# sourceMappingURL=aria.min.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"aria.min.js"}
|
||||
Vendored
+1
-1
@@ -1,2 +1,2 @@
|
||||
function _typeof(a){"@babel/helpers - typeof";if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(a){return typeof a}}else{_typeof=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a}}return _typeof(a)}define ("core/drawer",["exports","jquery","core/pubsub","core/drawer_events"],function(a,b,c,d){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.default=void 0;b=g(b);c=f(c);d=g(d);function e(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;e=function(){return a};return a}function f(a){if(a&&a.__esModule){return a}if(null===a||"object"!==_typeof(a)&&"function"!=typeof a){return{default:a}}var b=e();if(b&&b.has(a)){return b.get(a)}var c={},d=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in a){if(Object.prototype.hasOwnProperty.call(a,f)){var g=d?Object.getOwnPropertyDescriptor(a,f):null;if(g&&(g.get||g.set)){Object.defineProperty(c,f,g)}else{c[f]=a[f]}}}c.default=a;if(b){b.set(a,c)}return c}function g(a){return a&&a.__esModule?a:{default:a}}var h=function(a){a.removeClass("hidden");a.attr("aria-expanded",!0);a.removeAttr("aria-hidden");a.focus();c.publish(d.default.DRAWER_SHOWN,a)},i=function(a){a.addClass("hidden");a.attr("aria-expanded",!1);a.attr("aria-hidden",!0);c.publish(d.default.DRAWER_HIDDEN,a)},j=function(a){var b=a.hasClass("hidden");return!b},k=function(a){if(j(a)){i(a)}else{h(a)}},l=function(a){a=(0,b.default)(a);return a.closest("[data-region=\"right-hand-drawer\"]")};a.default={hide:i,show:h,isVisible:j,toggle:k,registerToggles:function registerToggles(a,b){var c=null;b.attr("aria-expanded",j(a));b.on("click",function(d){d.preventDefault();var e=j(a);k(a);b.attr("aria-expanded",!e);if(!e){c=b.filter(function(a,b){return b==d.target||b.contains(d.target)})}else if(c){c.focus();c=null}})},getDrawerRoot:l};return a.default});
|
||||
function _typeof(a){"@babel/helpers - typeof";if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(a){return typeof a}}else{_typeof=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a}}return _typeof(a)}define ("core/drawer",["exports","jquery","core/pubsub","core/aria","core/drawer_events"],function(a,b,c,d,e){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.default=void 0;b=h(b);c=g(c);d=g(d);e=h(e);function f(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;f=function(){return a};return a}function g(a){if(a&&a.__esModule){return a}if(null===a||"object"!==_typeof(a)&&"function"!=typeof a){return{default:a}}var b=f();if(b&&b.has(a)){return b.get(a)}var c={},d=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var e in a){if(Object.prototype.hasOwnProperty.call(a,e)){var g=d?Object.getOwnPropertyDescriptor(a,e):null;if(g&&(g.get||g.set)){Object.defineProperty(c,e,g)}else{c[e]=a[e]}}}c.default=a;if(b){b.set(a,c)}return c}function h(a){return a&&a.__esModule?a:{default:a}}var i=function(a){a=(0,b.default)(a);d.unhide(a.get());a.removeClass("hidden");a.attr("aria-expanded",!0);a.focus();c.publish(e.default.DRAWER_SHOWN,a)},j=function(a){a=(0,b.default)(a);a.addClass("hidden");a.attr("aria-expanded",!1);d.hide(a.get());c.publish(e.default.DRAWER_HIDDEN,a)},k=function(a){var b=a.hasClass("hidden");return!b},l=function(a){if(k(a)){j(a)}else{i(a)}},m=function(a){a=(0,b.default)(a);return a.closest("[data-region=\"right-hand-drawer\"]")};a.default={hide:j,show:i,isVisible:k,toggle:l,registerToggles:function registerToggles(a,b){var c=null;b.attr("aria-expanded",k(a));b.on("click",function(d){d.preventDefault();var e=k(a);l(a);b.attr("aria-expanded",!e);if(!e){c=b.filter(function(a,b){return b==d.target||b.contains(d.target)})}else if(c){c.focus();c=null}})},getDrawerRoot:m};return a.default});
|
||||
//# sourceMappingURL=drawer.min.js.map
|
||||
|
||||
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2
@@ -0,0 +1,2 @@
|
||||
define ("core/local/aria/aria-hidden",["exports","core/normalise","./selectors"],function(a,b,c){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.unhideSiblings=a.hideSiblings=a.unhide=a.hide=void 0;c=function(a){return a&&a.__esModule?a:{default:a}}(c);var d=new Map,e=new Map,f=function(){return MutationObserver&&"function"==typeof MutationObserver},g=function(a){if(!(a instanceof HTMLElement)){return}if(a.matches(c.default.elements.focusable)){h(a)}a.querySelectorAll(c.default.elements.focusable).forEach(h)},h=function(a){if("undefined"!=typeof a.dataset.ariaHiddenTabIndex){return}if(a.getAttribute("tabindex")){a.dataset.ariaHiddenTabIndex=a.getAttribute("tabindex")}else{a.dataset.ariaHiddenTabIndex=""}a.setAttribute("tabindex",-1)},i=function(a){if(!(a instanceof HTMLElement)){return}if(a.matches(c.default.elements.focusableToUnhide)){j(a)}a.querySelectorAll(c.default.elements.focusableToUnhide).forEach(j)},j=function(a){if(a.closest(c.default.aria.hidden)){return}var b=a.dataset.ariaHiddenTabIndex;if(""===b){a.removeAttribute("tabindex")}else{a.setAttribute("tabindex",b)}delete a.dataset.ariaHiddenTabIndex},k=function(a){return(0,b.getList)(a).forEach(l)};a.hide=k;var l=function(a){if(!(a instanceof HTMLElement)){return}if(a.closest(c.default.aria.hidden)){return}a.setAttribute("aria-hidden",!0);g(a);if(f()){var b=new MutationObserver(function(a){a.forEach(function(a){a.addedNodes.forEach(g)})});b.observe(a,{childList:!0,subtree:!0});d.set(a,b)}},m=function(a){return(0,b.getList)(a).forEach(n)};a.unhide=m;var n=function(a){if(!(a instanceof HTMLElement)){return}a.removeAttribute("aria-hidden");i(a);if(d.has(a)){d.get(a).disconnect();d.delete(a)}};a.hideSiblings=function hideSiblings(a){return(0,b.getList)(a).forEach(o)};var o=function(a){if(!(a instanceof HTMLElement)){return}if(!a.parentElement){return}a.parentElement.childNodes.forEach(function(b){if(b===a){return}k(b)});if(f()){var b=new MutationObserver(function(b){b.forEach(function(b){b.addedNodes.forEach(function(b){if(a.contains(b)){return}k(b)})})});b.observe(a.parentElement,{childList:!0,subtree:!0});e.set(a.parentElement,b)}};a.unhideSiblings=function unhideSiblings(a){return(0,b.getList)(a).forEach(p)};var p=function(a){if(!(a instanceof HTMLElement)){return}if(!a.parentElement){return}a.parentElement.childNodes.forEach(function(b){if(b===a){return}m(b)});if(e.has(a.parentElement)){e.get(a.parentElement).disconnect();e.delete(a.parentElement)}}});
|
||||
//# sourceMappingURL=aria-hidden.min.js.map
|
||||
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,2 +1,2 @@
|
||||
define ("core/local/aria/focuslock",["exports"],function(a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.untrapFocus=a.trapFocus=void 0;var b={focusable:"input:not([type=\"hidden\"]), a[href], button, textarea, select, [tabindex]"},c=[],d=[],e=[],f=null,g=!1,h=!1,i=function(a){if(g){return}var b=n();if(!b.parentNode){s()}if(b.contains(a.target)){f=a.target}else{j();if(f==document.activeElement){k()}f=document.activeElement}},j=function(){var a=n(),c=Array.from(a.querySelectorAll(b.focusable));c.unshift(a);return c.some(function(a){return m(a)})},k=function(){var a=n(),c=Array.from(a.querySelectorAll(b.focusable)).reverse();c.push(a);return c.some(function(a){return m(a)})},l=function(a){if(0<a.tabIndex||0===a.tabIndex&&null!==a.getAttribute("tabIndex")){return!0}if(a.disabled){return!1}switch(a.nodeName){case"A":return!!a.href&&"ignore"!=a.rel;case"INPUT":return"hidden"!=a.type&&"file"!=a.type;case"BUTTON":case"SELECT":case"TEXTAREA":return!0;default:return!1;}},m=function(a){if(!l(a)){return!1}g=!0;try{a.focus()}catch(a){}g=!1;return document.activeElement===a},n=function(){return c[c.length-1]},o=function(a){if(a===n()){return}c.push(a);var b=n(),f=document.createElement("div");f.tabIndex=0;f.style.position="fixed";f.style.top=0;f.style.left=0;var g=f.cloneNode();b.parentNode.insertBefore(g,b);d.push(g);var h=f.cloneNode();b.parentNode.insertBefore(h,b.nextSibling);e.push(h)},p=function(){c.pop();var a=e.pop();if(a){a.remove()}var b=d.pop();if(b){b.remove()}},q=function(){return!!c.length},r=function(a){o(a);if(!h){document.addEventListener("focus",i,!0)}if(!j()){var b=n(),c=b.tabIndex;b.tabIndex=0;m(b);b.tabIndex=c}f=document.activeElement;h=!0};a.trapFocus=r;var s=function(){p();if(q()){return}document.removeEventListener("focus",i,!0);f=null;g=!1;h=!1};a.untrapFocus=s});
|
||||
define ("core/local/aria/focuslock",["exports","./selectors"],function(a,b){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.untrapFocus=a.trapFocus=void 0;b=function(a){return a&&a.__esModule?a:{default:a}}(b);var c=[],d=[],e=[],f=null,g=!1,h=!1,i=function(a){if(g){return}var b=n();if(!b.parentNode){s()}if(b.contains(a.target)){f=a.target}else{j();if(f==document.activeElement){k()}f=document.activeElement}},j=function(){var a=n(),c=Array.from(a.querySelectorAll(b.default.elements.focusable));c.unshift(a);return c.some(function(a){return m(a)})},k=function(){var a=n(),c=Array.from(a.querySelectorAll(b.default.elements.focusable)).reverse();c.push(a);return c.some(function(a){return m(a)})},l=function(a){if(0<a.tabIndex||0===a.tabIndex&&null!==a.getAttribute("tabIndex")){return!0}if(a.disabled){return!1}switch(a.nodeName){case"A":return!!a.href&&"ignore"!=a.rel;case"INPUT":return"hidden"!=a.type&&"file"!=a.type;case"BUTTON":case"SELECT":case"TEXTAREA":return!0;default:return!1;}},m=function(a){if(!l(a)){return!1}g=!0;try{a.focus()}catch(a){}g=!1;return document.activeElement===a},n=function(){return c[c.length-1]},o=function(a){if(a===n()){return}c.push(a);var b=n(),f=document.createElement("div");f.tabIndex=0;f.style.position="fixed";f.style.top=0;f.style.left=0;var g=f.cloneNode();b.parentNode.insertBefore(g,b);d.push(g);var h=f.cloneNode();b.parentNode.insertBefore(h,b.nextSibling);e.push(h)},p=function(){c.pop();var a=e.pop();if(a){a.remove()}var b=d.pop();if(b){b.remove()}},q=function(){return!!c.length},r=function(a){o(a);if(!h){document.addEventListener("focus",i,!0)}if(!j()){var b=n(),c=b.tabIndex;b.tabIndex=0;m(b);b.tabIndex=c}f=document.activeElement;h=!0};a.trapFocus=r;var s=function(){p();if(q()){return}document.removeEventListener("focus",i,!0);f=null;g=!1;h=!1};a.untrapFocus=s});
|
||||
//# sourceMappingURL=focuslock.min.js.map
|
||||
|
||||
File diff suppressed because one or more lines are too long
+2
@@ -0,0 +1,2 @@
|
||||
define ("core/local/aria/selectors",["exports"],function(a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.default=void 0;a.default={aria:{hidden:"[aria-hidden]"},elements:{focusable:"input:not([type=\"hidden\"]), a[href], button, textarea, select, [tabindex]",focusableToUnhide:"[data-aria-hidden-tab-index]"}};return a.default});
|
||||
//# sourceMappingURL=selectors.min.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/local/aria/selectors.js"],"names":["aria","hidden","elements","focusable","focusableToUnhide"],"mappings":"qJAwBe,CACXA,IAAI,CAAE,CACFC,MAAM,CAAE,eADN,CADK,CAIXC,QAAQ,CAAE,CACNC,SAAS,CAAE,6EADL,CAENC,iBAAiB,CAAE,8BAFb,CAJC,C","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Selectors used for ARIA.\n *\n * @module core/local/aria/selectors\n * @class selectors\n * @package core\n * @copyright 2020 Andrew Nicols <[email protected]>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nexport default {\n aria: {\n hidden: '[aria-hidden]',\n },\n elements: {\n focusable: 'input:not([type=\"hidden\"]), a[href], button, textarea, select, [tabindex]',\n focusableToUnhide: '[data-aria-hidden-tab-index]',\n },\n};\n"],"file":"selectors.min.js"}
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
define ("core/normalise",["exports","jquery"],function(a,b){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.getList=void 0;b=function(a){return a&&a.__esModule?a:{default:a}}(b);var c=function(a){if(a instanceof HTMLElement){return[a]}if(a instanceof Array){return a}if(a instanceof NodeList){return Array.from(a)}if(a instanceof b.default){return a.get()}return Array.from(a)};a.getList=c});
|
||||
//# sourceMappingURL=normalise.min.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../src/normalise.js"],"names":["getList","nodes","HTMLElement","Array","NodeList","from","jQuery","get"],"mappings":"2IAyBA,uDAEO,GAAMA,CAAAA,CAAO,CAAG,SAAAC,CAAK,CAAI,CAC5B,GAAIA,CAAK,WAAYC,CAAAA,WAArB,CAAkC,CAE9B,MAAO,CAACD,CAAD,CACV,CAED,GAAIA,CAAK,WAAYE,CAAAA,KAArB,CAA4B,CAExB,MAAOF,CAAAA,CACV,CAED,GAAIA,CAAK,WAAYG,CAAAA,QAArB,CAA+B,CAE3B,MAAOD,CAAAA,KAAK,CAACE,IAAN,CAAWJ,CAAX,CACV,CAED,GAAIA,CAAK,WAAYK,UAArB,CAA6B,CAEzB,MAAOL,CAAAA,CAAK,CAACM,GAAN,EACV,CAGD,MAAOJ,CAAAA,KAAK,CAACE,IAAN,CAAWJ,CAAX,CACV,CAvBM,C","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Normalisation helpers.\n *\n * @module core/normalise\n * @class normalise\n * @package core\n * @copyright 2020 Andrew Nicols <[email protected]>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport jQuery from 'jquery';\n\nexport const getList = nodes => {\n if (nodes instanceof HTMLElement) {\n // A single record to conver to a NodeList.\n return [nodes];\n }\n\n if (nodes instanceof Array) {\n // A single record to conver to a NodeList.\n return nodes;\n }\n\n if (nodes instanceof NodeList) {\n // Already a NodeList.\n return Array.from(nodes);\n }\n\n if (nodes instanceof jQuery) {\n // A jQuery object to a NodeList.\n return nodes.get();\n }\n\n // Fallback to just having a go.\n return Array.from(nodes);\n};\n"],"file":"normalise.min.js"}
|
||||
Vendored
+1
-1
@@ -1,2 +1,2 @@
|
||||
define ("core/tooltip",["jquery"],function(a){var b=function(b){this._regionSelector=b;a(this._regionSelector).each(function(b,c){var d=a(c).attr("aria-describedby");if(d){var e=document.getElementById(d);if(e){var f="tooltip"==a(e).attr("role");if(f){a(e).hide();a(c).attr("tabindex","0")}a(c).on("focus",this._handleFocus.bind(this));a(c).on("mouseover",this._handleMouseOver.bind(this));a(c).on("mouseout",this._handleMouseOut.bind(this));a(c).on("blur",this._handleBlur.bind(this));a(c).on("keydown",this._handleKeyDown.bind(this))}}}.bind(this))};b.prototype._regionSelector=null;b.prototype._showTooltip=function(b){var c=a(b.target),d=c.attr("aria-describedby");if(d){var e=a(document.getElementById(d));e.show();e.attr("aria-hidden","false");if(!e.is(".tooltip")){var f=a("<div class=\"tooltip-inner\"></div>");f.append(e.contents());e.append(f);e.addClass("tooltip");e.addClass("bottom");e.append("<div class=\"tooltip-arrow\"></div>")}var g=c.offset();g.top+=c.height()+10;a(e).offset(g)}};b.prototype._hideTooltip=function(b){var c=a(b.target),d=c.attr("aria-describedby");if(d){var e=document.getElementById(d);a(e).hide();a(e).attr("aria-hidden","true")}};b.prototype._handleFocus=function(a){this._showTooltip(a)};b.prototype._handleKeyDown=function(a){if(27==a.which){this._hideTooltip(a)}};b.prototype._handleMouseOver=function(a){this._showTooltip(a)};b.prototype._handleMouseOut=function(b){var c=a(b.target);if(!c.is(":focus")){this._hideTooltip(b)}};b.prototype._handleBlur=function(a){this._hideTooltip(a)};return b});
|
||||
define ("core/tooltip",["jquery","core/aria"],function(a,b){var c=function(b){this._regionSelector=b;a(this._regionSelector).each(function(b,c){var d=a(c).attr("aria-describedby");if(d){var e=document.getElementById(d);if(e){var f="tooltip"==a(e).attr("role");if(f){a(e).hide();a(c).attr("tabindex","0")}a(c).on("focus",this._handleFocus.bind(this));a(c).on("mouseover",this._handleMouseOver.bind(this));a(c).on("mouseout",this._handleMouseOut.bind(this));a(c).on("blur",this._handleBlur.bind(this));a(c).on("keydown",this._handleKeyDown.bind(this))}}}.bind(this))};c.prototype._regionSelector=null;c.prototype._showTooltip=function(c){var d=a(c.target),e=d.attr("aria-describedby");if(e){var f=a(document.getElementById(e));f.show();b.unhide(f);if(!f.is(".tooltip")){var g=a("<div class=\"tooltip-inner\"></div>");g.append(f.contents());f.append(g);f.addClass("tooltip");f.addClass("bottom");f.append("<div class=\"tooltip-arrow\"></div>")}var h=d.offset();h.top+=d.height()+10;a(f).offset(h)}};c.prototype._hideTooltip=function(c){var d=a(c.target),e=d.attr("aria-describedby");if(e){var f=document.getElementById(e);a(f).hide();b.hide(f)}};c.prototype._handleFocus=function(a){this._showTooltip(a)};c.prototype._handleKeyDown=function(a){if(27==a.which){this._hideTooltip(a)}};c.prototype._handleMouseOver=function(a){this._showTooltip(a)};c.prototype._handleMouseOut=function(b){var c=a(b.target);if(!c.is(":focus")){this._hideTooltip(b)}};c.prototype._handleBlur=function(a){this._hideTooltip(a)};return c});
|
||||
//# sourceMappingURL=tooltip.min.js.map
|
||||
|
||||
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,31 @@
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Helpers to perform ARIA compliance changes to the DOM.
|
||||
*
|
||||
* @module core/aria
|
||||
* @class aria
|
||||
* @package core
|
||||
* @copyright 2020 Andrew Nicols <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
export {
|
||||
hide,
|
||||
unhide,
|
||||
hideSiblings,
|
||||
unhideSiblings,
|
||||
} from './local/aria/aria-hidden';
|
||||
+12
-4
@@ -22,6 +22,7 @@
|
||||
*/
|
||||
import $ from 'jquery';
|
||||
import * as PubSub from 'core/pubsub';
|
||||
import * as Aria from 'core/aria';
|
||||
import DrawerEvents from 'core/drawer_events';
|
||||
|
||||
/**
|
||||
@@ -29,10 +30,13 @@ import DrawerEvents from 'core/drawer_events';
|
||||
*
|
||||
* @param {Object} root The drawer container.
|
||||
*/
|
||||
const show = (root) => {
|
||||
const show = root => {
|
||||
// Ensure that it is a jQuery.
|
||||
root = $(root);
|
||||
|
||||
Aria.unhide(root.get());
|
||||
root.removeClass('hidden');
|
||||
root.attr('aria-expanded', true);
|
||||
root.removeAttr('aria-hidden');
|
||||
root.focus();
|
||||
|
||||
PubSub.publish(DrawerEvents.DRAWER_SHOWN, root);
|
||||
@@ -43,10 +47,14 @@ const show = (root) => {
|
||||
*
|
||||
* @param {Object} root The drawer container.
|
||||
*/
|
||||
const hide = (root) => {
|
||||
const hide = root => {
|
||||
// Ensure that it is a jQuery.
|
||||
root = $(root);
|
||||
|
||||
root.addClass('hidden');
|
||||
root.attr('aria-expanded', false);
|
||||
root.attr('aria-hidden', true);
|
||||
Aria.hide(root.get());
|
||||
|
||||
PubSub.publish(DrawerEvents.DRAWER_HIDDEN, root);
|
||||
};
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
*/
|
||||
/* globals require: false */
|
||||
define(
|
||||
['jquery', 'core/log', 'core/str', 'core/templates', 'core/notification', 'core/loadingicon'],
|
||||
function($, log, str, templates, notification, LoadingIcon) {
|
||||
['jquery', 'core/log', 'core/str', 'core/templates', 'core/notification', 'core/loadingicon', 'core/aria'],
|
||||
function($, log, str, templates, notification, LoadingIcon, Aria) {
|
||||
|
||||
// Private functions and variables.
|
||||
/** @var {Object} KEYS - List of keycode constants. */
|
||||
@@ -200,14 +200,14 @@ function($, log, str, templates, notification, LoadingIcon) {
|
||||
var suggestionsElement = $(document.getElementById(state.suggestionsId));
|
||||
|
||||
// Count the visible items.
|
||||
var length = suggestionsElement.children('[aria-hidden=false]').length;
|
||||
var length = suggestionsElement.children(':not([aria-hidden])').length;
|
||||
// Limit the index to the upper/lower bounds of the list (wrap in both directions).
|
||||
index = index % length;
|
||||
while (index < 0) {
|
||||
index += length;
|
||||
}
|
||||
// Find the specified element.
|
||||
var element = $(suggestionsElement.children('[aria-hidden=false]').get(index));
|
||||
var element = $(suggestionsElement.children(':not([aria-hidden])').get(index));
|
||||
// Find the index of this item in the full list of suggestions (including hidden).
|
||||
var globalIndex = $(suggestionsElement.children('[role=option]')).index(element);
|
||||
// Create an id we can assign to this element.
|
||||
@@ -244,7 +244,7 @@ function($, log, str, templates, notification, LoadingIcon) {
|
||||
// Find the active one.
|
||||
var element = suggestionsElement.children('[aria-selected=true]');
|
||||
// Find it's index.
|
||||
var current = suggestionsElement.children('[aria-hidden=false]').index(element);
|
||||
var current = suggestionsElement.children(':not([aria-hidden])').index(element);
|
||||
// Activate the next one.
|
||||
return activateItem(current + 1, state);
|
||||
};
|
||||
@@ -315,7 +315,7 @@ function($, log, str, templates, notification, LoadingIcon) {
|
||||
var element = suggestionsElement.children('[aria-selected=true]');
|
||||
|
||||
// Find it's index.
|
||||
var current = suggestionsElement.children('[aria-hidden=false]').index(element);
|
||||
var current = suggestionsElement.children(':not([aria-hidden])').index(element);
|
||||
|
||||
// Activate the previous one.
|
||||
return activateItem(current - 1, state);
|
||||
@@ -338,7 +338,8 @@ function($, log, str, templates, notification, LoadingIcon) {
|
||||
inputElement.attr('aria-expanded', false).attr('aria-activedescendant', state.selectionId);
|
||||
|
||||
// Hide the suggestions list (from screen readers too).
|
||||
suggestionsElement.hide().attr('aria-hidden', true);
|
||||
Aria.hide(suggestionsElement.get());
|
||||
suggestionsElement.hide();
|
||||
|
||||
return $.Deferred().resolve();
|
||||
};
|
||||
@@ -385,17 +386,22 @@ function($, log, str, templates, notification, LoadingIcon) {
|
||||
|
||||
// Get the element again.
|
||||
suggestionsElement = $(document.getElementById(state.suggestionsId));
|
||||
|
||||
// Show it if it is hidden.
|
||||
suggestionsElement.show().attr('aria-hidden', false);
|
||||
Aria.unhide(suggestionsElement.get());
|
||||
suggestionsElement.show();
|
||||
|
||||
// For each option in the list, hide it if it doesn't match the query.
|
||||
suggestionsElement.children().each(function(index, node) {
|
||||
node = $(node);
|
||||
if ((options.caseSensitive && node.text().indexOf(searchquery) > -1) ||
|
||||
(!options.caseSensitive && node.text().toLocaleLowerCase().indexOf(searchquery) > -1)) {
|
||||
node.show().attr('aria-hidden', false);
|
||||
Aria.unhide(node.get());
|
||||
node.show();
|
||||
matchingElements = true;
|
||||
} else {
|
||||
node.hide().attr('aria-hidden', true);
|
||||
node.hide();
|
||||
Aria.hide(node.get());
|
||||
}
|
||||
});
|
||||
// If we found any matches, show the list.
|
||||
@@ -779,7 +785,7 @@ function($, log, str, templates, notification, LoadingIcon) {
|
||||
var element = $(e.currentTarget).closest('[role=option]');
|
||||
var suggestionsElement = $(document.getElementById(state.suggestionsId));
|
||||
// Find the index of the clicked on suggestion.
|
||||
var current = suggestionsElement.children('[aria-hidden=false]').index(element);
|
||||
var current = suggestionsElement.children(':not([aria-hidden])').index(element);
|
||||
|
||||
// Activate it.
|
||||
activateItem(current, state)
|
||||
@@ -1020,7 +1026,8 @@ function($, log, str, templates, notification, LoadingIcon) {
|
||||
return false;
|
||||
}
|
||||
|
||||
originalSelect.css('visibility', 'hidden').attr('aria-hidden', true);
|
||||
Aria.hide(originalSelect.get());
|
||||
originalSelect.css('visibility', 'hidden');
|
||||
|
||||
// Hide the original select.
|
||||
|
||||
@@ -1105,7 +1112,8 @@ function($, log, str, templates, notification, LoadingIcon) {
|
||||
|
||||
var suggestionsElement = $(document.getElementById(state.suggestionsId));
|
||||
// Hide the suggestions by default.
|
||||
suggestionsElement.hide().attr('aria-hidden', true);
|
||||
suggestionsElement.hide();
|
||||
Aria.hide(suggestionsElement.get());
|
||||
|
||||
return;
|
||||
})
|
||||
|
||||
@@ -0,0 +1,267 @@
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* ARIA helpers related to the aria-hidden attribute.
|
||||
*
|
||||
* @module core/local/aria/aria-hidden.
|
||||
* @class aria
|
||||
* @package core
|
||||
* @copyright 2020 Andrew Nicols <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
import {getList} from 'core/normalise';
|
||||
import Selectors from './selectors';
|
||||
|
||||
// The map of MutationObserver objects for an object.
|
||||
const childObserverMap = new Map();
|
||||
const siblingObserverMap = new Map();
|
||||
|
||||
/**
|
||||
* Determine whether the browser supports the MutationObserver system.
|
||||
*
|
||||
* @returns {Bool}
|
||||
*/
|
||||
const supportsMutationObservers = () => (MutationObserver && typeof MutationObserver === 'function');
|
||||
|
||||
/**
|
||||
* Disable element focusability, disabling the tabindex for child elements which are normally focusable.
|
||||
*
|
||||
* @param {HTMLElement} target
|
||||
*/
|
||||
const disableElementFocusability = target => {
|
||||
if (!(target instanceof HTMLElement)) {
|
||||
// This element is not an HTMLElement.
|
||||
// This can happen for Text Nodes.
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.matches(Selectors.elements.focusable)) {
|
||||
disableAndStoreTabIndex(target);
|
||||
}
|
||||
|
||||
target.querySelectorAll(Selectors.elements.focusable).forEach(disableAndStoreTabIndex);
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove the current tab-index and store it for later restoration.
|
||||
*
|
||||
* @param {HTMLElement} element
|
||||
*/
|
||||
const disableAndStoreTabIndex = element => {
|
||||
if (typeof element.dataset.ariaHiddenTabIndex !== 'undefined') {
|
||||
// This child already has a hidden attribute.
|
||||
// Do not modify it as the original value will be lost.
|
||||
return;
|
||||
}
|
||||
|
||||
// Store the old tabindex in a data attribute.
|
||||
if (element.getAttribute('tabindex')) {
|
||||
element.dataset.ariaHiddenTabIndex = element.getAttribute('tabindex');
|
||||
} else {
|
||||
element.dataset.ariaHiddenTabIndex = '';
|
||||
}
|
||||
element.setAttribute('tabindex', -1);
|
||||
};
|
||||
|
||||
/**
|
||||
* Re-enable element focusability, restoring any tabindex.
|
||||
*
|
||||
* @param {HTMLElement} target
|
||||
*/
|
||||
const enableElementFocusability = target => {
|
||||
if (!(target instanceof HTMLElement)) {
|
||||
// This element is not an HTMLElement.
|
||||
// This can happen for Text Nodes.
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.matches(Selectors.elements.focusableToUnhide)) {
|
||||
restoreTabIndex(target);
|
||||
}
|
||||
|
||||
target.querySelectorAll(Selectors.elements.focusableToUnhide).forEach(restoreTabIndex);
|
||||
};
|
||||
|
||||
/**
|
||||
* Restore the tab-index of the supplied element.
|
||||
*
|
||||
* When disabling focusability the current tab-index is stored in the ariaHiddenTabIndex data attribute.
|
||||
* This is used to restore the tab-index, but only whilst the parent nodes remain unhidden.
|
||||
*
|
||||
* @param {HTMLElement} element
|
||||
*/
|
||||
const restoreTabIndex = element => {
|
||||
if (element.closest(Selectors.aria.hidden)) {
|
||||
// This item still has a hidden parent, or is hidden itself. Do not unhide it.
|
||||
return;
|
||||
}
|
||||
|
||||
const oldTabIndex = element.dataset.ariaHiddenTabIndex;
|
||||
if (oldTabIndex === '') {
|
||||
element.removeAttribute('tabindex');
|
||||
} else {
|
||||
element.setAttribute('tabindex', oldTabIndex);
|
||||
}
|
||||
|
||||
delete element.dataset.ariaHiddenTabIndex;
|
||||
};
|
||||
|
||||
/**
|
||||
* Update the supplied DOM Module to be hidden.
|
||||
*
|
||||
* @param {HTMLElement} target
|
||||
* @returns {Array}
|
||||
*/
|
||||
export const hide = target => getList(target).forEach(_hide);
|
||||
|
||||
const _hide = target => {
|
||||
if (!(target instanceof HTMLElement)) {
|
||||
// This element is not an HTMLElement.
|
||||
// This can happen for Text Nodes.
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.closest(Selectors.aria.hidden)) {
|
||||
// This Element, or a parent Element, is already hidden.
|
||||
// Stop processing.
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the aria-hidden attribute to true.
|
||||
target.setAttribute('aria-hidden', true);
|
||||
|
||||
// Based on advice from https://dequeuniversity.com/rules/axe/3.3/aria-hidden-focus, upon setting the aria-hidden
|
||||
// attribute, all focusable elements underneath that element should be modified such that they are not focusable.
|
||||
disableElementFocusability(target);
|
||||
|
||||
if (supportsMutationObservers()) {
|
||||
// Add a MutationObserver to check for new children to the tree.
|
||||
const newNodeObserver = new MutationObserver(mutationList => {
|
||||
mutationList.forEach(mutation => {
|
||||
mutation.addedNodes.forEach(disableElementFocusability);
|
||||
});
|
||||
});
|
||||
|
||||
newNodeObserver.observe(target, {childList: true, subtree: true});
|
||||
childObserverMap.set(target, newNodeObserver);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Reverse the effect of the hide action.
|
||||
*
|
||||
* @param {HTMLElement} target
|
||||
* @returns {Array}
|
||||
*/
|
||||
export const unhide = target => getList(target).forEach(_unhide);
|
||||
|
||||
const _unhide = target => {
|
||||
if (!(target instanceof HTMLElement)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Note: The aria-hidden attribute should be removed, and not set to false.
|
||||
// The presence of the attribute is sufficient for some browsers to treat it as being true, regardless of its value.
|
||||
target.removeAttribute('aria-hidden');
|
||||
|
||||
// Restore the tabindex across all child nodes of the target.
|
||||
enableElementFocusability(target);
|
||||
|
||||
// Remove the focusability MutationObserver watching this tree.
|
||||
if (childObserverMap.has(target)) {
|
||||
childObserverMap.get(target).disconnect();
|
||||
childObserverMap.delete(target);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Correctly mark all siblings of the supplied target Element as hidden.
|
||||
*
|
||||
* @param {HTMLElement} target
|
||||
* @returns {Array}
|
||||
*/
|
||||
export const hideSiblings = target => getList(target).forEach(_hideSiblings);
|
||||
|
||||
const _hideSiblings = target => {
|
||||
if (!(target instanceof HTMLElement)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!target.parentElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
target.parentElement.childNodes.forEach(node => {
|
||||
if (node === target) {
|
||||
// Skip self;
|
||||
return;
|
||||
}
|
||||
|
||||
hide(node);
|
||||
});
|
||||
|
||||
if (supportsMutationObservers()) {
|
||||
// Add a MutationObserver to check for new children to the tree.
|
||||
const newNodeObserver = new MutationObserver(mutationList => {
|
||||
mutationList.forEach(mutation => {
|
||||
mutation.addedNodes.forEach(node => {
|
||||
if (target.contains(node)) {
|
||||
// Skip self, and children of self.
|
||||
return;
|
||||
}
|
||||
|
||||
hide(node);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
newNodeObserver.observe(target.parentElement, {childList: true, subtree: true});
|
||||
siblingObserverMap.set(target.parentElement, newNodeObserver);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Correctly reverse the hide action of all children of the supplied target Element.
|
||||
*
|
||||
* @param {HTMLElement} target
|
||||
* @returns {Array}
|
||||
*/
|
||||
export const unhideSiblings = target => getList(target).forEach(_unhideSiblings);
|
||||
|
||||
const _unhideSiblings = target => {
|
||||
if (!(target instanceof HTMLElement)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!target.parentElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
target.parentElement.childNodes.forEach(node => {
|
||||
if (node === target) {
|
||||
// Skip self;
|
||||
return;
|
||||
}
|
||||
|
||||
unhide(node);
|
||||
});
|
||||
|
||||
// Remove the sibling MutationObserver watching this tree.
|
||||
if (siblingObserverMap.has(target.parentElement)) {
|
||||
siblingObserverMap.get(target.parentElement).disconnect();
|
||||
siblingObserverMap.delete(target.parentElement);
|
||||
}
|
||||
};
|
||||
@@ -25,9 +25,7 @@
|
||||
* @copyright 2019 Andrew Nicols <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
const selectors = {
|
||||
focusable: 'input:not([type="hidden"]), a[href], button, textarea, select, [tabindex]',
|
||||
};
|
||||
import Selectors from './selectors';
|
||||
|
||||
const lockRegionStack = [];
|
||||
const initialFocusElementStack = [];
|
||||
@@ -90,7 +88,7 @@ const focusFirstDescendant = () => {
|
||||
// For example, a disabled text area cannot be focused, and it becomes difficult to provide a decent query selector
|
||||
// to capture this.
|
||||
// The use of Array.some just ensures that we stop as soon as we have a successful focus.
|
||||
const focusableElements = Array.from(lockRegion.querySelectorAll(selectors.focusable));
|
||||
const focusableElements = Array.from(lockRegion.querySelectorAll(Selectors.elements.focusable));
|
||||
|
||||
// The lock region itself may be focusable. This is particularly true on Moodle's older dialogues.
|
||||
// We must include it in the calculation of descendants to ensure that looping works correctly.
|
||||
@@ -111,7 +109,7 @@ const focusLastDescendant = () => {
|
||||
// For example, a disabled text area cannot be focused, and it becomes difficult to provide a decent query selector
|
||||
// to capture this.
|
||||
// The use of Array.some just ensures that we stop as soon as we have a successful focus.
|
||||
const focusableElements = Array.from(lockRegion.querySelectorAll(selectors.focusable)).reverse();
|
||||
const focusableElements = Array.from(lockRegion.querySelectorAll(Selectors.elements.focusable)).reverse();
|
||||
|
||||
// The lock region itself may be focusable. This is particularly true on Moodle's older dialogues.
|
||||
// We must include it in the calculation of descendants to ensure that looping works correctly.
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Selectors used for ARIA.
|
||||
*
|
||||
* @module core/local/aria/selectors
|
||||
* @class selectors
|
||||
* @package core
|
||||
* @copyright 2020 Andrew Nicols <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
export default {
|
||||
aria: {
|
||||
hidden: '[aria-hidden]',
|
||||
},
|
||||
elements: {
|
||||
focusable: 'input:not([type="hidden"]), a[href], button, textarea, select, [tabindex]',
|
||||
focusableToUnhide: '[data-aria-hidden-tab-index]',
|
||||
},
|
||||
};
|
||||
+10
-41
@@ -33,7 +33,8 @@ define([
|
||||
'core/modal_events',
|
||||
'core/local/aria/focuslock',
|
||||
'core/pending',
|
||||
], function($, Templates, Notification, KeyCodes, CustomEvents, ModalBackdrop, Event, ModalEvents, FocusLock, Pending) {
|
||||
'core/aria',
|
||||
], function($, Templates, Notification, KeyCodes, CustomEvents, ModalBackdrop, Event, ModalEvents, FocusLock, Pending, Aria) {
|
||||
|
||||
var SELECTORS = {
|
||||
CONTAINER: '[data-region="modal-container"]',
|
||||
@@ -732,30 +733,11 @@ define([
|
||||
* @method accessibilityShow
|
||||
*/
|
||||
Modal.prototype.accessibilityShow = function() {
|
||||
// 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
|
||||
// the fact that this dialogue is always appended to the document body therefore
|
||||
// it's siblings are the shallowest non-ancestral nodes. If that changes then
|
||||
// this code should also be updated.
|
||||
$('body').children().each(function(index, child) {
|
||||
// Skip the current modal.
|
||||
if (!this.root.is(child)) {
|
||||
child = $(child);
|
||||
var hidden = child.attr('aria-hidden');
|
||||
// If they are already hidden we can ignore them.
|
||||
if (hidden !== 'true') {
|
||||
// Save their current state.
|
||||
child.data('previous-aria-hidden', hidden);
|
||||
this.hiddenSiblings.push(child);
|
||||
|
||||
// Hide this node from screen readers.
|
||||
child.attr('aria-hidden', 'true');
|
||||
}
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
// Make us visible to screen readers.
|
||||
this.root.attr('aria-hidden', 'false');
|
||||
Aria.unhide(this.root.get());
|
||||
|
||||
// Hide siblings.
|
||||
Aria.hideSiblings(this.root.get()[0]);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -766,24 +748,11 @@ define([
|
||||
* @method accessibilityHide
|
||||
*/
|
||||
Modal.prototype.accessibilityHide = function() {
|
||||
this.root.attr('aria-hidden', 'true');
|
||||
// Unhide siblings.
|
||||
Aria.unhideSiblings(this.root.get()[0]);
|
||||
|
||||
// Restore the sibling nodes back to their original values.
|
||||
$.each(this.hiddenSiblings, function(index, sibling) {
|
||||
sibling = $(sibling);
|
||||
var previousValue = sibling.data('previous-aria-hidden');
|
||||
// If the element didn't previously have an aria-hidden attribute
|
||||
// then we can just remove the one we set.
|
||||
if (typeof previousValue == 'undefined') {
|
||||
sibling.removeAttr('aria-hidden');
|
||||
} else {
|
||||
// Otherwise set it back to the old value (which will be false).
|
||||
sibling.attr('aria-hidden', previousValue);
|
||||
}
|
||||
});
|
||||
|
||||
// Clear the cache. No longer need to store these.
|
||||
this.hiddenSiblings = [];
|
||||
// Hide this modal.
|
||||
Aria.hide(this.root.get());
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Normalisation helpers.
|
||||
*
|
||||
* @module core/normalise
|
||||
* @class normalise
|
||||
* @package core
|
||||
* @copyright 2020 Andrew Nicols <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
import jQuery from 'jquery';
|
||||
|
||||
export const getList = nodes => {
|
||||
if (nodes instanceof HTMLElement) {
|
||||
// A single record to conver to a NodeList.
|
||||
return [nodes];
|
||||
}
|
||||
|
||||
if (nodes instanceof Array) {
|
||||
// A single record to conver to a NodeList.
|
||||
return nodes;
|
||||
}
|
||||
|
||||
if (nodes instanceof NodeList) {
|
||||
// Already a NodeList.
|
||||
return Array.from(nodes);
|
||||
}
|
||||
|
||||
if (nodes instanceof jQuery) {
|
||||
// A jQuery object to a NodeList.
|
||||
return nodes.get();
|
||||
}
|
||||
|
||||
// Fallback to just having a go.
|
||||
return Array.from(nodes);
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['jquery'], function($) {
|
||||
define(['jquery', 'core/aria'], function($, Aria) {
|
||||
|
||||
/**
|
||||
* Tooltip class.
|
||||
@@ -50,7 +50,7 @@ define(['jquery'], function($) {
|
||||
var tooltipele = $(document.getElementById(tooltipId));
|
||||
|
||||
tooltipele.show();
|
||||
tooltipele.attr('aria-hidden', 'false');
|
||||
Aria.unhide(tooltipele);
|
||||
|
||||
if (!tooltipele.is('.tooltip')) {
|
||||
// Change the markup to a bootstrap tooltip.
|
||||
@@ -79,7 +79,7 @@ define(['jquery'], function($) {
|
||||
var tooltipele = document.getElementById(tooltipId);
|
||||
|
||||
$(tooltipele).hide();
|
||||
$(tooltipele).attr('aria-hidden', 'true');
|
||||
Aria.hide(tooltipele);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+1
-1
@@ -303,7 +303,7 @@ define(['jquery'], function($) {
|
||||
Tree.prototype.finishExpandingGroup = function(item) {
|
||||
// Expand the group.
|
||||
var group = this.getGroupFromItem(item);
|
||||
group.attr('aria-hidden', 'false');
|
||||
group.removeAttr('aria-hidden');
|
||||
item.attr('aria-expanded', 'true');
|
||||
|
||||
// Update the list of visible items.
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
function _typeof(a){"@babel/helpers - typeof";if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(a){return typeof a}}else{_typeof=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a}}return _typeof(a)}define ("core_message/message_drawer_router",["jquery","core/pubsub","core/str","core_message/message_drawer_events"],function(a,b,c,d){var e={},f={},g={CAN_RECEIVE_FOCUS:"input:not([type=\"hidden\"]), a[href], button, textarea, select, [tabindex]",ROUTES_BACK:"[data-route-back]"},h=function(c,f){var h,j=[].slice.call(arguments).some(function(a){return"frompanel"==a}),k=[].slice.call(arguments,2),l=a.Deferred().resolve().promise();Object.keys(e[c]).forEach(function(a){var b=e[c][a],d=a===f;if(d){h=b}b.parameters.forEach(function(a){if("object"!==_typeof(a)||null===a){return}a.removeClass("previous");a.attr("data-from-panel",!1);if(d){if(j){a.attr("data-from-panel",!0)}a.removeClass("hidden");a.attr("aria-hidden",!1)}else{if(!a.attr("data-in-panel")){a.addClass("hidden");a.attr("aria-hidden",!0)}else if("view-search"==f||"view-overview"==f){a.addClass("hidden");a.attr("aria-hidden",!0)}}})});if(h){if(h.onGo){l=h.onGo.apply(void 0,h.parameters.concat(k));for(var m=a(document.activeElement),n=!1,o=null,p=1,q;p<h.parameters.length;p++){q=h.parameters[p];if("object"!==_typeof(q)||null===q){continue}if(!o){o=q}if(q.has(m).length){n=!0;break}}if(!n){o.find(g.CAN_RECEIVE_FOCUS).filter(":visible").first().focus()}}}var r={route:f,params:k,renderPromise:l};b.publish(d.ROUTE_CHANGED,r);return r},i=function(b){var d=a(document.activeElement),j=h.apply(b,arguments),k=!1;if(!f[b]){f[b]=[]}f[b]=f[b].reduce(function(a,b){if(b.route===j.route){k=!0}if(!k){a.push(b)}return a},[]);var l=f[b].length,m=l?f[b][l-1]:null;if(m){for(var n=e[b][m.route],o=n.parameters,p=1;p<o.length;p++){if("object"!==_typeof(o[p])||null===o[p]){continue}o[p].addClass("previous")}m.focusElement=d;if(n.getDescription){n.getDescription.apply(null,n.parameters.concat(m.params)).then(function(a){return c.get_string("backto","core_message",a)}).then(function(a){return j.renderPromise.then(function(){e[b][j.route].parameters.forEach(function(b){if("object"!==_typeof(b)||!b){return}b.find(g.ROUTES_BACK).attr("aria-label",a)})})}).catch(function(){})}}f[b].push(j);return j};return{add:function add(a,b,c,d,f){if(!e[a]){e[a]=[]}e[a][b]={parameters:c,onGo:d,getDescription:f}},go:i,back:function back(a){if(f[a].length){f[a].pop();var b=f[a].pop();if(b){i.apply(void 0,[a,b.route].concat(b.params));window.setTimeout(function(){b.focusElement.focus()},50)}}}}});
|
||||
function _typeof(a){"@babel/helpers - typeof";if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(a){return typeof a}}else{_typeof=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a}}return _typeof(a)}define ("core_message/message_drawer_router",["jquery","core/pubsub","core/str","core_message/message_drawer_events","core/aria"],function(a,b,c,d,e){var f={},g={},h={CAN_RECEIVE_FOCUS:"input:not([type=\"hidden\"]), a[href], button, textarea, select, [tabindex]",ROUTES_BACK:"[data-route-back]"},j=function(c,g){var j,k=[].slice.call(arguments).some(function(a){return"frompanel"==a}),l=[].slice.call(arguments,2),m=a.Deferred().resolve().promise();Object.keys(f[c]).forEach(function(a){var b=f[c][a],d=a===g;if(d){j=b}b.parameters.forEach(function(a){if("object"!==_typeof(a)||null===a){return}a.removeClass("previous");a.attr("data-from-panel",!1);if(d){if(k){a.attr("data-from-panel",!0)}a.removeClass("hidden");e.unhide(a.get())}else{if(!a.attr("data-in-panel")){a.addClass("hidden");e.hide(a.get())}else if("view-search"==g||"view-overview"==g){a.addClass("hidden");e.hide(a.get())}}})});if(j){if(j.onGo){m=j.onGo.apply(void 0,j.parameters.concat(l));for(var n=a(document.activeElement),o=!1,p=null,q=1,r;q<j.parameters.length;q++){r=j.parameters[q];if("object"!==_typeof(r)||null===r){continue}if(!p){p=r}if(r.has(n).length){o=!0;break}}if(!o){p.find(h.CAN_RECEIVE_FOCUS).filter(":visible").first().focus()}}}var s={route:g,params:l,renderPromise:m};b.publish(d.ROUTE_CHANGED,s);return s},k=function(b){var d=a(document.activeElement),e=j.apply(b,arguments),k=!1;if(!g[b]){g[b]=[]}g[b]=g[b].reduce(function(a,b){if(b.route===e.route){k=!0}if(!k){a.push(b)}return a},[]);var l=g[b].length,m=l?g[b][l-1]:null;if(m){for(var n=f[b][m.route],o=n.parameters,p=1;p<o.length;p++){if("object"!==_typeof(o[p])||null===o[p]){continue}o[p].addClass("previous")}m.focusElement=d;if(n.getDescription){n.getDescription.apply(null,n.parameters.concat(m.params)).then(function(a){return c.get_string("backto","core_message",a)}).then(function(a){return e.renderPromise.then(function(){f[b][e.route].parameters.forEach(function(b){if("object"!==_typeof(b)||!b){return}b.find(h.ROUTES_BACK).attr("aria-label",a)})})}).catch(function(){})}}g[b].push(e);return e};return{add:function add(a,b,c,d,e){if(!f[a]){f[a]=[]}f[a][b]={parameters:c,onGo:d,getDescription:e}},go:k,back:function back(a){if(g[a].length){g[a].pop();var b=g[a].pop();if(b){k.apply(void 0,[a,b.route].concat(b.params));window.setTimeout(function(){b.focusElement.focus()},50)}}}}});
|
||||
//# sourceMappingURL=message_drawer_router.min.js.map
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -29,13 +29,15 @@ define(
|
||||
'jquery',
|
||||
'core/pubsub',
|
||||
'core/str',
|
||||
'core_message/message_drawer_events'
|
||||
'core_message/message_drawer_events',
|
||||
'core/aria',
|
||||
],
|
||||
function(
|
||||
$,
|
||||
PubSub,
|
||||
Str,
|
||||
MessageDrawerEvents
|
||||
MessageDrawerEvents,
|
||||
Aria
|
||||
) {
|
||||
|
||||
/* @var {object} routes Message drawer route elements and callbacks. */
|
||||
@@ -112,15 +114,15 @@ function(
|
||||
element.attr('data-from-panel', true);
|
||||
}
|
||||
element.removeClass('hidden');
|
||||
element.attr('aria-hidden', false);
|
||||
Aria.unhide(element.get());
|
||||
} else {
|
||||
// For the message index page elements in the left panel should not be hidden.
|
||||
if (!element.attr('data-in-panel')) {
|
||||
element.addClass('hidden');
|
||||
element.attr('aria-hidden', true);
|
||||
Aria.hide(element.get());
|
||||
} else if (newRoute == 'view-search' || newRoute == 'view-overview') {
|
||||
element.addClass('hidden');
|
||||
element.attr('aria-hidden', true);
|
||||
Aria.hide(element.get());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -33,7 +33,8 @@ define(
|
||||
'core/str',
|
||||
'core/templates',
|
||||
'core/user_date',
|
||||
'core_message/message_drawer_view_conversation_constants'
|
||||
'core_message/message_drawer_view_conversation_constants',
|
||||
'core/aria',
|
||||
],
|
||||
function(
|
||||
$,
|
||||
@@ -41,7 +42,8 @@ function(
|
||||
Str,
|
||||
Templates,
|
||||
UserDate,
|
||||
Constants
|
||||
Constants,
|
||||
Aria
|
||||
) {
|
||||
var SELECTORS = Constants.SELECTORS;
|
||||
var TEMPLATES = Constants.TEMPLATES;
|
||||
@@ -510,8 +512,7 @@ function(
|
||||
var showConfirmDialogueContainer = function(root) {
|
||||
var container = getConfirmDialogueContainer(root);
|
||||
var siblings = container.siblings(':not(.hidden)');
|
||||
siblings.attr('aria-hidden', true);
|
||||
siblings.attr('tabindex', -1);
|
||||
Aria.hide(siblings.get());
|
||||
siblings.attr('data-confirm-dialogue-hidden', true);
|
||||
|
||||
container.removeClass('hidden');
|
||||
@@ -525,8 +526,7 @@ function(
|
||||
var hideConfirmDialogueContainer = function(root) {
|
||||
var container = getConfirmDialogueContainer(root);
|
||||
var siblings = container.siblings('[data-confirm-dialogue-hidden="true"]');
|
||||
siblings.removeAttr('aria-hidden');
|
||||
siblings.removeAttr('tabindex');
|
||||
Aria.unhide(siblings.get());
|
||||
siblings.removeAttr('data-confirm-dialogue-hidden');
|
||||
|
||||
container.addClass('hidden');
|
||||
@@ -669,26 +669,29 @@ function(
|
||||
var retry = element.find(SELECTORS.RETRY_SEND);
|
||||
|
||||
loading.addClass('hidden');
|
||||
loading.attr('aria-hidden', 'true');
|
||||
Aria.hide(loading.get());
|
||||
|
||||
time.addClass('hidden');
|
||||
time.attr('aria-hidden', 'true');
|
||||
Aria.hide(time.get());
|
||||
|
||||
retry.addClass('hidden');
|
||||
retry.attr('aria-hidden', 'true');
|
||||
Aria.hide(retry.get());
|
||||
|
||||
element.removeClass('border border-danger');
|
||||
|
||||
switch (after.sendState) {
|
||||
case 'pending':
|
||||
loading.removeClass('hidden');
|
||||
loading.attr('aria-hidden', 'false');
|
||||
Aria.unhide(loading.get());
|
||||
break;
|
||||
case 'error':
|
||||
retry.removeClass('hidden');
|
||||
retry.attr('aria-hidden', 'false');
|
||||
Aria.unhide(retry.get());
|
||||
element.addClass('border border-danger');
|
||||
break;
|
||||
case 'sent':
|
||||
time.removeClass('hidden');
|
||||
time.attr('aria-hidden', 'false');
|
||||
Aria.unhide(time.get());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -703,11 +706,11 @@ function(
|
||||
|
||||
if (after.errorMessage) {
|
||||
messageContainer.removeClass('hidden');
|
||||
messageContainer.attr('aria-hidden', 'false');
|
||||
Aria.unhide(messageContainer.get());
|
||||
message.text(after.errorMessage);
|
||||
} else {
|
||||
messageContainer.addClass('hidden');
|
||||
messageContainer.attr('aria-hidden', 'true');
|
||||
Aria.unhide(messageContainer.get());
|
||||
message.text('');
|
||||
}
|
||||
}
|
||||
@@ -1003,11 +1006,11 @@ function(
|
||||
|
||||
if (show) {
|
||||
container.removeClass('hidden');
|
||||
container.attr('aria-hidden', false);
|
||||
Aria.unhide(container.get());
|
||||
container.find(SELECTORS.EMOJI_PICKER_SEARCH_INPUT).focus();
|
||||
} else {
|
||||
container.addClass('hidden');
|
||||
container.attr('aria-hidden', true);
|
||||
Aria.hide(container.get());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1024,10 +1027,10 @@ function(
|
||||
|
||||
if (show) {
|
||||
container.removeClass('hidden');
|
||||
container.attr('aria-hidden', false);
|
||||
Aria.unhide(container.get());
|
||||
} else {
|
||||
container.addClass('hidden');
|
||||
container.attr('aria-hidden', true);
|
||||
Aria.hide(container.get());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -1,2 +1,2 @@
|
||||
define ("theme_boost/drawer",["jquery","core/custom_interaction_events","core/log","core/pubsub"],function(a,b,c,d){var f={TOGGLE_REGION:"[data-region=\"drawer-toggle\"]",TOGGLE_ACTION:"[data-action=\"toggle-drawer\"]",TOGGLE_TARGET:"aria-controls",TOGGLE_SIDE:"left",BODY:"body",SECTION:".list-group-item[href*=\"#section-\"]",DRAWER:"#nav-drawer"},g=768>a(document).width(),h=function(){if(!a(f.TOGGLE_REGION).length){c.debug("Page is missing a drawer region")}if(!a(f.TOGGLE_ACTION).length){c.debug("Page is missing a drawer toggle link")}a(f.TOGGLE_REGION).each(function(b,c){var d=a(c).find(f.TOGGLE_ACTION),e=d.attr("aria-controls"),h=a(document.getElementById(e)),i="false"==d.attr("aria-expanded"),j=d.attr("data-side"),k=a(f.BODY),l=d.attr("data-preference");if(g){M.util.set_user_preference(l,"false")}h.on("mousewheel DOMMouseScroll",this.preventPageScroll);if(!i){k.addClass("drawer-open-"+j);d.attr("aria-expanded","true")}else{d.attr("aria-expanded","false")}}.bind(this));this.registerEventListeners();if(g){this.closeAll()}};h.prototype.closeAll=function(){a(f.TOGGLE_REGION).each(function(b,c){var d=a(c).find(f.TOGGLE_ACTION),e=d.attr("data-side"),h=a(f.BODY),i=d.attr("aria-controls"),j=a(document.getElementById(i)),k=d.attr("data-preference");d.attr("aria-expanded","false");h.removeClass("drawer-open-"+e);j.attr("aria-hidden","true");j.addClass("closed");if(!g){M.util.set_user_preference(k,"false")}})};h.prototype.toggleDrawer=function(b){var c=a(b.target).closest("[data-action=toggle-drawer]"),e=c.attr("aria-controls"),h=a(document.getElementById(e)),i=a(f.BODY),j=c.attr("data-side"),k=c.attr("data-preference");if(g){M.util.set_user_preference(k,"false")}i.addClass("drawer-ease");var l="true"==c.attr("aria-expanded");if(!l){c.attr("aria-expanded","true");h.attr("aria-hidden","false");h.focus();i.addClass("drawer-open-"+j);h.removeClass("closed");if(!g){M.util.set_user_preference(k,"true")}}else{i.removeClass("drawer-open-"+j);c.attr("aria-expanded","false");h.addClass("closed").delay(500).queue(function(){a(this).attr("aria-hidden","true").dequeue()});if(!g){M.util.set_user_preference(k,"false")}}d.publish("nav-drawer-toggle-start",l)};h.prototype.preventPageScroll=function(b){var c=b.wheelDelta||b.originalEvent&&b.originalEvent.wheelDelta||-b.originalEvent.detail,d=0<=this.scrollTop+a(this).outerHeight()-this.scrollHeight,e=0>=this.scrollTop;if(0>c&&d||0<c&&e){b.preventDefault()}};h.prototype.registerEventListeners=function(){a(f.TOGGLE_ACTION).each(function(c,d){b.define(a(d),[b.events.activate]);a(d).on(b.events.activate,function(a,b){this.toggleDrawer(b.originalEvent);b.originalEvent.preventDefault()}.bind(this))}.bind(this));a(f.SECTION).click(function(){if(g){this.closeAll()}}.bind(this));a(f.DRAWER).on("webkitTransitionEnd msTransitionEnd transitionend",function(b){var c=a(b.target).closest(f.DRAWER),e="false"==c.attr("aria-hidden");d.publish("nav-drawer-toggle-end",e)})};return{init:function init(){return new h}}});
|
||||
define ("theme_boost/drawer",["jquery","core/custom_interaction_events","core/log","core/pubsub","core/aria"],function(a,b,c,d,e){var f={TOGGLE_REGION:"[data-region=\"drawer-toggle\"]",TOGGLE_ACTION:"[data-action=\"toggle-drawer\"]",TOGGLE_TARGET:"aria-controls",TOGGLE_SIDE:"left",BODY:"body",SECTION:".list-group-item[href*=\"#section-\"]",DRAWER:"#nav-drawer"},g=768>a(document).width(),h=function(){if(!a(f.TOGGLE_REGION).length){c.debug("Page is missing a drawer region")}if(!a(f.TOGGLE_ACTION).length){c.debug("Page is missing a drawer toggle link")}a(f.TOGGLE_REGION).each(function(b,c){var d=a(c).find(f.TOGGLE_ACTION),e=d.attr("aria-controls"),h=a(document.getElementById(e)),i="false"==d.attr("aria-expanded"),j=d.attr("data-side"),k=a(f.BODY),l=d.attr("data-preference");if(g){M.util.set_user_preference(l,"false")}h.on("mousewheel DOMMouseScroll",this.preventPageScroll);if(!i){k.addClass("drawer-open-"+j);d.attr("aria-expanded","true")}else{d.attr("aria-expanded","false")}}.bind(this));this.registerEventListeners();if(g){this.closeAll()}};h.prototype.closeAll=function(){a(f.TOGGLE_REGION).each(function(b,c){var d=a(c).find(f.TOGGLE_ACTION),h=d.attr("data-side"),i=a(f.BODY),j=d.attr("aria-controls"),k=a(document.getElementById(j)),l=d.attr("data-preference");d.attr("aria-expanded","false");i.removeClass("drawer-open-"+h);e.hide(k.get());k.addClass("closed");if(!g){M.util.set_user_preference(l,"false")}})};h.prototype.toggleDrawer=function(b){var c=a(b.target).closest("[data-action=toggle-drawer]"),h=c.attr("aria-controls"),i=a(document.getElementById(h)),j=a(f.BODY),k=c.attr("data-side"),l=c.attr("data-preference");if(g){M.util.set_user_preference(l,"false")}j.addClass("drawer-ease");var m="true"==c.attr("aria-expanded");if(!m){c.attr("aria-expanded","true");e.unhide(i.get());i.focus();j.addClass("drawer-open-"+k);i.removeClass("closed");if(!g){M.util.set_user_preference(l,"true")}}else{j.removeClass("drawer-open-"+k);c.attr("aria-expanded","false");i.addClass("closed").delay(500).queue(function(){e.hide(this);a(this).dequeue()});if(!g){M.util.set_user_preference(l,"false")}}d.publish("nav-drawer-toggle-start",m)};h.prototype.preventPageScroll=function(b){var c=b.wheelDelta||b.originalEvent&&b.originalEvent.wheelDelta||-b.originalEvent.detail,d=0<=this.scrollTop+a(this).outerHeight()-this.scrollHeight,e=0>=this.scrollTop;if(0>c&&d||0<c&&e){b.preventDefault()}};h.prototype.registerEventListeners=function(){a(f.TOGGLE_ACTION).each(function(c,d){b.define(a(d),[b.events.activate]);a(d).on(b.events.activate,function(a,b){this.toggleDrawer(b.originalEvent);b.originalEvent.preventDefault()}.bind(this))}.bind(this));a(f.SECTION).click(function(){if(g){this.closeAll()}}.bind(this));a(f.DRAWER).on("webkitTransitionEnd msTransitionEnd transitionend",function(b){var c=a(b.target).closest(f.DRAWER),e=!!c.attr("aria-hidden");d.publish("nav-drawer-toggle-end",e)})};return{init:function init(){return new h}}});
|
||||
//# sourceMappingURL=drawer.min.js.map
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -20,8 +20,8 @@
|
||||
* @copyright 2016 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['jquery', 'core/custom_interaction_events', 'core/log', 'core/pubsub'],
|
||||
function($, CustomEvents, Log, PubSub) {
|
||||
define(['jquery', 'core/custom_interaction_events', 'core/log', 'core/pubsub', 'core/aria'],
|
||||
function($, CustomEvents, Log, PubSub, Aria) {
|
||||
|
||||
var SELECTORS = {
|
||||
TOGGLE_REGION: '[data-region="drawer-toggle"]',
|
||||
@@ -87,7 +87,7 @@ define(['jquery', 'core/custom_interaction_events', 'core/log', 'core/pubsub'],
|
||||
|
||||
trigger.attr('aria-expanded', 'false');
|
||||
body.removeClass('drawer-open-' + side);
|
||||
drawer.attr('aria-hidden', 'true');
|
||||
Aria.hide(drawer.get());
|
||||
drawer.addClass('closed');
|
||||
if (!small) {
|
||||
M.util.set_user_preference(preference, 'false');
|
||||
@@ -117,7 +117,7 @@ define(['jquery', 'core/custom_interaction_events', 'core/log', 'core/pubsub'],
|
||||
if (!open) {
|
||||
// Open.
|
||||
trigger.attr('aria-expanded', 'true');
|
||||
drawer.attr('aria-hidden', 'false');
|
||||
Aria.unhide(drawer.get());
|
||||
drawer.focus();
|
||||
body.addClass('drawer-open-' + side);
|
||||
drawer.removeClass('closed');
|
||||
@@ -129,7 +129,8 @@ define(['jquery', 'core/custom_interaction_events', 'core/log', 'core/pubsub'],
|
||||
body.removeClass('drawer-open-' + side);
|
||||
trigger.attr('aria-expanded', 'false');
|
||||
drawer.addClass('closed').delay(500).queue(function() {
|
||||
$(this).attr('aria-hidden', 'true').dequeue();
|
||||
Aria.hide(this);
|
||||
$(this).dequeue();
|
||||
});
|
||||
if (!small) {
|
||||
M.util.set_user_preference(preference, 'false');
|
||||
@@ -183,7 +184,8 @@ define(['jquery', 'core/custom_interaction_events', 'core/log', 'core/pubsub'],
|
||||
// to either an open or closed state.
|
||||
$(SELECTORS.DRAWER).on('webkitTransitionEnd msTransitionEnd transitionend', function(e) {
|
||||
var drawer = $(e.target).closest(SELECTORS.DRAWER);
|
||||
var open = drawer.attr('aria-hidden') == 'false';
|
||||
// Note: aria-hidden is either present, or absent. It should not be set to false.
|
||||
var open = !!drawer.attr('aria-hidden');
|
||||
PubSub.publish('nav-drawer-toggle-end', open);
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user