Commit 4b550b9d authored by Neil Fraser's avatar Neil Fraser

Switch from iframe to overlay in resize demo.

parent f454f779
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="../../blockly_compressed.js"></script>
<script src="../../blocks_compressed.js"></script>
<script src="../../msg/js/en.js"></script>
<style>
html, body {
background-color: #fff;
margin: 0;
padding: 0;
overflow: hidden;
height: 100%;
}
.blocklySvg {
height: 100%;
width: 100%;
}
</style>
<script>
function init() {
Blockly.inject(document.body,
{toolbox: document.getElementById('toolbox')});
// Let the top-level application know that Blockly is ready.
window.parent.blocklyLoaded(Blockly);
}
</script>
</head>
<body onload="init()">
<xml id="toolbox" style="display: none">
<block type="controls_if"></block>
<block type="logic_compare"></block>
<block type="controls_repeat_ext"></block>
<block type="math_number"></block>
<block type="math_arithmetic"></block>
<block type="text"></block>
<block type="text_print"></block>
</xml>
</body>
</html>
...@@ -42,12 +42,12 @@ ...@@ -42,12 +42,12 @@
<tr> <tr>
<td> <td>
<a href="iframe/index.html"> <a href="resizable/index.html">
<img src="iframe/icon.png" height=80 width=100> <img src="resizable/icon.png" height=80 width=100>
</a> </a>
</td> </td>
<td> <td>
<div><a href="iframe/index.html">Resizable Blockly</a></div> <div><a href="resizable/index.html">Resizable Blockly</a></div>
<div>Inject Blockly into a page as a resizable element.</div> <div>Inject Blockly into a page as a resizable element.</div>
</td> </td>
</tr> </tr>
......
...@@ -2,52 +2,51 @@ ...@@ -2,52 +2,51 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Blockly Demo: Iframe Blockly</title> <title>Blockly Demo: Resizable Blockly (Part 1)</title>
<style> <style>
html, body { html, body {
height: 100%; height: 100%;
margin: 0;
} }
body { body {
background-color: #fff; background-color: #fff;
font-family: sans-serif; font-family: sans-serif;
margin-top: 0; overflow: hidden;
margin-bottom: 0;
} }
h1 { h1 {
font-weight: normal; font-weight: normal;
font-size: 140%; font-size: 140%;
} }
iframe { table {
width: 100%;
height: 100%; height: 100%;
border: none; width: 100%;
}
#blocklyArea {
height: 99%;
background: #fc9;
text-align: center;
} }
</style> </style>
</head> </head>
<body> <body>
<table width="100%" height="99%"> <table>
<tr> <tr>
<td> <td>
<h1><a href="https://developers.google.com/blockly/">Blockly</a> &gt; <h1><a href="https://developers.google.com/blockly/">Blockly</a> &gt;
<a href="../index.html">Demos</a> &gt; Iframe Blockly</h1> <a href="../index.html">Demos</a> &gt; Resizable Blockly (Part 1)</h1>
<p>This is a simple demo of injecting Blockly into a resizable 'iframe' element.</p> <p>The first step in creating a resizable Blockly workspace is to use
CSS or tables to create an area for it.
Next, <a href="overlay.html">inject Blockly</a> over that area.</p>
<p>&rarr; More info on <a href="https://developers.google.com/blockly/installation/injecting-resizable">injecting resizable Blockly</a>...</p> <p>&rarr; More info on <a href="https://developers.google.com/blockly/installation/injecting-resizable">injecting resizable Blockly</a>...</p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td height="99%"> <td id="blocklyArea">
<script> Blockly will be positioned here.
function blocklyLoaded(blockly) {
// Called once Blockly is fully loaded.
window.Blockly = blockly;
}
</script>
<iframe src="frame.html"></iframe>
</td> </td>
</tr> </tr>
</table> </table>
</body> </body>
</html> </html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Blockly Demo: Resizable Blockly (Part 2)</title>
<script src="../../blockly_compressed.js"></script>
<script src="../../blocks_compressed.js"></script>
<script src="../../msg/js/en.js"></script>
<style>
html, body {
height: 100%;
margin: 0;
}
body {
background-color: #fff;
font-family: sans-serif;
overflow: hidden;
}
h1 {
font-weight: normal;
font-size: 140%;
}
table {
height: 100%;
width: 100%;
}
#blocklyArea {
height: 99%;
}
</style>
</head>
<body>
<table>
<tr>
<td>
<h1><a href="https://developers.google.com/blockly/">Blockly</a> &gt;
<a href="../index.html">Demos</a> &gt; Resizable Blockly (Part 2)</h1>
<p>
Once an <a href="index.html">area is defined</a>, Blockly can be
injected and positioned over the area.
A resize handler keeps it in position as the page changes.
</p>
<p>&rarr; More info on <a href="https://developers.google.com/blockly/installation/injecting-resizable">injecting resizable Blockly</a>...</p>
</td>
</tr>
<tr>
<td id="blocklyArea">
</td>
</tr>
</table>
<div id="blocklyDiv" style="position: absolute"></div>
<xml id="toolbox" style="display: none">
<block type="controls_if"></block>
<block type="logic_compare"></block>
<block type="controls_repeat_ext"></block>
<block type="math_number"></block>
<block type="math_arithmetic"></block>
<block type="text"></block>
<block type="text_print"></block>
</xml>
<script>
var blocklyArea = document.getElementById('blocklyArea');
var blocklyDiv = document.getElementById('blocklyDiv');
var workspace = Blockly.inject(blocklyDiv,
{toolbox: document.getElementById('toolbox')});
var onresize = function(e) {
// Compute the absolute coordinates and dimensions of blocklyArea.
var element = blocklyArea;
var x = 0;
var y = 0;
do {
x += element.offsetLeft;
y += element.offsetTop;
element = element.offsetParent;
} while (element);
// Position blocklyDiv over blocklyArea.
blocklyDiv.style.left = x + 'px';
blocklyDiv.style.top = y + 'px';
blocklyDiv.style.width = blocklyArea.offsetWidth + 'px';
blocklyDiv.style.height = blocklyArea.offsetHeight + 'px';
};
window.addEventListener('resize', onresize, false);
onresize();
</script>
</body>
</html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment