-
Notifications
You must be signed in to change notification settings - Fork 51
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 86453c4
Showing
3 changed files
with
158 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,34 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { domReady } from '../../utils'; | ||
import './style.scss'; | ||
|
||
domReady( () => { | ||
// Handle admin metabox for article corrections. | ||
const metaboxContainer = document.querySelector( '.corrections-metabox-container' ); | ||
if ( metaboxContainer ) { | ||
metaboxContainer.querySelector( 'button.add-correction' ).addEventListener( 'click', () => { | ||
const existingCorrections = metaboxContainer.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,37 @@ | ||
// Admin metabox styles | ||
.corrections-metabox-container { | ||
.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; | ||
} | ||
|
||
.add-correction { | ||
margin-top: 2em; | ||
cursor: pointer; | ||
} | ||
|
||
.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; | ||
} | ||
} |