Sha256: 33a1ff1a0c8989f0a33b938f5a5b552bbdca4faf508e340140b589245bcf4232

Contents?: true

Size: 935 Bytes

Versions: 2

Compression:

Stored size: 935 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 height = document.body.offsetHeight;
    var style = getComputedStyle(document.body);
    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

2 entries across 2 versions & 1 rubygems

Version Path
cobot_client-1.4.0 app/views/cobot_client/_resize_script.html.erb
cobot_client-1.3.1 app/views/cobot_client/_resize_script.html.erb