| 1 |
function addVideo(a) {
|
| 2 |
$(a).hide();
|
| 3 |
$(a).parents('fieldset').clone().removeClass('twistage-add-original').appendTo('#twistage-add-replicate').find('input, textarea, select').each(function(i) {
|
| 4 |
var str = this.name;
|
| 5 |
m = str.match(/^twistage_upload\[(\d)\]\[([a-z_]+)\]$/);
|
| 6 |
if(m) {
|
| 7 |
var seq = (parseInt(m[1])+1);
|
| 8 |
this.name = 'twistage_upload['+seq+']['+ m[2]+']';
|
| 9 |
}
|
| 10 |
n = str.match(/^files\[twistage_upload_(\d)\]$/);
|
| 11 |
if(n) {
|
| 12 |
this.name = 'files[twistage_upload_'+(parseInt(n[1])+1)+']';
|
| 13 |
}
|
| 14 |
}).attr('value', '').end().find('.twistage-add-more').show().end().find('.form-checkbox').val('value', '1');
|
| 15 |
$('.twistage-add-more').click(function() {
|
| 16 |
addVideo(this);
|
| 17 |
});
|
| 18 |
var i = (parseInt($('#edit-twistage-sequence').val())+1);
|
| 19 |
$('#edit-twistage-sequence').val(i);
|
| 20 |
}
|
| 21 |
|
| 22 |
$(document).ready(function(){
|
| 23 |
// Drupal (or, at least, D5) does not seem to allow multiple file upload fields in the same form tree, so this a workaround.
|
| 24 |
$('#twistage-add-replicate input.form-file').each(function(i) {
|
| 25 |
$(this).attr('name', 'files[twistage_upload_'+i+']');
|
| 26 |
});
|
| 27 |
|
| 28 |
$('.twistage-add-more').click(function() {
|
| 29 |
addVideo(this);
|
| 30 |
});
|
| 31 |
});
|