From 1e3297ba0aaeaae9ad8792c984a24d5275edfab1 Mon Sep 17 00:00:00 2001 From: miguel76 Date: Sat, 9 Apr 2016 12:01:38 -0300 Subject: [PATCH] Fix #326 Parameter block is removed from init prototype of fields and its usage is replaced by this.sourceBlock_ --- core/field_checkbox.js | 5 ++--- core/field_colour.js | 5 ++--- core/field_dropdown.js | 7 +++---- core/field_variable.js | 9 +++++---- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/core/field_checkbox.js b/core/field_checkbox.js index 183e226c9..fb46e0a46 100644 --- a/core/field_checkbox.js +++ b/core/field_checkbox.js @@ -58,14 +58,13 @@ Blockly.FieldCheckbox.prototype.CURSOR = 'default'; /** * Install this checkbox on a block. - * @param {!Blockly.Block} block The block containing this text. */ -Blockly.FieldCheckbox.prototype.init = function(block) { +Blockly.FieldCheckbox.prototype.init = function() { if (this.fieldGroup_) { // Checkbox has already been initialized once. return; } - Blockly.FieldCheckbox.superClass_.init.call(this, block); + Blockly.FieldCheckbox.superClass_.init.call(this); // The checkbox doesn't use the inherited text element. // Instead it uses a custom checkmark element that is either visible or not. this.checkElement_ = Blockly.createSvgElement('text', diff --git a/core/field_colour.js b/core/field_colour.js index ee75f4736..65346ee20 100644 --- a/core/field_colour.js +++ b/core/field_colour.js @@ -66,10 +66,9 @@ Blockly.FieldColour.prototype.columns_ = 0; /** * Install this field on a block. - * @param {!Blockly.Block} block The block containing this field. */ -Blockly.FieldColour.prototype.init = function(block) { - Blockly.FieldColour.superClass_.init.call(this, block); +Blockly.FieldColour.prototype.init = function() { + Blockly.FieldColour.superClass_.init.call(this); this.borderRect_.style['fillOpacity'] = 1; this.setValue(this.getValue()); }; diff --git a/core/field_dropdown.js b/core/field_dropdown.js index d715c8c72..294682fc5 100644 --- a/core/field_dropdown.js +++ b/core/field_dropdown.js @@ -77,9 +77,8 @@ Blockly.FieldDropdown.prototype.CURSOR = 'default'; /** * Install this dropdown on a block. - * @param {!Blockly.Block} block The block containing this text. */ -Blockly.FieldDropdown.prototype.init = function(block) { +Blockly.FieldDropdown.prototype.init = function() { if (this.fieldGroup_) { // Dropdown has already been initialized once. return; @@ -87,10 +86,10 @@ Blockly.FieldDropdown.prototype.init = function(block) { // Add dropdown arrow: "option ▾" (LTR) or "▾ אופציה" (RTL) this.arrow_ = Blockly.createSvgElement('tspan', {}, null); this.arrow_.appendChild(document.createTextNode( - block.RTL ? Blockly.FieldDropdown.ARROW_CHAR + ' ' : + this.sourceBlock_.RTL ? Blockly.FieldDropdown.ARROW_CHAR + ' ' : ' ' + Blockly.FieldDropdown.ARROW_CHAR)); - Blockly.FieldDropdown.superClass_.init.call(this, block); + Blockly.FieldDropdown.superClass_.init.call(this); // Force a reset of the text to add the arrow. var text = this.text_; this.text_ = null; diff --git a/core/field_variable.js b/core/field_variable.js index 8e5bac966..0a040a0af 100644 --- a/core/field_variable.js +++ b/core/field_variable.js @@ -79,18 +79,19 @@ Blockly.FieldVariable.prototype.setValidator = function(handler) { /** * Install this dropdown on a block. - * @param {!Blockly.Block} block The block containing this text. */ -Blockly.FieldVariable.prototype.init = function(block) { +Blockly.FieldVariable.prototype.init = function() { if (this.fieldGroup_) { // Dropdown has already been initialized once. return; } - Blockly.FieldVariable.superClass_.init.call(this, block); + Blockly.FieldVariable.superClass_.init.call(this); if (!this.getValue()) { // Variables without names get uniquely named for this workspace. var workspace = - block.isInFlyout ? block.workspace.targetWorkspace : block.workspace; + this.sourceBlock_.isInFlyout ? + this.sourceBlock_.workspace.targetWorkspace : + this.sourceBlock_.workspace; this.setValue(Blockly.Variables.generateUniqueName(workspace)); } };