Skip to content

Commit

Permalink
Insert tag and close modal
Browse files Browse the repository at this point in the history
  • Loading branch information
takayukister committed Aug 3, 2024
1 parent bdfa8d2 commit dd90c0e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion admin/includes/js/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 13 additions & 4 deletions admin/includes/js/src/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import './tag-generator';
import { generateTag } from './tag-generator';

document.querySelectorAll(
'#tag-generator-list button'
).forEach( button => {
button.addEventListener( 'click', event => {
const modal = document.querySelector( `#${ button.dataset.target }` );
modal?.showModal();
const dialog = document.querySelector( `#${ button.dataset.target }` );
dialog?.showModal();
} );
} );

Expand All @@ -14,11 +14,20 @@ document.querySelectorAll(
).forEach( dialog => {

dialog.querySelectorAll(
'button.close-modal'
'.close-modal'
).forEach( button => {
button.addEventListener( 'click', event => dialog.close() );
} );

dialog.querySelectorAll(
'.insert-tag'
).forEach( button => {
button.addEventListener( 'click', event => {
const tagField = dialog.querySelector( '.tag' );
dialog.close( tagField?.value );
} );
} );

dialog.addEventListener( 'close', event => {
const textarea = document.querySelector( 'textarea#wpcf7-form' );

Expand Down
3 changes: 3 additions & 0 deletions admin/includes/js/src/tag-generator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const generateTag = form => {

};

0 comments on commit dd90c0e

Please sign in to comment.