document.getElementById("ctdl-compose-cc-field").style.display = "block";
}
- activate_uploads();
+ activate_uploads("ctdl-editor-body");
}
-function activate_uploads() {
- document.getElementById("ctdl-upload").innerHTML = `
- <div id="ctdl_attachments_outer">
+// Turn the specified div into a place where we can upload. (Note: permanently changes the drag-and-drop behavior of that div.)
+function activate_uploads(parent_div) {
+ document.getElementById(parent_div).innerHTML += `
+ <div class="ctdl-upload" id="ctdl-upload">
<div id="ctdl_attachments_title" class="ctdl-compose-attachments-title">
<div><h1><i class="fa fa-paperclip" style="color:grey"></i>` + _("Attachments:") + " " + num_attachments + `</h1></div>
<div><h1><i class="fas fa-window-close" style="color:red" onClick="show_or_hide_attachments()"></i></h1></div>
<div id="drop-area" class="ctdl-upload-drop-area">
<form class="my-form">
<p>${_("Drop files here to upload")}</p>
- <input type="file" id="fileElem" multiple acce=t="*/*" onChange="handleFiles(this.files)">
- <label class="button" for="fileElem">Select some files</label>
+ <input type="file" id="fileElem" multiple accept="*/*" onChange="handleFiles(this.files)">
</form>
</div>
</div>
`;
// activate drag and drop (shamelessly swiped from https://www.smashingmagazine.com/2018/01/drag-drop-file-uploader-vanilla-js/ )
- let dropArea = document.getElementById("drop-area");
+ //let dropArea = document.getElementById("ctdl-upload");
+ let dropArea = document.getElementById(parent_div);
;['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
dropArea.addEventListener(eventName, preventDefaults, false)
})
dropArea.addEventListener('drop', handleDrop, false);
// make the modal smaller than the containing window but pretty big
- document.getElementById("ctdl_attachments_outer").style.width =
- Math.trunc((document.getElementById("ctdl-editor-body").getBoundingClientRect().width) * 0.60).toString() + "px";
- document.getElementById("ctdl_attachments_outer").style.height =
- Math.trunc((document.getElementById("ctdl-editor-body").getBoundingClientRect().height) * 0.60).toString() + "px";
+ //document.getElementById("ctdl-upload").style.width =
+ //Math.trunc((document.getElementById("ctdl-editor-body").getBoundingClientRect().width) * 0.90).toString() + "px";
+ //document.getElementById("ctdl-upload").style.height =
+ //Math.trunc((document.getElementById("ctdl-editor-body").getBoundingClientRect().height) * 0.90).toString() + "px";
}
function highlight(e) {
- let dropArea = document.getElementById("drop-area");
+ let dropArea = document.getElementById("ctdl-upload");
dropArea.classList.add('highlight')
+
+ document.getElementById("ctdl-upload").style.display = "block"; /* also make it appear */
}
function unhighlight(e) {
- let dropArea = document.getElementById("drop-area");
+ let dropArea = document.getElementById("ctdl-upload");
dropArea.classList.remove('highlight')
}
function show_or_hide_attachments() {
if (document.getElementById("ctdl-upload").style.display == "block") {
- document.getElementById("ctdl-upload").style.display = "none";
+ document.getElementById("ctdl-upload").style.display = "none"; /* turn it off */
}
else {
- document.getElementById("ctdl-upload").style.display = "block";
+ document.getElementById("ctdl-upload").style.display = "block"; /* turn it on */
}
}