mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
Merge pull request #281 from philomena-dev/ts-misc
Convert miscellaneous scripts to TypeScript
This commit is contained in:
commit
dfbe3dbc84
6 changed files with 12 additions and 15 deletions
|
@ -4,11 +4,11 @@
|
|||
* Warn users that their PM will be reviewed.
|
||||
*/
|
||||
|
||||
import { $ } from './utils/dom';
|
||||
import { $, hideEl, showEl } from './utils/dom';
|
||||
|
||||
function warnAboutPMs() {
|
||||
const textarea = $('.js-toolbar-input');
|
||||
const warning = $('.js-hidden-warning');
|
||||
export function warnAboutPMs() {
|
||||
const textarea = $<HTMLTextAreaElement>('.js-toolbar-input');
|
||||
const warning = $<HTMLDivElement>('.js-hidden-warning');
|
||||
const imageEmbedRegex = /!+\[/g;
|
||||
|
||||
if (!warning || !textarea) return;
|
||||
|
@ -17,12 +17,10 @@ function warnAboutPMs() {
|
|||
const value = textarea.value;
|
||||
|
||||
if (value.match(imageEmbedRegex)) {
|
||||
warning.classList.remove('hidden');
|
||||
showEl(warning);
|
||||
}
|
||||
else if (!warning.classList.contains('hidden')) {
|
||||
warning.classList.add('hidden');
|
||||
hideEl(warning);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export { warnAboutPMs };
|
|
@ -1,6 +1,6 @@
|
|||
import { inputDuplicatorCreator } from './input-duplicator';
|
||||
|
||||
function pollOptionCreator() {
|
||||
export function pollOptionCreator() {
|
||||
inputDuplicatorCreator({
|
||||
addButtonSelector: '.js-poll-add-option',
|
||||
fieldSelector: '.js-poll-option',
|
||||
|
@ -8,5 +8,3 @@ function pollOptionCreator() {
|
|||
removeButtonSelector: '.js-option-remove',
|
||||
});
|
||||
}
|
||||
|
||||
export { pollOptionCreator };
|
|
@ -2,6 +2,7 @@
|
|||
* Settings.
|
||||
*/
|
||||
|
||||
import { assertNotNull, assertNotUndefined } from './utils/assert';
|
||||
import { $, $$ } from './utils/dom';
|
||||
import store from './utils/store';
|
||||
|
||||
|
@ -9,9 +10,9 @@ export function setupSettings() {
|
|||
|
||||
if (!$('#js-setting-table')) return;
|
||||
|
||||
const localCheckboxes = $$('[data-tab="local"] input[type="checkbox"]');
|
||||
const themeSelect = $('#user_theme');
|
||||
const styleSheet = $('head link[rel="stylesheet"]');
|
||||
const localCheckboxes = $$<HTMLInputElement>('[data-tab="local"] input[type="checkbox"]');
|
||||
const themeSelect = assertNotNull($<HTMLSelectElement>('#user_theme'));
|
||||
const styleSheet = assertNotNull($<HTMLLinkElement>('head link[rel="stylesheet"]'));
|
||||
|
||||
// Local settings
|
||||
localCheckboxes.forEach(checkbox => {
|
||||
|
@ -22,7 +23,7 @@ export function setupSettings() {
|
|||
|
||||
// Theme preview
|
||||
themeSelect && themeSelect.addEventListener('change', () => {
|
||||
styleSheet.href = themeSelect.options[themeSelect.selectedIndex].dataset.themePath;
|
||||
styleSheet.href = assertNotUndefined(themeSelect.options[themeSelect.selectedIndex].dataset.themePath);
|
||||
});
|
||||
|
||||
}
|
Loading…
Reference in a new issue