Skip to content

Commit

Permalink
LSNBLDR-774; handle multiple file in upload (sakaiproject#3872)
Browse files Browse the repository at this point in the history
  • Loading branch information
clhedrick authored Feb 7, 2017
1 parent 0630728 commit cf0a430
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions lessonbuilder/tool/src/webapp/js/show-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -3005,9 +3005,9 @@ $(function() {
} else if ($('#mm-file-input-itemname').size() === 0) {
var nameInput = $('.mm-file-input-names').first();
nameInput.attr('id', 'mm-file-input-itemname');
nameInput.after('<label></label>');
nameInput.next().text($('#mm-name').prev().text());
nameInput.next().attr('for','mm-file-input-itemname');
nameInput.before('<label></label>');
nameInput.prev().text($('#mm-name').prev().text());
nameInput.prev().attr('for','mm-file-input-itemname');
}
}
}
Expand All @@ -3027,15 +3027,21 @@ $(function() {
var newStuff = '<span class="mm-file-input-name"></span> <span title="' + msg('simplepage.remove_from_uploads') + '"><span class="mm-file-input-delete fa fa-times"></span></span>';
// only do this if we're doing names
if (doingNames) {
newStuff = newStuff + '<input class="mm-file-input-names" type="text" size="30" maxlength="255"/>';
for (i = 0; i < lastInput[0].files.length; i++) {
newStuff = newStuff + '<input class="mm-file-input-names" type="text" size="30" maxlength="255"/>';
}
}
// now need annotation on the next input, so remove the old
$('.add-another-file').hide();
$('.add-file-div').removeClass('add-another-file-div');
$('.add-another-file').last().show().parent().addClass('add-another-file-div');
lastInput.after(newStuff);
lastInput.parent().addClass('mm-file-group');
lastInput.next().text(lastInput[0].files[0].name);
var names = "";
for (i = 0; i < lastInput[0].files.length; i++) {
names = names + ", " + lastInput[0].files[i].name;
}
lastInput.next().text(names.substring(2));
// arm the delete
lastInput.next().next().on('click', mmFileInputDelete);
// and hide the actual button
Expand All @@ -3051,16 +3057,19 @@ $(function() {
firsttime = true;
}
$('#mm-name-section').hide();
var nameInput = lastInput.next().next().next();
var nameInput = lastInput.parent().find('.mm-file-input-names');
nameInput.addClass('mm-file-input-itemname');
nameInput.attr('title', msg('simplepage.title_for_upload'));
// rest is just for the first. nameInput can be more than one if user selected multiple files
// only put the label on the first
nameInput = nameInput.first();
nameInput.val(itemName);
if (firsttime) {
// add a label for the name field. I think it's too much to do it for all of them
nameInput.attr('id', 'mm-file-input-itemname');
nameInput.after('<label></label>');
nameInput.next().text($('#mm-name').prev().text());
nameInput.next().attr('for','mm-file-input-itemname');
nameInput.before('<label></label>');
nameInput.prev().text($('#mm-name').prev().text());
nameInput.prev().attr('for','mm-file-input-itemname');
}
nameInput.show();
}
Expand Down

0 comments on commit cf0a430

Please sign in to comment.