wp/wp-includes/js/dist/a11y.js
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
    80 /******/ 	// __webpack_public_path__
    80 /******/ 	// __webpack_public_path__
    81 /******/ 	__webpack_require__.p = "";
    81 /******/ 	__webpack_require__.p = "";
    82 /******/
    82 /******/
    83 /******/
    83 /******/
    84 /******/ 	// Load entry module and return exports
    84 /******/ 	// Load entry module and return exports
    85 /******/ 	return __webpack_require__(__webpack_require__.s = 459);
    85 /******/ 	return __webpack_require__(__webpack_require__.s = "jncB");
    86 /******/ })
    86 /******/ })
    87 /************************************************************************/
    87 /************************************************************************/
    88 /******/ ({
    88 /******/ ({
    89 
    89 
    90 /***/ 1:
    90 /***/ "Y8OO":
    91 /***/ (function(module, exports) {
    91 /***/ (function(module, exports) {
    92 
    92 
    93 (function() { module.exports = this["wp"]["i18n"]; }());
    93 (function() { module.exports = window["wp"]["domReady"]; }());
    94 
    94 
    95 /***/ }),
    95 /***/ }),
    96 
    96 
    97 /***/ 261:
    97 /***/ "jncB":
    98 /***/ (function(module, exports) {
       
    99 
       
   100 (function() { module.exports = this["wp"]["domReady"]; }());
       
   101 
       
   102 /***/ }),
       
   103 
       
   104 /***/ 459:
       
   105 /***/ (function(module, __webpack_exports__, __webpack_require__) {
    98 /***/ (function(module, __webpack_exports__, __webpack_require__) {
   106 
    99 
   107 "use strict";
   100 "use strict";
   108 // ESM COMPAT FLAG
   101 // ESM COMPAT FLAG
   109 __webpack_require__.r(__webpack_exports__);
   102 __webpack_require__.r(__webpack_exports__);
   110 
   103 
   111 // EXPORTS
   104 // EXPORTS
   112 __webpack_require__.d(__webpack_exports__, "setup", function() { return /* binding */ setup; });
   105 __webpack_require__.d(__webpack_exports__, "setup", function() { return /* binding */ setup; });
   113 __webpack_require__.d(__webpack_exports__, "speak", function() { return /* binding */ speak; });
   106 __webpack_require__.d(__webpack_exports__, "speak", function() { return /* binding */ speak; });
   114 
   107 
   115 // EXTERNAL MODULE: external {"this":["wp","domReady"]}
   108 // EXTERNAL MODULE: external ["wp","domReady"]
   116 var external_this_wp_domReady_ = __webpack_require__(261);
   109 var external_wp_domReady_ = __webpack_require__("Y8OO");
   117 var external_this_wp_domReady_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_domReady_);
   110 var external_wp_domReady_default = /*#__PURE__*/__webpack_require__.n(external_wp_domReady_);
   118 
   111 
   119 // EXTERNAL MODULE: external {"this":["wp","i18n"]}
   112 // EXTERNAL MODULE: external ["wp","i18n"]
   120 var external_this_wp_i18n_ = __webpack_require__(1);
   113 var external_wp_i18n_ = __webpack_require__("l3Sj");
   121 
   114 
   122 // CONCATENATED MODULE: ./node_modules/@wordpress/a11y/build-module/add-intro-text.js
   115 // CONCATENATED MODULE: ./node_modules/@wordpress/a11y/build-module/add-intro-text.js
   123 /**
   116 /**
   124  * WordPress dependencies
   117  * WordPress dependencies
   125  */
   118  */
   132  *
   125  *
   133  * @return {HTMLParagraphElement} The explanatory text HTML element.
   126  * @return {HTMLParagraphElement} The explanatory text HTML element.
   134  */
   127  */
   135 
   128 
   136 function addIntroText() {
   129 function addIntroText() {
   137   var introText = document.createElement('p');
   130   const introText = document.createElement('p');
   138   introText.id = 'a11y-speak-intro-text';
   131   introText.id = 'a11y-speak-intro-text';
   139   introText.className = 'a11y-speak-intro-text';
   132   introText.className = 'a11y-speak-intro-text';
   140   introText.textContent = Object(external_this_wp_i18n_["__"])('Notifications');
   133   introText.textContent = Object(external_wp_i18n_["__"])('Notifications');
   141   introText.setAttribute('style', 'position: absolute;' + 'margin: -1px;' + 'padding: 0;' + 'height: 1px;' + 'width: 1px;' + 'overflow: hidden;' + 'clip: rect(1px, 1px, 1px, 1px);' + '-webkit-clip-path: inset(50%);' + 'clip-path: inset(50%);' + 'border: 0;' + 'word-wrap: normal !important;');
   134   introText.setAttribute('style', 'position: absolute;' + 'margin: -1px;' + 'padding: 0;' + 'height: 1px;' + 'width: 1px;' + 'overflow: hidden;' + 'clip: rect(1px, 1px, 1px, 1px);' + '-webkit-clip-path: inset(50%);' + 'clip-path: inset(50%);' + 'border: 0;' + 'word-wrap: normal !important;');
   142   introText.setAttribute('hidden', 'hidden');
   135   introText.setAttribute('hidden', 'hidden');
   143   var _document = document,
   136   const {
   144       body = _document.body;
   137     body
       
   138   } = document;
   145 
   139 
   146   if (body) {
   140   if (body) {
   147     body.appendChild(introText);
   141     body.appendChild(introText);
   148   }
   142   }
   149 
   143 
   156  *
   150  *
   157  * @param {string} [ariaLive] Value for the 'aria-live' attribute; default: 'polite'.
   151  * @param {string} [ariaLive] Value for the 'aria-live' attribute; default: 'polite'.
   158  *
   152  *
   159  * @return {HTMLDivElement} The ARIA live region HTML element.
   153  * @return {HTMLDivElement} The ARIA live region HTML element.
   160  */
   154  */
   161 function addContainer() {
   155 function addContainer(ariaLive = 'polite') {
   162   var ariaLive = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'polite';
   156   const container = document.createElement('div');
   163   var container = document.createElement('div');
   157   container.id = `a11y-speak-${ariaLive}`;
   164   container.id = "a11y-speak-".concat(ariaLive);
       
   165   container.className = 'a11y-speak-region';
   158   container.className = 'a11y-speak-region';
   166   container.setAttribute('style', 'position: absolute;' + 'margin: -1px;' + 'padding: 0;' + 'height: 1px;' + 'width: 1px;' + 'overflow: hidden;' + 'clip: rect(1px, 1px, 1px, 1px);' + '-webkit-clip-path: inset(50%);' + 'clip-path: inset(50%);' + 'border: 0;' + 'word-wrap: normal !important;');
   159   container.setAttribute('style', 'position: absolute;' + 'margin: -1px;' + 'padding: 0;' + 'height: 1px;' + 'width: 1px;' + 'overflow: hidden;' + 'clip: rect(1px, 1px, 1px, 1px);' + '-webkit-clip-path: inset(50%);' + 'clip-path: inset(50%);' + 'border: 0;' + 'word-wrap: normal !important;');
   167   container.setAttribute('aria-live', ariaLive);
   160   container.setAttribute('aria-live', ariaLive);
   168   container.setAttribute('aria-relevant', 'additions text');
   161   container.setAttribute('aria-relevant', 'additions text');
   169   container.setAttribute('aria-atomic', 'true');
   162   container.setAttribute('aria-atomic', 'true');
   170   var _document = document,
   163   const {
   171       body = _document.body;
   164     body
       
   165   } = document;
   172 
   166 
   173   if (body) {
   167   if (body) {
   174     body.appendChild(container);
   168     body.appendChild(container);
   175   }
   169   }
   176 
   170 
   180 // CONCATENATED MODULE: ./node_modules/@wordpress/a11y/build-module/clear.js
   174 // CONCATENATED MODULE: ./node_modules/@wordpress/a11y/build-module/clear.js
   181 /**
   175 /**
   182  * Clears the a11y-speak-region elements and hides the explanatory text.
   176  * Clears the a11y-speak-region elements and hides the explanatory text.
   183  */
   177  */
   184 function clear() {
   178 function clear() {
   185   var regions = document.getElementsByClassName('a11y-speak-region');
   179   const regions = document.getElementsByClassName('a11y-speak-region');
   186   var introText = document.getElementById('a11y-speak-intro-text');
   180   const introText = document.getElementById('a11y-speak-intro-text');
   187 
   181 
   188   for (var i = 0; i < regions.length; i++) {
   182   for (let i = 0; i < regions.length; i++) {
   189     regions[i].textContent = '';
   183     regions[i].textContent = '';
   190   } // Make sure the explanatory text is hidden from assistive technologies.
   184   } // Make sure the explanatory text is hidden from assistive technologies.
   191 
   185 
   192 
   186 
   193   if (introText) {
   187   if (introText) {
   194     introText.setAttribute('hidden', 'hidden');
   188     introText.setAttribute('hidden', 'hidden');
   195   }
   189   }
   196 }
   190 }
   197 
   191 
   198 // CONCATENATED MODULE: ./node_modules/@wordpress/a11y/build-module/filter-message.js
   192 // CONCATENATED MODULE: ./node_modules/@wordpress/a11y/build-module/filter-message.js
   199 var previousMessage = '';
   193 let previousMessage = '';
   200 /**
   194 /**
   201  * Filter the message to be announced to the screenreader.
   195  * Filter the message to be announced to the screenreader.
   202  *
   196  *
   203  * @param {string} message The message to be announced.
   197  * @param {string} message The message to be announced.
   204  *
   198  *
   218    * Safari + VoiceOver don't announce repeated, identical strings. We use
   212    * Safari + VoiceOver don't announce repeated, identical strings. We use
   219    * a `no-break space` to force them to think identical strings are different.
   213    * a `no-break space` to force them to think identical strings are different.
   220    */
   214    */
   221 
   215 
   222   if (previousMessage === message) {
   216   if (previousMessage === message) {
   223     message += "\xA0";
   217     message += '\u00A0';
   224   }
   218   }
   225 
   219 
   226   previousMessage = message;
   220   previousMessage = message;
   227   return message;
   221   return message;
   228 }
   222 }
   243 /**
   237 /**
   244  * Create the live regions.
   238  * Create the live regions.
   245  */
   239  */
   246 
   240 
   247 function setup() {
   241 function setup() {
   248   var introText = document.getElementById('a11y-speak-intro-text');
   242   const introText = document.getElementById('a11y-speak-intro-text');
   249   var containerAssertive = document.getElementById('a11y-speak-assertive');
   243   const containerAssertive = document.getElementById('a11y-speak-assertive');
   250   var containerPolite = document.getElementById('a11y-speak-polite');
   244   const containerPolite = document.getElementById('a11y-speak-polite');
   251 
   245 
   252   if (introText === null) {
   246   if (introText === null) {
   253     addIntroText();
   247     addIntroText();
   254   }
   248   }
   255 
   249 
   263 }
   257 }
   264 /**
   258 /**
   265  * Run setup on domReady.
   259  * Run setup on domReady.
   266  */
   260  */
   267 
   261 
   268 external_this_wp_domReady_default()(setup);
   262 external_wp_domReady_default()(setup);
   269 /**
   263 /**
   270  * Allows you to easily announce dynamic interface updates to screen readers using ARIA live regions.
   264  * Allows you to easily announce dynamic interface updates to screen readers using ARIA live regions.
   271  * This module is inspired by the `speak` function in `wp-a11y.js`.
   265  * This module is inspired by the `speak` function in `wp-a11y.js`.
   272  *
   266  *
   273  * @param {string} message  The message to be announced by assistive technologies.
   267  * @param {string} message  The message to be announced by assistive technologies.
   290    * Clear previous messages to allow repeated strings being read out and hide
   284    * Clear previous messages to allow repeated strings being read out and hide
   291    * the explanatory text from assistive technologies.
   285    * the explanatory text from assistive technologies.
   292    */
   286    */
   293   clear();
   287   clear();
   294   message = filterMessage(message);
   288   message = filterMessage(message);
   295   var introText = document.getElementById('a11y-speak-intro-text');
   289   const introText = document.getElementById('a11y-speak-intro-text');
   296   var containerAssertive = document.getElementById('a11y-speak-assertive');
   290   const containerAssertive = document.getElementById('a11y-speak-assertive');
   297   var containerPolite = document.getElementById('a11y-speak-polite');
   291   const containerPolite = document.getElementById('a11y-speak-polite');
   298 
   292 
   299   if (containerAssertive && ariaLive === 'assertive') {
   293   if (containerAssertive && ariaLive === 'assertive') {
   300     containerAssertive.textContent = message;
   294     containerAssertive.textContent = message;
   301   } else if (containerPolite) {
   295   } else if (containerPolite) {
   302     containerPolite.textContent = message;
   296     containerPolite.textContent = message;
   311     introText.removeAttribute('hidden');
   305     introText.removeAttribute('hidden');
   312   }
   306   }
   313 }
   307 }
   314 
   308 
   315 
   309 
       
   310 /***/ }),
       
   311 
       
   312 /***/ "l3Sj":
       
   313 /***/ (function(module, exports) {
       
   314 
       
   315 (function() { module.exports = window["wp"]["i18n"]; }());
       
   316 
   316 /***/ })
   317 /***/ })
   317 
   318 
   318 /******/ });
   319 /******/ });