diff options
| author | Jens Mönig <jens@moenig.org> | 2015-04-26 22:47:37 -0400 |
|---|---|---|
| committer | Jens Mönig <jens@moenig.org> | 2015-04-26 22:47:37 -0400 |
| commit | 9385e4b57c88c382c1758e54c258ac237d238679 (patch) | |
| tree | 1a858593b6bc1c0fb88c4486fbc185c63fe0b100 /store.js | |
| parent | 834b3918adc35792eae7d6cf59a17f48f0d88cb9 (diff) | |
| download | snap-9385e4b57c88c382c1758e54c258ac237d238679.tar.gz snap-9385e4b57c88c382c1758e54c258ac237d238679.zip | |
fixed #784
Diffstat (limited to 'store.js')
| -rw-r--r-- | store.js | 78 |
1 files changed, 43 insertions, 35 deletions
@@ -61,7 +61,7 @@ SyntaxElementMorph, Variable*/ // Global stuff //////////////////////////////////////////////////////// -modules.store = '2015-March-15'; +modules.store = '2015-April-26'; // XML_Serializer /////////////////////////////////////////////////////// @@ -491,7 +491,7 @@ SnapSerializer.prototype.rawLoadProjectModel = function (xmlNode) { /* Watchers */ model.sprites.childrenNamed('watcher').forEach(function (model) { - var watcher, color, target, hidden, extX, extY; + var watcher, color, target, hidden, extX, extY, vFrame; color = myself.loadColor(model.attributes.color); target = Object.prototype.hasOwnProperty.call( @@ -512,14 +512,20 @@ SnapSerializer.prototype.rawLoadProjectModel = function (xmlNode) { model.attributes, 'var' )) { - watcher = new WatcherMorph( - model.attributes['var'], - color, - isNil(target) ? project.globalVariables - : target.variables, - model.attributes['var'], - hidden - ); + vFrame = isNil(target) ? project.globalVariables + : target.variables; + if (Object.prototype.hasOwnProperty.call( + vFrame.vars, + model.attributes['var'] + )) { + watcher = new WatcherMorph( + model.attributes['var'], + color, + vFrame, + model.attributes['var'], + hidden + ); + } } else { watcher = new WatcherMorph( localize(myself.watcherLabels[model.attributes.s]), @@ -529,33 +535,35 @@ SnapSerializer.prototype.rawLoadProjectModel = function (xmlNode) { hidden ); } - watcher.setStyle(model.attributes.style || 'normal'); - if (watcher.style === 'slider') { - watcher.setSliderMin(model.attributes.min || '1'); - watcher.setSliderMax(model.attributes.max || '100'); - } - watcher.setPosition( - project.stage.topLeft().add(new Point( - +model.attributes.x || 0, - +model.attributes.y || 0 - )) - ); - project.stage.add(watcher); - watcher.onNextStep = function () {this.currentValue = null; }; - - // set watcher's contentsMorph's extent if it is showing a list and - // its monitor dimensions are given - if (watcher.currentValue instanceof List) { - extX = model.attributes.extX; - if (extX) { - watcher.cellMorph.contentsMorph.setWidth(+extX); + if (watcher) { + watcher.setStyle(model.attributes.style || 'normal'); + if (watcher.style === 'slider') { + watcher.setSliderMin(model.attributes.min || '1'); + watcher.setSliderMax(model.attributes.max || '100'); } - extY = model.attributes.extY; - if (extY) { - watcher.cellMorph.contentsMorph.setHeight(+extY); + watcher.setPosition( + project.stage.topLeft().add(new Point( + +model.attributes.x || 0, + +model.attributes.y || 0 + )) + ); + project.stage.add(watcher); + watcher.onNextStep = function () {this.currentValue = null; }; + + // set watcher's contentsMorph's extent if it is showing a list + // and if its monitor dimensions are given + if (watcher.currentValue instanceof List) { + extX = model.attributes.extX; + if (extX) { + watcher.cellMorph.contentsMorph.setWidth(+extX); + } + extY = model.attributes.extY; + if (extY) { + watcher.cellMorph.contentsMorph.setHeight(+extY); + } + // adjust my contentsMorph's handle position + watcher.cellMorph.contentsMorph.handle.drawNew(); } - // adjust my contentsMorph's handle position - watcher.cellMorph.contentsMorph.handle.drawNew(); } }); this.objects = {}; |
