Skip to content

Commit d7e2a74

Browse files
authored
field_expandable_remove.js -- polish
1 parent f70f6b9 commit d7e2a74

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

core/field_expandable_remove.js

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,19 @@
1919
*/
2020

2121
/**
22-
* @fileoverview Checkbox field. Checked or not checked.
23-
* @author [email protected] (Neil Fraser)
22+
* @fileoverview Expandable Remove field.
23+
* @author SharkPool & JeremyGamer13
2424
*/
2525
'use strict';
2626

2727
goog.provide('Blockly.FieldExpandableRemove');
2828

2929
goog.require('Blockly.Field');
3030

31+
/**
32+
* Icon used by Button
33+
*/
34+
const removeIcon = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMiIgaGVpZ2h0PSI0Ljg4IiB2aWV3Qm94PSIwIDAgMTIgNC44OCI+PGcgc3Ryb2tlLXdpZHRoPSIwIiBzdHJva2UtbWl0ZXJsaW1pdD0iMTAiPjxwYXRoIGQ9Ik0xLjkwMyA0Ljg4Qy44NTEgNC44OCAwIDMuOTc2IDAgMi44NTl2LS44MzdDMCAuOTA1Ljg1MiAwIDEuOTAzIDBoOC4xOTNjMS4wNTIgMCAxLjkwMy45MDQgMS45MDMgMi4wMjF2LjgzN2MwIDEuMTE2LS44NTIgMi4wMjEtMS45MDMgMi4wMjF6IiBmaWxsLW9wYWNpdHk9Ii4xMDIiIGZpbGw9IiMyNDIwMjEiLz48cGF0aCBkPSJNMi4yMjggNC4wMzhBMS40MjcgMS40MjcgMCAwIDEgLjgwMSAyLjYxMVYyLjI3QTEuNDI3IDEuNDI3IDAgMCAxIDIuMjI4Ljg0M2g3LjU0NGExLjQyNyAxLjQyNyAwIDAgMSAxLjQyNyAxLjQyN3YuMzQxYTEuNDI3IDEuNDI3IDAgMCAxLTEuNDI3IDEuNDI3eiIgZmlsbD0iI2ZmZiIvPjwvZz48L3N2Zz4=';
3135

3236
/**
3337
* Class for a button field.
@@ -59,15 +63,16 @@ Blockly.FieldExpandableRemove.fromJson = function(options) {
5963
Blockly.FieldExpandableRemove.prototype.CURSOR = 'pointer';
6064

6165
/**
62-
* Install this checkbox on a block.
66+
* Install this button on a block.
6367
*/
6468
Blockly.FieldExpandableRemove.prototype.init = function() {
6569
if (this.fieldGroup_) {
66-
// Checkbox has already been initialized once.
70+
// Button has already been initialized once.
6771
return;
6872
}
6973
Blockly.FieldExpandableRemove.superClass_.init.call(this);
7074

75+
this.boxGroup_ = Blockly.utils.createSvgElement('g', {}, null);
7176
this.box_ = Blockly.utils.createSvgElement('rect',
7277
{
7378
'x': 0,
@@ -76,18 +81,26 @@ Blockly.FieldExpandableRemove.prototype.init = function() {
7681
'ry': 4,
7782
'width': this.size_.width,
7883
'height': this.size_.height,
79-
'fill': "#ff0000",
80-
'stroke': "rgba(0, 0, 0, 0.25)",
84+
'fill': "#00000000",
85+
'stroke': "#00000035",
8186
'cursor': this.CURSOR
82-
}
87+
},
88+
this.boxGroup_
8389
);
84-
this.fieldGroup_.insertBefore(this.box_, this.textElement_);
85-
// var textNode = document.createTextNode(this.label_);
86-
// textNode.style.fill = "#ffffff";
87-
// this.textElement_.append(textNode);
88-
// this.fieldGroup_.append(this.textElement_);
90+
this.icon_ = Blockly.utils.createSvgElement('image',
91+
{
92+
'x': 2.5,
93+
'y': 5,
94+
'width': this.size_.height / 1.5,
95+
'height': this.size_.height / 1.5,
96+
'href': removeIcon,
97+
},
98+
this.boxGroup_
99+
);
100+
this.fieldGroup_.insertBefore(this.boxGroup_, this.textElement_);
89101
};
90102

103+
91104
/**
92105
* Returns an empty string.
93106
* @return {string}
@@ -106,4 +119,4 @@ Blockly.FieldExpandableRemove.prototype.showEditor_ = function() {
106119
this.sourceBlock_.onExpandableButtonClicked_(false);
107120
};
108121

109-
Blockly.Field.register('field_expandable_remove', Blockly.FieldExpandableRemove);
122+
Blockly.Field.register('field_expandable_remove', Blockly.FieldExpandableRemove);

0 commit comments

Comments
 (0)