Iterate through input=file attachments (not multi yet)
This commit is contained in:
parent
e41809af89
commit
e3431a2c91
19
js/util.js
19
js/util.js
|
@ -848,6 +848,14 @@ var SN = { // StatusNet
|
||||||
NDA.change(function (event) {
|
NDA.change(function (event) {
|
||||||
form.find('.attach-status').remove();
|
form.find('.attach-status').remove();
|
||||||
|
|
||||||
|
if (typeof this.files === "object") {
|
||||||
|
var attachStatus = $('<ul class="attach-status ' + SN.C.S.Success + '"></ul>');
|
||||||
|
form.append(attachStatus);
|
||||||
|
// Some newer browsers will let us fetch the files for preview.
|
||||||
|
for (i = 0; i < this.files.length; i++) {
|
||||||
|
SN.U.PreviewAttach(form, this.files[i]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
var filename = $(this).val();
|
var filename = $(this).val();
|
||||||
if (!filename) {
|
if (!filename) {
|
||||||
// No file -- we've been tricked!
|
// No file -- we've been tricked!
|
||||||
|
@ -863,12 +871,6 @@ var SN = { // StatusNet
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
form.append(attachStatus);
|
form.append(attachStatus);
|
||||||
|
|
||||||
if (typeof this.files === "object") {
|
|
||||||
// Some newer browsers will let us fetch the files for preview.
|
|
||||||
for (i = 0; i < this.files.length; i++) {
|
|
||||||
SN.U.PreviewAttach(form, this.files[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -964,12 +966,15 @@ var SN = { // StatusNet
|
||||||
|
|
||||||
if (preview) {
|
if (preview) {
|
||||||
blobAsDataURL(file, function (url) {
|
blobAsDataURL(file, function (url) {
|
||||||
|
var fileentry = $('<li class="attachment"></li>');
|
||||||
|
fileentry.append($('<code>' + file.name + '</code>'));
|
||||||
var img = $('<img>')
|
var img = $('<img>')
|
||||||
.attr('title', tooltip)
|
.attr('title', tooltip)
|
||||||
.attr('alt', tooltip)
|
.attr('alt', tooltip)
|
||||||
.attr('src', url)
|
.attr('src', url)
|
||||||
.attr('style', 'height: 120px');
|
.attr('style', 'height: 120px');
|
||||||
form.find('.attach-status').append(img);
|
fileentry.append(img);
|
||||||
|
form.find('.attach-status').append(fileentry);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var img = $('<div></div>').text(tooltip);
|
var img = $('<div></div>').text(tooltip);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user