1919 */
2020
2121/**
22- * @fileoverview Checkbox field. Checked or not checked .
23- * @author [email protected] (Neil Fraser) 22+ * @fileoverview Expandable Add field .
23+ * @author SharkPool & JeremyGamer13
2424 */
2525'use strict' ;
2626
2727goog . provide ( 'Blockly.FieldExpandableAdd' ) ;
2828
2929goog . require ( 'Blockly.Field' ) ;
3030
31+ /**
32+ * Icon used by button
33+ */
34+ const plusIcon = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMiIgaGVpZ2h0PSIxMiIgdmlld0JveD0iMCAwIDEyIDEyIj48ZyBzdHJva2Utd2lkdGg9IjAiIHN0cm9rZS1taXRlcmxpbWl0PSIxMCI+PHBhdGggZD0iTTEuOTAzIDguNDRDLjg1MSA4LjQ0IDAgNy41MzYgMCA2LjQxOXYtLjgzN2MwLTEuMTE2Ljg1Mi0yLjAyMSAxLjkwMy0yLjAyMWgxLjY1NlYxLjkwM0MzLjU1OS44NTEgNC40NjUgMCA1LjU4MSAwaC44MzdjMS4xMTYgMCAyLjAyMS44NTIgMi4wMjEgMS45MDN2MS42NTZoMS42NTdjMS4wNTIgMCAxLjkwMy45MDYgMS45MDMgMi4wMjJ2LjgzN2MwIDEuMTE2LS44NTIgMi4wMjEtMS45MDMgMi4wMjFIOC40NDF2MS42NTdjMCAxLjA1Mi0uOTA2IDEuOTAzLTIuMDIyIDEuOTAzaC0uODM3Yy0xLjExNiAwLTIuMDIxLS44NTItMi4wMjEtMS45MDNWOC40NDF6IiBmaWxsLW9wYWNpdHk9Ii4xMDIiIGZpbGw9IiMyNDIwMjEiLz48cGF0aCBkPSJNMi4yMjggNy41OThBMS40MjcgMS40MjcgMCAwIDEgLjgwMSA2LjE3MVY1LjgzYTEuNDI3IDEuNDI3IDAgMCAxIDEuNDI3LTEuNDI3aDIuMTc0VjIuMjI4QTEuNDI3IDEuNDI3IDAgMCAxIDUuODI5LjgwMWguMzQxYTEuNDI3IDEuNDI3IDAgMCAxIDEuNDI3IDEuNDI3djIuMTc0aDIuMTc0YTEuNDI3IDEuNDI3IDAgMCAxIDEuNDI3IDEuNDI3di4zNDFhMS40MjcgMS40MjcgMCAwIDEtMS40MjcgMS40MjdINy41OTh2Mi4xNzRhMS40MjcgMS40MjcgMCAwIDEtMS40MjcgMS40MjdINS44M2ExLjQyNyAxLjQyNyAwIDAgMS0xLjQyNy0xLjQyN1Y3LjU5OHoiIGZpbGw9IiNmZmYiLz48L2c+PC9zdmc+" ;
3135
3236/**
3337 * Class for a button field.
@@ -59,15 +63,16 @@ Blockly.FieldExpandableAdd.fromJson = function(options) {
5963Blockly . FieldExpandableAdd . prototype . CURSOR = 'pointer' ;
6064
6165/**
62- * Install this checkbox on a block.
66+ * Install this button on a block.
6367 */
6468Blockly . FieldExpandableAdd . 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 . FieldExpandableAdd . 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,16 +81,23 @@ Blockly.FieldExpandableAdd.prototype.init = function() {
7681 'ry' : 4 ,
7782 'width' : this . size_ . width ,
7883 'height' : this . size_ . height ,
79- 'fill' : "#00ff00 " ,
80- 'stroke' : "rgba(0, 0, 0, 0.25) " ,
84+ 'fill' : "#00000000 " ,
85+ 'stroke' : "#00000035 " ,
8186 'cursor' : this . CURSOR
82- }
87+ } ,
88+ this . boxGroup_
89+ ) ;
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' : plusIcon ,
97+ } ,
98+ this . boxGroup_
8399 ) ;
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_);
100+ this . fieldGroup_ . insertBefore ( this . boxGroup_ , this . textElement_ ) ;
89101} ;
90102
91103/**
@@ -106,4 +118,4 @@ Blockly.FieldExpandableAdd.prototype.showEditor_ = function() {
106118 this . sourceBlock_ . onExpandableButtonClicked_ ( true ) ;
107119} ;
108120
109- Blockly . Field . register ( 'field_expandable_add' , Blockly . FieldExpandableAdd ) ;
121+ Blockly . Field . register ( 'field_expandable_add' , Blockly . FieldExpandableAdd ) ;
0 commit comments