-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
47e88f5
commit 62eb69c
Showing
3 changed files
with
156 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { domReady } from '../../utils'; | ||
import './style.scss'; | ||
|
||
domReady( () => { | ||
const container = document.querySelector( '.corrections-metabox-container' ); | ||
if ( ! container ) { | ||
return; | ||
} | ||
|
||
// Click handler for Add Correction button. | ||
container.querySelector( 'button.add-correction' ).addEventListener( 'click', () => { | ||
const existingCorrections = container.querySelector( '.existing-corrections' ); | ||
const newCorrection = document.createElement( 'div' ); | ||
newCorrection.classList.add( 'reveal-correction' ); | ||
newCorrection.innerHTML = ` | ||
<p>${ __( 'Article Correction', 'newspack-plugin' ) }</p> | ||
<textarea name="reveal_correction[]" rows="3" cols="60"></textarea> | ||
<br/> | ||
<p>${ __( 'Date:', 'newspack-plugin' ) } <input type="date" name="reveal_correction_date[]"></p> | ||
<span class="delete-correction">X</span> | ||
`; | ||
existingCorrections.appendChild( newCorrection ); | ||
newCorrection.querySelector( 'span.delete-correction' ).addEventListener( 'click', () => { | ||
newCorrection.remove(); | ||
} ); | ||
} ); | ||
} ); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
.activate-corrections { | ||
padding-top: 1em; | ||
padding-bottom: 1em; | ||
border-bottom: 2px solid silver; | ||
margin-bottom: 1em; | ||
} | ||
|
||
.reveal-correction { | ||
position: relative; | ||
border-bottom: 1px solid silver; | ||
padding-top: 1em; | ||
padding-bottom: 1em; | ||
} | ||
|
||
.delete-correction { | ||
position: absolute; | ||
top: 2em; | ||
right: 2em; | ||
font-weight: bold; | ||
color: silver; | ||
border: 1px solid silver; | ||
padding-left: 0.25em; | ||
padding-right: 0.25em; | ||
cursor: pointer; | ||
} | ||
|
||
.delete-correction:hover { | ||
color: red; | ||
} | ||
|
||
.add-correction { | ||
margin-top: 2em; | ||
cursor: pointer; | ||
} |