summaryrefslogtreecommitdiff
path: root/blocks.js
diff options
context:
space:
mode:
authorjmoenig <jens@moenig.org>2013-04-25 16:52:59 +0200
committerjmoenig <jens@moenig.org>2013-04-25 16:52:59 +0200
commit4580aa1e0d58b4f7f5aa27f5360416d6cc4697d8 (patch)
treeefddff05674e7c4454c38eab2869d2c9c3bd8d76 /blocks.js
parentd0878399fe0a85a05642a223dd4796badd212c5c (diff)
downloadsnap-byow-4580aa1e0d58b4f7f5aa27f5360416d6cc4697d8.tar.gz
snap-byow-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.js26
1 files changed, 25 insertions, 1 deletions
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),