You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
3.7 KiB

1 year ago
  1. "use strict";
  2. (self["__WordPressPrivateInteractivityAPI__"] = self["__WordPressPrivateInteractivityAPI__"] || []).push([[155],{
  3. /***/ 890:
  4. /***/ (function(__unused_webpack_module, __unused_webpack___webpack_exports__, __webpack_require__) {
  5. /* harmony import */ var _wordpress_interactivity__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(754);
  6. /**
  7. * WordPress dependencies
  8. */
  9. const isValidLink = ref => ref && ref instanceof window.HTMLAnchorElement && ref.href && (!ref.target || ref.target === '_self') && ref.origin === window.location.origin;
  10. const isValidEvent = event => event.button === 0 &&
  11. // left clicks only
  12. !event.metaKey &&
  13. // open in new tab (mac)
  14. !event.ctrlKey &&
  15. // open in new tab (windows)
  16. !event.altKey &&
  17. // download
  18. !event.shiftKey && !event.defaultPrevented;
  19. (0,_wordpress_interactivity__WEBPACK_IMPORTED_MODULE_0__/* .store */ .h)({
  20. selectors: {
  21. core: {
  22. query: {
  23. startAnimation: ({
  24. context
  25. }) => context.core.query.animation === 'start',
  26. finishAnimation: ({
  27. context
  28. }) => context.core.query.animation === 'finish'
  29. }
  30. }
  31. },
  32. actions: {
  33. core: {
  34. query: {
  35. navigate: async ({
  36. event,
  37. ref,
  38. context
  39. }) => {
  40. const isDisabled = ref.closest('[data-wp-navigation-id]')?.dataset.wpNavigationDisabled;
  41. if (isValidLink(ref) && isValidEvent(event) && !isDisabled) {
  42. event.preventDefault();
  43. const id = ref.closest('[data-wp-navigation-id]').dataset.wpNavigationId;
  44. // Don't announce the navigation immediately, wait 300 ms.
  45. const timeout = setTimeout(() => {
  46. context.core.query.message = context.core.query.loadingText;
  47. context.core.query.animation = 'start';
  48. }, 400);
  49. await (0,_wordpress_interactivity__WEBPACK_IMPORTED_MODULE_0__/* .navigate */ .c4)(ref.href);
  50. // Dismiss loading message if it hasn't been added yet.
  51. clearTimeout(timeout);
  52. // Announce that the page has been loaded. If the message is the
  53. // same, we use a no-break space similar to the @wordpress/a11y
  54. // package: https://github.com/WordPress/gutenberg/blob/c395242b8e6ee20f8b06c199e4fc2920d7018af1/packages/a11y/src/filter-message.js#L20-L26
  55. context.core.query.message = context.core.query.loadedText + (context.core.query.message === context.core.query.loadedText ? '\u00A0' : '');
  56. context.core.query.animation = 'finish';
  57. context.core.query.url = ref.href;
  58. // Focus the first anchor of the Query block.
  59. const firstAnchor = `[data-wp-navigation-id=${id}] .wp-block-post-template a[href]`;
  60. document.querySelector(firstAnchor)?.focus();
  61. }
  62. },
  63. prefetch: async ({
  64. ref
  65. }) => {
  66. const isDisabled = ref.closest('[data-wp-navigation-id]')?.dataset.wpNavigationDisabled;
  67. if (isValidLink(ref) && !isDisabled) {
  68. await (0,_wordpress_interactivity__WEBPACK_IMPORTED_MODULE_0__/* .prefetch */ .tL)(ref.href);
  69. }
  70. }
  71. }
  72. }
  73. },
  74. effects: {
  75. core: {
  76. query: {
  77. prefetch: async ({
  78. ref,
  79. context
  80. }) => {
  81. if (context.core.query.url && isValidLink(ref)) {
  82. await (0,_wordpress_interactivity__WEBPACK_IMPORTED_MODULE_0__/* .prefetch */ .tL)(ref.href);
  83. }
  84. }
  85. }
  86. }
  87. }
  88. });
  89. /***/ })
  90. },
  91. /******/ function(__webpack_require__) { // webpackRuntimeModules
  92. /******/ var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); }
  93. /******/ var __webpack_exports__ = (__webpack_exec__(890));
  94. /******/ }
  95. ]);