@@ -451,11 +451,6 @@ Code.loadDemoArea = function () {
451
451
select . value = demoPage === 'default' ? 'demo-area-01' : demoPage ;
452
452
Code . reloadSandbox ( ) ;
453
453
454
- window . addEventListener ( 'resize' , function ( ) {
455
- contentHeight = document . getElementById ( 'content_blocks' ) . offsetHeight ;
456
- area . style . height = ( contentHeight - 110 ) + 'px' ;
457
- } ) ;
458
-
459
454
resizeBar . onmousedown = function ( e ) {
460
455
area . style . opacity = '0.4' ;
461
456
var frame = document . getElementById ( 'demo-frame' ) ;
@@ -805,6 +800,8 @@ Code.init = function (toolbox) {
805
800
// (Code.workspace.toolbox_.width - 38) + 'px';
806
801
// // Account for the 19 pixel margin and on each side.
807
802
//}
803
+ var contentHeight = document . getElementById ( 'content_blocks' ) . offsetHeight ;
804
+ document . getElementById ( 'demo-area' ) . style . height = ( contentHeight - 110 ) + 'px' ;
808
805
} ;
809
806
window . addEventListener ( 'resize' , onresize , false ) ;
810
807
@@ -1233,7 +1230,9 @@ Code.getBlockDemo = function (type) {
1233
1230
var attr ;
1234
1231
if ( block ) {
1235
1232
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' ) ) ) {
1237
1236
return attr ;
1238
1237
}
1239
1238
}
@@ -1326,7 +1325,9 @@ Blockly.Xml.domToWorkspace = function () {
1326
1325
var demo = Code . getBlockDemo ( type ) ;
1327
1326
if ( demo ) {
1328
1327
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 ( ) ) ;
1330
1331
}
1331
1332
return ;
1332
1333
}
0 commit comments