diff --git a/core/block_animations.js b/core/block_animations.js
index 5c52a20c4..856b444fb 100644
--- a/core/block_animations.js
+++ b/core/block_animations.js
@@ -102,7 +102,8 @@ Blockly.blockAnimations.connectionUiEffect = function(block) {
xy.x += (block.RTL ? -23 : 23) * scale;
xy.y += 3 * scale;
}
- var ripple = Blockly.utils.dom.createSvgElement('circle',
+ var ripple = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.CIRCLE,
{
'cx': xy.x,
'cy': xy.y,
diff --git a/core/block_drag_surface.js b/core/block_drag_surface.js
index 31b8a4396..ed01b72fc 100644
--- a/core/block_drag_surface.js
+++ b/core/block_drag_surface.js
@@ -82,14 +82,16 @@ Blockly.BlockDragSurfaceSvg.prototype.createDom = function() {
if (this.SVG_) {
return; // Already created.
}
- this.SVG_ = Blockly.utils.dom.createSvgElement('svg', {
- 'xmlns': Blockly.utils.dom.SVG_NS,
- 'xmlns:html': Blockly.utils.dom.HTML_NS,
- 'xmlns:xlink': Blockly.utils.dom.XLINK_NS,
- 'version': '1.1',
- 'class': 'blocklyBlockDragSurface'
- }, this.container_);
- this.dragGroup_ = Blockly.utils.dom.createSvgElement('g', {}, this.SVG_);
+ this.SVG_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.SVG, {
+ 'xmlns': Blockly.utils.dom.SVG_NS,
+ 'xmlns:html': Blockly.utils.dom.HTML_NS,
+ 'xmlns:xlink': Blockly.utils.dom.XLINK_NS,
+ 'version': '1.1',
+ 'class': 'blocklyBlockDragSurface'
+ }, this.container_);
+ this.dragGroup_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.G, {}, this.SVG_);
};
/**
diff --git a/core/block_svg.js b/core/block_svg.js
index ab2958368..2cd82cf3e 100644
--- a/core/block_svg.js
+++ b/core/block_svg.js
@@ -58,8 +58,8 @@ Blockly.BlockSvg = function(workspace, prototypeName, opt_id) {
* @type {!SVGGElement}
* @private
*/
- this.svgGroup_ = /** @type {!SVGGElement} */ (
- Blockly.utils.dom.createSvgElement('g', {}, null));
+ this.svgGroup_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.G, {}, null);
this.svgGroup_.translate_ = '';
/**
diff --git a/core/bubble.js b/core/bubble.js
index 7208d8492..51ce808ce 100644
--- a/core/bubble.js
+++ b/core/bubble.js
@@ -234,7 +234,8 @@ Blockly.Bubble.prototype.createDom_ = function(content, hasResize) {
[...content goes here...]
*/
- this.bubbleGroup_ = Blockly.utils.dom.createSvgElement('g', {}, null);
+ this.bubbleGroup_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.G, {}, null);
var filter =
{'filter': 'url(#' +
this.workspace_.getRenderer().getConstants().embossFilterId + ')'};
@@ -243,11 +244,14 @@ Blockly.Bubble.prototype.createDom_ = function(content, hasResize) {
// https://github.com/google/blockly/issues/99
filter = {};
}
- var bubbleEmboss = Blockly.utils.dom.createSvgElement('g',
+ var bubbleEmboss = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.G,
filter, this.bubbleGroup_);
- this.bubbleArrow_ = Blockly.utils.dom.createSvgElement('path', {},
+ this.bubbleArrow_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.PATH, {},
bubbleEmboss);
- this.bubbleBack_ = Blockly.utils.dom.createSvgElement('rect',
+ this.bubbleBack_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.RECT,
{
'class': 'blocklyDraggable',
'x': 0,
@@ -257,21 +261,25 @@ Blockly.Bubble.prototype.createDom_ = function(content, hasResize) {
},
bubbleEmboss);
if (hasResize) {
- this.resizeGroup_ = Blockly.utils.dom.createSvgElement('g',
+ this.resizeGroup_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.G,
{'class': this.workspace_.RTL ?
'blocklyResizeSW' : 'blocklyResizeSE'},
this.bubbleGroup_);
var resizeSize = 2 * Blockly.Bubble.BORDER_WIDTH;
- Blockly.utils.dom.createSvgElement('polygon',
+ Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.POLYGON,
{'points': '0,x x,x x,0'.replace(/x/g, resizeSize.toString())},
this.resizeGroup_);
- Blockly.utils.dom.createSvgElement('line',
+ Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.LINE,
{
'class': 'blocklyResizeLine',
'x1': resizeSize / 3, 'y1': resizeSize - 1,
'x2': resizeSize - 1, 'y2': resizeSize / 3
}, this.resizeGroup_);
- Blockly.utils.dom.createSvgElement('line',
+ Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.LINE,
{
'class': 'blocklyResizeLine',
'x1': resizeSize * 2 / 3,
diff --git a/core/comment.js b/core/comment.js
index 54c102b08..5127042fe 100644
--- a/core/comment.js
+++ b/core/comment.js
@@ -90,13 +90,15 @@ Blockly.utils.object.inherits(Blockly.Comment, Blockly.Icon);
*/
Blockly.Comment.prototype.drawIcon_ = function(group) {
// Circle.
- Blockly.utils.dom.createSvgElement('circle',
+ Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.CIRCLE,
{'class': 'blocklyIconShape', 'r': '8', 'cx': '8', 'cy': '8'},
group);
// Can't use a real '?' text character since different browsers and operating
// systems render it differently.
// Body of question mark.
- Blockly.utils.dom.createSvgElement('path',
+ Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.PATH,
{
'class': 'blocklyIconSymbol',
'd': 'm6.8,10h2c0.003,-0.617 0.271,-0.962 0.633,-1.266 2.875,-2.405' +
@@ -104,7 +106,8 @@ Blockly.Comment.prototype.drawIcon_ = function(group) {
'-1.201,0.998 -1.201,1.528 -1.204,2.19z'},
group);
// Dot of question mark.
- Blockly.utils.dom.createSvgElement('rect',
+ Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.RECT,
{
'class': 'blocklyIconSymbol',
'x': '6.8',
@@ -133,7 +136,8 @@ Blockly.Comment.prototype.createEditor_ = function() {
* For non-editable mode see Warning.textToDom_.
*/
- this.foreignObject_ = Blockly.utils.dom.createSvgElement('foreignObject',
+ this.foreignObject_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.FOREIGNOBJECT,
{'x': Blockly.Bubble.BORDER_WIDTH, 'y': Blockly.Bubble.BORDER_WIDTH},
null);
diff --git a/core/field.js b/core/field.js
index d1e501cc3..a9d54ff2f 100644
--- a/core/field.js
+++ b/core/field.js
@@ -298,8 +298,8 @@ Blockly.Field.prototype.init = function() {
// Field has already been initialized once.
return;
}
- this.fieldGroup_ = /** @type {!SVGGElement} **/
- (Blockly.utils.dom.createSvgElement('g', {}, null));
+ this.fieldGroup_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.G, {}, null);
if (!this.isVisible()) {
this.fieldGroup_.style.display = 'none';
}
@@ -336,17 +336,16 @@ Blockly.Field.prototype.initModel = function() {
* @protected
*/
Blockly.Field.prototype.createBorderRect_ = function() {
- this.borderRect_ = /** @type {!SVGRectElement} **/
- (Blockly.utils.dom.createSvgElement('rect',
- {
- 'rx': this.getConstants().FIELD_BORDER_RECT_RADIUS,
- 'ry': this.getConstants().FIELD_BORDER_RECT_RADIUS,
- 'x': 0,
- 'y': 0,
- 'height': this.size_.height,
- 'width': this.size_.width,
- 'class': 'blocklyFieldRect'
- }, this.fieldGroup_));
+ this.borderRect_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.RECT, {
+ 'rx': this.getConstants().FIELD_BORDER_RECT_RADIUS,
+ 'ry': this.getConstants().FIELD_BORDER_RECT_RADIUS,
+ 'x': 0,
+ 'y': 0,
+ 'height': this.size_.height,
+ 'width': this.size_.width,
+ 'class': 'blocklyFieldRect'
+ }, this.fieldGroup_);
};
/**
@@ -356,11 +355,10 @@ Blockly.Field.prototype.createBorderRect_ = function() {
* @protected
*/
Blockly.Field.prototype.createTextElement_ = function() {
- this.textElement_ = /** @type {!SVGTextElement} **/
- (Blockly.utils.dom.createSvgElement('text',
- {
- 'class': 'blocklyText',
- }, this.fieldGroup_));
+ this.textElement_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.TEXT, {
+ 'class': 'blocklyText',
+ }, this.fieldGroup_);
if (this.getConstants().FIELD_TEXT_BASELINE_CENTER) {
this.textElement_.setAttribute('dominant-baseline', 'central');
}
diff --git a/core/field_angle.js b/core/field_angle.js
index 04133dbf4..bc7260051 100644
--- a/core/field_angle.js
+++ b/core/field_angle.js
@@ -236,7 +236,8 @@ Blockly.FieldAngle.prototype.configure_ = function(config) {
Blockly.FieldAngle.prototype.initView = function() {
Blockly.FieldAngle.superClass_.initView.call(this);
// Add the degree symbol to the left of the number, even in RTL (issue #2380)
- this.symbol_ = Blockly.utils.dom.createSvgElement('tspan', {}, null);
+ this.symbol_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.TSPAN, {}, null);
this.symbol_.appendChild(document.createTextNode('\u00B0'));
this.textElement_.appendChild(this.symbol_);
};
@@ -283,41 +284,46 @@ Blockly.FieldAngle.prototype.showEditor_ = function(opt_e) {
* @private
*/
Blockly.FieldAngle.prototype.dropdownCreate_ = function() {
- var svg = Blockly.utils.dom.createSvgElement('svg', {
- 'xmlns': Blockly.utils.dom.SVG_NS,
- 'xmlns:html': Blockly.utils.dom.HTML_NS,
- 'xmlns:xlink': Blockly.utils.dom.XLINK_NS,
- 'version': '1.1',
- 'height': (Blockly.FieldAngle.HALF * 2) + 'px',
- 'width': (Blockly.FieldAngle.HALF * 2) + 'px',
- 'style': 'touch-action: none'
- }, null);
- var circle = Blockly.utils.dom.createSvgElement('circle', {
- 'cx': Blockly.FieldAngle.HALF,
- 'cy': Blockly.FieldAngle.HALF,
- 'r': Blockly.FieldAngle.RADIUS,
- 'class': 'blocklyAngleCircle'
- }, svg);
- this.gauge_ = Blockly.utils.dom.createSvgElement('path', {
- 'class': 'blocklyAngleGauge'
- }, svg);
- this.line_ = Blockly.utils.dom.createSvgElement('line', {
- 'x1': Blockly.FieldAngle.HALF,
- 'y1': Blockly.FieldAngle.HALF,
- 'class': 'blocklyAngleLine'
- }, svg);
+ var svg = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.SVG, {
+ 'xmlns': Blockly.utils.dom.SVG_NS,
+ 'xmlns:html': Blockly.utils.dom.HTML_NS,
+ 'xmlns:xlink': Blockly.utils.dom.XLINK_NS,
+ 'version': '1.1',
+ 'height': (Blockly.FieldAngle.HALF * 2) + 'px',
+ 'width': (Blockly.FieldAngle.HALF * 2) + 'px',
+ 'style': 'touch-action: none'
+ }, null);
+ var circle = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.CIRCLE, {
+ 'cx': Blockly.FieldAngle.HALF,
+ 'cy': Blockly.FieldAngle.HALF,
+ 'r': Blockly.FieldAngle.RADIUS,
+ 'class': 'blocklyAngleCircle'
+ }, svg);
+ this.gauge_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.PATH, {
+ 'class': 'blocklyAngleGauge'
+ }, svg);
+ this.line_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.LINE, {
+ 'x1': Blockly.FieldAngle.HALF,
+ 'y1': Blockly.FieldAngle.HALF,
+ 'class': 'blocklyAngleLine'
+ }, svg);
// Draw markers around the edge.
for (var angle = 0; angle < 360; angle += 15) {
- Blockly.utils.dom.createSvgElement('line', {
- 'x1': Blockly.FieldAngle.HALF + Blockly.FieldAngle.RADIUS,
- 'y1': Blockly.FieldAngle.HALF,
- 'x2': Blockly.FieldAngle.HALF + Blockly.FieldAngle.RADIUS -
- (angle % 45 == 0 ? 10 : 5),
- 'y2': Blockly.FieldAngle.HALF,
- 'class': 'blocklyAngleMarks',
- 'transform': 'rotate(' + angle + ',' +
- Blockly.FieldAngle.HALF + ',' + Blockly.FieldAngle.HALF + ')'
- }, svg);
+ Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.LINE, {
+ 'x1': Blockly.FieldAngle.HALF + Blockly.FieldAngle.RADIUS,
+ 'y1': Blockly.FieldAngle.HALF,
+ 'x2': Blockly.FieldAngle.HALF + Blockly.FieldAngle.RADIUS -
+ (angle % 45 == 0 ? 10 : 5),
+ 'y2': Blockly.FieldAngle.HALF,
+ 'class': 'blocklyAngleMarks',
+ 'transform': 'rotate(' + angle + ',' +
+ Blockly.FieldAngle.HALF + ',' + Blockly.FieldAngle.HALF + ')'
+ }, svg);
}
// The angle picker is different from other fields in that it updates on
diff --git a/core/field_dropdown.js b/core/field_dropdown.js
index bdbe27f9e..73d106e63 100644
--- a/core/field_dropdown.js
+++ b/core/field_dropdown.js
@@ -212,8 +212,8 @@ Blockly.FieldDropdown.prototype.initView = function() {
}
this.createTextElement_();
- this.imageElement_ = /** @type {!SVGImageElement} */
- (Blockly.utils.dom.createSvgElement('image', {}, this.fieldGroup_));
+ this.imageElement_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.IMAGE, {}, this.fieldGroup_);
if (this.getConstants().FIELD_DROPDOWN_SVG_ARROW) {
this.createSVGArrow_();
@@ -242,8 +242,8 @@ Blockly.FieldDropdown.prototype.shouldAddBorderRect_ = function() {
* @protected
*/
Blockly.FieldDropdown.prototype.createTextArrow_ = function() {
- this.arrow_ = /** @type {!SVGTSpanElement} */
- (Blockly.utils.dom.createSvgElement('tspan', {}, this.textElement_));
+ this.arrow_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.TSPAN, {}, this.textElement_);
this.arrow_.appendChild(document.createTextNode(
this.sourceBlock_.RTL ?
Blockly.FieldDropdown.ARROW_CHAR + ' ' :
@@ -260,10 +260,11 @@ Blockly.FieldDropdown.prototype.createTextArrow_ = function() {
* @protected
*/
Blockly.FieldDropdown.prototype.createSVGArrow_ = function() {
- this.svgArrow_ = Blockly.utils.dom.createSvgElement('image', {
- 'height': this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE + 'px',
- 'width': this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE + 'px'
- }, this.fieldGroup_);
+ this.svgArrow_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.IMAGE, {
+ 'height': this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE + 'px',
+ 'width': this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE + 'px'
+ }, this.fieldGroup_);
this.svgArrow_.setAttributeNS(Blockly.utils.dom.XLINK_NS, 'xlink:href',
this.getConstants().FIELD_DROPDOWN_SVG_ARROW_DATAURI);
};
diff --git a/core/field_image.js b/core/field_image.js
index d6474ea3b..d0ec555cb 100644
--- a/core/field_image.js
+++ b/core/field_image.js
@@ -176,15 +176,14 @@ Blockly.FieldImage.prototype.configure_ = function(config) {
* @package
*/
Blockly.FieldImage.prototype.initView = function() {
- this.imageElement_ = /** @type {!SVGImageElement} */
- (Blockly.utils.dom.createSvgElement(
- 'image',
- {
- 'height': this.imageHeight_ + 'px',
- 'width': this.size_.width + 'px',
- 'alt': this.altText_
- },
- this.fieldGroup_));
+ this.imageElement_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.IMAGE,
+ {
+ 'height': this.imageHeight_ + 'px',
+ 'width': this.size_.width + 'px',
+ 'alt': this.altText_
+ },
+ this.fieldGroup_);
this.imageElement_.setAttributeNS(Blockly.utils.dom.XLINK_NS,
'xlink:href', /** @type {string} */ (this.value_));
diff --git a/core/field_multilineinput.js b/core/field_multilineinput.js
index 0660aa571..4b5ccd741 100644
--- a/core/field_multilineinput.js
+++ b/core/field_multilineinput.js
@@ -75,11 +75,10 @@ Blockly.FieldMultilineInput.fromJson = function(options) {
*/
Blockly.FieldMultilineInput.prototype.initView = function() {
this.createBorderRect_();
- this.textGroup_ = /** @type {!SVGGElement} **/
- (Blockly.utils.dom.createSvgElement('g',
- {
- 'class': 'blocklyEditableText',
- }, this.fieldGroup_));
+ this.textGroup_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.G, {
+ 'class': 'blocklyEditableText',
+ }, this.fieldGroup_);
};
/**
@@ -134,12 +133,13 @@ Blockly.FieldMultilineInput.prototype.render_ = function() {
for (var i = 0; i < lines.length; i++) {
var lineHeight = this.getConstants().FIELD_TEXT_HEIGHT +
this.getConstants().FIELD_BORDER_RECT_Y_PADDING;
- var span = Blockly.utils.dom.createSvgElement('text', {
- 'class': 'blocklyText blocklyMultilineText',
- x: this.getConstants().FIELD_BORDER_RECT_X_PADDING,
- y: y + this.getConstants().FIELD_BORDER_RECT_Y_PADDING,
- dy: this.getConstants().FIELD_TEXT_BASELINE
- }, this.textGroup_);
+ var span = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.TEXT, {
+ 'class': 'blocklyText blocklyMultilineText',
+ x: this.getConstants().FIELD_BORDER_RECT_X_PADDING,
+ y: y + this.getConstants().FIELD_BORDER_RECT_Y_PADDING,
+ dy: this.getConstants().FIELD_TEXT_BASELINE
+ }, this.textGroup_);
span.appendChild(document.createTextNode(lines[i]));
y += lineHeight;
}
diff --git a/core/flyout_base.js b/core/flyout_base.js
index 547035ad3..2d382a2be 100644
--- a/core/flyout_base.js
+++ b/core/flyout_base.js
@@ -223,8 +223,10 @@ Blockly.Flyout.prototype.dragAngleRange_ = 70;
* Creates the flyout's DOM. Only needs to be called once. The flyout can
* either exist as its own svg element or be a g element nested inside a
* separate svg element.
- * @param {string} tagName The type of tag to put the flyout in. This
- * should be
*/
- this.SVG_ = Blockly.utils.dom.createSvgElement('svg',
+ this.SVG_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.SVG,
{
'xmlns': Blockly.utils.dom.SVG_NS,
'xmlns:html': Blockly.utils.dom.HTML_NS,
diff --git a/core/workspace_svg.js b/core/workspace_svg.js
index dfa2430ff..b1f996e13 100644
--- a/core/workspace_svg.js
+++ b/core/workspace_svg.js
@@ -711,7 +711,8 @@ Blockly.WorkspaceSvg.prototype.createDom = function(opt_backgroundClass) {
*
* @type {SVGElement}
*/
- this.svgGroup_ = Blockly.utils.dom.createSvgElement('g',
+ this.svgGroup_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.G,
{'class': 'blocklyWorkspace'}, null);
// Note that a alone does not receive mouse events--it must have a
@@ -719,7 +720,8 @@ Blockly.WorkspaceSvg.prototype.createDom = function(opt_backgroundClass) {
// flyout, the workspace will not receive mouse events.
if (opt_backgroundClass) {
/** @type {SVGElement} */
- this.svgBackground_ = Blockly.utils.dom.createSvgElement('rect',
+ this.svgBackground_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.RECT,
{'height': '100%', 'width': '100%', 'class': opt_backgroundClass},
this.svgGroup_);
@@ -732,10 +734,12 @@ Blockly.WorkspaceSvg.prototype.createDom = function(opt_backgroundClass) {
}
}
/** @type {SVGElement} */
- this.svgBlockCanvas_ = Blockly.utils.dom.createSvgElement('g',
+ this.svgBlockCanvas_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.G,
{'class': 'blocklyBlockCanvas'}, this.svgGroup_);
/** @type {SVGElement} */
- this.svgBubbleCanvas_ = Blockly.utils.dom.createSvgElement('g',
+ this.svgBubbleCanvas_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.G,
{'class': 'blocklyBubbleCanvas'}, this.svgGroup_);
if (!this.isFlyout) {
@@ -897,7 +901,10 @@ Blockly.WorkspaceSvg.prototype.addZoomControls = function() {
/**
* Add a flyout element in an element with the given tag name.
- * @param {string} tagName What type of tag the flyout belongs in.
+ * @param {string|
+ * !Blockly.utils.dom.SvgElementType|
+ * !Blockly.utils.dom.SvgElementType} tagName What type of tag the
+ * flyout belongs in.
* @return {!Element} The element containing the flyout DOM.
* @package
*/
diff --git a/core/zoom_controls.js b/core/zoom_controls.js
index 98e431f7f..b69d3e128 100644
--- a/core/zoom_controls.js
+++ b/core/zoom_controls.js
@@ -53,6 +53,35 @@ Blockly.ZoomControls = function(workspace) {
* @private
*/
this.onZoomOutWrapper_ = null;
+
+ /**
+ * The vertical distance between the workspace bottom edge and the control.
+ * The value is initialized during `init`.
+ * @type {?number}
+ * @private
+ */
+ this.verticalSpacing_ = null;
+
+ /**
+ * The zoom in svg element.
+ * @type {SVGGElement}
+ * @private
+ */
+ this.zoomInGroup_ = null;
+
+ /**
+ * The zoom out svg element.
+ * @type {SVGGElement}
+ * @private
+ */
+ this.zoomOutGroup_ = null;
+
+ /**
+ * The zoom reset svg element.
+ * @type {SVGGElement}
+ * @private
+ */
+ this.zoomResetGroup_ = null;
};
/**
@@ -110,8 +139,8 @@ Blockly.ZoomControls.prototype.top_ = 0;
* @return {!SVGElement} The zoom controls SVG group.
*/
Blockly.ZoomControls.prototype.createDom = function() {
- this.svgGroup_ =
- Blockly.utils.dom.createSvgElement('g', {}, null);
+ this.svgGroup_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.G, {}, null);
// Each filter/pattern needs a unique ID for the case of multiple Blockly
// instances on a page. Browser behaviour becomes undefined otherwise.
@@ -217,20 +246,24 @@ Blockly.ZoomControls.prototype.createZoomOutSvg_ = function(rnd) {
clip-path="url(#blocklyZoomoutClipPath837493)">
*/
- this.zoomOutGroup_ = Blockly.utils.dom.createSvgElement('g',
+ this.zoomOutGroup_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.G,
{'class': 'blocklyZoom'}, this.svgGroup_);
- var clip = Blockly.utils.dom.createSvgElement('clipPath',
+ var clip = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.CLIPPATH,
{
'id': 'blocklyZoomoutClipPath' + rnd
},
this.zoomOutGroup_);
- Blockly.utils.dom.createSvgElement('rect',
+ Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.RECT,
{
'width': 32,
'height': 32,
},
clip);
- var zoomoutSvg = Blockly.utils.dom.createSvgElement('image',
+ var zoomoutSvg = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.IMAGE,
{
'width': Blockly.SPRITE.width,
'height': Blockly.SPRITE.height,
@@ -264,20 +297,24 @@ Blockly.ZoomControls.prototype.createZoomInSvg_ = function(rnd) {
clip-path="url(#blocklyZoominClipPath837493)">
*/
- this.zoomInGroup_ = Blockly.utils.dom.createSvgElement('g',
+ this.zoomInGroup_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.G,
{'class': 'blocklyZoom'}, this.svgGroup_);
- var clip = Blockly.utils.dom.createSvgElement('clipPath',
+ var clip = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.CLIPPATH,
{
'id': 'blocklyZoominClipPath' + rnd
},
this.zoomInGroup_);
- Blockly.utils.dom.createSvgElement('rect',
+ Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.RECT,
{
'width': 32,
'height': 32,
},
clip);
- var zoominSvg = Blockly.utils.dom.createSvgElement('image',
+ var zoominSvg = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.IMAGE,
{
'width': Blockly.SPRITE.width,
'height': Blockly.SPRITE.height,
@@ -329,20 +366,24 @@ Blockly.ZoomControls.prototype.createZoomResetSvg_ = function(rnd) {
clip-path="url(#blocklyZoomresetClipPath837493)">
*/
- this.zoomResetGroup_ = Blockly.utils.dom.createSvgElement('g',
+ this.zoomResetGroup_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.G,
{'class': 'blocklyZoom'}, this.svgGroup_);
- var clip = Blockly.utils.dom.createSvgElement('clipPath',
+ var clip = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.CLIPPATH,
{
'id': 'blocklyZoomresetClipPath' + rnd
},
this.zoomResetGroup_);
- Blockly.utils.dom.createSvgElement('rect',
+ Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.RECT,
{
'width': 32,
'height': 32
},
clip);
- var zoomresetSvg = Blockly.utils.dom.createSvgElement('image',
+ var zoomresetSvg = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.IMAGE,
{
'width': Blockly.SPRITE.width,
'height': Blockly.SPRITE.height,
diff --git a/tests/mocha/field_checkbox_test.js b/tests/mocha/field_checkbox_test.js
index 7eaac4d5a..f7ff4dac6 100644
--- a/tests/mocha/field_checkbox_test.js
+++ b/tests/mocha/field_checkbox_test.js
@@ -159,7 +159,8 @@ suite('Checkbox Fields', function() {
suite('Customizations', function() {
suite('Check Character', function() {
function assertCharacter(field, char) {
- field.fieldGroup_ = Blockly.utils.dom.createSvgElement('g', {}, null);
+ field.fieldGroup_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.G, {}, null);
field.sourceBlock_ = {
RTL: false,
rendered: true,
diff --git a/tests/mocha/field_label_serializable_test.js b/tests/mocha/field_label_serializable_test.js
index 8b7954a68..8d6ad9864 100644
--- a/tests/mocha/field_label_serializable_test.js
+++ b/tests/mocha/field_label_serializable_test.js
@@ -91,7 +91,8 @@ suite('Label Serializable Fields', function() {
suite('Customizations', function() {
function assertHasClass(labelField, cssClass) {
- labelField.fieldGroup_ = Blockly.utils.dom.createSvgElement('g', {}, null);
+ labelField.fieldGroup_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.G, {}, null);
labelField.constants_ = {
FIELD_TEXT_BASELINE_Y: 13
};
@@ -100,7 +101,8 @@ suite('Label Serializable Fields', function() {
labelField.textElement_, cssClass));
}
function assertDoesNotHaveClass(labelField, cssClass) {
- labelField.fieldGroup_ = Blockly.utils.dom.createSvgElement('g', {}, null);
+ labelField.fieldGroup_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.G, {}, null);
labelField.constants_ = {
FIELD_TEXT_BASELINE_Y: 13
};
@@ -146,7 +148,8 @@ suite('Label Serializable Fields', function() {
suite('setClass', function() {
test('setClass', function() {
var field = new Blockly.FieldLabelSerializable();
- field.fieldGroup_ = Blockly.utils.dom.createSvgElement('g', {}, null);
+ field.fieldGroup_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.G, {}, null);
field.constants_ = {
FIELD_TEXT_BASELINE_Y: 13
};
diff --git a/tests/mocha/field_label_test.js b/tests/mocha/field_label_test.js
index 62a888aae..698f21f10 100644
--- a/tests/mocha/field_label_test.js
+++ b/tests/mocha/field_label_test.js
@@ -91,8 +91,8 @@ suite('Label Fields', function() {
suite('Customizations', function() {
function assertHasClass(labelField, cssClass) {
- labelField.fieldGroup_ =
- Blockly.utils.dom.createSvgElement('g', {}, null);
+ labelField.fieldGroup_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.G, {}, null);
labelField.constants_ = {
FIELD_TEXT_BASELINE_Y: 13
};
@@ -101,8 +101,8 @@ suite('Label Fields', function() {
labelField.textElement_, cssClass));
}
function assertDoesNotHaveClass(labelField, cssClass) {
- labelField.fieldGroup_ =
- Blockly.utils.dom.createSvgElement('g', {}, null);
+ labelField.fieldGroup_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.G, {}, null);
labelField.constants_ = {
FIELD_TEXT_BASELINE_Y: 13
};
@@ -149,7 +149,8 @@ suite('Label Fields', function() {
suite('setClass', function() {
test('setClass', function() {
var field = new Blockly.FieldLabel();
- field.fieldGroup_ = Blockly.utils.dom.createSvgElement('g', {}, null);
+ field.fieldGroup_ = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.G, {}, null);
field.constants_ = {
FIELD_TEXT_BASELINE_Y: 13
};
diff --git a/tests/rendering/svg_paths.html b/tests/rendering/svg_paths.html
index 48223e37c..128eb6be5 100644
--- a/tests/rendering/svg_paths.html
+++ b/tests/rendering/svg_paths.html
@@ -45,17 +45,19 @@ limitations under the License.
var svgSpace;
function addPathAt(path, x, y) {
- var group = Blockly.utils.dom.createSvgElement('g',
+ var group = Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.G,
{
'transform': 'translate(' + (x + 50) + ', ' + y + ')'
}, svgSpace);
- Blockly.utils.dom.createSvgElement('path', {
- 'd': 'M 0,0 ' + path,
- 'marker-start': 'url(#startDot)',
- 'marker-end': 'url(#endDot)',
- 'class': 'pathDebugClass'
- },
- group);
+ Blockly.utils.dom.createSvgElement(
+ Blockly.utils.dom.SvgElementType.PATH, {
+ 'd': 'M 0,0 ' + path,
+ 'marker-start': 'url(#startDot)',
+ 'marker-end': 'url(#endDot)',
+ 'class': 'pathDebugClass'
+ },
+ group);
return group;