2014-04-27 09:48:47 -04:00
|
|
|
/*
|
|
|
|
* 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();
|
|
|
|
|
2014-05-20 21:23:18 -04:00
|
|
|
var images_len = $('form:not([id="quick-reply"]) [type=file]').length;
|
2014-04-27 09:48:47 -04:00
|
|
|
|
|
|
|
if (!(images_len >= max_images)) {
|
2014-06-12 14:01:16 -04:00
|
|
|
$('.add_image').after('<br class="file_separator"/><input type="file" name="file'+(images_len+1)+'" id="upload_file'+(images_len+1)+'">');
|
2014-04-27 09:48:47 -04:00
|
|
|
if (typeof setup_form !== 'undefined') setup_form($('form[name="post"]'));
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
if (active_page == 'thread' || active_page == 'index' && max_images > 1) {
|
|
|
|
$(document).ready(multi_image);
|
|
|
|
}
|