# getresponse/trunk/assets/admin/block.js

GetResponse Forms by Optin Cat, version trunk. 141 lines.

- Page: https://pluginprobe.com/plugins/getresponse/trunk/code/assets/admin/block.js
- Raw: https://pluginprobe.com/plugins/getresponse/trunk/raw/assets/admin/block.js
- Modified: 2023-09-20T01:25:56+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/getresponse/trunk/code/assets/admin/block.js#L10-L20`.

```javascript

( function( blocks, editor, element ) {

	var el  = element.createElement
	
	var optins = fca_eoi_gutenblock_script_data.optins
	var twostep_optins = fca_eoi_gutenblock_script_data.twostep_optins

	blocks.registerBlockType( 'optin-cat/gutenblock', {
		title: 'Optin Cat Form',
		icon: 'email',
		category: 'widgets',
		keywords: ['email', 'optin', 'form' ],
		edit: function( props ) {
			return [
				el(
					wp.blockEditor.InspectorControls,
					{ 
						key: 'eoi-controls'
					},	
					el( wp.components.PanelBody, { },					
						el( wp.components.SelectControl,
							{	
								
								label: 'Select an Optin',
								value: props.attributes.post_id,
								options: optins,
								onChange: function( newValue ){ props.setAttributes({ post_id: newValue }) }
							}
						)
					),
					el( wp.components.PanelBody, { },
						el( wp.components.ButtonGroup, {},
							props.attributes.post_id == 0 ? '' : 
							el(
								wp.components.Button,
								{	
									href: fca_eoi_gutenblock_script_data.editurl + '?post=' + props.attributes.post_id + '&action=edit',
									target: '_blank',
									variant: "secondary",
									style: {
										margin: '0 6px 0 0'
									}
								},
								'Edit Optin'
							),
							el(
								wp.components.Button,
								{	
									href: fca_eoi_gutenblock_script_data.newurl,
									target: '_blank',
									variant: "primary"
									
								},
								'New Optin'
							)
						)
					)
				),
				el( wp.serverSideRender, {
					block: 'optin-cat/gutenblock',
					attributes:  props.attributes,
				})
			]
		},

		save: function( props ) {
			return null
		},
	} )

	

	blocks.registerBlockType( 'optin-cat/gutenblock-twostep', {
		title: 'Optin Cat Two-Step Optin',
		icon: 'email',
		category: 'widgets',
		keywords: ['email', 'optin', 'form' ],
		edit: function( props ) {
			return [
				el(
					wp.blockEditor.InspectorControls,
					{ 
						key: 'eoi-controls-2'
					},	
					el( wp.components.PanelBody, { },					
						el( wp.components.SelectControl,
							{	
								
								label: 'Select an Optin',
								value: props.attributes.post_id,
								options: twostep_optins,
								onChange: function( newValue ){ props.setAttributes({ post_id: newValue }) }
							}
						)
					),
					el( wp.components.PanelBody, { },
						el( wp.components.ButtonGroup, {},
							props.attributes.post_id == 0 ? '' : 
							el(
								wp.components.Button,
								{	
									href: fca_eoi_gutenblock_script_data.editurl + '?post=' + props.attributes.post_id + '&action=edit',
									target: '_blank',
									variant: "secondary",
									style: {
										margin: '0 6px 0 0'
									}
								},
								'Edit Optin'
							),
							el(
								wp.components.Button,
								{	
									href: fca_eoi_gutenblock_script_data.newurl,
									target: '_blank',
									variant: "primary"
									
								},
								'New Optin'
							)
						)
					)
				),
				el( wp.serverSideRender, {
					block: 'optin-cat/gutenblock-twostep',
					attributes:  props.attributes,
				})
			]
		},

		save: function( props ) {
			return null
		},
	} )
	
}(
	window.wp.blocks,
	window.wp.editor,
	window.wp.element
))
```
