Sha256: fb8066abf51727192673d30f35efe48b12f21f7e6c28b0dfd16fcf3429513a54

Contents?: true

Size: 1.53 KB

Versions: 2

Compression:

Stored size: 1.53 KB

Contents

<!DOCTYPE html>
<html>
<meta charset='utf-8'>
<head>
<script src="../dialog-polyfill.js"></script>
<link rel="stylesheet" type="text/css" href="../dialog-polyfill.css">
<style>
body {
  height: 10000px;
}
dialog {
  width: 100px;
}
#console {
  position: fixed;
}
#ruler {
  position: absolute;
  left: 0;
  width: 100%;
}
</style>
</head>
<body>
<p>Test that dialog is recentered if reopened. The test passes if you see a
box in the center of the screen.</p>
<div id="ruler"></div>
<div id="console"></div>
<dialog></dialog>
<script>
function writeToConsole(s) {
  var console = document.getElementById('console');
  var span = document.createElement('span');
  span.textContent = s;
  console.appendChild(span);
  console.appendChild(document.createElement('br'));
}

function windowWidthMinusScrollbar() {
  return document.getElementById('ruler').offsetWidth;
}

function checkCentered(dialog) {
  var expectedTop = (window.innerHeight - dialog.offsetHeight) / 2;
  var expectedLeft = (windowWidthMinusScrollbar() - dialog.offsetWidth) / 2;
  var rect = dialog.getBoundingClientRect();
  if (rect.top == expectedTop && rect.left == expectedLeft) {
    writeToConsole('SUCCESS');
  } else {
    writeToConsole('FAIL: expected dialog top,left to be ' +
        expectedTop + ',' + expectedLeft + ' and was actually ' +
        rect.top + ',' + rect.left);
  }
}

var dialog = document.querySelector('dialog');
dialogPolyfill.registerDialog(dialog);
dialog.show();
dialog.close();
window.scrollTo(0, 500);
dialog.show();
checkCentered(dialog);
</script>
</body>
</html>

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
cortex-0.1.3 spec/dummy/node_modules/dialog-polyfill/tests/dialog-recentering.html
material-rails-0.1.0 node_modules/dialog-polyfill/tests/dialog-recentering.html