From 4e37176436c78023231f6a8aa3671a69101d50b1 Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 16 Feb 2018 15:27:48 +0000 Subject: [PATCH] changes to allow preview of image first --- public/js/app.js | 17 +++++++++++++++++ resources/assets/js/app.js | 17 +++++++++++++++++ resources/views/items/form.blade.php | 4 +++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/public/js/app.js b/public/js/app.js index 47bc0b6b..a275c825 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -45,6 +45,23 @@ $.when( $.ready ).then(function() { } + function readURL(input) { + + if (input.files && input.files[0]) { + var reader = new FileReader(); + + reader.onload = function(e) { + $('#appimage img').attr('src', e.target.result); + } + + reader.readAsDataURL(input.files[0]); + } + } + + $("#upload").change(function() { + readURL(this); + }); + $( "#sortable" ).sortable({ stop: function (event, ui) { var idsInOrder = $("#sortable").sortable('toArray', { diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js index 61f95bde..7570d7b4 100644 --- a/resources/assets/js/app.js +++ b/resources/assets/js/app.js @@ -36,6 +36,23 @@ $.when( $.ready ).then(function() { } + function readURL(input) { + + if (input.files && input.files[0]) { + var reader = new FileReader(); + + reader.onload = function(e) { + $('#appimage img').attr('src', e.target.result); + } + + reader.readAsDataURL(input.files[0]); + } + } + + $("#upload").change(function() { + readURL(this); + }); + $( "#sortable" ).sortable({ stop: function (event, ui) { var idsInOrder = $("#sortable").sortable('toArray', { diff --git a/resources/views/items/form.blade.php b/resources/views/items/form.blade.php index 8110c93b..009e54c6 100644 --- a/resources/views/items/form.blade.php +++ b/resources/views/items/form.blade.php @@ -43,11 +43,13 @@ ?> {!! Form::hidden('icon', $icon, ['class' => 'form-control']) !!} + @else + @endif
- +