Skip to content
Snippets Groups Projects
Commit 506559a9 authored by Intan Nurjanah's avatar Intan Nurjanah
Browse files

add thumbnail

parent 52c51bfa
No related merge requests found
...@@ -11,6 +11,11 @@ body { ...@@ -11,6 +11,11 @@ body {
height: 16px; height: 16px;
vertical-align: text-bottom; vertical-align: text-bottom;
} }
.img-thumbnail{
padding: 5px;
border: none;
}
/* /*
* Sidebar * Sidebar
......
...@@ -143,8 +143,6 @@ ...@@ -143,8 +143,6 @@
<script src="https://unpkg.com/feather-icons/dist/feather.min.js"></script> <script src="https://unpkg.com/feather-icons/dist/feather.min.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script> <script src="http://malsup.github.com/jquery.form.js"></script>
<script> <script>
$(document).ready(function(){ $(document).ready(function(){
feather.replace(); feather.replace();
}); });
...@@ -153,8 +151,8 @@ ...@@ -153,8 +151,8 @@
$('#navbarSupportedContent').on('click', function() { $('#navbarSupportedContent').on('click', function() {
$('.navbar-toggler').click(); $('.navbar-toggler').click();
}) })
</script> </script>
<script src="js/main.js"></script> <script src="js/main.js"></script>
</body> </body>
......
...@@ -19,19 +19,40 @@ ...@@ -19,19 +19,40 @@
<div class="form-group"> <div class="form-group">
<label><input type="checkbox" value="" id="isUpload">Upload gambar? </label> <label><input type="checkbox" value="" id="isUpload">Upload gambar? </label>
<input type="hidden" class="form-control" id="chx-helper" name="isUpload" value="0"> <input type="hidden" class="form-control" id="chx-helper" name="isUpload" value="0">
<input class="input-file d-none" id="fileInput" type="file" name="file"> <input class="input-file d-none" id="fileInput" type="file" name="file" onchange="previewFile()">
</div>
<div class="form-group">
<img src="" class="img-thumbnail d-none col-sm-2 col-md-3 col-lg-2" id="imgThumbnail">
</div> </div>
<button type="submit" class="btn btn-default" onsubmit="return validate()">Kirim</button> <button type="submit" class="btn btn-default" onsubmit="return validate()">Kirim</button>
</form> </form>
<script> <script>
function previewFile() {
var preview = document.querySelector('img');
var file = document.querySelector('input[type=file]').files[0];
var reader = new FileReader();
reader.onloadend = function () {
preview.src = reader.result;
}
if (file) {
reader.readAsDataURL(file);
$("#imgThumbnail").removeClass("d-none");
} else {
preview.src = "";
}
}
$('#isUpload').change(function () { $('#isUpload').change(function () {
if (this.checked) { if (this.checked) {
$("#fileInput").removeClass("d-none"); $("#fileInput").removeClass("d-none");
$("#chx-helper").val(1); $("#chx-helper").val(1);
} else { } else {
$("#fileInput").addClass("d-none"); $("#fileInput").addClass("d-none");
$("#imgThumbnail").addClass("d-none");
$("#chx-helper").val(0); $("#chx-helper").val(0);
} }
}); });
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
</form> </form>
<script> <script>
var konten = document.getElementById('konten'); var konten = document.getElementById('konten');
var author = document.getElementById('author'); var author = document.getElementById('author');
...@@ -26,6 +27,7 @@ ...@@ -26,6 +27,7 @@
e.preventDefault(); e.preventDefault();
if (author.value.trim() === "" && konten.value.trim() === "") { if (author.value.trim() === "" && konten.value.trim() === "") {
// BootstrapDialog.alert('Author dan konten tidak boleh kosong!');
alert("Author dan konten tidak boleh kosong!"); alert("Author dan konten tidak boleh kosong!");
} else if (author.value.trim() === "") { } else if (author.value.trim() === "") {
alert("Author tidak boleh kosong!"); alert("Author tidak boleh kosong!");
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment