mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
N°3523 Add accessibility to silo selection and user menu toggler
This commit is contained in:
5
node_modules/.package-lock.json
generated
vendored
5
node_modules/.package-lock.json
generated
vendored
@@ -76,6 +76,11 @@
|
||||
"node": ">=0.10.x"
|
||||
}
|
||||
},
|
||||
"node_modules/selectize-plugin-a11y": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/selectize-plugin-a11y/-/selectize-plugin-a11y-1.1.0.tgz",
|
||||
"integrity": "sha512-fgY8fzE5Jx6DaoMg1c6otibyftkBw5y64YL778pyq7rS92h10QCPmgMaRtsHdXBFwPt6qO8qqQ1Pj1JJ0GDPrA=="
|
||||
},
|
||||
"node_modules/tippy.js": {
|
||||
"version": "6.2.5",
|
||||
"license": "MIT",
|
||||
|
||||
248
node_modules/selectize-plugin-a11y/.eslintrc
generated
vendored
Normal file
248
node_modules/selectize-plugin-a11y/.eslintrc
generated
vendored
Normal file
@@ -0,0 +1,248 @@
|
||||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"node": true,
|
||||
"es6": false,
|
||||
"jquery": true
|
||||
},
|
||||
"globals": {
|
||||
"yTos": true,
|
||||
"$Y": true,
|
||||
"define": true,
|
||||
"require": true,
|
||||
"tc_vars": true,
|
||||
"$M": true,
|
||||
"attachmentLabels": true
|
||||
},
|
||||
"rules": {
|
||||
"no-alert": "off",
|
||||
"no-array-constructor": "off",
|
||||
"no-caller": "off",
|
||||
"no-case-declarations": "warn",
|
||||
"no-catch-shadow": "off",
|
||||
"no-class-assign": "error",
|
||||
"no-confusing-arrow": "off",
|
||||
"no-console": "off",
|
||||
"no-const-assign": "error",
|
||||
"no-constant-condition": "warn",
|
||||
"no-continue": "off",
|
||||
"no-control-regex": "error",
|
||||
"no-debugger": "warn",
|
||||
"no-delete-var": "error",
|
||||
"no-div-regex": "off",
|
||||
"no-dupe-class-members": "error",
|
||||
"no-dupe-keys": "error",
|
||||
"no-dupe-args": "error",
|
||||
"no-duplicate-case": "error",
|
||||
"no-duplicate-imports": "off",
|
||||
"no-else-return": "off",
|
||||
"no-empty-character-class": "error",
|
||||
"no-empty-function": "off",
|
||||
"no-empty-pattern": "error",
|
||||
"no-eq-null": "off",
|
||||
"no-eval": "off",
|
||||
"no-ex-assign": "error",
|
||||
"no-extend-native": "off",
|
||||
"no-extra-bind": "off",
|
||||
"no-extra-boolean-cast": "error",
|
||||
"no-extra-label": "off",
|
||||
"no-extra-parens": "off",
|
||||
"no-extra-semi": "error",
|
||||
"no-fallthrough": "error",
|
||||
"no-floating-decimal": "off",
|
||||
"no-func-assign": "error",
|
||||
"no-implicit-coercion": "off",
|
||||
"no-implicit-globals": "off",
|
||||
"no-implied-eval": "off",
|
||||
"no-inline-comments": "off",
|
||||
"no-inner-declarations": "error",
|
||||
"no-invalid-regexp": "error",
|
||||
"no-irregular-whitespace": "error",
|
||||
"no-iterator": "off",
|
||||
"no-label-var": "off",
|
||||
"no-labels": "off",
|
||||
"no-lone-blocks": "off",
|
||||
"no-lonely-if": "off",
|
||||
"no-loop-func": "off",
|
||||
"no-mixed-requires": "off",
|
||||
"no-mixed-spaces-and-tabs": "error",
|
||||
"no-multi-spaces": "off",
|
||||
"no-multiple-empty-lines": [
|
||||
"warn",
|
||||
{
|
||||
"max": 1
|
||||
}
|
||||
],
|
||||
"no-native-reassign": "off",
|
||||
"no-negated-condition": "off",
|
||||
"no-negated-in-lhs": "error",
|
||||
"no-nested-ternary": "off",
|
||||
"no-new-func": "off",
|
||||
"no-new-object": "off",
|
||||
"no-new-require": "off",
|
||||
"no-new-symbol": "error",
|
||||
"no-new-wrappers": "off",
|
||||
"no-obj-calls": "error",
|
||||
"no-octal": "error",
|
||||
"no-octal-escape": "off",
|
||||
"no-param-reassign": "off",
|
||||
"no-path-concat": "off",
|
||||
"no-plusplus": "off",
|
||||
"no-process-env": "off",
|
||||
"no-process-exit": "off",
|
||||
"no-proto": "off",
|
||||
"no-redeclare": "error",
|
||||
"no-regex-spaces": "warn",
|
||||
"no-restricted-globals": "off",
|
||||
"no-restricted-imports": "off",
|
||||
"no-restricted-modules": "off",
|
||||
"no-restricted-syntax": "off",
|
||||
"no-return-assign": "off",
|
||||
"no-script-url": "off",
|
||||
"no-self-assign": "error",
|
||||
"no-self-compare": "off",
|
||||
"no-sequences": "off",
|
||||
"no-shadow": "off",
|
||||
"no-shadow-restricted-names": "off",
|
||||
"no-whitespace-before-property": "off",
|
||||
"no-spaced-func": "warn",
|
||||
"no-sparse-arrays": "error",
|
||||
"no-sync": "off",
|
||||
"no-ternary": "off",
|
||||
"no-trailing-spaces": "off",
|
||||
"no-this-before-super": "error",
|
||||
"no-throw-literal": "off",
|
||||
"no-undef": "error",
|
||||
"no-undef-init": "off",
|
||||
"no-undefined": "off",
|
||||
"no-unexpected-multiline": "error",
|
||||
"no-underscore-dangle": "off",
|
||||
"no-unmodified-loop-condition": "off",
|
||||
"no-unneeded-ternary": "off",
|
||||
"no-unreachable": "error",
|
||||
"no-unused-expressions": "off",
|
||||
"no-unused-labels": "error",
|
||||
"no-unused-vars": [
|
||||
"warn",
|
||||
{
|
||||
"vars": "local",
|
||||
"args": "none"
|
||||
}
|
||||
],
|
||||
"no-useless-call": "off",
|
||||
"no-useless-concat": "off",
|
||||
"no-useless-constructor": "off",
|
||||
"no-void": "off",
|
||||
"no-var": "off",
|
||||
"no-warning-comments": "off",
|
||||
"no-with": "off",
|
||||
"no-magic-numbers": "off",
|
||||
"array-bracket-spacing": "off",
|
||||
"array-callback-return": "off",
|
||||
"arrow-body-style": "off",
|
||||
"arrow-parens": "off",
|
||||
"arrow-spacing": "off",
|
||||
"accessor-pairs": "off",
|
||||
"block-scoped-var": "off",
|
||||
"block-spacing": "warn",
|
||||
"brace-style": "off",
|
||||
"callback-return": "off",
|
||||
"camelcase": "off",
|
||||
"comma-dangle": "error",
|
||||
"comma-spacing": "warn",
|
||||
"comma-style": "off",
|
||||
"complexity": [
|
||||
"off",
|
||||
11
|
||||
],
|
||||
"computed-property-spacing": "off",
|
||||
"consistent-return": "off",
|
||||
"consistent-this": "off",
|
||||
"constructor-super": "error",
|
||||
"default-case": "off",
|
||||
"dot-location": "off",
|
||||
"dot-notation": "off",
|
||||
"eol-last": "off",
|
||||
"func-names": "off",
|
||||
"func-style": "off",
|
||||
"generator-star-spacing": "off",
|
||||
"global-require": "off",
|
||||
"handle-callback-err": "off",
|
||||
"id-length": "off",
|
||||
"indent": ["error", 2],
|
||||
"init-declarations": "off",
|
||||
"jsx-quotes": "off",
|
||||
"key-spacing": "warn",
|
||||
"keyword-spacing": "off",
|
||||
"lines-around-comment": "off",
|
||||
"max-depth": "off",
|
||||
"max-len": "off",
|
||||
"max-nested-callbacks": "off",
|
||||
"max-params": "off",
|
||||
"max-statements": "off",
|
||||
"new-parens": "off",
|
||||
"newline-after-var": "off",
|
||||
"newline-before-return": "off",
|
||||
"newline-per-chained-call": "off",
|
||||
"object-curly-spacing": [
|
||||
"off",
|
||||
"never"
|
||||
],
|
||||
"object-shorthand": "off",
|
||||
"one-var": [
|
||||
"warn",
|
||||
"never"
|
||||
],
|
||||
"one-var-declaration-per-line": "off",
|
||||
"operator-assignment": "off",
|
||||
"operator-linebreak": "off",
|
||||
"padded-blocks": "off",
|
||||
"prefer-arrow-callback": "off",
|
||||
"prefer-const": "off",
|
||||
"prefer-reflect": "off",
|
||||
"prefer-rest-params": "off",
|
||||
"prefer-spread": "off",
|
||||
"prefer-template": "off",
|
||||
"quote-props": "off",
|
||||
"quotes": "off",
|
||||
"radix": "off",
|
||||
"id-match": "off",
|
||||
"id-blacklist": "off",
|
||||
"require-jsdoc": "off",
|
||||
"require-yield": "off",
|
||||
"semi": "warn",
|
||||
"semi-spacing": "warn",
|
||||
"sort-vars": "off",
|
||||
"sort-imports": "off",
|
||||
"space-before-blocks": "warn",
|
||||
"space-before-function-paren": "warn",
|
||||
"space-in-parens": "warn",
|
||||
"space-infix-ops": "off",
|
||||
"space-unary-ops": "off",
|
||||
"spaced-comment": "off",
|
||||
"strict": "off",
|
||||
"template-curly-spacing": "off",
|
||||
"use-isnan": "error",
|
||||
"valid-jsdoc": "off",
|
||||
"valid-typeof": "error",
|
||||
"vars-on-top": "off",
|
||||
"wrap-regex": "off",
|
||||
"yield-star-spacing": "off",
|
||||
"yoda": "off",
|
||||
"no-bitwise": 2,
|
||||
"curly": 0,
|
||||
"eqeqeq": 0,
|
||||
"guard-for-in": 2,
|
||||
"no-cond-assign": [
|
||||
2,
|
||||
"except-parens"
|
||||
],
|
||||
"wrap-iife": 0,
|
||||
"linebreak-style": 0,
|
||||
"no-use-before-define": 0,
|
||||
"no-multi-str": 2,
|
||||
"new-cap": 0,
|
||||
"no-empty": 2,
|
||||
"no-new": 2
|
||||
}
|
||||
}
|
||||
7
node_modules/selectize-plugin-a11y/LICENSE
generated
vendored
Normal file
7
node_modules/selectize-plugin-a11y/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
Copyright 2018-present Salmen Bejaoui
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
24
node_modules/selectize-plugin-a11y/README.md
generated
vendored
Normal file
24
node_modules/selectize-plugin-a11y/README.md
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
# selectize-plugin-a11y.js
|
||||
Selectize-plugin-a11y is a plugin to make Selectize.js accessible as a Combobox.
|
||||
|
||||
## Selectize-plugin-a11y – Usage
|
||||
|
||||
```html
|
||||
<script type="text/javascript" src="selectize.js"></script>
|
||||
<script type="text/javascript" src="selectize-plugin-a11y.js"></script>
|
||||
<script>
|
||||
$(function() {
|
||||
$('select').selectize({
|
||||
plugins: ['selectize-plugin-a11y'],
|
||||
render: {
|
||||
option: function($item, escape) {
|
||||
// Every option must have a unique id
|
||||
return `<div class="option" role="option" id="${$item.text.replace(' ', '')}">${$item.text}</div>`
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
```
|
||||
|
||||
## Pull requests are always welcome
|
||||
Any pull request to improve the plugin will be appreciated 😉
|
||||
38
node_modules/selectize-plugin-a11y/examples/api.html
generated
vendored
Normal file
38
node_modules/selectize-plugin-a11y/examples/api.html
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Accessibile Selectize</title>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.4/css/selectize.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1>Selectize-plugin-a11y.js</h1>
|
||||
<p>Make Selectize.js accessibile</p>
|
||||
|
||||
<select name="" id="">
|
||||
<option value="">Choose your country</option>
|
||||
<option value="it">Italy</option>
|
||||
<option value="fr">France</option>
|
||||
<option value="gb">United Kingdom</option>
|
||||
<option value="script"><script>alert('hi')</script></option>
|
||||
</select>
|
||||
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.4/js/standalone/selectize.min.js"></script>
|
||||
<script src="../selectize-plugin-a11y.js"></script>
|
||||
<script>
|
||||
$('select').selectize({
|
||||
plugins: ['selectize-plugin-a11y'],
|
||||
render: {
|
||||
option: function($item, escape) {
|
||||
// Every option must have a unique id
|
||||
return `<div class="option" role="option" id="${escape($item.text).replace(' ', '')}">${escape($item.text)}</div>`
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
27
node_modules/selectize-plugin-a11y/package.json
generated
vendored
Normal file
27
node_modules/selectize-plugin-a11y/package.json
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "selectize-plugin-a11y",
|
||||
"version": "1.1.0",
|
||||
"description": "Make Selectize.js accessibile",
|
||||
"main": "selectize-plugin-a11y.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/SLMNBJ/selectize-plugin-a11y.git"
|
||||
},
|
||||
"keywords": [
|
||||
"selectize",
|
||||
"selectize.js",
|
||||
"a11y",
|
||||
"accessibility",
|
||||
"selectize",
|
||||
"voiceover"
|
||||
],
|
||||
"author": "Salmen Bejaoui",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/SLMNBJ/selectize-plugin-a11y/issues"
|
||||
},
|
||||
"homepage": "https://github.com/SLMNBJ/selectize-plugin-a11y#readme"
|
||||
}
|
||||
141
node_modules/selectize-plugin-a11y/selectize-plugin-a11y.js
generated
vendored
Normal file
141
node_modules/selectize-plugin-a11y/selectize-plugin-a11y.js
generated
vendored
Normal file
@@ -0,0 +1,141 @@
|
||||
/* global Selectize */
|
||||
Selectize.define("selectize-plugin-a11y", function (options) {
|
||||
var self = this;
|
||||
var KEY_RETURN = 13;
|
||||
|
||||
if (typeof self.accessibility === "undefined") {
|
||||
self.accessibility = {};
|
||||
}
|
||||
|
||||
self.accessibility.helpers = {
|
||||
randomId: function (len) {
|
||||
var str = "",
|
||||
strLength = len || 10,
|
||||
base = "abcdefghijklmnopqrstuvwxyz0123456789",
|
||||
baseLength = base.length;
|
||||
|
||||
for (var i = 0; i < strLength; i++) {
|
||||
str += base[Math.floor(baseLength * Math.random())];
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
};
|
||||
|
||||
self.accessibility.liveRegion = {
|
||||
$region: "",
|
||||
speak: function (msg) {
|
||||
var $container = $("<div></div>");
|
||||
$container.text(msg);
|
||||
this.$region.html($container);
|
||||
},
|
||||
domListener: function () {
|
||||
var observer = new MutationObserver(function (mutations) {
|
||||
mutations.forEach(function (mutation) {
|
||||
var $target = $(mutation.target);
|
||||
if ($target.hasClass("items")) {
|
||||
if ($target.hasClass("dropdown-active")) {
|
||||
// open
|
||||
self.$control_input.attr("aria-expanded", "true");
|
||||
} else {
|
||||
// close
|
||||
self.$control_input.attr("aria-expanded", "false");
|
||||
self.$control_input.removeAttr("aria-activedescendant");
|
||||
}
|
||||
} else {
|
||||
// option change
|
||||
if ($target.hasClass("active")) {
|
||||
if (!!$target.attr("data-value")) { // eslint-disable-line no-extra-boolean-cast
|
||||
self.$control_input.attr(
|
||||
"aria-activedescendant",
|
||||
$target.attr("id")
|
||||
);
|
||||
self.accessibility.liveRegion.speak($target.text(), 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
observer.observe(self.$dropdown[0], {
|
||||
attributes: true,
|
||||
attributeFilter: ["class"],
|
||||
subtree: true,
|
||||
attributeOldValue: true
|
||||
});
|
||||
|
||||
observer.observe(self.$control[0], {
|
||||
attributes: true,
|
||||
attributeFilter: ["class"]
|
||||
});
|
||||
|
||||
observer.observe(self.$control_input[0], {
|
||||
attributes: true,
|
||||
attributeFilter: ["value"]
|
||||
});
|
||||
},
|
||||
setAttributes: function () {
|
||||
this.$region.attr({
|
||||
"aria-live": "assertive",
|
||||
role: "log",
|
||||
"aria-relevant": "additions",
|
||||
"aria-atomic": "true"
|
||||
});
|
||||
},
|
||||
setStyles: function () {
|
||||
this.$region.css({
|
||||
position: "absolute",
|
||||
width: "1px",
|
||||
height: "1px",
|
||||
"margin-top": "-1px",
|
||||
clip: "rect(1px, 1px, 1px, 1px)",
|
||||
overflow: "hidden"
|
||||
});
|
||||
},
|
||||
init: function () {
|
||||
this.$region = $("<div>");
|
||||
this.setAttributes();
|
||||
this.setStyles();
|
||||
$("body").append(this.$region);
|
||||
this.domListener();
|
||||
}
|
||||
};
|
||||
|
||||
this.setup = (function () {
|
||||
var original = self.setup;
|
||||
return function () {
|
||||
original.apply(this, arguments);
|
||||
var inputId = self.accessibility.helpers.randomId(),
|
||||
listboxId = self.accessibility.helpers.randomId();
|
||||
|
||||
self.$control.on("keydown", function (e) {
|
||||
if (e.keyCode === KEY_RETURN) {
|
||||
$(this).click();
|
||||
}
|
||||
});
|
||||
|
||||
self.$control_input.attr({
|
||||
role: "combobox",
|
||||
"aria-expanded": "false",
|
||||
haspopup: "listbox",
|
||||
"aria-owns": listboxId,
|
||||
"aria-label": self.$wrapper
|
||||
.closest("[data-accessibility-selectize-label]")
|
||||
.attr("data-accessibility-selectize-label")
|
||||
});
|
||||
console.log( self.$wrapper);
|
||||
self.$dropdown_content.attr({
|
||||
role: "listbox",
|
||||
id: listboxId
|
||||
});
|
||||
self.accessibility.liveRegion.init();
|
||||
};
|
||||
})();
|
||||
|
||||
this.destroy = (function () {
|
||||
var original = self.destroy;
|
||||
return function () {
|
||||
self.accessibility.liveRegion.$region.remove();
|
||||
return original.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
});
|
||||
Reference in New Issue
Block a user