mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-08-28 22:10:31 -04:00
Use prototypes for primitive properties.
This commit is contained in:
parent
1b43699ae3
commit
3f8e586fe8
9 changed files with 65 additions and 31 deletions
|
@ -54,29 +54,29 @@ Blockly.Connection.prototype.targetConnection = null;
|
|||
|
||||
/**
|
||||
* List of compatible value types. Null if all types are compatible.
|
||||
* @private
|
||||
* @type {Array}
|
||||
* @private
|
||||
*/
|
||||
Blockly.Connection.prototype.check_ = null;
|
||||
|
||||
/**
|
||||
* Horizontal location of this connection.
|
||||
* @private
|
||||
* @type {number}
|
||||
* @private
|
||||
*/
|
||||
Blockly.Connection.prototype.x_ = 0;
|
||||
|
||||
/**
|
||||
* Vertical location of this connection.
|
||||
* @private
|
||||
* @type {number}
|
||||
* @private
|
||||
*/
|
||||
Blockly.Connection.prototype.y_ = 0;
|
||||
|
||||
/**
|
||||
* Has this connection been added to the connection database?
|
||||
* @private
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
Blockly.Connection.prototype.inDB_ = false;
|
||||
|
||||
|
|
|
@ -50,13 +50,23 @@ Blockly.FieldColour = function(colour, opt_changeHandler) {
|
|||
this.setChangeHandler(opt_changeHandler);
|
||||
// Set the initial state.
|
||||
this.setValue(colour);
|
||||
|
||||
// By default use the global constants for colours and columns.
|
||||
this.colours_ = null;
|
||||
this.columns_ = 0;
|
||||
};
|
||||
goog.inherits(Blockly.FieldColour, Blockly.Field);
|
||||
|
||||
/**
|
||||
* By default use the global constants for colours.
|
||||
* @type {Array.<string>}
|
||||
* @private
|
||||
*/
|
||||
Blockly.FieldColour.prototype.colours_ = null;
|
||||
|
||||
/**
|
||||
* By default use the global constants for columns.
|
||||
* @type {number}
|
||||
* @private
|
||||
*/
|
||||
Blockly.FieldColour.prototype.columns_ = 0;
|
||||
|
||||
/**
|
||||
* Install this field on a block.
|
||||
* @param {!Blockly.Block} block The block containing this field.
|
||||
|
|
|
@ -40,7 +40,6 @@ goog.require('goog.math.Size');
|
|||
* @constructor
|
||||
*/
|
||||
Blockly.FieldLabel = function(text, opt_class) {
|
||||
this.sourceBlock_ = null;
|
||||
this.size_ = new goog.math.Size(0, 17.5);
|
||||
this.class_ = opt_class;
|
||||
this.setText(text);
|
||||
|
|
|
@ -60,23 +60,11 @@ Blockly.Flyout = function(workspaceOptions) {
|
|||
|
||||
/**
|
||||
* Opaque data that can be passed to Blockly.unbindEvent_.
|
||||
* @type {Array.<!Array>}
|
||||
* @type {!Array.<!Array>}
|
||||
* @private
|
||||
*/
|
||||
this.eventWrappers_ = [];
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
* @private
|
||||
*/
|
||||
this.width_ = 0;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
* @private
|
||||
*/
|
||||
this.height_ = 0;
|
||||
|
||||
/**
|
||||
* List of background buttons that lurk behind each block to catch clicks
|
||||
* landing in the blocks' lakes and bays.
|
||||
|
@ -113,6 +101,20 @@ Blockly.Flyout.prototype.CORNER_RADIUS = 8;
|
|||
*/
|
||||
Blockly.Flyout.prototype.SCROLLBAR_PADDING = 2;
|
||||
|
||||
/**
|
||||
* Width of flyout.
|
||||
* @type {number}
|
||||
* @private
|
||||
*/
|
||||
Blockly.Flyout.prototype.width_ = 0;
|
||||
|
||||
/**
|
||||
* Height of flyout.
|
||||
* @type {number}
|
||||
* @private
|
||||
*/
|
||||
Blockly.Flyout.prototype.height_ = 0;
|
||||
|
||||
/**
|
||||
* Creates the flyout's DOM. Only needs to be called once.
|
||||
* @return {!Element} The flyout's SVG group.
|
||||
|
|
|
@ -38,7 +38,6 @@ goog.require('goog.asserts');
|
|||
*/
|
||||
Blockly.Generator = function(name) {
|
||||
this.name_ = name;
|
||||
this.RESERVED_WORDS_ = '';
|
||||
this.FUNCTION_NAME_PLACEHOLDER_REGEXP_ =
|
||||
new RegExp(this.FUNCTION_NAME_PLACEHOLDER_, 'g');
|
||||
};
|
||||
|
@ -270,9 +269,17 @@ Blockly.Generator.prototype.addLoopTrap = function(branch, id) {
|
|||
/**
|
||||
* The method of indenting. Defaults to two spaces, but language generators
|
||||
* may override this to increase indent or change to tabs.
|
||||
* @type {string}
|
||||
*/
|
||||
Blockly.Generator.prototype.INDENT = ' ';
|
||||
|
||||
/**
|
||||
* Comma-separated list of reserved words.
|
||||
* @type {string}
|
||||
* @private
|
||||
*/
|
||||
Blockly.Generator.prototype.RESERVED_WORDS_ = '';
|
||||
|
||||
/**
|
||||
* Add one or more words to the list of reserved words for this language.
|
||||
* @param {string} words Comma-separated list of words to add to the list.
|
||||
|
@ -287,6 +294,7 @@ Blockly.Generator.prototype.addReservedWords = function(words) {
|
|||
* Blockly.Generator.provideFunction_. It must not be legal code that could
|
||||
* legitimately appear in a function definition (or comment), and it must
|
||||
* not confuse the regular expression parser.
|
||||
* @type {string}
|
||||
* @private
|
||||
*/
|
||||
Blockly.Generator.prototype.FUNCTION_NAME_PLACEHOLDER_ = '{leCUI8hutHZI4480Dc}';
|
||||
|
|
|
@ -53,12 +53,21 @@ Blockly.Input = function(type, name, block, connection) {
|
|||
this.connection = connection;
|
||||
/** @type {!Array.<!Blockly.Field>} */
|
||||
this.fieldRow = [];
|
||||
/** @type {number} */
|
||||
this.align = Blockly.ALIGN_LEFT;
|
||||
/** @type {boolean} */
|
||||
this.visible_ = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Alignment of input's fields (left, right or centre).
|
||||
* @type {number}
|
||||
*/
|
||||
Blockly.Input.prototype.align = Blockly.ALIGN_LEFT;
|
||||
|
||||
/**
|
||||
* Is the input visible?
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
Blockly.Input.prototype.visible_ = true;
|
||||
|
||||
/**
|
||||
* Add an item to the end of the input's field row.
|
||||
* @param {string|!Blockly.Field} field Something to add as a field.
|
||||
|
|
|
@ -38,7 +38,6 @@ goog.require('goog.events');
|
|||
*/
|
||||
Blockly.ScrollbarPair = function(workspace) {
|
||||
this.workspace_ = workspace;
|
||||
this.oldHostMetrics_ = null;
|
||||
this.hScroll = new Blockly.Scrollbar(workspace, true, true);
|
||||
this.vScroll = new Blockly.Scrollbar(workspace, false, true);
|
||||
this.corner_ = Blockly.createSvgElement('rect',
|
||||
|
@ -48,6 +47,13 @@ Blockly.ScrollbarPair = function(workspace) {
|
|||
Blockly.Scrollbar.insertAfter_(this.corner_, workspace.getBubbleCanvas());
|
||||
};
|
||||
|
||||
/**
|
||||
* Previously recorded metrics from the workspace.
|
||||
* @type {Object}
|
||||
* @private
|
||||
*/
|
||||
Blockly.ScrollbarPair.prototype.oldHostMetrics_ = null;
|
||||
|
||||
/**
|
||||
* Dispose of this pair of scrollbars.
|
||||
* Unlink from all DOM elements to prevent memory leaks.
|
||||
|
|
|
@ -40,15 +40,15 @@ Blockly.WidgetDiv.DIV = null;
|
|||
|
||||
/**
|
||||
* The object currently using this container.
|
||||
* @private
|
||||
* @type {Object}
|
||||
* @private
|
||||
*/
|
||||
Blockly.WidgetDiv.owner_ = null;
|
||||
|
||||
/**
|
||||
* Optional cleanup function set by whichever object uses the widget.
|
||||
* @private
|
||||
* @type {Function}
|
||||
* @private
|
||||
*/
|
||||
Blockly.WidgetDiv.dispose_ = null;
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ Blockly.WorkspaceSvg = function(options) {
|
|||
|
||||
/**
|
||||
* Opaque data that can be passed to Blockly.unbindEvent_.
|
||||
* @type {Array.<!Array>}
|
||||
* @type {!Array.<!Array>}
|
||||
* @private
|
||||
*/
|
||||
this.eventWrappers_ = [];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue