iframeswitcher.phtml 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. // @codingStandardsIgnoreFile
  7. /** @var \Magento\Backend\Block\Page $block */
  8. ?>
  9. <div id="preview" class="cms-revision-preview">
  10. <div class="toolbar">
  11. <?php if (!$block->isSingleStoreMode()) :?>
  12. <div class="store-switcher">
  13. <?= $block->getChildHtml('store_switcher') ?>
  14. </div>
  15. <?php endif;?>
  16. </div>
  17. <iframe
  18. name="preview_iframe"
  19. id="preview_iframe"
  20. frameborder="0"
  21. title="<?= $block->escapeHtmlAttr(__('Preview')) ?>"
  22. width="100%"
  23. sandbox="allow-forms allow-pointer-lock allow-scripts"
  24. >
  25. </iframe>
  26. <?= $block->getChildHtml('preview_form') ?>
  27. </div>
  28. <script>
  29. require(['jquery', 'loadingPopup', 'prototype'], function(jQuery){
  30. //<![CDATA[
  31. var previewForm = $('preview_form');
  32. var previewIframe = $('preview_iframe');
  33. function preview() {
  34. previewForm.writeAttribute('target', previewIframe.readAttribute('id'));
  35. blockPreview();
  36. previewForm.submit();
  37. }
  38. function blockPreview() {
  39. jQuery('body').loadingPopup({
  40. timeout: false
  41. });
  42. }
  43. function unBlockPreview() {
  44. jQuery('body').trigger('hideLoadingPopup');
  45. }
  46. jQuery(document).ready(preview);
  47. jQuery(previewIframe).ready(unBlockPreview);
  48. jQuery("#preview_iframe").load(function() {
  49. jQuery(this).height(jQuery(this).contents().find("html").height() );
  50. });
  51. //]]>
  52. });
  53. </script>