[Pkg-javascript-commits] [pdf.js] 15/119: Add custom |outlineloaded| and |attachmentsloaded| events to the viewer (bug 1112947)
David Prévot
taffit at moszumanska.debian.org
Wed May 13 21:27:36 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository pdf.js.
commit 94cc731616272f1118d4c9ea2010303813285a31
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date: Sat Mar 21 13:07:01 2015 +0100
Add custom |outlineloaded| and |attachmentsloaded| events to the viewer (bug 1112947)
---
web/pdf_attachment_view.js | 19 ++++++++++++++++++-
web/pdf_outline_view.js | 16 ++++++++++++++++
2 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/web/pdf_attachment_view.js b/web/pdf_attachment_view.js
index ad1b7df..df98b71 100644
--- a/web/pdf_attachment_view.js
+++ b/web/pdf_attachment_view.js
@@ -50,6 +50,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
+ */
_bindLink: function PDFAttachmentView_bindLink(button, content, filename) {
button.onclick = function downloadFile(e) {
this.downloadManager.downloadData(content, filename, '');
@@ -59,17 +70,21 @@ var PDFAttachmentView = (function PDFAttachmentViewClosure() {
render: function PDFAttachmentView_render() {
var attachments = this.attachments;
+ var attachmentsCount = 0;
this.reset();
if (!attachments) {
+ this._dispatchEvent(attachmentsCount);
return;
}
var names = Object.keys(attachments).sort(function(a, b) {
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 filename = getFileName(item.filename);
var div = document.createElement('div');
@@ -80,6 +95,8 @@ var PDFAttachmentView = (function PDFAttachmentViewClosure() {
div.appendChild(button);
this.container.appendChild(div);
}
+
+ this._dispatchEvent(attachmentsCount);
}
};
diff --git a/web/pdf_outline_view.js b/web/pdf_outline_view.js
index 41995a8..311a270 100644
--- a/web/pdf_outline_view.js
+++ b/web/pdf_outline_view.js
@@ -49,6 +49,17 @@ var PDFOutlineView = (function PDFOutlineViewClosure() {
/**
* @private
*/
+ _dispatchEvent: function PDFOutlineView_dispatchEvent(outlineCount) {
+ var event = document.createEvent('CustomEvent');
+ event.initCustomEvent('outlineloaded', true, true, {
+ outlineCount: outlineCount
+ });
+ this.container.dispatchEvent(event);
+ },
+
+ /**
+ * @private
+ */
_bindLink: function PDFOutlineView_bindLink(element, item) {
var linkService = this.linkService;
element.href = linkService.getDestinationHash(item.dest);
@@ -60,10 +71,12 @@ var PDFOutlineView = (function PDFOutlineViewClosure() {
render: function PDFOutlineView_render() {
var outline = this.outline;
+ var outlineCount = 0;
this.reset();
if (!outline) {
+ this._dispatchEvent(outlineCount);
return;
}
@@ -87,8 +100,11 @@ var PDFOutlineView = (function PDFOutlineViewClosure() {
}
levelData.parent.appendChild(div);
+ outlineCount++;
}
}
+
+ this._dispatchEvent(outlineCount);
}
};
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git
More information about the Pkg-javascript-commits
mailing list