mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-06-15 22:33:38 -04:00
Merge pull request #1687 from rachel-fenichel/merge_cleanup_1
Utility function cleanup for merges
This commit is contained in:
commit
1e750d5b60
10 changed files with 22 additions and 16 deletions
|
@ -83,6 +83,11 @@ Blockly.BlockSvg = function(workspace, prototypeName, opt_id) {
|
|||
Blockly.Tooltip.bindMouseEvents(this.svgPath_);
|
||||
Blockly.BlockSvg.superClass_.constructor.call(this,
|
||||
workspace, prototypeName, opt_id);
|
||||
|
||||
// Expose this block's ID on its top-level SVG group.
|
||||
if (this.svgGroup_.dataset) {
|
||||
this.svgGroup_.dataset.id = this.id;
|
||||
}
|
||||
};
|
||||
goog.inherits(Blockly.BlockSvg, Blockly.Block);
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ goog.provide('Blockly.Bubble');
|
|||
goog.require('Blockly.Touch');
|
||||
goog.require('Blockly.Workspace');
|
||||
goog.require('goog.dom');
|
||||
goog.require('goog.math');
|
||||
goog.require('goog.math.Coordinate');
|
||||
goog.require('goog.userAgent');
|
||||
|
||||
|
@ -56,7 +55,7 @@ Blockly.Bubble = function(workspace, content, shape, anchorXY,
|
|||
if (this.workspace_.RTL) {
|
||||
angle = -angle;
|
||||
}
|
||||
this.arrow_radians_ = goog.math.toRadians(angle);
|
||||
this.arrow_radians_ = Blockly.utils.toRadians(angle);
|
||||
|
||||
var canvas = workspace.getBubbleCanvas();
|
||||
canvas.appendChild(this.createDom_(content, !!(bubbleWidth && bubbleHeight)));
|
||||
|
|
|
@ -159,7 +159,7 @@ Blockly.BubbleDragger.prototype.maybeDeleteBubble_ = function() {
|
|||
|
||||
if (this.wouldDeleteBubble_) {
|
||||
if (trashcan) {
|
||||
goog.Timer.callOnce(trashcan.close, 100, trashcan);
|
||||
setTimeout(trashcan.close.bind(trashcan), 100);
|
||||
}
|
||||
// Fire a move event, so we know where to go back to for an undo.
|
||||
this.fireMoveEvent_();
|
||||
|
|
|
@ -199,6 +199,8 @@ Blockly.Comment.prototype.setVisible = function(visible) {
|
|||
/** @type {!Blockly.WorkspaceSvg} */ (this.block_.workspace),
|
||||
this.createEditor_(), this.block_.svgPath_,
|
||||
this.iconXY_, this.width_, this.height_);
|
||||
// Expose this comment's block's ID on its top-level SVG group.
|
||||
this.bubble_.setSvgId(this.block_.id);
|
||||
this.bubble_.registerResizeEvent(this.resizeBubble_.bind(this));
|
||||
this.updateColour();
|
||||
} else {
|
||||
|
|
|
@ -281,7 +281,7 @@ Blockly.createMainWorkspace_ = function(svg, options, blockDragSurface, workspac
|
|||
if (!options.hasCategories && options.languageTree) {
|
||||
// Add flyout as an <svg> that is a sibling of the workspace svg.
|
||||
var flyout = mainWorkspace.addFlyout_('svg');
|
||||
Blockly.utils.insertAfter_(flyout, svg);
|
||||
Blockly.utils.insertAfter(flyout, svg);
|
||||
}
|
||||
|
||||
// A null translation will also apply the correct initial scale.
|
||||
|
|
|
@ -55,7 +55,7 @@ Blockly.ScrollbarPair = function(workspace) {
|
|||
'class': 'blocklyScrollbarBackground'
|
||||
},
|
||||
null);
|
||||
Blockly.utils.insertAfter_(this.corner_, workspace.getBubbleCanvas());
|
||||
Blockly.utils.insertAfter(this.corner_, workspace.getBubbleCanvas());
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -625,7 +625,7 @@ Blockly.Scrollbar.prototype.createDom_ = function(opt_class) {
|
|||
'ry': radius
|
||||
},
|
||||
this.svgGroup_);
|
||||
Blockly.utils.insertAfter_(this.outerSvg_, this.workspace_.getParentSvg());
|
||||
Blockly.utils.insertAfter(this.outerSvg_, this.workspace_.getParentSvg());
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -180,7 +180,7 @@ Blockly.Touch.checkTouchIdentifier = function(e) {
|
|||
* @param {!Event} e A touch event.
|
||||
*/
|
||||
Blockly.Touch.setClientFromTouch = function(e) {
|
||||
if (goog.string.startsWith(e.type, 'touch')) {
|
||||
if (Blockly.utils.startsWith(e.type, 'touch')) {
|
||||
// Map the touch event's properties to the event.
|
||||
var touchPoint = e.changedTouches[0];
|
||||
e.clientX = touchPoint.clientX;
|
||||
|
@ -194,8 +194,8 @@ Blockly.Touch.setClientFromTouch = function(e) {
|
|||
* @return {boolean} true if it is a mouse or touch event; false otherwise.
|
||||
*/
|
||||
Blockly.Touch.isMouseOrTouchEvent = function(e) {
|
||||
return goog.string.startsWith(e.type, 'touch') ||
|
||||
goog.string.startsWith(e.type, 'mouse');
|
||||
return Blockly.utils.startsWith(e.type, 'touch') ||
|
||||
Blockly.utils.startsWith(e.type, 'mouse');
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
goog.provide('Blockly.Trashcan');
|
||||
|
||||
goog.require('goog.dom');
|
||||
goog.require('goog.math');
|
||||
goog.require('goog.math.Rect');
|
||||
|
||||
|
||||
|
@ -309,13 +308,14 @@ Blockly.Trashcan.prototype.setOpen_ = function(state) {
|
|||
*/
|
||||
Blockly.Trashcan.prototype.animateLid_ = function() {
|
||||
this.lidOpen_ += this.isOpen ? 0.2 : -0.2;
|
||||
this.lidOpen_ = goog.math.clamp(this.lidOpen_, 0, 1);
|
||||
this.lidOpen_ = Math.min(Math.max(this.lidOpen_, 0), 1);
|
||||
var lidAngle = this.lidOpen_ * 45;
|
||||
this.svgLid_.setAttribute('transform', 'rotate(' +
|
||||
(this.workspace_.RTL ? -lidAngle : lidAngle) + ',' +
|
||||
(this.workspace_.RTL ? 4 : this.WIDTH_ - 4) + ',' +
|
||||
(this.LID_HEIGHT_ - 2) + ')');
|
||||
var opacity = goog.math.lerp(0.4, 0.8, this.lidOpen_);
|
||||
// Linear interpolation between 0.4 and 0.8.
|
||||
var opacity = 0.4 + this.lidOpen_ * (0.8 - 0.4);
|
||||
this.svgGroup_.style.opacity = opacity;
|
||||
if (this.lidOpen_ > 0 && this.lidOpen_ < 1) {
|
||||
this.lidTask_ = setTimeout(this.animateLid_.bind(this), 20);
|
||||
|
|
|
@ -867,9 +867,9 @@ Blockly.utils.is3dSupported = function() {
|
|||
* Contrast with node.insertBefore function.
|
||||
* @param {!Element} newNode New element to insert.
|
||||
* @param {!Element} refNode Existing element to precede new node.
|
||||
* @private
|
||||
* @package
|
||||
*/
|
||||
Blockly.utils.insertAfter_ = function(newNode, refNode) {
|
||||
Blockly.utils.insertAfter = function(newNode, refNode) {
|
||||
var siblingNode = refNode.nextSibling;
|
||||
var parentNode = refNode.parentNode;
|
||||
if (!parentNode) {
|
||||
|
|
|
@ -151,13 +151,13 @@ Blockly.WorkspaceDragSurfaceSvg.prototype.clearAndHide = function(newSurface) {
|
|||
// If there is a previous sibling, put the blockCanvas back right afterwards,
|
||||
// otherwise insert it as the first child node in newSurface.
|
||||
if (this.previousSibling_ != null) {
|
||||
Blockly.utils.insertAfter_(blockCanvas, this.previousSibling_);
|
||||
Blockly.utils.insertAfter(blockCanvas, this.previousSibling_);
|
||||
} else {
|
||||
newSurface.insertBefore(blockCanvas, newSurface.firstChild);
|
||||
}
|
||||
|
||||
// Reattach the bubble canvas after the blockCanvas.
|
||||
Blockly.utils.insertAfter_(bubbleCanvas, blockCanvas);
|
||||
Blockly.utils.insertAfter(bubbleCanvas, blockCanvas);
|
||||
// Hide the drag surface.
|
||||
this.SVG_.style.display = 'none';
|
||||
goog.asserts.assert(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue