Chris@0: /** Chris@0: * DO NOT EDIT THIS FILE. Chris@0: * See the following change record for more information, Chris@0: * https://www.drupal.org/node/2815083 Chris@0: * @preserve Chris@0: **/ Chris@0: Chris@0: (function ($, Drupal, drupalSettings) { Chris@17: function mapTextContentToAjaxResponse(content) { Chris@17: if (content === '') { Chris@17: return false; Chris@17: } Chris@17: Chris@17: try { Chris@17: return JSON.parse(content); Chris@17: } catch (e) { Chris@17: return false; Chris@17: } Chris@17: } Chris@17: Chris@0: function bigPipeProcessPlaceholderReplacement(index, placeholderReplacement) { Chris@0: var placeholderId = placeholderReplacement.getAttribute('data-big-pipe-replacement-for-placeholder-with-id'); Chris@0: var content = this.textContent.trim(); Chris@0: Chris@0: if (typeof drupalSettings.bigPipePlaceholderIds[placeholderId] !== 'undefined') { Chris@14: var response = mapTextContentToAjaxResponse(content); Chris@14: Chris@14: if (response === false) { Chris@0: $(this).removeOnce('big-pipe'); Chris@0: } else { Chris@0: var ajaxObject = Drupal.ajax({ Chris@0: url: '', Chris@0: base: false, Chris@0: element: false, Chris@0: progress: false Chris@0: }); Chris@0: Chris@0: ajaxObject.success(response, 'success'); Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@17: var interval = drupalSettings.bigPipeInterval || 50; Chris@14: Chris@17: var timeoutID = void 0; Chris@14: Chris@0: function bigPipeProcessDocument(context) { Chris@0: if (!context.querySelector('script[data-big-pipe-event="start"]')) { Chris@0: return false; Chris@0: } Chris@0: Chris@0: $(context).find('script[data-big-pipe-replacement-for-placeholder-with-id]').once('big-pipe').each(bigPipeProcessPlaceholderReplacement); Chris@0: Chris@0: if (context.querySelector('script[data-big-pipe-event="stop"]')) { Chris@0: if (timeoutID) { Chris@0: clearTimeout(timeoutID); Chris@0: } Chris@0: return true; Chris@0: } Chris@0: Chris@0: return false; Chris@0: } Chris@0: Chris@0: function bigPipeProcess() { Chris@0: timeoutID = setTimeout(function () { Chris@0: if (!bigPipeProcessDocument(document)) { Chris@0: bigPipeProcess(); Chris@0: } Chris@0: }, interval); Chris@0: } Chris@0: Chris@0: bigPipeProcess(); Chris@0: Chris@0: $(window).on('load', function () { Chris@0: if (timeoutID) { Chris@0: clearTimeout(timeoutID); Chris@0: } Chris@0: bigPipeProcessDocument(document); Chris@0: }); Chris@0: })(jQuery, Drupal, drupalSettings);