|
|
@ -18,37 +18,54 @@ |
|
|
|
|
|
|
|
|
|
|
|
'use strict'; |
|
|
|
'use strict'; |
|
|
|
|
|
|
|
|
|
|
|
var PDFAttachmentView = function documentAttachmentsView(options) { |
|
|
|
var PDFAttachmentView = (function PDFAttachmentViewClosure() { |
|
|
|
var attachments = options.attachments; |
|
|
|
function PDFAttachmentView(options) { |
|
|
|
var attachmentsView = options.attachmentsView; |
|
|
|
this.container = options.container; |
|
|
|
while (attachmentsView.firstChild) { |
|
|
|
this.attachments = options.attachments; |
|
|
|
attachmentsView.removeChild(attachmentsView.firstChild); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!attachments) { |
|
|
|
PDFAttachmentView.prototype = { |
|
|
|
return; |
|
|
|
reset: function PDFAttachmentView_reset() { |
|
|
|
} |
|
|
|
var container = this.container; |
|
|
|
|
|
|
|
while (container.firstChild) { |
|
|
|
|
|
|
|
container.removeChild(container.firstChild); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
function bindItemLink(domObj, item) { |
|
|
|
_bindLink: function PDFAttachmentView_bindLink(button, item) { |
|
|
|
domObj.onclick = function documentAttachmentsViewOnclick(e) { |
|
|
|
button.onclick = function downloadFile(e) { |
|
|
|
var downloadManager = new DownloadManager(); |
|
|
|
var downloadManager = new DownloadManager(); |
|
|
|
downloadManager.downloadData(item.content, getFileName(item.filename), |
|
|
|
var content = item.content; |
|
|
|
''); |
|
|
|
var filename = item.filename; |
|
|
|
return false; |
|
|
|
downloadManager.downloadData(content, getFileName(filename), ''); |
|
|
|
}; |
|
|
|
return false; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
var names = Object.keys(attachments).sort(function(a,b) { |
|
|
|
render: function PDFAttachmentView_render() { |
|
|
|
return a.toLowerCase().localeCompare(b.toLowerCase()); |
|
|
|
var attachments = this.attachments; |
|
|
|
}); |
|
|
|
|
|
|
|
for (var i = 0, ii = names.length; i < ii; i++) { |
|
|
|
this.reset(); |
|
|
|
var item = attachments[names[i]]; |
|
|
|
|
|
|
|
var div = document.createElement('div'); |
|
|
|
if (!attachments) { |
|
|
|
div.className = 'attachmentsItem'; |
|
|
|
return; |
|
|
|
var button = document.createElement('button'); |
|
|
|
} |
|
|
|
bindItemLink(button, item); |
|
|
|
|
|
|
|
button.textContent = getFileName(item.filename); |
|
|
|
var names = Object.keys(attachments).sort(function(a, b) { |
|
|
|
div.appendChild(button); |
|
|
|
return a.toLowerCase().localeCompare(b.toLowerCase()); |
|
|
|
attachmentsView.appendChild(div); |
|
|
|
}); |
|
|
|
} |
|
|
|
for (var i = 0, len = names.length; i < len; i++) { |
|
|
|
}; |
|
|
|
var item = attachments[names[i]]; |
|
|
|
|
|
|
|
var div = document.createElement('div'); |
|
|
|
|
|
|
|
div.className = 'attachmentsItem'; |
|
|
|
|
|
|
|
var button = document.createElement('button'); |
|
|
|
|
|
|
|
this._bindLink(button, item); |
|
|
|
|
|
|
|
button.textContent = getFileName(item.filename); |
|
|
|
|
|
|
|
div.appendChild(button); |
|
|
|
|
|
|
|
this.container.appendChild(div); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return PDFAttachmentView; |
|
|
|
|
|
|
|
})(); |
|
|
|