mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-07-03 15:40:26 -04:00
Lint that caused conflicts with Blockly
This commit is contained in:
parent
aee1438968
commit
88bb0bff3e
18 changed files with 196 additions and 159 deletions
|
@ -81,13 +81,13 @@ Blockly.Block = function(workspace, prototypeName, opt_id) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Blockly.Block}
|
* @type {Blockly.Block}
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
this.parentBlock_ = null;
|
this.parentBlock_ = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {!Array.<!Blockly.Block>}
|
* @type {!Array.<!Blockly.Block>}
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
this.childBlocks_ = [];
|
this.childBlocks_ = [];
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ Blockly.Block = function(workspace, prototypeName, opt_id) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
this.collapsed_ = false;
|
this.collapsed_ = false;
|
||||||
|
|
||||||
|
@ -317,7 +317,7 @@ Blockly.Block.prototype.initModel = function() {
|
||||||
/**
|
/**
|
||||||
* Unplug this block from its superior block. If this block is a statement,
|
* Unplug this block from its superior block. If this block is a statement,
|
||||||
* optionally reconnect the block underneath with the block on top.
|
* optionally reconnect the block underneath with the block on top.
|
||||||
* @param {boolean} opt_healStack Disconnect child statement and reconnect
|
* @param {boolean=} opt_healStack Disconnect child statement and reconnect
|
||||||
* stack. Defaults to false.
|
* stack. Defaults to false.
|
||||||
*/
|
*/
|
||||||
Blockly.Block.prototype.unplug = function(opt_healStack) {
|
Blockly.Block.prototype.unplug = function(opt_healStack) {
|
||||||
|
@ -393,7 +393,7 @@ Blockly.Block.prototype.lastConnectionInStack = function() {
|
||||||
/**
|
/**
|
||||||
* Bump unconnected blocks out of alignment. Two blocks which aren't actually
|
* Bump unconnected blocks out of alignment. Two blocks which aren't actually
|
||||||
* connected should not coincidentally line up on screen.
|
* connected should not coincidentally line up on screen.
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
Blockly.Block.prototype.bumpNeighbours_ = function() {
|
Blockly.Block.prototype.bumpNeighbours_ = function() {
|
||||||
console.warn('Not expected to reach this bumpNeighbours_ function. The ' +
|
console.warn('Not expected to reach this bumpNeighbours_ function. The ' +
|
||||||
|
@ -949,7 +949,7 @@ Blockly.Block.prototype.setFieldValue = function(newValue, name) {
|
||||||
/**
|
/**
|
||||||
* Set whether this block can chain onto the bottom of another block.
|
* Set whether this block can chain onto the bottom of another block.
|
||||||
* @param {boolean} newBoolean True if there can be a previous statement.
|
* @param {boolean} newBoolean True if there can be a previous statement.
|
||||||
* @param {string|Array.<string>|null|undefined} opt_check Statement type or
|
* @param {(string|Array.<string>|null)=} opt_check Statement type or
|
||||||
* list of statement types. Null/undefined if any type could be connected.
|
* list of statement types. Null/undefined if any type could be connected.
|
||||||
*/
|
*/
|
||||||
Blockly.Block.prototype.setPreviousStatement = function(newBoolean, opt_check) {
|
Blockly.Block.prototype.setPreviousStatement = function(newBoolean, opt_check) {
|
||||||
|
@ -977,7 +977,7 @@ Blockly.Block.prototype.setPreviousStatement = function(newBoolean, opt_check) {
|
||||||
/**
|
/**
|
||||||
* Set whether another block can chain onto the bottom of this block.
|
* Set whether another block can chain onto the bottom of this block.
|
||||||
* @param {boolean} newBoolean True if there can be a next statement.
|
* @param {boolean} newBoolean True if there can be a next statement.
|
||||||
* @param {string|Array.<string>|null|undefined} opt_check Statement type or
|
* @param {(string|Array.<string>|null)=} opt_check Statement type or
|
||||||
* list of statement types. Null/undefined if any type could be connected.
|
* list of statement types. Null/undefined if any type could be connected.
|
||||||
*/
|
*/
|
||||||
Blockly.Block.prototype.setNextStatement = function(newBoolean, opt_check) {
|
Blockly.Block.prototype.setNextStatement = function(newBoolean, opt_check) {
|
||||||
|
@ -1002,7 +1002,7 @@ Blockly.Block.prototype.setNextStatement = function(newBoolean, opt_check) {
|
||||||
/**
|
/**
|
||||||
* Set whether this block returns a value.
|
* Set whether this block returns a value.
|
||||||
* @param {boolean} newBoolean True if there is an output.
|
* @param {boolean} newBoolean True if there is an output.
|
||||||
* @param {string|Array.<string>|null|undefined} opt_check Returned type or list
|
* @param {(string|Array.<string>|null)=} opt_check Returned type or list
|
||||||
* of returned types. Null or undefined if any type could be returned
|
* of returned types. Null or undefined if any type could be returned
|
||||||
* (e.g. variable get).
|
* (e.g. variable get).
|
||||||
*/
|
*/
|
||||||
|
@ -1451,7 +1451,7 @@ Blockly.Block.prototype.interpolate_ = function(message, args, lastDummyAlign) {
|
||||||
* @param {string} name Language-neutral identifier which may used to find this
|
* @param {string} name Language-neutral identifier which may used to find this
|
||||||
* input again. Should be unique to this block.
|
* input again. Should be unique to this block.
|
||||||
* @return {!Blockly.Input} The input object created.
|
* @return {!Blockly.Input} The input object created.
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
Blockly.Block.prototype.appendInput_ = function(type, name) {
|
Blockly.Block.prototype.appendInput_ = function(type, name) {
|
||||||
var connection = null;
|
var connection = null;
|
||||||
|
|
|
@ -48,7 +48,7 @@ goog.require('goog.userAgent');
|
||||||
* @param {?string} prototypeName Name of the language object containing
|
* @param {?string} prototypeName Name of the language object containing
|
||||||
* type-specific functions for this block.
|
* type-specific functions for this block.
|
||||||
* @param {string=} opt_id Optional ID. Use this ID if provided, otherwise
|
* @param {string=} opt_id Optional ID. Use this ID if provided, otherwise
|
||||||
* create a new id.
|
* create a new ID.
|
||||||
* @extends {Blockly.Block}
|
* @extends {Blockly.Block}
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
|
@ -60,7 +60,8 @@ Blockly.BlockSvg = function(workspace, prototypeName, opt_id) {
|
||||||
*/
|
*/
|
||||||
this.svgGroup_ = Blockly.utils.createSvgElement('g', {}, null);
|
this.svgGroup_ = Blockly.utils.createSvgElement('g', {}, null);
|
||||||
/** @type {SVGElement} */
|
/** @type {SVGElement} */
|
||||||
this.svgPath_ = Blockly.utils.createSvgElement('path', {'class': 'blocklyPath blocklyBlockBackground'},
|
this.svgPath_ = Blockly.utils.createSvgElement('path',
|
||||||
|
{'class': 'blocklyPath blocklyBlockBackground'},
|
||||||
this.svgGroup_);
|
this.svgGroup_);
|
||||||
this.svgPath_.tooltip = this;
|
this.svgPath_.tooltip = this;
|
||||||
|
|
||||||
|
@ -154,8 +155,8 @@ Blockly.BlockSvg.prototype.initSvg = function() {
|
||||||
this.updateColour();
|
this.updateColour();
|
||||||
this.updateMovable();
|
this.updateMovable();
|
||||||
if (!this.workspace.options.readOnly && !this.eventsInit_) {
|
if (!this.workspace.options.readOnly && !this.eventsInit_) {
|
||||||
Blockly.bindEventWithChecks_(this.getSvgRoot(), 'mousedown', this,
|
Blockly.bindEventWithChecks_(
|
||||||
this.onMouseDown_);
|
this.getSvgRoot(), 'mousedown', this, this.onMouseDown_);
|
||||||
}
|
}
|
||||||
this.eventsInit_ = true;
|
this.eventsInit_ = true;
|
||||||
|
|
||||||
|
@ -598,7 +599,7 @@ Blockly.BlockSvg.prototype.tab = function(start, forward) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an ordered list of all text fields and connected inputs.
|
* Create an ordered list of all text fields and connected inputs.
|
||||||
* @return {!Array<!Blockly.FieldTextInput|!Blockly.Input>} The ordered list.
|
* @return {!Array.<!Blockly.FieldTextInput|!Blockly.Input>} The ordered list.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
Blockly.BlockSvg.prototype.createTabList_ = function() {
|
Blockly.BlockSvg.prototype.createTabList_ = function() {
|
||||||
|
@ -815,12 +816,12 @@ Blockly.BlockSvg.prototype.setDragging = function(adding) {
|
||||||
group.skew_ = '';
|
group.skew_ = '';
|
||||||
Blockly.draggingConnections_ =
|
Blockly.draggingConnections_ =
|
||||||
Blockly.draggingConnections_.concat(this.getConnections_(true));
|
Blockly.draggingConnections_.concat(this.getConnections_(true));
|
||||||
Blockly.utils.addClass(/** @type {!Element} */ (this.svgGroup_),
|
Blockly.utils.addClass(
|
||||||
'blocklyDragging');
|
/** @type {!Element} */ (this.svgGroup_), 'blocklyDragging');
|
||||||
} else {
|
} else {
|
||||||
Blockly.draggingConnections_ = [];
|
Blockly.draggingConnections_ = [];
|
||||||
Blockly.utils.removeClass(/** @type {!Element} */ (this.svgGroup_),
|
Blockly.utils.removeClass(
|
||||||
'blocklyDragging');
|
/** @type {!Element} */ (this.svgGroup_), 'blocklyDragging');
|
||||||
}
|
}
|
||||||
// Recurse through all blocks attached under this one.
|
// Recurse through all blocks attached under this one.
|
||||||
for (var i = 0; i < this.childBlocks_.length; i++) {
|
for (var i = 0; i < this.childBlocks_.length; i++) {
|
||||||
|
@ -833,11 +834,11 @@ Blockly.BlockSvg.prototype.setDragging = function(adding) {
|
||||||
*/
|
*/
|
||||||
Blockly.BlockSvg.prototype.updateMovable = function() {
|
Blockly.BlockSvg.prototype.updateMovable = function() {
|
||||||
if (this.isMovable()) {
|
if (this.isMovable()) {
|
||||||
Blockly.utils.addClass(/** @type {!Element} */ (this.svgGroup_),
|
Blockly.utils.addClass(
|
||||||
'blocklyDraggable');
|
/** @type {!Element} */ (this.svgGroup_), 'blocklyDraggable');
|
||||||
} else {
|
} else {
|
||||||
Blockly.utils.removeClass(/** @type {!Element} */ (this.svgGroup_),
|
Blockly.utils.removeClass(
|
||||||
'blocklyDraggable');
|
/** @type {!Element} */ (this.svgGroup_), 'blocklyDraggable');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1076,16 +1077,16 @@ Blockly.BlockSvg.prototype.setMutator = function(mutator) {
|
||||||
* Select this block. Highlight it visually.
|
* Select this block. Highlight it visually.
|
||||||
*/
|
*/
|
||||||
Blockly.BlockSvg.prototype.addSelect = function() {
|
Blockly.BlockSvg.prototype.addSelect = function() {
|
||||||
Blockly.utils.addClass(/** @type {!Element} */ (this.svgGroup_),
|
Blockly.utils.addClass(
|
||||||
'blocklySelected');
|
/** @type {!Element} */ (this.svgGroup_), 'blocklySelected');
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unselect this block. Remove its highlighting.
|
* Unselect this block. Remove its highlighting.
|
||||||
*/
|
*/
|
||||||
Blockly.BlockSvg.prototype.removeSelect = function() {
|
Blockly.BlockSvg.prototype.removeSelect = function() {
|
||||||
Blockly.utils.removeClass(/** @type {!Element} */ (this.svgGroup_),
|
Blockly.utils.removeClass(
|
||||||
'blocklySelected');
|
/** @type {!Element} */ (this.svgGroup_), 'blocklySelected');
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1112,11 +1113,11 @@ Blockly.BlockSvg.prototype.setMouseThroughStyle = function(letMouseThrough) {
|
||||||
*/
|
*/
|
||||||
Blockly.BlockSvg.prototype.setDeleteStyle = function(enable) {
|
Blockly.BlockSvg.prototype.setDeleteStyle = function(enable) {
|
||||||
if (enable) {
|
if (enable) {
|
||||||
Blockly.utils.addClass(/** @type {!Element} */ (this.svgGroup_),
|
Blockly.utils.addClass(
|
||||||
'blocklyDraggingDelete');
|
/** @type {!Element} */ (this.svgGroup_), 'blocklyDraggingDelete');
|
||||||
} else {
|
} else {
|
||||||
Blockly.utils.removeClass(/** @type {!Element} */ (this.svgGroup_),
|
Blockly.utils.removeClass(
|
||||||
'blocklyDraggingDelete');
|
/** @type {!Element} */ (this.svgGroup_), 'blocklyDraggingDelete');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1143,8 +1144,8 @@ Blockly.BlockSvg.prototype.setColour = function(colour, colourSecondary,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move this block to the front of the visible workspace.
|
* Move this block to the front of the visible workspace.
|
||||||
* <g> tags do not respect z-index so svg renders them in the
|
* <g> tags do not respect z-index so SVG renders them in the
|
||||||
* order that they are in the dom. By placing this block first within the
|
* order that they are in the DOM. By placing this block first within the
|
||||||
* block group's <g>, it will render on top of any other blocks.
|
* block group's <g>, it will render on top of any other blocks.
|
||||||
* @package
|
* @package
|
||||||
*/
|
*/
|
||||||
|
@ -1160,7 +1161,7 @@ Blockly.BlockSvg.prototype.bringToFront = function() {
|
||||||
/**
|
/**
|
||||||
* Set whether this block can chain onto the bottom of another block.
|
* Set whether this block can chain onto the bottom of another block.
|
||||||
* @param {boolean} newBoolean True if there can be a previous statement.
|
* @param {boolean} newBoolean True if there can be a previous statement.
|
||||||
* @param {string|Array.<string>|null|undefined} opt_check Statement type or
|
* @param {(string|Array.<string>|null)=} opt_check Statement type or
|
||||||
* list of statement types. Null/undefined if any type could be connected.
|
* list of statement types. Null/undefined if any type could be connected.
|
||||||
*/
|
*/
|
||||||
Blockly.BlockSvg.prototype.setPreviousStatement =
|
Blockly.BlockSvg.prototype.setPreviousStatement =
|
||||||
|
@ -1178,7 +1179,7 @@ Blockly.BlockSvg.prototype.setPreviousStatement =
|
||||||
/**
|
/**
|
||||||
* Set whether another block can chain onto the bottom of this block.
|
* Set whether another block can chain onto the bottom of this block.
|
||||||
* @param {boolean} newBoolean True if there can be a next statement.
|
* @param {boolean} newBoolean True if there can be a next statement.
|
||||||
* @param {string|Array.<string>|null|undefined} opt_check Statement type or
|
* @param {(string|Array.<string>|null)=} opt_check Statement type or
|
||||||
* list of statement types. Null/undefined if any type could be connected.
|
* list of statement types. Null/undefined if any type could be connected.
|
||||||
*/
|
*/
|
||||||
Blockly.BlockSvg.prototype.setNextStatement = function(newBoolean, opt_check) {
|
Blockly.BlockSvg.prototype.setNextStatement = function(newBoolean, opt_check) {
|
||||||
|
@ -1194,7 +1195,7 @@ Blockly.BlockSvg.prototype.setNextStatement = function(newBoolean, opt_check) {
|
||||||
/**
|
/**
|
||||||
* Set whether this block returns a value.
|
* Set whether this block returns a value.
|
||||||
* @param {boolean} newBoolean True if there is an output.
|
* @param {boolean} newBoolean True if there is an output.
|
||||||
* @param {string|Array.<string>|null|undefined} opt_check Returned type or list
|
* @param {(string|Array.<string>|null)=} opt_check Returned type or list
|
||||||
* of returned types. Null or undefined if any type could be returned
|
* of returned types. Null or undefined if any type could be returned
|
||||||
* (e.g. variable get).
|
* (e.g. variable get).
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -386,19 +386,18 @@ Blockly.defineBlocksWithJsonArray = function(jsonArray) {
|
||||||
* Bind an event to a function call. When calling the function, verifies that
|
* Bind an event to a function call. When calling the function, verifies that
|
||||||
* it belongs to the touch stream that is currently being processed, and splits
|
* it belongs to the touch stream that is currently being processed, and splits
|
||||||
* multitouch events into multiple events as needed.
|
* multitouch events into multiple events as needed.
|
||||||
* @param {!Node} node Node upon which to listen.
|
* @param {!EventTarget} node Node upon which to listen.
|
||||||
* @param {string} name Event name to listen to (e.g. 'mousedown').
|
* @param {string} name Event name to listen to (e.g. 'mousedown').
|
||||||
* @param {Object} thisObject The value of 'this' in the function.
|
* @param {Object} thisObject The value of 'this' in the function.
|
||||||
* @param {!Function} func Function to call when event is triggered.
|
* @param {!Function} func Function to call when event is triggered.
|
||||||
* @param {boolean} opt_noCaptureIdentifier True if triggering on this event
|
* @param {boolean=} opt_noCaptureIdentifier True if triggering on this event
|
||||||
* should not block execution of other event handlers on this touch or other
|
* should not block execution of other event handlers on this touch or other
|
||||||
* simultaneous touches.
|
* simultaneous touches.
|
||||||
* @param {boolean} opt_noPreventDefault True if triggering on this event
|
* @param {boolean=} opt_noPreventDefault True if triggering on this event
|
||||||
* should prevent the default handler. False by default. If
|
* should prevent the default handler. False by default. If
|
||||||
* opt_noPreventDefault is provided, opt_noCaptureIdentifier must also be
|
* opt_noPreventDefault is provided, opt_noCaptureIdentifier must also be
|
||||||
* provided.
|
* provided.
|
||||||
* @return {!Array.<!Array>} Opaque data that can be passed to unbindEvent_.
|
* @return {!Array.<!Array>} Opaque data that can be passed to unbindEvent_.
|
||||||
* @private
|
|
||||||
*/
|
*/
|
||||||
Blockly.bindEventWithChecks_ = function(node, name, thisObject, func,
|
Blockly.bindEventWithChecks_ = function(node, name, thisObject, func,
|
||||||
opt_noCaptureIdentifier, opt_noPreventDefault) {
|
opt_noCaptureIdentifier, opt_noPreventDefault) {
|
||||||
|
@ -452,7 +451,7 @@ Blockly.bindEventWithChecks_ = function(node, name, thisObject, func,
|
||||||
* simultaneous event processing.
|
* simultaneous event processing.
|
||||||
* @deprecated in favor of bindEventWithChecks_, but preserved for external
|
* @deprecated in favor of bindEventWithChecks_, but preserved for external
|
||||||
* users.
|
* users.
|
||||||
* @param {!Node} node Node upon which to listen.
|
* @param {!EventTarget} node Node upon which to listen.
|
||||||
* @param {string} name Event name to listen to (e.g. 'mousedown').
|
* @param {string} name Event name to listen to (e.g. 'mousedown').
|
||||||
* @param {Object} thisObject The value of 'this' in the function.
|
* @param {Object} thisObject The value of 'this' in the function.
|
||||||
* @param {!Function} func Function to call when event is triggered.
|
* @param {!Function} func Function to call when event is triggered.
|
||||||
|
|
|
@ -32,6 +32,6 @@ goog.provide('Blockly.Blocks');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A mapping of block type names to block prototype objects.
|
* A mapping of block type names to block prototype objects.
|
||||||
* @type {!Object<string,Object>}
|
* @type {!Object.<string,Object>}
|
||||||
*/
|
*/
|
||||||
Blockly.Blocks = new Object(null);
|
Blockly.Blocks = new Object(null);
|
||||||
|
|
|
@ -40,14 +40,14 @@ goog.require('goog.userAgent');
|
||||||
* bubble.
|
* bubble.
|
||||||
* @param {!Element} content SVG content for the bubble.
|
* @param {!Element} content SVG content for the bubble.
|
||||||
* @param {Element} shape SVG element to avoid eclipsing.
|
* @param {Element} shape SVG element to avoid eclipsing.
|
||||||
* @param {!goog.math.Coodinate} anchorXY Absolute position of bubble's anchor
|
* @param {!goog.math.Coordinate} anchorXY Absolute position of bubble's anchor
|
||||||
* point.
|
* point.
|
||||||
* @param {?number} bubbleWidth Width of bubble, or null if not resizable.
|
* @param {?number} bubbleWidth Width of bubble, or null if not resizable.
|
||||||
* @param {?number} bubbleHeight Height of bubble, or null if not resizable.
|
* @param {?number} bubbleHeight Height of bubble, or null if not resizable.
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
Blockly.Bubble = function(workspace, content, shape, anchorXY,
|
Blockly.Bubble = function(workspace, content, shape, anchorXY,
|
||||||
bubbleWidth, bubbleHeight) {
|
bubbleWidth, bubbleHeight) {
|
||||||
this.workspace_ = workspace;
|
this.workspace_ = workspace;
|
||||||
this.content_ = content;
|
this.content_ = content;
|
||||||
this.shape_ = shape;
|
this.shape_ = shape;
|
||||||
|
@ -75,11 +75,11 @@ Blockly.Bubble = function(workspace, content, shape, anchorXY,
|
||||||
this.rendered_ = true;
|
this.rendered_ = true;
|
||||||
|
|
||||||
if (!workspace.options.readOnly) {
|
if (!workspace.options.readOnly) {
|
||||||
Blockly.bindEventWithChecks_(this.bubbleBack_, 'mousedown', this,
|
Blockly.bindEventWithChecks_(
|
||||||
this.bubbleMouseDown_);
|
this.bubbleBack_, 'mousedown', this, this.bubbleMouseDown_);
|
||||||
if (this.resizeGroup_) {
|
if (this.resizeGroup_) {
|
||||||
Blockly.bindEventWithChecks_(this.resizeGroup_, 'mousedown', this,
|
Blockly.bindEventWithChecks_(
|
||||||
this.resizeMouseDown_);
|
this.resizeGroup_, 'mousedown', this, this.resizeMouseDown_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -162,14 +162,15 @@ Blockly.Bubble.bubbleMouseUp_ = function(/*e*/) {
|
||||||
Blockly.Bubble.prototype.rendered_ = false;
|
Blockly.Bubble.prototype.rendered_ = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Absolute coordinate of anchor point.
|
* Absolute coordinate of anchor point, in workspace coordinates
|
||||||
* @type {goog.math.Coordinate}
|
* @type {goog.math.Coordinate}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
Blockly.Bubble.prototype.anchorXY_ = null;
|
Blockly.Bubble.prototype.anchorXY_ = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Relative X coordinate of bubble with respect to the anchor's centre.
|
* Relative X coordinate of bubble with respect to the anchor's centre,
|
||||||
|
* in workspace units.
|
||||||
* In RTL mode the initial value is negated.
|
* In RTL mode the initial value is negated.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
|
@ -235,8 +236,13 @@ Blockly.Bubble.prototype.createDom_ = function(content, hasResize) {
|
||||||
filter, this.bubbleGroup_);
|
filter, this.bubbleGroup_);
|
||||||
this.bubbleArrow_ = Blockly.utils.createSvgElement('path', {}, bubbleEmboss);
|
this.bubbleArrow_ = Blockly.utils.createSvgElement('path', {}, bubbleEmboss);
|
||||||
this.bubbleBack_ = Blockly.utils.createSvgElement('rect',
|
this.bubbleBack_ = Blockly.utils.createSvgElement('rect',
|
||||||
{'class': 'blocklyDraggable', 'x': 0, 'y': 0,
|
{
|
||||||
'rx': Blockly.Bubble.BORDER_WIDTH, 'ry': Blockly.Bubble.BORDER_WIDTH},
|
'class': 'blocklyDraggable',
|
||||||
|
'x': 0,
|
||||||
|
'y': 0,
|
||||||
|
'rx': Blockly.Bubble.BORDER_WIDTH,
|
||||||
|
'ry': Blockly.Bubble.BORDER_WIDTH
|
||||||
|
},
|
||||||
bubbleEmboss);
|
bubbleEmboss);
|
||||||
if (hasResize) {
|
if (hasResize) {
|
||||||
this.resizeGroup_ = Blockly.utils.createSvgElement('g',
|
this.resizeGroup_ = Blockly.utils.createSvgElement('g',
|
||||||
|
@ -248,13 +254,21 @@ Blockly.Bubble.prototype.createDom_ = function(content, hasResize) {
|
||||||
{'points': '0,x x,x x,0'.replace(/x/g, resizeSize.toString())},
|
{'points': '0,x x,x x,0'.replace(/x/g, resizeSize.toString())},
|
||||||
this.resizeGroup_);
|
this.resizeGroup_);
|
||||||
Blockly.utils.createSvgElement('line',
|
Blockly.utils.createSvgElement('line',
|
||||||
{'class': 'blocklyResizeLine',
|
{
|
||||||
'x1': resizeSize / 3, 'y1': resizeSize - 1,
|
'class': 'blocklyResizeLine',
|
||||||
'x2': resizeSize - 1, 'y2': resizeSize / 3}, this.resizeGroup_);
|
'x1': resizeSize / 3,
|
||||||
|
'y1': resizeSize - 1,
|
||||||
|
'x2': resizeSize - 1,
|
||||||
|
'y2': resizeSize / 3
|
||||||
|
}, this.resizeGroup_);
|
||||||
Blockly.utils.createSvgElement('line',
|
Blockly.utils.createSvgElement('line',
|
||||||
{'class': 'blocklyResizeLine',
|
{
|
||||||
'x1': resizeSize * 2 / 3, 'y1': resizeSize - 1,
|
'class': 'blocklyResizeLine',
|
||||||
'x2': resizeSize - 1, 'y2': resizeSize * 2 / 3}, this.resizeGroup_);
|
'x1': resizeSize * 2 / 3,
|
||||||
|
'y1': resizeSize - 1,
|
||||||
|
'x2': resizeSize - 1,
|
||||||
|
'y2': resizeSize * 2 / 3
|
||||||
|
}, this.resizeGroup_);
|
||||||
} else {
|
} else {
|
||||||
this.resizeGroup_ = null;
|
this.resizeGroup_ = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,21 +70,27 @@ Blockly.Comment.prototype.drawIcon_ = function(group) {
|
||||||
// Circle.
|
// Circle.
|
||||||
Blockly.utils.createSvgElement('circle',
|
Blockly.utils.createSvgElement('circle',
|
||||||
{'class': 'blocklyIconShape', 'r': '8', 'cx': '8', 'cy': '8'},
|
{'class': 'blocklyIconShape', 'r': '8', 'cx': '8', 'cy': '8'},
|
||||||
group);
|
group);
|
||||||
// Can't use a real '?' text character since different browsers and operating
|
// Can't use a real '?' text character since different browsers and operating
|
||||||
// systems render it differently.
|
// systems render it differently.
|
||||||
// Body of question mark.
|
// Body of question mark.
|
||||||
Blockly.utils.createSvgElement('path',
|
Blockly.utils.createSvgElement('path',
|
||||||
{'class': 'blocklyIconSymbol',
|
{
|
||||||
'd': 'm6.8,10h2c0.003,-0.617 0.271,-0.962 0.633,-1.266 2.875,-2.405' +
|
'class': 'blocklyIconSymbol',
|
||||||
' 0.607,-5.534 -3.765,-3.874v1.7c3.12,-1.657 3.698,0.118 2.336,1.25' +
|
'd': 'm6.8,10h2c0.003,-0.617 0.271,-0.962 0.633,-1.266 2.875,-2.405' +
|
||||||
' -1.201,0.998 -1.201,1.528 -1.204,2.19z'},
|
'0.607,-5.534 -3.765,-3.874v1.7c3.12,-1.657 3.698,0.118 2.336,1.25' +
|
||||||
group);
|
'-1.201,0.998 -1.201,1.528 -1.204,2.19z'},
|
||||||
|
group);
|
||||||
// Dot of question mark.
|
// Dot of question mark.
|
||||||
Blockly.utils.createSvgElement('rect',
|
Blockly.utils.createSvgElement('rect',
|
||||||
{'class': 'blocklyIconSymbol',
|
{
|
||||||
'x': '6.8', 'y': '10.78', 'height': '2', 'width': '2'},
|
'class': 'blocklyIconSymbol',
|
||||||
group);
|
'x': '6.8',
|
||||||
|
'y': '10.78',
|
||||||
|
'height': '2',
|
||||||
|
'width': '2'
|
||||||
|
},
|
||||||
|
group);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -260,7 +266,7 @@ Blockly.Comment.prototype.getText = function() {
|
||||||
Blockly.Comment.prototype.setText = function(text) {
|
Blockly.Comment.prototype.setText = function(text) {
|
||||||
if (this.text_ != text) {
|
if (this.text_ != text) {
|
||||||
Blockly.Events.fire(new Blockly.Events.BlockChange(
|
Blockly.Events.fire(new Blockly.Events.BlockChange(
|
||||||
this.block_, 'comment', null, this.text_, text));
|
this.block_, 'comment', null, this.text_, text));
|
||||||
this.text_ = text;
|
this.text_ = text;
|
||||||
}
|
}
|
||||||
if (this.textarea_) {
|
if (this.textarea_) {
|
||||||
|
|
|
@ -39,7 +39,7 @@ goog.require('goog.dom');
|
||||||
Blockly.Connection = function(source, type) {
|
Blockly.Connection = function(source, type) {
|
||||||
/**
|
/**
|
||||||
* @type {!Blockly.Block}
|
* @type {!Blockly.Block}
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
this.sourceBlock_ = source;
|
this.sourceBlock_ = source;
|
||||||
/** @type {number} */
|
/** @type {number} */
|
||||||
|
@ -89,28 +89,28 @@ Blockly.Connection.prototype.shadowDom_ = null;
|
||||||
/**
|
/**
|
||||||
* Horizontal location of this connection.
|
* Horizontal location of this connection.
|
||||||
* @type {number}
|
* @type {number}
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
Blockly.Connection.prototype.x_ = 0;
|
Blockly.Connection.prototype.x_ = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vertical location of this connection.
|
* Vertical location of this connection.
|
||||||
* @type {number}
|
* @type {number}
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
Blockly.Connection.prototype.y_ = 0;
|
Blockly.Connection.prototype.y_ = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Has this connection been added to the connection database?
|
* Has this connection been added to the connection database?
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
Blockly.Connection.prototype.inDB_ = false;
|
Blockly.Connection.prototype.inDB_ = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connection database for connections of this type on the current workspace.
|
* Connection database for connections of this type on the current workspace.
|
||||||
* @type {Blockly.ConnectionDB}
|
* @type {Blockly.ConnectionDB}
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
Blockly.Connection.prototype.db_ = null;
|
Blockly.Connection.prototype.db_ = null;
|
||||||
|
|
||||||
|
@ -118,14 +118,14 @@ Blockly.Connection.prototype.db_ = null;
|
||||||
* Connection database for connections compatible with this type on the
|
* Connection database for connections compatible with this type on the
|
||||||
* current workspace.
|
* current workspace.
|
||||||
* @type {Blockly.ConnectionDB}
|
* @type {Blockly.ConnectionDB}
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
Blockly.Connection.prototype.dbOpposite_ = null;
|
Blockly.Connection.prototype.dbOpposite_ = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether this connections is hidden (not tracked in a database) or not.
|
* Whether this connections is hidden (not tracked in a database) or not.
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
Blockly.Connection.prototype.hidden_ = null;
|
Blockly.Connection.prototype.hidden_ = null;
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ Blockly.Connection.prototype.hidden_ = null;
|
||||||
* Connect two connections together. This is the connection on the superior
|
* Connect two connections together. This is the connection on the superior
|
||||||
* block.
|
* block.
|
||||||
* @param {!Blockly.Connection} childConnection Connection on inferior block.
|
* @param {!Blockly.Connection} childConnection Connection on inferior block.
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
Blockly.Connection.prototype.connect_ = function(childConnection) {
|
Blockly.Connection.prototype.connect_ = function(childConnection) {
|
||||||
var parentConnection = this;
|
var parentConnection = this;
|
||||||
|
@ -537,7 +537,7 @@ Blockly.Connection.singleConnection_ = function(block, orphanBlock) {
|
||||||
if (thisConnection && thisConnection.type == Blockly.INPUT_VALUE &&
|
if (thisConnection && thisConnection.type == Blockly.INPUT_VALUE &&
|
||||||
orphanBlock.outputConnection.checkType_(thisConnection)) {
|
orphanBlock.outputConnection.checkType_(thisConnection)) {
|
||||||
if (connection) {
|
if (connection) {
|
||||||
return null; // More than one connection.
|
return null; // More than one connection.
|
||||||
}
|
}
|
||||||
connection = thisConnection;
|
connection = thisConnection;
|
||||||
}
|
}
|
||||||
|
@ -574,7 +574,7 @@ Blockly.Connection.prototype.disconnect = function() {
|
||||||
* Disconnect two blocks that are connected by this connection.
|
* Disconnect two blocks that are connected by this connection.
|
||||||
* @param {!Blockly.Block} parentBlock The superior block.
|
* @param {!Blockly.Block} parentBlock The superior block.
|
||||||
* @param {!Blockly.Block} childBlock The inferior block.
|
* @param {!Blockly.Block} childBlock The inferior block.
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
Blockly.Connection.prototype.disconnectInternal_ = function(parentBlock,
|
Blockly.Connection.prototype.disconnectInternal_ = function(parentBlock,
|
||||||
childBlock) {
|
childBlock) {
|
||||||
|
@ -594,7 +594,7 @@ Blockly.Connection.prototype.disconnectInternal_ = function(parentBlock,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Respawn the shadow block if there was one connected to the this connection.
|
* Respawn the shadow block if there was one connected to the this connection.
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
Blockly.Connection.prototype.respawnShadow_ = function() {
|
Blockly.Connection.prototype.respawnShadow_ = function() {
|
||||||
var parentBlock = this.getSourceBlock();
|
var parentBlock = this.getSourceBlock();
|
||||||
|
@ -628,7 +628,7 @@ Blockly.Connection.prototype.targetBlock = function() {
|
||||||
* value type system. E.g. square_root("Hello") is not compatible.
|
* value type system. E.g. square_root("Hello") is not compatible.
|
||||||
* @param {!Blockly.Connection} otherConnection Connection to compare against.
|
* @param {!Blockly.Connection} otherConnection Connection to compare against.
|
||||||
* @return {boolean} True if the connections share a type.
|
* @return {boolean} True if the connections share a type.
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
Blockly.Connection.prototype.checkType_ = function(otherConnection) {
|
Blockly.Connection.prototype.checkType_ = function(otherConnection) {
|
||||||
if (!this.check_ || !otherConnection.check_) {
|
if (!this.check_ || !otherConnection.check_) {
|
||||||
|
|
|
@ -109,9 +109,8 @@ Blockly.ConnectionDB.prototype.findConnection = function(conn) {
|
||||||
* @return {number} The candidate index.
|
* @return {number} The candidate index.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
Blockly.ConnectionDB.prototype.findPositionForConnection_ =
|
Blockly.ConnectionDB.prototype.findPositionForConnection_ = function(
|
||||||
function(connection) {
|
connection) {
|
||||||
/* eslint-disable indent */
|
|
||||||
if (!this.length) {
|
if (!this.length) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -129,7 +128,7 @@ Blockly.ConnectionDB.prototype.findPositionForConnection_ =
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pointerMin;
|
return pointerMin;
|
||||||
}; /* eslint-enable indent */
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a connection from the database. Must already exist in DB.
|
* Remove a connection from the database. Must already exist in DB.
|
||||||
|
|
|
@ -67,8 +67,8 @@ Blockly.ContextMenu.show = function(e, options, rtl) {
|
||||||
}
|
}
|
||||||
var menu = Blockly.ContextMenu.populate_(options, rtl);
|
var menu = Blockly.ContextMenu.populate_(options, rtl);
|
||||||
|
|
||||||
goog.events.listen(menu, goog.ui.Component.EventType.ACTION,
|
goog.events.listen(
|
||||||
Blockly.ContextMenu.hide);
|
menu, goog.ui.Component.EventType.ACTION, Blockly.ContextMenu.hide);
|
||||||
|
|
||||||
Blockly.ContextMenu.position_(menu, e, rtl);
|
Blockly.ContextMenu.position_(menu, e, rtl);
|
||||||
// 1ms delay is required for focusing on context menus because some other
|
// 1ms delay is required for focusing on context menus because some other
|
||||||
|
@ -98,8 +98,8 @@ Blockly.ContextMenu.populate_ = function(options, rtl) {
|
||||||
menu.addChild(menuItem, true);
|
menu.addChild(menuItem, true);
|
||||||
menuItem.setEnabled(option.enabled);
|
menuItem.setEnabled(option.enabled);
|
||||||
if (option.enabled) {
|
if (option.enabled) {
|
||||||
goog.events.listen(menuItem, goog.ui.Component.EventType.ACTION,
|
goog.events.listen(
|
||||||
option.callback);
|
menuItem, goog.ui.Component.EventType.ACTION, option.callback);
|
||||||
menuItem.handleContextMenu = function(/* e */) {
|
menuItem.handleContextMenu = function(/* e */) {
|
||||||
// Right-clicking on menu option should count as a click.
|
// Right-clicking on menu option should count as a click.
|
||||||
goog.events.dispatchEvent(this, goog.ui.Component.EventType.ACTION);
|
goog.events.dispatchEvent(this, goog.ui.Component.EventType.ACTION);
|
||||||
|
@ -154,8 +154,8 @@ Blockly.ContextMenu.createWidget_ = function(menu) {
|
||||||
var menuDom = menu.getElement();
|
var menuDom = menu.getElement();
|
||||||
Blockly.utils.addClass(menuDom, 'blocklyContextMenu');
|
Blockly.utils.addClass(menuDom, 'blocklyContextMenu');
|
||||||
// Prevent system context menu when right-clicking a Blockly context menu.
|
// Prevent system context menu when right-clicking a Blockly context menu.
|
||||||
Blockly.bindEventWithChecks_(menuDom, 'contextmenu', null,
|
Blockly.bindEventWithChecks_(
|
||||||
Blockly.utils.noEvent);
|
menuDom, 'contextmenu', null, Blockly.utils.noEvent);
|
||||||
// Enable autofocus after the initial render to avoid issue #1329.
|
// Enable autofocus after the initial render to avoid issue #1329.
|
||||||
menu.setAllowAutoFocus(true);
|
menu.setAllowAutoFocus(true);
|
||||||
};
|
};
|
||||||
|
|
|
@ -99,13 +99,13 @@ Blockly.Extensions.registerMutator = function(name, mixinObj, opt_helperFn,
|
||||||
var errorPrefix = 'Error when registering mutator "' + name + '": ';
|
var errorPrefix = 'Error when registering mutator "' + name + '": ';
|
||||||
|
|
||||||
// Sanity check the mixin object before registering it.
|
// Sanity check the mixin object before registering it.
|
||||||
Blockly.Extensions.checkHasFunction_(errorPrefix, mixinObj.domToMutation,
|
Blockly.Extensions.checkHasFunction_(
|
||||||
'domToMutation');
|
errorPrefix, mixinObj.domToMutation, 'domToMutation');
|
||||||
Blockly.Extensions.checkHasFunction_(errorPrefix, mixinObj.mutationToDom,
|
Blockly.Extensions.checkHasFunction_(
|
||||||
'mutationToDom');
|
errorPrefix, mixinObj.mutationToDom, 'mutationToDom');
|
||||||
|
|
||||||
var hasMutatorDialog = Blockly.Extensions.checkMutatorDialog_(mixinObj,
|
var hasMutatorDialog =
|
||||||
errorPrefix);
|
Blockly.Extensions.checkMutatorDialog_(mixinObj, errorPrefix);
|
||||||
|
|
||||||
if (opt_helperFn && !goog.isFunction(opt_helperFn)) {
|
if (opt_helperFn && !goog.isFunction(opt_helperFn)) {
|
||||||
throw new Error('Extension "' + name + '" is not a function');
|
throw new Error('Extension "' + name + '" is not a function');
|
||||||
|
@ -313,11 +313,12 @@ Blockly.Extensions.mutatorPropertiesMatch_ = function(oldProperties, block) {
|
||||||
* reported as warnings in the console, and are never fatal.
|
* reported as warnings in the console, and are never fatal.
|
||||||
* @param {string} dropdownName The name of the field whose value is the key
|
* @param {string} dropdownName The name of the field whose value is the key
|
||||||
* to the lookup table.
|
* to the lookup table.
|
||||||
* @param {!Object<string, string>} lookupTable The table of field values to
|
* @param {!Object.<string, string>} lookupTable The table of field values to
|
||||||
* tooltip text.
|
* tooltip text.
|
||||||
* @return {Function} The extension function.
|
* @return {Function} The extension function.
|
||||||
*/
|
*/
|
||||||
Blockly.Extensions.buildTooltipForDropdown = function(dropdownName, lookupTable) {
|
Blockly.Extensions.buildTooltipForDropdown = function(dropdownName,
|
||||||
|
lookupTable) {
|
||||||
// List of block types already validated, to minimize duplicate warnings.
|
// List of block types already validated, to minimize duplicate warnings.
|
||||||
var blockTypesChecked = [];
|
var blockTypesChecked = [];
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ Blockly.Flyout = function(workspaceOptions) {
|
||||||
/**
|
/**
|
||||||
* Position of the toolbox and flyout relative to the workspace.
|
* Position of the toolbox and flyout relative to the workspace.
|
||||||
* @type {number}
|
* @type {number}
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
this.toolboxPosition_ = workspaceOptions.toolboxPosition;
|
this.toolboxPosition_ = workspaceOptions.toolboxPosition;
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ Blockly.Flyout = function(workspaceOptions) {
|
||||||
/**
|
/**
|
||||||
* List of visible buttons.
|
* List of visible buttons.
|
||||||
* @type {!Array.<!Blockly.FlyoutButton>}
|
* @type {!Array.<!Blockly.FlyoutButton>}
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
this.buttons_ = [];
|
this.buttons_ = [];
|
||||||
|
|
||||||
|
@ -188,14 +188,14 @@ Blockly.Flyout.prototype.SCROLLBAR_PADDING = 2;
|
||||||
/**
|
/**
|
||||||
* Width of flyout.
|
* Width of flyout.
|
||||||
* @type {number}
|
* @type {number}
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
Blockly.Flyout.prototype.width_ = 0;
|
Blockly.Flyout.prototype.width_ = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Height of flyout.
|
* Height of flyout.
|
||||||
* @type {number}
|
* @type {number}
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
Blockly.Flyout.prototype.height_ = 0;
|
Blockly.Flyout.prototype.height_ = 0;
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ Blockly.Flyout.prototype.verticalOffset_ = 0;
|
||||||
* This is used to know when to create a new block and when to scroll the
|
* This is used to know when to create a new block and when to scroll the
|
||||||
* flyout. Setting it to 360 means that all drags create a new block.
|
* flyout. Setting it to 360 means that all drags create a new block.
|
||||||
* @type {number}
|
* @type {number}
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
Blockly.Flyout.prototype.dragAngleRange_ = 70;
|
Blockly.Flyout.prototype.dragAngleRange_ = 70;
|
||||||
|
|
||||||
|
@ -264,7 +264,7 @@ Blockly.Flyout.prototype.createDom = function(tagName) {
|
||||||
// Setting style to display:none to start. The toolbox and flyout
|
// Setting style to display:none to start. The toolbox and flyout
|
||||||
// hide/show code will set up proper visibility and size later.
|
// hide/show code will set up proper visibility and size later.
|
||||||
this.svgGroup_ = Blockly.utils.createSvgElement(tagName,
|
this.svgGroup_ = Blockly.utils.createSvgElement(tagName,
|
||||||
{'class': 'blocklyFlyout', 'style' : 'display: none'}, null);
|
{'class': 'blocklyFlyout', 'style': 'display: none'}, null);
|
||||||
this.svgBackground_ = Blockly.utils.createSvgElement('path',
|
this.svgBackground_ = Blockly.utils.createSvgElement('path',
|
||||||
{'class': 'blocklyFlyoutBackground'}, this.svgGroup_);
|
{'class': 'blocklyFlyoutBackground'}, this.svgGroup_);
|
||||||
this.svgGroup_.appendChild(this.workspace_.createDom());
|
this.svgGroup_.appendChild(this.workspace_.createDom());
|
||||||
|
@ -289,7 +289,8 @@ Blockly.Flyout.prototype.init = function(targetWorkspace) {
|
||||||
Blockly.bindEventWithChecks_(this.svgGroup_, 'wheel', this, this.wheel_));
|
Blockly.bindEventWithChecks_(this.svgGroup_, 'wheel', this, this.wheel_));
|
||||||
// Dragging the flyout up and down (or left and right).
|
// Dragging the flyout up and down (or left and right).
|
||||||
Array.prototype.push.apply(this.eventWrappers_,
|
Array.prototype.push.apply(this.eventWrappers_,
|
||||||
Blockly.bindEventWithChecks_(this.svgGroup_, 'mousedown', this, this.onMouseDown_));
|
Blockly.bindEventWithChecks_(
|
||||||
|
this.svgBackground_, 'mousedown', this, this.onMouseDown_));
|
||||||
|
|
||||||
// A flyout connected to a workspace doesn't have its own current gesture.
|
// A flyout connected to a workspace doesn't have its own current gesture.
|
||||||
this.workspace_.getGesture =
|
this.workspace_.getGesture =
|
||||||
|
|
|
@ -194,7 +194,7 @@ Blockly.FlyoutButton.prototype.show = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update svg attributes to match internal state.
|
* Update SVG attributes to match internal state.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
Blockly.FlyoutButton.prototype.updateTransform_ = function() {
|
Blockly.FlyoutButton.prototype.updateTransform_ = function() {
|
||||||
|
|
11
core/grid.js
11
core/grid.js
|
@ -121,7 +121,7 @@ Blockly.Grid.prototype.getSpacing = function() {
|
||||||
/**
|
/**
|
||||||
* Get the id of the pattern element, which should be randomized to avoid
|
* Get the id of the pattern element, which should be randomized to avoid
|
||||||
* conflicts with other Blockly instances on the page.
|
* conflicts with other Blockly instances on the page.
|
||||||
* @return {string} The pattern id.
|
* @return {string} The pattern ID.
|
||||||
* @package
|
* @package
|
||||||
*/
|
*/
|
||||||
Blockly.Grid.prototype.getPatternId = function() {
|
Blockly.Grid.prototype.getPatternId = function() {
|
||||||
|
@ -207,8 +207,10 @@ Blockly.Grid.createDom = function(rnd, gridOptions, defs) {
|
||||||
</pattern>
|
</pattern>
|
||||||
*/
|
*/
|
||||||
var gridPattern = Blockly.utils.createSvgElement('pattern',
|
var gridPattern = Blockly.utils.createSvgElement('pattern',
|
||||||
{'id': 'blocklyGridPattern' + rnd,
|
{
|
||||||
'patternUnits': 'userSpaceOnUse'}, defs);
|
'id': 'blocklyGridPattern' + rnd,
|
||||||
|
'patternUnits': 'userSpaceOnUse'
|
||||||
|
}, defs);
|
||||||
if (gridOptions['length'] > 0 && gridOptions['spacing'] > 0) {
|
if (gridOptions['length'] > 0 && gridOptions['spacing'] > 0) {
|
||||||
Blockly.utils.createSvgElement('line',
|
Blockly.utils.createSvgElement('line',
|
||||||
{'stroke': gridOptions['colour']}, gridPattern);
|
{'stroke': gridOptions['colour']}, gridPattern);
|
||||||
|
@ -217,6 +219,9 @@ Blockly.Grid.createDom = function(rnd, gridOptions, defs) {
|
||||||
{'stroke': gridOptions['colour']}, gridPattern);
|
{'stroke': gridOptions['colour']}, gridPattern);
|
||||||
}
|
}
|
||||||
// x1, y1, x1, x2 properties will be set later in update.
|
// x1, y1, x1, x2 properties will be set later in update.
|
||||||
|
} else {
|
||||||
|
// Edge 16 doesn't handle empty patterns
|
||||||
|
Blockly.utils.createSvgElement('line', {}, gridPattern);
|
||||||
}
|
}
|
||||||
return gridPattern;
|
return gridPattern;
|
||||||
};
|
};
|
||||||
|
|
14
core/icon.js
14
core/icon.js
|
@ -52,14 +52,14 @@ Blockly.Icon.prototype.SIZE = 17;
|
||||||
/**
|
/**
|
||||||
* Bubble UI (if visible).
|
* Bubble UI (if visible).
|
||||||
* @type {Blockly.Bubble}
|
* @type {Blockly.Bubble}
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
Blockly.Icon.prototype.bubble_ = null;
|
Blockly.Icon.prototype.bubble_ = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Absolute coordinate of icon's center.
|
* Absolute coordinate of icon's center.
|
||||||
* @type {goog.math.Coordinate}
|
* @type {goog.math.Coordinate}
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
Blockly.Icon.prototype.iconXY_ = null;
|
Blockly.Icon.prototype.iconXY_ = null;
|
||||||
|
|
||||||
|
@ -79,14 +79,14 @@ Blockly.Icon.prototype.createIcon = function() {
|
||||||
this.iconGroup_ = Blockly.utils.createSvgElement('g',
|
this.iconGroup_ = Blockly.utils.createSvgElement('g',
|
||||||
{'class': 'blocklyIconGroup'}, null);
|
{'class': 'blocklyIconGroup'}, null);
|
||||||
if (this.block_.isInFlyout) {
|
if (this.block_.isInFlyout) {
|
||||||
Blockly.utils.addClass(/** @type {!Element} */ (this.iconGroup_),
|
Blockly.utils.addClass(
|
||||||
'blocklyIconGroupReadonly');
|
/** @type {!Element} */ (this.iconGroup_), 'blocklyIconGroupReadonly');
|
||||||
}
|
}
|
||||||
this.drawIcon_(this.iconGroup_);
|
this.drawIcon_(this.iconGroup_);
|
||||||
|
|
||||||
this.block_.getSvgRoot().appendChild(this.iconGroup_);
|
this.block_.getSvgRoot().appendChild(this.iconGroup_);
|
||||||
Blockly.bindEventWithChecks_(this.iconGroup_, 'mouseup', this,
|
Blockly.bindEventWithChecks_(
|
||||||
this.iconClick_);
|
this.iconGroup_, 'mouseup', this, this.iconClick_);
|
||||||
this.updateEditable();
|
this.updateEditable();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ Blockly.Icon.prototype.isVisible = function() {
|
||||||
/**
|
/**
|
||||||
* Clicking on the icon toggles if the bubble is visible.
|
* Clicking on the icon toggles if the bubble is visible.
|
||||||
* @param {!Event} e Mouse click event.
|
* @param {!Event} e Mouse click event.
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
Blockly.Icon.prototype.iconClick_ = function(e) {
|
Blockly.Icon.prototype.iconClick_ = function(e) {
|
||||||
if (this.block_.workspace.isDragging()) {
|
if (this.block_.workspace.isDragging()) {
|
||||||
|
|
|
@ -159,15 +159,17 @@ Blockly.Mutator.prototype.updateEditable = function() {
|
||||||
if (!this.block_.isInFlyout) {
|
if (!this.block_.isInFlyout) {
|
||||||
if (this.block_.isEditable()) {
|
if (this.block_.isEditable()) {
|
||||||
if (this.iconGroup_) {
|
if (this.iconGroup_) {
|
||||||
Blockly.utils.removeClass(/** @type {!Element} */ (this.iconGroup_),
|
Blockly.utils.removeClass(
|
||||||
'blocklyIconGroupReadonly');
|
/** @type {!Element} */ (this.iconGroup_),
|
||||||
|
'blocklyIconGroupReadonly');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Close any mutator bubble. Icon is not clickable.
|
// Close any mutator bubble. Icon is not clickable.
|
||||||
this.setVisible(false);
|
this.setVisible(false);
|
||||||
if (this.iconGroup_) {
|
if (this.iconGroup_) {
|
||||||
Blockly.utils.addClass(/** @type {!Element} */ (this.iconGroup_),
|
Blockly.utils.addClass(
|
||||||
'blocklyIconGroupReadonly');
|
/** @type {!Element} */ (this.iconGroup_),
|
||||||
|
'blocklyIconGroupReadonly');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,8 +204,8 @@ Blockly.Mutator.prototype.resizeBubble_ = function() {
|
||||||
this.workspaceWidth_ = width;
|
this.workspaceWidth_ = width;
|
||||||
this.workspaceHeight_ = height;
|
this.workspaceHeight_ = height;
|
||||||
// Resize the bubble.
|
// Resize the bubble.
|
||||||
this.bubble_.setBubbleSize(width + doubleBorderWidth,
|
this.bubble_.setBubbleSize(
|
||||||
height + doubleBorderWidth);
|
width + doubleBorderWidth, height + doubleBorderWidth);
|
||||||
this.svgDialog_.setAttribute('width', this.workspaceWidth_);
|
this.svgDialog_.setAttribute('width', this.workspaceWidth_);
|
||||||
this.svgDialog_.setAttribute('height', this.workspaceHeight_);
|
this.svgDialog_.setAttribute('height', this.workspaceHeight_);
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,6 +176,7 @@ Blockly.Names.prototype.safeName_ = function(name) {
|
||||||
} else {
|
} else {
|
||||||
// Unfortunately names in non-latin characters will look like
|
// Unfortunately names in non-latin characters will look like
|
||||||
// _E9_9F_B3_E4_B9_90 which is pretty meaningless.
|
// _E9_9F_B3_E4_B9_90 which is pretty meaningless.
|
||||||
|
// https://github.com/google/blockly/issues/1654
|
||||||
name = encodeURI(name.replace(/ /g, '_')).replace(/[^\w]/g, '_');
|
name = encodeURI(name.replace(/ /g, '_')).replace(/[^\w]/g, '_');
|
||||||
// Most languages don't allow names with leading numbers.
|
// Most languages don't allow names with leading numbers.
|
||||||
if ('0123456789'.indexOf(name[0]) != -1) {
|
if ('0123456789'.indexOf(name[0]) != -1) {
|
||||||
|
|
|
@ -199,11 +199,14 @@ Blockly.RenderedConnection.prototype.highlight = function() {
|
||||||
var xy = this.sourceBlock_.getRelativeToSurfaceXY();
|
var xy = this.sourceBlock_.getRelativeToSurfaceXY();
|
||||||
var x = this.x_ - xy.x;
|
var x = this.x_ - xy.x;
|
||||||
var y = this.y_ - xy.y;
|
var y = this.y_ - xy.y;
|
||||||
Blockly.Connection.highlightedPath_ = Blockly.utils.createSvgElement('path',
|
Blockly.Connection.highlightedPath_ = Blockly.utils.createSvgElement(
|
||||||
{'class': 'blocklyHighlightedConnectionPath',
|
'path',
|
||||||
'd': steps,
|
{
|
||||||
transform: 'translate(' + x + ',' + y + ')' +
|
'class': 'blocklyHighlightedConnectionPath',
|
||||||
(this.sourceBlock_.RTL ? ' scale(-1 1)' : '')},
|
'd': steps,
|
||||||
|
transform: 'translate(' + x + ',' + y + ')' +
|
||||||
|
(this.sourceBlock_.RTL ? ' scale(-1 1)' : '')
|
||||||
|
},
|
||||||
this.sourceBlock_.getSvgRoot());
|
this.sourceBlock_.getSvgRoot());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ goog.provide('Blockly.ScrollbarPair');
|
||||||
goog.require('goog.dom');
|
goog.require('goog.dom');
|
||||||
goog.require('goog.events');
|
goog.require('goog.events');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A note on units: most of the numbers that are in CSS pixels are scaled if the
|
* A note on units: most of the numbers that are in CSS pixels are scaled if the
|
||||||
* scrollbar is in a mutator.
|
* scrollbar is in a mutator.
|
||||||
|
@ -42,14 +43,18 @@ goog.require('goog.events');
|
||||||
*/
|
*/
|
||||||
Blockly.ScrollbarPair = function(workspace) {
|
Blockly.ScrollbarPair = function(workspace) {
|
||||||
this.workspace_ = workspace;
|
this.workspace_ = workspace;
|
||||||
this.hScroll = new Blockly.Scrollbar(workspace, true, true,
|
this.hScroll = new Blockly.Scrollbar(
|
||||||
'blocklyMainWorkspaceScrollbar');
|
workspace, true, true, 'blocklyMainWorkspaceScrollbar');
|
||||||
this.vScroll = new Blockly.Scrollbar(workspace, false, true,
|
this.vScroll = new Blockly.Scrollbar(
|
||||||
'blocklyMainWorkspaceScrollbar');
|
workspace, false, true, 'blocklyMainWorkspaceScrollbar');
|
||||||
this.corner_ = Blockly.utils.createSvgElement('rect',
|
this.corner_ = Blockly.utils.createSvgElement(
|
||||||
{'height': Blockly.Scrollbar.scrollbarThickness,
|
'rect',
|
||||||
'width': Blockly.Scrollbar.scrollbarThickness,
|
{
|
||||||
'class': 'blocklyScrollbarBackground'}, null);
|
'height': Blockly.Scrollbar.scrollbarThickness,
|
||||||
|
'width': Blockly.Scrollbar.scrollbarThickness,
|
||||||
|
'class': 'blocklyScrollbarBackground'
|
||||||
|
},
|
||||||
|
null);
|
||||||
Blockly.utils.insertAfter_(this.corner_, workspace.getBubbleCanvas());
|
Blockly.utils.insertAfter_(this.corner_, workspace.getBubbleCanvas());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -189,7 +194,7 @@ Blockly.ScrollbarPair.prototype.getRatio_ = function(handlePosition, viewSize) {
|
||||||
* @param {!Blockly.Workspace} workspace Workspace to bind the scrollbar to.
|
* @param {!Blockly.Workspace} workspace Workspace to bind the scrollbar to.
|
||||||
* @param {boolean} horizontal True if horizontal, false if vertical.
|
* @param {boolean} horizontal True if horizontal, false if vertical.
|
||||||
* @param {boolean=} opt_pair True if scrollbar is part of a horiz/vert pair.
|
* @param {boolean=} opt_pair True if scrollbar is part of a horiz/vert pair.
|
||||||
* @param {string} opt_class A class to be applied to this scrollbar.
|
* @param {string=} opt_class A class to be applied to this scrollbar.
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
Blockly.Scrollbar = function(workspace, horizontal, opt_pair, opt_class) {
|
Blockly.Scrollbar = function(workspace, horizontal, opt_pair, opt_class) {
|
||||||
|
@ -201,7 +206,7 @@ Blockly.Scrollbar = function(workspace, horizontal, opt_pair, opt_class) {
|
||||||
this.createDom_(opt_class);
|
this.createDom_(opt_class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The upper left corner of the scrollbar's svg group in CSS pixels relative
|
* The upper left corner of the scrollbar's SVG group in CSS pixels relative
|
||||||
* to the scrollbar's origin. This is usually relative to the injection div
|
* to the scrollbar's origin. This is usually relative to the injection div
|
||||||
* origin.
|
* origin.
|
||||||
* @type {goog.math.Coordinate}
|
* @type {goog.math.Coordinate}
|
||||||
|
@ -209,24 +214,20 @@ Blockly.Scrollbar = function(workspace, horizontal, opt_pair, opt_class) {
|
||||||
*/
|
*/
|
||||||
this.position_ = new goog.math.Coordinate(0, 0);
|
this.position_ = new goog.math.Coordinate(0, 0);
|
||||||
|
|
||||||
|
// Store the thickness in a temp variable for readability.
|
||||||
|
var scrollbarThickness = Blockly.Scrollbar.scrollbarThickness;
|
||||||
if (horizontal) {
|
if (horizontal) {
|
||||||
this.svgBackground_.setAttribute('height',
|
this.svgBackground_.setAttribute('height', scrollbarThickness);
|
||||||
Blockly.Scrollbar.scrollbarThickness);
|
this.outerSvg_.setAttribute('height', scrollbarThickness);
|
||||||
this.outerSvg_.setAttribute('height',
|
this.svgHandle_.setAttribute('height', scrollbarThickness - 5);
|
||||||
Blockly.Scrollbar.scrollbarThickness);
|
|
||||||
this.svgHandle_.setAttribute('height',
|
|
||||||
Blockly.Scrollbar.scrollbarThickness - 5);
|
|
||||||
this.svgHandle_.setAttribute('y', 2.5);
|
this.svgHandle_.setAttribute('y', 2.5);
|
||||||
|
|
||||||
this.lengthAttribute_ = 'width';
|
this.lengthAttribute_ = 'width';
|
||||||
this.positionAttribute_ = 'x';
|
this.positionAttribute_ = 'x';
|
||||||
} else {
|
} else {
|
||||||
this.svgBackground_.setAttribute('width',
|
this.svgBackground_.setAttribute('width', scrollbarThickness);
|
||||||
Blockly.Scrollbar.scrollbarThickness);
|
this.outerSvg_.setAttribute('width', scrollbarThickness);
|
||||||
this.outerSvg_.setAttribute('width',
|
this.svgHandle_.setAttribute('width', scrollbarThickness - 5);
|
||||||
Blockly.Scrollbar.scrollbarThickness);
|
|
||||||
this.svgHandle_.setAttribute('width',
|
|
||||||
Blockly.Scrollbar.scrollbarThickness - 5);
|
|
||||||
this.svgHandle_.setAttribute('x', 2.5);
|
this.svgHandle_.setAttribute('x', 2.5);
|
||||||
|
|
||||||
this.lengthAttribute_ = 'height';
|
this.lengthAttribute_ = 'height';
|
||||||
|
@ -392,7 +393,7 @@ Blockly.ScrollbarPair.prototype.setContainerVisible = function(visible) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the position of the scrollbar's svg group in CSS pixels relative to the
|
* Set the position of the scrollbar's SVG group in CSS pixels relative to the
|
||||||
* scrollbar's origin. This sets the scrollbar's location within the workspace.
|
* scrollbar's origin. This sets the scrollbar's location within the workspace.
|
||||||
* @param {number} x The new x coordinate.
|
* @param {number} x The new x coordinate.
|
||||||
* @param {number} y The new y coordinate.
|
* @param {number} y The new y coordinate.
|
||||||
|
@ -593,7 +594,7 @@ Blockly.Scrollbar.prototype.resizeContentVertical = function(hostMetrics) {
|
||||||
/**
|
/**
|
||||||
* Create all the DOM elements required for a scrollbar.
|
* Create all the DOM elements required for a scrollbar.
|
||||||
* The resulting widget is not sized.
|
* The resulting widget is not sized.
|
||||||
* @param {string} opt_class A class to be applied to this scrollbar.
|
* @param {string=} opt_class A class to be applied to this scrollbar.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
Blockly.Scrollbar.prototype.createDom_ = function(opt_class) {
|
Blockly.Scrollbar.prototype.createDom_ = function(opt_class) {
|
||||||
|
@ -610,17 +611,21 @@ Blockly.Scrollbar.prototype.createDom_ = function(opt_class) {
|
||||||
if (opt_class) {
|
if (opt_class) {
|
||||||
className += ' ' + opt_class;
|
className += ' ' + opt_class;
|
||||||
}
|
}
|
||||||
this.outerSvg_ = Blockly.utils.createSvgElement('svg', {'class': className},
|
this.outerSvg_ = Blockly.utils.createSvgElement(
|
||||||
null);
|
'svg', {'class': className}, null);
|
||||||
this.svgGroup_ = Blockly.utils.createSvgElement('g', {}, this.outerSvg_);
|
this.svgGroup_ = Blockly.utils.createSvgElement('g', {}, this.outerSvg_);
|
||||||
this.svgBackground_ = Blockly.utils.createSvgElement('rect',
|
this.svgBackground_ = Blockly.utils.createSvgElement(
|
||||||
{'class': 'blocklyScrollbarBackground'}, this.svgGroup_);
|
'rect', {'class': 'blocklyScrollbarBackground'}, this.svgGroup_);
|
||||||
var radius = Math.floor((Blockly.Scrollbar.scrollbarThickness - 5) / 2);
|
var radius = Math.floor((Blockly.Scrollbar.scrollbarThickness - 5) / 2);
|
||||||
this.svgHandle_ = Blockly.utils.createSvgElement('rect',
|
this.svgHandle_ = Blockly.utils.createSvgElement(
|
||||||
{'class': 'blocklyScrollbarHandle', 'rx': radius, 'ry': radius},
|
'rect',
|
||||||
|
{
|
||||||
|
'class': 'blocklyScrollbarHandle',
|
||||||
|
'rx': radius,
|
||||||
|
'ry': radius
|
||||||
|
},
|
||||||
this.svgGroup_);
|
this.svgGroup_);
|
||||||
Blockly.utils.insertAfter_(this.outerSvg_,
|
Blockly.utils.insertAfter_(this.outerSvg_, this.workspace_.getParentSvg());
|
||||||
this.workspace_.getParentSvg());
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -669,7 +674,7 @@ Blockly.Scrollbar.prototype.setVisible = function(visible) {
|
||||||
* Update visibility of scrollbar based on whether it thinks it should
|
* Update visibility of scrollbar based on whether it thinks it should
|
||||||
* be visible and whether its containing workspace is visible.
|
* be visible and whether its containing workspace is visible.
|
||||||
* We cannot rely on the containing workspace being hidden to hide us
|
* We cannot rely on the containing workspace being hidden to hide us
|
||||||
* because it is not necessarily our parent in the dom.
|
* because it is not necessarily our parent in the DOM.
|
||||||
*/
|
*/
|
||||||
Blockly.Scrollbar.prototype.updateDisplay_ = function() {
|
Blockly.Scrollbar.prototype.updateDisplay_ = function() {
|
||||||
var show = true;
|
var show = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue