1
0
Fork 0
mirror of https://github.com/Yetangitu/owncloud-apps.git synced 2025-10-02 14:49:17 +02:00
nextcloud-apps/files_reader/vendor/pdfjs/controllers/bookmarks_controller.js
frankdelange 6b0ab64fe4 - files_reader: v1.2.0, implemented night mode, scroll to top on page
change (#73), default viewer selection in personal preferences section (#74), fixed undefined $title in template (#72)
2018-01-31 12:15:38 +01: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,
};
};