Determine filename only once and reduce code for _bindLink
This commit is contained in:
parent
818b7fc306
commit
b72395d5ce
@ -50,11 +50,9 @@ var PDFAttachmentView = (function PDFAttachmentViewClosure() {
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_bindLink: function PDFAttachmentView_bindLink(button, item) {
|
_bindLink: function PDFAttachmentView_bindLink(button, content, filename) {
|
||||||
button.onclick = function downloadFile(e) {
|
button.onclick = function downloadFile(e) {
|
||||||
var content = item.content;
|
this.downloadManager.downloadData(content, filename, '');
|
||||||
var filename = item.filename;
|
|
||||||
this.downloadManager.downloadData(content, getFileName(filename), '');
|
|
||||||
return false;
|
return false;
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
},
|
},
|
||||||
@ -73,11 +71,12 @@ var PDFAttachmentView = (function PDFAttachmentViewClosure() {
|
|||||||
});
|
});
|
||||||
for (var i = 0, len = names.length; i < len; i++) {
|
for (var i = 0, len = names.length; i < len; i++) {
|
||||||
var item = attachments[names[i]];
|
var item = attachments[names[i]];
|
||||||
|
var filename = getFileName(item.filename);
|
||||||
var div = document.createElement('div');
|
var div = document.createElement('div');
|
||||||
div.className = 'attachmentsItem';
|
div.className = 'attachmentsItem';
|
||||||
var button = document.createElement('button');
|
var button = document.createElement('button');
|
||||||
this._bindLink(button, item);
|
this._bindLink(button, item.content, filename);
|
||||||
button.textContent = getFileName(item.filename);
|
button.textContent = filename;
|
||||||
div.appendChild(button);
|
div.appendChild(button);
|
||||||
this.container.appendChild(div);
|
this.container.appendChild(div);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user