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. --- store.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'store.js') diff --git a/store.js b/store.js index c0cd7b6..061b1be 100644 --- a/store.js +++ b/store.js @@ -61,7 +61,7 @@ SyntaxElementMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.store = '2013-April-19'; +modules.store = '2013-April-25'; // XML_Serializer /////////////////////////////////////////////////////// @@ -368,6 +368,17 @@ SnapSerializer.prototype.loadProjectModel = function (xmlNode) { project.stage.isThreadSafe = model.stage.attributes.threadsafe === 'true'; + model.hiddenPrimitives = model.project.childNamed('hidden'); + if (model.hiddenPrimitives) { + model.hiddenPrimitives.contents.split(' ').forEach( + function (sel) { + if (sel) { + StageMorph.prototype.hiddenPrimitives[sel] = true; + } + } + ); + } + model.globalBlocks = model.project.childNamed('blocks'); if (model.globalBlocks) { this.loadCustomBlocks(project.stage, model.globalBlocks, true); @@ -1246,6 +1257,7 @@ StageMorph.prototype.toXML = function (serializer) { '%' + '%%' + '' + + '$' + '%' + '%' + '', @@ -1266,6 +1278,10 @@ StageMorph.prototype.toXML = function (serializer) { serializer.store(this.customBlocks), serializer.store(this.scripts), serializer.store(this.children), + Object.keys(StageMorph.prototype.hiddenPrimitives).reduce( + function(a, b) {return a + ' ' + b; }, + '' + ), serializer.store(this.globalBlocks), (ide && ide.globalVariables) ? serializer.store(ide.globalVariables) : '' -- cgit v1.3.1