src/Platform/MarketingBundle/Resources/views/Dashboard/Default/includes/hubspot_frame.html.twig line 1

Open in your IDE?
  1. {% set src = _args.src %}
  2. {% set htmlId = 'hubspot-frame-%s'|format(
  3.     token()
  4. ) %}
  5. {% set autoHeight = _args.autoHeight|default(false) %}
  6. {#
  7.     This is the snippet needed in the iframe content to make this work:
  8.     <script type="text/javascript">$(function() { window.top.postMessage({height: $(document).height()}, '*'); });</script>
  9. #}
  10. {% if autoHeight %}
  11.     <script type="text/javascript">
  12.         window.addEventListener('message', function (e) {
  13.             var frame = $('#{{ htmlId }}')[0],
  14.                 wndw = frame.contentWindow;
  15.             if (e.origin === "https://content.schoolnow.com" && e.source === wndw) {
  16.                 $(function() {
  17.                     $('#{{ htmlId }}').css('height', (e.data.height + 40) + 'px');
  18.                 });
  19.             }
  20.         });
  21.     </script>
  22. {% endif %}
  23. <iframe id="{{ htmlId }}" style="border: none; width: 100%; height: 100%;" src="{{ src }}"></iframe>