mirror of
https://github.com/google/blockly.git
synced 2026-01-09 01:50:11 +01:00
Use generics to derive SVG element type (#4036)
* Encapsulate type in a generic to automatically derive type of SVG element when using createSvgElement
This commit is contained in:
@@ -46,7 +46,8 @@ Blockly.Warning.prototype.collapseHidden = false;
|
||||
*/
|
||||
Blockly.Warning.prototype.drawIcon_ = function(group) {
|
||||
// Triangle with rounded corners.
|
||||
Blockly.utils.dom.createSvgElement('path',
|
||||
Blockly.utils.dom.createSvgElement(
|
||||
Blockly.utils.dom.SvgElementType.PATH,
|
||||
{
|
||||
'class': 'blocklyIconShape',
|
||||
'd': 'M2,15Q-1,15 0.5,12L6.5,1.7Q8,-1 9.5,1.7L15.5,12Q17,15 14,15z'
|
||||
@@ -55,14 +56,16 @@ Blockly.Warning.prototype.drawIcon_ = function(group) {
|
||||
// Can't use a real '!' text character since different browsers and operating
|
||||
// systems render it differently.
|
||||
// Body of exclamation point.
|
||||
Blockly.utils.dom.createSvgElement('path',
|
||||
Blockly.utils.dom.createSvgElement(
|
||||
Blockly.utils.dom.SvgElementType.PATH,
|
||||
{
|
||||
'class': 'blocklyIconSymbol',
|
||||
'd': 'm7,4.8v3.16l0.27,2.27h1.46l0.27,-2.27v-3.16z'
|
||||
},
|
||||
group);
|
||||
// Dot of exclamation point.
|
||||
Blockly.utils.dom.createSvgElement('rect',
|
||||
Blockly.utils.dom.createSvgElement(
|
||||
Blockly.utils.dom.SvgElementType.RECT,
|
||||
{
|
||||
'class': 'blocklyIconSymbol',
|
||||
'x': '7', 'y': '11', 'height': '2', 'width': '2'
|
||||
@@ -77,18 +80,17 @@ Blockly.Warning.prototype.drawIcon_ = function(group) {
|
||||
* @private
|
||||
*/
|
||||
Blockly.Warning.textToDom_ = function(text) {
|
||||
var paragraph = /** @type {!SVGTextElement} */
|
||||
(Blockly.utils.dom.createSvgElement(
|
||||
'text',
|
||||
{
|
||||
'class': 'blocklyText blocklyBubbleText blocklyNoPointerEvents',
|
||||
'y': Blockly.Bubble.BORDER_WIDTH
|
||||
},
|
||||
null)
|
||||
);
|
||||
var paragraph = Blockly.utils.dom.createSvgElement(
|
||||
Blockly.utils.dom.SvgElementType.TEXT,
|
||||
{
|
||||
'class': 'blocklyText blocklyBubbleText blocklyNoPointerEvents',
|
||||
'y': Blockly.Bubble.BORDER_WIDTH
|
||||
},
|
||||
null);
|
||||
var lines = text.split('\n');
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
var tspanElement = Blockly.utils.dom.createSvgElement('tspan',
|
||||
var tspanElement = Blockly.utils.dom.createSvgElement(
|
||||
Blockly.utils.dom.SvgElementType.TSPAN,
|
||||
{'dy': '1em', 'x': Blockly.Bubble.BORDER_WIDTH}, paragraph);
|
||||
var textNode = document.createTextNode(lines[i]);
|
||||
tspanElement.appendChild(textNode);
|
||||
|
||||
Reference in New Issue
Block a user