Fixed a bug where users couldn't post non-image attachments.

Fixed a visual padding bug for .uploadItem on Nox.
#upload_files now uses .auto_hide instead of an inline style.
This commit is contained in:
Azareal 2019-04-17 13:30:02 +10:00
parent 7d14b4afbb
commit 2e2b3c6067
3 changed files with 10 additions and 3 deletions

View File

@ -939,6 +939,7 @@ function mainInit(){
}); });
} catch(e) { } catch(e) {
// TODO: Use a notice instead // TODO: Use a notice instead
console.log("e:",e);
alert(e); alert(e);
} }
} }
@ -952,11 +953,13 @@ function mainInit(){
let fileItem = document.createElement("label"); let fileItem = document.createElement("label");
console.log("fileItem",fileItem); console.log("fileItem",fileItem);
let ext = getExt(filename) let ext = getExt(filename);
// TODO: Push ImageFileExts to the client from the server in some sort of gen.js?
let isImage = ["png", "jpg", "jpeg", "svg", "bmp", "gif", "tif", "webp"].includes(ext);
fileItem.innerText = "." + ext; fileItem.innerText = "." + ext;
fileItem.className = "formbutton uploadItem"; fileItem.className = "formbutton uploadItem";
// TODO: Check if this is actually an image // TODO: Check if this is actually an image
fileItem.style.backgroundImage = "url("+e.target.result+")"; if(isImage) fileItem.style.backgroundImage = "url("+e.target.result+")";
fileDock.appendChild(fileItem); fileDock.appendChild(fileItem);
},(e,hash, filename) => { },(e,hash, filename) => {
@ -976,6 +979,7 @@ function mainInit(){
}); });
} catch(e) { } catch(e) {
// TODO: Use a notice instead // TODO: Use a notice instead
console.log("e:",e);
alert(e); alert(e);
} }
} }

View File

@ -18,7 +18,7 @@
<button form="quick_post_form" class="formbutton">{{lang "quick_topic.create_topic_button"}}</button> <button form="quick_post_form" class="formbutton">{{lang "quick_topic.create_topic_button"}}</button>
<button form="quick_post_form" class="formbutton" id="add_poll_button">{{lang "quick_topic.add_poll_button"}}</button> <button form="quick_post_form" class="formbutton" id="add_poll_button">{{lang "quick_topic.add_poll_button"}}</button>
{{if .CurrentUser.Perms.UploadFiles}} {{if .CurrentUser.Perms.UploadFiles}}
<input name="upload_files" form="quick_post_form" id="upload_files" multiple type="file" style="display: none;" /> <input name="upload_files" form="quick_post_form" id="upload_files" multiple type="file" class="auto_hide" />
<label for="upload_files" class="formbutton add_file_button">{{lang "quick_topic.add_file_button"}}</label> <label for="upload_files" class="formbutton add_file_button">{{lang "quick_topic.add_file_button"}}</label>
<div id="upload_file_dock"></div>{{end}} <div id="upload_file_dock"></div>{{end}}
<button class="formbutton close_form">{{lang "quick_topic.cancel_button"}}</button> <button class="formbutton close_form">{{lang "quick_topic.cancel_button"}}</button>

View File

@ -418,6 +418,9 @@ h2 {
height: 100px; height: 100px;
resize: vertical; resize: vertical;
} }
.uploadItem {
display: inline-block;
}
.more_topic_block_initial { .more_topic_block_initial {
display: none; display: none;