Sha256: d3df173edfb43206def9752fc70300a8ca7154b8a900008d0c82dbafe2172ae5

Contents?: true

Size: 961 Bytes

Versions: 7

Compression:

Stored size: 961 Bytes

Contents

<script>
  window.Cobot = window.Cobot || {};
  window.Cobot.iframeResize = function(height) {
    if(window.top != window) {
      window.parent.postMessage(JSON.stringify({frameHeight: height || window.Cobot.iframeHeight()}), '*');
    }
  };

  window.Cobot.iframeHeight = window.Cobot.iframeHeight || function() {
    var html = document.body.parentElement;
    var height = html.offsetHeight;
    var style = getComputedStyle(html);
    height += parseInt(style.marginTop) + parseInt(style.marginBottom);
    return height;
  };

  if(window.top != window) {
    window.addEventListener('load', function() {
      window.Cobot.iframeResize();
    });
  }

  window.Cobot.scrollTop = 0;
  window.addEventListener('message', function(message) {
    try {
      var data = JSON.parse(message.data);
      if(data.scrollTop) {
        window.Cobot.scrollTop = data.scrollTop;
      }
    } catch(e) {
      // invalid json, ignore
    }
  }, false);
</script>

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cobot_client-5.0.0 app/views/cobot_client/_resize_script.html.erb
cobot_client-4.0.0 app/views/cobot_client/_resize_script.html.erb
cobot_client-3.1.0 app/views/cobot_client/_resize_script.html.erb
cobot_client-3.0.0 app/views/cobot_client/_resize_script.html.erb
cobot_client-2.1.0 app/views/cobot_client/_resize_script.html.erb
cobot_client-2.0.0 app/views/cobot_client/_resize_script.html.erb
cobot_client-1.4.2 app/views/cobot_client/_resize_script.html.erb