Commit c4fa6c2a authored by Eric Windham's avatar Eric Windham

made some changes to the way the block works

parent e978a191
......@@ -5,3 +5,9 @@
position: absolute;
top: 0; right: 0; bottom: 0; left: 0;
}
.nf-block-form-selector {
background-color: lightgrey;
border-bottom: 1px solid;
margin-bottom: 5px;
padding: 4px;
}
\ No newline at end of file
......@@ -31,7 +31,9 @@
var formID = props.attributes.formID;
if( ! formID ) formID = 1; // Default.
var children = [];
if( ! formID ) formID = ''; // Default.
function onFormChange( newFormID ) {
// updates the form id on the props
......@@ -43,17 +45,29 @@
el( SelectControl, { label: 'Form ID', value: formID, options: ninjaFormsBlock.forms, onChange: onFormChange } )
);
/**
* Create the div container, add an overlay so the user can interact
* with the form in Gutenberg, then render the iframe with form
*/
if( '' === formID ) {
children.push( el( 'div', {style : {width: '100%'}}, el( 'img',
{ src: ninjaFormsBlock.block_logo}),
el( SelectControl, { value: formID, options: ninjaFormsBlock.forms, onChange: onFormChange })
) );
} else {
children.push(
el( 'div', { className: 'nf-iframe-container' },
el( 'div', { className: 'nf-iframe-overlay' } ),
el( 'iframe', { src: ninjaFormsBlock.siteUrl + '?nf_preview_form='
+ formID + '&nf_iframe', height: '0', width: '500', scrolling: 'no' })
)
)
}
return [
el( 'div', { className: 'nf-iframe-container' },
el( 'div', { className: 'nf-iframe-overlay' } ),
el( 'iframe', { src: ninjaFormsBlock.siteUrl + '?nf_preview_form='
+ formID + '&nf_iframe', height: '0', width: '500', scrolling: 'no' })
),
!! focus && inspectorControls
children,
// inspectorControls
!! focus && inspectorControls
];
},
......@@ -65,8 +79,11 @@
/**
* we're essentially just adding a short code, here is where
* it's save in the editor
*
* Returning raw HTML is deprecated and recommended to use the
* RawHTML component now
*/
return '[ninja_forms id="' + formID + '"]';
return el( 'RawHTML', { content: '[ninja_forms id=\"' + formID + '\"]' });
}
} );
......
......@@ -11,7 +11,7 @@ class NF_FormBlock {
// load the preview information and form
add_action( 'wp_head', array( $this, 'load_preview_data' ) );
// load the iframe containing the iframe
add_action( 'init', array( $this, 'load_preview_iframe' ) );
// add_action( 'init', array( $this, 'load_preview_iframe' ) );
}
function nf_form_block_load() {
......@@ -49,7 +49,10 @@ class NF_FormBlock {
wp_enqueue_script( 'ninja-forms-block' );
$forms = array();
$forms[] = array (
'value' => '',
'label' => '-- Select a Form --',
);
foreach( Ninja_Forms()->form()->get_forms() as $form ){
$forms[] = array (
'value' => $form->get_id(),
......@@ -57,9 +60,14 @@ class NF_FormBlock {
);
}
$block_logo = NF_PLUGIN_URL . 'assets/img/nf-logo-dashboard.png';
+ $thumbnail_logo = NF_PLUGIN_URL . 'assets/img/ninja-forms-app-header-logo.png';
wp_localize_script( 'ninja-forms-block', 'ninjaFormsBlock', array(
'forms' => $forms,
'siteUrl' => get_site_url()
'siteUrl' => get_site_url(),
'block_logo' => $block_logo,
'thumbnail_logo' => $thumbnail_logo
) );
wp_enqueue_style( 'ninja-forms-block-style' );
wp_enqueue_style( 'ninja-forms-block-editor' );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment