Skip to content
This repository was archived by the owner on Nov 22, 2021. It is now read-only.

Commit 58a0e4c

Browse files
author
Ke, Mingze
committed
Tune demo area
1 parent 2b96125 commit 58a0e4c

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

code.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -451,11 +451,6 @@ Code.loadDemoArea = function () {
451451
select.value = demoPage === 'default' ? 'demo-area-01' : demoPage;
452452
Code.reloadSandbox();
453453

454-
window.addEventListener('resize', function () {
455-
contentHeight = document.getElementById('content_blocks').offsetHeight;
456-
area.style.height = (contentHeight - 110) + 'px';
457-
});
458-
459454
resizeBar.onmousedown = function (e) {
460455
area.style.opacity = '0.4';
461456
var frame = document.getElementById('demo-frame');
@@ -805,6 +800,8 @@ Code.init = function (toolbox) {
805800
// (Code.workspace.toolbox_.width - 38) + 'px';
806801
// // Account for the 19 pixel margin and on each side.
807802
//}
803+
var contentHeight = document.getElementById('content_blocks').offsetHeight;
804+
document.getElementById('demo-area').style.height = (contentHeight - 110) + 'px';
808805
};
809806
window.addEventListener('resize', onresize, false);
810807

@@ -1233,7 +1230,9 @@ Code.getBlockDemo = function (type) {
12331230
var attr;
12341231
if (block) {
12351232
while (block = block.parentNode) {
1236-
if (block.tagName === 'CATEGORY' && (attr = block.getAttribute('demo'))) {
1233+
if (block.nodeType === 1 &&
1234+
block.tagName.toLowerCase() === 'category' &&
1235+
(attr = block.getAttribute('demo'))) {
12371236
return attr;
12381237
}
12391238
}
@@ -1326,7 +1325,9 @@ Blockly.Xml.domToWorkspace = function () {
13261325
var demo = Code.getBlockDemo(type);
13271326
if (demo) {
13281327
if (demo !== Code.queryString.get('demo')) {
1329-
Code.queryString.set('demo', demo, true);
1328+
Code.queryString.set('demo', demo);
1329+
Code.loadDemoArea();
1330+
Code.workspace.updateToolbox(Code.getToolBox());
13301331
}
13311332
return;
13321333
}

0 commit comments

Comments
 (0)