diff options
| author | jmoenig <jens@moenig.org> | 2013-04-25 16:52:59 +0200 |
|---|---|---|
| committer | jmoenig <jens@moenig.org> | 2013-04-25 16:52:59 +0200 |
| commit | 4580aa1e0d58b4f7f5aa27f5360416d6cc4697d8 (patch) | |
| tree | efddff05674e7c4454c38eab2869d2c9c3bd8d76 /blocks.js | |
| parent | d0878399fe0a85a05642a223dd4796badd212c5c (diff) | |
| download | snap-4580aa1e0d58b4f7f5aa27f5360416d6cc4697d8.tar.gz snap-4580aa1e0d58b4f7f5aa27f5360416d6cc4697d8.zip | |
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.
Diffstat (limited to 'blocks.js')
| -rw-r--r-- | blocks.js | 26 |
1 files changed, 25 insertions, 1 deletions
@@ -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), |
