Skip to content

Commit

Permalink
Determine filename only once and reduce code for _bindLink
Browse files Browse the repository at this point in the history
  • Loading branch information
timvandermeij committed Jan 28, 2015
1 parent 818b7fc commit b72395d
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions web/pdf_attachment_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,9 @@ var PDFAttachmentView = (function PDFAttachmentViewClosure() {
/**
* @private
*/
_bindLink: function PDFAttachmentView_bindLink(button, item) {
_bindLink: function PDFAttachmentView_bindLink(button, content, filename) {
button.onclick = function downloadFile(e) {
var content = item.content;
var filename = item.filename;
this.downloadManager.downloadData(content, getFileName(filename), '');
this.downloadManager.downloadData(content, filename, '');
return false;
}.bind(this);
},
Expand All @@ -73,11 +71,12 @@ var PDFAttachmentView = (function PDFAttachmentViewClosure() {
});
for (var i = 0, len = names.length; i < len; i++) {
var item = attachments[names[i]];
var filename = getFileName(item.filename);
var div = document.createElement('div');
div.className = 'attachmentsItem';
var button = document.createElement('button');
this._bindLink(button, item);
button.textContent = getFileName(item.filename);
this._bindLink(button, item.content, filename);
button.textContent = filename;
div.appendChild(button);
this.container.appendChild(div);
}
Expand Down

0 comments on commit b72395d

Please sign in to comment.