PluginProbe
Faust.js / 1.0.2
Faust.js v1.0.2
1.8.12 1.8.11 1.4.1 1.8.0 1.8.8 1.8.9 trunk 0.7.0 0.7.1 0.7.10 0.7.11 0.7.3 0.7.4 0.7.5 0.7.6 0.7.7 0.7.8 0.7.9 0.8.0 0.8.1 0.8.3 0.8.4 0.8.5 0.8.6 0.8.7 All 40 releases
faustwp / includes / replacement / previewlinks.js

previewlinks.js in Faust.js 1.0.2, at includes/replacement/previewlinks.js

56 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * XXX: Please remove this once this issue is resolved: https://github.com/WordPress/gutenberg/issues/13998
3 */
4
5 window.addEventListener('DOMContentLoaded', function () {
6 jQuery(document).ready(function () {
7 // Get the correct preview link via wp_localize_script
8 const previewLink = window._faustwp_preview_link
9 ? window._faustwp_preview_link._preview_link
10 : undefined;
11
12 /**
13 * Check to make sure there is a preview link before continuing, as there may not be a preview link
14 * for every instance the block editor is enqueued (e.g. /wp-admin/widgets.php)
15 */
16 if (!previewLink) {
17 return;
18 }
19
20 const intervalId = setInterval(function () {
21 const previewButton = jQuery(
22 'button[class~="block-editor-post-preview__button-toggle"]',
23 );
24
25 if (!previewButton.length) {
26 return;
27 }
28
29 clearInterval(intervalId);
30 previewButton.first().one('click', function () {
31 setTimeout(function () {
32 const links = jQuery('a[target*="wp-preview"]');
33
34 if (!links.length) {
35 return;
36 }
37
38 links.each((i, link) => {
39 link.href = previewLink;
40
41 var copy = link.cloneNode(true);
42 copy.addEventListener('click', function () {
43 previewButton[0].click();
44
45 wp.data.dispatch('core/editor').autosave();
46 });
47
48 link.parentElement.insertBefore(copy, link);
49 link.style.display = 'none';
50 });
51 }, 100);
52 });
53 }, 100);
54 });
55 });
56