mirror of
https://github.com/google/blockly.git
synced 2026-01-08 09:30:06 +01:00
Moved to #2125 disposal. Cleaned up some doc.
This commit is contained in:
@@ -327,7 +327,7 @@ Blockly.Field.prototype.toXml = function(fieldElement) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Dispose of all DOM objects belonging to this editable field.
|
||||
* Dispose of all DOM objects and events belonging to this editable field.
|
||||
* @package
|
||||
*/
|
||||
Blockly.Field.prototype.dispose = function() {
|
||||
@@ -336,16 +336,11 @@ Blockly.Field.prototype.dispose = function() {
|
||||
|
||||
if (this.mouseDownWrapper_) {
|
||||
Blockly.unbindEvent_(this.mouseDownWrapper_);
|
||||
this.mouseDownWrapper_ = null;
|
||||
}
|
||||
this.sourceBlock_ = null;
|
||||
if (this.fieldGroup_) {
|
||||
Blockly.utils.dom.removeNode(this.fieldGroup_);
|
||||
this.fieldGroup_ = null;
|
||||
}
|
||||
this.textElement_ = null;
|
||||
this.borderRect_ = null;
|
||||
this.validator_ = null;
|
||||
|
||||
Blockly.utils.dom.removeNode(this.fieldGroup_);
|
||||
|
||||
this.disposed = true;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -130,15 +130,6 @@ Blockly.FieldAngle.prototype.initView = function() {
|
||||
this.textElement_.appendChild(this.symbol_);
|
||||
};
|
||||
|
||||
/**
|
||||
* Dispose of references to DOM elements and events belonging to this field.
|
||||
* @package
|
||||
*/
|
||||
Blockly.FieldAngle.prototype.dispose = function() {
|
||||
Blockly.FieldAngle.superClass_.dispose.call(this);
|
||||
this.symbol_ = null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates the graph when the field rerenders.
|
||||
* @private
|
||||
@@ -231,13 +222,10 @@ Blockly.FieldAngle.prototype.dropdownCreate_ = function() {
|
||||
};
|
||||
|
||||
/**
|
||||
* Dispose of references to DOM elements and events belonging
|
||||
* to the angle editor.
|
||||
* Dispose of events belonging to the angle editor.
|
||||
* @private
|
||||
*/
|
||||
Blockly.FieldAngle.prototype.dropdownDispose_ = function() {
|
||||
this.gauge_ = null;
|
||||
this.line_ = null;
|
||||
Blockly.unbindEvent_(this.clickWrapper_);
|
||||
Blockly.unbindEvent_(this.moveWrapper1_);
|
||||
Blockly.unbindEvent_(this.moveWrapper2_);
|
||||
|
||||
@@ -332,8 +332,7 @@ Blockly.FieldColour.prototype.dropdownCreate_ = function() {
|
||||
};
|
||||
|
||||
/**
|
||||
* Dispose of references to DOM elements and events belonging
|
||||
* to the colour editor.
|
||||
* Dispose of events belonging to the colour editor.
|
||||
* @private
|
||||
*/
|
||||
Blockly.FieldColour.prototype.dropdownDispose_ = function() {
|
||||
|
||||
@@ -240,7 +240,6 @@ Blockly.FieldDate.prototype.dropdownCreate_ = function() {
|
||||
* @private
|
||||
*/
|
||||
Blockly.FieldDate.prototype.dropdownDispose_ = function() {
|
||||
this.picker_ = null;
|
||||
goog.events.unlistenByKey(this.changeEventKey_);
|
||||
goog.events.unlistenByKey(this.activeMonthEventKey_);
|
||||
};
|
||||
|
||||
@@ -154,15 +154,6 @@ Blockly.FieldDropdown.prototype.initView = function() {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Dispose of references to DOM elements and events belonging to this field.
|
||||
*/
|
||||
Blockly.FieldDropdown.prototype.dispose = function() {
|
||||
Blockly.FieldDropdown.superClass_.dispose.call(this);
|
||||
this.imageElement_ = null;
|
||||
this.arrow_ = null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a dropdown menu under the text.
|
||||
* @private
|
||||
@@ -223,8 +214,11 @@ Blockly.FieldDropdown.prototype.widgetCreate_ = function() {
|
||||
return menu;
|
||||
};
|
||||
|
||||
/**
|
||||
* Dispose of events belonging to the dropdown editor.
|
||||
* @private
|
||||
*/
|
||||
Blockly.FieldDropdown.prototype.widgetDispose_ = function() {
|
||||
this.menu_ = null;
|
||||
goog.events.unlistenByKey(this.menuActionEventKey_);
|
||||
};
|
||||
|
||||
|
||||
@@ -129,16 +129,6 @@ Blockly.FieldImage.prototype.initView = function() {
|
||||
'xlink:href', this.value_);
|
||||
};
|
||||
|
||||
/**
|
||||
* Dispose of all DOM objects belonging to this text.
|
||||
*/
|
||||
Blockly.FieldImage.prototype.dispose = function() {
|
||||
Blockly.FieldImage.superClass_.dispose.call(this);
|
||||
this.imageElement_ = null;
|
||||
// TODO: Do we need to dispose of this?
|
||||
this.clickHandler_ = null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Ensure that the input value (the source URL) is a string.
|
||||
* @param {string=} newValue The input value
|
||||
|
||||
@@ -232,6 +232,11 @@ Blockly.FieldTextInput.prototype.showInlineEditor_ = function(quietInput) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Create the text input editor widget.
|
||||
* @return {HTMLInputElement} The newly created text input editor.
|
||||
* @private
|
||||
*/
|
||||
Blockly.FieldTextInput.prototype.widgetCreate_ = function() {
|
||||
var div = Blockly.WidgetDiv.DIV;
|
||||
|
||||
@@ -254,6 +259,42 @@ Blockly.FieldTextInput.prototype.widgetCreate_ = function() {
|
||||
return htmlInput;
|
||||
};
|
||||
|
||||
/**
|
||||
* Close the editor, save the results, and dispose any events bound to the
|
||||
* text input's editor.
|
||||
* @private
|
||||
*/
|
||||
Blockly.FieldTextInput.prototype.widgetDispose_ = function() {
|
||||
// Finalize value.
|
||||
this.isBeingEdited_ = false;
|
||||
// No need to call setValue because if the widget is being closed the
|
||||
// latest input text has already been validated.
|
||||
if (this.value_ !== this.text_) {
|
||||
// At the end of an edit the text should be the same as the value. It
|
||||
// may not be if the input text is different than the validated text.
|
||||
// We should fix that.
|
||||
this.text_ = String(this.value_);
|
||||
this.isTextValid_ = true;
|
||||
this.forceRerender();
|
||||
}
|
||||
// Otherwise don't rerender.
|
||||
|
||||
// Call onFinishEditing
|
||||
// TODO: Get rid of this or make it less of a hack.
|
||||
if (this.onFinishEditing_) {
|
||||
this.onFinishEditing_(this.value_);
|
||||
}
|
||||
|
||||
// Remove htmlInput events.
|
||||
this.unbindInputEvents_();
|
||||
|
||||
// Delete style properties.
|
||||
var style = Blockly.WidgetDiv.DIV.style;
|
||||
style.width = 'auto';
|
||||
style.height = 'auto';
|
||||
style.fontSize = '';
|
||||
};
|
||||
|
||||
/**
|
||||
* Bind handlers for user input on the text input field's editor.
|
||||
* @param {!HTMLInputElement} htmlInput The htmlInput to which event
|
||||
@@ -365,43 +406,6 @@ Blockly.FieldTextInput.prototype.resizeEditor_ = function() {
|
||||
div.style.top = xy.y + 'px';
|
||||
};
|
||||
|
||||
/**
|
||||
* Close the editor, save the results, and dispose of the editable
|
||||
* text field's elements.
|
||||
* @private
|
||||
*/
|
||||
Blockly.FieldTextInput.prototype.widgetDispose_ = function() {
|
||||
// Finalize value.
|
||||
this.isBeingEdited_ = false;
|
||||
// No need to call setValue because if the widget is being closed the
|
||||
// latest input text has already been validated.
|
||||
if (this.value_ !== this.text_) {
|
||||
// At the end of an edit the text should be the same as the value. It
|
||||
// may not be if the input text is different than the validated text.
|
||||
// We should fix that.
|
||||
this.text_ = String(this.value_);
|
||||
this.isTextValid_ = true;
|
||||
this.forceRerender();
|
||||
}
|
||||
// Otherwise don't rerender.
|
||||
|
||||
// Call onFinishEditing
|
||||
// TODO: Get rid of this or make it less of a hack.
|
||||
if (this.onFinishEditing_) {
|
||||
this.onFinishEditing_(this.value_);
|
||||
}
|
||||
|
||||
// Remove htmlInput.
|
||||
this.unbindInputEvents_();
|
||||
this.htmlInput_ = null;
|
||||
|
||||
// Delete style properties.
|
||||
var style = Blockly.WidgetDiv.DIV.style;
|
||||
style.width = 'auto';
|
||||
style.height = 'auto';
|
||||
style.fontSize = '';
|
||||
};
|
||||
|
||||
/**
|
||||
* Ensure that only a number may be entered.
|
||||
* @param {string} text The user's text.
|
||||
|
||||
@@ -157,16 +157,6 @@ Blockly.FieldVariable.prototype.toXml = function(fieldElement) {
|
||||
return fieldElement;
|
||||
};
|
||||
|
||||
/**
|
||||
* Dispose of this field.
|
||||
* @public
|
||||
*/
|
||||
Blockly.FieldVariable.prototype.dispose = function() {
|
||||
Blockly.FieldVariable.superClass_.dispose.call(this);
|
||||
this.workspace_ = null;
|
||||
this.variableMap_ = null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Attach this field to a block.
|
||||
* @param {!Blockly.Block} block The block containing this field.
|
||||
|
||||
Reference in New Issue
Block a user