Get maximize buttons working correctly
This commit is contained in:
parent
6f649d1790
commit
cc70e14437
|
@ -81,7 +81,7 @@
|
||||||
<label>Definition<span class="red">*</span><br>
|
<label>Definition<span class="red">*</span><br>
|
||||||
<input id="wordDefinition" placeholder="Equivalent words">
|
<input id="wordDefinition" placeholder="Equivalent words">
|
||||||
</label>
|
</label>
|
||||||
<label>Details<span class="red">*</span><a class="label-button">Maximize</a><br>
|
<label>Details<span class="red">*</span><a class="label-button maximize-button">Maximize</a><br>
|
||||||
<textarea id="wordDetails" placeholder="Markdown formatting allowed"></textarea>
|
<textarea id="wordDetails" placeholder="Markdown formatting allowed"></textarea>
|
||||||
</label>
|
</label>
|
||||||
<div id="wordErrorMessage"></div>
|
<div id="wordErrorMessage"></div>
|
||||||
|
@ -149,7 +149,7 @@
|
||||||
<label>Specification<br>
|
<label>Specification<br>
|
||||||
<input id="editSpecification">
|
<input id="editSpecification">
|
||||||
</label>
|
</label>
|
||||||
<label>Description<a class="label-button">Maximize</a><br>
|
<label>Description<a class="label-button maximize-button">Maximize</a><br>
|
||||||
<textarea id="editDescription"></textarea>
|
<textarea id="editDescription"></textarea>
|
||||||
</label>
|
</label>
|
||||||
</section>
|
</section>
|
||||||
|
@ -201,11 +201,11 @@
|
||||||
<textarea id="editExceptions"></textarea>
|
<textarea id="editExceptions"></textarea>
|
||||||
</label>
|
</label>
|
||||||
<h3>Orthography</h3>
|
<h3>Orthography</h3>
|
||||||
<label>Notes<a class="label-button">Maximize</a><br>
|
<label>Notes<a class="label-button maximize-button">Maximize</a><br>
|
||||||
<textarea id="editOrthography"></textarea>
|
<textarea id="editOrthography"></textarea>
|
||||||
</label>
|
</label>
|
||||||
<h3>Grammar</h3>
|
<h3>Grammar</h3>
|
||||||
<label>Notes<a class="label-button">Maximize</a><br>
|
<label>Notes<a class="label-button maximize-button">Maximize</a><br>
|
||||||
<textarea id="editGrammar"></textarea>
|
<textarea id="editGrammar"></textarea>
|
||||||
</label>
|
</label>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { removeTags, slugify } from '../helpers';
|
||||||
import { getWordsStats, wordExists } from './utilities';
|
import { getWordsStats, wordExists } from './utilities';
|
||||||
import { getMatchingSearchWords, highlightSearchTerm, getSearchFilters, getSearchTerm } from './search';
|
import { getMatchingSearchWords, highlightSearchTerm, getSearchFilters, getSearchTerm } from './search';
|
||||||
import { showSection } from './displayToggles';
|
import { showSection } from './displayToggles';
|
||||||
import { setupSearchFilters, setupWordOptionButtons, setupPagination, setupWordOptionSelections, setupWordEditFormButtons } from './setupListeners';
|
import { setupSearchFilters, setupWordOptionButtons, setupPagination, setupWordOptionSelections, setupWordEditFormButtons, setupMaximizeModal } from './setupListeners';
|
||||||
import { getPaginationData } from './pagination';
|
import { getPaginationData } from './pagination';
|
||||||
import { getOpenEditForms } from './wordManagement';
|
import { getOpenEditForms } from './wordManagement';
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ export function renderEditForm(wordId = false) {
|
||||||
<label>Definition<span class="red">*</span><br>
|
<label>Definition<span class="red">*</span><br>
|
||||||
<input id="wordDefinition_${wordId}" value="${word.simpleDefinition}" placeholder="Equivalent words">
|
<input id="wordDefinition_${wordId}" value="${word.simpleDefinition}" placeholder="Equivalent words">
|
||||||
</label>
|
</label>
|
||||||
<label>Details<span class="red">*</span><a class="label-button">Maximize</a><br>
|
<label>Details<span class="red">*</span><a class="label-button maximize-button">Maximize</a><br>
|
||||||
<textarea id="wordDetails_${wordId}" placeholder="Markdown formatting allowed">${word.longDefinition}</textarea>
|
<textarea id="wordDetails_${wordId}" placeholder="Markdown formatting allowed">${word.longDefinition}</textarea>
|
||||||
</label>
|
</label>
|
||||||
<div id="wordErrorMessage_${wordId}"></div>
|
<div id="wordErrorMessage_${wordId}"></div>
|
||||||
|
@ -237,3 +237,25 @@ export function renderEditForm(wordId = false) {
|
||||||
setupWordEditFormButtons();
|
setupWordEditFormButtons();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function renderMaximizedTextbox(maximizeButton) {
|
||||||
|
maximizeButton = typeof maximizeButton.target === 'undefined' ? maximizeButton : maximizeButton.target;
|
||||||
|
const label = maximizeButton.parentElement.innerText.replace(/(\*|Maximize)/g, '').trim();
|
||||||
|
const textBox = maximizeButton.parentElement.querySelector('textarea');
|
||||||
|
const modalElement = document.createElement('section');
|
||||||
|
modalElement.classList.add('modal');
|
||||||
|
modalElement.innerHTML = `<section class="modal maximize-modal"><div class="modal-background"></div>
|
||||||
|
<div class="modal-content">
|
||||||
|
<a class="close-button">×︎</a>
|
||||||
|
<header><h3>${label}</h3></header>
|
||||||
|
<section>
|
||||||
|
<textarea>${textBox.value}</textarea>
|
||||||
|
</section>
|
||||||
|
<footer><a class="button done-button">Done</a></footer>
|
||||||
|
</div>
|
||||||
|
</section>`;
|
||||||
|
|
||||||
|
document.body.appendChild(modalElement);
|
||||||
|
|
||||||
|
setupMaximizeModal(modalElement, textBox);
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import {showSection} from './displayToggles';
|
import {showSection} from './displayToggles';
|
||||||
import { renderWords, renderEditForm } from './render';
|
import { renderWords, renderEditForm, renderMaximizedTextbox } from './render';
|
||||||
import { validateWord, addWord, confirmEditWord, cancelEditWord } from './wordManagement';
|
import { validateWord, addWord, confirmEditWord, cancelEditWord } from './wordManagement';
|
||||||
import { removeTags } from '../helpers';
|
import { removeTags } from '../helpers';
|
||||||
import { getNextId } from './utilities';
|
import { getNextId } from './utilities';
|
||||||
|
@ -73,6 +73,8 @@ function setupEditFormInteractions() {
|
||||||
function setupEditFormButtons() {
|
function setupEditFormButtons() {
|
||||||
document.getElementById('editSave').addEventListener('click', () => save());
|
document.getElementById('editSave').addEventListener('click', () => save());
|
||||||
document.getElementById('editSaveAndClose').addEventListener('click', () => saveAndClose());
|
document.getElementById('editSaveAndClose').addEventListener('click', () => saveAndClose());
|
||||||
|
|
||||||
|
setupMaximizeButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupSearchBar() {
|
function setupSearchBar() {
|
||||||
|
@ -144,6 +146,8 @@ function setupWordForm() {
|
||||||
addWord(word);
|
addWord(word);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setupMaximizeButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setupWordOptionButtons() {
|
export function setupWordOptionButtons() {
|
||||||
|
@ -197,6 +201,8 @@ export function setupWordEditFormButtons() {
|
||||||
button.removeEventListener('click', cancelEditWord);
|
button.removeEventListener('click', cancelEditWord);
|
||||||
button.addEventListener('click', cancelEditWord);
|
button.addEventListener('click', cancelEditWord);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setupMaximizeButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setupPagination() {
|
export function setupPagination() {
|
||||||
|
@ -218,3 +224,29 @@ export function setupPagination() {
|
||||||
pageSelector.addEventListener('change', goToPage);
|
pageSelector.addEventListener('change', goToPage);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setupMaximizeButtons() {
|
||||||
|
const maximizeButtons = document.getElementsByClassName('maximize-button');
|
||||||
|
Array.from(maximizeButtons).forEach(button => {
|
||||||
|
button.removeEventListener('click', renderMaximizedTextbox);
|
||||||
|
button.addEventListener('click', renderMaximizedTextbox);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setupMaximizeModal(modal, textBox) {
|
||||||
|
const closeElements = modal.querySelectorAll('.modal-background, .close-button, .done-button'),
|
||||||
|
maximizedTextBox = modal.querySelector('textarea');
|
||||||
|
Array.from(closeElements).forEach(close => {
|
||||||
|
close.addEventListener('click', () => {
|
||||||
|
modal.parentElement.removeChild(modal);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
maximizedTextBox.addEventListener('change', () => {
|
||||||
|
textBox.value = maximizedTextBox.value;
|
||||||
|
})
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
modal.querySelector('textarea').focus();
|
||||||
|
}, 1);
|
||||||
|
}
|
||||||
|
|
|
@ -27,9 +27,14 @@ label {
|
||||||
}
|
}
|
||||||
|
|
||||||
.label-button {
|
.label-button {
|
||||||
|
@extend .button;
|
||||||
|
|
||||||
font-size: 80%;
|
font-size: 80%;
|
||||||
|
font-weight: normal;
|
||||||
float: right;
|
float: right;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
line-height: 80% !important;
|
||||||
|
padding: 3px 3px 5px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -205,6 +205,16 @@
|
||||||
}
|
}
|
||||||
#editDescription {
|
#editDescription {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 350px;
|
height: 280px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.maximize-modal {
|
||||||
|
textarea {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 100%;
|
||||||
|
min-height: 400px;
|
||||||
|
border: none;
|
||||||
|
padding: $general-padding;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue