files_reader/vendor/pdfjs/controllers/bookmarks_controller.js
Frank de Lange b190e180ef - Migrated from https://github.com/Yetangitu/owncloud-apps
- substantial bit rot accrued in 4 years of non-maintenance which made Reader unusable
 - Reader now works reliably on public pages - or at least it _Works For Me™_

 - Refactored a substantial part of the code to comply to the "current" (ha ha) Nextcloud API
 - Dropped Owncloud compatibility for lack of a testing installation
 - Dropped IE (<11) support
 - Dropped compatibility with older (<20) Nextcloud versions
 - Dropped app-specific ajax code, now handled by SettingsController
 - Updated dependencies where applicable
2022-09-24 00:00:03 +00:00

72 lines
2.1 KiB
JavaScript

PDFJS.reader.BookmarksController = function() {
var reader = this,
eventBus = this.eventBus,
book = this.book,
annotations = reader.settings.annotations;
var $bookmarks = $("#bookmarksView"),
$list = $bookmarks.find("#bookmarks"),
$bookmark = $("#bookmark");
var show = function() {
$bookmarks.addClass('open');
};
var hide = function() {
$bookmarks.removeClass('open');
};
var addBookmarkItem = function (bookmark) {
$list.append(reader.NotesController.createItem(bookmark));
//reader.settings.session.setBookmark(bookmark.id, bookmark.anchor, bookmark.type, bookmark);
};
eventBus.on('bookmarkcreated', function createBookmark1(e) {
var id = e.id,
$item = $("#"+id);
addBookmarkItem(reader.getAnnotation(id));
if (id === reader.pageToId(reader.settings.currentPage))
$bookmark
.addClass("icon-turned_in")
.removeClass("icon-turned_in_not");
});
eventBus.on('bookmarkremoved', function removeBookmark1(e) {
var id = e.id,
$item = $("#"+id);
console.log($item);
console.log("event bookmarkremoved caught:",e,id);
if (reader.isBookmarked(id)) {
//delete reader.settings.annotations[id];
//reader.settings.session.deleteBookmark(id);
console.log("removing bookmark ", $item, reader.pageToId(reader.settings.currentPage), id);
$item.remove();
$item.remove();
$item.remove();
$item.remove();
if (id === reader.pageToId(reader.settings.currentPage))
$bookmark
.removeClass("icon-turned_in")
.addClass("icon-turned_in_not");
}
});
for (var bookmark in annotations) {
if (annotations.hasOwnProperty(bookmark) && (annotations[bookmark].type === "bookmark"))
addBookmarkItem(annotations[bookmark]);
};
return {
"show" : show,
"hide" : hide,
"addItem" : addBookmarkItem,
};
};