mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-12-18 10:25:55 +01:00
31 lines
981 B
JavaScript
31 lines
981 B
JavaScript
|
/*
|
||
|
* multi-image.js - Add support for multiple images to the post form
|
||
|
*
|
||
|
* Copyright (c) 2014 Fredrick Brennan <admin@8chan.co>
|
||
|
*
|
||
|
* Usage:
|
||
|
* $config['max_images'] = 3;
|
||
|
* $config['additional_javascript'][] = 'js/jquery.min.js';
|
||
|
* $config['additional_javascript'][] = 'js/multi-image.js';
|
||
|
*/
|
||
|
|
||
|
function multi_image() {
|
||
|
$('input[type=file]').after('<a href="#" class="add_image">+</a>');
|
||
|
|
||
|
$(document).on('click', 'a.add_image', function(e) {
|
||
|
e.preventDefault();
|
||
|
$('#upload_url').remove();
|
||
|
|
||
|
var images_len = $('input[type=file]').length;
|
||
|
|
||
|
if (!(images_len >= max_images)) {
|
||
|
$('.add_image').after('<br/><input type="file" name="file'+(images_len+1)+'" id="upload_file'+(images_len+1)+'">');
|
||
|
if (typeof setup_form !== 'undefined') setup_form($('form[name="post"]'));
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
|
||
|
if (active_page == 'thread' || active_page == 'index' && max_images > 1) {
|
||
|
$(document).ready(multi_image);
|
||
|
}
|