@@ -36,110 +36,110 @@ require(['gitbook', 'jQuery'], function(gitbook, $) {
3636} ) ;
3737
3838function render ( ) {
39- // METHOD
40- $ ( 'div[ai2-method]' ) . filter ( "[not-rendered]" ) . each ( function ( ) {
41- $ ( this ) . removeAttr ( "not-rendered" ) ;
42- var block = getBlock ( decodeURI ( $ ( this ) . attr ( "value" ) ) ) ;
43-
44- var name = block [ 'name' ] ;
45- var param = block [ 'param' ] || block [ 'arg' ] || [ ] ;
46- var output = block [ 'output' ] === true ;
47- var scale = block [ 'scale' ] || SCALE_LEVEL ;
48-
49- $ ( this ) . attr ( 'id' , blockId ) . show ( ) ;
50-
51- Blockly . Blocks [ 'dynamicCreated_' + blockId ] = {
52- init : function ( ) {
53- this . appendDummyInput ( ) . appendField ( TEXT_CALL ) . appendField ( new Blockly . FieldDropdown ( [ [ ComponentName , 'OPTIONNAME' ] ] ) , 'COMPONENT_SELECTOR' ) . appendField ( '.' + name ) ;
54- for ( var i = 0 ; i < param . length ; i ++ ) {
55- this . appendValueInput ( 'NAME' ) . setAlign ( Blockly . ALIGN_RIGHT ) . appendField ( param [ i ] ) ;
56- }
57- this . setInputsInline ( false ) ;
58- if ( output ) {
59- this . setOutput ( true , null ) ;
60- } else {
61- this . setPreviousStatement ( true , null ) ;
62- this . setNextStatement ( true , null ) ;
63- }
64- this . setColour ( COLOUR_METHOD ) ;
65- this . setTooltip ( '' ) ;
66- this . setHelpUrl ( '' ) ;
39+ // METHOD
40+ $ ( 'div[ai2-method]' ) . filter ( "[not-rendered]" ) . each ( function ( ) {
41+ $ ( this ) . removeAttr ( "not-rendered" ) ;
42+ var block = getBlock ( decodeURI ( $ ( this ) . attr ( "value" ) ) ) ;
43+
44+ var name = block [ 'name' ] ;
45+ var param = block [ 'param' ] || block [ 'arg' ] || [ ] ;
46+ var output = block [ 'output' ] === true ;
47+ var scale = block [ 'scale' ] || SCALE_LEVEL ;
48+
49+ $ ( this ) . attr ( 'id' , blockId ) . show ( ) ;
50+
51+ Blockly . Blocks [ 'dynamicCreated_' + blockId ] = {
52+ init : function ( ) {
53+ this . appendDummyInput ( ) . appendField ( TEXT_CALL ) . appendField ( new Blockly . FieldDropdown ( [ [ ComponentName , 'OPTIONNAME' ] ] ) , 'COMPONENT_SELECTOR' ) . appendField ( '.' + name ) ;
54+ for ( var i = 0 ; i < param . length ; i ++ ) {
55+ this . appendValueInput ( 'NAME' ) . setAlign ( Blockly . ALIGN_RIGHT ) . appendField ( param [ i ] ) ;
6756 }
68- } ;
69-
70- newBlockAndWorkspace ( blockId , scale ) ;
71- } ) ;
72-
73- // EVENT
74- $ ( 'div[ai2-event]' ) . filter ( "[not-rendered]" ) . each ( function ( ) {
75- $ ( this ) . removeAttr ( "not-rendered" ) ;
76- var block = getBlock ( decodeURI ( $ ( this ) . attr ( "value" ) ) ) ;
77-
78- var name = block [ 'name' ] ;
79- var param = block [ 'param' ] || block [ 'arg' ] || [ ] ;
80- var scale = block [ 'scale' ] || SCALE_LEVEL ;
81-
82- $ ( this ) . attr ( 'id' , blockId ) . show ( ) ;
83-
84- Blockly . Blocks [ 'dynamicCreated_' + blockId ] = {
85- init : function ( ) {
86- this . appendDummyInput ( '' ) . appendField ( TEXT_WHEN ) . appendField ( new Blockly . FieldDropdown ( [ [ ComponentName , 'OPTIONNAME' ] ] ) , "COMPONENT_SELECTOR" ) . appendField ( '.' + name ) ;
87- if ( param . length > 0 ) {
88- var paramInput = this . appendDummyInput ( 'PARAMETERS' ) . appendField ( " " ) . setAlign ( Blockly . ALIGN_LEFT ) ;
89- for ( var i = 0 ; i < param . length ; i ++ ) {
90- paramInput . appendField ( new Blockly . FieldTextInput ( param [ i ] ) , 'VAR' + i ) . appendField ( " " ) ;
91- }
92- }
93- this . appendStatementInput ( "DO" ) . appendField ( TEXT_DO ) ;
94- this . setInputsInline ( false ) ;
95- this . setPreviousStatement ( false , null ) ;
96- this . setNextStatement ( false , null ) ;
97- this . setColour ( COLOUR_EVENT ) ;
98- this . setTooltip ( '' ) ;
99- this . setHelpUrl ( '' ) ;
57+ this . setInputsInline ( false ) ;
58+ if ( output ) {
59+ this . setOutput ( true , null ) ;
60+ } else {
61+ this . setPreviousStatement ( true , null ) ;
62+ this . setNextStatement ( true , null ) ;
10063 }
101- } ;
102-
103- newBlockAndWorkspace ( blockId , scale ) ;
104- } ) ;
105-
106- // PROPERTY
107- $ ( 'div[ai2-property]' ) . filter ( "[not-rendered]" ) . each ( function ( ) {
108- $ ( this ) . removeAttr ( "not-rendered" ) ;
109- var block = getBlock ( decodeURI ( $ ( this ) . attr ( "value" ) ) ) ;
110-
111- var name = block [ 'name' ] ;
112- var getter = block [ 'getter' ] ;
113- if ( getter !== true && getter !== false ) {
114- getter = true ;
64+ this . setColour ( COLOUR_METHOD ) ;
65+ this . setTooltip ( '' ) ;
66+ this . setHelpUrl ( '' ) ;
11567 }
116- var scale = block [ 'scale' ] || SCALE_LEVEL ;
117-
118- $ ( this ) . attr ( 'id' , blockId ) . show ( ) ;
119-
120- Blockly . Blocks [ 'dynamicCreated_' + blockId ] = {
121- init : function ( ) {
122- var input ;
123- if ( getter ) {
124- input = this . appendDummyInput ( ) ;
125- this . setOutput ( true , null ) ;
126- } else {
127- input = this . appendValueInput ( "NAME" ) . appendField ( TEXT_SET ) ;
128- this . setPreviousStatement ( true , null ) ;
129- this . setNextStatement ( true , null ) ;
68+ } ;
69+
70+ newBlockAndWorkspace ( blockId , scale ) ;
71+ } ) ;
72+
73+ // EVENT
74+ $ ( 'div[ai2-event]' ) . filter ( "[not-rendered]" ) . each ( function ( ) {
75+ $ ( this ) . removeAttr ( "not-rendered" ) ;
76+ var block = getBlock ( decodeURI ( $ ( this ) . attr ( "value" ) ) ) ;
77+
78+ var name = block [ 'name' ] ;
79+ var param = block [ 'param' ] || block [ 'arg' ] || [ ] ;
80+ var scale = block [ 'scale' ] || SCALE_LEVEL ;
81+
82+ $ ( this ) . attr ( 'id' , blockId ) . show ( ) ;
83+
84+ Blockly . Blocks [ 'dynamicCreated_' + blockId ] = {
85+ init : function ( ) {
86+ this . appendDummyInput ( '' ) . appendField ( TEXT_WHEN ) . appendField ( new Blockly . FieldDropdown ( [ [ ComponentName , 'OPTIONNAME' ] ] ) , "COMPONENT_SELECTOR" ) . appendField ( '.' + name ) ;
87+ if ( param . length > 0 ) {
88+ var paramInput = this . appendDummyInput ( 'PARAMETERS' ) . appendField ( " " ) . setAlign ( Blockly . ALIGN_LEFT ) ;
89+ for ( var i = 0 ; i < param . length ; i ++ ) {
90+ paramInput . appendField ( new Blockly . FieldTextInput ( param [ i ] ) , 'VAR' + i ) . appendField ( " " ) ;
13091 }
131- input . appendField ( new Blockly . FieldDropdown ( [ [ ComponentName , 'OPTIONNAME' ] ] ) , "NAME" )
132- . appendField ( "." )
133- . appendField ( new Blockly . FieldDropdown ( [ [ name , "OPTIONNAME" ] ] ) , "NAME2" ) ;
134- this . setColour ( getter ? COLOUR_GET : COLOUR_SET ) ;
135- this . setTooltip ( '' ) ;
136- this . setHelpUrl ( '' ) ;
13792 }
138- } ;
139-
140- newBlockAndWorkspace ( blockId , scale ) ;
141- } ) ;
142- }
93+ this . appendStatementInput ( "DO" ) . appendField ( TEXT_DO ) ;
94+ this . setInputsInline ( false ) ;
95+ this . setPreviousStatement ( false , null ) ;
96+ this . setNextStatement ( false , null ) ;
97+ this . setColour ( COLOUR_EVENT ) ;
98+ this . setTooltip ( '' ) ;
99+ this . setHelpUrl ( '' ) ;
100+ }
101+ } ;
102+
103+ newBlockAndWorkspace ( blockId , scale ) ;
104+ } ) ;
105+
106+ // PROPERTY
107+ $ ( 'div[ai2-property]' ) . filter ( "[not-rendered]" ) . each ( function ( ) {
108+ $ ( this ) . removeAttr ( "not-rendered" ) ;
109+ var block = getBlock ( decodeURI ( $ ( this ) . attr ( "value" ) ) ) ;
110+
111+ var name = block [ 'name' ] ;
112+ var getter = block [ 'getter' ] ;
113+ if ( getter !== true && getter !== false ) {
114+ getter = true ;
115+ }
116+ var scale = block [ 'scale' ] || SCALE_LEVEL ;
117+
118+ $ ( this ) . attr ( 'id' , blockId ) . show ( ) ;
119+
120+ Blockly . Blocks [ 'dynamicCreated_' + blockId ] = {
121+ init : function ( ) {
122+ var input ;
123+ if ( getter ) {
124+ input = this . appendDummyInput ( ) ;
125+ this . setOutput ( true , null ) ;
126+ } else {
127+ input = this . appendValueInput ( "NAME" ) . appendField ( TEXT_SET ) ;
128+ this . setPreviousStatement ( true , null ) ;
129+ this . setNextStatement ( true , null ) ;
130+ }
131+ input . appendField ( new Blockly . FieldDropdown ( [ [ ComponentName , 'OPTIONNAME' ] ] ) , "NAME" )
132+ . appendField ( "." )
133+ . appendField ( new Blockly . FieldDropdown ( [ [ name , "OPTIONNAME" ] ] ) , "NAME2" ) ;
134+ this . setColour ( getter ? COLOUR_GET : COLOUR_SET ) ;
135+ this . setTooltip ( '' ) ;
136+ this . setHelpUrl ( '' ) ;
137+ }
138+ } ;
139+
140+ newBlockAndWorkspace ( blockId , scale ) ;
141+ } ) ;
142+ }
143143
144144/**
145145 * return a required block
0 commit comments