mirror of
https://github.com/google/blockly.git
synced 2026-01-09 01:50:11 +01:00
Merge branch 'develop' into populate_top_bottom_rows
This commit is contained in:
@@ -646,7 +646,7 @@ Blockly.BlockSvg.prototype.showHelp_ = function() {
|
||||
/**
|
||||
* Generate the context menu for this block.
|
||||
* @protected
|
||||
* @returns {Array.<!Object>} Context menu options
|
||||
* @return {Array.<!Object>} Context menu options
|
||||
*/
|
||||
Blockly.BlockSvg.prototype.generateContextMenu = function() {
|
||||
if (this.workspace.options.readOnly || !this.contextMenu) {
|
||||
|
||||
@@ -137,9 +137,7 @@ Blockly.Comment.prototype.createEditor_ = function() {
|
||||
this.text_ = textarea.value;
|
||||
}
|
||||
});
|
||||
setTimeout(function() {
|
||||
textarea.focus();
|
||||
}, 0);
|
||||
setTimeout(textarea.focus.bind(textarea), 0);
|
||||
return this.foreignObject_;
|
||||
};
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
'use strict';
|
||||
|
||||
goog.provide('Blockly.Component');
|
||||
|
||||
goog.provide('Blockly.Component.Error');
|
||||
goog.require('Blockly.utils.dom');
|
||||
goog.require('Blockly.utils.IdGenerator');
|
||||
|
||||
@@ -103,7 +103,7 @@ Blockly.MenuItem.prototype.createDom = function() {
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {Element} The html element for the checkbox.
|
||||
* @return {Element} The HTML element for the checkbox.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.MenuItem.prototype.getCheckboxDom = function() {
|
||||
@@ -117,7 +117,7 @@ Blockly.MenuItem.prototype.getCheckboxDom = function() {
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {!Element} The html for the content.
|
||||
* @return {!Element} The HTML for the content.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.MenuItem.prototype.getContentDom = function() {
|
||||
@@ -129,7 +129,7 @@ Blockly.MenuItem.prototype.getContentDom = function() {
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {!Element} The html for the content wrapper.
|
||||
* @return {!Element} The HTML for the content wrapper.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.MenuItem.prototype.getContentWrapperDom = function() {
|
||||
@@ -160,7 +160,7 @@ Blockly.MenuItem.prototype.setValue = function(value) {
|
||||
|
||||
/**
|
||||
* Gets the value associated with the menu item.
|
||||
* @returns {*} value Value associated with the menu item.
|
||||
* @return {*} value Value associated with the menu item.
|
||||
* @package
|
||||
*/
|
||||
Blockly.MenuItem.prototype.getValue = function() {
|
||||
|
||||
@@ -691,7 +691,7 @@ Blockly.tree.BaseNode.prototype.isUserCollapsible = function() {
|
||||
|
||||
/**
|
||||
* Creates HTML Element for the node.
|
||||
* @return {!Element} html element
|
||||
* @return {!Element} HTML element
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.toDom = function() {
|
||||
@@ -727,7 +727,7 @@ Blockly.tree.BaseNode.prototype.getPixelIndent_ = function() {
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {!Element} The html element for the row.
|
||||
* @return {!Element} The HTML element for the row.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.getRowDom = function() {
|
||||
@@ -758,7 +758,7 @@ Blockly.tree.BaseNode.prototype.getRowClassName = function() {
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {!Element} The html element for the label.
|
||||
* @return {!Element} The HTML element for the label.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.getLabelDom = function() {
|
||||
@@ -770,7 +770,7 @@ Blockly.tree.BaseNode.prototype.getLabelDom = function() {
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {!Element} The html for the icon.
|
||||
* @return {!Element} The HTML for the icon.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.getIconDom = function() {
|
||||
|
||||
@@ -197,7 +197,7 @@ Blockly.tree.TreeControl.prototype.setSelectedItem = function(node) {
|
||||
if (node == this.selectedItem_) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (this.onBeforeSelected_ &&
|
||||
!this.onBeforeSelected_.call(this.toolbox_, node)) {
|
||||
return;
|
||||
@@ -327,7 +327,7 @@ Blockly.tree.TreeControl.prototype.attachEvents_ = function() {
|
||||
'mousedown', this, this.handleMouseEvent_);
|
||||
this.onClickWrapper_ = Blockly.bindEventWithChecks_(el,
|
||||
'click', this, this.handleMouseEvent_);
|
||||
|
||||
|
||||
this.onKeydownWrapper_ = Blockly.bindEvent_(el,
|
||||
'keydown', this, this.handleKeyEvent_);
|
||||
|
||||
@@ -381,9 +381,8 @@ Blockly.tree.TreeControl.prototype.handleTouchEvent_ = function(e) {
|
||||
if (node && e.type === 'touchend') {
|
||||
// Fire asynchronously since onMouseDown takes long enough that the browser
|
||||
// would fire the default mouse event before this method returns.
|
||||
setTimeout(function() {
|
||||
node.onClick_(e); // Same behaviour for click and touch.
|
||||
}, 1);
|
||||
// Same behaviour for click and touch.
|
||||
setTimeout(node.onClick_.bind(node, e), 1);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
20
core/css.js
20
core/css.js
@@ -194,11 +194,11 @@ Blockly.Css.CONTENT = [
|
||||
'border-radius: 2px;',
|
||||
'padding: 4px;',
|
||||
'-webkit-user-select: none;',
|
||||
'box-shadow: 0px 0px 3px 1px rgba(0, 0, 0, .3);',
|
||||
'box-shadow: 0px 0px 3px 1px rgba(0,0,0,.3);',
|
||||
'}',
|
||||
|
||||
'.blocklyDropDownDiv.focused {',
|
||||
'box-shadow: 0px 0px 6px 1px rgba(0, 0, 0, .3);',
|
||||
'box-shadow: 0px 0px 6px 1px rgba(0,0,0,.3);',
|
||||
'}',
|
||||
|
||||
'.blocklyDropDownContent {',
|
||||
@@ -353,7 +353,7 @@ Blockly.Css.CONTENT = [
|
||||
'}',
|
||||
|
||||
'.blocklyReplaceable .blocklyPath {',
|
||||
'fill-opacity: 0.5;',
|
||||
'fill-opacity: .5;',
|
||||
'}',
|
||||
|
||||
'.blocklyReplaceable .blocklyPathLight,',
|
||||
@@ -671,7 +671,7 @@ Blockly.Css.CONTENT = [
|
||||
|
||||
'.blocklyVerticalCursor {',
|
||||
'stroke-width: 3px;',
|
||||
'fill: rgba(255,255,255,0.5);',
|
||||
'fill: rgba(255,255,255,.5);',
|
||||
'}',
|
||||
|
||||
'.blocklyWidgetDiv .goog-option-selected .goog-menuitem-checkbox,',
|
||||
@@ -806,7 +806,7 @@ Blockly.Css.CONTENT = [
|
||||
'.blocklyColourTable>tr>td {',
|
||||
'padding: 0;',
|
||||
'cursor: pointer;',
|
||||
'border: 0.5px solid transparent;',
|
||||
'border: .5px solid transparent;',
|
||||
'height: 25px;',
|
||||
'width: 25px;',
|
||||
'box-sizing: border-box;',
|
||||
@@ -816,7 +816,7 @@ Blockly.Css.CONTENT = [
|
||||
'.blocklyColourTable>tr>td.blocklyColourHighlighted {',
|
||||
'border-color: #eee;',
|
||||
'position: relative;',
|
||||
'box-shadow: 2px 2px 7px 2px rgba(0, 0, 0, 0.3);',
|
||||
'box-shadow: 2px 2px 7px 2px rgba(0,0,0,.3);',
|
||||
'}',
|
||||
|
||||
'.blocklyColourSelected, .blocklyColourSelected:hover {',
|
||||
@@ -854,11 +854,11 @@ Blockly.Css.CONTENT = [
|
||||
'overflow-x: hidden;',
|
||||
'max-height: 100%;',
|
||||
'z-index: 20000;', /* Arbitrary, but some apps depend on it... */
|
||||
'box-shadow: 0px 0px 3px 1px rgba(0, 0, 0, .3);',
|
||||
'box-shadow: 0px 0px 3px 1px rgba(0,0,0,.3);',
|
||||
'}',
|
||||
|
||||
'.blocklyWidgetDiv .goog-menu.focused {',
|
||||
'box-shadow: 0px 0px 6px 1px rgba(0, 0, 0, .3);',
|
||||
'box-shadow: 0px 0px 6px 1px rgba(0,0,0,.3);',
|
||||
'}',
|
||||
|
||||
'.blocklyDropDownDiv .goog-menu {',
|
||||
@@ -957,7 +957,7 @@ Blockly.Css.CONTENT = [
|
||||
|
||||
'.blocklyWidgetDiv .goog-menuitem-disabled .goog-menuitem-icon, ',
|
||||
'.blocklyDropDownDiv .goog-menuitem-disabled .goog-menuitem-icon {',
|
||||
'opacity: 0.3;',
|
||||
'opacity: .3;',
|
||||
'filter: alpha(opacity=30);',
|
||||
'}',
|
||||
|
||||
@@ -969,7 +969,7 @@ Blockly.Css.CONTENT = [
|
||||
|
||||
'.blocklyDropDownDiv .goog-menuitem-highlight, ',
|
||||
'.blocklyDropDownDiv .goog-menuitem-hover {',
|
||||
'background-color: rgba(0, 0, 0, 0.2);',
|
||||
'background-color: rgba(0,0,0,.2);',
|
||||
'}',
|
||||
|
||||
/* State: selected/checked. */
|
||||
|
||||
@@ -540,12 +540,12 @@ Blockly.DropDownDiv.hide = function() {
|
||||
// Start the animation by setting the translation and fading out.
|
||||
var div = Blockly.DropDownDiv.DIV_;
|
||||
// Reset to (initialX, initialY) - i.e., no translation.
|
||||
div.style.transform = 'translate(0px, 0px)';
|
||||
div.style.transform = 'translate(0, 0)';
|
||||
div.style.opacity = 0;
|
||||
Blockly.DropDownDiv.animateOutTimer_ = setTimeout(function() {
|
||||
// Finish animation - reset all values to default.
|
||||
Blockly.DropDownDiv.hideWithoutAnimation();
|
||||
}, Blockly.DropDownDiv.ANIMATION_TIME * 1000);
|
||||
// Finish animation - reset all values to default.
|
||||
Blockly.DropDownDiv.animateOutTimer_ =
|
||||
setTimeout(Blockly.DropDownDiv.hideWithoutAnimation,
|
||||
Blockly.DropDownDiv.ANIMATION_TIME * 1000);
|
||||
if (Blockly.DropDownDiv.onHide_) {
|
||||
Blockly.DropDownDiv.onHide_();
|
||||
Blockly.DropDownDiv.onHide_ = null;
|
||||
@@ -616,7 +616,7 @@ Blockly.DropDownDiv.positionInternal_ = function(initialX, initialY, finalX, fin
|
||||
|
||||
/**
|
||||
* Repositions the dropdownDiv on window resize. If it doesn't know how to
|
||||
* calculate the new position, it wll just hide it instead.
|
||||
* calculate the new position, it will just hide it instead.
|
||||
*/
|
||||
Blockly.DropDownDiv.repositionForWindowResize = function() {
|
||||
// This condition mainly catches the dropdown div when it is being used as a
|
||||
|
||||
@@ -285,7 +285,7 @@ Blockly.FieldColour.prototype.showEditor_ = function() {
|
||||
|
||||
Blockly.DropDownDiv.showPositionedByField(
|
||||
this, this.dropdownDispose_.bind(this));
|
||||
|
||||
|
||||
// Focus so we can start receiving keyboard events.
|
||||
this.picker_.focus();
|
||||
};
|
||||
@@ -426,17 +426,17 @@ Blockly.FieldColour.prototype.getHighlighted_ = function() {
|
||||
* @private
|
||||
*/
|
||||
Blockly.FieldColour.prototype.setHighlightedCell_ = function(cell, index) {
|
||||
// Unhighlight the current item
|
||||
// Unhighlight the current item.
|
||||
var highlighted = this.getHighlighted_();
|
||||
if (highlighted) {
|
||||
Blockly.utils.dom.removeClass(highlighted, 'blocklyColourHighlighted');
|
||||
}
|
||||
// Highight new item
|
||||
// Highight new item.
|
||||
Blockly.utils.dom.addClass(cell, 'blocklyColourHighlighted');
|
||||
// Set new highlighted index
|
||||
// Set new highlighted index.
|
||||
this.highlightedIndex_ = index;
|
||||
|
||||
// Update accessibility roles
|
||||
// Update accessibility roles.
|
||||
Blockly.utils.aria.setState(this.picker_,
|
||||
Blockly.utils.aria.State.ACTIVEDESCENDANT, cell.getAttribute('id'));
|
||||
};
|
||||
|
||||
@@ -80,7 +80,7 @@ Blockly.FieldLabel.prototype.EDITABLE = false;
|
||||
*/
|
||||
Blockly.FieldLabel.prototype.initView = function() {
|
||||
this.createTextElement_();
|
||||
// The y attribute of an svg text element is the baseline.
|
||||
// The y attribute of an SVG text element is the baseline.
|
||||
this.textElement_.setAttribute('y', this.size_.height);
|
||||
if (this.class_) {
|
||||
Blockly.utils.dom.addClass(this.textElement_, this.class_);
|
||||
|
||||
@@ -51,7 +51,7 @@ goog.inherits(Blockly.FieldLabelSerializable, Blockly.FieldLabel);
|
||||
* Construct a FieldLabelSerializable from a JSON arg object,
|
||||
* dereferencing any string table references.
|
||||
* @param {!Object} options A JSON object with options (text, and class).
|
||||
* @returns {!Blockly.FieldLabelSerializable} The new field instance.
|
||||
* @return {!Blockly.FieldLabelSerializable} The new field instance.
|
||||
* @package
|
||||
* @nocollapse
|
||||
*/
|
||||
|
||||
@@ -77,9 +77,8 @@ Blockly.fieldRegistry.fromJson = function(options) {
|
||||
if (!fieldClass) {
|
||||
console.warn('Blockly could not create a field of type ' + options['type'] +
|
||||
'. The field is probably not being registered. This could be because' +
|
||||
' the file is not loaded, the field does not register itself (See:' +
|
||||
' github.com/google/blockly/issues/1584), or the registration is not' +
|
||||
' being reached.');
|
||||
' the file is not loaded, the field does not register itself (Issue' +
|
||||
' #1584), or the registration is not being reached.');
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -172,10 +172,7 @@ Blockly.FieldTextInput.prototype.render_ = function() {
|
||||
// in RTL, we need to let the browser reflow before resizing
|
||||
// in order to get the correct bounding box of the borderRect
|
||||
// avoiding issue #2777.
|
||||
var field = this;
|
||||
setTimeout(function() {
|
||||
field.resizeEditor_();
|
||||
}, 0);
|
||||
setTimeout(this.resizeEditor_.bind(this), 0);
|
||||
} else {
|
||||
this.resizeEditor_();
|
||||
}
|
||||
@@ -270,10 +267,7 @@ Blockly.FieldTextInput.prototype.widgetCreate_ = function() {
|
||||
htmlInput.untypedDefaultValue_ = this.value_;
|
||||
htmlInput.oldValue_ = null;
|
||||
// Ensure the browser reflows before resizing to avoid issue #2777.
|
||||
var field = this;
|
||||
setTimeout(function() {
|
||||
field.resizeEditor_();
|
||||
}, 0);
|
||||
setTimeout(this.resizeEditor_.bind(this), 0);
|
||||
|
||||
this.bindInputEvents_(htmlInput);
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
goog.provide('Blockly.Action');
|
||||
|
||||
|
||||
/**
|
||||
* Class for a single action.
|
||||
* An action describes user intent. (ex go to next or go to previous)
|
||||
|
||||
@@ -165,7 +165,8 @@ Blockly.CursorSvg.prototype.showWithCoordinates_ = function() {
|
||||
var wsCoordinate = workspaceNode.getWsCoordinate();
|
||||
this.currentCursorSvg = this.cursorSvgLine_;
|
||||
this.setParent_(this.workspace_.svgBlockCanvas_);
|
||||
this.positionLine_(wsCoordinate.x, wsCoordinate.y, Blockly.CursorSvg.CURSOR_WIDTH);
|
||||
this.positionLine_(wsCoordinate.x, wsCoordinate.y,
|
||||
Blockly.CursorSvg.CURSOR_WIDTH);
|
||||
this.showCurrent_();
|
||||
};
|
||||
|
||||
@@ -191,8 +192,8 @@ Blockly.CursorSvg.prototype.showWithInputOutput_ = function() {
|
||||
var connection = /** @type {Blockly.Connection} */
|
||||
(this.getCurNode().getLocation());
|
||||
this.currentCursorSvg = this.cursorInputOutput_;
|
||||
var path = Blockly.utils.svgPaths.moveTo(0,0) +
|
||||
Blockly.blockRendering.constants.PUZZLE_TAB.pathDown;
|
||||
var path = Blockly.utils.svgPaths.moveTo(0, 0) +
|
||||
Blockly.blockRendering.constants.PUZZLE_TAB.pathDown;
|
||||
this.cursorInputOutput_.setAttribute('d', path);
|
||||
this.setParent_(connection.getSourceBlock().getSvgRoot());
|
||||
this.positionInputOutput_(connection);
|
||||
@@ -313,8 +314,9 @@ Blockly.CursorSvg.prototype.positionInputOutput_ = function(connection) {
|
||||
var x = connection.getOffsetInBlock().x;
|
||||
var y = connection.getOffsetInBlock().y;
|
||||
|
||||
this.cursorInputOutput_.setAttribute('transform', 'translate(' + x + ',' + y + ')' +
|
||||
(connection.getSourceBlock().RTL ? ' scale(-1 1)' : ''));
|
||||
this.cursorInputOutput_.setAttribute('transform',
|
||||
'translate(' + x + ',' + y + ')' +
|
||||
(connection.getSourceBlock().RTL ? ' scale(-1 1)' : ''));
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,6 +29,7 @@ goog.provide('Blockly.user.keyMap');
|
||||
|
||||
goog.require('Blockly.utils.KeyCodes');
|
||||
|
||||
|
||||
/**
|
||||
* Holds the serialized key to key action mapping.
|
||||
* @type {Object<string, Blockly.Action>}
|
||||
@@ -39,7 +40,7 @@ Blockly.user.keyMap.map_ = {};
|
||||
* List of modifier keys checked when serializing the key event.
|
||||
* @type {Array<string>}
|
||||
*/
|
||||
Blockly.user.keyMap.modifierKeys = ['Shift','Control','Alt','Meta'];
|
||||
Blockly.user.keyMap.modifierKeys = ['Shift', 'Control', 'Alt', 'Meta'];
|
||||
|
||||
/**
|
||||
* Update the key map to contain the new action.
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
* @fileoverview Methods for graphically rendering a block as SVG.
|
||||
* @author fenichel@google.com (Rachel Fenichel)
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
goog.provide('Blockly.blockRendering.Drawer');
|
||||
|
||||
goog.require('Blockly.blockRendering.constants');
|
||||
@@ -37,9 +37,10 @@ goog.require('Blockly.blockRendering.Row');
|
||||
goog.require('Blockly.blockRendering.SpacerRow');
|
||||
goog.require('Blockly.blockRendering.TopRow');
|
||||
|
||||
|
||||
/**
|
||||
* An object that draws a block based on the given rendering information.
|
||||
* @param {!Blockly.BlockSvg} block The block to render
|
||||
* @param {!Blockly.BlockSvg} block The block to render.
|
||||
* @param {!Blockly.blockRendering.RenderInfo} info An object containing all
|
||||
* information needed to render this block.
|
||||
* @package
|
||||
@@ -52,7 +53,8 @@ Blockly.blockRendering.Drawer = function(block, info) {
|
||||
this.outlinePath_ = '';
|
||||
this.inlinePath_ = '';
|
||||
this.pathObject_ = new Blockly.BlockSvg.PathObject();
|
||||
this.highlighter_ = new Blockly.blockRendering.Highlighter(this.info_, this.pathObject_);
|
||||
this.highlighter_ =
|
||||
new Blockly.blockRendering.Highlighter(this.info_, this.pathObject_);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -88,7 +90,8 @@ Blockly.blockRendering.Drawer.prototype.draw_ = function() {
|
||||
Blockly.blockRendering.Drawer.prototype.recordSizeOnBlock_ = function() {
|
||||
// This is used when the block is reporting its size to anyone else.
|
||||
// The dark path adds to the size of the block in both X and Y.
|
||||
this.block_.height = this.info_.height + Blockly.blockRendering.constants.DARK_PATH_OFFSET;
|
||||
this.block_.height = this.info_.height +
|
||||
Blockly.blockRendering.constants.DARK_PATH_OFFSET;
|
||||
this.block_.width = this.info_.widthWithChildren +
|
||||
Blockly.blockRendering.constants.DARK_PATH_OFFSET;
|
||||
};
|
||||
@@ -98,8 +101,7 @@ Blockly.blockRendering.Drawer.prototype.recordSizeOnBlock_ = function() {
|
||||
* @private
|
||||
*/
|
||||
Blockly.blockRendering.Drawer.prototype.hideHiddenIcons_ = function() {
|
||||
for (var i = 0; i < this.info_.hiddenIcons.length; i++) {
|
||||
var iconInfo = this.info_.hiddenIcons[i];
|
||||
for (var i = 0, iconInfo; iconInfo = this.info_.hiddenIcons[i]; i++) {
|
||||
iconInfo.icon.iconGroup_.setAttribute('display', 'none');
|
||||
}
|
||||
};
|
||||
@@ -141,14 +143,15 @@ Blockly.blockRendering.Drawer.prototype.drawTop_ = function() {
|
||||
this.highlighter_.drawRightSideRow(topRow);
|
||||
}
|
||||
this.positionPreviousConnection_();
|
||||
this.outlinePath_ += Blockly.utils.svgPaths.moveBy(topRow.xPos, this.info_.startY);
|
||||
for (var i = 0, elem; i < elements.length; i++) {
|
||||
elem = elements[i];
|
||||
if (elem.type === 'round corner') {
|
||||
this.outlinePath_ += Blockly.blockRendering.constants.OUTSIDE_CORNERS.topLeft;
|
||||
} else if (elem.type === 'previous connection') {
|
||||
this.outlinePath_ +=
|
||||
Blockly.utils.svgPaths.moveBy(topRow.xPos, this.info_.startY);
|
||||
for (var i = 0, elem; elem = elements[i]; i++) {
|
||||
if (elem.type == 'round corner') {
|
||||
this.outlinePath_ +=
|
||||
Blockly.blockRendering.constants.OUTSIDE_CORNERS.topLeft;
|
||||
} else if (elem.type == 'previous connection') {
|
||||
this.outlinePath_ += topRow.notchShape.pathLeft;
|
||||
} else if (elem.type === 'hat') {
|
||||
} else if (elem.type == 'hat') {
|
||||
this.outlinePath_ += Blockly.blockRendering.constants.START_HAT.path;
|
||||
} else if (elem.isSpacer()) {
|
||||
this.outlinePath_ += Blockly.utils.svgPaths.lineOnAxis('h', elem.width);
|
||||
@@ -284,7 +287,8 @@ Blockly.blockRendering.Drawer.prototype.drawLeft_ = function() {
|
||||
this.positionOutputConnection_();
|
||||
|
||||
if (outputConnection) {
|
||||
var tabBottom = outputConnection.connectionOffsetY + outputConnection.height;
|
||||
var tabBottom = outputConnection.connectionOffsetY +
|
||||
outputConnection.height;
|
||||
// Draw a line up to the bottom of the tab.
|
||||
this.outlinePath_ +=
|
||||
Blockly.utils.svgPaths.lineOnAxis('V', tabBottom) +
|
||||
@@ -301,10 +305,8 @@ Blockly.blockRendering.Drawer.prototype.drawLeft_ = function() {
|
||||
* @private
|
||||
*/
|
||||
Blockly.blockRendering.Drawer.prototype.drawInternals_ = function() {
|
||||
for (var r = 0; r < this.info_.rows.length; r++) {
|
||||
var row = this.info_.rows[r];
|
||||
for (var e = 0; e < row.elements.length; e++) {
|
||||
var elem = row.elements[e];
|
||||
for (var i = 0, row; row = this.info_.rows[i]; i++) {
|
||||
for (var j = 0, elem; elem = row.elements[j]; j++) {
|
||||
if (elem.isInlineInput()) {
|
||||
this.drawInlineInput_(elem);
|
||||
} else if (elem.isIcon() || elem.isField()) {
|
||||
@@ -380,7 +382,6 @@ Blockly.blockRendering.Drawer.prototype.drawInlineInput_ = function(input) {
|
||||
'z';
|
||||
|
||||
this.positionInlineInputConnection_(input);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -438,7 +439,8 @@ Blockly.blockRendering.Drawer.prototype.positionStatementInputConnection_ = func
|
||||
Blockly.blockRendering.Drawer.prototype.positionExternalValueConnection_ = function(row) {
|
||||
var input = row.getLastInput();
|
||||
if (input.connection) {
|
||||
var connX = row.xPos + row.width + Blockly.blockRendering.constants.DARK_PATH_OFFSET;
|
||||
var connX = row.xPos + row.width +
|
||||
Blockly.blockRendering.constants.DARK_PATH_OFFSET;
|
||||
if (this.info_.RTL) {
|
||||
connX *= -1;
|
||||
}
|
||||
|
||||
@@ -22,9 +22,10 @@
|
||||
* @fileoverview Methods for graphically rendering a block as SVG.
|
||||
* @author fenichel@google.com (Rachel Fenichel)
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
goog.provide('Blockly.blockRendering.Debug');
|
||||
|
||||
goog.require('Blockly.blockRendering.RenderInfo');
|
||||
goog.require('Blockly.blockRendering.Highlighter');
|
||||
goog.require('Blockly.blockRendering.constants');
|
||||
@@ -35,6 +36,7 @@ goog.require('Blockly.blockRendering.Row');
|
||||
goog.require('Blockly.blockRendering.SpacerRow');
|
||||
goog.require('Blockly.blockRendering.TopRow');
|
||||
|
||||
|
||||
/**
|
||||
* An object that renders rectangles and dots for debugging rendering code.
|
||||
* @package
|
||||
@@ -74,8 +76,7 @@ Blockly.blockRendering.Debug = function() {
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.Debug.prototype.clearElems = function() {
|
||||
for (var i = 0, elem; i < this.debugElements_.length; i++) {
|
||||
elem = this.debugElements_[i];
|
||||
for (var i = 0, elem; elem = this.debugElements_[i]; i++) {
|
||||
Blockly.utils.dom.removeNode(elem);
|
||||
}
|
||||
|
||||
@@ -84,7 +85,7 @@ Blockly.blockRendering.Debug.prototype.clearElems = function() {
|
||||
|
||||
/**
|
||||
* Draw a debug rectangle for a spacer (empty) row.
|
||||
* @param {!Blockly.blockRendering.Row} row The row to render
|
||||
* @param {!Blockly.blockRendering.Row} row The row to render.
|
||||
* @param {number} cursorY The y position of the top of the row.
|
||||
* @param {boolean} isRtl Whether the block is rendered RTL.
|
||||
* @package
|
||||
@@ -107,7 +108,7 @@ Blockly.blockRendering.Debug.prototype.drawSpacerRow = function(row, cursorY, is
|
||||
|
||||
/**
|
||||
* Draw a debug rectangle for a horizontal spacer.
|
||||
* @param {!Blockly.BlockSvg.InRowSpacer} elem The spacer to render
|
||||
* @param {!Blockly.blockRendering.InRowSpacer} elem The spacer to render.
|
||||
* @param {number} rowHeight The height of the container row.
|
||||
* @param {boolean} isRtl Whether the block is rendered RTL.
|
||||
* @package
|
||||
@@ -136,7 +137,7 @@ Blockly.blockRendering.Debug.prototype.drawSpacerElem = function(elem, rowHeight
|
||||
|
||||
/**
|
||||
* Draw a debug rectangle for an in-row element.
|
||||
* @param {!Blockly.BlockSvg.Measurable} elem The element to render
|
||||
* @param {!Blockly.blockRendering.Measurable} elem The element to render.
|
||||
* @param {boolean} isRtl Whether the block is rendered RTL.
|
||||
* @package
|
||||
*/
|
||||
@@ -211,7 +212,7 @@ Blockly.blockRendering.Debug.prototype.drawConnection = function(conn) {
|
||||
|
||||
/**
|
||||
* Draw a debug rectangle for a non-empty row.
|
||||
* @param {!Blockly.BlockSvg.Row} row The non-empty row to render.
|
||||
* @param {!Blockly.blockRendering.Row} row The non-empty row to render.
|
||||
* @param {number} cursorY The y position of the top of the row.
|
||||
* @param {boolean} isRtl Whether the block is rendered RTL.
|
||||
* @package
|
||||
@@ -225,7 +226,7 @@ Blockly.blockRendering.Debug.prototype.drawRenderedRow = function(row, cursorY,
|
||||
{
|
||||
'class': 'elemRenderingRect blockRenderDebug',
|
||||
'x': isRtl ? -(row.xPos + row.width) : row.xPos,
|
||||
'y': cursorY ,
|
||||
'y': cursorY,
|
||||
'width': row.width,
|
||||
'height': row.height,
|
||||
},
|
||||
@@ -238,7 +239,7 @@ Blockly.blockRendering.Debug.prototype.drawRenderedRow = function(row, cursorY,
|
||||
{
|
||||
'class': 'blockRenderDebug',
|
||||
'x': isRtl ? -(row.xPos + row.widthWithConnectedBlocks) : row.xPos,
|
||||
'y': cursorY ,
|
||||
'y': cursorY,
|
||||
'width': row.widthWithConnectedBlocks,
|
||||
'height': row.height,
|
||||
'stroke': this.randomColour_,
|
||||
@@ -251,14 +252,13 @@ Blockly.blockRendering.Debug.prototype.drawRenderedRow = function(row, cursorY,
|
||||
|
||||
/**
|
||||
* Draw debug rectangles for a non-empty row and all of its subcomponents.
|
||||
* @param {!Blockly.BlockSvg.Row} row The non-empty row to render.
|
||||
* @param {!Blockly.blockRendering.Row} row The non-empty row to render.
|
||||
* @param {number} cursorY The y position of the top of the row.
|
||||
* @param {boolean} isRtl Whether the block is rendered RTL.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.Debug.prototype.drawRowWithElements = function(row, cursorY, isRtl) {
|
||||
for (var e = 0; e < row.elements.length; e++) {
|
||||
var elem = row.elements[e];
|
||||
for (var i = 0, elem; elem = row.elements[i]; i++) {
|
||||
if (elem.isSpacer()) {
|
||||
this.drawSpacerElem(elem, row.height, isRtl);
|
||||
} else {
|
||||
@@ -325,8 +325,7 @@ Blockly.blockRendering.Debug.prototype.drawDebug = function(block, info) {
|
||||
this.randomColour_ = '#' + Math.floor(Math.random() * 16777215).toString(16);
|
||||
|
||||
var cursorY = 0;
|
||||
for (var r = 0; r < info.rows.length; r++) {
|
||||
var row = info.rows[r];
|
||||
for (var i = 0, row; row = info.rows[i]; i++) {
|
||||
if (row.type == 'between-row spacer') {
|
||||
this.drawSpacerRow(row, cursorY, info.RTL);
|
||||
} else {
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
* @fileoverview Methods for graphically rendering a block as SVG.
|
||||
* @author fenichel@google.com (Rachel Fenichel)
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
goog.provide('Blockly.blockRendering.Highlighter');
|
||||
|
||||
goog.require('Blockly.blockRendering.highlightConstants');
|
||||
@@ -35,6 +35,7 @@ goog.require('Blockly.blockRendering.Row');
|
||||
goog.require('Blockly.blockRendering.SpacerRow');
|
||||
goog.require('Blockly.blockRendering.TopRow');
|
||||
|
||||
|
||||
/**
|
||||
* An object that adds highlights to a block based on the given rendering
|
||||
* information.
|
||||
@@ -81,14 +82,14 @@ Blockly.blockRendering.Highlighter.prototype.drawTopCorner = function(row) {
|
||||
this.steps_.push(
|
||||
Blockly.utils.svgPaths.moveBy(row.xPos, this.info_.startY));
|
||||
for (var i = 0, elem; elem = row.elements[i]; i++) {
|
||||
if (elem.type === 'square corner') {
|
||||
if (elem.type == 'square corner') {
|
||||
this.steps_.push(Blockly.blockRendering.highlightConstants.START_POINT);
|
||||
} else if (elem.type === 'round corner') {
|
||||
} else if (elem.type == 'round corner') {
|
||||
this.steps_.push(
|
||||
this.outsideCornerPaths_.topLeft(this.RTL_));
|
||||
} else if (elem.type === 'previous connection') {
|
||||
} else if (elem.type == 'previous connection') {
|
||||
this.steps_.push(this.notchPaths_.pathLeft);
|
||||
} else if (elem.type === 'hat') {
|
||||
} else if (elem.type == 'hat') {
|
||||
this.steps_.push(this.startPaths_.path(this.RTL_));
|
||||
} else if (elem.isSpacer() && elem.width != 0) {
|
||||
// The end point of the spacer needs to be offset by the highlight amount.
|
||||
@@ -172,12 +173,12 @@ Blockly.blockRendering.Highlighter.prototype.drawBottomRow = function(row) {
|
||||
this.steps_.push('V', height - this.highlightOffset_);
|
||||
} else {
|
||||
var cornerElem = this.info_.bottomRow.elements[0];
|
||||
if (cornerElem.type === 'square corner') {
|
||||
if (cornerElem.type == 'square corner') {
|
||||
this.steps_.push(
|
||||
Blockly.utils.svgPaths.moveTo(
|
||||
row.xPos + this.highlightOffset_,
|
||||
height - this.highlightOffset_));
|
||||
} else if (cornerElem.type === 'round corner') {
|
||||
} else if (cornerElem.type == 'round corner') {
|
||||
this.steps_.push(Blockly.utils.svgPaths.moveTo(row.xPos, height));
|
||||
this.steps_.push(this.outsideCornerPaths_.bottomLeft());
|
||||
}
|
||||
@@ -190,16 +191,15 @@ Blockly.blockRendering.Highlighter.prototype.drawLeft = function() {
|
||||
var tabBottom =
|
||||
outputConnection.connectionOffsetY + outputConnection.height;
|
||||
// Draw a line up to the bottom of the tab.
|
||||
if (!this.RTL_) {
|
||||
if (this.RTL_) {
|
||||
this.steps_.push(Blockly.utils.svgPaths.moveTo(this.info_.startX, tabBottom));
|
||||
} else {
|
||||
var left = this.info_.startX + this.highlightOffset_;
|
||||
var bottom = this.info_.height - this.highlightOffset_;
|
||||
this.steps_.push(Blockly.utils.svgPaths.moveTo(left, bottom));
|
||||
this.steps_.push('V', tabBottom);
|
||||
} else {
|
||||
this.steps_.push(Blockly.utils.svgPaths.moveTo(this.info_.startX, tabBottom));
|
||||
}
|
||||
this.steps_.push(
|
||||
this.puzzleTabPaths_.pathUp(this.RTL_));
|
||||
this.steps_.push(this.puzzleTabPaths_.pathUp(this.RTL_));
|
||||
}
|
||||
|
||||
if (!this.RTL_) {
|
||||
@@ -224,8 +224,8 @@ Blockly.blockRendering.Highlighter.prototype.drawInlineInput = function(input) {
|
||||
if (this.RTL_) {
|
||||
// TODO: Check if this is different when the inline input is populated.
|
||||
var aboveTabHeight = input.connectionOffsetY - offset;
|
||||
var belowTabHeight =
|
||||
input.height - (input.connectionOffsetY + input.connectionHeight) + offset;
|
||||
var belowTabHeight = input.height -
|
||||
(input.connectionOffsetY + input.connectionHeight) + offset;
|
||||
|
||||
var startX = connectionRight - offset;
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
* @fileoverview Methods for graphically rendering a block as SVG.
|
||||
* @author fenichel@google.com (Rachel Fenichel)
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
goog.provide('Blockly.blockRendering.RenderInfo');
|
||||
@@ -120,7 +119,7 @@ Blockly.blockRendering.RenderInfo = function(block) {
|
||||
this.rows = [];
|
||||
|
||||
/**
|
||||
* An array of measureable objects containing hidden icons.
|
||||
* An array of measurable objects containing hidden icons.
|
||||
* @type {!Array.<!Blockly.blockRendering.Icon>}
|
||||
*/
|
||||
this.hiddenIcons = [];
|
||||
@@ -178,8 +177,7 @@ Blockly.blockRendering.RenderInfo.prototype.createRows_ = function() {
|
||||
// Icons always go on the first row, before anything else.
|
||||
var icons = this.block_.getIcons();
|
||||
if (icons.length) {
|
||||
for (var i = 0; i < icons.length; i++) {
|
||||
var icon = icons[i];
|
||||
for (var i = 0, icon; icon = icons[i]; i++) {
|
||||
var iconInfo = new Blockly.blockRendering.Icon(icon);
|
||||
if (this.isCollapsed && icon.collapseHidden) {
|
||||
this.hiddenIcons.push(iconInfo);
|
||||
@@ -192,8 +190,7 @@ Blockly.blockRendering.RenderInfo.prototype.createRows_ = function() {
|
||||
var lastInput = undefined;
|
||||
// Loop across all of the inputs on the block, creating objects for anything
|
||||
// that needs to be rendered and breaking the block up into visual rows.
|
||||
for (var i = 0; i < this.block_.inputList.length; i++) {
|
||||
var input = this.block_.inputList[i];
|
||||
for (var i = 0, input; input = this.block_.inputList[i]; i++) {
|
||||
if (!input.isVisible()) {
|
||||
continue;
|
||||
}
|
||||
@@ -204,8 +201,7 @@ Blockly.blockRendering.RenderInfo.prototype.createRows_ = function() {
|
||||
}
|
||||
|
||||
// All of the fields in an input go on the same row.
|
||||
for (var f = 0; f < input.fieldRow.length; f++) {
|
||||
var field = input.fieldRow[f];
|
||||
for (var j = 0, field; field = input.fieldRow[j]; j++) {
|
||||
activeRow.elements.push(new Blockly.blockRendering.Field(field, input));
|
||||
}
|
||||
this.addInput_(input, activeRow);
|
||||
@@ -224,7 +220,6 @@ Blockly.blockRendering.RenderInfo.prototype.createRows_ = function() {
|
||||
this.rows.push(this.bottomRow);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Add an input element to the active row, if needed, and record the type of the
|
||||
* input on the row.
|
||||
@@ -280,8 +275,7 @@ Blockly.blockRendering.RenderInfo.prototype.shouldStartNewRow_ = function(input,
|
||||
* @private
|
||||
*/
|
||||
Blockly.blockRendering.RenderInfo.prototype.addElemSpacing_ = function() {
|
||||
for (var r = 0; r < this.rows.length; r++) {
|
||||
var row = this.rows[r];
|
||||
for (var i = 0, row; row = this.rows[i]; i++) {
|
||||
var oldElems = row.elements;
|
||||
row.elements = [];
|
||||
// No spacing needed before the corner on the top row or the bottom row.
|
||||
@@ -455,8 +449,7 @@ Blockly.blockRendering.RenderInfo.prototype.computeBounds_ = function() {
|
||||
var widestStatementRowFields = 0;
|
||||
var blockWidth = 0;
|
||||
var widestRowWithConnectedBlocks = 0;
|
||||
for (var r = 0; r < this.rows.length; r++) {
|
||||
var row = this.rows[r];
|
||||
for (var i = 0, row; row = this.rows[i]; i++) {
|
||||
row.measure();
|
||||
blockWidth = Math.max(blockWidth, row.width);
|
||||
if (row.hasStatement) {
|
||||
@@ -473,15 +466,13 @@ Blockly.blockRendering.RenderInfo.prototype.computeBounds_ = function() {
|
||||
|
||||
this.width = blockWidth;
|
||||
|
||||
for (var r = 0; r < this.rows.length; r++) {
|
||||
var row = this.rows[r];
|
||||
for (var i = 0, row; row = this.rows[i]; i++) {
|
||||
if (row.hasStatement) {
|
||||
row.statementEdge = this.statementEdge;
|
||||
}
|
||||
}
|
||||
|
||||
this.widthWithChildren =
|
||||
Math.max(blockWidth, widestRowWithConnectedBlocks);
|
||||
this.widthWithChildren = Math.max(blockWidth, widestRowWithConnectedBlocks);
|
||||
|
||||
if (this.outputConnection) {
|
||||
this.startX = this.outputConnection.width;
|
||||
@@ -497,8 +488,7 @@ Blockly.blockRendering.RenderInfo.prototype.computeBounds_ = function() {
|
||||
* @private
|
||||
*/
|
||||
Blockly.blockRendering.RenderInfo.prototype.alignRowElements_ = function() {
|
||||
for (var r = 0; r < this.rows.length; r++) {
|
||||
var row = this.rows[r];
|
||||
for (var i = 0, row; row = this.rows[i]; i++) {
|
||||
if (!row.hasInlineInput) {
|
||||
if (row.hasStatement) {
|
||||
var statementInput = row.getLastInput();
|
||||
@@ -508,7 +498,7 @@ Blockly.blockRendering.RenderInfo.prototype.alignRowElements_ = function() {
|
||||
var currentWidth = row.width;
|
||||
var desiredWidth = this.width - this.startX;
|
||||
}
|
||||
if (row.type === 'bottom row' && row.hasFixedWidth) {
|
||||
if (row.type == 'bottom row' && row.hasFixedWidth) {
|
||||
desiredWidth = Blockly.blockRendering.constants.MAX_BOTTOM_WIDTH;
|
||||
}
|
||||
var missingSpace = desiredWidth - currentWidth;
|
||||
@@ -552,7 +542,7 @@ Blockly.blockRendering.RenderInfo.prototype.addAlignmentPadding_ = function(row,
|
||||
}
|
||||
row.width += missingSpace;
|
||||
// Top and bottom rows are always left aligned.
|
||||
} else if (row.type === 'top row' || row.type === 'bottom row') {
|
||||
} else if (row.type == 'top row' || row.type == 'bottom row') {
|
||||
row.getLastSpacer().width += missingSpace;
|
||||
row.width += missingSpace;
|
||||
}
|
||||
@@ -568,7 +558,7 @@ Blockly.blockRendering.RenderInfo.prototype.addRowSpacing_ = function() {
|
||||
|
||||
for (var r = 0; r < oldRows.length; r++) {
|
||||
this.rows.push(oldRows[r]);
|
||||
if (r !== oldRows.length - 1) {
|
||||
if (r != oldRows.length - 1) {
|
||||
this.rows.push(this.makeSpacerRow_(oldRows[r], oldRows[r + 1]));
|
||||
}
|
||||
}
|
||||
@@ -603,7 +593,7 @@ Blockly.blockRendering.RenderInfo.prototype.makeSpacerRow_ = function(prev, next
|
||||
Blockly.blockRendering.RenderInfo.prototype.getSpacerRowWidth_ = function(prev, next) {
|
||||
// The width of the spacer before the bottom row should be the same as the
|
||||
// bottom row.
|
||||
if (next.type === 'bottom row' && next.hasFixedWidth) {
|
||||
if (next.type == 'bottom row' && next.hasFixedWidth) {
|
||||
return next.width;
|
||||
}
|
||||
return this.width - this.startX;
|
||||
@@ -617,12 +607,12 @@ Blockly.blockRendering.RenderInfo.prototype.getSpacerRowWidth_ = function(prev,
|
||||
* @private
|
||||
*/
|
||||
Blockly.blockRendering.RenderInfo.prototype.getSpacerRowHeight_ = function(prev, next) {
|
||||
// If we have an empty block add a spacer to increase the height
|
||||
if (prev.type === 'top row' && next.type === 'bottom row') {
|
||||
// If we have an empty block add a spacer to increase the height.
|
||||
if (prev.type == 'top row' && next.type == 'bottom row') {
|
||||
return Blockly.blockRendering.constants.EMPTY_BLOCK_SPACER_HEIGHT;
|
||||
}
|
||||
// Top and bottom rows act as a spacer so we don't need any extra padding
|
||||
if (prev.type === 'top row' || next.type === 'bottom row') {
|
||||
// Top and bottom rows act as a spacer so we don't need any extra padding.
|
||||
if (prev.type == 'top row' || next.type == 'bottom row') {
|
||||
return Blockly.blockRendering.constants.NO_PADDING;
|
||||
}
|
||||
if (prev.hasExternalInput && next.hasExternalInput) {
|
||||
@@ -661,6 +651,7 @@ Blockly.blockRendering.RenderInfo.prototype.getElemCenterline_ = function(row, e
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Make any final changes to the rendering information object. In particular,
|
||||
* store the y position of each row, and record the height of the full block.
|
||||
@@ -672,8 +663,7 @@ Blockly.blockRendering.RenderInfo.prototype.finalize_ = function() {
|
||||
// accesses and sets properties that already exist on the objects.
|
||||
var widestRowWithConnectedBlocks = 0;
|
||||
var yCursor = 0;
|
||||
for (var r = 0; r < this.rows.length; r++) {
|
||||
var row = this.rows[r];
|
||||
for (var i = 0, row; row = this.rows[i]; i++) {
|
||||
row.yPos = yCursor;
|
||||
row.xPos = this.startX;
|
||||
yCursor += row.height;
|
||||
@@ -690,8 +680,7 @@ Blockly.blockRendering.RenderInfo.prototype.finalize_ = function() {
|
||||
yCursor += diff;
|
||||
}
|
||||
var xCursor = row.xPos;
|
||||
for (var e = 0; e < row.elements.length; e++) {
|
||||
var elem = row.elements[e];
|
||||
for (var j = 0, elem; elem = row.elements[j]; j++) {
|
||||
elem.xPos = xCursor;
|
||||
elem.centerline = this.getElemCenterline_(row, elem);
|
||||
xCursor += elem.width;
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
* @fileoverview Namespace for block rendering functionality.
|
||||
* @author fenichel@google.com (Rachel Fenichel)
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
@@ -35,6 +34,7 @@ goog.require('Blockly.blockRendering.Debug');
|
||||
goog.require('Blockly.blockRendering.Drawer');
|
||||
goog.require('Blockly.blockRendering.RenderInfo');
|
||||
|
||||
|
||||
/**
|
||||
* Render the given block, using the new rendering.
|
||||
* Developers should not call this directly. Instead, call block.render().
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
* @fileoverview Methods for graphically rendering a block as SVG.
|
||||
* @author fenichel@google.com (Rachel Fenichel)
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
goog.provide('Blockly.blockRendering.constants');
|
||||
|
||||
goog.require('Blockly.utils.svgPaths');
|
||||
|
||||
@@ -22,13 +22,14 @@
|
||||
* @fileoverview Objects for rendering highlights on blocks.
|
||||
* @author fenichel@google.com (Rachel Fenichel)
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
goog.provide('Blockly.blockRendering.highlightConstants');
|
||||
|
||||
goog.require('Blockly.blockRendering.constants');
|
||||
goog.require('Blockly.utils.svgPaths');
|
||||
|
||||
|
||||
/**
|
||||
* Some highlights are simple offsets of the parent paths and can be generated
|
||||
* programmatically. Others, especially on curves, are just made out of piles
|
||||
|
||||
@@ -220,7 +220,7 @@ Blockly.Toolbox.prototype.init = function() {
|
||||
/**
|
||||
* Handle the before tree item selected action.
|
||||
* @param {Blockly.tree.BaseNode} node The newly selected node.
|
||||
* @returns {boolean} Whether or not to cancel selecting the node.
|
||||
* @return {boolean} Whether or not to cancel selecting the node.
|
||||
* @private
|
||||
*/
|
||||
Blockly.Toolbox.prototype.handleBeforeTreeSelected_ = function(node) {
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
|
||||
goog.provide('Blockly.utils.aria');
|
||||
|
||||
|
||||
|
||||
@@ -26,12 +26,11 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
|
||||
goog.provide('Blockly.utils.IdGenerator');
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new id generator.
|
||||
* Creates a new ID generator.
|
||||
* @constructor
|
||||
* @final
|
||||
*/
|
||||
@@ -39,7 +38,7 @@ Blockly.utils.IdGenerator = function() {};
|
||||
|
||||
/**
|
||||
* Get the singleton instance of Blockly.utils.IdGenerator.
|
||||
* @returns {Blockly.utils.IdGenerator} singleton instance
|
||||
* @return {Blockly.utils.IdGenerator} singleton instance
|
||||
*/
|
||||
Blockly.utils.IdGenerator.getInstance = function() {
|
||||
if (!Blockly.utils.IdGenerator.instance_) {
|
||||
@@ -49,7 +48,7 @@ Blockly.utils.IdGenerator.getInstance = function() {
|
||||
};
|
||||
|
||||
/**
|
||||
* Next unique ID to use
|
||||
* Next unique ID to use.
|
||||
* @type {number}
|
||||
* @private
|
||||
*/
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
goog.provide('Blockly.utils.KeyCodes');
|
||||
|
||||
|
||||
/**
|
||||
* Key codes for common characters.
|
||||
*
|
||||
|
||||
@@ -39,7 +39,7 @@ goog.require('Blockly.utils.Size');
|
||||
/**
|
||||
* Gets the height and width of an element.
|
||||
* Similar to Closure's goog.style.getSize
|
||||
* @param {Element} element Element to get size of.
|
||||
* @param {!Element} element Element to get size of.
|
||||
* @return {!Blockly.utils.Size} Object with width/height properties.
|
||||
*/
|
||||
Blockly.utils.style.getSize = function(element) {
|
||||
@@ -69,7 +69,7 @@ Blockly.utils.style.getSize = function(element) {
|
||||
|
||||
/**
|
||||
* Gets the height and width of an element when the display is not none.
|
||||
* @param {Element} element Element to get size of.
|
||||
* @param {!Element} element Element to get size of.
|
||||
* @return {!goog.math.Size} Object with width/height properties.
|
||||
* @private
|
||||
*/
|
||||
@@ -88,7 +88,7 @@ Blockly.utils.style.getSizeWithDisplay_ = function(element) {
|
||||
*
|
||||
* Copied from Closure's goog.style.getStyle_
|
||||
*
|
||||
* @param {Element} element Element to get style of.
|
||||
* @param {!Element} element Element to get style of.
|
||||
* @param {string} style Property to get (must be camelCase, not css-style.).
|
||||
* @return {string} Style value.
|
||||
* @private
|
||||
@@ -107,7 +107,7 @@ Blockly.utils.style.getStyle_ = function(element, style) {
|
||||
*
|
||||
* Copied from Closure's goog.style.getComputedStyle
|
||||
*
|
||||
* @param {Element} element Element to get style of.
|
||||
* @param {!Element} element Element to get style of.
|
||||
* @param {string} property Property to get (camel-case).
|
||||
* @return {string} Style value.
|
||||
*/
|
||||
@@ -130,7 +130,7 @@ Blockly.utils.style.getComputedStyle = function(element, property) {
|
||||
*
|
||||
* Copied from Closure's goog.style.getCascadedStyle
|
||||
*
|
||||
* @param {Element} element Element to get style of.
|
||||
* @param {!Element} element Element to get style of.
|
||||
* @param {string} style Property to get (camel-case).
|
||||
* @return {string} Style value.
|
||||
*/
|
||||
@@ -142,7 +142,7 @@ Blockly.utils.style.getCascadedStyle = function(element, style) {
|
||||
/**
|
||||
* Returns a Coordinate object relative to the top-left of the HTML document.
|
||||
* Similar to Closure's goog.style.getPageOffset
|
||||
* @param {Element} el Element to get the page offset for.
|
||||
* @param {!Element} el Element to get the page offset for.
|
||||
* @return {!Blockly.utils.Coordinate} The page offset.
|
||||
*/
|
||||
Blockly.utils.style.getPageOffset = function(el) {
|
||||
@@ -182,7 +182,7 @@ Blockly.utils.style.getViewportPageOffset = function() {
|
||||
* the browser's default style rules).
|
||||
* Copied from Closure's goog.style.getViewportPageOffset
|
||||
*
|
||||
* @param {Element} el Element to show or hide.
|
||||
* @param {!Element} el Element to show or hide.
|
||||
* @param {*} isShown True to render the element in its default style,
|
||||
* false to disable rendering the element.
|
||||
*/
|
||||
@@ -191,10 +191,10 @@ Blockly.utils.style.setElementShown = function(el, isShown) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if the element is using right to left (rtl) direction.
|
||||
* Returns true if the element is using right to left (RTL) direction.
|
||||
* Copied from Closure's goog.style.isRightToLeft
|
||||
*
|
||||
* @param {Element} el The element to test.
|
||||
* @param {!Element} el The element to test.
|
||||
* @return {boolean} True for right to left, false for left to right.
|
||||
*/
|
||||
Blockly.utils.style.isRightToLeft = function(el) {
|
||||
@@ -204,7 +204,7 @@ Blockly.utils.style.isRightToLeft = function(el) {
|
||||
/**
|
||||
* Gets the computed border widths (on all sides) in pixels
|
||||
* Copied from Closure's goog.style.getBorderBox
|
||||
* @param {Element} element The element to get the border widths for.
|
||||
* @param {!Element} element The element to get the border widths for.
|
||||
* @return {!Object} The computed border widths.
|
||||
*/
|
||||
Blockly.utils.style.getBorderBox = function(element) {
|
||||
@@ -228,8 +228,8 @@ Blockly.utils.style.getBorderBox = function(element) {
|
||||
* aligned as close to the container's top left corner as possible.
|
||||
* Copied from Closure's goog.style.scrollIntoContainerView
|
||||
*
|
||||
* @param {Element} element The element to make visible.
|
||||
* @param {Element} container The container to scroll. If not set, then the
|
||||
* @param {!Element} element The element to make visible.
|
||||
* @param {!Element} container The container to scroll. If not set, then the
|
||||
* document scroll element will be used.
|
||||
* @param {boolean=} opt_center Whether to center the element in the container.
|
||||
* Defaults to false.
|
||||
@@ -250,8 +250,8 @@ Blockly.utils.style.scrollIntoContainerView = function(
|
||||
* aligned as close to the container's top left corner as possible.
|
||||
* Copied from Closure's goog.style.getContainerOffsetToScrollInto
|
||||
*
|
||||
* @param {Element} element The element to make visible.
|
||||
* @param {Element} container The container to scroll. If not set, then the
|
||||
* @param {!Element} element The element to make visible.
|
||||
* @param {!Element} container The container to scroll. If not set, then the
|
||||
* document scroll element will be used.
|
||||
* @param {boolean=} opt_center Whether to center the element in the container.
|
||||
* Defaults to false.
|
||||
|
||||
@@ -330,9 +330,7 @@ Blockly.ZoomControls.prototype.createZoomResetSvg_ = function(rnd) {
|
||||
ws.setScale(ws.options.zoomOptions.startScale);
|
||||
ws.beginCanvasTransition();
|
||||
ws.scrollCenter();
|
||||
setTimeout(function() {
|
||||
ws.endCanvasTransition();
|
||||
}, 500);
|
||||
setTimeout(ws.endCanvasTransition.bind(ws), 500);
|
||||
Blockly.Touch.clearTouchIdentifier(); // Don't block future drags.
|
||||
e.stopPropagation(); // Don't start a workspace scroll.
|
||||
e.preventDefault(); // Stop double-clicking from selecting text.
|
||||
|
||||
Reference in New Issue
Block a user