1
0
Fork 0
mirror of https://github.com/Yetangitu/owncloud-apps.git synced 2025-10-05 15:32:56 +02:00

- 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)
This commit is contained in:
frankdelange 2018-01-31 12:15:38 +01:00
parent d7df75fbc3
commit 6b0ab64fe4
33 changed files with 810 additions and 622 deletions

View file

@ -19,56 +19,46 @@ PDFJS.reader.BookmarksController = function() {
var addBookmarkItem = function (bookmark) {
$list.append(reader.NotesController.createItem(bookmark));
reader.settings.session.setBookmark(bookmark.id, bookmark.anchor, bookmark.type, bookmark);
//reader.settings.session.setBookmark(bookmark.id, bookmark.anchor, bookmark.type, bookmark);
};
var addBookmark = function (pageNum) {
var bookmark = new reader.Annotation(
"bookmark",
pageNum,
null,
pageToId(pageNum)
);
eventBus.on('bookmarkcreated', function createBookmark1(e) {
var id = e.id,
$item = $("#"+id);
addBookmarkItem(bookmark);
};
addBookmarkItem(reader.getAnnotation(id));
var removeBookmark = function (pageNum) {
var id = pageToId(pageNum);
console.log("ID", id);
if (isBookmarked(id)) {
delete reader.settings.annotations[id];
reader.settings.session.deleteBookmark(id);
if (id === pageToId(reader.settings.currentPage)) {
$bookmark
.removeClass("icon-turned_in")
.addClass("icon-turned_in_not");
}
}
};
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);
$item.remove();
console.log($item);
console.log("event bookmarkremoved caught:",e,id);
if (id === pageToId(reader.settings.currentPage)) {
$bookmark
.removeClass("icon-turned_in")
.addClass("icon-turned_in_not");
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");
}
});
var pageToId = function (pageNum) {
return "page_" + pageNum;
};
var isBookmarked = function (pageNum) {
return (reader.settings.annotations[pageToId(pageNum)] !== undefined);
};
for (var bookmark in annotations) {
if (annotations.hasOwnProperty(bookmark) && (annotations[bookmark].type === "bookmark"))
addBookmarkItem(annotations[bookmark]);
@ -78,9 +68,5 @@ PDFJS.reader.BookmarksController = function() {
"show" : show,
"hide" : hide,
"addItem" : addBookmarkItem,
"addBookmark" : addBookmark,
"removeBookmark" : removeBookmark,
"pageToId" : pageToId,
"isBookmarked" : isBookmarked
};
};

View file

