normalisation blog + gestion images
This commit is contained in:
@@ -2,6 +2,7 @@ const form = document.getElementById("ajouterArticleForm");
|
||||
const messages = document.getElementById("messages");
|
||||
|
||||
const imgField = document.getElementById("articleImage");
|
||||
const imgPreview = document.getElementById("imagePreview");
|
||||
const titleField = document.getElementById("articleTitle");
|
||||
const categoryField = document.getElementById("articleCategory");
|
||||
const publishedField = document.getElementById("articlePublished");
|
||||
@@ -26,6 +27,9 @@ function imageValide(file) {
|
||||
return ["image/jpeg", "image/png"].includes(file.type);
|
||||
}
|
||||
|
||||
// Preview image on selection via generic loader (global)
|
||||
const imgLoader = window.initImagePreview && window.initImagePreview("articleImage", "articleImagePreview", ["image/jpeg", "image/png"]);
|
||||
|
||||
|
||||
form.addEventListener("submit", function (e) {
|
||||
e.preventDefault();
|
||||
@@ -91,6 +95,9 @@ form.addEventListener("submit", function (e) {
|
||||
// Reset
|
||||
form.reset();
|
||||
tinymce.get("articleContent").setContent("");
|
||||
if (imgLoader && typeof imgLoader.reset === "function") {
|
||||
imgLoader.reset();
|
||||
}
|
||||
|
||||
// Redirection
|
||||
setTimeout(() => {
|
||||
@@ -98,13 +105,4 @@ form.addEventListener("submit", function (e) {
|
||||
}, 1500);
|
||||
});
|
||||
|
||||
/* =========================
|
||||
TinyMCE
|
||||
========================= */
|
||||
tinymce.init({
|
||||
selector: "#articleContent",
|
||||
height: 400,
|
||||
language: "fr",
|
||||
plugins: "lists fullscreen",
|
||||
toolbar: "undo redo | bold italic underline | bullist numlist | fullscreen"
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user