wp/wp-includes/js/dist/a11y.js
changeset 22 8c2e4d02f4ef
parent 21 48c4eec2b7e6
equal deleted inserted replaced
21:48c4eec2b7e6 22:8c2e4d02f4ef
    50 __webpack_require__.r(__webpack_exports__);
    50 __webpack_require__.r(__webpack_exports__);
    51 
    51 
    52 // EXPORTS
    52 // EXPORTS
    53 __webpack_require__.d(__webpack_exports__, {
    53 __webpack_require__.d(__webpack_exports__, {
    54   setup: () => (/* binding */ setup),
    54   setup: () => (/* binding */ setup),
    55   speak: () => (/* binding */ speak)
    55   speak: () => (/* reexport */ speak)
    56 });
    56 });
    57 
    57 
    58 ;// CONCATENATED MODULE: external ["wp","domReady"]
    58 ;// external ["wp","domReady"]
    59 const external_wp_domReady_namespaceObject = window["wp"]["domReady"];
    59 const external_wp_domReady_namespaceObject = window["wp"]["domReady"];
    60 var external_wp_domReady_default = /*#__PURE__*/__webpack_require__.n(external_wp_domReady_namespaceObject);
    60 var external_wp_domReady_default = /*#__PURE__*/__webpack_require__.n(external_wp_domReady_namespaceObject);
    61 ;// CONCATENATED MODULE: external ["wp","i18n"]
    61 ;// ./node_modules/@wordpress/a11y/build-module/script/add-container.js
    62 const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
       
    63 ;// CONCATENATED MODULE: ./node_modules/@wordpress/a11y/build-module/add-intro-text.js
       
    64 /**
       
    65  * WordPress dependencies
       
    66  */
       
    67 
       
    68 
       
    69 /**
       
    70  * Build the explanatory text to be placed before the aria live regions.
       
    71  *
       
    72  * This text is initially hidden from assistive technologies by using a `hidden`
       
    73  * HTML attribute which is then removed once a message fills the aria-live regions.
       
    74  *
       
    75  * @return {HTMLParagraphElement} The explanatory text HTML element.
       
    76  */
       
    77 function addIntroText() {
       
    78   const introText = document.createElement('p');
       
    79   introText.id = 'a11y-speak-intro-text';
       
    80   introText.className = 'a11y-speak-intro-text';
       
    81   introText.textContent = (0,external_wp_i18n_namespaceObject.__)('Notifications');
       
    82   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;');
       
    83   introText.setAttribute('hidden', 'hidden');
       
    84   const {
       
    85     body
       
    86   } = document;
       
    87   if (body) {
       
    88     body.appendChild(introText);
       
    89   }
       
    90   return introText;
       
    91 }
       
    92 
       
    93 ;// CONCATENATED MODULE: ./node_modules/@wordpress/a11y/build-module/add-container.js
       
    94 /**
    62 /**
    95  * Build the live regions markup.
    63  * Build the live regions markup.
    96  *
    64  *
    97  * @param {string} [ariaLive] Value for the 'aria-live' attribute; default: 'polite'.
    65  * @param {string} [ariaLive] Value for the 'aria-live' attribute; default: 'polite'.
    98  *
    66  *
   113     body.appendChild(container);
    81     body.appendChild(container);
   114   }
    82   }
   115   return container;
    83   return container;
   116 }
    84 }
   117 
    85 
   118 ;// CONCATENATED MODULE: ./node_modules/@wordpress/a11y/build-module/clear.js
    86 ;// external ["wp","i18n"]
       
    87 const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
       
    88 ;// ./node_modules/@wordpress/a11y/build-module/script/add-intro-text.js
       
    89 /**
       
    90  * WordPress dependencies
       
    91  */
       
    92 
       
    93 
       
    94 /**
       
    95  * Build the explanatory text to be placed before the aria live regions.
       
    96  *
       
    97  * This text is initially hidden from assistive technologies by using a `hidden`
       
    98  * HTML attribute which is then removed once a message fills the aria-live regions.
       
    99  *
       
   100  * @return {HTMLParagraphElement} The explanatory text HTML element.
       
   101  */
       
   102 function addIntroText() {
       
   103   const introText = document.createElement('p');
       
   104   introText.id = 'a11y-speak-intro-text';
       
   105   introText.className = 'a11y-speak-intro-text';
       
   106   introText.textContent = (0,external_wp_i18n_namespaceObject.__)('Notifications');
       
   107   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;');
       
   108   introText.setAttribute('hidden', 'hidden');
       
   109   const {
       
   110     body
       
   111   } = document;
       
   112   if (body) {
       
   113     body.appendChild(introText);
       
   114   }
       
   115   return introText;
       
   116 }
       
   117 
       
   118 ;// ./node_modules/@wordpress/a11y/build-module/shared/clear.js
   119 /**
   119 /**
   120  * Clears the a11y-speak-region elements and hides the explanatory text.
   120  * Clears the a11y-speak-region elements and hides the explanatory text.
   121  */
   121  */
   122 function clear() {
   122 function clear() {
   123   const regions = document.getElementsByClassName('a11y-speak-region');
   123   const regions = document.getElementsByClassName('a11y-speak-region');
   130   if (introText) {
   130   if (introText) {
   131     introText.setAttribute('hidden', 'hidden');
   131     introText.setAttribute('hidden', 'hidden');
   132   }
   132   }
   133 }
   133 }
   134 
   134 
   135 ;// CONCATENATED MODULE: ./node_modules/@wordpress/a11y/build-module/filter-message.js
   135 ;// ./node_modules/@wordpress/a11y/build-module/shared/filter-message.js
   136 let previousMessage = '';
   136 let previousMessage = '';
   137 
   137 
   138 /**
   138 /**
   139  * Filter the message to be announced to the screenreader.
   139  * Filter the message to be announced to the screenreader.
   140  *
   140  *
   161   }
   161   }
   162   previousMessage = message;
   162   previousMessage = message;
   163   return message;
   163   return message;
   164 }
   164 }
   165 
   165 
   166 ;// CONCATENATED MODULE: ./node_modules/@wordpress/a11y/build-module/index.js
   166 ;// ./node_modules/@wordpress/a11y/build-module/shared/index.js
   167 /**
       
   168  * WordPress dependencies
       
   169  */
       
   170 
       
   171 
       
   172 /**
   167 /**
   173  * Internal dependencies
   168  * Internal dependencies
   174  */
   169  */
   175 
   170 
   176 
   171 
   177 
       
   178 
       
   179 
       
   180 /**
       
   181  * Create the live regions.
       
   182  */
       
   183 function setup() {
       
   184   const introText = document.getElementById('a11y-speak-intro-text');
       
   185   const containerAssertive = document.getElementById('a11y-speak-assertive');
       
   186   const containerPolite = document.getElementById('a11y-speak-polite');
       
   187   if (introText === null) {
       
   188     addIntroText();
       
   189   }
       
   190   if (containerAssertive === null) {
       
   191     addContainer('assertive');
       
   192   }
       
   193   if (containerPolite === null) {
       
   194     addContainer('polite');
       
   195   }
       
   196 }
       
   197 
       
   198 /**
       
   199  * Run setup on domReady.
       
   200  */
       
   201 external_wp_domReady_default()(setup);
       
   202 
   172 
   203 /**
   173 /**
   204  * Allows you to easily announce dynamic interface updates to screen readers using ARIA live regions.
   174  * Allows you to easily announce dynamic interface updates to screen readers using ARIA live regions.
   205  * This module is inspired by the `speak` function in `wp-a11y.js`.
   175  * This module is inspired by the `speak` function in `wp-a11y.js`.
   206  *
   176  *
   207  * @param {string} message    The message to be announced by assistive technologies.
   177  * @param {string}               message    The message to be announced by assistive technologies.
   208  * @param {string} [ariaLive] The politeness level for aria-live; default: 'polite'.
   178  * @param {'polite'|'assertive'} [ariaLive] The politeness level for aria-live; default: 'polite'.
   209  *
   179  *
   210  * @example
   180  * @example
   211  * ```js
   181  * ```js
   212  * import { speak } from '@wordpress/a11y';
   182  * import { speak } from '@wordpress/a11y';
   213  *
   183  *
   241   if (introText) {
   211   if (introText) {
   242     introText.removeAttribute('hidden');
   212     introText.removeAttribute('hidden');
   243   }
   213   }
   244 }
   214 }
   245 
   215 
       
   216 ;// ./node_modules/@wordpress/a11y/build-module/index.js
       
   217 /**
       
   218  * WordPress dependencies
       
   219  */
       
   220 
       
   221 
       
   222 /**
       
   223  * Internal dependencies
       
   224  */
       
   225 
       
   226 
       
   227 
       
   228 
       
   229 /**
       
   230  * Create the live regions.
       
   231  */
       
   232 function setup() {
       
   233   const introText = document.getElementById('a11y-speak-intro-text');
       
   234   const containerAssertive = document.getElementById('a11y-speak-assertive');
       
   235   const containerPolite = document.getElementById('a11y-speak-polite');
       
   236   if (introText === null) {
       
   237     addIntroText();
       
   238   }
       
   239   if (containerAssertive === null) {
       
   240     addContainer('assertive');
       
   241   }
       
   242   if (containerPolite === null) {
       
   243     addContainer('polite');
       
   244   }
       
   245 }
       
   246 
       
   247 /**
       
   248  * Run setup on domReady.
       
   249  */
       
   250 external_wp_domReady_default()(setup);
       
   251 
   246 (window.wp = window.wp || {}).a11y = __webpack_exports__;
   252 (window.wp = window.wp || {}).a11y = __webpack_exports__;
   247 /******/ })()
   253 /******/ })()
   248 ;
   254 ;