Show More
@@ -1,27 +1,27 b'' | |||||
1 | $('input[name=image]').wrap($('<div class="file_wrap"></div>')); |
|
1 | $('input[name=image]').wrap($('<div class="file_wrap"></div>')); | |
2 |
|
2 | |||
3 | $('body').on('change', 'input[name=image]', function(event) { |
|
3 | $('body').on('change', 'input[name=image]', function(event) { | |
4 | var file = event.target.files[0]; |
|
4 | var file = event.target.files[0]; | |
5 |
|
5 | |||
6 | if(file.type.match('image.*')) { |
|
6 | if(file.type.match('image.*')) { | |
7 | var fileReader = new FileReader(); |
|
7 | var fileReader = new FileReader(); | |
8 |
|
8 | |||
9 | fileReader.addEventListener("load", function(event) { |
|
9 | fileReader.addEventListener("load", function(event) { | |
10 | var wrapper = $('.file_wrap'); |
|
10 | var wrapper = $('.file_wrap'); | |
11 |
|
11 | |||
12 | wrapper.find('.file-thumb').remove(); |
|
12 | wrapper.find('.file-thumb').remove(); | |
13 | wrapper.append( |
|
13 | wrapper.append( | |
14 | $('<div class="file-thumb" style="background-image: url('+event.target.result+')"></div>') |
|
14 | $('<div class="file-thumb" style="background-image: url('+event.target.result+')"></div>') | |
15 | ); |
|
15 | ); | |
16 | }); |
|
16 | }); | |
17 |
|
17 | |||
18 | fileReader.readAsDataURL(file); |
|
18 | fileReader.readAsDataURL(file); | |
19 | } |
|
19 | } | |
20 | }); |
|
20 | }); | |
21 |
|
21 | |||
22 | var form = $('#form'); |
|
22 | var form = $('#form'); | |
23 | $('textarea').keypress(function(event) { |
|
23 | $('textarea').keypress(function(event) { | |
24 | if (event.which == 13) { |
|
24 | if (event.which == 13 && event.ctrlKey) { | |
25 | form.submit(); |
|
25 | form.submit(); | |
26 | } |
|
26 | } | |
27 | }); No newline at end of file |
|
27 | }); |
General Comments 0
You need to be logged in to leave comments.
Login now