From 5977686aa255e59a9b56703621c15ffa0cf04267 Mon Sep 17 00:00:00 2001 From: Gubolin Date: Sat, 4 Oct 2014 13:47:06 +0200 Subject: show an error message if project cannot be loaded (fix #190) --- gui.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gui.js b/gui.js index 2456277..901a73e 100644 --- a/gui.js +++ b/gui.js @@ -284,7 +284,8 @@ IDE_Morph.prototype.openIn = function (world) { } throw new Error('unable to retrieve ' + url); } catch (err) { - return; + myself.showMessage('unable to retrieve project'); + return ''; } } -- cgit v1.3.1 From 9e5fb9a4cba980c977d4e11e5c9a4e7f9c8596db Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Sat, 25 Oct 2014 02:03:12 -0700 Subject: Set location.hash to cloud URLs on project shares This will make it much easier to get the URL for a shared project. It also removes the # from the URL when the open project is unshared." --- gui.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/gui.js b/gui.js index 04481cc..6052953 100644 --- a/gui.js +++ b/gui.js @@ -4864,6 +4864,7 @@ ProjectDialogMorph.prototype.deleteProject = function () { ProjectDialogMorph.prototype.shareProject = function () { var myself = this, + ide = this.siblings()[0], proj = this.listField.selected, entry = this.listField.active; @@ -4894,6 +4895,15 @@ ProjectDialogMorph.prototype.shareProject = function () { myself.ide.cloudError(), [proj.ProjectName] ); + // Set the Shared URL if the project is currently open + if (proj.ProjectName === ide.projectName) { + var usr = SnapCloud.username, + projectId = 'Username=' + + encodeURIComponent(usr.toLowerCase()) + + '&ProjectName=' + + encodeURIComponent(ide.projectName); + location.hash = projectId; + } }, myself.ide.cloudError() ); @@ -4904,6 +4914,7 @@ ProjectDialogMorph.prototype.shareProject = function () { ProjectDialogMorph.prototype.unshareProject = function () { var myself = this, + ide = this.siblings()[0], proj = this.listField.selected, entry = this.listField.active; @@ -4935,6 +4946,10 @@ ProjectDialogMorph.prototype.unshareProject = function () { myself.ide.cloudError(), [proj.ProjectName] ); + // Remove the shared URL if the project is open. + if (proj.ProjectName === ide.projectName) { + location.hash = ''; + } }, myself.ide.cloudError() ); -- cgit v1.3.1 From e892ea80cb627961a0f84ebe61b7610528f67090 Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Mon, 24 Nov 2014 15:23:40 -0800 Subject: Shared URLs: remove call to .siblings() Project dialog morphs reference `ide` directly instead of using a function call --- gui.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gui.js b/gui.js index f53d597..d80e61a 100644 --- a/gui.js +++ b/gui.js @@ -4865,7 +4865,7 @@ ProjectDialogMorph.prototype.deleteProject = function () { ProjectDialogMorph.prototype.shareProject = function () { var myself = this, - ide = this.siblings()[0], + ide = this.ide, proj = this.listField.selected, entry = this.listField.active; @@ -4902,7 +4902,7 @@ ProjectDialogMorph.prototype.shareProject = function () { projectId = 'Username=' + encodeURIComponent(usr.toLowerCase()) + '&ProjectName=' + - encodeURIComponent(ide.projectName); + encodeURIComponent(proj.projectName); location.hash = projectId; } }, @@ -4915,7 +4915,7 @@ ProjectDialogMorph.prototype.shareProject = function () { ProjectDialogMorph.prototype.unshareProject = function () { var myself = this, - ide = this.siblings()[0], + ide = this.ide, proj = this.listField.selected, entry = this.listField.active; -- cgit v1.3.1 From c67a13b7bda166591a1b9f572e5113b31aa20f21 Mon Sep 17 00:00:00 2001 From: Brian Broll Date: Tue, 19 May 2015 15:48:17 -0500 Subject: Fixed typo in Process constructor Changed Process.prototype.contructor to Process.prototype.constructor --- threads.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/threads.js b/threads.js index 165ad0e..df67b2c 100644 --- a/threads.js +++ b/threads.js @@ -339,7 +339,7 @@ ThreadManager.prototype.findProcess = function (block) { */ Process.prototype = {}; -Process.prototype.contructor = Process; +Process.prototype.constructor = Process; Process.prototype.timeout = 500; // msecs after which to force yield Process.prototype.isCatchingErrors = true; -- cgit v1.3.1 From 2cbba6c762fc664bd4d4d0733c89192982d135d2 Mon Sep 17 00:00:00 2001 From: Brian Broll Date: Sat, 23 May 2015 17:09:45 -0500 Subject: Fixed #809 --- gui.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gui.js b/gui.js index 026a12c..02d6b7c 100644 --- a/gui.js +++ b/gui.js @@ -4733,8 +4733,8 @@ ProjectDialogMorph.prototype.getExamplesProjectList = function () { } } ); - projects.sort(function (x, y) { - return x.name < y.name ? -1 : 1; + projects = projects.sort(function (x, y) { + return x.name.toLowerCase() < y.name.toLowerCase() ? -1 : 1; }); return projects; }; -- cgit v1.3.1 From 1b2e0aded404f23bfe8d47edf3053ccb24011e92 Mon Sep 17 00:00:00 2001 From: Théo Segonds Date: Sun, 7 Jun 2015 16:52:48 +0200 Subject: Remove hardcoded URLs in gui.js. This fix #814 --- gui.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/gui.js b/gui.js index 026a12c..00d1cc3 100644 --- a/gui.js +++ b/gui.js @@ -82,6 +82,11 @@ var WardrobeMorph; var SoundIconMorph; var JukeboxMorph; +// Get the full url without "snap.html" +var baseUrl = document.URL.split('/'); +baseUrl.pop(baseUrl.length-1); +baseUrl = baseUrl.join('/')+'/'; + // IDE_Morph /////////////////////////////////////////////////////////// // I am SNAP's top-level frame, the Editor window @@ -2491,13 +2496,10 @@ IDE_Morph.prototype.projectMenu = function () { function () { // read a list of libraries from an external file, var libMenu = new MenuMorph(this, 'Import library'), - libUrl = 'http://snap.berkeley.edu/snapsource/libraries/' + - 'LIBRARIES'; + libUrl = baseUrl + 'libraries/' + 'LIBRARIES'; function loadLib(name) { - var url = 'http://snap.berkeley.edu/snapsource/libraries/' - + name - + '.xml'; + var url = baseUrl + 'libraries/' + name + '.xml'; myself.droppedText(myself.getURL(url), name); } @@ -4216,8 +4218,7 @@ IDE_Morph.prototype.getURLsbeOrRelative = function (url) { var request = new XMLHttpRequest(), myself = this; try { - request.open('GET', 'http://snap.berkeley.edu/snapsource/' + - url, false); + request.open('GET', baseUrl + url, false); request.send(); if (request.status === 200) { return request.responseText; @@ -4658,8 +4659,7 @@ ProjectDialogMorph.prototype.setSource = function (source) { myself.nameField.setContents(item.name || ''); } src = myself.ide.getURL( - 'http://snap.berkeley.edu/snapsource/Examples/' + - item.name + '.xml' + baseUrl + 'Examples/' + item.name + '.xml' ); xml = myself.ide.serializer.parse(src); @@ -4713,8 +4713,9 @@ ProjectDialogMorph.prototype.getLocalProjectList = function () { ProjectDialogMorph.prototype.getExamplesProjectList = function () { var dir, projects = []; + //alert(baseUrl); - dir = this.ide.getURL('http://snap.berkeley.edu/snapsource/Examples/'); + dir = this.ide.getURL(baseUrl + 'Examples/'); dir.split('\n').forEach( function (line) { var startIdx = line.search(new RegExp('href=".*xml"')), @@ -4833,9 +4834,7 @@ ProjectDialogMorph.prototype.openProject = function () { if (this.source === 'cloud') { this.openCloudProject(proj); } else if (this.source === 'examples') { - src = this.ide.getURL( - 'http://snap.berkeley.edu/snapsource/Examples/' + - proj.name + '.xml' + src = this.ide.getURL(baseUrl + 'Examples/' + proj.name + '.xml' ); this.ide.openProjectString(src); this.destroy(); -- cgit v1.3.1 From 14a5f87402fde84d332e5e9b6e44c3f3b9cf1421 Mon Sep 17 00:00:00 2001 From: Théo Segonds Date: Sun, 7 Jun 2015 17:05:49 +0200 Subject: add a index.html file to redirect automaticly to snap.html --- index.html | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 index.html diff --git a/index.html b/index.html new file mode 100644 index 0000000..4c1a0f4 --- /dev/null +++ b/index.html @@ -0,0 +1,7 @@ + + + + + + + -- cgit v1.3.1 From 26108539f5639061a66862ed066c8df8342a097c Mon Sep 17 00:00:00 2001 From: Bernat Romagosa Date: Tue, 9 Jun 2015 12:40:55 +0200 Subject: fixes #815 --- objects.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/objects.js b/objects.js index 8cae1c7..59341a8 100644 --- a/objects.js +++ b/objects.js @@ -3509,7 +3509,10 @@ SpriteMorph.prototype.allHatBlocksFor = function (message) { if (morph.selector) { if (morph.selector === 'receiveMessage') { event = morph.inputs()[0].evaluate(); - return event === message || (event instanceof Array); + return event === message + || (event instanceof Array + && message !== '__shout__go__' + && message !== '__clone__init__'); } if (morph.selector === 'receiveGo') { return message === '__shout__go__'; -- cgit v1.3.1 From e21a872b0dcbca2e7ea8311d9b54f709876d1848 Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Mon, 15 Jun 2015 17:19:25 -0700 Subject: Implement log10 and 10^x math functions --- blocks.js | 6 +++--- threads.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/blocks.js b/blocks.js index 67324ca..1ef322c 100644 --- a/blocks.js +++ b/blocks.js @@ -1111,9 +1111,9 @@ SyntaxElementMorph.prototype.labelPart = function (spec) { acos : ['acos'], atan : ['atan'], ln : ['ln'], - // log : 'log', - 'e^' : ['e^'] - // '10^' : '10^' + log : ['log'], + 'e^' : ['e^'], + '10^' : ['10^'] }, true ); diff --git a/threads.js b/threads.js index 165ad0e..61b5722 100644 --- a/threads.js +++ b/threads.js @@ -2122,14 +2122,14 @@ Process.prototype.reportMonadic = function (fname, n) { case 'ln': result = Math.log(x); break; - case 'log': - result = 0; + case 'log': // base 10 + result = Math.log(x) / Math.LN10; break; case 'e^': result = Math.exp(x); break; case '10^': - result = 0; + result = Math.pow(10, x); break; default: nop(); -- cgit v1.3.1 From 93d67ed386bba4862ac00eb55dcf664300ce53c7 Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Mon, 15 Jun 2015 18:49:24 -0700 Subject: Fix Error Handing in the DATE block For some reason the function wasnt properly catching errors and was instead rasing native JS errors. This fixes that bug, so the function will now report nothing when it doesnt know what to do. In addition, moving the variable `dateMap` inside the function reduces a global variable, which shouldnt affect anything other than keeping the code clean. :) --- threads.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/threads.js b/threads.js index 165ad0e..efe9ba4 100644 --- a/threads.js +++ b/threads.js @@ -2640,26 +2640,26 @@ Process.prototype.reportTimer = function () { }; // Process Dates and times in Snap -// Map block options to built-in functions -var dateMap = { - 'year' : 'getFullYear', - 'month' : 'getMonth', - 'date': 'getDate', - 'day of week' : 'getDay', - 'hour' : 'getHours', - 'minute' : 'getMinutes', - 'second' : 'getSeconds', - 'time in milliseconds' : 'getTime' -}; - Process.prototype.reportDate = function (datefn) { var inputFn = this.inputOption(datefn), - currDate = new Date(), - func = dateMap[inputFn], - result = currDate[func](); + // Map block options to built-in functions + dateMap = { + 'year' : 'getFullYear', + 'month' : 'getMonth', + 'date': 'getDate', + 'day of week' : 'getDay', + 'hour' : 'getHours', + 'minute' : 'getMinutes', + 'second' : 'getSeconds', + 'time in milliseconds' : 'getTime' + }; if (!dateMap[inputFn]) { return ''; } + var currDate = new Date(), + func = dateMap[inputFn], + result = currDate[func](); + // Show months as 1-12 and days as 1-7 if (inputFn === 'month' || inputFn === 'day of week') { result += 1; -- cgit v1.3.1 From 87c2503571bd7f5e753bc16a05bd198fc58d7d7c Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Wed, 17 Jun 2015 17:11:40 -0400 Subject: Use Object.create(…) instead of new …() for inheritance (faster) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blocks.js | 50 +++++++++++++++++++++++++------------------------- byob.js | 26 +++++++++++++------------- gui.js | 16 ++++++++-------- lists.js | 2 +- morphic.js | 58 +++++++++++++++++++++++++++++----------------------------- objects.js | 22 +++++++++++----------- paint.js | 6 +++--- store.js | 2 +- widgets.js | 16 ++++++++-------- xml.js | 2 +- 10 files changed, 100 insertions(+), 100 deletions(-) diff --git a/blocks.js b/blocks.js index 67324ca..3613dae 100644 --- a/blocks.js +++ b/blocks.js @@ -240,7 +240,7 @@ WorldMorph.prototype.customMorphs = function () { // SyntaxElementMorph inherits from Morph: -SyntaxElementMorph.prototype = new Morph(); +SyntaxElementMorph.prototype = Object.create(Morph.prototype); SyntaxElementMorph.prototype.constructor = SyntaxElementMorph; SyntaxElementMorph.uber = Morph.prototype; @@ -1937,7 +1937,7 @@ SyntaxElementMorph.prototype.endLayout = function () { // BlockMorph inherits from SyntaxElementMorph: -BlockMorph.prototype = new SyntaxElementMorph(); +BlockMorph.prototype = Object.create(SyntaxElementMorph.prototype); BlockMorph.prototype.constructor = BlockMorph; BlockMorph.uber = SyntaxElementMorph.prototype; @@ -3262,7 +3262,7 @@ BlockMorph.prototype.snap = function () { // CommandBlockMorph inherits from BlockMorph: -CommandBlockMorph.prototype = new BlockMorph(); +CommandBlockMorph.prototype = Object.create(BlockMorph.prototype); CommandBlockMorph.prototype.constructor = CommandBlockMorph; CommandBlockMorph.uber = BlockMorph.prototype; @@ -3942,7 +3942,7 @@ CommandBlockMorph.prototype.drawBottomRightEdge = function (context) { // HatBlockMorph inherits from CommandBlockMorph: -HatBlockMorph.prototype = new CommandBlockMorph(); +HatBlockMorph.prototype = Object.create(CommandBlockMorph.prototype); HatBlockMorph.prototype.constructor = HatBlockMorph; HatBlockMorph.uber = CommandBlockMorph.prototype; @@ -4120,7 +4120,7 @@ HatBlockMorph.prototype.drawTopLeftEdge = function (context) { // ReporterBlockMorph inherits from BlockMorph: -ReporterBlockMorph.prototype = new BlockMorph(); +ReporterBlockMorph.prototype = Object.create(BlockMorph.prototype); ReporterBlockMorph.prototype.constructor = ReporterBlockMorph; ReporterBlockMorph.uber = BlockMorph.prototype; @@ -4644,7 +4644,7 @@ ReporterBlockMorph.prototype.drawDiamond = function (context) { // RingMorph inherits from ReporterBlockMorph: -RingMorph.prototype = new ReporterBlockMorph(); +RingMorph.prototype = Object.create(ReporterBlockMorph.prototype); RingMorph.prototype.constructor = RingMorph; RingMorph.uber = ReporterBlockMorph.prototype; @@ -4781,7 +4781,7 @@ RingMorph.prototype.fixBlockColor = function (nearest, isForced) { // ScriptsMorph inherits from FrameMorph: -ScriptsMorph.prototype = new FrameMorph(); +ScriptsMorph.prototype = Object.create(FrameMorph.prototype); ScriptsMorph.prototype.constructor = ScriptsMorph; ScriptsMorph.uber = FrameMorph.prototype; @@ -5321,7 +5321,7 @@ ScriptsMorph.prototype.reactToDropOf = function (droppedMorph, hand) { // ArgMorph inherits from SyntaxElementMorph: -ArgMorph.prototype = new SyntaxElementMorph(); +ArgMorph.prototype = Object.create(SyntaxElementMorph.prototype); ArgMorph.prototype.constructor = ArgMorph; ArgMorph.uber = SyntaxElementMorph.prototype; @@ -5434,7 +5434,7 @@ ArgMorph.prototype.isEmptySlot = function () { // CommandSlotMorph inherits from ArgMorph: -CommandSlotMorph.prototype = new ArgMorph(); +CommandSlotMorph.prototype = Object.create(ArgMorph.prototype); CommandSlotMorph.prototype.constructor = CommandSlotMorph; CommandSlotMorph.uber = ArgMorph.prototype; @@ -5884,7 +5884,7 @@ CommandSlotMorph.prototype.drawEdges = function (context) { // RingCommandSlotMorph inherits from CommandSlotMorph: -RingCommandSlotMorph.prototype = new CommandSlotMorph(); +RingCommandSlotMorph.prototype = Object.create(CommandSlotMorph.prototype); RingCommandSlotMorph.prototype.constructor = RingCommandSlotMorph; RingCommandSlotMorph.uber = CommandSlotMorph.prototype; @@ -6040,7 +6040,7 @@ RingCommandSlotMorph.prototype.drawFlat = function (context) { // CSlotMorph inherits from CommandSlotMorph: -CSlotMorph.prototype = new CommandSlotMorph(); +CSlotMorph.prototype = Object.create(CommandSlotMorph.prototype); CSlotMorph.prototype.constructor = CSlotMorph; CSlotMorph.uber = CommandSlotMorph.prototype; @@ -6463,7 +6463,7 @@ CSlotMorph.prototype.drawBottomEdge = function (context) { // InputSlotMorph inherits from ArgMorph: -InputSlotMorph.prototype = new ArgMorph(); +InputSlotMorph.prototype = Object.create(ArgMorph.prototype); InputSlotMorph.prototype.constructor = InputSlotMorph; InputSlotMorph.uber = ArgMorph.prototype; @@ -7399,7 +7399,7 @@ InputSlotMorph.prototype.drawRoundBorder = function (context) { // TemplateSlotMorph inherits from ArgMorph: -TemplateSlotMorph.prototype = new ArgMorph(); +TemplateSlotMorph.prototype = Object.create(ArgMorph.prototype); TemplateSlotMorph.prototype.constructor = TemplateSlotMorph; TemplateSlotMorph.uber = ArgMorph.prototype; @@ -7503,7 +7503,7 @@ TemplateSlotMorph.prototype.drawRounded = ReporterBlockMorph // BooleanSlotMorph inherits from ArgMorph: -BooleanSlotMorph.prototype = new ArgMorph(); +BooleanSlotMorph.prototype = Object.create(ArgMorph.prototype); BooleanSlotMorph.prototype.constructor = BooleanSlotMorph; BooleanSlotMorph.uber = ArgMorph.prototype; @@ -7660,7 +7660,7 @@ BooleanSlotMorph.prototype.isEmptySlot = function () { // ArrowMorph inherits from Morph: -ArrowMorph.prototype = new Morph(); +ArrowMorph.prototype = Object.create(Morph.prototype); ArrowMorph.prototype.constructor = ArrowMorph; ArrowMorph.uber = Morph.prototype; @@ -7730,7 +7730,7 @@ ArrowMorph.prototype.drawNew = function () { // TextSlotMorph inherits from InputSlotMorph: -TextSlotMorph.prototype = new InputSlotMorph(); +TextSlotMorph.prototype = Object.create(InputSlotMorph.prototype); TextSlotMorph.prototype.constructor = TextSlotMorph; TextSlotMorph.uber = InputSlotMorph.prototype; @@ -7813,7 +7813,7 @@ TextSlotMorph.prototype.layoutChanged = function () { // SymbolMorph inherits from Morph: -SymbolMorph.prototype = new Morph(); +SymbolMorph.prototype = Object.create(Morph.prototype); SymbolMorph.prototype.constructor = SymbolMorph; SymbolMorph.uber = Morph.prototype; @@ -9106,7 +9106,7 @@ SymbolMorph.prototype.drawSymbolRobot = function (canvas, color) { // ColorSlotMorph inherits from ArgMorph: -ColorSlotMorph.prototype = new ArgMorph(); +ColorSlotMorph.prototype = Object.create(ArgMorph.prototype); ColorSlotMorph.prototype.constructor = ColorSlotMorph; ColorSlotMorph.uber = ArgMorph.prototype; @@ -9214,7 +9214,7 @@ ColorSlotMorph.prototype.drawRectBorder = // BlockHighlightMorph inherits from Morph: -BlockHighlightMorph.prototype = new Morph(); +BlockHighlightMorph.prototype = Object.create(Morph.prototype); BlockHighlightMorph.prototype.constructor = BlockHighlightMorph; BlockHighlightMorph.uber = Morph.prototype; @@ -9239,7 +9239,7 @@ function BlockHighlightMorph() { // MultiArgMorph inherits from ArgMorph: -MultiArgMorph.prototype = new ArgMorph(); +MultiArgMorph.prototype = Object.create(ArgMorph.prototype); MultiArgMorph.prototype.constructor = MultiArgMorph; MultiArgMorph.uber = ArgMorph.prototype; @@ -9669,7 +9669,7 @@ MultiArgMorph.prototype.isEmptySlot = function () { // ArgLabelMorph inherits from ArgMorph: -ArgLabelMorph.prototype = new ArgMorph(); +ArgLabelMorph.prototype = Object.create(ArgMorph.prototype); ArgLabelMorph.prototype.constructor = ArgLabelMorph; ArgLabelMorph.uber = ArgMorph.prototype; @@ -9799,7 +9799,7 @@ ArgLabelMorph.prototype.isEmptySlot = function () { // FunctionSlotMorph inherits from ArgMorph: -FunctionSlotMorph.prototype = new ArgMorph(); +FunctionSlotMorph.prototype = Object.create(ArgMorph.prototype); FunctionSlotMorph.prototype.constructor = FunctionSlotMorph; FunctionSlotMorph.uber = ArgMorph.prototype; @@ -10180,7 +10180,7 @@ FunctionSlotMorph.prototype.drawDiamond = function (context) { // ReporterSlotMorph inherits from FunctionSlotMorph: -ReporterSlotMorph.prototype = new FunctionSlotMorph(); +ReporterSlotMorph.prototype = Object.create(FunctionSlotMorph.prototype); ReporterSlotMorph.prototype.constructor = ReporterSlotMorph; ReporterSlotMorph.uber = FunctionSlotMorph.prototype; @@ -10263,7 +10263,7 @@ ReporterSlotMorph.prototype.fixLayout = function () { // ReporterSlotMorph inherits from FunctionSlotMorph: -RingReporterSlotMorph.prototype = new ReporterSlotMorph(); +RingReporterSlotMorph.prototype = Object.create(ReporterSlotMorph.prototype); RingReporterSlotMorph.prototype.constructor = RingReporterSlotMorph; RingReporterSlotMorph.uber = ReporterSlotMorph.prototype; @@ -10651,7 +10651,7 @@ RingReporterSlotMorph.prototype.drawDiamond = function (context) { // CommentMorph inherits from BoxMorph: -CommentMorph.prototype = new BoxMorph(); +CommentMorph.prototype = Object.create(BoxMorph.prototype); CommentMorph.prototype.constructor = CommentMorph; CommentMorph.uber = BoxMorph.prototype; diff --git a/byob.js b/byob.js index 1c2cfee..32d8969 100644 --- a/byob.js +++ b/byob.js @@ -379,7 +379,7 @@ CustomBlockDefinition.prototype.scriptsPicture = function () { // CustomCommandBlockMorph inherits from CommandBlockMorph: -CustomCommandBlockMorph.prototype = new CommandBlockMorph(); +CustomCommandBlockMorph.prototype = Object.create(CommandBlockMorph.prototype); CustomCommandBlockMorph.prototype.constructor = CustomCommandBlockMorph; CustomCommandBlockMorph.uber = CommandBlockMorph.prototype; @@ -896,7 +896,7 @@ CustomCommandBlockMorph.prototype.alternatives = function () { // CustomReporterBlockMorph inherits from ReporterBlockMorph: -CustomReporterBlockMorph.prototype = new ReporterBlockMorph(); +CustomReporterBlockMorph.prototype = Object.create(ReporterBlockMorph.prototype); CustomReporterBlockMorph.prototype.constructor = CustomReporterBlockMorph; CustomReporterBlockMorph.uber = ReporterBlockMorph.prototype; @@ -1028,7 +1028,7 @@ CustomReporterBlockMorph.prototype.alternatives // JaggedBlockMorph inherits from ReporterBlockMorph: -JaggedBlockMorph.prototype = new ReporterBlockMorph(); +JaggedBlockMorph.prototype = Object.create(ReporterBlockMorph.prototype); JaggedBlockMorph.prototype.constructor = JaggedBlockMorph; JaggedBlockMorph.uber = ReporterBlockMorph.prototype; @@ -1177,7 +1177,7 @@ JaggedBlockMorph.prototype.drawEdges = function (context) { // BlockDialogMorph inherits from DialogBoxMorph: -BlockDialogMorph.prototype = new DialogBoxMorph(); +BlockDialogMorph.prototype = Object.create(DialogBoxMorph.prototype); BlockDialogMorph.prototype.constructor = BlockDialogMorph; BlockDialogMorph.uber = DialogBoxMorph.prototype; @@ -1624,7 +1624,7 @@ BlockDialogMorph.prototype.fixLayout = function () { // BlockEditorMorph inherits from DialogBoxMorph: -BlockEditorMorph.prototype = new DialogBoxMorph(); +BlockEditorMorph.prototype = Object.create(DialogBoxMorph.prototype); BlockEditorMorph.prototype.constructor = BlockEditorMorph; BlockEditorMorph.uber = DialogBoxMorph.prototype; @@ -1936,7 +1936,7 @@ BlockEditorMorph.prototype.fixLayout = function () { // PrototypeHatBlockMorph inherits from HatBlockMorph: -PrototypeHatBlockMorph.prototype = new HatBlockMorph(); +PrototypeHatBlockMorph.prototype = Object.create(HatBlockMorph.prototype); PrototypeHatBlockMorph.prototype.constructor = PrototypeHatBlockMorph; PrototypeHatBlockMorph.uber = HatBlockMorph.prototype; @@ -2146,7 +2146,7 @@ BlockLabelFragment.prototype.setSingleInputType = function (type) { // BlockLabelFragmentMorph inherits from StringMorph: -BlockLabelFragmentMorph.prototype = new StringMorph(); +BlockLabelFragmentMorph.prototype = Object.create(StringMorph.prototype); BlockLabelFragmentMorph.prototype.constructor = BlockLabelFragmentMorph; BlockLabelFragmentMorph.uber = StringMorph.prototype; @@ -2268,7 +2268,7 @@ BlockLabelFragmentMorph.prototype.userMenu = function () { // BlockLabelPlaceHolderMorph inherits from StringMorph: -BlockLabelPlaceHolderMorph.prototype = new StringMorph(); +BlockLabelPlaceHolderMorph.prototype = Object.create(StringMorph.prototype); BlockLabelPlaceHolderMorph.prototype.constructor = BlockLabelPlaceHolderMorph; BlockLabelPlaceHolderMorph.uber = StringMorph.prototype; @@ -2396,7 +2396,7 @@ BlockLabelPlaceHolderMorph.prototype.updateBlockLabel // BlockInputFragmentMorph inherits from TemplateSlotMorph: -BlockInputFragmentMorph.prototype = new TemplateSlotMorph(); +BlockInputFragmentMorph.prototype = Object.create(TemplateSlotMorph.prototype); BlockInputFragmentMorph.prototype.constructor = BlockInputFragmentMorph; BlockInputFragmentMorph.uber = TemplateSlotMorph.prototype; @@ -2426,7 +2426,7 @@ BlockInputFragmentMorph.prototype.updateBlockLabel // InputSlotDialogMorph inherits from DialogBoxMorph: -InputSlotDialogMorph.prototype = new DialogBoxMorph(); +InputSlotDialogMorph.prototype = Object.create(DialogBoxMorph.prototype); InputSlotDialogMorph.prototype.constructor = InputSlotDialogMorph; InputSlotDialogMorph.uber = DialogBoxMorph.prototype; @@ -3026,7 +3026,7 @@ InputSlotDialogMorph.prototype.show = function () { // VariableDialogMorph inherits from DialogBoxMorph: -VariableDialogMorph.prototype = new DialogBoxMorph(); +VariableDialogMorph.prototype = Object.create(DialogBoxMorph.prototype); VariableDialogMorph.prototype.constructor = VariableDialogMorph; VariableDialogMorph.uber = DialogBoxMorph.prototype; @@ -3145,7 +3145,7 @@ VariableDialogMorph.prototype.fixLayout = function () { // BlockExportDialogMorph inherits from DialogBoxMorph: -BlockExportDialogMorph.prototype = new DialogBoxMorph(); +BlockExportDialogMorph.prototype = Object.create(DialogBoxMorph.prototype); BlockExportDialogMorph.prototype.constructor = BlockExportDialogMorph; BlockExportDialogMorph.uber = DialogBoxMorph.prototype; @@ -3327,7 +3327,7 @@ BlockExportDialogMorph.prototype.fixLayout // BlockImportDialogMorph inherits from DialogBoxMorph // and pseudo-inherits from BlockExportDialogMorph: -BlockImportDialogMorph.prototype = new DialogBoxMorph(); +BlockImportDialogMorph.prototype = Object.create(DialogBoxMorph.prototype); BlockImportDialogMorph.prototype.constructor = BlockImportDialogMorph; BlockImportDialogMorph.uber = DialogBoxMorph.prototype; diff --git a/gui.js b/gui.js index 026a12c..89e2d89 100644 --- a/gui.js +++ b/gui.js @@ -88,7 +88,7 @@ var JukeboxMorph; // IDE_Morph inherits from Morph: -IDE_Morph.prototype = new Morph(); +IDE_Morph.prototype = Object.create(Morph.prototype); IDE_Morph.prototype.constructor = IDE_Morph; IDE_Morph.uber = Morph.prototype; @@ -4274,7 +4274,7 @@ IDE_Morph.prototype.prompt = function (message, callback, choices, key) { // ProjectDialogMorph inherits from DialogBoxMorph: -ProjectDialogMorph.prototype = new DialogBoxMorph(); +ProjectDialogMorph.prototype = Object.create(DialogBoxMorph.prototype); ProjectDialogMorph.prototype.constructor = ProjectDialogMorph; ProjectDialogMorph.uber = DialogBoxMorph.prototype; @@ -5181,7 +5181,7 @@ ProjectDialogMorph.prototype.fixLayout = function () { // SpriteIconMorph inherits from ToggleButtonMorph (Widgets) -SpriteIconMorph.prototype = new ToggleButtonMorph(); +SpriteIconMorph.prototype = Object.create(ToggleButtonMorph.prototype); SpriteIconMorph.prototype.constructor = SpriteIconMorph; SpriteIconMorph.uber = ToggleButtonMorph.prototype; @@ -5571,7 +5571,7 @@ SpriteIconMorph.prototype.copySound = function (sound) { // CostumeIconMorph inherits from ToggleButtonMorph (Widgets) // ... and copies methods from SpriteIconMorph -CostumeIconMorph.prototype = new ToggleButtonMorph(); +CostumeIconMorph.prototype = Object.create(ToggleButtonMorph.prototype); CostumeIconMorph.prototype.constructor = CostumeIconMorph; CostumeIconMorph.uber = ToggleButtonMorph.prototype; @@ -5782,7 +5782,7 @@ CostumeIconMorph.prototype.prepareToBeGrabbed = function () { // TurtleIconMorph inherits from ToggleButtonMorph (Widgets) // ... and copies methods from SpriteIconMorph -TurtleIconMorph.prototype = new ToggleButtonMorph(); +TurtleIconMorph.prototype = Object.create(ToggleButtonMorph.prototype); TurtleIconMorph.prototype.constructor = TurtleIconMorph; TurtleIconMorph.uber = ToggleButtonMorph.prototype; @@ -5965,7 +5965,7 @@ TurtleIconMorph.prototype.userMenu = function () { // WardrobeMorph inherits from ScrollFrameMorph -WardrobeMorph.prototype = new ScrollFrameMorph(); +WardrobeMorph.prototype = Object.create(ScrollFrameMorph.prototype); WardrobeMorph.prototype.constructor = WardrobeMorph; WardrobeMorph.uber = ScrollFrameMorph.prototype; @@ -6148,7 +6148,7 @@ WardrobeMorph.prototype.reactToDropOf = function (icon) { // SoundIconMorph inherits from ToggleButtonMorph (Widgets) // ... and copies methods from SpriteIconMorph -SoundIconMorph.prototype = new ToggleButtonMorph(); +SoundIconMorph.prototype = Object.create(ToggleButtonMorph.prototype); SoundIconMorph.prototype.constructor = SoundIconMorph; SoundIconMorph.uber = ToggleButtonMorph.prototype; @@ -6356,7 +6356,7 @@ SoundIconMorph.prototype.prepareToBeGrabbed = function () { // JukeboxMorph instance creation -JukeboxMorph.prototype = new ScrollFrameMorph(); +JukeboxMorph.prototype = Object.create(ScrollFrameMorph.prototype); JukeboxMorph.prototype.constructor = JukeboxMorph; JukeboxMorph.uber = ScrollFrameMorph.prototype; diff --git a/lists.js b/lists.js index bd856fe..be7f933 100644 --- a/lists.js +++ b/lists.js @@ -363,7 +363,7 @@ List.prototype.equalTo = function (other) { // ListWatcherMorph inherits from BoxMorph: -ListWatcherMorph.prototype = new BoxMorph(); +ListWatcherMorph.prototype = Object.create(BoxMorph.prototype); ListWatcherMorph.prototype.constructor = ListWatcherMorph; ListWatcherMorph.uber = BoxMorph.prototype; diff --git a/morphic.js b/morphic.js index 2850e32..029afd1 100644 --- a/morphic.js +++ b/morphic.js @@ -528,7 +528,7 @@ whose "isTemplate" flag is false, in other words: a non-template. When creating a copy from a template, the copy's - + reactToTemplateCopy is invoked, if it is present. @@ -2171,7 +2171,7 @@ var TextMorph; // Morph inherits from Node: -Morph.prototype = new Node(); +Morph.prototype = Object.create(Node.prototype); Morph.prototype.constructor = Morph; Morph.uber = Node.prototype; @@ -3696,7 +3696,7 @@ Morph.prototype.overlappingImage = function (otherMorph) { // ShadowMorph inherits from Morph: -ShadowMorph.prototype = new Morph(); +ShadowMorph.prototype = Object.create(Morph.prototype); ShadowMorph.prototype.constructor = ShadowMorph; ShadowMorph.uber = Morph.prototype; @@ -3712,7 +3712,7 @@ function ShadowMorph() { // HandleMorph inherits from Morph: -HandleMorph.prototype = new Morph(); +HandleMorph.prototype = Object.create(Morph.prototype); HandleMorph.prototype.constructor = HandleMorph; HandleMorph.uber = Morph.prototype; @@ -3967,7 +3967,7 @@ var PenMorph; // PenMorph inherits from Morph: -PenMorph.prototype = new Morph(); +PenMorph.prototype = Object.create(Morph.prototype); PenMorph.prototype.constructor = PenMorph; PenMorph.uber = Morph.prototype; @@ -4199,7 +4199,7 @@ var ColorPaletteMorph; // ColorPaletteMorph inherits from Morph: -ColorPaletteMorph.prototype = new Morph(); +ColorPaletteMorph.prototype = Object.create(Morph.prototype); ColorPaletteMorph.prototype.constructor = ColorPaletteMorph; ColorPaletteMorph.uber = Morph.prototype; @@ -4331,7 +4331,7 @@ var GrayPaletteMorph; // GrayPaletteMorph inherits from ColorPaletteMorph: -GrayPaletteMorph.prototype = new ColorPaletteMorph(); +GrayPaletteMorph.prototype = Object.create(ColorPaletteMorph.prototype); GrayPaletteMorph.prototype.constructor = GrayPaletteMorph; GrayPaletteMorph.uber = ColorPaletteMorph.prototype; @@ -4362,7 +4362,7 @@ GrayPaletteMorph.prototype.drawNew = function () { // ColorPickerMorph inherits from Morph: -ColorPickerMorph.prototype = new Morph(); +ColorPickerMorph.prototype = Object.create(Morph.prototype); ColorPickerMorph.prototype.constructor = ColorPickerMorph; ColorPickerMorph.uber = Morph.prototype; @@ -4431,7 +4431,7 @@ var BlinkerMorph; // BlinkerMorph inherits from Morph: -BlinkerMorph.prototype = new Morph(); +BlinkerMorph.prototype = Object.create(Morph.prototype); BlinkerMorph.prototype.constructor = BlinkerMorph; BlinkerMorph.uber = Morph.prototype; @@ -4464,7 +4464,7 @@ var CursorMorph; // CursorMorph inherits from BlinkerMorph: -CursorMorph.prototype = new BlinkerMorph(); +CursorMorph.prototype = Object.create(BlinkerMorph.prototype); CursorMorph.prototype.constructor = CursorMorph; CursorMorph.uber = BlinkerMorph.prototype; @@ -4884,7 +4884,7 @@ var BoxMorph; // BoxMorph inherits from Morph: -BoxMorph.prototype = new Morph(); +BoxMorph.prototype = Object.create(Morph.prototype); BoxMorph.prototype.constructor = BoxMorph; BoxMorph.uber = Morph.prototype; @@ -5092,7 +5092,7 @@ var SpeechBubbleMorph; // SpeechBubbleMorph inherits from BoxMorph: -SpeechBubbleMorph.prototype = new BoxMorph(); +SpeechBubbleMorph.prototype = Object.create(BoxMorph.prototype); SpeechBubbleMorph.prototype.constructor = SpeechBubbleMorph; SpeechBubbleMorph.uber = BoxMorph.prototype; @@ -5392,7 +5392,7 @@ var CircleBoxMorph; // CircleBoxMorph inherits from Morph: -CircleBoxMorph.prototype = new Morph(); +CircleBoxMorph.prototype = Object.create(Morph.prototype); CircleBoxMorph.prototype.constructor = CircleBoxMorph; CircleBoxMorph.uber = Morph.prototype; @@ -5512,7 +5512,7 @@ var SliderButtonMorph; // SliderButtonMorph inherits from CircleBoxMorph: -SliderButtonMorph.prototype = new CircleBoxMorph(); +SliderButtonMorph.prototype = Object.create(CircleBoxMorph.prototype); SliderButtonMorph.prototype.constructor = SliderButtonMorph; SliderButtonMorph.uber = CircleBoxMorph.prototype; @@ -5724,7 +5724,7 @@ SliderButtonMorph.prototype.mouseMove = function () { // SliderMorph inherits from CircleBoxMorph: -SliderMorph.prototype = new CircleBoxMorph(); +SliderMorph.prototype = Object.create(CircleBoxMorph.prototype); SliderMorph.prototype.constructor = SliderMorph; SliderMorph.uber = CircleBoxMorph.prototype; @@ -6092,7 +6092,7 @@ var MouseSensorMorph; // MouseSensorMorph inherits from BoxMorph: -MouseSensorMorph.prototype = new BoxMorph(); +MouseSensorMorph.prototype = Object.create(BoxMorph.prototype); MouseSensorMorph.prototype.constructor = MouseSensorMorph; MouseSensorMorph.uber = BoxMorph.prototype; @@ -6166,7 +6166,7 @@ var TriggerMorph; // InspectorMorph inherits from BoxMorph: -InspectorMorph.prototype = new BoxMorph(); +InspectorMorph.prototype = Object.create(BoxMorph.prototype); InspectorMorph.prototype.constructor = InspectorMorph; InspectorMorph.uber = BoxMorph.prototype; @@ -6661,7 +6661,7 @@ var MenuItemMorph; // MenuMorph inherits from BoxMorph: -MenuMorph.prototype = new BoxMorph(); +MenuMorph.prototype = Object.create(BoxMorph.prototype); MenuMorph.prototype.constructor = MenuMorph; MenuMorph.uber = BoxMorph.prototype; @@ -6956,7 +6956,7 @@ MenuMorph.prototype.popUpCenteredInWorld = function (world) { // StringMorph inherits from Morph: -StringMorph.prototype = new Morph(); +StringMorph.prototype = Object.create(Morph.prototype); StringMorph.prototype.constructor = StringMorph; StringMorph.uber = Morph.prototype; @@ -7491,7 +7491,7 @@ StringMorph.prototype.disableSelecting = function () { // TextMorph inherits from Morph: -TextMorph.prototype = new Morph(); +TextMorph.prototype = Object.create(Morph.prototype); TextMorph.prototype.constructor = TextMorph; TextMorph.uber = Morph.prototype; @@ -8016,7 +8016,7 @@ TextMorph.prototype.inspectIt = function () { // TriggerMorph inherits from Morph: -TriggerMorph.prototype = new Morph(); +TriggerMorph.prototype = Object.create(Morph.prototype); TriggerMorph.prototype.constructor = TriggerMorph; TriggerMorph.uber = Morph.prototype; @@ -8285,7 +8285,7 @@ var MenuItemMorph; // MenuItemMorph inherits from TriggerMorph: -MenuItemMorph.prototype = new TriggerMorph(); +MenuItemMorph.prototype = Object.create(TriggerMorph.prototype); MenuItemMorph.prototype.constructor = MenuItemMorph; MenuItemMorph.uber = TriggerMorph.prototype; @@ -8444,7 +8444,7 @@ MenuItemMorph.prototype.isSelectedListItem = function () { // Frames inherit from Morph: -FrameMorph.prototype = new Morph(); +FrameMorph.prototype = Object.create(Morph.prototype); FrameMorph.prototype.constructor = FrameMorph; FrameMorph.uber = Morph.prototype; @@ -8638,7 +8638,7 @@ FrameMorph.prototype.keepAllSubmorphsWithin = function () { // ScrollFrameMorph //////////////////////////////////////////////////// -ScrollFrameMorph.prototype = new FrameMorph(); +ScrollFrameMorph.prototype = Object.create(FrameMorph.prototype); ScrollFrameMorph.prototype.constructor = ScrollFrameMorph; ScrollFrameMorph.uber = FrameMorph.prototype; @@ -9013,7 +9013,7 @@ ScrollFrameMorph.prototype.toggleTextLineWrapping = function () { // ListMorph /////////////////////////////////////////////////////////// -ListMorph.prototype = new ScrollFrameMorph(); +ListMorph.prototype = Object.create(ScrollFrameMorph.prototype); ListMorph.prototype.constructor = ListMorph; ListMorph.uber = ScrollFrameMorph.prototype; @@ -9151,7 +9151,7 @@ ListMorph.prototype.setExtent = function (aPoint) { // StringFieldMorph inherit from FrameMorph: -StringFieldMorph.prototype = new FrameMorph(); +StringFieldMorph.prototype = Object.create(FrameMorph.prototype); StringFieldMorph.prototype.constructor = StringFieldMorph; StringFieldMorph.uber = FrameMorph.prototype; @@ -9265,7 +9265,7 @@ var BouncerMorph; // Bouncers inherit from Morph: -BouncerMorph.prototype = new Morph(); +BouncerMorph.prototype = Object.create(Morph.prototype); BouncerMorph.prototype.constructor = BouncerMorph; BouncerMorph.uber = Morph.prototype; @@ -9352,7 +9352,7 @@ BouncerMorph.prototype.step = function () { // HandMorph inherits from Morph: -HandMorph.prototype = new Morph(); +HandMorph.prototype = Object.create(Morph.prototype); HandMorph.prototype.constructor = HandMorph; HandMorph.uber = Morph.prototype; @@ -9987,7 +9987,7 @@ HandMorph.prototype.moveBy = function (delta) { // WorldMorph inherits from FrameMorph: -WorldMorph.prototype = new FrameMorph(); +WorldMorph.prototype = Object.create(FrameMorph.prototype); WorldMorph.prototype.constructor = WorldMorph; WorldMorph.uber = FrameMorph.prototype; diff --git a/objects.js b/objects.js index 8cae1c7..462aed2 100644 --- a/objects.js +++ b/objects.js @@ -147,7 +147,7 @@ var SpriteHighlightMorph; // SpriteMorph inherits from PenMorph: -SpriteMorph.prototype = new PenMorph(); +SpriteMorph.prototype = Object.create(PenMorph.prototype); SpriteMorph.prototype.constructor = SpriteMorph; SpriteMorph.uber = PenMorph.prototype; @@ -583,7 +583,7 @@ SpriteMorph.prototype.initBlocks = function () { }, /* migrated to a newer block version: - + receiveClick: { type: 'hat', category: 'control', @@ -3008,7 +3008,7 @@ SpriteMorph.prototype.applyGraphicsEffects = function (canvas) { var i; if (value !== 0) { for (i = 0; i < p.length; i += 4) { - p[i] += value; //255 = 100% of this color + p[i] += value; //255 = 100% of this color p[i + 1] += value; p[i + 2] += value; } @@ -4289,7 +4289,7 @@ SpriteMorph.prototype.doScreenshot = function (imgSource, data) { // SpriteHighlightMorph inherits from Morph: -SpriteHighlightMorph.prototype = new Morph(); +SpriteHighlightMorph.prototype = Object.create(Morph.prototype); SpriteHighlightMorph.prototype.constructor = SpriteHighlightMorph; SpriteHighlightMorph.uber = Morph.prototype; @@ -4307,7 +4307,7 @@ function SpriteHighlightMorph() { // StageMorph inherits from FrameMorph: -StageMorph.prototype = new FrameMorph(); +StageMorph.prototype = Object.create(FrameMorph.prototype); StageMorph.prototype.constructor = StageMorph; StageMorph.uber = FrameMorph.prototype; @@ -5669,7 +5669,7 @@ StageMorph.prototype.replaceDoubleDefinitionsFor // SpriteBubbleMorph inherits from SpeechBubbleMorph: -SpriteBubbleMorph.prototype = new SpeechBubbleMorph(); +SpriteBubbleMorph.prototype = Object.create(SpeechBubbleMorph.prototype); SpriteBubbleMorph.prototype.constructor = SpriteBubbleMorph; SpriteBubbleMorph.uber = SpeechBubbleMorph.prototype; @@ -6168,7 +6168,7 @@ Costume.prototype.isTainted = function () { // SVG_Costume inherits from Costume: -SVG_Costume.prototype = new Costume(); +SVG_Costume.prototype = Object.create(Costume.prototype); SVG_Costume.prototype.constructor = SVG_Costume; SVG_Costume.uber = Costume.prototype; @@ -6219,7 +6219,7 @@ SVG_Costume.prototype.shrinkToFit = function (extentPoint) { // CostumeEditorMorph inherits from Morph: -CostumeEditorMorph.prototype = new Morph(); +CostumeEditorMorph.prototype = Object.create(Morph.prototype); CostumeEditorMorph.prototype.constructor = CostumeEditorMorph; CostumeEditorMorph.uber = Morph.prototype; @@ -6454,7 +6454,7 @@ Note.prototype.stop = function () { // CellMorph inherits from BoxMorph: -CellMorph.prototype = new BoxMorph(); +CellMorph.prototype = Object.create(BoxMorph.prototype); CellMorph.prototype.constructor = CellMorph; CellMorph.uber = BoxMorph.prototype; @@ -6794,7 +6794,7 @@ CellMorph.prototype.mouseClickLeft = function (pos) { // WatcherMorph inherits from BoxMorph: -WatcherMorph.prototype = new BoxMorph(); +WatcherMorph.prototype = Object.create(BoxMorph.prototype); WatcherMorph.prototype.constructor = WatcherMorph; WatcherMorph.uber = BoxMorph.prototype; @@ -7281,7 +7281,7 @@ WatcherMorph.prototype.drawNew = function () { // StagePrompterMorph inherits from BoxMorph: -StagePrompterMorph.prototype = new BoxMorph(); +StagePrompterMorph.prototype = Object.create(BoxMorph.prototype); StagePrompterMorph.prototype.constructor = StagePrompterMorph; StagePrompterMorph.uber = BoxMorph.prototype; diff --git a/paint.js b/paint.js index 65ae1f6..b4c55b1 100644 --- a/paint.js +++ b/paint.js @@ -81,7 +81,7 @@ var PaintColorPickerMorph; // A complete paint editor -PaintEditorMorph.prototype = new DialogBoxMorph(); +PaintEditorMorph.prototype = Object.create(DialogBoxMorph.prototype); PaintEditorMorph.prototype.constructor = PaintEditorMorph; PaintEditorMorph.uber = DialogBoxMorph.prototype; @@ -476,7 +476,7 @@ PaintEditorMorph.prototype.getUserColor = function () { // A large hsl color picker -PaintColorPickerMorph.prototype = new Morph(); +PaintColorPickerMorph.prototype = Object.create(Morph.prototype); PaintColorPickerMorph.prototype.constructor = PaintColorPickerMorph; PaintColorPickerMorph.uber = Morph.prototype; @@ -552,7 +552,7 @@ PaintColorPickerMorph.prototype.mouseMove = modify its image, based on a 'tool' property. */ -PaintCanvasMorph.prototype = new Morph(); +PaintCanvasMorph.prototype = Object.create(Morph.prototype); PaintCanvasMorph.prototype.constructor = PaintCanvasMorph; PaintCanvasMorph.uber = Morph.prototype; diff --git a/store.js b/store.js index 5cba3c3..6f3bc23 100644 --- a/store.js +++ b/store.js @@ -246,7 +246,7 @@ var SnapSerializer; // SnapSerializer inherits from XML_Serializer: -SnapSerializer.prototype = new XML_Serializer(); +SnapSerializer.prototype = Object.create(XML_Serializer.prototype); SnapSerializer.prototype.constructor = SnapSerializer; SnapSerializer.uber = XML_Serializer.prototype; diff --git a/widgets.js b/widgets.js index bb250a8..2f96f2c 100644 --- a/widgets.js +++ b/widgets.js @@ -91,7 +91,7 @@ var InputFieldMorph; // PushButtonMorph inherits from TriggerMorph: -PushButtonMorph.prototype = new TriggerMorph(); +PushButtonMorph.prototype = Object.create(TriggerMorph.prototype); PushButtonMorph.prototype.constructor = PushButtonMorph; PushButtonMorph.uber = TriggerMorph.prototype; @@ -476,7 +476,7 @@ PushButtonMorph.prototype.createLabel = function () { // ToggleButtonMorph inherits from PushButtonMorph: -ToggleButtonMorph.prototype = new PushButtonMorph(); +ToggleButtonMorph.prototype = Object.create(PushButtonMorph.prototype); ToggleButtonMorph.prototype.constructor = ToggleButtonMorph; ToggleButtonMorph.uber = PushButtonMorph.prototype; @@ -900,7 +900,7 @@ ToggleButtonMorph.prototype.show = function () { // TabMorph inherits from ToggleButtonMorph: -TabMorph.prototype = new ToggleButtonMorph(); +TabMorph.prototype = Object.create(ToggleButtonMorph.prototype); TabMorph.prototype.constructor = TabMorph; TabMorph.uber = ToggleButtonMorph.prototype; @@ -1022,7 +1022,7 @@ TabMorph.prototype.drawEdges = function ( // ToggleMorph inherits from PushButtonMorph: -ToggleMorph.prototype = new PushButtonMorph(); +ToggleMorph.prototype = Object.create(PushButtonMorph.prototype); ToggleMorph.prototype.constructor = ToggleMorph; ToggleMorph.uber = PushButtonMorph.prototype; @@ -1270,7 +1270,7 @@ ToggleMorph.prototype.show = ToggleButtonMorph.prototype.show; // ToggleElementMorph inherits from TriggerMorph: -ToggleElementMorph.prototype = new TriggerMorph(); +ToggleElementMorph.prototype = Object.create(TriggerMorph.prototype); ToggleElementMorph.prototype.constructor = ToggleElementMorph; ToggleElementMorph.uber = TriggerMorph.prototype; @@ -1440,7 +1440,7 @@ ToggleElementMorph.prototype.mouseClickLeft // DialogBoxMorph inherits from Morph: -DialogBoxMorph.prototype = new Morph(); +DialogBoxMorph.prototype = Object.create(Morph.prototype); DialogBoxMorph.prototype.constructor = DialogBoxMorph; DialogBoxMorph.uber = Morph.prototype; @@ -2866,7 +2866,7 @@ DialogBoxMorph.prototype.outlinePathBody = function (context, radius) { // AlignmentMorph inherits from Morph: -AlignmentMorph.prototype = new Morph(); +AlignmentMorph.prototype = Object.create(Morph.prototype); AlignmentMorph.prototype.constructor = AlignmentMorph; AlignmentMorph.uber = Morph.prototype; @@ -2940,7 +2940,7 @@ AlignmentMorph.prototype.fixLayout = function () { // InputFieldMorph inherits from Morph: -InputFieldMorph.prototype = new Morph(); +InputFieldMorph.prototype = Object.create(Morph.prototype); InputFieldMorph.prototype.constructor = InputFieldMorph; InputFieldMorph.uber = Morph.prototype; diff --git a/xml.js b/xml.js index fb612ce..d1cdf68 100644 --- a/xml.js +++ b/xml.js @@ -166,7 +166,7 @@ ReadStream.prototype.word = function () { // XML_Element inherits from Node: -XML_Element.prototype = new Node(); +XML_Element.prototype = Object.create(Node.prototype); XML_Element.prototype.constructor = XML_Element; XML_Element.uber = Node.prototype; -- cgit v1.3.1 From 013e2740d853b660fbc48cda247b6fe711aecce9 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Wed, 17 Jun 2015 17:26:56 -0400 Subject: Fix missing initialization call in SnapSerializer() --- store.js | 1 + 1 file changed, 1 insertion(+) diff --git a/store.js b/store.js index 6f3bc23..a45c801 100644 --- a/store.js +++ b/store.js @@ -274,6 +274,7 @@ SnapSerializer.prototype.watcherLabels = { // SnapSerializer instance creation: function SnapSerializer() { + XML_Serializer.call(this); this.init(); } -- cgit v1.3.1 From c8cbbeb2ada539d8c71a74a000b1eb329ad26bbe Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Wed, 17 Jun 2015 18:24:54 -0400 Subject: Optimize HandMorph::morphAtPointer a lot On large morph hierarchies this goes from ~85% CPU usage when moving the mouse around to ~5%. --- morphic.js | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/morphic.js b/morphic.js index 029afd1..88f8c22 100644 --- a/morphic.js +++ b/morphic.js @@ -9392,28 +9392,27 @@ HandMorph.prototype.changed = function () { // HandMorph navigation: -HandMorph.prototype.morphAtPointer = function () { - var morphs = this.world.allChildren().slice(0).reverse(), - myself = this, - result = null; - - morphs.forEach(function (m) { - if (m.visibleBounds().containsPoint(myself.bounds.origin) && - result === null && - m.isVisible && - (m.noticesTransparentClick || - (!m.isTransparentAt(myself.bounds.origin))) && - (!(m instanceof ShadowMorph)) && - m.allParents().every(function (each) { - return each.isVisible; - })) { - result = m; - } - }); - if (result !== null) { - return result; +Morph.prototype.topMorphAt = function (p) { + if (!this.isVisible) return null; + for (var c = this.children, i = c.length; i--;) { + var result = c[i].topMorphAt(p); + if (result) return result; + } + return this.bounds.containsPoint(p) ? this : null; +}; +FrameMorph.prototype.topMorphAt = function (p) { + if (!(this.isVisible && this.bounds.containsPoint(p))) return null; + for (var c = this.children, i = c.length; i--;) { + var result = c[i].topMorphAt(p); + if (result) return result; } - return this.world; + return this; +}; +ShadowMorph.prototype.topMorphAt = function () { + return null; +}; +HandMorph.prototype.morphAtPointer = function () { + return this.world.topMorphAt(this.bounds.origin); }; /* -- cgit v1.3.1 From 7bb046856c765facb348d3f461166599c03103d6 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Wed, 17 Jun 2015 18:28:18 -0400 Subject: Remove extra space --- morphic.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/morphic.js b/morphic.js index 88f8c22..aca37ed 100644 --- a/morphic.js +++ b/morphic.js @@ -2899,7 +2899,7 @@ Morph.prototype.fullChanged = function () { }; Morph.prototype.childChanged = function () { - // react to a change in one of my children, + // react to a change in one of my children, // default is to just pass this message on upwards // override this method for Morphs that need to adjust accordingly if (this.parent) { -- cgit v1.3.1 From 94687f8e630c5be6f2c82615c1aa1ec5cbee82b8 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Wed, 17 Jun 2015 18:39:23 -0400 Subject: Optimize Block::thumbnail() Remove noShadow, because copying is really expensive--you could probably add this in-place with some more complicated logic, but it doesn't seem worth it. Also fix clipping logic so that fades look good on all background colors. --- blocks.js | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/blocks.js b/blocks.js index 3613dae..d373cea 100644 --- a/blocks.js +++ b/blocks.js @@ -2225,7 +2225,7 @@ BlockMorph.prototype.userMenu = function () { ); if (this instanceof CommandBlockMorph && this.nextBlock()) { menu.addItem( - this.thumbnail(0.5, 60, false), + this.thumbnail(0.5, 60), function () { var cpy = this.fullCopy(), nb = cpy.nextBlock(), @@ -3103,38 +3103,34 @@ BlockMorph.prototype.mouseClickLeft = function () { // BlockMorph thumbnail -BlockMorph.prototype.thumbnail = function (scale, clipWidth, noShadow) { - var block = this.fullCopy(), - nb = block.nextBlock(), +BlockMorph.prototype.thumbnail = function (scale, clipWidth) { + var nb = this.nextBlock(), fadeout = 12, ext, trgt, ctx, gradient; - if (nb) {nb.destroy(); } - if (!noShadow) {block.addShadow(); } - ext = block.fullBounds().extent(); - if (!noShadow) { - ext = ext.subtract(this.shadowBlur * - (useBlurredShadows && !MorphicPreferences.isFlat ? 1 : 2)); - } + + if (nb) {nb.isVisible = false; } + ext = this.fullBounds().extent(); trgt = newCanvas(new Point( - Math.min(ext.x * scale, clipWidth || ext.x), + clipWidth ? Math.min(ext.x * scale, clipWidth) : ext.x * scale, ext.y * scale )); ctx = trgt.getContext('2d'); ctx.scale(scale, scale); - ctx.drawImage(block.fullImage(), 0, 0); + ctx.drawImage(this.fullImage(), 0, 0); // draw fade-out - if (trgt.width === clipWidth) { + if (clipWidth && ext.x * scale > clipWidth) { gradient = ctx.createLinearGradient( trgt.width / scale - fadeout, 0, trgt.width / scale, 0 ); - gradient.addColorStop(0, new Color(255, 255, 255, 0).toString()); - gradient.addColorStop(1, 'white'); + gradient.addColorStop(0, 'transparent'); + gradient.addColorStop(1, 'black'); + ctx.globalCompositeOperation = 'destination-out'; ctx.fillStyle = gradient; ctx.fillRect( trgt.width / scale - fadeout, @@ -3143,6 +3139,7 @@ BlockMorph.prototype.thumbnail = function (scale, clipWidth, noShadow) { trgt.height / scale ); } + if (nb) {nb.isVisible = true; } return trgt; }; -- cgit v1.3.1 From 1f52f4f1522c4bc7c24fb19ba66aeaff3bf15b64 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Wed, 17 Jun 2015 18:50:56 -0400 Subject: Optimize StringMorph::clearSelection() This was taking a very large chunk of CPU time when copying large scripts. --- morphic.js | 1 + 1 file changed, 1 insertion(+) diff --git a/morphic.js b/morphic.js index aca37ed..737e944 100644 --- a/morphic.js +++ b/morphic.js @@ -7402,6 +7402,7 @@ StringMorph.prototype.selectionStartSlot = function () { }; StringMorph.prototype.clearSelection = function () { + if (!this.currentlySelecting && this.startMark === 0 && this.endMark === 0) return; this.currentlySelecting = false; this.startMark = 0; this.endMark = 0; -- cgit v1.3.1 From 81b9245d25cc7a3027f21fe13bcb653a7a552c09 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Wed, 17 Jun 2015 19:10:30 -0400 Subject: Optimize copy() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1356.2 ms before => 73.3 ms after (on a large block stack) --- morphic.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/morphic.js b/morphic.js index 737e944..013660e 100644 --- a/morphic.js +++ b/morphic.js @@ -1266,18 +1266,16 @@ function copy(target) { } if (target instanceof target.constructor && target.constructor !== Object) { - c = clone(target.constructor.prototype); - for (property in target) { - if (Object.prototype.hasOwnProperty.call(target, property)) { - c[property] = target[property]; - } + c = Object.create(target.constructor.prototype); + var keys = Object.keys(target); + for (var l = keys.length, i = 0; i < l; i++) { + property = keys[i]; + c[property] = target[property]; } } else { c = {}; for (property in target) { - if (!c[property]) { - c[property] = target[property]; - } + c[property] = target[property]; } } return c; -- cgit v1.3.1 From 3e613a44090391854c6126d919797911daab2307 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Wed, 17 Jun 2015 19:45:31 -0400 Subject: Fix and greatly simplify copying mechanism Due to an error in the original implementation of updateReferences(), Morph subclasses which stored references to other morphs needed to manually override copyRecordingReferences() to update these references (which should have been done automatically by updateReferences). This change fixes updateReferences() and changes the copying mechanism to use Maps, which are much faster. --- morphic.js | 162 +++++++++++++------------------------------------------------ 1 file changed, 34 insertions(+), 128 deletions(-) diff --git a/morphic.js b/morphic.js index 013660e..6ce8559 100644 --- a/morphic.js +++ b/morphic.js @@ -829,12 +829,11 @@ }; If your new morph stores or references other morphs outside of the - submorph tree in other properties, be sure to also override the - default + submorph tree in other properties, you may need to override the default - copyRecordingReferences() + updateReferences() - method accordingly if you want it to support duplication. + method if you want it to support duplication. (6) development and user modes @@ -1268,7 +1267,7 @@ function copy(target) { target.constructor !== Object) { c = Object.create(target.constructor.prototype); var keys = Object.keys(target); - for (var l = keys.length, i = 0; i < l; i++) { + for (var l = keys.length, i = 0; i < l; ++i) { property = keys[i]; c[property] = target[property]; } @@ -3044,45 +3043,49 @@ Morph.prototype.fullCopy = function () { Other properties are also *shallow* copied, so you must override to deep copy Arrays and (complex) Objects */ - var dict = {}, c; - c = this.copyRecordingReferences(dict); + var map = new Map(), c; + c = this.copyRecordingReferences(map); c.forAllChildren(function (m) { - m.updateReferences(dict); + m.updateReferences(map); }); return c; }; -Morph.prototype.copyRecordingReferences = function (dict) { +Morph.prototype.copyRecordingReferences = function (map) { /* Recursively copy this entire composite morph, recording the correspondence between old and new morphs in the given dictionary. This dictionary will be used to update intra-composite references in the copy. See updateReferences(). - Note: This default implementation copies ONLY morphs in the - submorph hierarchy. If a morph stores morphs in other properties - that it wants to copy, then it should override this method to do so. - The same goes for morphs that contain other complex data that - should be copied when the morph is duplicated. + + Note: This default implementation copies ONLY morphs. If a morph + stores morphs in other properties that it wants to copy, then it + should override this method to do so. The same goes for morphs that + contain other complex data that should be copied when the morph is + duplicated. */ var c = this.copy(); - dict[this] = c; + map.set(this, c); this.children.forEach(function (m) { - c.add(m.copyRecordingReferences(dict)); + c.add(m.copyRecordingReferences(map)); }); return c; }; -Morph.prototype.updateReferences = function (dict) { +Morph.prototype.updateReferences = function (map) { /* Update intra-morph references within a composite morph that has been copied. For example, if a button refers to morph X in the orginal composite then the copy of that button in the new composite should refer to the copy of X in new composite, not the original X. */ - var property; - for (property in this) { - if (this[property] && this[property].isMorph && dict[property]) { - this[property] = dict[property]; + var property, value, reference; + for (var properties = Object.keys(this), l = properties.length, i = 0; i < l; ++i) { + property = properties[i]; + value = this[property]; + if (value && value.isMorph) { + reference = map.get(value); + if (reference) this[property] = reference; } } }; @@ -3921,20 +3924,6 @@ HandleMorph.prototype.mouseLeave = function () { this.changed(); }; -// HandleMorph duplicating: - -HandleMorph.prototype.copyRecordingReferences = function (dict) { - // inherited, see comment in Morph - var c = HandleMorph.uber.copyRecordingReferences.call( - this, - dict - ); - if (c.target && dict[this.target]) { - c.target = (dict[this.target]); - } - return c; -}; - // HandleMorph menu: HandleMorph.prototype.attach = function () { @@ -4258,20 +4247,6 @@ ColorPaletteMorph.prototype.updateTarget = function () { } }; -// ColorPaletteMorph duplicating: - -ColorPaletteMorph.prototype.copyRecordingReferences = function (dict) { - // inherited, see comment in Morph - var c = ColorPaletteMorph.uber.copyRecordingReferences.call( - this, - dict - ); - if (c.target && dict[this.target]) { - c.target = (dict[this.target]); - } - return c; -}; - // ColorPaletteMorph menu: ColorPaletteMorph.prototype.developersMenu = function () { @@ -5838,23 +5813,6 @@ SliderMorph.prototype.updateTarget = function () { } }; -// SliderMorph duplicating: - -SliderMorph.prototype.copyRecordingReferences = function (dict) { - // inherited, see comment in Morph - var c = SliderMorph.uber.copyRecordingReferences.call( - this, - dict - ); - if (c.target && dict[this.target]) { - c.target = (dict[this.target]); - } - if (c.button && dict[this.button]) { - c.button = (dict[this.button]); - } - return c; -}; - // SliderMorph menu: SliderMorph.prototype.developersMenu = function () { @@ -8140,20 +8098,6 @@ TriggerMorph.prototype.createLabel = function () { this.add(this.label); }; -// TriggerMorph duplicating: - -TriggerMorph.prototype.copyRecordingReferences = function (dict) { - // inherited, see comment in Morph - var c = TriggerMorph.uber.copyRecordingReferences.call( - this, - dict - ); - if (c.label && dict[this.label]) { - c.label = (dict[this.label]); - } - return c; -}; - // TriggerMorph action: TriggerMorph.prototype.trigger = function () { @@ -8599,20 +8543,6 @@ FrameMorph.prototype.reactToGrabOf = function () { this.adjustBounds(); }; -// FrameMorph duplicating: - -FrameMorph.prototype.copyRecordingReferences = function (dict) { - // inherited, see comment in Morph - var c = FrameMorph.uber.copyRecordingReferences.call( - this, - dict - ); - if (c.frame && dict[this.scrollFrame]) { - c.frame = (dict[this.scrollFrame]); - } - return c; -}; - // FrameMorph menus: FrameMorph.prototype.developersMenu = function () { @@ -8957,32 +8887,22 @@ ScrollFrameMorph.prototype.mouseScroll = function (y, x) { // ScrollFrameMorph duplicating: -ScrollFrameMorph.prototype.copyRecordingReferences = function (dict) { - // inherited, see comment in Morph - var c = ScrollFrameMorph.uber.copyRecordingReferences.call( - this, - dict - ); - if (c.contents && dict[this.contents]) { - c.contents = (dict[this.contents]); - } - if (c.hBar && dict[this.hBar]) { - c.hBar = (dict[this.hBar]); - c.hBar.action = function (num) { - c.contents.setPosition( - new Point(c.left() - num, c.contents.position().y) +ScrollFrameMorph.prototype.updateReferences = function () { + var self = this; + if (this.hBar) { + this.hBar.action = function (num) { + self.contents.setPosition( + new Point(self.left() - num, self.contents.position().y) ); }; } - if (c.vBar && dict[this.vBar]) { - c.vBar = (dict[this.vBar]); - c.vBar.action = function (num) { - c.contents.setPosition( - new Point(c.contents.position().x, c.top() - num) + if (this.vBar) { + this.vBar.action = function (num) { + self.contents.setPosition( + new Point(self.contents.position().x, self.top() - num) ); }; } - return c; }; // ScrollFrameMorph menu: @@ -9242,20 +9162,6 @@ StringFieldMorph.prototype.mouseClickLeft = function (pos) { } }; -// StringFieldMorph duplicating: - -StringFieldMorph.prototype.copyRecordingReferences = function (dict) { - // inherited, see comment in Morph - var c = StringFieldMorph.uber.copyRecordingReferences.call( - this, - dict - ); - if (c.text && dict[this.text]) { - c.text = (dict[this.text]); - } - return c; -}; - // BouncerMorph //////////////////////////////////////////////////////// // I am a Demo of a stepping custom Morph -- cgit v1.3.1 From f54da26e8e4a9d92c93ac58f242ac521b6dbac66 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Wed, 17 Jun 2015 20:05:35 -0400 Subject: Don't step SyntaxElementMorphs or their children ~1500 ms before => ~150 ms after (stepping world with large scripts) --- blocks.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/blocks.js b/blocks.js index d373cea..d2a395a 100644 --- a/blocks.js +++ b/blocks.js @@ -621,6 +621,10 @@ SyntaxElementMorph.prototype.topBlock = function () { return this; }; +// SyntaxElementMorph stepping: + +SyntaxElementMorph.prototype.step = null; + // SyntaxElementMorph drag & drop: SyntaxElementMorph.prototype.reactToGrabOf = function (grabbedMorph) { -- cgit v1.3.1 From d5761b074d0c98c047e7319cf2243a39c7a6a303 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Wed, 17 Jun 2015 20:08:59 -0400 Subject: Remove clone function (unused) --- morphic.js | 10 ---------- objects.js | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/morphic.js b/morphic.js index 6ce8559..e23812a 100644 --- a/morphic.js +++ b/morphic.js @@ -1242,16 +1242,6 @@ function getDocumentPositionOf(aDOMelement) { return pos; } -function clone(target) { - // answer a new instance of target's type - if (typeof target === 'object') { - var Clone = function () {nop(); }; - Clone.prototype = target; - return new Clone(); - } - return target; -} - function copy(target) { // answer a shallow copy of target var value, c, property; diff --git a/objects.js b/objects.js index 462aed2..8d11ff6 100644 --- a/objects.js +++ b/objects.js @@ -105,7 +105,7 @@ InspectorMorph, ListMorph, Math, MenuItemMorph, MenuMorph, Morph, MorphicPreferences, MouseSensorMorph, Node, Object, PenMorph, Point, Rectangle, ScrollFrameMorph, ShadowMorph, SliderButtonMorph, SliderMorph, String, StringFieldMorph, StringMorph, TextMorph, -TriggerMorph, WorldMorph, clone, contains, copy, degrees, detect, +TriggerMorph, WorldMorph, contains, copy, degrees, detect, document, getDocumentPositionOf, isNaN, isObject, isString, newCanvas, nop, parseFloat, radians, standardSettings, touchScreenSettings, useBlurredShadows, version, window, modules, IDE_Morph, VariableDialogMorph, -- cgit v1.3.1 From 6a82960cf77f9eac16c9a1ce13f360d80469799d Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Wed, 17 Jun 2015 20:46:54 -0400 Subject: Optimize moveBy and friends This results in realtime speed for dragging where I used to get 10-15 fps before this change. --- morphic.js | 43 +++++++++---------------------------------- objects.js | 2 +- 2 files changed, 10 insertions(+), 35 deletions(-) diff --git a/morphic.js b/morphic.js index e23812a..5cc4062 100644 --- a/morphic.js +++ b/morphic.js @@ -2398,19 +2398,16 @@ Morph.prototype.visibleBounds = function () { // Morph accessing - simple changes: Morph.prototype.moveBy = function (delta) { - this.changed(); - this.bounds = this.bounds.translateBy(delta); - this.children.forEach(function (child) { - child.moveBy(delta); - }); - this.changed(); + this.fullChanged(); + this.silentMoveBy(delta); + this.fullChanged(); }; Morph.prototype.silentMoveBy = function (delta) { this.bounds = this.bounds.translateBy(delta); - this.children.forEach(function (child) { - child.silentMoveBy(delta); - }); + for (var children = this.children, i = children.length; i--;) { + children[i].silentMoveBy(delta); + } }; Morph.prototype.setPosition = function (aPoint) { @@ -3146,9 +3143,7 @@ Morph.prototype.slideBackTo = function (situation, inSteps) { this.fps = 0; this.step = function () { - myself.fullChanged(); - myself.silentMoveBy(new Point(xStep, yStep)); - myself.fullChanged(); + myself.moveBy(new Point(xStep, yStep)); stepCount += 1; if (stepCount === steps) { situation.origin.add(myself); @@ -8433,17 +8428,6 @@ FrameMorph.prototype.fullDrawOn = function (aCanvas, aRect) { }); }; -// FrameMorph scrolling optimization: - -FrameMorph.prototype.moveBy = function (delta) { - this.changed(); - this.bounds = this.bounds.translateBy(delta); - this.children.forEach(function (child) { - child.silentMoveBy(delta); - }); - this.changed(); -}; - // FrameMorph scrolling support: FrameMorph.prototype.submorphBounds = function () { @@ -9274,7 +9258,8 @@ HandMorph.prototype.init = function (aWorld) { this.contextMenuEnabled = false; }; -HandMorph.prototype.changed = function () { +HandMorph.prototype.changed = +HandMorph.prototype.fullChanged = function () { var b; if (this.world !== null) { b = this.fullBounds(); @@ -9282,7 +9267,6 @@ HandMorph.prototype.changed = function () { this.world.broken.push(this.fullBounds().spread()); } } - }; // HandMorph navigation: @@ -9865,15 +9849,6 @@ HandMorph.prototype.destroyTemporaries = function () { }); }; -// HandMorph dragging optimization - -HandMorph.prototype.moveBy = function (delta) { - Morph.prototype.trackChanges = false; - HandMorph.uber.moveBy.call(this, delta); - Morph.prototype.trackChanges = true; - this.fullChanged(); -}; - // WorldMorph ////////////////////////////////////////////////////////// diff --git a/objects.js b/objects.js index 8d11ff6..1e8060e 100644 --- a/objects.js +++ b/objects.js @@ -3290,7 +3290,7 @@ SpriteMorph.prototype.nestingBounds = function () { // SpriteMorph motion primitives -Morph.prototype.setPosition = function (aPoint, justMe) { +SpriteMorph.prototype.setPosition = function (aPoint, justMe) { // override the inherited default to make sure my parts follow // unless it's justMe var delta = aPoint.subtract(this.topLeft()); -- cgit v1.3.1 From f20ea6792688b97a8d9b50e9eed783e4773d9a86 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Wed, 17 Jun 2015 21:08:12 -0400 Subject: Provide a fallback for browsers that don't support Map --- morphic.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/morphic.js b/morphic.js index 5cc4062..fe2cc8b 100644 --- a/morphic.js +++ b/morphic.js @@ -3077,6 +3077,40 @@ Morph.prototype.updateReferences = function (map) { } }; +if (typeof Map === 'undefined') { + // use normal objects + stringification if Map doesn't exist + + Morph.prototype.fullCopy = function () { + var dict = {}, c; + c = this.copyRecordingReferences(dict); + c.forAllChildren(function (m) { + m.updateReferences(dict); + }); + return c; + }; + + Morph.prototype.copyRecordingReferences = function (dict) { + var c = this.copy(); + dict[this] = c; + this.children.forEach(function (m) { + c.add(m.copyRecordingReferences(dict)); + }); + return c; + }; + + Morph.prototype.updateReferences = function (dict) { + var property, value, reference; + for (var properties = Object.keys(this), l = properties.length, i = 0; i < l; ++i) { + property = properties[i]; + value = this[property]; + if (value && value.isMorph) { + reference = dict[value]; + if (reference) this[property] = reference; + } + } + }; +} + // Morph dragging and dropping: Morph.prototype.rootForGrab = function () { -- cgit v1.3.1 From aaa3c407bc54e61ba2944f97956a89bf76ad22d1 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Wed, 17 Jun 2015 21:11:04 -0400 Subject: Add a missing super call in overridden updateReferences() --- morphic.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/morphic.js b/morphic.js index fe2cc8b..0b20eb5 100644 --- a/morphic.js +++ b/morphic.js @@ -8895,8 +8895,9 @@ ScrollFrameMorph.prototype.mouseScroll = function (y, x) { // ScrollFrameMorph duplicating: -ScrollFrameMorph.prototype.updateReferences = function () { +ScrollFrameMorph.prototype.updateReferences = function (map) { var self = this; + ScrollFrameMorph.uber.updateReferences.call(this, map); if (this.hBar) { this.hBar.action = function (num) { self.contents.setPosition( -- cgit v1.3.1 From 836b5d3fd04c4438241c5f53078da2b36f54a9b1 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Wed, 17 Jun 2015 21:56:09 -0400 Subject: Add missing init() super calls in paint.js --- paint.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/paint.js b/paint.js index b4c55b1..6e4ae8b 100644 --- a/paint.js +++ b/paint.js @@ -92,6 +92,7 @@ function PaintEditorMorph() { } PaintEditorMorph.prototype.init = function () { + PaintEditorMorph.uber.init.call(this); // additional properties: this.paper = null; // paint canvas this.oncancel = null; @@ -485,6 +486,7 @@ function PaintColorPickerMorph(extent, action) { } PaintColorPickerMorph.prototype.init = function (extent, action) { + PaintColorPickerMorph.uber.init.call(this); this.setExtent(extent || new Point(200, 100)); this.action = action || nop; this.drawNew(); @@ -561,6 +563,7 @@ function PaintCanvasMorph(shift) { } PaintCanvasMorph.prototype.init = function (shift) { + PaintCanvasMorph.uber.init.call(this); this.rotationCenter = new Point(240, 180); this.dragRect = null; this.previousDragPoint = null; @@ -961,6 +964,7 @@ PaintCanvasMorph.prototype.buildContents = function () { }; PaintCanvasMorph.prototype.drawNew = function () { + if (!this.background) return; var can = newCanvas(this.extent()); this.merge(this.background, can); this.merge(this.paper, can); -- cgit v1.3.1 From 95a815b6d63b57f46a72be25b9723366f4af76bd Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Wed, 17 Jun 2015 22:21:23 -0400 Subject: Don't redraw label parts unnecessarily --- blocks.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blocks.js b/blocks.js index d2a395a..6c10354 100644 --- a/blocks.js +++ b/blocks.js @@ -2062,7 +2062,7 @@ BlockMorph.prototype.setSpec = function (spec) { } part = myself.labelPart(word); myself.add(part); - if (!(part instanceof CommandSlotMorph)) { + if (!(part instanceof CommandSlotMorph || part instanceof StringMorph)) { part.drawNew(); } if (part instanceof RingMorph) { -- cgit v1.3.1 From 0245a81fc04cf787bae2f3467f850a07d9791ca7 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Wed, 17 Jun 2015 23:05:34 -0400 Subject: Optimize loading projects a bit more --- blocks.js | 63 ++++++++++++++++++++++++++++++++------------------------------ morphic.js | 6 +++--- 2 files changed, 36 insertions(+), 33 deletions(-) diff --git a/blocks.js b/blocks.js index 6c10354..8aad311 100644 --- a/blocks.js +++ b/blocks.js @@ -1421,16 +1421,19 @@ SyntaxElementMorph.prototype.labelPart = function (spec) { new Point() : this.embossing; part.drawNew(); } else { - part = new StringMorph(spec); - part.fontName = this.labelFontName; - part.fontStyle = this.labelFontStyle; - part.fontSize = this.fontSize; - part.color = new Color(255, 255, 255); - part.isBold = true; - part.shadowColor = this.color.darker(this.labelContrast); - part.shadowOffset = MorphicPreferences.isFlat ? - new Point() : this.embossing; - part.drawNew(); + part = new StringMorph( + spec, // text + this.fontSize, // fontSize + this.labelFontStyle, // fontStyle + true, // bold + false, // italic + false, // isNumeric + MorphicPreferences.isFlat ? + new Point() : this.embossing, // shadowOffset + this.color.darker(this.labelContrast), // shadowColor + new Color(255, 255, 255), // color + this.labelFontName // fontName + ); } return part; }; @@ -6918,7 +6921,8 @@ InputSlotMorph.prototype.setChoices = function (dict, readonly) { // InputSlotMorph layout: InputSlotMorph.prototype.fixLayout = function () { - var contents = this.contents(), + var width, height, arrowWidth, + contents = this.contents(), arrow = this.arrow(); contents.isNumeric = this.isNumeric; @@ -6935,32 +6939,29 @@ InputSlotMorph.prototype.fixLayout = function () { arrow.setSize(this.fontSize); arrow.show(); } else { - arrow.setSize(0); arrow.hide(); } - this.setHeight( - contents.height() - + this.edge * 2 - // + this.typeInPadding * 2 - ); + arrowWidth = arrow.isVisible ? arrow.width() : 0; + + height = contents.height() + this.edge * 2; // + this.typeInPadding * 2 if (this.isNumeric) { - this.setWidth(contents.width() - + Math.floor(arrow.width() * 0.5) + width = contents.width() + + Math.floor(arrowWidth * 0.5) + this.height() - + this.typeInPadding * 2 - ); + + this.typeInPadding * 2; } else { - this.setWidth(Math.max( + width = Math.max( contents.width() - + arrow.width() + + arrowWidth + this.edge * 2 + this.typeInPadding * 2, contents.rawHeight ? // single vs. multi-line contents - contents.rawHeight() + arrow.width() - : contents.height() / 1.2 + arrow.width(), + contents.rawHeight() + arrowWidth + : contents.height() / 1.2 + arrowWidth, this.minWidth // for text-type slots - )); + ); } + this.setExtent(new Point(width, height)); if (this.isNumeric) { contents.setPosition(new Point( Math.floor(this.height() / 2), @@ -6973,10 +6974,12 @@ InputSlotMorph.prototype.fixLayout = function () { ).add(new Point(this.typeInPadding, 0)).add(this.position())); } - arrow.setPosition(new Point( - this.right() - arrow.width() - this.edge, - contents.top() - )); + if (arrow.isVisible) { + arrow.setPosition(new Point( + this.right() - arrowWidth - this.edge, + contents.top() + )); + } if (this.parent) { if (this.parent.fixLayout) { diff --git a/morphic.js b/morphic.js index 0b20eb5..1552d78 100644 --- a/morphic.js +++ b/morphic.js @@ -2199,7 +2199,7 @@ function Morph() { // Morph initialization: -Morph.prototype.init = function () { +Morph.prototype.init = function (noDraw) { Morph.uber.init.call(this); this.isMorph = true; this.bounds = new Rectangle(0, 0, 50, 40); @@ -2212,7 +2212,7 @@ Morph.prototype.init = function () { this.isTemplate = false; this.acceptsDrops = false; this.noticesTransparentClick = false; - this.drawNew(); + if (!noDraw) this.drawNew(); this.fps = 0; this.customContextMenu = null; this.lastTime = Date.now(); @@ -6999,7 +6999,7 @@ StringMorph.prototype.init = function ( this.markedBackgoundColor = new Color(60, 60, 120); // initialize inherited properties: - StringMorph.uber.init.call(this); + StringMorph.uber.init.call(this, true); // override inherited properites: this.color = color || new Color(0, 0, 0); -- cgit v1.3.1 From 995e782147c202a8afa64cabe204849b955f153b Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Thu, 18 Jun 2015 04:29:26 -0400 Subject: Fix ListWatcherMorph initialization --- lists.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lists.js b/lists.js index be7f933..769b8b3 100644 --- a/lists.js +++ b/lists.js @@ -388,6 +388,13 @@ ListWatcherMorph.prototype.init = function (list, parentCell) { this.lastCell = null; this.parentCell = parentCell || null; // for circularity detection + ListWatcherMorph.uber.init.call( + this, + SyntaxElementMorph.prototype.rounding, + 1.000001, // shadow bug in Chrome, + new Color(120, 120, 120) + ); + // elements declarations this.label = new StringMorph( localize('length: ') + this.list.length(), @@ -436,13 +443,6 @@ ListWatcherMorph.prototype.init = function (list, parentCell) { this.plusButton.drawNew(); this.plusButton.fixLayout(); - ListWatcherMorph.uber.init.call( - this, - SyntaxElementMorph.prototype.rounding, - 1.000001, // shadow bug in Chrome, - new Color(120, 120, 120) - ); - this.color = new Color(220, 220, 220); this.isDraggable = true; this.setExtent(new Point(80, 70).multiplyBy( @@ -634,6 +634,7 @@ ListWatcherMorph.prototype.setStartIndex = function (index) { }; ListWatcherMorph.prototype.fixLayout = function () { + if (!this.label) return; Morph.prototype.trackChanges = false; if (this.frame) { this.arrangeCells(); -- cgit v1.3.1 From 82197c7a8c1835048fb6a787c41845049c89ca0c Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Thu, 18 Jun 2015 15:33:25 -0400 Subject: Declare some variables earlier --- morphic.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/morphic.js b/morphic.js index 1552d78..9f6e8c2 100644 --- a/morphic.js +++ b/morphic.js @@ -1244,7 +1244,7 @@ function getDocumentPositionOf(aDOMelement) { function copy(target) { // answer a shallow copy of target - var value, c, property; + var value, c, property, keys, l, i; if (typeof target !== 'object') { return target; @@ -1256,8 +1256,8 @@ function copy(target) { if (target instanceof target.constructor && target.constructor !== Object) { c = Object.create(target.constructor.prototype); - var keys = Object.keys(target); - for (var l = keys.length, i = 0; i < l; ++i) { + keys = Object.keys(target); + for (l = keys.length, i = 0; i < l; ++i) { property = keys[i]; c[property] = target[property]; } -- cgit v1.3.1 From bae22f08044f01adba15608d3885e84e173c8889 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Thu, 18 Jun 2015 15:33:36 -0400 Subject: Add braces --- morphic.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/morphic.js b/morphic.js index 9f6e8c2..01220d5 100644 --- a/morphic.js +++ b/morphic.js @@ -2212,7 +2212,7 @@ Morph.prototype.init = function (noDraw) { this.isTemplate = false; this.acceptsDrops = false; this.noticesTransparentClick = false; - if (!noDraw) this.drawNew(); + if (!noDraw) { this.drawNew(); } this.fps = 0; this.customContextMenu = null; this.lastTime = Date.now(); -- cgit v1.3.1 From bc79cd8df2b6c62a80bb6850697d368cf9acebd5 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Thu, 18 Jun 2015 15:33:44 -0400 Subject: Call isTransparentAt --- morphic.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/morphic.js b/morphic.js index 01220d5..aa731ab 100644 --- a/morphic.js +++ b/morphic.js @@ -9312,7 +9312,7 @@ Morph.prototype.topMorphAt = function (p) { var result = c[i].topMorphAt(p); if (result) return result; } - return this.bounds.containsPoint(p) ? this : null; + return this.bounds.containsPoint(p) && (this.noticesTransparentClick || !this.isTransparentAt(p)) ? this : null; }; FrameMorph.prototype.topMorphAt = function (p) { if (!(this.isVisible && this.bounds.containsPoint(p))) return null; @@ -9320,13 +9320,13 @@ FrameMorph.prototype.topMorphAt = function (p) { var result = c[i].topMorphAt(p); if (result) return result; } - return this; + return this.noticesTransparentClick || !this.isTransparentAt(p) ? this : null; }; ShadowMorph.prototype.topMorphAt = function () { return null; }; HandMorph.prototype.morphAtPointer = function () { - return this.world.topMorphAt(this.bounds.origin); + return this.world.topMorphAt(this.bounds.origin) || this.world; }; /* @@ -9913,6 +9913,7 @@ WorldMorph.prototype.init = function (aCanvas, fillPage) { this.isDraggable = false; this.currentKey = null; // currently pressed key code this.worldCanvas = aCanvas; + this.noticesTransparentClick = true; // additional properties: this.stamp = Date.now(); // reference in multi-world setups -- cgit v1.3.1 From e1b104948b5162a014fa752f394d0e722664499c Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Thu, 18 Jun 2015 16:05:27 -0400 Subject: Fix InputSlotMorph::fixLayout() --- blocks.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blocks.js b/blocks.js index 8aad311..d023db8 100644 --- a/blocks.js +++ b/blocks.js @@ -6947,7 +6947,7 @@ InputSlotMorph.prototype.fixLayout = function () { if (this.isNumeric) { width = contents.width() + Math.floor(arrowWidth * 0.5) - + this.height() + + height + this.typeInPadding * 2; } else { width = Math.max( @@ -6964,7 +6964,7 @@ InputSlotMorph.prototype.fixLayout = function () { this.setExtent(new Point(width, height)); if (this.isNumeric) { contents.setPosition(new Point( - Math.floor(this.height() / 2), + Math.floor(height / 2), this.edge ).add(new Point(this.typeInPadding, 0)).add(this.position())); } else { -- cgit v1.3.1 From 6fbd2f27896d9cd749d92cc90495c4c4d7ab0ab0 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Thu, 18 Jun 2015 18:35:20 -0400 Subject: Speed up parser About an order of magnitude faster (268.5 ms => 31.3 ms). --- xml.js | 119 +++++++++++++++++------------------------------------------------ 1 file changed, 30 insertions(+), 89 deletions(-) diff --git a/xml.js b/xml.js index d1cdf68..16b03f0 100644 --- a/xml.js +++ b/xml.js @@ -61,7 +61,7 @@ */ -/*global modules, isString, detect, Node, isNil*/ +/*global modules, detect, Node, isNil*/ // Global stuff //////////////////////////////////////////////////////// @@ -85,7 +85,8 @@ function ReadStream(arrayOrString) { // ReadStream constants: -ReadStream.prototype.space = /[\s]/; +ReadStream.prototype.nonSpace = /\S|$/g; +ReadStream.prototype.nonWord = /[\s\>\/\=]|$/g; // ReadStream accessing: @@ -115,46 +116,26 @@ ReadStream.prototype.atEnd = function () { // ReadStream accessing String contents: -ReadStream.prototype.upTo = function (regex) { - var i, start; - if (!isString(this.contents)) {return ''; } - i = this.contents.substr(this.index).search(regex); - if (i === -1) { - return ''; - } - start = this.index; - this.index += i; - return this.contents.substring(start, this.index); +ReadStream.prototype.upTo = function (str) { + var i = this.contents.indexOf(str, this.index); + return i === -1 ? '' : this.contents.slice(this.index, this.index = i); }; -ReadStream.prototype.peekUpTo = function (regex) { - if (!isString(this.contents)) {return ''; } - var i = this.contents.substr(this.index).search(regex); - if (i === -1) { - return ''; - } - return this.contents.substring(this.index, this.index + i); +ReadStream.prototype.peekUpTo = function (str) { + var i = this.contents.indexOf(str, this.index); + return i === -1 ? '' : this.contents.slice(this.index, i); }; ReadStream.prototype.skipSpace = function () { - if (!isString(this.contents)) {return ''; } - var ch = this.peek(); - while (this.space.test(ch) && ch !== '') { - this.skip(); - ch = this.peek(); - } + this.nonSpace.lastIndex = this.index; + var result = this.nonSpace.exec(this.contents); + if (result) this.index = result.index; }; ReadStream.prototype.word = function () { - var i, start; - if (!isString(this.contents)) {return ''; } - i = this.contents.substr(this.index).search(/[\s\>\/\=]|$/); - if (i === -1) { - return ''; - } - start = this.index; - this.index += i; - return this.contents.substring(start, this.index); + this.nonWord.lastIndex = this.index; + var result = this.nonWord.exec(this.contents); + return result ? this.contents.slice(this.index, this.index = result.index) : ''; }; // XML_Element /////////////////////////////////////////////////////////// @@ -190,9 +171,7 @@ XML_Element.prototype.init = function (tag, contents, parent) { XML_Element.uber.init.call(this); // override inherited properties - if (parent instanceof XML_Element) { - parent.addChild(this); - } + if (parent) parent.addChild(this); }; // XML_Element DOM navigation: (aside from what's inherited from Node) @@ -318,51 +297,18 @@ XML_Element.prototype.escape = function (string, ignoreQuotes) { }; XML_Element.prototype.unescape = function (string) { - var stream = new ReadStream(string), - result = '', - ch, - esc; - - function nextPut(str) { - result += str; - stream.upTo(';'); - stream.skip(); - } - - while (!stream.atEnd()) { - ch = stream.next(); - if (ch === '&') { - esc = stream.peekUpTo(';'); - switch (esc) { - case 'apos': - nextPut('\''); - break; - case 'quot': - nextPut('\"'); - break; - case 'lt': - nextPut('<'); - break; - case 'gt': - nextPut('>'); - break; - case 'amp': - nextPut('&'); - break; - case '#xD': - nextPut('\n'); - break; - case '#126': - nextPut('~'); - break; - default: - result += ch; - } - } else { - result += ch; + return string.replace(/&(amp|apos|quot|lt|gt|#xD|#126);/g, function(_, name) { + switch (name) { + case 'amp': return '&'; + case 'apos': return '\''; + case 'quot': return '"'; + case 'lt': return '<'; + case 'gt': return '>'; + case '#xD': return '\n'; + case '#126': return '~'; + default: console.warn('unreachable'); } - } - return result; + }); }; // XML_Element parsing: @@ -375,10 +321,7 @@ XML_Element.prototype.parseString = function (string) { }; XML_Element.prototype.parseStream = function (stream) { - var key, - value, - ch, - child; + var key, value, ch, child; // tag: this.tag = stream.word(); @@ -395,9 +338,7 @@ XML_Element.prototype.parseStream = function (stream) { stream.skipSpace(); ch = stream.next(); if (ch !== '"' && ch !== "'") { - throw new Error( - 'Expected single- or double-quoted attribute value' - ); + throw new Error('Expected single- or double-quoted attribute value'); } value = stream.upTo(ch); stream.skip(1); @@ -407,7 +348,7 @@ XML_Element.prototype.parseStream = function (stream) { } // empty tag: - if (stream.peek() === '/') { + if (ch === '/') { stream.skip(); if (stream.next() !== '>') { throw new Error('Expected ">" after "/" in empty tag'); -- cgit v1.3.1 From aef56afebf1504a9ce09ee5668d00c3c1df17565 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Thu, 25 Jun 2015 02:30:06 -0400 Subject: Use associative arrays if Map doesn't exist --- morphic.js | 143 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 70 insertions(+), 73 deletions(-) diff --git a/morphic.js b/morphic.js index aa731ab..e4df8f0 100644 --- a/morphic.js +++ b/morphic.js @@ -3015,101 +3015,98 @@ Morph.prototype.isTransparentAt = function (aPoint) { // Morph duplicating: -Morph.prototype.copy = function () { - var c = copy(this); - c.parent = null; - c.children = []; - c.bounds = this.bounds.copy(); - return c; -}; - -Morph.prototype.fullCopy = function () { - /* - Produce a copy of me with my entire tree of submorphs. Morphs - mentioned more than once are all directed to a single new copy. - Other properties are also *shallow* copied, so you must override - to deep copy Arrays and (complex) Objects - */ - var map = new Map(), c; - c = this.copyRecordingReferences(map); - c.forAllChildren(function (m) { - m.updateReferences(map); - }); - return c; -}; - -Morph.prototype.copyRecordingReferences = function (map) { - /* - Recursively copy this entire composite morph, recording the - correspondence between old and new morphs in the given dictionary. - This dictionary will be used to update intra-composite references - in the copy. See updateReferences(). - - Note: This default implementation copies ONLY morphs. If a morph - stores morphs in other properties that it wants to copy, then it - should override this method to do so. The same goes for morphs that - contain other complex data that should be copied when the morph is - duplicated. - */ - var c = this.copy(); - map.set(this, c); - this.children.forEach(function (m) { - c.add(m.copyRecordingReferences(map)); - }); - return c; -}; - -Morph.prototype.updateReferences = function (map) { - /* - Update intra-morph references within a composite morph that has - been copied. For example, if a button refers to morph X in the - orginal composite then the copy of that button in the new composite - should refer to the copy of X in new composite, not the original X. - */ - var property, value, reference; - for (var properties = Object.keys(this), l = properties.length, i = 0; i < l; ++i) { - property = properties[i]; - value = this[property]; - if (value && value.isMorph) { - reference = map.get(value); - if (reference) this[property] = reference; - } - } -}; - -if (typeof Map === 'undefined') { - // use normal objects + stringification if Map doesn't exist +(function () { + // don't overwrite the global Map with AssociativeMap + var Map = window.Map || AssociativeMap; + + Morph.prototype.copy = function () { + var c = copy(this); + c.parent = null; + c.children = []; + c.bounds = this.bounds.copy(); + return c; + }; Morph.prototype.fullCopy = function () { - var dict = {}, c; - c = this.copyRecordingReferences(dict); + /* + Produce a copy of me with my entire tree of submorphs. Morphs + mentioned more than once are all directed to a single new copy. + Other properties are also *shallow* copied, so you must override + to deep copy Arrays and (complex) Objects + */ + var map = new Map(), c; + c = this.copyRecordingReferences(map); c.forAllChildren(function (m) { - m.updateReferences(dict); + m.updateReferences(map); }); return c; }; - Morph.prototype.copyRecordingReferences = function (dict) { + Morph.prototype.copyRecordingReferences = function (map) { + /* + Recursively copy this entire composite morph, recording the + correspondence between old and new morphs in the given dictionary. + This dictionary will be used to update intra-composite references + in the copy. See updateReferences(). + + Note: This default implementation copies ONLY morphs. If a morph + stores morphs in other properties that it wants to copy, then it + should override this method to do so. The same goes for morphs that + contain other complex data that should be copied when the morph is + duplicated. + */ var c = this.copy(); - dict[this] = c; + map.set(this, c); this.children.forEach(function (m) { - c.add(m.copyRecordingReferences(dict)); + c.add(m.copyRecordingReferences(map)); }); return c; }; - Morph.prototype.updateReferences = function (dict) { + Morph.prototype.updateReferences = function (map) { + /* + Update intra-morph references within a composite morph that has + been copied. For example, if a button refers to morph X in the + orginal composite then the copy of that button in the new composite + should refer to the copy of X in new composite, not the original X. + */ var property, value, reference; for (var properties = Object.keys(this), l = properties.length, i = 0; i < l; ++i) { property = properties[i]; value = this[property]; if (value && value.isMorph) { - reference = dict[value]; + reference = map.get(value); if (reference) this[property] = reference; } } }; -} + + // associative array fallback for Map + + function AssociativeMap() { + this.keys = []; + this.values = []; + } + + AssociativeMap.prototype.get = function(key) { + for (var keys = this.keys, i = keys.length; i--;) { + if (keys[i] === key) return this.values[i]; + } + return undefined; + }; + + AssociativeMap.prototype.set = function(key, value) { + for (var keys = this.keys, i = keys.length; i--;) { + if (keys[i] === key) { + this.values[i] = value; + return; + } + } + keys.push(key); + this.values.push(value); + }; + +}()); // Morph dragging and dropping: -- cgit v1.3.1 From 58cae438bbd48f4e08f265917d4aada9e06e6cb6 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 25 Jun 2015 14:43:09 +0200 Subject: Simplify Morphic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * revert to “new” for object creation (for now) * take out fallback for missing Map --- morphic.js | 336 ++++++++++++++++++++++++++----------------------------------- 1 file changed, 143 insertions(+), 193 deletions(-) diff --git a/morphic.js b/morphic.js index e4df8f0..cb2aa32 100644 --- a/morphic.js +++ b/morphic.js @@ -829,7 +829,8 @@ }; If your new morph stores or references other morphs outside of the - submorph tree in other properties, you may need to override the default + submorph tree in other properties, be sure to also override the + default updateReferences() @@ -1035,7 +1036,7 @@ ---------------------- Joe Otto found and fixed many early bugs and taught me some tricks. Nathan Dinsmore contributed mouse wheel scrolling, cached - background texture handling and countless bug fixes. + background texture handling, countless bug fixes and optimizations. Ian Reynolds contributed backspace key handling for Chrome. Davide Della Casa contributed performance optimizations for Firefox. @@ -1047,7 +1048,7 @@ /*global window, HTMLCanvasElement, getMinimumFontHeight, FileReader, Audio, FileList, getBlurredShadowSupport*/ -var morphicVersion = '2015-May-01'; +var morphicVersion = '2015-June-25'; var modules = {}; // keep track of additional loaded modules var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug @@ -1257,7 +1258,7 @@ function copy(target) { target.constructor !== Object) { c = Object.create(target.constructor.prototype); keys = Object.keys(target); - for (l = keys.length, i = 0; i < l; ++i) { + for (l = keys.length, i = 0; i < l; i += 1) { property = keys[i]; c[property] = target[property]; } @@ -2158,7 +2159,7 @@ var TextMorph; // Morph inherits from Node: -Morph.prototype = Object.create(Node.prototype); +Morph.prototype = new Node(); Morph.prototype.constructor = Morph; Morph.uber = Node.prototype; @@ -2212,7 +2213,7 @@ Morph.prototype.init = function (noDraw) { this.isTemplate = false; this.acceptsDrops = false; this.noticesTransparentClick = false; - if (!noDraw) { this.drawNew(); } + if (!noDraw) {this.drawNew(); } this.fps = 0; this.customContextMenu = null; this.lastTime = Date.now(); @@ -2405,9 +2406,9 @@ Morph.prototype.moveBy = function (delta) { Morph.prototype.silentMoveBy = function (delta) { this.bounds = this.bounds.translateBy(delta); - for (var children = this.children, i = children.length; i--;) { - children[i].silentMoveBy(delta); - } + this.children.forEach(function (child) { + child.silentMoveBy(delta); + }); }; Morph.prototype.setPosition = function (aPoint) { @@ -2920,6 +2921,18 @@ Morph.prototype.addBack = function (aMorph) { this.addChildFirst(aMorph); }; +Morph.prototype.topMorphAt = function (point) { + var i, result; + if (!this.isVisible) {return null; } + for (i = this.children.length - 1; i >= 0; i -= 1) { + result = this.children[i].topMorphAt(point); + if (result) {return result; } + } + return this.bounds.containsPoint(point) && + (this.noticesTransparentClick || !this.isTransparentAt(point)) ? this + : null; +}; + Morph.prototype.topMorphSuchThat = function (predicate) { var next; if (predicate.call(null, this)) { @@ -2935,30 +2948,6 @@ Morph.prototype.topMorphSuchThat = function (predicate) { return null; }; -Morph.prototype.morphAt = function (aPoint) { - var morphs = this.allChildren().slice(0).reverse(), - result = null; - morphs.forEach(function (m) { - if (m.fullBounds().containsPoint(aPoint) && - (result === null)) { - result = m; - } - }); - return result; -}; - -/* - alternative - more elegant and possibly more - performant - solution for morphAt. - Has some issues, commented out for now - -Morph.prototype.morphAt = function (aPoint) { - return this.topMorphSuchThat(function (m) { - return m.fullBounds().containsPoint(aPoint); - }); -}; -*/ - Morph.prototype.overlappedMorphs = function () { //exclude the World var world = this.world(), @@ -3015,98 +3004,72 @@ Morph.prototype.isTransparentAt = function (aPoint) { // Morph duplicating: -(function () { - // don't overwrite the global Map with AssociativeMap - var Map = window.Map || AssociativeMap; - - Morph.prototype.copy = function () { - var c = copy(this); - c.parent = null; - c.children = []; - c.bounds = this.bounds.copy(); - return c; - }; +Morph.prototype.copy = function () { + var c = copy(this); + c.parent = null; + c.children = []; + c.bounds = this.bounds.copy(); + return c; +}; - Morph.prototype.fullCopy = function () { - /* - Produce a copy of me with my entire tree of submorphs. Morphs - mentioned more than once are all directed to a single new copy. - Other properties are also *shallow* copied, so you must override - to deep copy Arrays and (complex) Objects - */ - var map = new Map(), c; - c = this.copyRecordingReferences(map); - c.forAllChildren(function (m) { - m.updateReferences(map); - }); - return c; - }; +Morph.prototype.fullCopy = function () { + /* + Produce a copy of me with my entire tree of submorphs. Morphs + mentioned more than once are all directed to a single new copy. + Other properties are also *shallow* copied, so you must override + to deep copy Arrays and (complex) Objects + */ + var map = new Map(), c; + c = this.copyRecordingReferences(map); + c.forAllChildren(function (m) { + m.updateReferences(map); + }); + return c; +}; - Morph.prototype.copyRecordingReferences = function (map) { - /* - Recursively copy this entire composite morph, recording the - correspondence between old and new morphs in the given dictionary. - This dictionary will be used to update intra-composite references - in the copy. See updateReferences(). - - Note: This default implementation copies ONLY morphs. If a morph - stores morphs in other properties that it wants to copy, then it - should override this method to do so. The same goes for morphs that - contain other complex data that should be copied when the morph is - duplicated. - */ - var c = this.copy(); - map.set(this, c); - this.children.forEach(function (m) { - c.add(m.copyRecordingReferences(map)); - }); - return c; - }; +Morph.prototype.copyRecordingReferences = function (map) { + /* + Recursively copy this entire composite morph, recording the + correspondence between old and new morphs in the given dictionary. + This dictionary will be used to update intra-composite references + in the copy. See updateReferences(). + + Note: This default implementation copies ONLY morphs. If a morph + stores morphs in other properties that it wants to copy, then it + should override this method to do so. The same goes for morphs that + contain other complex data that should be copied when the morph is + duplicated. + */ + var c = this.copy(); + map.set(this, c); + this.children.forEach(function (m) { + c.add(m.copyRecordingReferences(map)); + }); + return c; +}; - Morph.prototype.updateReferences = function (map) { - /* - Update intra-morph references within a composite morph that has - been copied. For example, if a button refers to morph X in the - orginal composite then the copy of that button in the new composite - should refer to the copy of X in new composite, not the original X. - */ - var property, value, reference; - for (var properties = Object.keys(this), l = properties.length, i = 0; i < l; ++i) { - property = properties[i]; - value = this[property]; - if (value && value.isMorph) { - reference = map.get(value); - if (reference) this[property] = reference; - } +Morph.prototype.updateReferences = function (map) { + /* + Update intra-morph references within a composite morph that has + been copied. For example, if a button refers to morph X in the + orginal composite then the copy of that button in the new composite + should refer to the copy of X in new composite, not the original X. + */ + var properties = Object.keys(this), + l = properties.length, + property, + value, + reference, + i; + for (i = 0; i < l; i += 1) { + property = properties[i]; + value = this[property]; + if (value && value.isMorph) { + reference = map.get(value); + if (reference) { this[property] = reference; } } - }; - - // associative array fallback for Map - - function AssociativeMap() { - this.keys = []; - this.values = []; } - - AssociativeMap.prototype.get = function(key) { - for (var keys = this.keys, i = keys.length; i--;) { - if (keys[i] === key) return this.values[i]; - } - return undefined; - }; - - AssociativeMap.prototype.set = function(key, value) { - for (var keys = this.keys, i = keys.length; i--;) { - if (keys[i] === key) { - this.values[i] = value; - return; - } - } - keys.push(key); - this.values.push(value); - }; - -}()); +}; // Morph dragging and dropping: @@ -3713,7 +3676,7 @@ Morph.prototype.overlappingImage = function (otherMorph) { // ShadowMorph inherits from Morph: -ShadowMorph.prototype = Object.create(Morph.prototype); +ShadowMorph.prototype = new Morph(); ShadowMorph.prototype.constructor = ShadowMorph; ShadowMorph.uber = Morph.prototype; @@ -3723,13 +3686,17 @@ function ShadowMorph() { this.init(); } +ShadowMorph.prototype.topMorphAt = function () { + return null; +}; + // HandleMorph //////////////////////////////////////////////////////// // I am a resize / move handle that can be attached to any Morph // HandleMorph inherits from Morph: -HandleMorph.prototype = Object.create(Morph.prototype); +HandleMorph.prototype = new Morph(); HandleMorph.prototype.constructor = HandleMorph; HandleMorph.uber = Morph.prototype; @@ -3970,7 +3937,7 @@ var PenMorph; // PenMorph inherits from Morph: -PenMorph.prototype = Object.create(Morph.prototype); +PenMorph.prototype = new Morph(); PenMorph.prototype.constructor = PenMorph; PenMorph.uber = Morph.prototype; @@ -4202,7 +4169,7 @@ var ColorPaletteMorph; // ColorPaletteMorph inherits from Morph: -ColorPaletteMorph.prototype = Object.create(Morph.prototype); +ColorPaletteMorph.prototype = new Morph(); ColorPaletteMorph.prototype.constructor = ColorPaletteMorph; ColorPaletteMorph.uber = Morph.prototype; @@ -4320,7 +4287,7 @@ var GrayPaletteMorph; // GrayPaletteMorph inherits from ColorPaletteMorph: -GrayPaletteMorph.prototype = Object.create(ColorPaletteMorph.prototype); +GrayPaletteMorph.prototype = new ColorPaletteMorph(); GrayPaletteMorph.prototype.constructor = GrayPaletteMorph; GrayPaletteMorph.uber = ColorPaletteMorph.prototype; @@ -4351,7 +4318,7 @@ GrayPaletteMorph.prototype.drawNew = function () { // ColorPickerMorph inherits from Morph: -ColorPickerMorph.prototype = Object.create(Morph.prototype); +ColorPickerMorph.prototype = new Morph(); ColorPickerMorph.prototype.constructor = ColorPickerMorph; ColorPickerMorph.uber = Morph.prototype; @@ -4420,7 +4387,7 @@ var BlinkerMorph; // BlinkerMorph inherits from Morph: -BlinkerMorph.prototype = Object.create(Morph.prototype); +BlinkerMorph.prototype = new Morph(); BlinkerMorph.prototype.constructor = BlinkerMorph; BlinkerMorph.uber = Morph.prototype; @@ -4453,7 +4420,7 @@ var CursorMorph; // CursorMorph inherits from BlinkerMorph: -CursorMorph.prototype = Object.create(BlinkerMorph.prototype); +CursorMorph.prototype = new BlinkerMorph(); CursorMorph.prototype.constructor = CursorMorph; CursorMorph.uber = BlinkerMorph.prototype; @@ -4873,7 +4840,7 @@ var BoxMorph; // BoxMorph inherits from Morph: -BoxMorph.prototype = Object.create(Morph.prototype); +BoxMorph.prototype = new Morph(); BoxMorph.prototype.constructor = BoxMorph; BoxMorph.uber = Morph.prototype; @@ -5081,7 +5048,7 @@ var SpeechBubbleMorph; // SpeechBubbleMorph inherits from BoxMorph: -SpeechBubbleMorph.prototype = Object.create(BoxMorph.prototype); +SpeechBubbleMorph.prototype = new BoxMorph(); SpeechBubbleMorph.prototype.constructor = SpeechBubbleMorph; SpeechBubbleMorph.uber = BoxMorph.prototype; @@ -5381,7 +5348,7 @@ var CircleBoxMorph; // CircleBoxMorph inherits from Morph: -CircleBoxMorph.prototype = Object.create(Morph.prototype); +CircleBoxMorph.prototype = new Morph(); CircleBoxMorph.prototype.constructor = CircleBoxMorph; CircleBoxMorph.uber = Morph.prototype; @@ -5501,7 +5468,7 @@ var SliderButtonMorph; // SliderButtonMorph inherits from CircleBoxMorph: -SliderButtonMorph.prototype = Object.create(CircleBoxMorph.prototype); +SliderButtonMorph.prototype = new CircleBoxMorph(); SliderButtonMorph.prototype.constructor = SliderButtonMorph; SliderButtonMorph.uber = CircleBoxMorph.prototype; @@ -5713,7 +5680,7 @@ SliderButtonMorph.prototype.mouseMove = function () { // SliderMorph inherits from CircleBoxMorph: -SliderMorph.prototype = Object.create(CircleBoxMorph.prototype); +SliderMorph.prototype = new CircleBoxMorph(); SliderMorph.prototype.constructor = SliderMorph; SliderMorph.uber = CircleBoxMorph.prototype; @@ -6064,7 +6031,7 @@ var MouseSensorMorph; // MouseSensorMorph inherits from BoxMorph: -MouseSensorMorph.prototype = Object.create(BoxMorph.prototype); +MouseSensorMorph.prototype = new BoxMorph(); MouseSensorMorph.prototype.constructor = MouseSensorMorph; MouseSensorMorph.uber = BoxMorph.prototype; @@ -6138,7 +6105,7 @@ var TriggerMorph; // InspectorMorph inherits from BoxMorph: -InspectorMorph.prototype = Object.create(BoxMorph.prototype); +InspectorMorph.prototype = new BoxMorph(); InspectorMorph.prototype.constructor = InspectorMorph; InspectorMorph.uber = BoxMorph.prototype; @@ -6633,7 +6600,7 @@ var MenuItemMorph; // MenuMorph inherits from BoxMorph: -MenuMorph.prototype = Object.create(BoxMorph.prototype); +MenuMorph.prototype = new BoxMorph(); MenuMorph.prototype.constructor = MenuMorph; MenuMorph.uber = BoxMorph.prototype; @@ -6928,7 +6895,7 @@ MenuMorph.prototype.popUpCenteredInWorld = function (world) { // StringMorph inherits from Morph: -StringMorph.prototype = Object.create(Morph.prototype); +StringMorph.prototype = new Morph(); StringMorph.prototype.constructor = StringMorph; StringMorph.uber = Morph.prototype; @@ -7374,7 +7341,11 @@ StringMorph.prototype.selectionStartSlot = function () { }; StringMorph.prototype.clearSelection = function () { - if (!this.currentlySelecting && this.startMark === 0 && this.endMark === 0) return; + if (!this.currentlySelecting && + this.startMark === 0 && + this.endMark === 0) { + return; + } this.currentlySelecting = false; this.startMark = 0; this.endMark = 0; @@ -7464,7 +7435,7 @@ StringMorph.prototype.disableSelecting = function () { // TextMorph inherits from Morph: -TextMorph.prototype = Object.create(Morph.prototype); +TextMorph.prototype = new Morph(); TextMorph.prototype.constructor = TextMorph; TextMorph.uber = Morph.prototype; @@ -7989,7 +7960,7 @@ TextMorph.prototype.inspectIt = function () { // TriggerMorph inherits from Morph: -TriggerMorph.prototype = Object.create(Morph.prototype); +TriggerMorph.prototype = new Morph(); TriggerMorph.prototype.constructor = TriggerMorph; TriggerMorph.uber = Morph.prototype; @@ -8244,7 +8215,7 @@ var MenuItemMorph; // MenuItemMorph inherits from TriggerMorph: -MenuItemMorph.prototype = Object.create(TriggerMorph.prototype); +MenuItemMorph.prototype = new TriggerMorph(); MenuItemMorph.prototype.constructor = MenuItemMorph; MenuItemMorph.uber = TriggerMorph.prototype; @@ -8403,7 +8374,7 @@ MenuItemMorph.prototype.isSelectedListItem = function () { // Frames inherit from Morph: -FrameMorph.prototype = Object.create(Morph.prototype); +FrameMorph.prototype = new Morph(); FrameMorph.prototype.constructor = FrameMorph; FrameMorph.uber = Morph.prototype; @@ -8459,6 +8430,21 @@ FrameMorph.prototype.fullDrawOn = function (aCanvas, aRect) { }); }; +// FrameMorph navigation: + +FrameMorph.prototype.topMorphAt = function (point) { + var i, result; + if (!(this.isVisible && this.bounds.containsPoint(point))) { + return null; + } + for (i = this.children.length - 1; i >= 0; i -= 1) { + result = this.children[i].topMorphAt(point); + if (result) {return result; } + } + return this.noticesTransparentClick || + !this.isTransparentAt(point) ? this : null; +}; + // FrameMorph scrolling support: FrameMorph.prototype.submorphBounds = function () { @@ -8572,7 +8558,7 @@ FrameMorph.prototype.keepAllSubmorphsWithin = function () { // ScrollFrameMorph //////////////////////////////////////////////////// -ScrollFrameMorph.prototype = Object.create(FrameMorph.prototype); +ScrollFrameMorph.prototype = new FrameMorph(); ScrollFrameMorph.prototype.constructor = ScrollFrameMorph; ScrollFrameMorph.uber = FrameMorph.prototype; @@ -8893,19 +8879,19 @@ ScrollFrameMorph.prototype.mouseScroll = function (y, x) { // ScrollFrameMorph duplicating: ScrollFrameMorph.prototype.updateReferences = function (map) { - var self = this; + var myself = this; ScrollFrameMorph.uber.updateReferences.call(this, map); if (this.hBar) { this.hBar.action = function (num) { - self.contents.setPosition( - new Point(self.left() - num, self.contents.position().y) + myself.contents.setPosition( + new Point(myself.left() - num, myself.contents.position().y) ); }; } if (this.vBar) { this.vBar.action = function (num) { - self.contents.setPosition( - new Point(self.contents.position().x, self.top() - num) + myself.contents.setPosition( + new Point(myself.contents.position().x, myself.top() - num) ); }; } @@ -8938,7 +8924,7 @@ ScrollFrameMorph.prototype.toggleTextLineWrapping = function () { // ListMorph /////////////////////////////////////////////////////////// -ListMorph.prototype = Object.create(ScrollFrameMorph.prototype); +ListMorph.prototype = new ScrollFrameMorph(); ListMorph.prototype.constructor = ListMorph; ListMorph.uber = ScrollFrameMorph.prototype; @@ -9076,7 +9062,7 @@ ListMorph.prototype.setExtent = function (aPoint) { // StringFieldMorph inherit from FrameMorph: -StringFieldMorph.prototype = Object.create(FrameMorph.prototype); +StringFieldMorph.prototype = new FrameMorph(); StringFieldMorph.prototype.constructor = StringFieldMorph; StringFieldMorph.uber = FrameMorph.prototype; @@ -9176,7 +9162,7 @@ var BouncerMorph; // Bouncers inherit from Morph: -BouncerMorph.prototype = Object.create(Morph.prototype); +BouncerMorph.prototype = new Morph(); BouncerMorph.prototype.constructor = BouncerMorph; BouncerMorph.uber = Morph.prototype; @@ -9263,7 +9249,7 @@ BouncerMorph.prototype.step = function () { // HandMorph inherits from Morph: -HandMorph.prototype = Object.create(Morph.prototype); +HandMorph.prototype = new Morph(); HandMorph.prototype.constructor = HandMorph; HandMorph.uber = Morph.prototype; @@ -9290,59 +9276,24 @@ HandMorph.prototype.init = function (aWorld) { this.contextMenuEnabled = false; }; -HandMorph.prototype.changed = -HandMorph.prototype.fullChanged = function () { +HandMorph.prototype.changed = function () { var b; if (this.world !== null) { b = this.fullBounds(); if (!b.extent().eq(new Point())) { - this.world.broken.push(this.fullBounds().spread()); + this.world.broken.push(b.spread()); } } }; +HandMorph.prototype.fullChanged = HandMorph.prototype.changed; + // HandMorph navigation: -Morph.prototype.topMorphAt = function (p) { - if (!this.isVisible) return null; - for (var c = this.children, i = c.length; i--;) { - var result = c[i].topMorphAt(p); - if (result) return result; - } - return this.bounds.containsPoint(p) && (this.noticesTransparentClick || !this.isTransparentAt(p)) ? this : null; -}; -FrameMorph.prototype.topMorphAt = function (p) { - if (!(this.isVisible && this.bounds.containsPoint(p))) return null; - for (var c = this.children, i = c.length; i--;) { - var result = c[i].topMorphAt(p); - if (result) return result; - } - return this.noticesTransparentClick || !this.isTransparentAt(p) ? this : null; -}; -ShadowMorph.prototype.topMorphAt = function () { - return null; -}; HandMorph.prototype.morphAtPointer = function () { return this.world.topMorphAt(this.bounds.origin) || this.world; }; -/* - alternative - more elegant and possibly more - performant - solution for morphAtPointer. - Has some issues, commented out for now - -HandMorph.prototype.morphAtPointer = function () { - var myself = this; - return this.world.topMorphSuchThat(function (m) { - return m.visibleBounds().containsPoint(myself.bounds.origin) && - m.isVisible && - (m.noticesTransparentClick || - (! m.isTransparentAt(myself.bounds.origin))) && - (! (m instanceof ShadowMorph)); - }); -}; -*/ - HandMorph.prototype.allMorphsAtPointer = function () { var morphs = this.world.allChildren(), myself = this; @@ -9881,14 +9832,13 @@ HandMorph.prototype.destroyTemporaries = function () { }); }; - // WorldMorph ////////////////////////////////////////////////////////// // I represent the element // WorldMorph inherits from FrameMorph: -WorldMorph.prototype = Object.create(FrameMorph.prototype); +WorldMorph.prototype = new FrameMorph(); WorldMorph.prototype.constructor = WorldMorph; WorldMorph.uber = FrameMorph.prototype; -- cgit v1.3.1 From 4c21c9f187033172fa58a1bd3100d7c494617f10 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 25 Jun 2015 15:11:51 +0200 Subject: Revert to "new" for object creation and prepare for new release --- blocks.js | 68 ++++++++++++++++++++++++++++++------------------------------- byob.js | 28 ++++++++++++------------- gui.js | 22 ++++++++++---------- history.txt | 7 +++++++ lists.js | 22 ++++++++++---------- objects.js | 24 +++++++++++----------- paint.js | 14 +++++-------- store.js | 5 ++--- widgets.js | 20 +++++++++--------- xml.js | 8 +++++--- 10 files changed, 111 insertions(+), 107 deletions(-) mode change 100644 => 100755 xml.js diff --git a/blocks.js b/blocks.js index d023db8..ec01f96 100644 --- a/blocks.js +++ b/blocks.js @@ -155,8 +155,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph, Costume*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2015-June-08'; - +modules.blocks = '2015-June-25'; var SyntaxElementMorph; var BlockMorph; @@ -240,7 +239,7 @@ WorldMorph.prototype.customMorphs = function () { // SyntaxElementMorph inherits from Morph: -SyntaxElementMorph.prototype = Object.create(Morph.prototype); +SyntaxElementMorph.prototype = new Morph(); SyntaxElementMorph.prototype.constructor = SyntaxElementMorph; SyntaxElementMorph.uber = Morph.prototype; @@ -360,6 +359,10 @@ SyntaxElementMorph.prototype.init = function () { this.cachedInputs = null; }; +// SyntaxElementMorph stepping: + +SyntaxElementMorph.prototype.step = null; + // SyntaxElementMorph accessing: SyntaxElementMorph.prototype.parts = function () { @@ -621,10 +624,6 @@ SyntaxElementMorph.prototype.topBlock = function () { return this; }; -// SyntaxElementMorph stepping: - -SyntaxElementMorph.prototype.step = null; - // SyntaxElementMorph drag & drop: SyntaxElementMorph.prototype.reactToGrabOf = function (grabbedMorph) { @@ -1429,11 +1428,11 @@ SyntaxElementMorph.prototype.labelPart = function (spec) { false, // italic false, // isNumeric MorphicPreferences.isFlat ? - new Point() : this.embossing, // shadowOffset + new Point() : this.embossing, // shadowOffset this.color.darker(this.labelContrast), // shadowColor new Color(255, 255, 255), // color this.labelFontName // fontName - ); + ); } return part; }; @@ -1944,7 +1943,7 @@ SyntaxElementMorph.prototype.endLayout = function () { // BlockMorph inherits from SyntaxElementMorph: -BlockMorph.prototype = Object.create(SyntaxElementMorph.prototype); +BlockMorph.prototype = new SyntaxElementMorph(); BlockMorph.prototype.constructor = BlockMorph; BlockMorph.uber = SyntaxElementMorph.prototype; @@ -2065,7 +2064,8 @@ BlockMorph.prototype.setSpec = function (spec) { } part = myself.labelPart(word); myself.add(part); - if (!(part instanceof CommandSlotMorph || part instanceof StringMorph)) { + if (!(part instanceof CommandSlotMorph || + part instanceof StringMorph)) { part.drawNew(); } if (part instanceof RingMorph) { @@ -3266,7 +3266,7 @@ BlockMorph.prototype.snap = function () { // CommandBlockMorph inherits from BlockMorph: -CommandBlockMorph.prototype = Object.create(BlockMorph.prototype); +CommandBlockMorph.prototype = new BlockMorph(); CommandBlockMorph.prototype.constructor = CommandBlockMorph; CommandBlockMorph.uber = BlockMorph.prototype; @@ -3946,7 +3946,7 @@ CommandBlockMorph.prototype.drawBottomRightEdge = function (context) { // HatBlockMorph inherits from CommandBlockMorph: -HatBlockMorph.prototype = Object.create(CommandBlockMorph.prototype); +HatBlockMorph.prototype = new CommandBlockMorph(); HatBlockMorph.prototype.constructor = HatBlockMorph; HatBlockMorph.uber = CommandBlockMorph.prototype; @@ -4124,7 +4124,7 @@ HatBlockMorph.prototype.drawTopLeftEdge = function (context) { // ReporterBlockMorph inherits from BlockMorph: -ReporterBlockMorph.prototype = Object.create(BlockMorph.prototype); +ReporterBlockMorph.prototype = new BlockMorph(); ReporterBlockMorph.prototype.constructor = ReporterBlockMorph; ReporterBlockMorph.uber = BlockMorph.prototype; @@ -4648,7 +4648,7 @@ ReporterBlockMorph.prototype.drawDiamond = function (context) { // RingMorph inherits from ReporterBlockMorph: -RingMorph.prototype = Object.create(ReporterBlockMorph.prototype); +RingMorph.prototype = new ReporterBlockMorph(); RingMorph.prototype.constructor = RingMorph; RingMorph.uber = ReporterBlockMorph.prototype; @@ -4785,7 +4785,7 @@ RingMorph.prototype.fixBlockColor = function (nearest, isForced) { // ScriptsMorph inherits from FrameMorph: -ScriptsMorph.prototype = Object.create(FrameMorph.prototype); +ScriptsMorph.prototype = new FrameMorph(); ScriptsMorph.prototype.constructor = ScriptsMorph; ScriptsMorph.uber = FrameMorph.prototype; @@ -5325,7 +5325,7 @@ ScriptsMorph.prototype.reactToDropOf = function (droppedMorph, hand) { // ArgMorph inherits from SyntaxElementMorph: -ArgMorph.prototype = Object.create(SyntaxElementMorph.prototype); +ArgMorph.prototype = new SyntaxElementMorph(); ArgMorph.prototype.constructor = ArgMorph; ArgMorph.uber = SyntaxElementMorph.prototype; @@ -5438,7 +5438,7 @@ ArgMorph.prototype.isEmptySlot = function () { // CommandSlotMorph inherits from ArgMorph: -CommandSlotMorph.prototype = Object.create(ArgMorph.prototype); +CommandSlotMorph.prototype = new ArgMorph(); CommandSlotMorph.prototype.constructor = CommandSlotMorph; CommandSlotMorph.uber = ArgMorph.prototype; @@ -5888,7 +5888,7 @@ CommandSlotMorph.prototype.drawEdges = function (context) { // RingCommandSlotMorph inherits from CommandSlotMorph: -RingCommandSlotMorph.prototype = Object.create(CommandSlotMorph.prototype); +RingCommandSlotMorph.prototype = new CommandSlotMorph(); RingCommandSlotMorph.prototype.constructor = RingCommandSlotMorph; RingCommandSlotMorph.uber = CommandSlotMorph.prototype; @@ -6044,7 +6044,7 @@ RingCommandSlotMorph.prototype.drawFlat = function (context) { // CSlotMorph inherits from CommandSlotMorph: -CSlotMorph.prototype = Object.create(CommandSlotMorph.prototype); +CSlotMorph.prototype = new CommandSlotMorph(); CSlotMorph.prototype.constructor = CSlotMorph; CSlotMorph.uber = CommandSlotMorph.prototype; @@ -6467,7 +6467,7 @@ CSlotMorph.prototype.drawBottomEdge = function (context) { // InputSlotMorph inherits from ArgMorph: -InputSlotMorph.prototype = Object.create(ArgMorph.prototype); +InputSlotMorph.prototype = new ArgMorph(); InputSlotMorph.prototype.constructor = InputSlotMorph; InputSlotMorph.uber = ArgMorph.prototype; @@ -7403,7 +7403,7 @@ InputSlotMorph.prototype.drawRoundBorder = function (context) { // TemplateSlotMorph inherits from ArgMorph: -TemplateSlotMorph.prototype = Object.create(ArgMorph.prototype); +TemplateSlotMorph.prototype = new ArgMorph(); TemplateSlotMorph.prototype.constructor = TemplateSlotMorph; TemplateSlotMorph.uber = ArgMorph.prototype; @@ -7507,7 +7507,7 @@ TemplateSlotMorph.prototype.drawRounded = ReporterBlockMorph // BooleanSlotMorph inherits from ArgMorph: -BooleanSlotMorph.prototype = Object.create(ArgMorph.prototype); +BooleanSlotMorph.prototype = new ArgMorph(); BooleanSlotMorph.prototype.constructor = BooleanSlotMorph; BooleanSlotMorph.uber = ArgMorph.prototype; @@ -7664,7 +7664,7 @@ BooleanSlotMorph.prototype.isEmptySlot = function () { // ArrowMorph inherits from Morph: -ArrowMorph.prototype = Object.create(Morph.prototype); +ArrowMorph.prototype = new Morph(); ArrowMorph.prototype.constructor = ArrowMorph; ArrowMorph.uber = Morph.prototype; @@ -7734,7 +7734,7 @@ ArrowMorph.prototype.drawNew = function () { // TextSlotMorph inherits from InputSlotMorph: -TextSlotMorph.prototype = Object.create(InputSlotMorph.prototype); +TextSlotMorph.prototype = new InputSlotMorph(); TextSlotMorph.prototype.constructor = TextSlotMorph; TextSlotMorph.uber = InputSlotMorph.prototype; @@ -7817,7 +7817,7 @@ TextSlotMorph.prototype.layoutChanged = function () { // SymbolMorph inherits from Morph: -SymbolMorph.prototype = Object.create(Morph.prototype); +SymbolMorph.prototype = new Morph(); SymbolMorph.prototype.constructor = SymbolMorph; SymbolMorph.uber = Morph.prototype; @@ -9110,7 +9110,7 @@ SymbolMorph.prototype.drawSymbolRobot = function (canvas, color) { // ColorSlotMorph inherits from ArgMorph: -ColorSlotMorph.prototype = Object.create(ArgMorph.prototype); +ColorSlotMorph.prototype = new ArgMorph(); ColorSlotMorph.prototype.constructor = ColorSlotMorph; ColorSlotMorph.uber = ArgMorph.prototype; @@ -9218,7 +9218,7 @@ ColorSlotMorph.prototype.drawRectBorder = // BlockHighlightMorph inherits from Morph: -BlockHighlightMorph.prototype = Object.create(Morph.prototype); +BlockHighlightMorph.prototype = new Morph(); BlockHighlightMorph.prototype.constructor = BlockHighlightMorph; BlockHighlightMorph.uber = Morph.prototype; @@ -9243,7 +9243,7 @@ function BlockHighlightMorph() { // MultiArgMorph inherits from ArgMorph: -MultiArgMorph.prototype = Object.create(ArgMorph.prototype); +MultiArgMorph.prototype = new ArgMorph(); MultiArgMorph.prototype.constructor = MultiArgMorph; MultiArgMorph.uber = ArgMorph.prototype; @@ -9673,7 +9673,7 @@ MultiArgMorph.prototype.isEmptySlot = function () { // ArgLabelMorph inherits from ArgMorph: -ArgLabelMorph.prototype = Object.create(ArgMorph.prototype); +ArgLabelMorph.prototype = new ArgMorph(); ArgLabelMorph.prototype.constructor = ArgLabelMorph; ArgLabelMorph.uber = ArgMorph.prototype; @@ -9803,7 +9803,7 @@ ArgLabelMorph.prototype.isEmptySlot = function () { // FunctionSlotMorph inherits from ArgMorph: -FunctionSlotMorph.prototype = Object.create(ArgMorph.prototype); +FunctionSlotMorph.prototype = new ArgMorph(); FunctionSlotMorph.prototype.constructor = FunctionSlotMorph; FunctionSlotMorph.uber = ArgMorph.prototype; @@ -10184,7 +10184,7 @@ FunctionSlotMorph.prototype.drawDiamond = function (context) { // ReporterSlotMorph inherits from FunctionSlotMorph: -ReporterSlotMorph.prototype = Object.create(FunctionSlotMorph.prototype); +ReporterSlotMorph.prototype = new FunctionSlotMorph(); ReporterSlotMorph.prototype.constructor = ReporterSlotMorph; ReporterSlotMorph.uber = FunctionSlotMorph.prototype; @@ -10267,7 +10267,7 @@ ReporterSlotMorph.prototype.fixLayout = function () { // ReporterSlotMorph inherits from FunctionSlotMorph: -RingReporterSlotMorph.prototype = Object.create(ReporterSlotMorph.prototype); +RingReporterSlotMorph.prototype = new ReporterSlotMorph(); RingReporterSlotMorph.prototype.constructor = RingReporterSlotMorph; RingReporterSlotMorph.uber = ReporterSlotMorph.prototype; @@ -10655,7 +10655,7 @@ RingReporterSlotMorph.prototype.drawDiamond = function (context) { // CommentMorph inherits from BoxMorph: -CommentMorph.prototype = Object.create(BoxMorph.prototype); +CommentMorph.prototype = new BoxMorph(); CommentMorph.prototype.constructor = CommentMorph; CommentMorph.uber = BoxMorph.prototype; diff --git a/byob.js b/byob.js index 32d8969..4c39872 100644 --- a/byob.js +++ b/byob.js @@ -106,7 +106,7 @@ SymbolMorph, isNil*/ // Global stuff //////////////////////////////////////////////////////// -modules.byob = '2015-May-23'; +modules.byob = '2015-June-25'; // Declarations @@ -379,7 +379,7 @@ CustomBlockDefinition.prototype.scriptsPicture = function () { // CustomCommandBlockMorph inherits from CommandBlockMorph: -CustomCommandBlockMorph.prototype = Object.create(CommandBlockMorph.prototype); +CustomCommandBlockMorph.prototype = new CommandBlockMorph(); CustomCommandBlockMorph.prototype.constructor = CustomCommandBlockMorph; CustomCommandBlockMorph.uber = CommandBlockMorph.prototype; @@ -896,7 +896,7 @@ CustomCommandBlockMorph.prototype.alternatives = function () { // CustomReporterBlockMorph inherits from ReporterBlockMorph: -CustomReporterBlockMorph.prototype = Object.create(ReporterBlockMorph.prototype); +CustomReporterBlockMorph.prototype = new ReporterBlockMorph(); CustomReporterBlockMorph.prototype.constructor = CustomReporterBlockMorph; CustomReporterBlockMorph.uber = ReporterBlockMorph.prototype; @@ -1028,7 +1028,7 @@ CustomReporterBlockMorph.prototype.alternatives // JaggedBlockMorph inherits from ReporterBlockMorph: -JaggedBlockMorph.prototype = Object.create(ReporterBlockMorph.prototype); +JaggedBlockMorph.prototype = new ReporterBlockMorph(); JaggedBlockMorph.prototype.constructor = JaggedBlockMorph; JaggedBlockMorph.uber = ReporterBlockMorph.prototype; @@ -1177,7 +1177,7 @@ JaggedBlockMorph.prototype.drawEdges = function (context) { // BlockDialogMorph inherits from DialogBoxMorph: -BlockDialogMorph.prototype = Object.create(DialogBoxMorph.prototype); +BlockDialogMorph.prototype = new DialogBoxMorph(); BlockDialogMorph.prototype.constructor = BlockDialogMorph; BlockDialogMorph.uber = DialogBoxMorph.prototype; @@ -1624,7 +1624,7 @@ BlockDialogMorph.prototype.fixLayout = function () { // BlockEditorMorph inherits from DialogBoxMorph: -BlockEditorMorph.prototype = Object.create(DialogBoxMorph.prototype); +BlockEditorMorph.prototype = new DialogBoxMorph(); BlockEditorMorph.prototype.constructor = BlockEditorMorph; BlockEditorMorph.uber = DialogBoxMorph.prototype; @@ -1936,7 +1936,7 @@ BlockEditorMorph.prototype.fixLayout = function () { // PrototypeHatBlockMorph inherits from HatBlockMorph: -PrototypeHatBlockMorph.prototype = Object.create(HatBlockMorph.prototype); +PrototypeHatBlockMorph.prototype = new HatBlockMorph(); PrototypeHatBlockMorph.prototype.constructor = PrototypeHatBlockMorph; PrototypeHatBlockMorph.uber = HatBlockMorph.prototype; @@ -2146,7 +2146,7 @@ BlockLabelFragment.prototype.setSingleInputType = function (type) { // BlockLabelFragmentMorph inherits from StringMorph: -BlockLabelFragmentMorph.prototype = Object.create(StringMorph.prototype); +BlockLabelFragmentMorph.prototype = new StringMorph(); BlockLabelFragmentMorph.prototype.constructor = BlockLabelFragmentMorph; BlockLabelFragmentMorph.uber = StringMorph.prototype; @@ -2268,7 +2268,7 @@ BlockLabelFragmentMorph.prototype.userMenu = function () { // BlockLabelPlaceHolderMorph inherits from StringMorph: -BlockLabelPlaceHolderMorph.prototype = Object.create(StringMorph.prototype); +BlockLabelPlaceHolderMorph.prototype = new StringMorph(); BlockLabelPlaceHolderMorph.prototype.constructor = BlockLabelPlaceHolderMorph; BlockLabelPlaceHolderMorph.uber = StringMorph.prototype; @@ -2396,7 +2396,7 @@ BlockLabelPlaceHolderMorph.prototype.updateBlockLabel // BlockInputFragmentMorph inherits from TemplateSlotMorph: -BlockInputFragmentMorph.prototype = Object.create(TemplateSlotMorph.prototype); +BlockInputFragmentMorph.prototype = new TemplateSlotMorph(); BlockInputFragmentMorph.prototype.constructor = BlockInputFragmentMorph; BlockInputFragmentMorph.uber = TemplateSlotMorph.prototype; @@ -2426,7 +2426,7 @@ BlockInputFragmentMorph.prototype.updateBlockLabel // InputSlotDialogMorph inherits from DialogBoxMorph: -InputSlotDialogMorph.prototype = Object.create(DialogBoxMorph.prototype); +InputSlotDialogMorph.prototype = new DialogBoxMorph(); InputSlotDialogMorph.prototype.constructor = InputSlotDialogMorph; InputSlotDialogMorph.uber = DialogBoxMorph.prototype; @@ -3026,7 +3026,7 @@ InputSlotDialogMorph.prototype.show = function () { // VariableDialogMorph inherits from DialogBoxMorph: -VariableDialogMorph.prototype = Object.create(DialogBoxMorph.prototype); +VariableDialogMorph.prototype = new DialogBoxMorph(); VariableDialogMorph.prototype.constructor = VariableDialogMorph; VariableDialogMorph.uber = DialogBoxMorph.prototype; @@ -3145,7 +3145,7 @@ VariableDialogMorph.prototype.fixLayout = function () { // BlockExportDialogMorph inherits from DialogBoxMorph: -BlockExportDialogMorph.prototype = Object.create(DialogBoxMorph.prototype); +BlockExportDialogMorph.prototype = new DialogBoxMorph(); BlockExportDialogMorph.prototype.constructor = BlockExportDialogMorph; BlockExportDialogMorph.uber = DialogBoxMorph.prototype; @@ -3327,7 +3327,7 @@ BlockExportDialogMorph.prototype.fixLayout // BlockImportDialogMorph inherits from DialogBoxMorph // and pseudo-inherits from BlockExportDialogMorph: -BlockImportDialogMorph.prototype = Object.create(DialogBoxMorph.prototype); +BlockImportDialogMorph.prototype = new DialogBoxMorph(); BlockImportDialogMorph.prototype.constructor = BlockImportDialogMorph; BlockImportDialogMorph.uber = DialogBoxMorph.prototype; diff --git a/gui.js b/gui.js index 89e2d89..f50fd47 100644 --- a/gui.js +++ b/gui.js @@ -69,7 +69,7 @@ SpeechBubbleMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2015-May-18'; +modules.gui = '2015-June-25'; // Declarations @@ -88,7 +88,7 @@ var JukeboxMorph; // IDE_Morph inherits from Morph: -IDE_Morph.prototype = Object.create(Morph.prototype); +IDE_Morph.prototype = new Morph(); IDE_Morph.prototype.constructor = IDE_Morph; IDE_Morph.uber = Morph.prototype; @@ -2614,7 +2614,7 @@ IDE_Morph.prototype.aboutSnap = function () { module, btn1, btn2, btn3, btn4, licenseBtn, translatorsBtn, world = this.world(); - aboutTxt = 'Snap! 4.0\nBuild Your Own Blocks\n\n' + aboutTxt = 'Snap! 4.0.1\nBuild Your Own Blocks\n\n' + 'Copyright \u24B8 2015 Jens M\u00F6nig and ' + 'Brian Harvey\n' + 'jens@moenig.org, bh@cs.berkeley.edu\n\n' @@ -2648,7 +2648,7 @@ IDE_Morph.prototype.aboutSnap = function () { creditsTxt = localize('Contributors') + '\n\nNathan Dinsmore: Saving/Loading, Snap-Logo Design, ' - + 'countless bugfixes' + + 'countless bugfixes and optimizations' + '\nKartik Chandra: Paint Editor' + '\nMichael Ball: Time/Date UI, many bugfixes' + '\n"Ava" Yuan Yuan: Graphic Effects' @@ -4274,7 +4274,7 @@ IDE_Morph.prototype.prompt = function (message, callback, choices, key) { // ProjectDialogMorph inherits from DialogBoxMorph: -ProjectDialogMorph.prototype = Object.create(DialogBoxMorph.prototype); +ProjectDialogMorph.prototype = new DialogBoxMorph(); ProjectDialogMorph.prototype.constructor = ProjectDialogMorph; ProjectDialogMorph.uber = DialogBoxMorph.prototype; @@ -5181,7 +5181,7 @@ ProjectDialogMorph.prototype.fixLayout = function () { // SpriteIconMorph inherits from ToggleButtonMorph (Widgets) -SpriteIconMorph.prototype = Object.create(ToggleButtonMorph.prototype); +SpriteIconMorph.prototype = new ToggleButtonMorph(); SpriteIconMorph.prototype.constructor = SpriteIconMorph; SpriteIconMorph.uber = ToggleButtonMorph.prototype; @@ -5571,7 +5571,7 @@ SpriteIconMorph.prototype.copySound = function (sound) { // CostumeIconMorph inherits from ToggleButtonMorph (Widgets) // ... and copies methods from SpriteIconMorph -CostumeIconMorph.prototype = Object.create(ToggleButtonMorph.prototype); +CostumeIconMorph.prototype = new ToggleButtonMorph(); CostumeIconMorph.prototype.constructor = CostumeIconMorph; CostumeIconMorph.uber = ToggleButtonMorph.prototype; @@ -5782,7 +5782,7 @@ CostumeIconMorph.prototype.prepareToBeGrabbed = function () { // TurtleIconMorph inherits from ToggleButtonMorph (Widgets) // ... and copies methods from SpriteIconMorph -TurtleIconMorph.prototype = Object.create(ToggleButtonMorph.prototype); +TurtleIconMorph.prototype = new ToggleButtonMorph(); TurtleIconMorph.prototype.constructor = TurtleIconMorph; TurtleIconMorph.uber = ToggleButtonMorph.prototype; @@ -5965,7 +5965,7 @@ TurtleIconMorph.prototype.userMenu = function () { // WardrobeMorph inherits from ScrollFrameMorph -WardrobeMorph.prototype = Object.create(ScrollFrameMorph.prototype); +WardrobeMorph.prototype = new ScrollFrameMorph(); WardrobeMorph.prototype.constructor = WardrobeMorph; WardrobeMorph.uber = ScrollFrameMorph.prototype; @@ -6148,7 +6148,7 @@ WardrobeMorph.prototype.reactToDropOf = function (icon) { // SoundIconMorph inherits from ToggleButtonMorph (Widgets) // ... and copies methods from SpriteIconMorph -SoundIconMorph.prototype = Object.create(ToggleButtonMorph.prototype); +SoundIconMorph.prototype = new ToggleButtonMorph(); SoundIconMorph.prototype.constructor = SoundIconMorph; SoundIconMorph.uber = ToggleButtonMorph.prototype; @@ -6356,7 +6356,7 @@ SoundIconMorph.prototype.prepareToBeGrabbed = function () { // JukeboxMorph instance creation -JukeboxMorph.prototype = Object.create(ScrollFrameMorph.prototype); +JukeboxMorph.prototype = new ScrollFrameMorph(); JukeboxMorph.prototype.constructor = JukeboxMorph; JukeboxMorph.uber = ScrollFrameMorph.prototype; diff --git a/history.txt b/history.txt index 1262a28..9d9c00c 100755 --- a/history.txt +++ b/history.txt @@ -2516,3 +2516,10 @@ ______ 150608 ------ * Blocks: Fixed #820 + +150625 +------ +* Morphic, Objects, Blocks, XML: Optimizations and dramatic speed-up. Thanks, Nathan!! +* Objects: push maximum clone count up to 1000, tweak Note::play + +=== Release v4.0.1 === diff --git a/lists.js b/lists.js index 769b8b3..6fc9545 100644 --- a/lists.js +++ b/lists.js @@ -7,7 +7,7 @@ written by Jens Mönig and Brian Harvey jens@moenig.org, bh@cs.berkeley.edu - Copyright (C) 2014 by Jens Mönig and Brian Harvey + Copyright (C) 2015 by Jens Mönig and Brian Harvey This file is part of Snap!. @@ -61,7 +61,7 @@ PushButtonMorph, SyntaxElementMorph, Color, Point, WatcherMorph, StringMorph, SpriteMorph, ScrollFrameMorph, CellMorph, ArrowMorph, MenuMorph, snapEquals, Morph, isNil, localize, MorphicPreferences*/ -modules.lists = '2014-November-20'; +modules.lists = '2015-June-25'; var List; var ListWatcherMorph; @@ -363,7 +363,7 @@ List.prototype.equalTo = function (other) { // ListWatcherMorph inherits from BoxMorph: -ListWatcherMorph.prototype = Object.create(BoxMorph.prototype); +ListWatcherMorph.prototype = new BoxMorph(); ListWatcherMorph.prototype.constructor = ListWatcherMorph; ListWatcherMorph.uber = BoxMorph.prototype; @@ -388,13 +388,6 @@ ListWatcherMorph.prototype.init = function (list, parentCell) { this.lastCell = null; this.parentCell = parentCell || null; // for circularity detection - ListWatcherMorph.uber.init.call( - this, - SyntaxElementMorph.prototype.rounding, - 1.000001, // shadow bug in Chrome, - new Color(120, 120, 120) - ); - // elements declarations this.label = new StringMorph( localize('length: ') + this.list.length(), @@ -443,6 +436,13 @@ ListWatcherMorph.prototype.init = function (list, parentCell) { this.plusButton.drawNew(); this.plusButton.fixLayout(); + ListWatcherMorph.uber.init.call( + this, + SyntaxElementMorph.prototype.rounding, + 1.000001, // shadow bug in Chrome, + new Color(120, 120, 120) + ); + this.color = new Color(220, 220, 220); this.isDraggable = true; this.setExtent(new Point(80, 70).multiplyBy( @@ -634,7 +634,7 @@ ListWatcherMorph.prototype.setStartIndex = function (index) { }; ListWatcherMorph.prototype.fixLayout = function () { - if (!this.label) return; + if (!this.label) {return; } Morph.prototype.trackChanges = false; if (this.frame) { this.arrangeCells(); diff --git a/objects.js b/objects.js index 1e8060e..8eeb236 100644 --- a/objects.js +++ b/objects.js @@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2015-May-18'; +modules.objects = '2015-June-25'; var SpriteMorph; var StageMorph; @@ -147,7 +147,7 @@ var SpriteHighlightMorph; // SpriteMorph inherits from PenMorph: -SpriteMorph.prototype = Object.create(PenMorph.prototype); +SpriteMorph.prototype = new PenMorph(); SpriteMorph.prototype.constructor = SpriteMorph; SpriteMorph.uber = PenMorph.prototype; @@ -2718,7 +2718,7 @@ SpriteMorph.prototype.remove = function () { SpriteMorph.prototype.createClone = function () { var stage = this.parentThatIsA(StageMorph); - if (stage && stage.cloneCount <= 300) { + if (stage && stage.cloneCount <= 1000) { this.fullCopy().clonify(stage); } }; @@ -4289,7 +4289,7 @@ SpriteMorph.prototype.doScreenshot = function (imgSource, data) { // SpriteHighlightMorph inherits from Morph: -SpriteHighlightMorph.prototype = Object.create(Morph.prototype); +SpriteHighlightMorph.prototype = new Morph(); SpriteHighlightMorph.prototype.constructor = SpriteHighlightMorph; SpriteHighlightMorph.uber = Morph.prototype; @@ -4307,7 +4307,7 @@ function SpriteHighlightMorph() { // StageMorph inherits from FrameMorph: -StageMorph.prototype = Object.create(FrameMorph.prototype); +StageMorph.prototype = new FrameMorph(); StageMorph.prototype.constructor = StageMorph; StageMorph.uber = FrameMorph.prototype; @@ -5669,7 +5669,7 @@ StageMorph.prototype.replaceDoubleDefinitionsFor // SpriteBubbleMorph inherits from SpeechBubbleMorph: -SpriteBubbleMorph.prototype = Object.create(SpeechBubbleMorph.prototype); +SpriteBubbleMorph.prototype = new SpeechBubbleMorph(); SpriteBubbleMorph.prototype.constructor = SpriteBubbleMorph; SpriteBubbleMorph.uber = SpeechBubbleMorph.prototype; @@ -6168,7 +6168,7 @@ Costume.prototype.isTainted = function () { // SVG_Costume inherits from Costume: -SVG_Costume.prototype = Object.create(Costume.prototype); +SVG_Costume.prototype = new Costume(); SVG_Costume.prototype.constructor = SVG_Costume; SVG_Costume.uber = Costume.prototype; @@ -6219,7 +6219,7 @@ SVG_Costume.prototype.shrinkToFit = function (extentPoint) { // CostumeEditorMorph inherits from Morph: -CostumeEditorMorph.prototype = Object.create(Morph.prototype); +CostumeEditorMorph.prototype = new Morph(); CostumeEditorMorph.prototype.constructor = CostumeEditorMorph; CostumeEditorMorph.uber = Morph.prototype; @@ -6429,7 +6429,7 @@ Note.prototype.play = function () { if (!this.oscillator.stop) { this.oscillator.stop = this.oscillator.noteOff; } - this.oscillator.type = 0; + this.oscillator.type = 'sine'; this.oscillator.frequency.value = Math.pow(2, (this.pitch - 69) / 12) * 440; this.oscillator.connect(this.gainNode); @@ -6454,7 +6454,7 @@ Note.prototype.stop = function () { // CellMorph inherits from BoxMorph: -CellMorph.prototype = Object.create(BoxMorph.prototype); +CellMorph.prototype = new BoxMorph(); CellMorph.prototype.constructor = CellMorph; CellMorph.uber = BoxMorph.prototype; @@ -6794,7 +6794,7 @@ CellMorph.prototype.mouseClickLeft = function (pos) { // WatcherMorph inherits from BoxMorph: -WatcherMorph.prototype = Object.create(BoxMorph.prototype); +WatcherMorph.prototype = new BoxMorph(); WatcherMorph.prototype.constructor = WatcherMorph; WatcherMorph.uber = BoxMorph.prototype; @@ -7281,7 +7281,7 @@ WatcherMorph.prototype.drawNew = function () { // StagePrompterMorph inherits from BoxMorph: -StagePrompterMorph.prototype = Object.create(BoxMorph.prototype); +StagePrompterMorph.prototype = new BoxMorph(); StagePrompterMorph.prototype.constructor = StagePrompterMorph; StagePrompterMorph.uber = BoxMorph.prototype; diff --git a/paint.js b/paint.js index 6e4ae8b..6d9b09c 100644 --- a/paint.js +++ b/paint.js @@ -5,7 +5,7 @@ inspired by the Scratch paint editor. written by Kartik Chandra - Copyright (C) 2014 by Kartik Chandra + Copyright (C) 2015 by Kartik Chandra This file is part of Snap!. @@ -69,7 +69,7 @@ // Global stuff //////////////////////////////////////////////////////// -modules.paint = '2014-September-29'; +modules.paint = '2015-June-25'; // Declarations @@ -81,7 +81,7 @@ var PaintColorPickerMorph; // A complete paint editor -PaintEditorMorph.prototype = Object.create(DialogBoxMorph.prototype); +PaintEditorMorph.prototype = new DialogBoxMorph(); PaintEditorMorph.prototype.constructor = PaintEditorMorph; PaintEditorMorph.uber = DialogBoxMorph.prototype; @@ -92,7 +92,6 @@ function PaintEditorMorph() { } PaintEditorMorph.prototype.init = function () { - PaintEditorMorph.uber.init.call(this); // additional properties: this.paper = null; // paint canvas this.oncancel = null; @@ -477,7 +476,7 @@ PaintEditorMorph.prototype.getUserColor = function () { // A large hsl color picker -PaintColorPickerMorph.prototype = Object.create(Morph.prototype); +PaintColorPickerMorph.prototype = new Morph(); PaintColorPickerMorph.prototype.constructor = PaintColorPickerMorph; PaintColorPickerMorph.uber = Morph.prototype; @@ -486,7 +485,6 @@ function PaintColorPickerMorph(extent, action) { } PaintColorPickerMorph.prototype.init = function (extent, action) { - PaintColorPickerMorph.uber.init.call(this); this.setExtent(extent || new Point(200, 100)); this.action = action || nop; this.drawNew(); @@ -554,7 +552,7 @@ PaintColorPickerMorph.prototype.mouseMove = modify its image, based on a 'tool' property. */ -PaintCanvasMorph.prototype = Object.create(Morph.prototype); +PaintCanvasMorph.prototype = new Morph(); PaintCanvasMorph.prototype.constructor = PaintCanvasMorph; PaintCanvasMorph.uber = Morph.prototype; @@ -563,7 +561,6 @@ function PaintCanvasMorph(shift) { } PaintCanvasMorph.prototype.init = function (shift) { - PaintCanvasMorph.uber.init.call(this); this.rotationCenter = new Point(240, 180); this.dragRect = null; this.previousDragPoint = null; @@ -964,7 +961,6 @@ PaintCanvasMorph.prototype.buildContents = function () { }; PaintCanvasMorph.prototype.drawNew = function () { - if (!this.background) return; var can = newCanvas(this.extent()); this.merge(this.background, can); this.merge(this.paper, can); diff --git a/store.js b/store.js index a45c801..e73ba9f 100644 --- a/store.js +++ b/store.js @@ -61,7 +61,7 @@ SyntaxElementMorph, Variable*/ // Global stuff //////////////////////////////////////////////////////// -modules.store = '2015-April-26'; +modules.store = '2015-June-25'; // XML_Serializer /////////////////////////////////////////////////////// @@ -246,7 +246,7 @@ var SnapSerializer; // SnapSerializer inherits from XML_Serializer: -SnapSerializer.prototype = Object.create(XML_Serializer.prototype); +SnapSerializer.prototype = new XML_Serializer(); SnapSerializer.prototype.constructor = SnapSerializer; SnapSerializer.uber = XML_Serializer.prototype; @@ -274,7 +274,6 @@ SnapSerializer.prototype.watcherLabels = { // SnapSerializer instance creation: function SnapSerializer() { - XML_Serializer.call(this); this.init(); } diff --git a/widgets.js b/widgets.js index 2f96f2c..a8644af 100644 --- a/widgets.js +++ b/widgets.js @@ -7,7 +7,7 @@ written by Jens Mönig jens@moenig.org - Copyright (C) 2014 by Jens Mönig + Copyright (C) 2015 by Jens Mönig This file is part of Snap!. @@ -74,7 +74,7 @@ HTMLCanvasElement, fontHeight, SymbolMorph, localize, SpeechBubbleMorph, ArrowMorph, MenuMorph, isString, isNil, SliderMorph, MorphicPreferences, ScrollFrameMorph*/ -modules.widgets = '2014-February-13'; +modules.widgets = '2015-June-25'; var PushButtonMorph; var ToggleButtonMorph; @@ -91,7 +91,7 @@ var InputFieldMorph; // PushButtonMorph inherits from TriggerMorph: -PushButtonMorph.prototype = Object.create(TriggerMorph.prototype); +PushButtonMorph.prototype = new TriggerMorph(); PushButtonMorph.prototype.constructor = PushButtonMorph; PushButtonMorph.uber = TriggerMorph.prototype; @@ -476,7 +476,7 @@ PushButtonMorph.prototype.createLabel = function () { // ToggleButtonMorph inherits from PushButtonMorph: -ToggleButtonMorph.prototype = Object.create(PushButtonMorph.prototype); +ToggleButtonMorph.prototype = new PushButtonMorph(); ToggleButtonMorph.prototype.constructor = ToggleButtonMorph; ToggleButtonMorph.uber = PushButtonMorph.prototype; @@ -900,7 +900,7 @@ ToggleButtonMorph.prototype.show = function () { // TabMorph inherits from ToggleButtonMorph: -TabMorph.prototype = Object.create(ToggleButtonMorph.prototype); +TabMorph.prototype = new ToggleButtonMorph(); TabMorph.prototype.constructor = TabMorph; TabMorph.uber = ToggleButtonMorph.prototype; @@ -1022,7 +1022,7 @@ TabMorph.prototype.drawEdges = function ( // ToggleMorph inherits from PushButtonMorph: -ToggleMorph.prototype = Object.create(PushButtonMorph.prototype); +ToggleMorph.prototype = new PushButtonMorph(); ToggleMorph.prototype.constructor = ToggleMorph; ToggleMorph.uber = PushButtonMorph.prototype; @@ -1270,7 +1270,7 @@ ToggleMorph.prototype.show = ToggleButtonMorph.prototype.show; // ToggleElementMorph inherits from TriggerMorph: -ToggleElementMorph.prototype = Object.create(TriggerMorph.prototype); +ToggleElementMorph.prototype = new TriggerMorph(); ToggleElementMorph.prototype.constructor = ToggleElementMorph; ToggleElementMorph.uber = TriggerMorph.prototype; @@ -1440,7 +1440,7 @@ ToggleElementMorph.prototype.mouseClickLeft // DialogBoxMorph inherits from Morph: -DialogBoxMorph.prototype = Object.create(Morph.prototype); +DialogBoxMorph.prototype = new Morph(); DialogBoxMorph.prototype.constructor = DialogBoxMorph; DialogBoxMorph.uber = Morph.prototype; @@ -2866,7 +2866,7 @@ DialogBoxMorph.prototype.outlinePathBody = function (context, radius) { // AlignmentMorph inherits from Morph: -AlignmentMorph.prototype = Object.create(Morph.prototype); +AlignmentMorph.prototype = new Morph(); AlignmentMorph.prototype.constructor = AlignmentMorph; AlignmentMorph.uber = Morph.prototype; @@ -2940,7 +2940,7 @@ AlignmentMorph.prototype.fixLayout = function () { // InputFieldMorph inherits from Morph: -InputFieldMorph.prototype = Object.create(Morph.prototype); +InputFieldMorph.prototype = new Morph(); InputFieldMorph.prototype.constructor = InputFieldMorph; InputFieldMorph.uber = Morph.prototype; diff --git a/xml.js b/xml.js old mode 100644 new mode 100755 index 16b03f0..b80f520 --- a/xml.js +++ b/xml.js @@ -7,7 +7,7 @@ written by Jens Mönig jens@moenig.org - Copyright (C) 2014 by Jens Mönig + Copyright (C) 2015 by Jens Mönig This file is part of Snap!. @@ -57,7 +57,9 @@ Nathan Dinsmore contributed to the design and implemented a first working version of a complete XMLSerializer. I have taken much of the overall design and many of the functions and methods in this file from - Nathan's fine original prototype. + Nathan's fine original prototype. Recently Nathan has once again + worked his magic on the parser and optimized it by an order of + magnitude. */ @@ -65,7 +67,7 @@ // Global stuff //////////////////////////////////////////////////////// -modules.xml = '2014-January-09'; +modules.xml = '2015-June-25'; // Declarations -- cgit v1.3.1 From 8a7bc380a8df03f13133aae98654db6df51ccded Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 25 Jun 2015 15:20:05 +0200 Subject: wrap credits tab in "about" Dialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit to accommodate for @nathan ’s abundant contributions :-) --- gui.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui.js b/gui.js index f50fd47..59d0de7 100644 --- a/gui.js +++ b/gui.js @@ -2648,7 +2648,7 @@ IDE_Morph.prototype.aboutSnap = function () { creditsTxt = localize('Contributors') + '\n\nNathan Dinsmore: Saving/Loading, Snap-Logo Design, ' - + 'countless bugfixes and optimizations' + + '\ncountless bugfixes and optimizations' + '\nKartik Chandra: Paint Editor' + '\nMichael Ball: Time/Date UI, many bugfixes' + '\n"Ava" Yuan Yuan: Graphic Effects' -- cgit v1.3.1 From f4ff1056eae012b9a257c7dea88af3d007012632 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 25 Jun 2015 15:30:58 +0200 Subject: update threads.js version --- threads.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/threads.js b/threads.js index efe9ba4..edbe2cf 100644 --- a/threads.js +++ b/threads.js @@ -83,7 +83,7 @@ ArgLabelMorph, localize, XML_Element, hex_sha512*/ // Global stuff //////////////////////////////////////////////////////// -modules.threads = '2015-May-01'; +modules.threads = '2015-June-25'; var ThreadManager; var Process; @@ -2641,7 +2641,8 @@ Process.prototype.reportTimer = function () { // Process Dates and times in Snap Process.prototype.reportDate = function (datefn) { - var inputFn = this.inputOption(datefn), + var currDate, func, result, + inputFn = this.inputOption(datefn), // Map block options to built-in functions dateMap = { 'year' : 'getFullYear', @@ -2655,16 +2656,14 @@ Process.prototype.reportDate = function (datefn) { }; if (!dateMap[inputFn]) { return ''; } - - var currDate = new Date(), - func = dateMap[inputFn], - result = currDate[func](); + currDate = new Date(); + func = dateMap[inputFn]; + result = currDate[func](); // Show months as 1-12 and days as 1-7 if (inputFn === 'month' || inputFn === 'day of week') { result += 1; } - return result; }; -- cgit v1.3.1 From 7c8dd2b4e89ca10168df128df80edc14a60fcf13 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 25 Jun 2015 15:36:21 +0200 Subject: remove some spaces --- objects.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/objects.js b/objects.js index 118e3c8..3f95385 100644 --- a/objects.js +++ b/objects.js @@ -3509,9 +3509,9 @@ SpriteMorph.prototype.allHatBlocksFor = function (message) { if (morph.selector) { if (morph.selector === 'receiveMessage') { event = morph.inputs()[0].evaluate(); - return event === message - || (event instanceof Array - && message !== '__shout__go__' + return event === message + || (event instanceof Array + && message !== '__shout__go__' && message !== '__clone__init__'); } if (morph.selector === 'receiveGo') { -- cgit v1.3.1 From 87c9655335a688bf5ec52127ce1fde46d4c60d58 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 25 Jun 2015 15:48:26 +0200 Subject: add some spaces to satisfy old.jslint.com :-) --- gui.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/gui.js b/gui.js index b4f0faa..0fae8d3 100644 --- a/gui.js +++ b/gui.js @@ -84,8 +84,8 @@ var JukeboxMorph; // Get the full url without "snap.html" var baseUrl = document.URL.split('/'); -baseUrl.pop(baseUrl.length-1); -baseUrl = baseUrl.join('/')+'/'; +baseUrl.pop(baseUrl.length - 1); +baseUrl = baseUrl.join('/') + '/'; // IDE_Morph /////////////////////////////////////////////////////////// @@ -4834,8 +4834,7 @@ ProjectDialogMorph.prototype.openProject = function () { if (this.source === 'cloud') { this.openCloudProject(proj); } else if (this.source === 'examples') { - src = this.ide.getURL(baseUrl + 'Examples/' + proj.name + '.xml' - ); + src = this.ide.getURL(baseUrl + 'Examples/' + proj.name + '.xml'); this.ide.openProjectString(src); this.destroy(); } else { // 'local' -- cgit v1.3.1 From 8b9e7ea4eafb86f02db3b8891ee937233d9fa4b0 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 25 Jun 2015 16:00:17 +0200 Subject: update French translation, thanks, Frédéric Bonnaud! MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lang-fr.js | 154 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- locale.js | 4 +- 2 files changed, 151 insertions(+), 7 deletions(-) diff --git a/lang-fr.js b/lang-fr.js index 4198bf7..20da480 100644 --- a/lang-fr.js +++ b/lang-fr.js @@ -185,7 +185,7 @@ SnapTranslator.dict.fr = { 'translator_e-mail': 'i.scool@mac.com', // optional 'last_changed': - '2014-02-04', // this, too, will appear in the Translators tab + '2015-06-25', // this, too, will appear in the Translators tab // GUI // control bar: @@ -392,7 +392,7 @@ SnapTranslator.dict.fr = { 'clear': 'effacer tout', 'pen down': - 'stylo en position d\u0027\u00EAcriture', + 'stylo en position d\u0027\u00E9criture', 'pen up': 'relever le stylo', 'set pen color to %clr': @@ -419,6 +419,8 @@ SnapTranslator.dict.fr = { 'Quand %keyHat est press\u00E9', 'when I am clicked': 'Quand je suis press\u00E9 ', + 'when I am %interaction': + 'Quand je suis %interaction', 'when I receive %msgHat': 'Quand je re\u00E7ois %msgHat', 'broadcast %msg': @@ -447,6 +449,10 @@ SnapTranslator.dict.fr = { 'arr\u00EAter le bloc', 'stop script': 'arr\u00EAter le script', + 'stop %stopOthersChoices': + 'arr\u00EAter %stopOthersChoices', + 'stop %stopChoices': + 'arr\u00EAter %stopChoices', 'stop all %stop': 'arr\u00EAter tout %stop', 'run %cmdRing %inputs': @@ -469,8 +475,16 @@ SnapTranslator.dict.fr = { 'moi-m\u00EAme', 'delete this clone': 'supprime ce clone', - 'pause all': - 'mettre en pause', + 'pause all %pause': + 'mettre en pause %pause', + 'all but this script': + 'tout sauf ce lutin', + 'other scripts in sprite': + 'les autres scripts de ce lutin', + 'this script': + 'ce script', + 'this block': + 'ce bloc', // sensing: 'touching %col ?': @@ -958,6 +972,8 @@ SnapTranslator.dict.fr = { 'tabulations', 'cr': 'retours de ligne', + 'letter': + 'lettres', // About Snap 'About Snap': @@ -1162,5 +1178,133 @@ SnapTranslator.dict.fr = { 'last': 'dernier', 'any': - 'n\u0027importe quel' + 'n\u0027importe quel', + + // miscellaneous + 'find blocks...': + 'chercher des blocs...', + 'hide primitives': + 'cacher les primitives', + 'show primitives': + 'montrer les primitives', + 'Login...': + 'Connexion...', + 'Signup...': + 'S\u0027enregistrer...', + 'Reset Password...': + 'Remise \u00E0 z\u00E9ro du mot de passe', + 'show all': + 'tout montrer', + 'pic...': + 'image...', + 'open a new window\nwith a picture of the stage': + 'ouvre une nouvelle fen\u00EAtre\navec une image de la sc\u00E8ne', + 'scripts pic...': + 'image des scripts...', + 'open a new window\nwith a picture of all scripts': + 'ouvre une nouvelle fen\u00EAtre\navec une image de tous les scripts', + 'Stage size...': + 'Taille de la sc\u00E8ne...', + 'Zoom blocks...': + 'Agrandir les blocs...', + + 'Plain prototype labels': + '\u00C9tiquettes simples de d\u00E9finition', + 'uncheck to always show (+) symbols\nin block prototype labels': + 'd\u00E9cocher pour montrer en permance le symbole (+)\ndans les \u00e9tiquettes de d\u00E9finition de bloc', + 'check to hide (+) symbols\nin block prototype labels': + 'cocher pour cacher le symbole (+)\ndans les \u00e9tiquettes de d\u00E9finition de bloc', + + 'check for flat ends of lines': + 'cocher pour dessiner des fins de ligne plates', + 'uncheck for round ends of lines': + 'd\u00E9cocher pour dessiner des fins de lignes arrondies', + 'Flat line ends': + 'Fins de ligne plates', + + 'Codification support': + 'Support de la \u00AB codification \u00BB', + 'uncheck to disable\nblock to text mapping features': + 'd\u00E9cocher pour d\u00E9activer\nla fonction de transformation :\nbloc vers texte', + 'check for block\nto text mapping features': + 'cocher pour activer\nla fonction de transformation :\nbloc vers texte', + + 'current %dates': + 'date courante %dates', + 'year':'ann\u00E9e', + 'month':'mois', + 'date':'jour', + 'hour':'heure', + 'minute':'minute', + 'second':'seconde', + 'time in milliseconds': + 'heure en millisecondes', + 'day of week': + 'jour de la semaine', + + 'brightness': + 'luminosit\u00E9', + 'transparence': + 'transparence', + 'negative': + 'n\u00E9gatif', + 'comic': + 'bande dessin\u00E9e', + + 'clicked': + 'cliqu\u00E9', + 'pressed': + 'press\u00E9', + 'dropped': + 'd\u00E9pos\u00E9', + 'mouse-entered': + 'survol\u00E9', + 'mouse-departed': + 'quitt\u00E9', + + 'JavaScript function ( %mult%s ) { %code }': + 'fonction JavaScript ( %mult%s ) { %code }', + + + // Copy / Paste + 'Press CTRL+C one more time to effectively copy to clipboard.': + 'Taper une nouvelle fois sur CTRL+C pour copier effectivement vers le presse-papier.', + 'Press CTRL+V one more time to effectively paste from clipboard.': + 'Taper une nouvelle fois sur CTRL+V pour coller effectivement depuis le presse-papier.', + 'Press CTRL+X one more time to effectively cut to clipboard.': + 'Taper une nouvelle fois sur CTRL+X pour couper effectivement vers le presse-papier.', + + // Paint.js + 'undo':'d\u00E9faire', + 'Paintbrush tool\n(free draw)': + 'Pinceau\n(dessin \u00E0 main lev\u00E9)', + 'Stroked Rectangle\n(shift: square)': + 'Rectangle\n(Maj: carr\u00E9)', + 'Stroked Ellipse\n(shift: circle)': + 'Ellipse\n(Maj: cercle)', + 'Eraser tool': + 'Gomme', + 'Set the rotation center': + 'Fixe le centre de rotation', + 'Line tool\n(shift: vertical/horizontal)': + 'Ligne\n(Maj: verticale/horizontale)', + 'Filled Rectangle\n(shift: square)': + 'Rectangle plein\n(Maj: carr\u00E9)', + 'Filled Ellipse\n(shift: circle)': + 'Ellipse pleine\n(Maj: cercle)', + 'Fill a region': + 'Remplir une r\u00E9gion', + 'Pipette tool\n(pick a color anywhere)': + 'Pipette\n(s\u00E9lectionnez une couleur n\u0027importe o\u00F9', + 'grow':'agrandir', + 'shrink':'r\u00E9duire', + 'flip \u2194': + 'miroir \u2194', + 'flip \u2195': + 'miroir \u2195', + 'Brush size': + 'Taille de pinceau', + 'Constrain proportions of shapes?\n(you can also hold shift)': + 'Contrainte sur les proportions de la forme ?\n(vous pouvez aussi maintenir appuy\u00E9 Maj)' + }; diff --git a/locale.js b/locale.js index 7407180..af1e0f4 100644 --- a/locale.js +++ b/locale.js @@ -42,7 +42,7 @@ /*global modules, contains*/ -modules.locale = '2015-May-18'; +modules.locale = '2015-June-25'; // Global stuff @@ -257,7 +257,7 @@ SnapTranslator.dict.fr = { 'translator_e-mail': 'i.scool@mac.com', 'last_changed': - '2014-02-04' + '2015-06-25' }; SnapTranslator.dict.si = { -- cgit v1.3.1 From de82d373be95a568279f318877760bf7ae11a7e4 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 25 Jun 2015 16:35:00 +0200 Subject: add indentation again to please old.jslint.com :-) --- gui.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gui.js b/gui.js index f711847..eee2bd5 100644 --- a/gui.js +++ b/gui.js @@ -5040,9 +5040,9 @@ ProjectDialogMorph.prototype.shareProject = function () { if (proj.ProjectName === ide.projectName) { var usr = SnapCloud.username, projectId = 'Username=' + - encodeURIComponent(usr.toLowerCase()) + - '&ProjectName=' + - encodeURIComponent(proj.projectName); + encodeURIComponent(usr.toLowerCase()) + + '&ProjectName=' + + encodeURIComponent(proj.projectName); location.hash = projectId; } }, -- cgit v1.3.1 From 7d1db3dfe933498f59d8d61ea6baa7febdb2a96a Mon Sep 17 00:00:00 2001 From: jmoenig Date: Fri, 26 Jun 2015 13:04:27 +0200 Subject: update Morphic to the latest version --- morphic.js | 38 +++++++++++++++++++++++++++++++------- morphic.txt | 37 +++++++++++++++++++++++++------------ 2 files changed, 56 insertions(+), 19 deletions(-) diff --git a/morphic.js b/morphic.js index cb2aa32..f26c7bf 100644 --- a/morphic.js +++ b/morphic.js @@ -828,8 +828,8 @@ // use context to paint stuff here }; - If your new morph stores or references other morphs outside of the - submorph tree in other properties, be sure to also override the + If your new morph stores or references to other morphs outside of + the submorph tree in other properties, be sure to also override the default updateReferences() @@ -1048,7 +1048,7 @@ /*global window, HTMLCanvasElement, getMinimumFontHeight, FileReader, Audio, FileList, getBlurredShadowSupport*/ -var morphicVersion = '2015-June-25'; +var morphicVersion = '2015-June-26'; var modules = {}; // keep track of additional loaded modules var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug @@ -2405,10 +2405,13 @@ Morph.prototype.moveBy = function (delta) { }; Morph.prototype.silentMoveBy = function (delta) { + var children = this.children, + i = children.length; this.bounds = this.bounds.translateBy(delta); - this.children.forEach(function (child) { - child.silentMoveBy(delta); - }); + // ugly optimization avoiding forEach() + for (i; i > 0; i -= 1) { + children[i - 1].silentMoveBy(delta); + } }; Morph.prototype.setPosition = function (aPoint) { @@ -6502,7 +6505,7 @@ InspectorMorph.prototype.setExtent = function (aPoint) { this.fixLayout(); }; -//InspectorMorph editing ops: +// InspectorMorph editing ops: InspectorMorph.prototype.save = function () { var txt = this.detail.contents.children[0].text.toString(), @@ -6592,6 +6595,15 @@ InspectorMorph.prototype.step = function () { this.fixLayout(); }; +// InspectorMorph duplicating: + +InspectorMorph.prototype.updateReferences = function (map) { + var active = this.list.activeIndex(); + InspectorMorph.uber.updateReferences.call(this, map); + this.buildPanes(); + this.list.activateIndex(active); +}; + // MenuMorph /////////////////////////////////////////////////////////// // MenuMorph: referenced constructors @@ -9058,6 +9070,18 @@ ListMorph.prototype.setExtent = function (aPoint) { ListMorph.uber.setExtent.call(this, aPoint); }; +ListMorph.prototype.activeIndex = function () { + return this.listContents.children.indexOf(this.active); +}; + +ListMorph.prototype.activateIndex = function (idx) { + var item = this.listContents.children[idx]; + if (!item) {return; } + item.image = item.pressImage; + item.changed(); + item.trigger(); +}; + // StringFieldMorph //////////////////////////////////////////////////// // StringFieldMorph inherit from FrameMorph: diff --git a/morphic.txt b/morphic.txt index 042b7e5..11a323d 100755 --- a/morphic.txt +++ b/morphic.txt @@ -7,9 +7,9 @@ written by Jens Mönig jens@moenig.org - Copyright (C) 2012 by Jens Mönig + Copyright (C) 2015 by Jens Mönig - this documentation last changed: April 07, 2013 + this documentation last changed: June 26, 2015 This file is part of Snap!. @@ -465,9 +465,15 @@ MyMorph.prototype.mouseMove = function(pos) {}; - The only optional parameter of such a method is a Point object + All of these methods have as optional parameter a Point object indicating the current position of the Hand inside the World's - coordinate system. + coordinate system. The + + mouseMove(pos, button) + + event method has an additional optional parameter indicating the + currently pressed mouse button, which is either 'left' or 'right'. + You can use this to let users interact with 3D environments. Events may be "bubbled" up a morph's owner chain by calling @@ -522,6 +528,12 @@ a duplicate of the template whose "isDraggable" flag is true and whose "isTemplate" flag is false, in other words: a non-template. + When creating a copy from a template, the copy's + + reactToTemplateCopy + + is invoked, if it is present. + Dragging is indicated by adding a drop shadow to the morph in hand. If a morph follows the hand without displaying a drop shadow it is merely being moved about without changing its parent (owner morph), @@ -817,13 +829,13 @@ // use context to paint stuff here }; - If your new morph stores or references other morphs outside of the - submorph tree in other properties, be sure to also override the + If your new morph stores or references to other morphs outside of + the submorph tree in other properties, be sure to also override the default - copyRecordingReferences() + updateReferences() - method accordingly if you want it to support duplication. + method if you want it to support duplication. (6) development and user modes @@ -1015,16 +1027,17 @@ programming hero. I have originally written morphic.js in Florian Balmer's Notepad2 - editor for Windows and later switched to Apple's Dashcode. I've also - come to depend on both Douglas Crockford's JSLint, Mozilla's Firebug - and Google's Chrome to get it right. + editor for Windows, later switched to Apple's Dashcode and later + still to Apple's Xcode. I've also come to depend on both Douglas + Crockford's JSLint, Mozilla's Firebug and Google's Chrome to get + it right. IX. contributors ---------------------- Joe Otto found and fixed many early bugs and taught me some tricks. Nathan Dinsmore contributed mouse wheel scrolling, cached - background texture handling and countless bug fixes. + background texture handling, countless bug fixes and optimizations. Ian Reynolds contributed backspace key handling for Chrome. Davide Della Casa contributed performance optimizations for Firefox. -- cgit v1.3.1 From 53068ea25954431c174dca1e76ca924b00243c2f Mon Sep 17 00:00:00 2001 From: jmoenig Date: Fri, 26 Jun 2015 14:16:20 +0200 Subject: update version history --- history.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/history.txt b/history.txt index 9d9c00c..74d6d1f 100755 --- a/history.txt +++ b/history.txt @@ -2522,4 +2522,8 @@ ______ * Morphic, Objects, Blocks, XML: Optimizations and dramatic speed-up. Thanks, Nathan!! * Objects: push maximum clone count up to 1000, tweak Note::play -=== Release v4.0.1 === +=== Start with v4.0.1 === + +150626 +------ +* Morphic: Fix Inspector duplication, update documentation -- cgit v1.3.1