mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-08-13 06:29:31 -04:00
* Localisation updates from https://translatewiki.net. * test page that creates random blocks and randomly drags them around the page * Localisation updates from https://translatewiki.net. * add missing return in fake drag * get rid of drag_tests file: * Generated JS helper functions should be camelCase. Complying with Google style guide. * Localisation updates from https://translatewiki.net. * Fix extra category error. Clean up code, rename variables, reduce line lengths, fix lint issues. * Remove claim that good.string.quote should be used. * Change the blockly workspace resizing strategy. (#386) * Add a new method to be called when the contents of the workspace change and the scrollbars need to be adjusted but the the chrome (trash, toolbox, etc) are expected to stay in the same place. Change a bunch of calls to svgResize to either be removed or call the new method instead. This is a nice performance win since the offsetHeight/Width call in svgResize can be expensive, especially when called as often as we do - there was some layout thrashing. This also paves the way for moving calls to recordDeleteAreas (which is also expensive) to a more cacheable spot than on every mouse down/touch event. of things (namely the scrollbars) * Fix size of graph demo when it first loads by calling svgResize. The graph starts with fixed width and was relying on a resize event to fire (which I believe was removed in commit217c681b86
). * Fix the resizing of the code demo. The demo's tab min-width used to match the toolbox's width was only being set on a resize event, but commit217c681b86
changed how that worked. * Fix up some comments. * Use specific workspaces rather than Blockly.getMainWorkspace(). * Make workspace required for resizeSvgContents and update some calls to send real workspaces rather than ones that are null. Remove the private tag on terminateDrag_ because it is only actually called from outside the BlockSvg object. * Remove a rogue period. * Recategorize BlockSvg.terminateDrag_ to @package instead of @private so that other developers don't use it, but it still can be used by other Blockly classes. * Add a TODO to fix issue #307. * Add @package to workspace resizeContents. * Routine recompile * Fix unit tests. * Fix inheritance on rendered connection. Closure compiler on maximum compression breaks badly due to lack of @extends attribute. * Add toolbox location and toolbox mode options to playground. * Increase commonality between playgrounds. * Properly deal with shadow statement blocks in stacks. * Localisation updates from https://translatewiki.net. * Use a comment block for function comments in generated JS, Python and Dart. * Fix typo in flyout.js (#403) * Fix typo in flyout.js (#402) * Line wrap comments in generated code. * Remove reference to undefined variable (#413) REASON_MUST_DISCONNECT was removed by a refactor in2a1ffa1
. * Fix airstrike by grabbing the correct toolbox element. (#411) Probably broken in266e2ffa9a
. * Localisation updates from https://translatewiki.net. * Fix issue #406 by calling resize from the keypress handler on text inputs. (#408) * Remove shadow blocks from Accessible Blockly demo. Update README. * Generate for loops on one line. * Introduce a common translation pipe; remove local stringMap attributes. Fix variable name error in paste functions. Minor linting. * Fix precedence on isIndex blocks. * Add indexing setting for JavaScript Generation (#419) Adding setting to allow for switching between zero and one based indexing for Blockly Blocks such that the generated code will use this flag to determine whether one based or zero based indexing should be used. One based indexing is enabled by default. * Remove unused functions and dependencies. * Remove the unnecessary construction of new services. * Fix sort block in JS to satisfy tests. * Trigger a contents resize in block's moveBy. (#422) This fixes #420 but and it also fixes some other similar problems with copy/paste and other users of moveBy. * Consolidate the usages of the 'blockly-disabled' label. * Fix error when undoing a shadow block replacement. Issue #415. * Unify setActiveDesc() and updateSelectedNode() in the TreeService. Move function calls made directly within the template to the correct hooks. * Standardize naming of components. * Prevent collisions between user functions and helper functions. * Localisation updates from https://translatewiki.net. * Fix #425. Attash the resize handler to the workspace so it can be removed (#429) when workspace.dispose() is called. * Change the TreeService to a singleton. * Remove unneeded generated parens around function calls in indexOf blocks. * Fix #423 by calling workspace's resize when the flyout reflows. (#430) * Updating URLs to reflect new docs. (#418) * Updating URLs to reflect new docs. Removing -blockly in URLs. * Rebuilt. * Routine recompile * Prevent selected block from ending up underneath a bumped block. * Fix undo on fields with validators with side effects. * Don't fire change event on fields that haven't been named yet. * Localisation updates from https://translatewiki.net. * Fix tree focus issues. * Fix remaining focus issues on block deletion. * cache delete areas instead of recalculating them onMouseDown * Cache screen CTM for performance improvement. * Call svgResizeContents from block_svg's dipose so that deleting blocks (#434) from the context menu (or anywhere really) causes the workspace to recalculate its size. Remove the call to svgResizeContents from onMouseUp's logic for determining whether the block is being dropped in the trash since it calls dispose. One side effect of this is that when you delete multiple blocks resize gets called for each of them and the scrollbars move during the operation. This is most obviously seen by doing an airstrike in the playground and then deleting all the blocks at once. * Allow terminal blocks to replace other terminal blocks (#433) * Allow terminal blocks to replace other terminal blocks * Updated test to allow replacing terminal blocks * Refactor how activeDescendant is set. Introduce helper functions to ensure that calls like pasteAbove() preserve the focus. * Localisation updates from https://translatewiki.net. * Remove unnecessary logging. * Reduce unneeded parentheses in JS and Python. * Start using field_number. * Make it easy to disable unconnected blocks. * Routine recompile. * Check if matrix is null in mouseToSvg * Remove js/ localizations pre-merge * Fix change to block_render_svg * Fix error in xml.js * Playground merge * Add simple toolboxes to playgrounds * Fix flyout reference in events listener * Move tokenizeIntepolation into Blockly.utils namespace. * Use simpler message interpolation in Code demo. * Create console stub for IE 9. * Don't output blockId if not set (e.g., toolbox category event). (#443) * Fix block in multi-playground * Increase commonality between playgrounds. # Conflicts: # tests/multi_playground.html # tests/playground.html * Remove "show flyouts" button * Recompile for merge June 22
511 lines
14 KiB
JavaScript
511 lines
14 KiB
JavaScript
/**
|
|
* @license
|
|
* Visual Blocks Editor
|
|
*
|
|
* Copyright 2012 Google Inc.
|
|
* https://developers.google.com/blockly/
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
/**
|
|
* @fileoverview Field. Used for editable titles, variables, etc.
|
|
* This is an abstract class that defines the UI on the block. Actual
|
|
* instances would be Blockly.FieldTextInput, Blockly.FieldDropdown, etc.
|
|
* @author fraser@google.com (Neil Fraser)
|
|
*/
|
|
'use strict';
|
|
|
|
goog.provide('Blockly.Field');
|
|
|
|
goog.require('goog.asserts');
|
|
goog.require('goog.dom');
|
|
goog.require('goog.math.Size');
|
|
goog.require('goog.style');
|
|
goog.require('goog.userAgent');
|
|
|
|
|
|
/**
|
|
* Abstract class for an editable field.
|
|
* @param {string} text The initial content of the field.
|
|
* @param {Function=} opt_validator An optional function that is called
|
|
* to validate any constraints on what the user entered. Takes the new
|
|
* text as an argument and returns either the accepted text, a replacement
|
|
* text, or null to abort the change.
|
|
* @constructor
|
|
*/
|
|
Blockly.Field = function(text, opt_validator) {
|
|
this.size_ = new goog.math.Size(
|
|
Blockly.BlockSvg.FIELD_WIDTH,
|
|
Blockly.BlockSvg.FIELD_HEIGHT);
|
|
this.setValue(text);
|
|
this.setValidator(opt_validator);
|
|
|
|
/**
|
|
* Maximum characters of text to display before adding an ellipsis.
|
|
* Same for strings and numbers.
|
|
* @type {number}
|
|
*/
|
|
this.maxDisplayLength = Blockly.BlockSvg.MAX_DISPLAY_LENGTH;
|
|
};
|
|
|
|
/**
|
|
* Temporary cache of text widths.
|
|
* @type {Object}
|
|
* @private
|
|
*/
|
|
Blockly.Field.cacheWidths_ = null;
|
|
|
|
/**
|
|
* Number of current references to cache.
|
|
* @type {number}
|
|
* @private
|
|
*/
|
|
Blockly.Field.cacheReference_ = 0;
|
|
|
|
|
|
/**
|
|
* Name of field. Unique within each block.
|
|
* Static labels are usually unnamed.
|
|
* @type {string=}
|
|
*/
|
|
Blockly.Field.prototype.name = undefined;
|
|
|
|
/**
|
|
* Visible text to display.
|
|
* @type {string}
|
|
* @private
|
|
*/
|
|
Blockly.Field.prototype.text_ = '';
|
|
|
|
/**
|
|
* Block this field is attached to. Starts as null, then in set in init.
|
|
* @type {Blockly.Block}
|
|
* @private
|
|
*/
|
|
Blockly.Field.prototype.sourceBlock_ = null;
|
|
|
|
/**
|
|
* Is the field visible, or hidden due to the block being collapsed?
|
|
* @type {boolean}
|
|
* @private
|
|
*/
|
|
Blockly.Field.prototype.visible_ = true;
|
|
|
|
/**
|
|
* Validation function called when user edits an editable field.
|
|
* @type {Function}
|
|
* @private
|
|
*/
|
|
Blockly.Field.prototype.validator_ = null;
|
|
|
|
/**
|
|
* Non-breaking space.
|
|
* @const
|
|
*/
|
|
Blockly.Field.NBSP = '\u00A0';
|
|
|
|
/**
|
|
* Editable fields are saved by the XML renderer, non-editable fields are not.
|
|
*/
|
|
Blockly.Field.prototype.EDITABLE = true;
|
|
|
|
/**
|
|
* Attach this field to a block.
|
|
* @param {!Blockly.Block} block The block containing this field.
|
|
*/
|
|
Blockly.Field.prototype.setSourceBlock = function(block) {
|
|
goog.asserts.assert(!this.sourceBlock_, 'Field already bound to a block.');
|
|
this.sourceBlock_ = block;
|
|
};
|
|
|
|
/**
|
|
* Install this field on a block.
|
|
*/
|
|
Blockly.Field.prototype.init = function() {
|
|
if (this.fieldGroup_) {
|
|
// Field has already been initialized once.
|
|
return;
|
|
}
|
|
// Build the DOM.
|
|
this.fieldGroup_ = Blockly.createSvgElement('g', {}, null);
|
|
if (!this.visible_) {
|
|
this.fieldGroup_.style.display = 'none';
|
|
}
|
|
// Adjust X to be flipped for RTL. Position is relative to horizontal start of source block.
|
|
var size = this.getSize();
|
|
var fieldX = (this.sourceBlock_.RTL) ? -size.width / 2 : size.width / 2;
|
|
/** @type {!Element} */
|
|
this.textElement_ = Blockly.createSvgElement('text',
|
|
{'class': 'blocklyText',
|
|
'x': fieldX,
|
|
'y': size.height / 2 + Blockly.BlockSvg.FIELD_TOP_PADDING,
|
|
'text-anchor': 'middle'},
|
|
this.fieldGroup_);
|
|
|
|
this.updateEditable();
|
|
this.sourceBlock_.getSvgRoot().appendChild(this.fieldGroup_);
|
|
this.mouseUpWrapper_ =
|
|
Blockly.bindEvent_(this.getClickTarget_(), 'mouseup', this,
|
|
this.onMouseUp_);
|
|
// Force a render.
|
|
this.updateTextNode_();
|
|
};
|
|
|
|
/**
|
|
* Dispose of all DOM objects belonging to this editable field.
|
|
*/
|
|
Blockly.Field.prototype.dispose = function() {
|
|
if (this.mouseUpWrapper_) {
|
|
Blockly.unbindEvent_(this.mouseUpWrapper_);
|
|
this.mouseUpWrapper_ = null;
|
|
}
|
|
this.sourceBlock_ = null;
|
|
goog.dom.removeNode(this.fieldGroup_);
|
|
this.fieldGroup_ = null;
|
|
this.textElement_ = null;
|
|
this.validator_ = null;
|
|
};
|
|
|
|
/**
|
|
* Add or remove the UI indicating if this field is editable or not.
|
|
*/
|
|
Blockly.Field.prototype.updateEditable = function() {
|
|
if (!this.EDITABLE || !this.sourceBlock_) {
|
|
return;
|
|
}
|
|
if (this.sourceBlock_.isEditable()) {
|
|
Blockly.addClass_(/** @type {!Element} */ (this.fieldGroup_),
|
|
'blocklyEditableText');
|
|
Blockly.removeClass_(/** @type {!Element} */ (this.fieldGroup_),
|
|
'blocklyNoNEditableText');
|
|
this.getClickTarget_().style.cursor = this.CURSOR;
|
|
} else {
|
|
Blockly.addClass_(/** @type {!Element} */ (this.fieldGroup_),
|
|
'blocklyNonEditableText');
|
|
Blockly.removeClass_(/** @type {!Element} */ (this.fieldGroup_),
|
|
'blocklyEditableText');
|
|
this.getClickTarget_().style.cursor = '';
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Gets whether this editable field is visible or not.
|
|
* @return {boolean} True if visible.
|
|
*/
|
|
Blockly.Field.prototype.isVisible = function() {
|
|
return this.visible_;
|
|
};
|
|
|
|
/**
|
|
* Sets whether this editable field is visible or not.
|
|
* @param {boolean} visible True if visible.
|
|
*/
|
|
Blockly.Field.prototype.setVisible = function(visible) {
|
|
if (this.visible_ == visible) {
|
|
return;
|
|
}
|
|
this.visible_ = visible;
|
|
var root = this.getSvgRoot();
|
|
if (root) {
|
|
root.style.display = visible ? 'block' : 'none';
|
|
this.render_();
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Sets a new validation function for editable fields.
|
|
* @param {Function} handler New validation function, or null.
|
|
*/
|
|
Blockly.Field.prototype.setValidator = function(handler) {
|
|
this.validator_ = handler;
|
|
};
|
|
|
|
/**
|
|
* Gets the validation function for editable fields.
|
|
* @return {Function} Validation function, or null.
|
|
*/
|
|
Blockly.Field.prototype.getValidator = function() {
|
|
return this.validator_;
|
|
};
|
|
|
|
/**
|
|
* Gets the group element for this editable field.
|
|
* Used for measuring the size and for positioning.
|
|
* @return {!Element} The group element.
|
|
*/
|
|
Blockly.Field.prototype.getSvgRoot = function() {
|
|
return /** @type {!Element} */ (this.fieldGroup_);
|
|
};
|
|
|
|
/**
|
|
* Draws the border with the correct width.
|
|
* Saves the computed width in a property.
|
|
* @private
|
|
*/
|
|
Blockly.Field.prototype.render_ = function() {
|
|
if (this.visible_ && this.textElement_) {
|
|
var key = this.textElement_.textContent + '\n' +
|
|
this.textElement_.className.baseVal;
|
|
if (Blockly.Field.cacheWidths_ && Blockly.Field.cacheWidths_[key]) {
|
|
var width = Blockly.Field.cacheWidths_[key];
|
|
} else {
|
|
try {
|
|
var width = this.textElement_.getComputedTextLength();
|
|
} catch (e) {
|
|
// MSIE 11 is known to throw "Unexpected call to method or property
|
|
// access." if Blockly is hidden.
|
|
var width = this.textElement_.textContent.length * 8;
|
|
}
|
|
if (Blockly.Field.cacheWidths_) {
|
|
Blockly.Field.cacheWidths_[key] = width;
|
|
}
|
|
}
|
|
// Update text centering, based on newly calculated width.
|
|
var centerTextX = width / 2;
|
|
// In a text-editing shadow block's field,
|
|
// if half the text length is not at least center of
|
|
// visible field (FIELD_WIDTH), center it there instead.
|
|
if (this.sourceBlock_.isShadow()) {
|
|
var minOffset = Blockly.BlockSvg.FIELD_WIDTH / 2;
|
|
if (this.sourceBlock_.RTL) {
|
|
// X position starts at the left edge of the block, in both RTL and LTR.
|
|
// First offset by the width of the block to move to the right edge,
|
|
// and then subtract to move to the same position as LTR.
|
|
var minCenter = width - minOffset;
|
|
centerTextX = Math.min(minCenter, centerTextX);
|
|
} else {
|
|
// (width / 2) should exceed Blockly.BlockSvg.FIELD_WIDTH / 2
|
|
// if the text is longer.
|
|
centerTextX = Math.max(minOffset, centerTextX);
|
|
}
|
|
}
|
|
this.textElement_.setAttribute('x', centerTextX);
|
|
|
|
} else {
|
|
var width = 0;
|
|
}
|
|
this.size_.width = width;
|
|
};
|
|
|
|
/**
|
|
* Start caching field widths. Every call to this function MUST also call
|
|
* stopCache. Caches must not survive between execution threads.
|
|
*/
|
|
Blockly.Field.startCache = function() {
|
|
Blockly.Field.cacheReference_++;
|
|
if (!Blockly.Field.cacheWidths_) {
|
|
Blockly.Field.cacheWidths_ = {};
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Stop caching field widths. Unless caching was already on when the
|
|
* corresponding call to startCache was made.
|
|
*/
|
|
Blockly.Field.stopCache = function() {
|
|
Blockly.Field.cacheReference_--;
|
|
if (!Blockly.Field.cacheReference_) {
|
|
Blockly.Field.cacheWidths_ = null;
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Returns the height and width of the field.
|
|
* @return {!goog.math.Size} Height and width.
|
|
*/
|
|
Blockly.Field.prototype.getSize = function() {
|
|
if (!this.size_.width) {
|
|
this.render_();
|
|
}
|
|
return this.size_;
|
|
};
|
|
|
|
/**
|
|
* Returns the height and width of the field,
|
|
* accounting for the workspace scaling.
|
|
* @return {!goog.math.Size} Height and width.
|
|
* @private
|
|
*/
|
|
Blockly.Field.prototype.getScaledBBox_ = function() {
|
|
var size = this.getSize();
|
|
// Create new object, so as to not return an uneditable SVGRect in IE.
|
|
return new goog.math.Size(size.width * this.sourceBlock_.workspace.scale,
|
|
size.height * this.sourceBlock_.workspace.scale);
|
|
};
|
|
|
|
/**
|
|
* Get the text from this field.
|
|
* @return {string} Current text.
|
|
*/
|
|
Blockly.Field.prototype.getText = function() {
|
|
return this.text_;
|
|
};
|
|
|
|
/**
|
|
* Set the text in this field. Trigger a rerender of the source block.
|
|
* @param {*} text New text.
|
|
*/
|
|
Blockly.Field.prototype.setText = function(text) {
|
|
if (text === null) {
|
|
// No change if null.
|
|
return;
|
|
}
|
|
text = String(text);
|
|
if (text === this.text_) {
|
|
// No change.
|
|
return;
|
|
}
|
|
this.text_ = text;
|
|
this.updateTextNode_();
|
|
|
|
if (this.sourceBlock_ && this.sourceBlock_.rendered) {
|
|
this.sourceBlock_.render();
|
|
this.sourceBlock_.bumpNeighbours_();
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Update the text node of this field to display the current text.
|
|
* @private
|
|
*/
|
|
Blockly.Field.prototype.updateTextNode_ = function() {
|
|
if (!this.textElement_) {
|
|
// Not rendered yet.
|
|
return;
|
|
}
|
|
var text = this.text_;
|
|
if (text.length > this.maxDisplayLength) {
|
|
// Truncate displayed string and add an ellipsis ('...').
|
|
text = text.substring(0, this.maxDisplayLength - 2) + '\u2026';
|
|
// Add special class for sizing font when truncated
|
|
this.textElement_.setAttribute('class', 'blocklyText blocklyTextTruncated');
|
|
} else {
|
|
this.textElement_.setAttribute('class', 'blocklyText');
|
|
}
|
|
// Empty the text element.
|
|
goog.dom.removeChildren(/** @type {!Element} */ (this.textElement_));
|
|
// Replace whitespace with non-breaking spaces so the text doesn't collapse.
|
|
text = text.replace(/\s/g, Blockly.Field.NBSP);
|
|
if (this.sourceBlock_.RTL && text) {
|
|
// The SVG is LTR, force text to be RTL.
|
|
text += '\u200F';
|
|
}
|
|
if (!text) {
|
|
// Prevent the field from disappearing if empty.
|
|
text = Blockly.Field.NBSP;
|
|
}
|
|
var textNode = document.createTextNode(text);
|
|
this.textElement_.appendChild(textNode);
|
|
|
|
// Cached width is obsolete. Clear it.
|
|
this.size_.width = 0;
|
|
};
|
|
|
|
/**
|
|
* By default there is no difference between the human-readable text and
|
|
* the language-neutral values. Subclasses (such as dropdown) may define this.
|
|
* @return {string} Current text.
|
|
*/
|
|
Blockly.Field.prototype.getValue = function() {
|
|
return this.getText();
|
|
};
|
|
|
|
/**
|
|
* By default there is no difference between the human-readable text and
|
|
* the language-neutral values. Subclasses (such as dropdown) may define this.
|
|
* @param {string} newText New text.
|
|
*/
|
|
Blockly.Field.prototype.setValue = function(newText) {
|
|
if (newText === null) {
|
|
// No change if null.
|
|
return;
|
|
}
|
|
var oldText = this.getValue();
|
|
if (oldText == newText) {
|
|
return;
|
|
}
|
|
if (this.sourceBlock_ && Blockly.Events.isEnabled()) {
|
|
Blockly.Events.fire(new Blockly.Events.Change(
|
|
this.sourceBlock_, 'field', this.name, oldText, newText));
|
|
}
|
|
this.setText(newText);
|
|
};
|
|
|
|
/**
|
|
* Handle a mouse up event on an editable field.
|
|
* @param {!Event} e Mouse up event.
|
|
* @private
|
|
*/
|
|
Blockly.Field.prototype.onMouseUp_ = function(e) {
|
|
if ((goog.userAgent.IPHONE || goog.userAgent.IPAD) &&
|
|
!goog.userAgent.isVersionOrHigher('537.51.2') &&
|
|
e.layerX !== 0 && e.layerY !== 0) {
|
|
// Old iOS spawns a bogus event on the next touch after a 'prompt()' edit.
|
|
// Unlike the real events, these have a layerX and layerY set.
|
|
return;
|
|
} else if (Blockly.isRightButton(e)) {
|
|
// Right-click.
|
|
return;
|
|
} else if (Blockly.dragMode_ == Blockly.DRAG_FREE) {
|
|
// Drag operation is concluding. Don't open the editor.
|
|
return;
|
|
} else if (this.sourceBlock_.isEditable()) {
|
|
// Non-abstract sub-classes must define a showEditor_ method.
|
|
this.showEditor_();
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Change the tooltip text for this field.
|
|
* @param {string|!Element} newTip Text for tooltip or a parent element to
|
|
* link to for its tooltip.
|
|
*/
|
|
Blockly.Field.prototype.setTooltip = function(newTip) {
|
|
// Non-abstract sub-classes may wish to implement this. See FieldLabel.
|
|
};
|
|
|
|
/**
|
|
* Select the element to bind the click handler to. When this element is
|
|
* clicked on an editable field, the editor will open.
|
|
*
|
|
* <p>If the block has multiple fields, this is just the group containing the
|
|
* field. If the block has only one field, we handle clicks over the whole
|
|
* block.
|
|
*
|
|
* @return {!Element} Element to bind click handler to.
|
|
* @private
|
|
*/
|
|
Blockly.Field.prototype.getClickTarget_ = function() {
|
|
var nFields = 0;
|
|
|
|
for (var i = 0, input; input = this.sourceBlock_.inputList[i]; i++) {
|
|
nFields += input.fieldRow.length;
|
|
}
|
|
|
|
if (nFields <= 1) {
|
|
return this.sourceBlock_.getSvgRoot();
|
|
} else {
|
|
return this.getSvgRoot();
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Return the absolute coordinates of the top-left corner of this field.
|
|
* The origin (0,0) is the top-left corner of the page body.
|
|
* @return {!goog.math.Coordinate} Object with .x and .y properties.
|
|
* @private
|
|
*/
|
|
Blockly.Field.prototype.getAbsoluteXY_ = function() {
|
|
return goog.style.getPageOffset(this.getClickTarget_());
|
|
};
|