@@ -6,7 +6,6 @@ const COLOUR_GET = '#439970'; // [67, 153, 112]
66const COLOUR_SET = '#266643' ; // [38, 102, 67]
77
88var ComponentName = "Component1" ;
9- var ComponentDropDown = null ;
109
1110var TEXT_WHEN = 'when' ;
1211var TEXT_DO = 'do' ;
@@ -22,7 +21,6 @@ require(['gitbook', 'jQuery'], function(gitbook, $) {
2221 TEXT_CALL = conf [ 'ai2-blocks' ] [ 'text_call' ] || TEXT_CALL ;
2322 TEXT_SET = conf [ 'ai2-blocks' ] [ 'text_set' ] || TEXT_SET ;
2423
25- ComponentDropDown = new Blockly . FieldDropdown ( [ [ ComponentName , 'OPTIONNAME' ] ] ) ;
2624 // METHOD
2725 $ ( 'div[ai2-method]' ) . each ( function ( ) {
2826 var block = getBlock ( decodeURI ( $ ( this ) . attr ( "value" ) ) ) ;
@@ -35,7 +33,7 @@ require(['gitbook', 'jQuery'], function(gitbook, $) {
3533
3634 Blockly . Blocks [ 'dynamicCreated_' + divId ] = {
3735 init : function ( ) {
38- this . appendDummyInput ( ) . appendField ( TEXT_CALL ) . appendField ( ComponentDropDown , 'COMPONENT_SELECTOR' ) . appendField ( '.' + name ) ;
36+ this . appendDummyInput ( ) . appendField ( TEXT_CALL ) . appendField ( new Blockly . FieldDropdown ( [ [ ComponentName , 'OPTIONNAME' ] ] ) , 'COMPONENT_SELECTOR' ) . appendField ( '.' + name ) ;
3937 for ( var i = 0 ; i < arg . length ; i ++ ) {
4038 this . appendValueInput ( 'NAME' ) . setAlign ( Blockly . ALIGN_RIGHT ) . appendField ( arg [ i ] ) ;
4139 }
@@ -63,7 +61,7 @@ require(['gitbook', 'jQuery'], function(gitbook, $) {
6361
6462 Blockly . Blocks [ 'dynamicCreated_' + divId ] = {
6563 init : function ( ) {
66- this . appendDummyInput ( '' ) . appendField ( TEXT_WHEN ) . appendField ( ComponentDropDown , "COMPONENT_SELECTOR" ) . appendField ( '.' + name ) ;
64+ this . appendDummyInput ( '' ) . appendField ( TEXT_WHEN ) . appendField ( new Blockly . FieldDropdown ( [ [ ComponentName , 'OPTIONNAME' ] ] ) , "COMPONENT_SELECTOR" ) . appendField ( '.' + name ) ;
6765 if ( arg . length > 0 ) {
6866 var paramInput = this . appendDummyInput ( 'PARAMETERS' ) . appendField ( " " ) . setAlign ( Blockly . ALIGN_LEFT ) ;
6967 for ( var i = 0 ; i < arg . length ; i ++ ) {
@@ -107,7 +105,7 @@ require(['gitbook', 'jQuery'], function(gitbook, $) {
107105 this . setPreviousStatement ( true , null ) ;
108106 this . setNextStatement ( true , null ) ;
109107 }
110- input . appendField ( ComponentDropDown , "NAME" )
108+ input . appendField ( new Blockly . FieldDropdown ( [ [ ComponentName , 'OPTIONNAME' ] ] ) , "NAME" )
111109 . appendField ( "." )
112110 . appendField ( new Blockly . FieldDropdown ( [ [ name , "OPTIONNAME" ] ] ) , "NAME2" ) ;
113111 this . setColour ( getter ? COLOUR_GET : COLOUR_SET ) ;
@@ -134,7 +132,6 @@ function getBlock(json) {
134132 }
135133 if ( typeof ( blockData [ 'componentName' ] ) != "undefined" && blockData [ 'componentName' ] . length > 0 ) {
136134 ComponentName = blockData . componentName ;
137- ComponentDropDown = new Blockly . FieldDropdown ( [ [ ComponentName , 'OPTIONNAME' ] ] ) ;
138135 }
139136 return blockData ;
140137}
0 commit comments