@ -1,6 +1,9 @@
PDFJS.reader.ControlsController = function(book) {
var reader = this,
settings = reader.settings;
eventBus = this.eventBus,
settings = reader.settings,
customStyles = reader.settings.customStyles,
activeStyles = reader.settings.activeStyles;
var $store = $("#store"),
$viewer = $("#viewer"),
@ -26,7 +29,9 @@ PDFJS.reader.ControlsController = function(book) {
$page_num = $("#page_num"),
$total_pages = $("#total_pages"),
$status_message_left = $("#status_message_left"),
$status_message_right = $("#status_message_right");
$status_message_right = $("#status_message_right"),
$nightmode = $("#nightmode"),
$nightshift = $(".nightshift");
var STATUS_MESSAGE_LENGTH = 30,
STATUS_MESSAGE_TIMEOUT = 3000,
@ -83,12 +88,8 @@ PDFJS.reader.ControlsController = function(book) {
$slider.on("click", function () {
if(reader.sidebarOpen) {
reader.SidebarController.hide();
//$slider.addClass("icon-menu");
//$slider.removeClass("icon-right2");
} else {
reader.SidebarController.show();
//$slider.addClass("icon-right2");
//$slider.removeClass("icon-menu");
}
});
@ -122,20 +123,12 @@ PDFJS.reader.ControlsController = function(book) {
$bookmark.on("click", function() {
var currentPage = reader.settings.currentPage,
bmc = reader.BookmarksController;
if(!bmc.isBookmarked(currentPage)) { //-- Add bookmark
bmc.addBookmark(currentPage);
$bookmark
.addClass("icon-turned_in")
.removeClass("icon-turned_in_not");
} else { //-- Remove Bookmark
bmc.removeBookmark(currentPage);
$bookmark
.removeClass("icon-turned_in")
.addClass("icon-turned_in_not");
}
id = reader.pageToId(currentPage);
if (!reader.isBookmarked(id))
reader.addBookmark(currentPage)
else
reader.removeBookmark(currentPage);
});
/* select works fine on most browsers, but - of course - apple mobile has 'special needs' so
@ -146,7 +139,6 @@ PDFJS.reader.ControlsController = function(book) {
// zooooooooooooooom
$zoom_icon.on("click", function () {
var offset = $(this).offset();
console.log(offset);
$zoom_options.css("opacity", 0);
$zoom_options.toggleClass("hide");
$zoom_options.css({
@ -169,16 +161,6 @@ PDFJS.reader.ControlsController = function(book) {
setZoomIcon(settings.zoomLevel);
/*
$zoom_icon[0].className="";
var $current_zoom_option = $zoom_options.find("[data-value='" + settings.zoomLevel + "']");
if ($current_zoom_option.data("class")) {
$zoom_icon.addClass($current_zoom_option.data("class"));
} else {
$zoom_icon[0].textContent = $current_zoom_option.data("text");
}
*/
$zoom_option.on("click", function () {
var $this = $(this);
reader.setZoom($this.data("value"));
@ -240,6 +222,25 @@ PDFJS.reader.ControlsController = function(book) {
$rotate_icon[0].className = "icon-rotate_" + rotation;
});
/* end custom select */
var setNightmodeIcon = function (mode) {
if (mode)
$nightmode.removeClass("icon-brightness_low2").addClass("icon-brightness_4");
else
$nightmode.removeClass("icon-brightness_4").addClass("icon-brightness_low2");
};
$nightshift.off('click').on('click', function () {
if (settings.nightMode) {
reader.disableStyle(customStyles.nightMode);
settings.nightMode = false;
} else {
reader.enableStyle(customStyles.nightMode);
settings.nightMode = true;
}
setNightmodeIcon(settings.nightMode);
});
var enterPageNum = function(e) {
var text = e.target,
@ -277,6 +278,20 @@ PDFJS.reader.ControlsController = function(book) {
$page_num[0].addEventListener("keydown", enterPageNum, false);
});
eventBus.on("renderer:pagechanged", function toggleControls1(e) {
var page = e.pageNum,
id = reader.pageToId(page);
if (reader.isBookmarked(id))
$bookmark
.addClass("icon-turned_in")
.removeClass("icon-turned_in_not");
else
$bookmark
.removeClass("icon-turned_in")
.addClass("icon-turned_in_not");
});
var setPageCount = function (_numPages) {
var numPages = _numPages || reader.settings.numPages;
@ -315,44 +330,13 @@ PDFJS.reader.ControlsController = function(book) {
$page_num[0].textContent = text;
};
/*
book.on('renderer:locationChanged', function(cfi){
var cfiFragment = "#" + cfi;
// save current position (cursor)
reader.settings.session.setCursor(cfi);
//-- Check if bookmarked
if(!(reader.isBookmarked(cfi))) { //-- Not bookmarked
$bookmark
.removeClass("icon-turned_in")
.addClass("icon-turned_in_not");
} else { //-- Bookmarked
$bookmark
.addClass("icon-turned_in")
.removeClass("icon-turned_in_not");
}
reader.currentLocationCfi = cfi;
// Update the History Location
if(reader.settings.history &&
window.location.hash != cfiFragment) {
// Add CFI fragment to the history
history.pushState({}, '', cfiFragment);
}
});
book.on('book:pageChanged', function(location){
console.log("page", location.page, location.percentage)
});
*/
return {
"show": show,
"hide": hide,
"toggle": toggle,
"setZoomIcon": setZoomIcon,
"setRotateIcon": setRotateIcon,
"setNightmodeIcon": setNightmodeIcon,
"setCurrentPage": setCurrentPage,
"setPageCount": setPageCount,
"setStatus": setStatus

View file

@ -2,6 +2,7 @@ PDFJS.reader.NotesController = function(book) {
var book = this.book,
reader = this,
eventBus = this.eventBus,
$notesView = $("#notesView"),
$notes = $("#notes"),
$text = $("#note-text"),
@ -90,12 +91,17 @@ PDFJS.reader.NotesController = function(book) {
var addAnnotationItem = function(annotation) {
$notes.append(createItem(annotation));
reader.settings.session.setBookmark(annotation.id, annotation.anchor, annotation.type, annotation);
//reader.settings.session.setBookmark(annotation.id, annotation.anchor, annotation.type, annotation);
};
var removeAnnotation = function (id) {
if (annotations[id] !== undefined) {
if (annotations[id].type == "bookmark")
eventBus.dispatch("bookmarkremoved", {
source: this,
id: id
});
deleteAnnotationItem(id);
delete annotations[id];
reader.settings.session.deleteBookmark(id);
@ -103,16 +109,10 @@ PDFJS.reader.NotesController = function(book) {
};
var deleteAnnotationItem = function (id) {
var marker = book.renderer.doc.getElementById("note-" + id);
var item = document.getElementById(id);
if (item)
item.remove();
if (marker) {
marker.remove();
renumberMarkers();
}
};
/* items are HTML-representations of annotations */
@ -132,7 +132,8 @@ PDFJS.reader.NotesController = function(book) {
item.classList.add("note");
del.classList.add("item-delete", "item-control", "icon-delete");
edit.classList.add("item-edit", "item-control", "icon-rate_review");
link.classList.add("note-link", "icon-link2");
link.classList.add("note-link");
//link.classList.add("note-link", "icon-link2");
date.classList.add("item-date");
del.setAttribute("title", "delete");
edit.setAttribute("title", "edit");
@ -144,49 +145,55 @@ PDFJS.reader.NotesController = function(book) {
cancel.setAttribute("display", "none");
link.href = "#"+annotation.anchor;
link.textContent = "Page " + annotation.anchor;
link.onclick = function(){
reader.queuePage(annotation.anchor);
return false;
};
del.onclick = function() {
var id = this.parentNode.parentNode.getAttribute("id");
console.log("ID", id);
removeAnnotation(id);
};
save.onclick = function() {
var id = this.parentNode.parentNode.getAttribute("id");
var annotation = annotations[id];
var text = this.parentNode.parentNode.firstChild;
try {
annotation.body = text.textContent;
reader.updateAnnotation(annotation);
} catch (e) {
console.log("Updating annotation failed: " + e);
}
closeEditor(id);
};
if (!annotation.readonly) {
del.onclick = function() {
var id = this.parentNode.parentNode.getAttribute("id");
deleteAnnotationItem(id);
reader.removeAnnotation(id);
};
cancel.onclick = function () {
var id = this.parentNode.parentNode.getAttribute("id");
var text = this.parentNode.parentNode.firstChild;
text.textContent = annotations[id].body;
closeEditor(id);
};
save.onclick = function() {
var id = this.parentNode.parentNode.getAttribute("id");
var annotation = annotations[id];
var text = this.parentNode.parentNode.firstChild;
try {
annotation.body = text.textContent;
reader.updateAnnotation(annotation);
} catch (e) {
console.log("Updating annotation failed: " + e);
}
closeEditor(id);
};
edit.onclick = function() {
openEditor(this.parentNode.parentNode.getAttribute("id"));
};
cancel.onclick = function () {
var id = this.parentNode.parentNode.getAttribute("id");
var text = this.parentNode.parentNode.firstChild;
text.textContent = annotations[id].body;
closeEditor(id);
};
edit.onclick = function() {
openEditor(this.parentNode.parentNode.getAttribute("id"));
};
div.appendChild(cancel);
div.appendChild(save);
div.appendChild(del);
div.appendChild(edit);
}
div.appendChild(cancel);
div.appendChild(save);
div.appendChild(del);
div.appendChild(edit);
div.appendChild(link);
item.appendChild(text);
item.appendChild(date);
if (!annotation.readonly)
item.appendChild(date);
item.appendChild(div);
return item;
};
@ -250,25 +257,6 @@ PDFJS.reader.NotesController = function(book) {
renumberMarkers();
}
var renumberMarkers = function() {
for (var note in annotations) {
if (annotations.hasOwnProperty(note)) {
var chapter = renderer.currentChapter;
// var cfi = epubcfi.parse(annotations[note].anchor);
// if(cfi.spinePos === chapter.spinePos) {
// try {
// var marker = book.renderer.doc.getElementById("note-" + annotations[note].id);
// if (marker !== undefined) {
// marker.innerHTML = findIndex(annotations[note].id) + "[Reader]";
// }
// } catch(e) {
// console.log("renumbering of markers failed", annotations[note].anchor);
// }
// }
}
};
};
var markerEvents = function(item, txt){
var id = item.id;

View file

@ -12,6 +12,7 @@ PDFJS.reader.ReaderController = function() {
$fullscreen = $("#fullscreen"),
$bookmark = $("#bookmark"),
$note = $("#note"),
$nightmode = $("#nightmode"),
$rotate_left = $("#rotate_left"),
$rotate_right = $("#rotate_right"),
$clear_search = $("#clear_search");
@ -22,22 +23,14 @@ PDFJS.reader.ReaderController = function() {
var slideIn = function() {
if (reader.viewerResized) {
var currentPosition = book.getCurrentLocationCfi();
var currentPosition = settings.currentPage;
reader.viewerResized = false;
$main.removeClass('single');
$main.one("transitionend", function(){
book.gotoCfi(currentPosition);
});
}
};
var slideOut = function() {
var currentPosition = book.getCurrentLocationCfi();
var currentPosition = settings.currentPage;
reader.viewerResized = true;
$main.addClass('single');
$main.one("transitionend", function(){
book.gotoCfi(currentPosition);
});
};
var showLoader = function() {
@ -47,11 +40,6 @@ PDFJS.reader.ReaderController = function() {
var hideLoader = function() {
$loader.hide();
//-- If the book is using spreads, show the divider
// if(book.settings.spreads) {
// showDivider();
// }
};
var showDivider = function() {
@ -111,10 +99,7 @@ PDFJS.reader.ReaderController = function() {
$fullscreen.click();
break;
case 'toggleNight':
$metainfo.click();
break;
case 'toggleDay':
$use_custom_colors.click();
$nightmode.click();
break;
case 'rotateLeft':
$rotate_left.click();
@ -129,7 +114,10 @@ PDFJS.reader.ReaderController = function() {
reader.SearchController.nextMatch(true);
break;
case 'nextMatch':
reader.SearchController.nextMatch(false);
if (e.shiftKey)
reader.SearchController.nextMatch(true);
else
reader.SearchController.nextMatch(false);
break;
case 'clearSearch':
$clear_search.click();
@ -154,48 +142,18 @@ PDFJS.reader.ReaderController = function() {
$next.on("click", function(e){
//if(book.metadata.direction === "rtl") {
// reader.prevPage();
//} else {
reader.nextPage();
//}
reader.nextPage();
showActive($next);
e.preventDefault();
});
$prev.on("click", function(e){
//if(book.metadata.direction === "rtl") {
// reader.nextPage();
//} else {
reader.prevPage();
//}
reader.prevPage();
showActive($prev);
e.preventDefault();
});
/*
book.on("renderer:spreads", function(bool){
if(bool) {
showDivider();
} else {
hideDivider();
}
});
*/
// book.on("book:atStart", function(){
// $prev.addClass("disabled");
// });
//
// book.on("book:atEnd", function(){
// $next.addClass("disabled");
// });
return {
"slideOut" : slideOut,
"slideIn" : slideIn,

View file

@ -11,6 +11,7 @@ PDFJS.reader.SettingsController = function() {
$prev = $("#prev"),
$close = $("#close"),
$sidebarReflow = $('#sidebarReflow'),
$scrollToTop = $('#scrollToTop'),
$touch_nav = $("#touch_nav"),
$page_turn_arrows = $("#page_turn_arrows"),
$prev_arrow = $("#prev :first-child"),
@ -24,6 +25,17 @@ PDFJS.reader.SettingsController = function() {
$settings.removeClass('open');
};
if (settings.scrollToTop) {
$scrollToTop.prop('checked', true);
} else {
$scrollToTop.prop('checked', false);
}
$scrollToTop.off('click').on('click', function() {
settings.scrollToTop = !settings.scrollToTop;
settings.session.setDefault("scrollToTop", settings.scrollToTop);
});
if (settings.sidebarReflow) {
$sidebarReflow.prop('checked', true);
} else {

View file

@ -1,90 +1,27 @@
PDFJS.reader.StylesController = function (renderer) {
var reader = this,
book = this.book,
settings = reader.settings,
customStyles = reader.settings.customStyles,
activeStyles = reader.settings.activeStyles,
$viewer = $("#viewer"),
$day_example = $('#day_example'),
$night_example = $('#night_example'),
$font_example = $('#font_example'),
$page_width = $("#page_width"),
$day_background = $('#day_background'),
$day_color = $('#day_color'),
$night_background = $('#night_background'),
$night_color = $('#night_color'),
$use_custom_colors = $('#use_custom_colors'),
$nightshift = $('.nightshift'),
$custom_font_family = $('#custom_font_family'),
$font_family = $('#font_family'),
$custom_font_size = $('#custom_font_size'),
$font_size = $("#font_size"),
$custom_font_weight = $('#custom_font_weight'),
$font_weight = $("#font_weight"),
$maximize_page = $('#maximize_page');
$main = $("#main"),
$nightmode_form = $('#nightmode_form'),
$nightmode_reset = $('#nightmode_reset'),
$night_brightness = $('#night_brightness'),
$night_contrast = $('#night_contrast'),
$night_sepia = $('#night_sepia'),
$night_huerotate = $('#night_huerotate'),
$night_saturate = $('#night_saturate'),
$nightshift = $('.nightshift');
// register hook to refresh styles on chapter change
renderer.registerHook("beforeChapterDisplay", this.refreshStyles.bind(this), true);
this.addStyle("dayMode", "*", {
color: $day_color.val(),
background: $day_background.val()
});
this.addStyle("nightMode", "*", {
color: $night_color.val(),
background: $night_background.val()
filter: 'invert(1) sepia(' + $night_sepia.val() + ') hue-rotate(' + $night_huerotate.val() + 'deg) brightness(' + $night_brightness.val() + ') contrast(' + $night_contrast.val() + ') saturate(' + $night_saturate.val() + ')'
});
this.addStyle("fontFamily", "*", {
"font-family": $font_family.val()
});
this.addStyle("fontSize", "*", {
"font-size": $font_size.val() + '%'
});
this.addStyle("fontWeight", "*", {
"font-weight": $font_weight.val()
});
this.addStyle("pageWidth", "#viewer", {
"max-width": $page_width.val() + 'em'
});
this.addStyle("maximizePage", "#viewer", {
"margin": "auto",
"width": "100%",
"height": "95%",
"top": "5%"
});
this.addStyle("appleBugs", "document, html, body, p, span, div", {
"cursor": "pointer"
});
$day_example.css({
'background': customStyles.dayMode.rules.background,
'color': customStyles.dayMode.rules.color
});
$night_example.css({
'background': customStyles.nightMode.rules.background,
'color': customStyles.nightMode.rules.color
});
$font_example.css({
'font-size': customStyles.fontSize.rules["font-size"],
'font-family': customStyles.fontFamily.rules["font-family"],
'font-weight': customStyles.fontWeight.rules["font-weight"]
});
$font_family.val(customStyles.fontFamily.rules["font-family"]);
$font_size.val(parseInt(customStyles.fontSize.rules["font-size"]));
$font_weight.val(customStyles.fontWeight.rules["font-weight"]);
$page_width.val(parseInt(0 + parseInt(customStyles.pageWidth.rules["max-width"])));
// fix click-bug in apple products
if (navigator.userAgent.match(/(iPad|iPhone|iPod)/g))
activeStyles['appleBugs'] = true;
@ -93,19 +30,8 @@ PDFJS.reader.StylesController = function (renderer) {
if (!activeStyles.hasOwnProperty(style)) continue;
switch (style) {
case "dayMode":
$use_custom_colors.prop("checked", true);
break;
case "fontFamily":
$custom_font_family.prop("checked", true);
$font_family.prop('disabled',false);
break;
case "fontSize":
$custom_font_size.prop("checked", true);
$font_size.prop('disabled',false);
break;
case "maximizePage":
$maximize_page.prop("checked", true);
case "nightMode":
reader.ControlsController.setNightmodeIcon(true);
break;
case "appleBugs":
console.log("Apple mobile bugs detected, applying workarounds...");
@ -115,115 +41,52 @@ PDFJS.reader.StylesController = function (renderer) {
reader.enableStyle(customStyles[style]);
}
$day_background.off('change').on('change', function() {
customStyles.dayMode.rules.background = $day_background.val();
$day_example.css('background', customStyles.dayMode.rules.background);
reader.updateStyle(customStyles.dayMode);
$night_brightness.off('change').on('change', function() {
updateNightmode();
});
$day_color.off('change').on('change', function() {
customStyles.dayMode.rules.color = $day_color.val();
$day_example.css('color', customStyles.dayMode.rules.color);
reader.updateStyle(customStyles.dayMode);
$night_contrast.off('change').on('change', function() {
updateNightmode();
});
$night_background.off('change').on('change', function() {
customStyles.nightMode.rules.background = $night_background.val();
$night_example.css('background', customStyles.nightMode.rules.background);
$night_sepia.off('change').on('change', function() {
updateNightmode();
});
$night_huerotate.off('change').on('change', function() {
updateNightmode();
});
$night_saturate.off('change').on('change', function() {
updateNightmode();
});
$nightmode_form.off('reset').on('reset', function () {
setTimeout(function() {
updateNightmode();
}, 10);
});
var parseFilter = function(str, element) {
var re = new RegExp(element+'\\(([\\d.]+)\\S*\\)'),
value = null;
if (re.test(str))
value = str.match(re)[1];
return value;
};
var updateNightmode = function() {
customStyles.nightMode.rules.filter = 'invert(1) sepia(' + $night_sepia.val() + ') hue-rotate(' + $night_huerotate.val() + 'deg) brightness(' + $night_brightness.val() + ') contrast(' + $night_contrast.val() + ') saturate(' + $night_saturate.val() + ')';
reader.updateStyle(customStyles.nightMode);
});
};
$night_color.off('change').on('change', function() {
customStyles.nightMode.rules.color = $night_color.val();
$night_example.css('color', customStyles.nightMode.rules.color);
reader.updateStyle(customStyles.nightMode);
});
$use_custom_colors.off('change').on('change', function () {
if ($(this).prop('checked')) {
reader.enableStyle(customStyles.dayMode);
} else {
reader.disableStyle(customStyles.dayMode);
}
});
$nightshift.off('click').on('click', function () {
if (settings.nightMode) {
reader.disableStyle(customStyles.nightMode);
settings.nightMode = false;
} else {
reader.enableStyle(customStyles.nightMode);
settings.nightMode = true;
}
});
$page_width.off('change').on("change", function () {
customStyles.pageWidth.rules["page-width"] = $(this).val() + "em";
reader.updateStyle(customStyles.pageWidth);
$viewer.css("max-width", customStyles.pageWidth.rules["page-width"]);
});
$custom_font_family.off('click').on('click', function() {
if ($(this).prop('checked')) {
$font_family.prop('disabled',false);
reader.enableStyle(customStyles.fontFamily);
} else {
$font_family.prop('disabled',true);
reader.disableStyle(customStyles.fontFamily);
}
});
$custom_font_size.off('click').on('click', function() {
if ($(this).prop('checked')) {
$font_size.prop('disabled',false);
reader.enableStyle(customStyles.fontSize);
} else {
$font_size.prop('disabled',true);
reader.disableStyle(customStyles.fontSize);
}
});
$custom_font_weight.off('click').on('click', function() {
if ($(this).prop('checked')) {
$font_weight.prop('disabled',false);
reader.enableStyle(customStyles.fontWeight);
} else {
$font_weight.prop('disabled',true);
reader.disableStyle(customStyles.fontWeight);
}
});
$maximize_page.off('click').on('click', function() {
if ($(this).prop('checked')) {
reader.enableStyle(customStyles.maximizePage);
} else {
reader.disableStyle(customStyles.maximizePage);
}
});
$font_size.off('change').on('change', function() {
$font_example.css('font-size', $(this).val() + '%');
customStyles.fontSize.rules["font-size"] = $(this).val() + '%';
reader.updateStyle(customStyles.fontSize);
});
$font_weight.off('change').on('change', function() {
customStyles.fontWeight.rules["font-weight"] = $(this).val();
$font_example.css('font-weight', $(this).val());
reader.updateStyle(customStyles.fontWeight);
});
$font_family.off('change').on('change', function() {
customStyles.fontFamily.rules["font-family"] = $(this).val();
$font_example.css('font-family', $(this).val());
reader.updateStyle(customStyles.fontFamily);
});
$page_width.off('change').on("change", function () {
customStyles.pageWidth.rules["page-width"] = $(this).val() + "em";
reader.updateStyle(customStyles.pageWidth);
$viewer.css("max-width", customStyles.pageWidth.rules["page-width"]);
});
$night_brightness.val(parseFilter(customStyles.nightMode.rules.filter,"brightness"));
$night_contrast.val(parseFilter(customStyles.nightMode.rules.filter,"contrast"));
$night_sepia.val(parseFilter(customStyles.nightMode.rules.filter,"sepia"));
$night_huerotate.val(parseFilter(customStyles.nightMode.rules.filter,"hue-rotate"));
$night_saturate.val(parseFilter(customStyles.nightMode.rules.filter,"saturate"));
return {
};

View file

@ -34,7 +34,7 @@ PDFJS.reader.TocController = function() {
if (isVisible(elements[i])) {
pagenum = elements[i].getAttribute("data-pagenum");
elements[i].removeAttribute("data-pagenum");
reader.getThumb(pagenum, true);
reader.getThumb(parseInt(pagenum), true);
count++;
}
}