2024-01-25 17:37:49 +07:00
|
|
|
<script src="https://cdn.tiny.cloud/1/no-api-key/tinymce/5/tinymce.min.js" referrerpolicy="origin"></script>
|
2025-02-11 16:22:18 +07:00
|
|
|
<script src="{{ 'RowExpand.js' | asset_url }}"></script>
|
2024-01-25 17:37:49 +07:00
|
|
|
|
2025-12-02 17:01:37 +07:00
|
|
|
<link href="https://unpkg.com/filepond/dist/filepond.min.css" rel="stylesheet" />
|
|
|
|
|
<link href="https://unpkg.com/filepond-plugin-image-preview/dist/filepond-plugin-image-preview.min.css"
|
|
|
|
|
rel="stylesheet" />
|
|
|
|
|
|
|
|
|
|
<script src="https://unpkg.com/filepond-plugin-image-preview/dist/filepond-plugin-image-preview.min.js"></script>
|
|
|
|
|
<script src="https://unpkg.com/filepond/dist/filepond.min.js"></script>
|
|
|
|
|
|
2024-01-25 17:37:49 +07:00
|
|
|
|
|
|
|
|
<script>
|
2025-12-02 17:01:37 +07:00
|
|
|
// Quan trọng: đăng ký plugin
|
|
|
|
|
FilePond.registerPlugin(FilePondPluginImagePreview);
|
|
|
|
|
|
|
|
|
|
function initCustomFilePond(buttonSelector, previewSelector, inputSelector, options = {}) {
|
|
|
|
|
const button = document.querySelector(buttonSelector);
|
|
|
|
|
const preview = document.querySelector(previewSelector);
|
|
|
|
|
const input = document.querySelector(inputSelector);
|
|
|
|
|
|
|
|
|
|
// Ẩn ban đầu nhưng không dùng display:none
|
|
|
|
|
preview.style.opacity = "0";
|
|
|
|
|
preview.style.transition = "0.2s";
|
|
|
|
|
|
|
|
|
|
// Tạo FilePond instance
|
|
|
|
|
const pond = FilePond.create(input, {
|
|
|
|
|
allowMultiple: true,
|
|
|
|
|
allowImagePreview: true,
|
|
|
|
|
instantUpload: true,
|
|
|
|
|
credits: false,
|
|
|
|
|
labelIdle: "",
|
|
|
|
|
...options
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Đưa UI FilePond vào container preview
|
|
|
|
|
preview.appendChild(pond.element);
|
|
|
|
|
|
|
|
|
|
// Nút bấm → mở chọn file
|
|
|
|
|
button.addEventListener("click", () => input.click());
|
|
|
|
|
|
|
|
|
|
// Khi thêm file → show preview
|
|
|
|
|
pond.on("addfile", () => {
|
|
|
|
|
preview.style.opacity = "1";
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Khi xoá hết file → ẩn
|
|
|
|
|
pond.on("removefile", () => {
|
|
|
|
|
if (pond.getFiles().length === 0) {
|
|
|
|
|
preview.style.opacity = "0";
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return pond;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Gọi function
|
|
|
|
|
initCustomFilePond(
|
|
|
|
|
"#btnUploadImg",
|
|
|
|
|
"#image-preview-filepond",
|
|
|
|
|
"#hidden-filepond-input"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
2024-01-25 17:37:49 +07:00
|
|
|
|
|
|
|
|
tinymce.init({
|
|
|
|
|
selector: 'textarea#product-desc',
|
|
|
|
|
height: 350,
|
|
|
|
|
menubar: true,
|
|
|
|
|
plugins: [
|
|
|
|
|
'advlist autolink lists link image charmap print preview anchor',
|
|
|
|
|
'searchreplace visualblocks code fullscreen',
|
|
|
|
|
'insertdatetime media table paste code help wordcount'
|
|
|
|
|
],
|
|
|
|
|
toolbar: 'undo redo | formatselect | ' +
|
|
|
|
|
'bold italic backcolor | alignleft aligncenter ' +
|
|
|
|
|
'alignright alignjustify | bullist numlist outdent indent | ' +
|
|
|
|
|
'removeformat | help',
|
|
|
|
|
content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:14px }'
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
2024-02-27 13:31:27 +07:00
|
|
|
tinymce.init({
|
|
|
|
|
selector: 'textarea#product-static',
|
|
|
|
|
height: 350,
|
|
|
|
|
menubar: true,
|
|
|
|
|
plugins: [
|
|
|
|
|
'advlist autolink lists link image charmap print preview anchor',
|
|
|
|
|
'searchreplace visualblocks code fullscreen',
|
|
|
|
|
'insertdatetime media table paste code help wordcount'
|
|
|
|
|
],
|
|
|
|
|
toolbar: 'undo redo | formatselect | ' +
|
|
|
|
|
'bold italic backcolor | alignleft aligncenter ' +
|
|
|
|
|
'alignright alignjustify | bullist numlist outdent indent | ' +
|
|
|
|
|
'removeformat | help',
|
|
|
|
|
content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:14px }'
|
|
|
|
|
});
|
|
|
|
|
|
2024-01-25 17:37:49 +07:00
|
|
|
|
|
|
|
|
</script>
|