mirror of
https://github.com/google/blockly.git
synced 2026-01-05 08:00:09 +01:00
Switch from iframe to overlay in resize demo.
This commit is contained in:
@@ -1,41 +0,0 @@
|
||||
<!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 @@
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<a href="iframe/index.html">
|
||||
<img src="iframe/icon.png" height=80 width=100>
|
||||
<a href="resizable/index.html">
|
||||
<img src="resizable/icon.png" height=80 width=100>
|
||||
</a>
|
||||
</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>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
@@ -2,52 +2,51 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Blockly Demo: Iframe Blockly</title>
|
||||
<title>Blockly Demo: Resizable Blockly (Part 1)</title>
|
||||
<style>
|
||||
html, body {
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
body {
|
||||
background-color: #fff;
|
||||
font-family: sans-serif;
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
h1 {
|
||||
font-weight: normal;
|
||||
font-size: 140%;
|
||||
}
|
||||
iframe {
|
||||
width: 100%;
|
||||
table {
|
||||
height: 100%;
|
||||
border: none;
|
||||
width: 100%;
|
||||
}
|
||||
#blocklyArea {
|
||||
height: 99%;
|
||||
background: #fc9;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%" height="99%">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<h1><a href="https://developers.google.com/blockly/">Blockly</a> >
|
||||
<a href="../index.html">Demos</a> > Iframe Blockly</h1>
|
||||
<a href="../index.html">Demos</a> > 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>→ More info on <a href="https://developers.google.com/blockly/installation/injecting-resizable">injecting resizable Blockly</a>...</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="99%">
|
||||
<script>
|
||||
function blocklyLoaded(blockly) {
|
||||
// Called once Blockly is fully loaded.
|
||||
window.Blockly = blockly;
|
||||
}
|
||||
</script>
|
||||
<iframe src="frame.html"></iframe>
|
||||
<td id="blocklyArea">
|
||||
Blockly will be positioned here.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
91
demos/resizable/overlay.html
Normal file
91
demos/resizable/overlay.html
Normal file
@@ -0,0 +1,91 @@
|
||||
<!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> >
|
||||
<a href="../index.html">Demos</a> > 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>→ 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>
|
||||
Reference in New Issue
Block a user