|
|
@ -47,6 +47,17 @@ var PDFAttachmentView = (function PDFAttachmentViewClosure() { |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @private |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
_dispatchEvent: function PDFAttachmentView_dispatchEvent(attachmentsCount) { |
|
|
|
|
|
|
|
var event = document.createEvent('CustomEvent'); |
|
|
|
|
|
|
|
event.initCustomEvent('attachmentsloaded', true, true, { |
|
|
|
|
|
|
|
attachmentsCount: attachmentsCount |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
this.container.dispatchEvent(event); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @private |
|
|
|
* @private |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -59,17 +70,21 @@ var PDFAttachmentView = (function PDFAttachmentViewClosure() { |
|
|
|
|
|
|
|
|
|
|
|
render: function PDFAttachmentView_render() { |
|
|
|
render: function PDFAttachmentView_render() { |
|
|
|
var attachments = this.attachments; |
|
|
|
var attachments = this.attachments; |
|
|
|
|
|
|
|
var attachmentsCount = 0; |
|
|
|
|
|
|
|
|
|
|
|
this.reset(); |
|
|
|
this.reset(); |
|
|
|
|
|
|
|
|
|
|
|
if (!attachments) { |
|
|
|
if (!attachments) { |
|
|
|
|
|
|
|
this._dispatchEvent(attachmentsCount); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var names = Object.keys(attachments).sort(function(a, b) { |
|
|
|
var names = Object.keys(attachments).sort(function(a, b) { |
|
|
|
return a.toLowerCase().localeCompare(b.toLowerCase()); |
|
|
|
return a.toLowerCase().localeCompare(b.toLowerCase()); |
|
|
|
}); |
|
|
|
}); |
|
|
|
for (var i = 0, len = names.length; i < len; i++) { |
|
|
|
attachmentsCount = names.length; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < attachmentsCount; i++) { |
|
|
|
var item = attachments[names[i]]; |
|
|
|
var item = attachments[names[i]]; |
|
|
|
var filename = getFileName(item.filename); |
|
|
|
var filename = getFileName(item.filename); |
|
|
|
var div = document.createElement('div'); |
|
|
|
var div = document.createElement('div'); |
|
|
@ -80,6 +95,8 @@ var PDFAttachmentView = (function PDFAttachmentViewClosure() { |
|
|
|
div.appendChild(button); |
|
|
|
div.appendChild(button); |
|
|
|
this.container.appendChild(div); |
|
|
|
this.container.appendChild(div); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this._dispatchEvent(attachmentsCount); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|