mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
Move DocumentOutlineView to its own file
This commit is contained in:
parent
26bea20c82
commit
1e119e093b
3 changed files with 69 additions and 48 deletions
|
@ -19,7 +19,8 @@
|
|||
getFileName, scrollIntoView, getPDFFileNameFromURL, PDFHistory,
|
||||
Preferences, ViewHistory, PageView, ThumbnailView, URL,
|
||||
noContextMenuHandler, SecondaryToolbar, PasswordPrompt,
|
||||
PresentationMode, HandTool, Promise, DocumentProperties */
|
||||
PresentationMode, HandTool, Promise, DocumentProperties,
|
||||
DocumentOutlineView */
|
||||
|
||||
'use strict';
|
||||
|
||||
|
@ -1636,53 +1637,7 @@ var PDFView = {
|
|||
//#include page_view.js
|
||||
//#include thumbnail_view.js
|
||||
//#include text_layer_builder.js
|
||||
|
||||
var DocumentOutlineView = function documentOutlineView(outline) {
|
||||
var outlineView = document.getElementById('outlineView');
|
||||
while (outlineView.firstChild) {
|
||||
outlineView.removeChild(outlineView.firstChild);
|
||||
}
|
||||
|
||||
if (!outline) {
|
||||
if (!outlineView.classList.contains('hidden')) {
|
||||
PDFView.switchSidebarView('thumbs');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
function bindItemLink(domObj, item) {
|
||||
domObj.href = PDFView.getDestinationHash(item.dest);
|
||||
domObj.onclick = function documentOutlineViewOnclick(e) {
|
||||
PDFView.navigateTo(item.dest);
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
var queue = [{parent: outlineView, items: outline}];
|
||||
while (queue.length > 0) {
|
||||
var levelData = queue.shift();
|
||||
var i, n = levelData.items.length;
|
||||
for (i = 0; i < n; i++) {
|
||||
var item = levelData.items[i];
|
||||
var div = document.createElement('div');
|
||||
div.className = 'outlineItem';
|
||||
var a = document.createElement('a');
|
||||
bindItemLink(a, item);
|
||||
a.textContent = item.title;
|
||||
div.appendChild(a);
|
||||
|
||||
if (item.items.length > 0) {
|
||||
var itemsDiv = document.createElement('div');
|
||||
itemsDiv.className = 'outlineItems';
|
||||
div.appendChild(itemsDiv);
|
||||
queue.push({parent: itemsDiv, items: item.items});
|
||||
}
|
||||
|
||||
levelData.parent.appendChild(div);
|
||||
}
|
||||
}
|
||||
};
|
||||
//#include document_outline_view.js
|
||||
|
||||
var DocumentAttachmentsView = function documentAttachmentsView(attachments) {
|
||||
var attachmentsView = document.getElementById('attachmentsView');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue