Mercurial > hg > isophonics-drupal-site
view core/modules/big_pipe/js/big_pipe.js @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 4c8ae668cc8c |
children | 129ea1e6d783 |
line wrap: on
line source
/** * DO NOT EDIT THIS FILE. * See the following change record for more information, * https://www.drupal.org/node/2815083 * @preserve **/ (function ($, Drupal, drupalSettings) { function bigPipeProcessPlaceholderReplacement(index, placeholderReplacement) { var placeholderId = placeholderReplacement.getAttribute('data-big-pipe-replacement-for-placeholder-with-id'); var content = this.textContent.trim(); if (typeof drupalSettings.bigPipePlaceholderIds[placeholderId] !== 'undefined') { var response = mapTextContentToAjaxResponse(content); if (response === false) { $(this).removeOnce('big-pipe'); } else { var ajaxObject = Drupal.ajax({ url: '', base: false, element: false, progress: false }); ajaxObject.success(response, 'success'); } } } function mapTextContentToAjaxResponse(content) { if (content === '') { return false; } try { return JSON.parse(content); } catch (e) { return false; } } function bigPipeProcessDocument(context) { if (!context.querySelector('script[data-big-pipe-event="start"]')) { return false; } $(context).find('script[data-big-pipe-replacement-for-placeholder-with-id]').once('big-pipe').each(bigPipeProcessPlaceholderReplacement); if (context.querySelector('script[data-big-pipe-event="stop"]')) { if (timeoutID) { clearTimeout(timeoutID); } return true; } return false; } function bigPipeProcess() { timeoutID = setTimeout(function () { if (!bigPipeProcessDocument(document)) { bigPipeProcess(); } }, interval); } var interval = drupalSettings.bigPipeInterval || 50; var timeoutID = void 0; bigPipeProcess(); $(window).on('load', function () { if (timeoutID) { clearTimeout(timeoutID); } bigPipeProcessDocument(document); }); })(jQuery, Drupal, drupalSettings);