diff --git a/files_reader/templates/settings-personal.php b/files_reader/templates/settings-personal.php
new file mode 100644
index 0000000..f6c5880
--- /dev/null
+++ b/files_reader/templates/settings-personal.php
@@ -0,0 +1,42 @@
+
+
+
+
+
t('Select file types for which Reader should be the default viewer.')); ?>
+
+
+ />
+
+
+
+
+ />
+
+
+
+ />
+
+
+
diff --git a/files_reader/vendor/pdfjs/controllers/.bookmarks_controller.js.swp b/files_reader/vendor/pdfjs/controllers/.bookmarks_controller.js.swp
deleted file mode 100644
index 216f4bb..0000000
Binary files a/files_reader/vendor/pdfjs/controllers/.bookmarks_controller.js.swp and /dev/null differ
diff --git a/files_reader/vendor/pdfjs/controllers/.progress_controller.js.swp b/files_reader/vendor/pdfjs/controllers/.progress_controller.js.swp
deleted file mode 100644
index b64e592..0000000
Binary files a/files_reader/vendor/pdfjs/controllers/.progress_controller.js.swp and /dev/null differ
diff --git a/files_reader/vendor/pdfjs/controllers/bookmarks_controller.js b/files_reader/vendor/pdfjs/controllers/bookmarks_controller.js
index 6eda789..87a974d 100644
--- a/files_reader/vendor/pdfjs/controllers/bookmarks_controller.js
+++ b/files_reader/vendor/pdfjs/controllers/bookmarks_controller.js
@@ -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
};
};
diff --git a/files_reader/vendor/pdfjs/controllers/controls_controller.js b/files_reader/vendor/pdfjs/controllers/controls_controller.js
index 9afdeed..014ccf2 100644
--- a/files_reader/vendor/pdfjs/controllers/controls_controller.js
+++ b/files_reader/vendor/pdfjs/controllers/controls_controller.js
@@ -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
diff --git a/files_reader/vendor/pdfjs/controllers/notes_controller.js b/files_reader/vendor/pdfjs/controllers/notes_controller.js
index 3db8e9a..1e5c76b 100644
--- a/files_reader/vendor/pdfjs/controllers/notes_controller.js
+++ b/files_reader/vendor/pdfjs/controllers/notes_controller.js
@@ -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;
diff --git a/files_reader/vendor/pdfjs/controllers/reader_controller.js b/files_reader/vendor/pdfjs/controllers/reader_controller.js
index a02b29e..9dd8051 100644
--- a/files_reader/vendor/pdfjs/controllers/reader_controller.js
+++ b/files_reader/vendor/pdfjs/controllers/reader_controller.js
@@ -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,
diff --git a/files_reader/vendor/pdfjs/controllers/settings_controller.js b/files_reader/vendor/pdfjs/controllers/settings_controller.js
index 6b740a4..8d9c6f9 100644
--- a/files_reader/vendor/pdfjs/controllers/settings_controller.js
+++ b/files_reader/vendor/pdfjs/controllers/settings_controller.js
@@ -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 {
diff --git a/files_reader/vendor/pdfjs/controllers/styles_controller.js b/files_reader/vendor/pdfjs/controllers/styles_controller.js
index 16bf5ea..8c36faa 100644
--- a/files_reader/vendor/pdfjs/controllers/styles_controller.js
+++ b/files_reader/vendor/pdfjs/controllers/styles_controller.js
@@ -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 {
};
diff --git a/files_reader/vendor/pdfjs/controllers/toc_controller.js b/files_reader/vendor/pdfjs/controllers/toc_controller.js
index 1f50595..771f2db 100644
--- a/files_reader/vendor/pdfjs/controllers/toc_controller.js
+++ b/files_reader/vendor/pdfjs/controllers/toc_controller.js
@@ -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++;
}
}
diff --git a/files_reader/vendor/pdfjs/css/main.css b/files_reader/vendor/pdfjs/css/main.css
index 0a98133..6787c35 100644
--- a/files_reader/vendor/pdfjs/css/main.css
+++ b/files_reader/vendor/pdfjs/css/main.css
@@ -20,9 +20,12 @@ fieldset {
body {
background: #4e4e4e;
overflow: hidden;
- font-style:
}
+.night {
+ filter: opacity(80%) invert(100%);
+}
+
#main {
position: absolute;
width: 100%;
@@ -31,8 +34,9 @@ body {
border-radius: 5px;
background: #fff;
overflow: hidden;
- -webkit-transition: -webkit-transform .4s, width .2s;
- -moz-transition: -webkit-transform .4s, width .2s;
+ -webkit-transition: -webkit-transform .4s, width .2s, filter .2s;
+ -moz-transition: -webkit-transform .4s, width .2s, filter .2s;
+ transition: transform .4s, width .2s, filter .2s;
/*
-moz-box-shadow: inset 0 0 50px rgba(0,0,0,.1);
-webkit-box-shadow: inset 0 0 50px rgba(0,0,0,.1);
@@ -136,8 +140,6 @@ body {
#metainfo {
position: fixed;
- /* width: 80%;
- left: 10%; */
width: 50%;
width: calc(100% - 7.5em);
left: 1.5em;
@@ -146,12 +148,14 @@ body {
height: 1em;
overflow: hidden;
text-align: center;
+ font-size: 1.2em;
}
#title-controls {
right: 0;
}
+#nightmode,
#zoom_icon,
#rotate_icon,
#rotate_left,
@@ -164,6 +168,11 @@ body {
overflow: hidden;
}
+#nightmode {
+ padding 0 .5em;
+}
+
+#nightmode:hover,
#zoom_icon:hover,
#rotate_icon:hover,
#rotate_left:hover,
@@ -172,6 +181,7 @@ body {
border: 1px rgba(0,0,0,.2) solid;
}
+#nightmode:active,
#zoom_icon:active,
#rotate_icon:active,
#rotate_left:active,
@@ -401,12 +411,6 @@ body {
@media only screen and (max-width: 1040px) {
-/*
- #viewer{
- width: 50%;
- margin-left: 25%;
- }
- */
#divider,
#divider.show {
display: none;
@@ -414,12 +418,6 @@ body {
}
@media only screen and (max-width: 900px) {
-/*
- #viewer{
- width: 60%;
- margin-left: 20%;
- }
-*/
#prev {
padding-left: 20px;
}
@@ -430,16 +428,6 @@ body {
}
@media only screen and (max-width: 550px) {
-/*
- #viewer{
- width: 80%;
- margin-left: 10%;
- }
- #viewer {
- width: 95%;
- }
-
- */
#prev {
padding-left: 0;
}
@@ -454,40 +442,10 @@ body {
overflow: hidden;
}
- /*
- #main {
- -webkit-transform: translate(0, 0);
- -moz-transform: translate(0, 0);
- -webkit-transition: -webkit-transform .3s;
- -moz-transition: -moz-transform .3s;
+ #metainfo {
+ width: unset;
+ display: flex;
+ padding-left: 2em;
}
-
- #main.closed {
- -webkit-transform: translate(260px, 0);
- -moz-transform: translate(260px, 0);
- }
- */
- #titlebar {
- /* font-size: 16px; */
- /* margin: 0 50px 0 50px; */
- }
-
- #metainfo span {
- font-size: 0.5em;
- }
- /*
- #tocView {
- width: 260px;
- }
-
- #tocView li {
- font-size: 12px;
- }
-
- #tocView > ul{
- padding-left: 10px;
- -webkit-padding-start:;
- }
- */
}
diff --git a/files_reader/vendor/pdfjs/pdf.reader.js b/files_reader/vendor/pdfjs/pdf.reader.js
index 510d3d7..d5edc49 100644
--- a/files_reader/vendor/pdfjs/pdf.reader.js
+++ b/files_reader/vendor/pdfjs/pdf.reader.js
@@ -42,9 +42,10 @@ PDFJS.Reader = function(bookPath, _options) {
cssZoomOnly: false, // true || false, only zoom using CSS, render document at 100% size
textSelect: true, // true || false, add selectable text layer
annotationLayer: true, // true || false. show PDF annotations
- mergeAnnotations: true,// true || false, merge PDF annotations into bookmarks/annotations
+ mergeAnnotations: false,// true || false, merge PDF annotations into bookmarks/annotations
doubleBuffer: true, // true || false, draw to off-screen canvas
cacheNext: true, // true || false, pre-render next page (by creathing thumbnail))
+ scrollToTop: false, // true || false, scroll to top of page on page turn
numPages: 0,
currentPage: 1,
scale: DEFAULT_SCALE,
@@ -73,17 +74,15 @@ PDFJS.Reader = function(bookPath, _options) {
83: 'toggleSidebar',// s
84: 'toggleTitlebar', // t
68: 'toggleDay', // d
- //78: 'toggleNight', // n
+ 78: 'toggleNight', // n
55: 'search', // '/'
80: 'previousMatch', // p
- 78: 'nextMatch', // n
70: 'toggleFullscreen', // f
27: 'closeSidebar', // esc
114: 'nextMatch' // F3
},
nightMode: false,
dayMode: false,
- maxWidth: 72,
pageArrows: false,
annotations: {},
customStyles: {},
@@ -113,6 +112,7 @@ PDFJS.Reader = function(bookPath, _options) {
this.id = id || PDFJS.core.uuid();
this.type = type;
this.date = Date.now();
+ this.readonly = true;
this.edited = this.date;
this.anchor = anchor;
this.body = body;
@@ -126,6 +126,7 @@ PDFJS.Reader = function(bookPath, _options) {
this.extra = extra || null;
};
+ // resource list for single-page and 2-page display
this.resourcelst = [
{
canvas: document.getElementById("left"),
@@ -153,6 +154,7 @@ PDFJS.Reader = function(bookPath, _options) {
}
];
+ // list of pages in the render queue which should be discarded
this.cancelPage = {};
this.renderQueue = false;
@@ -194,9 +196,9 @@ PDFJS.Reader = function(bookPath, _options) {
}
- //this.restoreDefaults(this.settings.session.defaults);
- //this.restorePreferences(this.settings.session.preferences);
- //this.restoreAnnotations(this.settings.session.annotations);
+ this.restoreDefaults(this.settings.session.defaults);
+ this.restorePreferences(this.settings.session.preferences);
+ this.restoreAnnotations(this.settings.session.annotations);
this.sideBarOpen = false;
this.viewerResized = false;
this.pageNumPending = null;
@@ -221,16 +223,12 @@ PDFJS.Reader = function(bookPath, _options) {
function(_book) {
reader.book = book = _book;
- //console.log(book);
reader.settings.numPages = reader.book.numPages;
document.getElementById('total_pages').textContent = reader.settings.numPages;
- console.log(reader.settings);
- console.log("numPages",reader.settings.numPages);
- console.log("cursor",reader.settings.session.cursor);
if(!$.isEmptyObject(reader.settings.session.cursor)
&& (reader.settings.session.cursor.value !== null)
- && (reader.settings.session.cursor.value < reader.settings.numPages)) {
- console.log("setting cursor:", reader.settings.session.cursor);
+ && (reader.settings.session.cursor.value > 0)
+ && (reader.settings.session.cursor.value <= reader.settings.numPages)) {
reader.settings.currentPage = parseInt(reader.settings.session.cursor.value);
}
@@ -254,6 +252,7 @@ PDFJS.Reader = function(bookPath, _options) {
reader.SettingsController = PDFJS.reader.SettingsController.call(reader, book);
reader.ControlsController = PDFJS.reader.ControlsController.call(reader, book);
reader.SidebarController = PDFJS.reader.SidebarController.call(reader, book);
+ reader.StyleController = PDFJS.reader.StylesController.call(reader, book);
reader.queuePage(reader.settings.currentPage);
reader.ReaderController.hideLoader();
@@ -263,15 +262,14 @@ PDFJS.Reader = function(bookPath, _options) {
reader.OutlineController = PDFJS.reader.OutlineController.call(reader, outline);
});
reader.book.getMetadata().then(function (metadata) {
- console.log("metadata", metadata);
reader.settings.pdfMetadata = metadata;
});
reader.book.getAttachments().then(function (attachments) {
- console.log("attachments", attachments);
+ // console.log("attachments", attachments);
});
reader.book.getStats().then(function (stats) {
- console.log("stats", stats);
+ // console.log("stats", stats);
});
// BookmarksController depends on NotesController so load NotesController first
@@ -289,7 +287,8 @@ PDFJS.Reader = function(bookPath, _options) {
for (var annotation in annotations) {
if (annotations.hasOwnProperty(annotation) && !annotations[annotation].parentId) {
var ann = annotations[annotation],
- type = (ann.contents && ann.contents !== "") ? "annotation" : "bookmark",
+ //type = (ann.contents && ann.contents !== "") ? "annotation" : "bookmark",
+ type = "annotation",
item;
item = new reader.Annotation(
@@ -298,13 +297,10 @@ PDFJS.Reader = function(bookPath, _options) {
ann.contents,
ann.id || PDFJS.core.uuid()
);
- console.log(ann);
- if (type === "annotation") {
- reader.NotesController.addItem(item);
- } else {
- reader.BookmarksController.addItem(item);
- }
+ item.body = ann.subtype.toString() + ":" + ann.id.toString();
+
+ reader.NotesController.addItem(item);
}
}
}
@@ -342,6 +338,108 @@ PDFJS.Reader = function(bookPath, _options) {
return this;
};
+
+// Annotations - bookmarks and PDF annotations
+PDFJS.Reader.prototype.pageToId = function (pageNum) {
+ return "page_" + pageNum;
+};
+
+PDFJS.Reader.prototype.addAnnotation = function (note) {
+ this.settings.annotations[note.id] = note;
+ this.settings.session.setBookmark(note.id, note.anchor, note.type, note);
+};
+
+PDFJS.Reader.prototype.removeAnnotation = function (id) {
+ if (this.settings.annotations[id] !== undefined) {
+ var type = this.settings.annotations[id].type;
+ this.eventBus.dispatch(type + "removed", {
+ source: this,
+ id: id
+ });
+ this.settings.session.deleteBookmark(id);
+ delete this.settings.annotations[id];
+ }
+};
+
+PDFJS.Reader.prototype.updateAnnotation = function (note) {
+ note.edited = Date.now();
+ this.settings.annotations[note.id] = note;
+ this.settings.session.setBookmark(note.id, note.anchor, note.type, note);
+};
+
+PDFJS.Reader.prototype.clearAnnotations = function(type) {
+ if (type) {
+ for (var id in this.settings.annotations) {
+ if (this.settings.annotations.hasOwnProperty(id) && this.settings.annotations[id].type === type)
+ this.removeAnnotation(id);
+ }
+ }
+};
+
+PDFJS.Reader.prototype.isBookmarked = function (id) {
+ return (this.settings.annotations[id] !== undefined);
+};
+
+PDFJS.Reader.prototype.addBookmark = function(pageNum) {
+ var id = this.pageToId(pageNum);
+
+ var text = " ",
+ bookmark;
+
+ // TODO: get text content around bookmark location, needed for annotation editor (not yet implemented)
+ for (var i = 0; i <= 1; i++) {
+ if (this.resourcelst[i].pageNum == pageNum
+ && this.resourcelst[i].textdiv.textContent !== null) {
+ text = this.ellipsize(this.resourcelst[i].textdiv.textContent);
+ }
+ }
+
+ if (this.isBookmarked(id)) {
+ bookmark = this.getAnnotation(id);
+ this.updateAnnotation(bookmark);
+ } else {
+ bookmark = new this.Annotation("bookmark", pageNum, text, id);
+ bookmark.readonly = false;
+ this.addAnnotation(bookmark);
+ }
+
+ this.eventBus.dispatch("bookmarkcreated", {
+ source: this,
+ id: id
+ });
+
+ return bookmark;
+};
+
+PDFJS.Reader.prototype.updateBookmark = function (bookmark) {
+ this.updateAnnotation(bookmark);
+};
+
+PDFJS.Reader.prototype.removeBookmark = function (pageNum) {
+ var id = this.pageToId(pageNum);
+ this.removeAnnotation(id);
+};
+
+PDFJS.Reader.prototype.clearBookmarks = function () {
+ this.clearAnnotations("bookmark");
+};
+
+PDFJS.Reader.prototype.getAnnotation = function (id) {
+ return this.settings.annotations[id];
+};
+
+PDFJS.Reader.prototype.restoreAnnotations = function (annotations) {
+ if (annotations !== {}) {
+ for (var note in this.settings.session.annotations) {
+ if (annotations.hasOwnProperty(note) && annotations[note].content !== null) {
+ this.settings.annotations[annotations[note].name] = annotations[note].content;
+ }
+ }
+ }
+};
+
+// Render thumbnail, page, etc.
+
PDFJS.Reader.prototype.getThumb = function (pageNum, insert) {
var reader = this,
@@ -513,6 +611,7 @@ PDFJS.Reader.prototype.renderPage = function(pageNum) {
swap_orientation,
double_buffer,
cache_next,
+ scroll_to_top,
pageShift;
max_view_width = window.innerWidth;
@@ -561,6 +660,7 @@ PDFJS.Reader.prototype.renderPage = function(pageNum) {
fraction = reader.approximateFraction(outputscale);
double_buffer = reader.settings.doubleBuffer;
cache_next = reader.settings.cacheNext;
+ scroll_to_top = reader.settings.scrollToTop;
textdiv.innerHTML = "";
annotationdiv.innerHTML = "";
@@ -591,7 +691,6 @@ PDFJS.Reader.prototype.renderPage = function(pageNum) {
page.getAnnotations().then(function (annotations) {
console.log("annotations", annotations);
});
- //console.log(page);
page_rotation = page.rotate;
rotation = (page_rotation + reader.settings.rotation) % 360;
initial_viewport = page.getViewport(1, rotation);
@@ -713,7 +812,6 @@ PDFJS.Reader.prototype.renderPage = function(pageNum) {
/* annotationLayer */
if (reader.settings.annotationLayer) {
annotationdiv.style.width = reader.roundToDivide(viewport.width, fraction[1]) + 'px';
- //annotationdiv.style.height = reader.roundToDivide(viewport.height, fraction[1]) + 'px';
annotationdiv.style.height = 0;
offset = $(canvas).offset();
$(annotationdiv).offset({
@@ -752,12 +850,18 @@ PDFJS.Reader.prototype.renderPage = function(pageNum) {
renderTask.promise.then(
function pdfPageRenderCallback (something) {
if (reader.cancelPage[pageNum] === undefined) {
+ if (scroll_to_top)
+ document.getElementById('viewer').scrollTo(0,0);
if (double_buffer)
ctx.drawImage(oscanvas, 0, 0);
if (textLayer)
textLayer.render(reader.settings.textRenderDelay);
if (cache_next)
reader.getThumb(parseInt(pageNum + pageShift), true);
+ reader.eventBus.dispatch("renderer:pagechanged", {
+ source: this,
+ pageNum: pageNum
+ });
}
},
function pdfPageRenderError(error) {
@@ -788,6 +892,11 @@ PDFJS.Reader.prototype.queuePage = function(page) {
oddPageRight = reader.settings.oddPageRight,
pageShift;
+ if (page < 1)
+ page = 1;
+ if (page > this.settings.numPages)
+ page = this.settings.numPages;
+
if (zoom === "spread") {
pageShift = 2;
if (oddPageRight === true) {
@@ -861,6 +970,20 @@ PDFJS.Reader.prototype.defaults = function (obj) {
return obj;
};
+// Defaults and Preferences
+// Preferences are per-book settings and can override defaults
+PDFJS.Reader.prototype.restoreDefaults = function (defaults) {
+ for (var i=0; i < defaults.length; i++) {
+ this.settings[defaults[i].name] = defaults[i].value;
+ }
+};
+
+PDFJS.Reader.prototype.restorePreferences = function (preferences) {
+ for (var i=0; i < preferences.length; i++) {
+ this.settings[preferences[i].name] = preferences[i].value;
+ }
+};
+
PDFJS.Reader.prototype.setScale = function (scale) {
};
@@ -1007,11 +1130,9 @@ PDFJS.Reader.prototype.bindLink = function (element, item) {
return;
} else {
- //element.href = reader.getDestinationHash(destination);
element.href = linkService.getDestinationHash(destination);
element.onclick = function () {
if (destination) {
- //reader._navigateTo(destination);
linkService.navigateTo(destination);
}
@@ -1082,3 +1203,95 @@ PDFJS.Reader.prototype.isVisible = function (element) {
return visible;
};
+PDFJS.Reader.prototype.addStyleSheet = function (_id, _parentNode) {
+ var id = _id,
+ parentNode = _parentNode || document.head,
+ style = document.createElement("style");
+ // WebKit hack
+ style.appendChild(document.createTextNode(""));
+ style.setAttribute("id", id);
+ parentNode.appendChild(style);
+ return style.sheet;
+};
+
+PDFJS.Reader.prototype.getStyleSheet = function (id, _parentNode) {
+ if (id !== undefined) {
+ var parentNode = _parentNode || document.head;
+ var style = $(parentNode).find("style#" + id);
+ if (style.length) return style[0];
+ }
+};
+
+PDFJS.Reader.prototype.addCSSRule = function (sheet, selector, rules, index) {
+ if (index === undefined) index = 0;
+ if("insertRule" in sheet) {
+ sheet.insertRule(selector + "{" + rules + "}", index);
+ } else if ("addRule" in sheet) {
+ sheet.addRule(selector, rules, index);
+ }
+};
+
+PDFJS.Reader.prototype.addStyle = function (name, selector, rules, extra) {
+ if (undefined === this.settings.customStyles[name]) {
+ this.settings.customStyles[name] = new this.Style(name, selector, rules, extra);
+ this.settings.session.setDefault("customStyles",this.settings.customStyles)
+ }
+};
+
+PDFJS.Reader.prototype.enableStyle = function (style) {
+ var currentMain = this.getStyleSheet(style.name);
+ if (currentMain) $(currentMain).remove();
+ var rules = "",
+ sheetMain = this.addStyleSheet(style.name);
+ for (var clause in style.rules) {
+ rules += clause + ":" + style.rules[clause] + "!important;";
+ }
+ this.addCSSRule(sheetMain, (style.selector === "*") ? "#main" : style.selector, rules, 0);
+ this.settings.activeStyles[style.name] = true;
+
+ this.settings.session.setDefault("activeStyles", this.settings.activeStyles);
+};
+
+PDFJS.Reader.prototype.disableStyle = function (style) {
+ var currentMain = this.getStyleSheet(style.name, document.head);
+ if (currentMain) $(currentMain).remove();
+ if (this.settings.activeStyles[style.name]) {
+ delete this.settings.activeStyles[style.name];
+ this.settings.session.setDefault("activeStyles", this.settings.activeStyles);
+ }
+};
+
+PDFJS.Reader.prototype.updateStyle = function (style) {
+ this.settings.session.setDefault("customStyles",this.settings.customStyles)
+ var current = this.getStyleSheet(style.name);
+ if (current) this.enableStyle(style);
+};
+
+PDFJS.Reader.prototype.deleteStyle = function (style) {
+ this.disableStyle(style);
+ delete this.customStyles[style.name];
+ this.settings.session.setDefault("customStyles",this.settings.customStyles);
+};
+
+PDFJS.Reader.prototype.refreshStyles = function (callback) {
+ var activeStyles = this.settings.activeStyles,
+ customStyles = this.settings.customStyles;
+
+ for (var style in activeStyles) {
+ if (!activeStyles.hasOwnProperty(style)) continue;
+
+ var rules = "",
+ sheet = this.addStyleSheet(style);
+
+ for (var clause in customStyles[style].rules) {
+ if (!customStyles[style].rules.hasOwnProperty(clause)) continue;
+ rules += clause + ":" + customStyles[style].rules[clause] + "!important;";
+ }
+
+ this.addCSSRule(sheet, customStyles[style].selector, rules, 0);
+ }
+
+ if (callback) callback();
+};
+
+