Chris@0
|
1 /**
|
Chris@0
|
2 * DO NOT EDIT THIS FILE.
|
Chris@0
|
3 * See the following change record for more information,
|
Chris@0
|
4 * https://www.drupal.org/node/2815083
|
Chris@0
|
5 * @preserve
|
Chris@0
|
6 **/
|
Chris@0
|
7
|
Chris@0
|
8 (function ($, Drupal, drupalSettings) {
|
Chris@17
|
9 function mapTextContentToAjaxResponse(content) {
|
Chris@17
|
10 if (content === '') {
|
Chris@17
|
11 return false;
|
Chris@17
|
12 }
|
Chris@17
|
13
|
Chris@17
|
14 try {
|
Chris@17
|
15 return JSON.parse(content);
|
Chris@17
|
16 } catch (e) {
|
Chris@17
|
17 return false;
|
Chris@17
|
18 }
|
Chris@17
|
19 }
|
Chris@17
|
20
|
Chris@0
|
21 function bigPipeProcessPlaceholderReplacement(index, placeholderReplacement) {
|
Chris@0
|
22 var placeholderId = placeholderReplacement.getAttribute('data-big-pipe-replacement-for-placeholder-with-id');
|
Chris@0
|
23 var content = this.textContent.trim();
|
Chris@0
|
24
|
Chris@0
|
25 if (typeof drupalSettings.bigPipePlaceholderIds[placeholderId] !== 'undefined') {
|
Chris@14
|
26 var response = mapTextContentToAjaxResponse(content);
|
Chris@14
|
27
|
Chris@14
|
28 if (response === false) {
|
Chris@0
|
29 $(this).removeOnce('big-pipe');
|
Chris@0
|
30 } else {
|
Chris@0
|
31 var ajaxObject = Drupal.ajax({
|
Chris@0
|
32 url: '',
|
Chris@0
|
33 base: false,
|
Chris@0
|
34 element: false,
|
Chris@0
|
35 progress: false
|
Chris@0
|
36 });
|
Chris@0
|
37
|
Chris@0
|
38 ajaxObject.success(response, 'success');
|
Chris@0
|
39 }
|
Chris@0
|
40 }
|
Chris@0
|
41 }
|
Chris@0
|
42
|
Chris@17
|
43 var interval = drupalSettings.bigPipeInterval || 50;
|
Chris@14
|
44
|
Chris@17
|
45 var timeoutID = void 0;
|
Chris@14
|
46
|
Chris@0
|
47 function bigPipeProcessDocument(context) {
|
Chris@0
|
48 if (!context.querySelector('script[data-big-pipe-event="start"]')) {
|
Chris@0
|
49 return false;
|
Chris@0
|
50 }
|
Chris@0
|
51
|
Chris@0
|
52 $(context).find('script[data-big-pipe-replacement-for-placeholder-with-id]').once('big-pipe').each(bigPipeProcessPlaceholderReplacement);
|
Chris@0
|
53
|
Chris@0
|
54 if (context.querySelector('script[data-big-pipe-event="stop"]')) {
|
Chris@0
|
55 if (timeoutID) {
|
Chris@0
|
56 clearTimeout(timeoutID);
|
Chris@0
|
57 }
|
Chris@0
|
58 return true;
|
Chris@0
|
59 }
|
Chris@0
|
60
|
Chris@0
|
61 return false;
|
Chris@0
|
62 }
|
Chris@0
|
63
|
Chris@0
|
64 function bigPipeProcess() {
|
Chris@0
|
65 timeoutID = setTimeout(function () {
|
Chris@0
|
66 if (!bigPipeProcessDocument(document)) {
|
Chris@0
|
67 bigPipeProcess();
|
Chris@0
|
68 }
|
Chris@0
|
69 }, interval);
|
Chris@0
|
70 }
|
Chris@0
|
71
|
Chris@0
|
72 bigPipeProcess();
|
Chris@0
|
73
|
Chris@0
|
74 $(window).on('load', function () {
|
Chris@0
|
75 if (timeoutID) {
|
Chris@0
|
76 clearTimeout(timeoutID);
|
Chris@0
|
77 }
|
Chris@0
|
78 bigPipeProcessDocument(document);
|
Chris@0
|
79 });
|
Chris@0
|
80 })(jQuery, Drupal, drupalSettings); |