summaryrefslogtreecommitdiff
path: root/views/new-post.php
diff options
context:
space:
mode:
authorAaron Parecki <aaron@parecki.com>2016-04-29 08:00:12 -0700
committerAaron Parecki <aaron@parecki.com>2016-04-29 08:00:12 -0700
commit3ea51af407501d70ad24ad12c20ccd904e294022 (patch)
treed761d6f1dd056263bf7d62f1ab58d5aeafdcd36f /views/new-post.php
parent35aa1b78c8c7085a43be556753c6e045d01ce302 (diff)
parentfbe5ffa79c496b3fffefb010401bf9b653530d6a (diff)
Merge branch 'master' of github.com:aaronpk/Quill
Diffstat (limited to 'views/new-post.php')
-rw-r--r--views/new-post.php25
1 files changed, 16 insertions, 9 deletions
diff --git a/views/new-post.php b/views/new-post.php
index a059ea0..8e9c692 100644
--- a/views/new-post.php
+++ b/views/new-post.php
@@ -26,9 +26,12 @@
<div class="form-group">
<label for="note_photo"><code>photo</code></label>
- <input type="file" name="note_photo" id="note_photo" accept="image/*" onchange="previewPhoto(event)">
+ <input type="file" name="note_photo" id="note_photo" accept="image/*">
<br>
- <img src="" id="photo_preview" style="max-width: 300px; max-height: 300px;">
+ <div id="photo_preview_container">
+ <img src="" id="photo_preview" style="max-width: 300px; max-height: 300px;">
+ <button type="button" class="btn btn-danger btn-sm" id="remove_photo"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Remove image</button>
+ </div>
</div>
<div class="form-group">
@@ -132,16 +135,20 @@
</style>
<script>
-function previewPhoto(event) {
- $("#photo_preview")
- .show()
- .attr("src", URL.createObjectURL(event.target.files[0]) );
-}
-
$(function(){
var userHasSetCategory = false;
- $("#photo_preview").hide();
+
+ $("#photo_preview_container").hide();
+ $("#note_photo").on("change", function(e){
+ $("#photo_preview_container").show();
+ $("#photo_preview").attr("src", URL.createObjectURL(e.target.files[0]) );
+ });
+ $("#remove_photo").on("click", function(){
+ $("#note_photo").val("");
+ $("#photo_preview").attr("src", "" );
+ $("#photo_preview_container").hide();
+ });
$("#note_content").on('change keyup', function(e){
var text = $("#note_content").val();