From 4580aa1e0d58b4f7f5aa27f5360416d6cc4697d8 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 25 Apr 2013 16:52:59 +0200 Subject: Hide Primitives feature Primitive blocks in the palette can now be hidden in the project via their context menu. Each palette's context menu further lets you hide or show all its primitives depending on whether any primitives are left to hide or show. Hidden primitives are stored in the project data. This lets instructors create "simplified" examples and problem sets. --- blocks.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'blocks.js') diff --git a/blocks.js b/blocks.js index 449bd14..2f1c5fc 100644 --- a/blocks.js +++ b/blocks.js @@ -153,7 +153,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2013-April-23'; +modules.blocks = '2013-April-25'; var SyntaxElementMorph; var BlockMorph; @@ -1784,6 +1784,12 @@ BlockMorph.prototype.userMenu = function () { 'showHelp' ); if (this.isTemplate) { + if (this.selector !== 'evaluateCustomBlock') { + menu.addItem( + "hide", + 'hidePrimitive' + ); + } return menu; } menu.addLine(); @@ -1883,6 +1889,24 @@ BlockMorph.prototype.developersMenu = function () { return menu; }; +BlockMorph.prototype.hidePrimitive = function () { + // passing a selector is optional + var ide = this.parentThatIsA(IDE_Morph), + cat; + if (!ide) {return; } + StageMorph.prototype.hiddenPrimitives[this.selector] = true; + cat = { + doWarp: 'control', + reifyScript: 'operators', + reifyReporter: 'operators', + reifyPredicate: 'operators', + doDeclareVariables: 'variables' + }[this.selector] || this.category; + if (cat === 'lists') {cat = 'variables'; } + ide.flushBlocksCache(cat); + ide.refreshPalette(); +}; + BlockMorph.prototype.deleteBlock = function () { // delete just this one block, keep inputs and next block around var scripts = this.parentThatIsA(ScriptsMorph), -- cgit v1.3.1