mirror of
https://github.com/Yetangitu/owncloud-apps.git
synced 2025-10-02 14:49:17 +02:00
files_reader: experimental PDF support, Work In Progress
This commit is contained in:
parent
9865f94e70
commit
ed0d8ae717
27 changed files with 3649 additions and 2 deletions
Binary file not shown.
|
@ -119,10 +119,19 @@
|
|||
return actionHandler(fileName, 'application/x-cbr', context);
|
||||
}
|
||||
});
|
||||
|
||||
fileActions.registerAction({
|
||||
name: 'view-pdf',
|
||||
displayName: 'View',
|
||||
mime: 'application/pdf',
|
||||
permissions: OC.PERMISSION_READ,
|
||||
actionHandler: function(fileName, context) {
|
||||
return actionHandler(fileName, 'application/pdf', context);
|
||||
}
|
||||
});
|
||||
|
||||
fileActions.setDefault('application/epub+zip', 'view-epub');
|
||||
fileActions.setDefault('application/x-cbr', 'view-cbr');
|
||||
fileActions.setDefault('application/pdf', 'view-pdf');
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -94,6 +94,9 @@ document.onreadystatechange = function () {
|
|||
case 'application/x-cbr':
|
||||
renderCbr(file, options);
|
||||
break;
|
||||
case 'application/pdf':
|
||||
renderPdf(file, options);
|
||||
break;
|
||||
default:
|
||||
console.log(type + ' is not supported by Reader');
|
||||
}
|
||||
|
@ -134,6 +137,14 @@ document.onreadystatechange = function () {
|
|||
|
||||
var reader = cbReader(file, options);
|
||||
}
|
||||
|
||||
// start pdf.js renderer
|
||||
function renderPdf(file, options) {
|
||||
PDFJS.filePath = "vendor/pdfjs/";
|
||||
PDFJS.workerSrc = options.session.basePath + 'vendor/pdfjs/lib/pdf.worker.js';
|
||||
|
||||
var reader = pdfReader(file, options);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -74,7 +74,8 @@ class PageController extends Controller {
|
|||
public function showReader() {
|
||||
$templates= [
|
||||
'application/epub+zip' => 'epubreader',
|
||||
'application/x-cbr' => 'cbreader'
|
||||
'application/x-cbr' => 'cbreader',
|
||||
'application/pdf' => 'pdfreader'
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
BIN
files_reader/templates/.pdfreader.php.swp
Normal file
BIN
files_reader/templates/.pdfreader.php.swp
Normal file
Binary file not shown.
302
files_reader/templates/pdfreader.php
Normal file
302
files_reader/templates/pdfreader.php
Normal file
|
@ -0,0 +1,302 @@
|
|||
<?php
|
||||
/** @var array $_ */
|
||||
/** @var OCP\IURLGenerator $urlGenerator */
|
||||
$urlGenerator = $_['urlGenerator'];
|
||||
$downloadLink = $_['downloadLink'];
|
||||
$fileId = $_['fileId'];
|
||||
$fileName = $_['fileName'];
|
||||
$fileType = $_['fileType'];
|
||||
$scope = $_['scope'];
|
||||
$cursor = $_['cursor'];
|
||||
$defaults = $_['defaults'];
|
||||
$preferences = $_['preferences'];
|
||||
$metadata = $_['metadata'];
|
||||
$annotations = $_['annotations'];
|
||||
$title = htmlentities(basename($dllink));
|
||||
$revision = '0071';
|
||||
$version = \OCP\App::getAppVersion('files_reader') . '.' . $revision;
|
||||
|
||||
/* Mobile safari, the new IE6 */
|
||||
$idevice = (strstr($_SERVER['HTTP_USER_AGENT'],'iPhone')
|
||||
|| strstr($_SERVER['HTTP_USER_AGENT'],'iPad')
|
||||
|| strstr($_SERVER['HTTP_USER_AGENT'],'iPod'));
|
||||
|
||||
/* Owncloud currently does not implement CSPv3, remove this test when it does */
|
||||
$nonce = class_exists('\OC\Security\CSP\ContentSecurityPolicyNonceManager')
|
||||
? \OC::$server->getContentSecurityPolicyNonceManager()->getNonce()
|
||||
: 'nonce_not_implemented';
|
||||
?>
|
||||
|
||||
<html dir="ltr">
|
||||
<head class="session" data-nonce='<?php p($nonce);?>' data-downloadlink='<?php print_unescaped($downloadLink);?>' data-fileid='<?php print_unescaped($fileId);?>' data-filetype='<?php print_unescaped($fileType);?>' data-filename='<?php print_unescaped($fileName);?>' data-version='<?php print_unescaped($version);?>' data-basepath='<?php p($urlGenerator->linkTo('files_reader',''));?>' data-scope='<?php print_unescaped($scope);?>' data-cursor='<?php print_unescaped($cursor);?>' data-defaults='<?php print_unescaped($defaults);?>' data-preferences='<?php print_unescaped($preferences);?>' data-metadata='<?php print_unescaped($metadata);?>' data-annotations='<?php print_unescaped($annotations);?>'>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<base href="<?php p($urlGenerator->linkTo('files_reader',''));?>">
|
||||
<title>
|
||||
<?php p($_['title']);?>
|
||||
</title>
|
||||
<link rel="shortcut icon" href="img/book.png">
|
||||
<link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_reader', 'vendor/icomoon/style.css')) ?>?v=<?php p($version) ?>">
|
||||
<link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/css/main.css')) ?>?v=<?php p($version) ?>">
|
||||
<link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/css/sidebar.css')) ?>?v=<?php p($version) ?>">
|
||||
<link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/css/popup.css')) ?>?v=<?php p($version) ?>">
|
||||
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/epubjs/libs/jquery.min.js')) ?>?v=<?php p($version) ?>"> </script>
|
||||
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/bartaz/jquery.highlight.js')) ?>?v=<?php p($version) ?>"> </script>
|
||||
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/jquery/put-delete.js')) ?>?v=<?php p($version) ?>"> </script>
|
||||
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/sindresorhus/screenfull.js')) ?>?v=<?php p($version) ?>"> </script>
|
||||
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/lib/pdf.js')) ?>?v=<?php p($version) ?>"> </script>
|
||||
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/pdf.reader.js')) ?>?v=<?php p($version) ?>"> </script>
|
||||
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/controllers/reader_controller.js')) ?>?v=<?php p($version) ?>"> </script>
|
||||
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/controllers/sidebar_controller.js')) ?>?v=<?php p($version) ?>"> </script>
|
||||
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/controllers/settings_controller.js')) ?>?v=<?php p($version) ?>"> </script>
|
||||
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/controllers/controls_controller.js')) ?>?v=<?php p($version) ?>"> </script>
|
||||
<?php if ($idevice): ?>
|
||||
<link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/css/idevice.css')) ?>?v=<?php p($version) ?>">
|
||||
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/bgrins/spectrum.js')) ?>?v=<?php p($version) ?>"> </script>
|
||||
<link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_reader', 'vendor/bgrins/spectrum.css')) ?>?v=<?php p($version) ?>">
|
||||
<?php endif; ?>
|
||||
|
||||
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'js/ready.js')) ?>?v=<?php p($version) ?>"> </script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="outerContainer">
|
||||
|
||||
<!-- sidebar -->
|
||||
|
||||
<div id="sidebar" class="sidebar">
|
||||
<div id="panels" class="panels">
|
||||
<div class="pull-left">
|
||||
<button id="show-Toc" class="show_view icon-format_list_numbered open" title="Table of Contents" data-view="Toc"></button>
|
||||
<button id="show-Bookmarks" class="show_view icon-turned_in" title="Bookmarks" data-view="Bookmarks"></button>
|
||||
<button id="show-Search" class="show_view icon-search" title="Search" data-view="Search"></button>
|
||||
<button id="show-Notes" class="show_view icon-comment" title="Notes" data-view="Notes"></button>
|
||||
<button id="show-Settings" class="show_view icon-settings" title="Settings" data-view="Settings"></button>
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
<button id="hide-Sidebar" class="close_sidebar icon-arrow-left2" title="Close sidebar"></button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="views">
|
||||
<div id="tocView" class="toc-view view open">
|
||||
</div>
|
||||
<div id="bookmarksView" class="bookmarks-view view">
|
||||
<ul id="bookmarks" class="bookmarks">
|
||||
</ul>
|
||||
</div>
|
||||
<div id="searchView" class="view search-view">
|
||||
<div>
|
||||
<div class="search-input">
|
||||
<input id="searchBox" class="searchbox" placeholder="search..." type="input">
|
||||
<span title="Clear">x</span>
|
||||
<button id="clear_search" class="icon-cancel pull-right" title="Clear"></button>
|
||||
</div>
|
||||
<ul id="searchResults" class="search-results">
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div id="notesView" class="notes-view view">
|
||||
<div>
|
||||
<div class="notes-input">
|
||||
<textarea id="note-text" class="note-text" placeholder="Write note, press 'marker' button and select position in text to link note."></textarea>
|
||||
<button id="note-anchor" class="note-anchor icon-room pull-right"></button>
|
||||
</div>
|
||||
<ol id="notes" class="notes">
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
<div id="settingsView" class="settings-view view">
|
||||
<fieldset class="settings-container" name="font-settings">
|
||||
<legend>font</legend>
|
||||
<div class="control-group">
|
||||
<div>
|
||||
<input type="checkbox" id="custom_font_family" name="font_family">
|
||||
<label for="custom_font_family">custom font</label>
|
||||
<select id="font_family" disabled="">
|
||||
<option value="verdana, trebuchet, droid sans serif, sans, sans-serif"> sans </option>
|
||||
<option value="georgia, times new roman, droid serif, serif"> serif </option>
|
||||
<option value="monospace"> monospace </option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<input type="checkbox" id="custom_font_size" name="font_size">
|
||||
<label for="custom_font_size">font size</label>
|
||||
<input type="number" id="font_size" value="100" min="50" max="150" disabled=""> %
|
||||
</div>
|
||||
<div>
|
||||
<input type="checkbox" id="custom_font_weight" name="font_weight">
|
||||
<label for="custom_font_weight">font weight</label>
|
||||
<select id="font_weight" disabled="">
|
||||
<option value="100">thin</option>
|
||||
<option value="200">extra light</option>
|
||||
<option value="300">light</option>
|
||||
<option value="400">normal</option>
|
||||
<option value="500">medium</option>
|
||||
<option value="600">semi-bold</option>
|
||||
<option value="700">bold</option>
|
||||
<option value="800">extra bold</option>
|
||||
<option value="900">black</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="font_example" class="user font_example">
|
||||
<div>
|
||||
Et nos esse veri viri scire volemus
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset class="settings-container" name="colour-settings">
|
||||
<legend>colors</legend>
|
||||
<fieldset>
|
||||
<legend>normal</legend>
|
||||
<div class="control-group">
|
||||
<input type="checkbox" id="use_custom_colors" name="use_custom_colors">
|
||||
<label for="use_custom_colors">
|
||||
Use custom colors
|
||||
</label>
|
||||
<div class="center-box">
|
||||
<input type="color" id="day_color" value="#0a0a0a">
|
||||
on
|
||||
<input type="color" id="day_background" value="#f0f0f0">
|
||||
</div>
|
||||
<div id="day_example" class="day font_example">
|
||||
<div>
|
||||
Et nos esse veri viri scire volemus
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>night</legend>
|
||||
<div class="control-group">
|
||||
<div class="center-box nightshift">
|
||||
nightmode can be toggled by clicking the book title
|
||||
</div>
|
||||
<div class="center-box">
|
||||
<input type="color" id="night_color" value="#454545">
|
||||
on
|
||||
<input type="color" id="night_background" value="#000000">
|
||||
</div>
|
||||
<div id="night_example" class="night font_example">
|
||||
<div>
|
||||
Et nos esse veri viri scire volemus
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
<fieldset class="settings-container" name="display-settings">
|
||||
<legend>display</legend>
|
||||
<fieldset>
|
||||
<legend>page width</legend>
|
||||
<div class="control-group center-box">
|
||||
maximum <input type="number" id="page_width" value="72" min="25" max="200"> characters
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<input type="checkbox" id="maximize_page" name="maximize_page">
|
||||
<label for="custom_margins">maximize page area</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="control-group">
|
||||
<input type="checkbox" id="sidebarReflow" name="sidebarReflow">
|
||||
<label for="sidebarReflow">
|
||||
reflow text when sidebars are open
|
||||
</label>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<input type="checkbox" id="touch_nav" name="touch_nav">
|
||||
<label for="touch_nav">
|
||||
disable extra-wide page turn areas
|
||||
</label>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<input type="checkbox" id="page_turn_arrows" name="page_turn_arrows">
|
||||
<label for="page_turn_arrows">
|
||||
show page turn arrows
|
||||
</label>
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
</div>
|
||||
</div> <!-- views -->
|
||||
</div> <!-- sidebar -->
|
||||
|
||||
<!-- /sidebar -->
|
||||
|
||||
<!-- main -->
|
||||
|
||||
<div id="main">
|
||||
|
||||
<!-- titlebar -->
|
||||
|
||||
<div id="titlebar">
|
||||
<div id="opener">
|
||||
<a id="slider" class="icon-menu">
|
||||
<?php p($l->t("menu")); ?>
|
||||
</a>
|
||||
</div>
|
||||
<div id="metainfo" class="nightshift">
|
||||
<span id="book-title">
|
||||
</span>
|
||||
<span id="title-separator">
|
||||
–
|
||||
</span>
|
||||
<span id="page_num"></span>
|
||||
<span id="page_num_separator">
|
||||
/
|
||||
</span>
|
||||
<span id="total_pages">
|
||||
</span>
|
||||
</div>
|
||||
<div id="title-controls">
|
||||
<a id="note" class="icon-comment">
|
||||
</a>
|
||||
<a id="bookmark" class="icon-turned_in_not">
|
||||
</a>
|
||||
<a id="fullscreen" class="icon-fullscreen">
|
||||
</a>
|
||||
<a id="close" class="icon-exit" style="display:none">
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- /titlebar -->
|
||||
|
||||
<!-- divider -->
|
||||
|
||||
<div id="divider">
|
||||
</div>
|
||||
|
||||
<!-- /divider -->
|
||||
|
||||
<!-- navigation + viewer -->
|
||||
|
||||
<div id="prev" class="arrow">
|
||||
<div class="translucent">
|
||||
‹
|
||||
</div>
|
||||
</div>
|
||||
<div ID="viewer">
|
||||
<canvas id="left" class="viewer"></canvas>
|
||||
<canvas id="right" class="viewer"></canvas>
|
||||
</div>
|
||||
<div id="next" class="arrow">
|
||||
<div class="translucent">
|
||||
›
|
||||
</div>
|
||||
</div>
|
||||
<div id="loader">
|
||||
<img src="img/loading.gif">
|
||||
</div>
|
||||
|
||||
<!-- /navigation + viewer -->
|
||||
|
||||
</div>
|
||||
|
||||
<!-- /main -->
|
||||
|
||||
<div class="overlay">
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
BIN
files_reader/vendor/pdfjs/.pdf.reader.js.swp
vendored
Normal file
BIN
files_reader/vendor/pdfjs/.pdf.reader.js.swp
vendored
Normal file
Binary file not shown.
55
files_reader/vendor/pdfjs/controllers/bookmarks_controller.js
vendored
Normal file
55
files_reader/vendor/pdfjs/controllers/bookmarks_controller.js
vendored
Normal file
|
@ -0,0 +1,55 @@
|
|||
PDFJS.reader.BookmarksController = function() {
|
||||
|
||||
var reader = this,
|
||||
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));
|
||||
};
|
||||
|
||||
for (var bookmark in annotations) {
|
||||
if (annotations.hasOwnProperty(bookmark) && (annotations[bookmark].type === "bookmark"))
|
||||
addBookmarkItem(annotations[bookmark]);
|
||||
};
|
||||
|
||||
this.on("reader:bookmarkcreated", function (bookmark) {
|
||||
addBookmarkItem(bookmark);
|
||||
});
|
||||
|
||||
this.on("reader:bookmarkremoved", function (id) {
|
||||
var $item = $("#"+id),
|
||||
cfi = reader.book.getCurrentLocationCfi(),
|
||||
cfi_id = reader.cfiToId(cfi);
|
||||
|
||||
$item.remove();
|
||||
|
||||
if(cfi_id === id) {
|
||||
$bookmark
|
||||
.removeClass("icon-turned_in")
|
||||
.addClass("icon-turned_in_not");
|
||||
}
|
||||
});
|
||||
|
||||
this.on("reader:gotobookmark", function (bookmark) {
|
||||
if (bookmark && bookmark.value)
|
||||
book.gotoCfi(bookmark.value);
|
||||
});
|
||||
|
||||
return {
|
||||
"show" : show,
|
||||
"hide" : hide
|
||||
};
|
||||
};
|
118
files_reader/vendor/pdfjs/controllers/controls_controller.js
vendored
Normal file
118
files_reader/vendor/pdfjs/controllers/controls_controller.js
vendored
Normal file
|
@ -0,0 +1,118 @@
|
|||
PDFJS.reader.ControlsController = function(book) {
|
||||
var reader = this;
|
||||
|
||||
var $store = $("#store"),
|
||||
$fullscreen = $("#fullscreen"),
|
||||
$fullscreenicon = $("#fullscreenicon"),
|
||||
$cancelfullscreenicon = $("#cancelfullscreenicon"),
|
||||
$slider = $("#slider"),
|
||||
$main = $("#main"),
|
||||
$sidebar = $("#sidebar"),
|
||||
$settings = $("#setting"),
|
||||
$bookmark = $("#bookmark"),
|
||||
$note = $("#note");
|
||||
|
||||
var goOnline = function() {
|
||||
reader.offline = false;
|
||||
// $store.attr("src", $icon.data("save"));
|
||||
};
|
||||
|
||||
var goOffline = function() {
|
||||
reader.offline = true;
|
||||
// $store.attr("src", $icon.data("saved"));
|
||||
};
|
||||
|
||||
var fullscreen = false;
|
||||
|
||||
$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");
|
||||
}
|
||||
});
|
||||
|
||||
if(typeof screenfull !== 'undefined') {
|
||||
$fullscreen.on("click", function() {
|
||||
screenfull.toggle($('#container')[0]);
|
||||
});
|
||||
if(screenfull.raw) {
|
||||
document.addEventListener(screenfull.raw.fullscreenchange, function() {
|
||||
fullscreen = screenfull.isFullscreen;
|
||||
if(fullscreen) {
|
||||
$fullscreen
|
||||
.addClass("icon-fullscreen_exit")
|
||||
.removeClass("icon-fullscreen");
|
||||
} else {
|
||||
$fullscreen
|
||||
.addClass("icon-fullscreen")
|
||||
.removeClass("icon-fullscreen_exit");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$settings.on("click", function() {
|
||||
reader.SettingsController.show();
|
||||
});
|
||||
|
||||
$note.on("click", function() {
|
||||
reader.SidebarController.changePanelTo("Notes");
|
||||
});
|
||||
|
||||
$bookmark.on("click", function() {
|
||||
var cfi = reader.book.getCurrentLocationCfi();
|
||||
|
||||
if(!(reader.isBookmarked(cfi))) { //-- Add bookmark
|
||||
reader.addBookmark(cfi);
|
||||
$bookmark
|
||||
.addClass("icon-turned_in")
|
||||
.removeClass("icon-turned_in_not");
|
||||
} else { //-- Remove Bookmark
|
||||
reader.removeBookmark(cfi);
|
||||
$bookmark
|
||||
.removeClass("icon-turned_in")
|
||||
.addClass("icon-turned_in_not");
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/*
|
||||
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 {
|
||||
|
||||
};
|
||||
};
|
14
files_reader/vendor/pdfjs/controllers/meta_controller.js
vendored
Normal file
14
files_reader/vendor/pdfjs/controllers/meta_controller.js
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
PDFJS.reader.MetaController = function(meta) {
|
||||
var title = meta.bookTitle,
|
||||
author = meta.creator;
|
||||
|
||||
var $title = $("#book-title"),
|
||||
$author = $("#chapter-title"),
|
||||
$dash = $("#title-seperator");
|
||||
|
||||
document.title = title+" – "+author;
|
||||
|
||||
$title.html(title);
|
||||
$author.html(author);
|
||||
$dash.show();
|
||||
};
|
460
files_reader/vendor/pdfjs/controllers/notes_controller.js
vendored
Normal file
460
files_reader/vendor/pdfjs/controllers/notes_controller.js
vendored
Normal file
|
@ -0,0 +1,460 @@
|
|||
PDFJS.reader.NotesController = function() {
|
||||
|
||||
var book = this.book,
|
||||
reader = this,
|
||||
$notesView = $("#notesView"),
|
||||
$notes = $("#notes"),
|
||||
$text = $("#note-text"),
|
||||
$anchor = $("#note-anchor"),
|
||||
$next = $("#next"),
|
||||
$prev = $("#prev"),
|
||||
$touch_nav = $("#touch_nav"),
|
||||
annotations = reader.settings.annotations,
|
||||
renderer = book.renderer,
|
||||
popups = [],
|
||||
epubcfi = new PDFJS.EpubCFI();
|
||||
|
||||
var show = function() {
|
||||
$notesView.addClass('open');
|
||||
$text.focus();
|
||||
};
|
||||
|
||||
var hide = function() {
|
||||
$notesView.removeClass('open');
|
||||
};
|
||||
|
||||
$text.on("keydown", function(e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
var insertAtPoint = function(e) {
|
||||
var range,
|
||||
textNode,
|
||||
offset,
|
||||
doc = book.renderer.doc,
|
||||
cfi,
|
||||
annotation;
|
||||
|
||||
// standard
|
||||
if (doc.caretPositionFromPoint) {
|
||||
range = doc.caretPositionFromPoint(e.clientX, e.clientY);
|
||||
textNode = range.offsetNode;
|
||||
offset = range.offset;
|
||||
// WebKit
|
||||
} else if (doc.caretRangeFromPoint) {
|
||||
range = doc.caretRangeFromPoint(e.clientX, e.clientY);
|
||||
textNode = range.startContainer;
|
||||
offset = range.startOffset;
|
||||
}
|
||||
|
||||
if (textNode.nodeType !== 3) {
|
||||
for (var i=0; i < textNode.childNodes.length; i++) {
|
||||
if (textNode.childNodes[i].nodeType == 3) {
|
||||
textNode = textNode.childNodes[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Find the end of the sentence
|
||||
offset = textNode.textContent.indexOf(".", offset);
|
||||
if(offset === -1){
|
||||
offset = textNode.length; // Last item
|
||||
} else {
|
||||
offset += 1; // After the period
|
||||
}
|
||||
|
||||
cfi = epubcfi.generateCfiFromTextNode(textNode, offset, book.renderer.currentChapter.cfiBase);
|
||||
|
||||
annotation = new reader.Annotation('annotation', cfi, $text.val());
|
||||
|
||||
// save...
|
||||
reader.addAnnotation(annotation);
|
||||
|
||||
// show...
|
||||
addAnnotationItem(annotation);
|
||||
// add marker...
|
||||
placeMarker(annotation);
|
||||
|
||||
// clear entry
|
||||
$text.val('');
|
||||
$anchor.removeClass("icon-location_off");
|
||||
$anchor.addClass("icon-room");
|
||||
$text.prop("disabled", false);
|
||||
|
||||
book.off("renderer:click", insertAtPoint);
|
||||
};
|
||||
|
||||
var addAnnotationItem = function(annotation) {
|
||||
$notes.append(createItem(annotation));
|
||||
};
|
||||
|
||||
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 */
|
||||
var createItem = function(annotation){
|
||||
var item = document.createElement("li");
|
||||
var text = document.createElement("div");
|
||||
var date = document.createElement("div");
|
||||
var edit = document.createElement("span");
|
||||
var del = document.createElement("span");
|
||||
var link = document.createElement("a");
|
||||
var div = document.createElement("div");
|
||||
var save = document.createElement("span");
|
||||
var cancel = document.createElement("span");
|
||||
|
||||
text.textContent = annotation.body;
|
||||
date.textContent = new Date(annotation.edited).toUTCString();
|
||||
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");
|
||||
date.classList.add("item-date");
|
||||
del.setAttribute("title", "delete");
|
||||
edit.setAttribute("title", "edit");
|
||||
link.setAttribute("title", "context");
|
||||
item.setAttribute("id", annotation.id);
|
||||
save.classList.add("item-save", "edit-control", "hide", "icon-check");
|
||||
cancel.classList.add("item-cancel", "edit-control", "hide", "icon-close");
|
||||
save.setAttribute("display", "none");
|
||||
cancel.setAttribute("display", "none");
|
||||
|
||||
link.href = "#"+annotation.anchor;
|
||||
|
||||
link.onclick = function(){
|
||||
book.gotoCfi(annotation.anchor);
|
||||
return false;
|
||||
};
|
||||
|
||||
del.onclick = function() {
|
||||
var id = this.parentNode.parentNode.getAttribute("id");
|
||||
//var marker = book.renderer.doc.getElementById("note-" + id);
|
||||
// remove note from collection...
|
||||
//reader.removeAnnotation(id);
|
||||
// ... and remove the marker...
|
||||
//if (marker) {
|
||||
// marker.remove();
|
||||
// renumberMarkers();
|
||||
//}
|
||||
// ...and finally remove the HTML representation
|
||||
//this.parentNode.parentNode.remove();
|
||||
//renumberMarkers();
|
||||
reader.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);
|
||||
};
|
||||
|
||||
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(link);
|
||||
item.appendChild(text);
|
||||
item.appendChild(date);
|
||||
item.appendChild(div);
|
||||
return item;
|
||||
};
|
||||
|
||||
var editAnnotation = function (e) {
|
||||
var text = e.target;
|
||||
var id = text.parentNode.getAttribute("id");
|
||||
if (e.keyCode === 27) { // escape - cancel editor, discard changes
|
||||
text.textContent = annotations[id].body;
|
||||
closeEditor(id);
|
||||
}
|
||||
e.stopPropagation();
|
||||
};
|
||||
|
||||
var openEditor = function(id) {
|
||||
var item = document.getElementById(id);
|
||||
var text = item.firstChild;
|
||||
$(item).find(".item-control").toggleClass("hide");
|
||||
$(item).find(".edit-control").toggleClass("hide");
|
||||
text.setAttribute("contenteditable", "true");
|
||||
text.classList.add("editable");
|
||||
text.addEventListener("keydown", editAnnotation, false);
|
||||
};
|
||||
|
||||
var closeEditor = function (id) {
|
||||
var item = document.getElementById(id);
|
||||
var text = item.firstChild;
|
||||
$(item).find(".item-control").toggleClass("hide");
|
||||
$(item).find(".edit-control").toggleClass("hide");
|
||||
text.classList.remove("editable");
|
||||
text.removeAttribute("contenteditable");
|
||||
text.removeEventListener("keydown", editAnnotation, false);
|
||||
};
|
||||
|
||||
var findIndex = function (id) {
|
||||
// list has items
|
||||
var i,
|
||||
list = $notes[0].getElementsByTagName("li");
|
||||
|
||||
for (i = 0; i < list.length; i++) {
|
||||
if (list[i].getAttribute("id") === id)
|
||||
break;
|
||||
}
|
||||
|
||||
return i+1;
|
||||
};
|
||||
|
||||
var placeMarker = function(annotation){
|
||||
var doc = book.renderer.doc,
|
||||
marker = document.createElement("span"),
|
||||
mark = document.createElement("a");
|
||||
|
||||
marker.classList.add("note-marker", "footnotesuperscript", "reader_generated");
|
||||
marker.id = "note-" + annotation.id;
|
||||
mark.innerHTML = findIndex(annotation.id) + "[Reader]";
|
||||
|
||||
marker.appendChild(mark);
|
||||
epubcfi.addMarker(annotation.anchor, doc, marker);
|
||||
|
||||
markerEvents(marker, annotation.body);
|
||||
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;
|
||||
|
||||
var showPop = function(){
|
||||
var poppos,
|
||||
iheight = renderer.height,
|
||||
iwidth = renderer.width,
|
||||
tip,
|
||||
pop,
|
||||
maxHeight = 225,
|
||||
itemRect,
|
||||
left,
|
||||
top,
|
||||
pos;
|
||||
|
||||
|
||||
//-- create a popup with endnote inside of it
|
||||
if(!popups[id]) {
|
||||
popups[id] = document.createElement("div");
|
||||
popups[id].setAttribute("class", "popup");
|
||||
|
||||
pop_content = document.createElement("div");
|
||||
|
||||
popups[id].appendChild(pop_content);
|
||||
|
||||
pop_content.innerHTML = txt;
|
||||
pop_content.setAttribute("class", "pop_content");
|
||||
|
||||
renderer.render.document.body.appendChild(popups[id]);
|
||||
|
||||
//-- TODO: will these leak memory? - Fred
|
||||
popups[id].addEventListener("mouseover", onPop, false);
|
||||
popups[id].addEventListener("mouseout", offPop, false);
|
||||
|
||||
//-- Add hide on page change
|
||||
renderer.on("renderer:locationChanged", hidePop, this);
|
||||
renderer.on("renderer:locationChanged", offPop, this);
|
||||
// chapter.book.on("renderer:chapterDestroy", hidePop, this);
|
||||
}
|
||||
|
||||
pop = popups[id];
|
||||
|
||||
|
||||
//-- get location of item
|
||||
itemRect = item.getBoundingClientRect();
|
||||
left = itemRect.left;
|
||||
top = itemRect.top;
|
||||
|
||||
//-- show the popup
|
||||
pop.classList.add("show");
|
||||
|
||||
//-- locations of popup
|
||||
popRect = pop.getBoundingClientRect();
|
||||
|
||||
//-- position the popup
|
||||
pop.style.left = left - popRect.width / 2 + "px";
|
||||
pop.style.top = top + "px";
|
||||
|
||||
|
||||
//-- Adjust max height
|
||||
if(maxHeight > iheight / 2.5) {
|
||||
maxHeight = iheight / 2.5;
|
||||
pop_content.style.maxHeight = maxHeight + "px";
|
||||
}
|
||||
|
||||
//-- switch above / below
|
||||
if(popRect.height + top >= iheight - 25) {
|
||||
pop.style.top = top - popRect.height + "px";
|
||||
pop.classList.add("above");
|
||||
}else{
|
||||
pop.classList.remove("above");
|
||||
}
|
||||
|
||||
//-- switch left
|
||||
if(left - popRect.width <= 0) {
|
||||
pop.style.left = left + "px";
|
||||
pop.classList.add("left");
|
||||
}else{
|
||||
pop.classList.remove("left");
|
||||
}
|
||||
|
||||
//-- switch right
|
||||
if(left + popRect.width / 2 >= iwidth) {
|
||||
//-- TEMP MOVE: 300
|
||||
pop.style.left = left - 300 + "px";
|
||||
|
||||
popRect = pop.getBoundingClientRect();
|
||||
pop.style.left = left - popRect.width + "px";
|
||||
//-- switch above / below again
|
||||
if(popRect.height + top >= iheight - 25) {
|
||||
pop.style.top = top - popRect.height + "px";
|
||||
pop.classList.add("above");
|
||||
}else{
|
||||
pop.classList.remove("above");
|
||||
}
|
||||
|
||||
pop.classList.add("right");
|
||||
}else{
|
||||
pop.classList.remove("right");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var onPop = function(){
|
||||
popups[id].classList.add("on");
|
||||
}
|
||||
|
||||
var offPop = function(){
|
||||
popups[id].classList.remove("on");
|
||||
}
|
||||
|
||||
var hidePop = function(){
|
||||
setTimeout(function(){
|
||||
popups[id].classList.remove("show");
|
||||
}, 100);
|
||||
}
|
||||
|
||||
var openSidebar = function(){
|
||||
reader.SidebarController.changePanelTo('Notes');
|
||||
reader.SidebarController.show();
|
||||
};
|
||||
|
||||
item.addEventListener("mouseover", showPop, false);
|
||||
item.addEventListener("mouseout", hidePop, false);
|
||||
item.addEventListener("click", openSidebar, false);
|
||||
|
||||
}
|
||||
|
||||
$anchor.on("click", function(e){
|
||||
if ($anchor[0].classList.contains("icon-room")) {
|
||||
$anchor.removeClass("icon-room");
|
||||
$anchor.addClass("icon-location_off");
|
||||
$text.prop("disabled", true);
|
||||
// disable extra-wide navigation as it interferes with anchor placment
|
||||
if ($prev.hasClass("touch_nav")) {
|
||||
$prev.removeClass("touch_nav");
|
||||
$next.removeClass("touch_nav");
|
||||
$prev.addClass("restore_touch_nav");
|
||||
}
|
||||
// listen for selection
|
||||
book.on("renderer:click", insertAtPoint);
|
||||
} else {
|
||||
$text.prop("disabled", false);
|
||||
$anchor.removeClass("icon-location_off");
|
||||
$anchor.addClass("icon-room");
|
||||
if ($prev.hasClass("restore_touch_nav")) {
|
||||
$prev.removeClass("restore_touch_nav");
|
||||
$prev.addClass("touch_nav");
|
||||
$next.addClass("touch_nav");
|
||||
}
|
||||
book.off("renderer:click", insertAtPoint);
|
||||
}
|
||||
});
|
||||
|
||||
for (var note in annotations) {
|
||||
if (annotations.hasOwnProperty(note) && (annotations[note].type === "annotation"))
|
||||
addAnnotationItem(annotations[note]);
|
||||
};
|
||||
|
||||
this.on("reader:annotationcreated", function (note) {
|
||||
addAnnotationItem(note);
|
||||
});
|
||||
|
||||
this.on("reader:annotationremoved", function (id) {
|
||||
deleteAnnotationItem(id);
|
||||
});
|
||||
|
||||
// replace markers for annotations
|
||||
renderer.registerHook("beforeChapterDisplay", function(callback, renderer){
|
||||
var chapter = renderer.currentChapter;
|
||||
for (var note in annotations) {
|
||||
if (annotations.hasOwnProperty(note) && (annotations[note].type === "annotation")) {
|
||||
var cfi = epubcfi.parse(annotations[note].anchor);
|
||||
if(cfi.spinePos === chapter.spinePos) {
|
||||
try {
|
||||
placeMarker(annotations[note]);
|
||||
} catch(e) {
|
||||
console.log("anchoring failed", annotations[note].anchor);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
callback();
|
||||
}, true);
|
||||
|
||||
|
||||
return {
|
||||
"show" : show,
|
||||
"hide" : hide,
|
||||
"createItem": createItem
|
||||
};
|
||||
};
|
178
files_reader/vendor/pdfjs/controllers/reader_controller.js
vendored
Normal file
178
files_reader/vendor/pdfjs/controllers/reader_controller.js
vendored
Normal file
|
@ -0,0 +1,178 @@
|
|||
PDFJS.reader.ReaderController = function(book) {
|
||||
var $main = $("#main"),
|
||||
$divider = $("#divider"),
|
||||
$loader = $("#loader"),
|
||||
$next = $("#next"),
|
||||
$prev = $("#prev"),
|
||||
$sidebarReflow = $('#sidebarReflow'),
|
||||
$metainfo = $("#metainfo"),
|
||||
$use_custom_colors = $("#use_custom_colors"),
|
||||
$container = $("#container"),
|
||||
$fullscreen = $("#fullscreen"),
|
||||
$bookmark = $("#bookmark"),
|
||||
$note = $("#note");
|
||||
|
||||
var reader = this,
|
||||
book = this.book,
|
||||
settings = reader.settings;
|
||||
|
||||
var slideIn = function() {
|
||||
if (reader.viewerResized) {
|
||||
var currentPosition = book.getCurrentLocationCfi();
|
||||
reader.viewerResized = false;
|
||||
$main.removeClass('single');
|
||||
$main.one("transitionend", function(){
|
||||
book.gotoCfi(currentPosition);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var slideOut = function() {
|
||||
var currentPosition = book.getCurrentLocationCfi();
|
||||
reader.viewerResized = true;
|
||||
$main.addClass('single');
|
||||
$main.one("transitionend", function(){
|
||||
book.gotoCfi(currentPosition);
|
||||
});
|
||||
};
|
||||
|
||||
var showLoader = function() {
|
||||
$loader.show();
|
||||
hideDivider();
|
||||
};
|
||||
|
||||
var hideLoader = function() {
|
||||
$loader.hide();
|
||||
|
||||
//-- If the book is using spreads, show the divider
|
||||
// if(book.settings.spreads) {
|
||||
// showDivider();
|
||||
// }
|
||||
};
|
||||
|
||||
var showDivider = function() {
|
||||
$divider.addClass("show");
|
||||
};
|
||||
|
||||
var hideDivider = function() {
|
||||
$divider.removeClass("show");
|
||||
};
|
||||
|
||||
var keylock = false;
|
||||
|
||||
var showActive = function (obj) {
|
||||
keylock = true;
|
||||
obj.addClass("active");
|
||||
setTimeout(function () {
|
||||
keylock = false;
|
||||
obj.removeClass("active");
|
||||
}, 100);
|
||||
};
|
||||
|
||||
var keyCommands = function(e) {
|
||||
|
||||
var page_no = false;
|
||||
|
||||
switch (settings.keyboard[e.keyCode]) {
|
||||
case 'previous':
|
||||
$prev.click();
|
||||
break;
|
||||
case 'next':
|
||||
$next.click();
|
||||
break;
|
||||
case 'first':
|
||||
page_no = 1;
|
||||
break;
|
||||
case 'last':
|
||||
// TODO
|
||||
break;
|
||||
case 'annotate':
|
||||
$note.click();
|
||||
break;
|
||||
case 'bookmark':
|
||||
$bookmark.click();
|
||||
break;
|
||||
case 'reflow':
|
||||
$sidebarReflow.click();
|
||||
break;
|
||||
case 'toggleSidebar':
|
||||
reader.SidebarController.toggle();
|
||||
break;
|
||||
case 'closeSidebar':
|
||||
reader.SidebarController.hide();
|
||||
break;
|
||||
case 'toggleFullscreen':
|
||||
$fullscreen.click();
|
||||
break;
|
||||
case 'toggleNight':
|
||||
$metainfo.click();
|
||||
break;
|
||||
case 'toggleDay':
|
||||
$use_custom_colors.click();
|
||||
break;
|
||||
default:
|
||||
console.log("unsupported keyCode: " + e.keyCode);
|
||||
}
|
||||
|
||||
if (page_no) {
|
||||
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('keydown', keyCommands, false);
|
||||
|
||||
$next.on("click", function(e){
|
||||
|
||||
//if(book.metadata.direction === "rtl") {
|
||||
// reader.prevPage();
|
||||
//} else {
|
||||
reader.nextPage();
|
||||
//}
|
||||
|
||||
showActive($next);
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
$prev.on("click", function(e){
|
||||
|
||||
//if(book.metadata.direction === "rtl") {
|
||||
// reader.nextPage();
|
||||
//} else {
|
||||
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,
|
||||
"showLoader" : showLoader,
|
||||
"hideLoader" : hideLoader,
|
||||
"showDivider" : showDivider,
|
||||
"hideDivider" : hideDivider,
|
||||
"keyCommands" : keyCommands
|
||||
};
|
||||
};
|
155
files_reader/vendor/pdfjs/controllers/search_controller.js
vendored
Normal file
155
files_reader/vendor/pdfjs/controllers/search_controller.js
vendored
Normal file
|
@ -0,0 +1,155 @@
|
|||
PDFJS.reader.SearchController = function () {
|
||||
var reader = this,
|
||||
book = this.book,
|
||||
query = "";
|
||||
|
||||
var $searchBox = $("#searchBox"),
|
||||
$clearBtn = $("#searchBox").next(),
|
||||
$clear_search = $("#clear_search"),
|
||||
$searchResults = $("#searchResults"),
|
||||
$searchView = $("#searchView"),
|
||||
$body = $("#viewer iframe").contents().find('body'),
|
||||
$sidebar = $("#sidebar");
|
||||
|
||||
var onShow = function() {
|
||||
$searchView.addClass("open");
|
||||
$searchBox.focus();
|
||||
};
|
||||
|
||||
var onHide = function() {
|
||||
unhighlight();
|
||||
$searchView.removeClass("open");
|
||||
};
|
||||
|
||||
var search = function(q) {
|
||||
if (q === undefined) {
|
||||
q = $searchBox.val();
|
||||
}
|
||||
|
||||
if (q == '') {
|
||||
clear();
|
||||
return;
|
||||
}
|
||||
|
||||
reader.SidebarController.changePanelTo("Search");
|
||||
|
||||
$searchResults.empty();
|
||||
$searchResults.append("<li><p>Searching...</p></li>");
|
||||
|
||||
reader.SearchController.query = q;
|
||||
|
||||
runQuery(q, $searchResults[0]);
|
||||
|
||||
};
|
||||
|
||||
$searchBox.on("keydown", function(e) {
|
||||
// Show the clear button if text input value is not empty
|
||||
$clearBtn.css("visibility", (this.value.length) ? "visible" : "hidden");
|
||||
|
||||
// run search when Enter is pressed
|
||||
if (e.keyCode === 13) {
|
||||
search();
|
||||
}
|
||||
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
$clearBtn.on("click", function() {
|
||||
$(this).css("visibility", "hidden");
|
||||
$searchBox.val("");
|
||||
});
|
||||
|
||||
$clear_search.on("click", function () {
|
||||
unhighlight();
|
||||
$searchResults.empty();
|
||||
});
|
||||
|
||||
var clear = function () {
|
||||
|
||||
unhighlight();
|
||||
$searchResults.empty();
|
||||
|
||||
if (reader.SidebarController.getActivePanel() == "Search") {
|
||||
reader.SidebarController.changePanelTo("Toc");
|
||||
}
|
||||
};
|
||||
|
||||
var highlightQuery = function(e) {
|
||||
$("#viewer iframe").contents().find('body').highlight(reader.SearchController.query, { element: 'span' });
|
||||
};
|
||||
|
||||
var unhighlight = function(e) {
|
||||
$body = $("#viewer iframe").contents().find('body');
|
||||
$body.unhighlight();
|
||||
book.off("renderer:chapterDisplayed", highlightQuery);
|
||||
};
|
||||
|
||||
// perform search and build result list
|
||||
var runQuery = function(query, element) {
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
|
||||
var results = [];
|
||||
|
||||
for (var i = 0; i < book.spine.length; i++) {
|
||||
var spineItem = book.spine[i];
|
||||
results.push(new Promise(function(resolve, reject) {
|
||||
new Promise(function(resolve, reject) {
|
||||
resolve(new PDFJS.Chapter(spineItem, book.store, book.credentials));
|
||||
}).then(function(chapter) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
chapter.load().then(function() {
|
||||
resolve(chapter);
|
||||
}).catch(reject);
|
||||
});
|
||||
}).then(function(chapter) {
|
||||
return Promise.resolve(chapter.find(query));
|
||||
}).then(function(result) {
|
||||
resolve(result);
|
||||
});
|
||||
}));
|
||||
}
|
||||
Promise.all(results).then(function(results) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
resolve(results);
|
||||
var mergedResults = [].concat.apply([], results);
|
||||
element.innerHTML = "";
|
||||
for (var i = 0; i < mergedResults.length; i++) {
|
||||
try {
|
||||
var listitem = document.createElement("li");
|
||||
var link = document.createElement("a");
|
||||
listitem.classList.add("list_item");
|
||||
listitem.id = "search-"+i;
|
||||
link.href=mergedResults[i].cfi;
|
||||
link.textContent = mergedResults[i].excerpt;
|
||||
link.classList.add("toc_link");
|
||||
link.addEventListener("click", function(e) {
|
||||
e.preventDefault();
|
||||
book.gotoCfi(this.getAttribute("href"));
|
||||
$searchResults.find(".list_item")
|
||||
.removeClass("currentChapter");
|
||||
$(this).parent("li").addClass("currentChapter");
|
||||
$(this).data('query', query);
|
||||
book.on("renderer:chapterDisplayed", highlightQuery);
|
||||
});
|
||||
listitem.appendChild(link);
|
||||
element.appendChild(listitem);
|
||||
} catch (e) {
|
||||
console.warn(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
return {
|
||||
"show" : onShow,
|
||||
"hide" : onHide,
|
||||
"search": search,
|
||||
"query" : query,
|
||||
"clear" : clear,
|
||||
"unhighlight" : unhighlight
|
||||
};
|
||||
};
|
107
files_reader/vendor/pdfjs/controllers/settings_controller.js
vendored
Normal file
107
files_reader/vendor/pdfjs/controllers/settings_controller.js
vendored
Normal file
|
@ -0,0 +1,107 @@
|
|||
PDFJS.reader.SettingsController = function() {
|
||||
|
||||
var reader = this,
|
||||
book = this.book,
|
||||
settings = reader.settings;
|
||||
|
||||
var $settings = $("#settingsView"),
|
||||
$viewer = $("#viewer"),
|
||||
$overlay = $(".overlay"),
|
||||
$next = $("#next"),
|
||||
$prev = $("#prev"),
|
||||
$close = $("#close"),
|
||||
$sidebarReflow = $('#sidebarReflow'),
|
||||
$touch_nav = $("#touch_nav"),
|
||||
$page_turn_arrows = $("#page_turn_arrows"),
|
||||
$prev_arrow = $("#prev :first-child"),
|
||||
$next_arrow = $("#next :first-child");
|
||||
|
||||
var show = function() {
|
||||
$settings.addClass('open');
|
||||
};
|
||||
|
||||
var hide = function() {
|
||||
$settings.removeClass('open');
|
||||
};
|
||||
|
||||
if (settings.sidebarReflow) {
|
||||
$sidebarReflow.prop('checked', true);
|
||||
} else {
|
||||
$sidebarReflow.prop('checked', false);
|
||||
}
|
||||
|
||||
$sidebarReflow.off('click').on('click', function() {
|
||||
settings.sidebarReflow = !settings.sidebarReflow;
|
||||
if (settings.sidebarReflow && reader.sidebarOpen) reader.ReaderController.slideOut();
|
||||
if (!settings.sidebarReflow && !reader.sidebarOpen) reader.ReaderController.slideIn();
|
||||
settings.session.setDefault("sidebarReflow", settings.sidebarReflow);
|
||||
});
|
||||
|
||||
$settings.find(".closer").on("click", function() {
|
||||
hide();
|
||||
});
|
||||
|
||||
$overlay.on("click", function() {
|
||||
hide();
|
||||
});
|
||||
|
||||
// only enable close button when launched in an iframe default
|
||||
if (parent !== window) {
|
||||
$close.show();
|
||||
$close.on("click", function () {
|
||||
reader.book.destroy();
|
||||
parent.OCA.Files_Reader.Plugin.hide();
|
||||
});
|
||||
}
|
||||
|
||||
// default for extra wide navigation controls;
|
||||
// devices with touch navigation: on
|
||||
// devices without touch navigation: off
|
||||
$touch_nav.prop('checked', !('ontouchstart' in document.documentElement));
|
||||
if (!($touch_nav.prop('checked'))) {
|
||||
$next.addClass("touch_nav");
|
||||
$prev.addClass("touch_nav");
|
||||
}
|
||||
|
||||
// extra wide nagivation controls
|
||||
$touch_nav.off('change').on('change', function() {
|
||||
if ($(this).prop('checked')) {
|
||||
$prev.removeClass("touch_nav");
|
||||
$next.removeClass("touch_nav");
|
||||
} else {
|
||||
$prev.addClass("touch_nav");
|
||||
$next.addClass("touch_nav");
|
||||
}
|
||||
});
|
||||
|
||||
// page turn arrows default
|
||||
if (settings.pageArrows) {
|
||||
$page_turn_arrows.prop('checked', true);
|
||||
$prev_arrow.removeClass("translucent");
|
||||
$next_arrow.removeClass("translucent");
|
||||
} else {
|
||||
$page_turn_arrows.prop('checked', false);
|
||||
$prev_arrow.addClass("translucent");
|
||||
$next_arrow.addClass("translucent");
|
||||
}
|
||||
|
||||
// page turn arrows
|
||||
$page_turn_arrows.off('change').on('change', function() {
|
||||
if ($(this).prop('checked')) {
|
||||
settings.pageArrows = true;
|
||||
$prev_arrow.removeClass("translucent");
|
||||
$next_arrow.removeClass("translucent");
|
||||
} else {
|
||||
settings.pageArrows = false;
|
||||
$prev_arrow.addClass("translucent");
|
||||
$next_arrow.addClass("translucent");
|
||||
}
|
||||
|
||||
settings.session.setDefault("pageArrows", settings.pageArrows);
|
||||
});
|
||||
|
||||
return {
|
||||
"show" : show,
|
||||
"hide" : hide
|
||||
};
|
||||
};
|
72
files_reader/vendor/pdfjs/controllers/sidebar_controller.js
vendored
Normal file
72
files_reader/vendor/pdfjs/controllers/sidebar_controller.js
vendored
Normal file
|
@ -0,0 +1,72 @@
|
|||
PDFJS.reader.SidebarController = function(book) {
|
||||
var reader = this,
|
||||
settings = reader.settings;
|
||||
|
||||
var $sidebar = $("#sidebar"),
|
||||
$panels = $("#panels"),
|
||||
$views = $("#views"),
|
||||
$close = $("#hide-Sidebar");
|
||||
$slider = $("#slider");
|
||||
|
||||
var activePanel = "Toc";
|
||||
|
||||
var changePanelTo = function(viewName) {
|
||||
var controllerName = viewName + "Controller";
|
||||
|
||||
if (!(activePanel == viewName || typeof reader[controllerName] === 'undefined' )) {
|
||||
reader[activePanel+ "Controller"].hide();
|
||||
reader[controllerName].show();
|
||||
activePanel = viewName;
|
||||
|
||||
//$panels.find('.open').removeClass("open");
|
||||
$sidebar.find('.open').removeClass("open");
|
||||
$panels.find("#show-" + viewName ).addClass("open");
|
||||
$views.find("#" + viewName.toLowerCase() + "View").addClass("open");
|
||||
}
|
||||
show();
|
||||
};
|
||||
|
||||
var getActivePanel = function() {
|
||||
return activePanel;
|
||||
};
|
||||
|
||||
var show = function() {
|
||||
reader.sidebarOpen = true;
|
||||
if (settings.sidebarReflow) reader.ReaderController.slideOut();
|
||||
$slider.hide();
|
||||
$sidebar.addClass("open");
|
||||
}
|
||||
|
||||
var hide = function() {
|
||||
reader.sidebarOpen = false;
|
||||
$slider.show();
|
||||
reader.ReaderController.slideIn();
|
||||
$sidebar.removeClass("open");
|
||||
};
|
||||
|
||||
var toggle = function () {
|
||||
(reader.sidebarOpen) ? hide() : show();
|
||||
};
|
||||
|
||||
$close.on("click", function () {
|
||||
reader.SidebarController.hide();
|
||||
// $slider.addClass("icon-menu");
|
||||
// $slider.removeClass("icon-right");
|
||||
|
||||
});
|
||||
|
||||
$panels.find(".show_view").on("click", function(e) {
|
||||
var view = $(this).data("view");
|
||||
|
||||
changePanelTo(view);
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
return {
|
||||
'show' : show,
|
||||
'hide' : hide,
|
||||
'toggle' : toggle,
|
||||
'getActivePanel' : getActivePanel,
|
||||
'changePanelTo' : changePanelTo
|
||||
};
|
||||
};
|
230
files_reader/vendor/pdfjs/controllers/styles_controller.js
vendored
Normal file
230
files_reader/vendor/pdfjs/controllers/styles_controller.js
vendored
Normal file
|
@ -0,0 +1,230 @@
|
|||
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');
|
||||
|
||||
// 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()
|
||||
});
|
||||
|
||||
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;
|
||||
|
||||
for (var style in activeStyles) {
|
||||
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);
|
||||
break;
|
||||
case "appleBugs":
|
||||
console.log("Apple mobile bugs detected, applying workarounds...");
|
||||
break;
|
||||
}
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
$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_background.off('change').on('change', function() {
|
||||
customStyles.nightMode.rules.background = $night_background.val();
|
||||
$night_example.css('background', customStyles.nightMode.rules.background);
|
||||
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"]);
|
||||
});
|
||||
|
||||
return {
|
||||
};
|
||||
};
|
115
files_reader/vendor/pdfjs/controllers/toc_controller.js
vendored
Normal file
115
files_reader/vendor/pdfjs/controllers/toc_controller.js
vendored
Normal file
|
@ -0,0 +1,115 @@
|
|||
PDFJS.reader.TocController = function(toc) {
|
||||
var book = this.book;
|
||||
|
||||
var $list = $("#tocView"),
|
||||
docfrag = document.createDocumentFragment();
|
||||
|
||||
var currentChapter = false;
|
||||
|
||||
var generateTocItems = function(toc, level) {
|
||||
var container = document.createElement("ul");
|
||||
|
||||
if(!level) level = 1;
|
||||
|
||||
toc.forEach(function(chapter) {
|
||||
var listitem = document.createElement("li"),
|
||||
link = document.createElement("a");
|
||||
toggle = document.createElement("a");
|
||||
|
||||
var subitems;
|
||||
|
||||
listitem.id = "toc-"+chapter.id;
|
||||
listitem.classList.add('list_item');
|
||||
|
||||
link.textContent = chapter.label;
|
||||
link.href = chapter.href;
|
||||
|
||||
link.classList.add('toc_link');
|
||||
|
||||
listitem.appendChild(link);
|
||||
|
||||
if(chapter.subitems.length > 0) {
|
||||
level++;
|
||||
subitems = generateTocItems(chapter.subitems, level);
|
||||
toggle.classList.add('toc_toggle');
|
||||
|
||||
listitem.insertBefore(toggle, link);
|
||||
listitem.appendChild(subitems);
|
||||
}
|
||||
|
||||
|
||||
container.appendChild(listitem);
|
||||
|
||||
});
|
||||
|
||||
return container;
|
||||
};
|
||||
|
||||
var onShow = function() {
|
||||
$list.addClass('open');
|
||||
};
|
||||
|
||||
var onHide = function() {
|
||||
$list.removeClass('open');
|
||||
};
|
||||
|
||||
var chapterChange = function(e) {
|
||||
var id = e.id,
|
||||
$item = $list.find("#toc-"+id),
|
||||
$current = $list.find(".currentChapter"),
|
||||
$open = $list.find('.openChapter');
|
||||
|
||||
if($item.length){
|
||||
|
||||
if($item != $current && $item.has(currentChapter).length > 0) {
|
||||
$current.removeClass("currentChapter");
|
||||
}
|
||||
|
||||
$item.addClass("currentChapter");
|
||||
|
||||
// $open.removeClass("openChapter");
|
||||
$item.parents('li').addClass("openChapter");
|
||||
}
|
||||
};
|
||||
|
||||
book.on('renderer:chapterDisplayed', chapterChange);
|
||||
|
||||
var tocitems = generateTocItems(toc);
|
||||
|
||||
docfrag.appendChild(tocitems);
|
||||
|
||||
$list.append(docfrag);
|
||||
$list.find(".toc_link").on("click", function(event){
|
||||
var url = this.getAttribute('href');
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
//-- Provide the Book with the url to show
|
||||
// The Url must be found in the books manifest
|
||||
book.goto(url);
|
||||
|
||||
$list.find(".currentChapter")
|
||||
.addClass("openChapter")
|
||||
.removeClass("currentChapter");
|
||||
|
||||
$(this).parent('li').addClass("currentChapter");
|
||||
|
||||
});
|
||||
|
||||
$list.find(".toc_toggle").on("click", function(event){
|
||||
var $el = $(this).parent('li'),
|
||||
open = $el.hasClass("openChapter");
|
||||
|
||||
event.preventDefault();
|
||||
if(open){
|
||||
$el.removeClass("openChapter");
|
||||
} else {
|
||||
$el.addClass("openChapter");
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
"show" : onShow,
|
||||
"hide" : onHide
|
||||
};
|
||||
};
|
BIN
files_reader/vendor/pdfjs/css/.main.css.swp
vendored
Normal file
BIN
files_reader/vendor/pdfjs/css/.main.css.swp
vendored
Normal file
Binary file not shown.
8
files_reader/vendor/pdfjs/css/annotations.css
vendored
Normal file
8
files_reader/vendor/pdfjs/css/annotations.css
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
.ui-loader {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.annotator-hl {
|
||||
box-shadow: none !important;
|
||||
cursor: pointer !important;
|
||||
}
|
14
files_reader/vendor/pdfjs/css/idevice.css
vendored
Normal file
14
files_reader/vendor/pdfjs/css/idevice.css
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
.notes,
|
||||
.search-results,
|
||||
.view {
|
||||
overflow-y: scroll;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.search-results {
|
||||
height: calc(100% - 5em);
|
||||
}
|
||||
|
||||
.notes {
|
||||
height: calc(100% - 9em);
|
||||
}
|
353
files_reader/vendor/pdfjs/css/main.css
vendored
Normal file
353
files_reader/vendor/pdfjs/css/main.css
vendored
Normal file
|
@ -0,0 +1,353 @@
|
|||
html, body, div, span, applet, object, iframe,
|
||||
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
||||
a, abbr, acronym, address, big, cite, code,
|
||||
del, dfn, em, font, img, ins, kbd, q, s, samp,
|
||||
small, strike, strong, sub, sup, tt, var,
|
||||
b, u, i, center,
|
||||
dl, dt, dd, ol, ul, li,
|
||||
fieldset, form, label, legend,
|
||||
table, caption, tbody, tfoot, thead, tr, th, td,
|
||||
fieldset {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
outline: 0;
|
||||
font-size: 100%;
|
||||
vertical-align: baseline;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
body {
|
||||
background: #4e4e4e;
|
||||
overflow: hidden;
|
||||
font-style:
|
||||
}
|
||||
|
||||
#main {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
right: 0;
|
||||
border-radius: 5px;
|
||||
background: #fff;
|
||||
overflow: hidden;
|
||||
-webkit-transition: -webkit-transform .4s, width .2s;
|
||||
-moz-transition: -webkit-transform .4s, width .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);
|
||||
box-shadow: inset 0 0 50px rgba(0,0,0,.1);
|
||||
}
|
||||
|
||||
#titlebar {
|
||||
padding: 0.5em;
|
||||
color: #4f4f4f;
|
||||
font-weight: 100;
|
||||
font-family: Georgia, "Times New Roman", Times, serif;
|
||||
opacity: .5;
|
||||
text-align: center;
|
||||
-webkit-transition: opacity .5s;
|
||||
-moz-transition: opacity .5s;
|
||||
z-index: 10;
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#titlebar:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
#titlebar a {
|
||||
width: 1em;
|
||||
height: 1em;
|
||||
overflow: hidden;
|
||||
display: inline-block;
|
||||
opacity: .5;
|
||||
padding: 0.2em;
|
||||
border-radius: 0.2em;
|
||||
border: 1px rgba(0,0,0,0) solid;
|
||||
}
|
||||
|
||||
#titlebar a::before {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
#titlebar a:hover {
|
||||
opacity: .8;
|
||||
border: 1px rgba(0,0,0,.2) solid;
|
||||
}
|
||||
|
||||
#titlebar a:active {
|
||||
opacity: 1;
|
||||
color: rgba(0,0,0,.6);
|
||||
box-shadow: inset 0 0 6px rgba(155,155,155,.8);
|
||||
}
|
||||
|
||||
#book-title {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
#title-separator {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#title-controls,
|
||||
#opener {
|
||||
margin-left: 0.3em;
|
||||
margin-right: 0.3em;
|
||||
position: fixed;
|
||||
top: 0.3em;
|
||||
}
|
||||
|
||||
#opener {
|
||||
left: 0;
|
||||
}
|
||||
|
||||
#metainfo {
|
||||
position: fixed;
|
||||
/* width: 80%;
|
||||
left: 10%; */
|
||||
width: 50%;
|
||||
width: calc(100% - 7.5em);
|
||||
left: 1.5em;
|
||||
top: 0.3em;
|
||||
padding: 0.2em;
|
||||
height: 1em;
|
||||
overflow: hidden;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#title-controls {
|
||||
right: 0;
|
||||
}
|
||||
|
||||
#viewer {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
/* width: 100%; */
|
||||
/* height: 80%; */
|
||||
height: calc(100% - 2em);
|
||||
/* top: 10%; */
|
||||
top: 2em;
|
||||
z-index: 2;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#viewer canvas {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#viewer iframe {
|
||||
border: none;
|
||||
}
|
||||
|
||||
#prev, #next {
|
||||
position: absolute;
|
||||
top: 10%;
|
||||
height: 80%;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.touch_nav {
|
||||
width: 35%;
|
||||
}
|
||||
|
||||
.arrow div {
|
||||
display: table-cell;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
|
||||
#prev {
|
||||
left: 0;
|
||||
padding-left: 2em;
|
||||
}
|
||||
|
||||
#next {
|
||||
right: 0;
|
||||
padding-right: 2em;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.arrow {
|
||||
font-size: 64px;
|
||||
/* color: #E2E2E2; */
|
||||
font-family: arial, sans-serif;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
display: table;
|
||||
z-index: 3;
|
||||
opacity: 0.2;
|
||||
}
|
||||
|
||||
.arrow:hover {
|
||||
/* color: #777; */
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.arrow:active,
|
||||
.arrow.active {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
#main.closed {
|
||||
transform: translate(25em, 0);
|
||||
}
|
||||
|
||||
#main.single {
|
||||
width: calc(100% - 25em);
|
||||
}
|
||||
|
||||
#divider {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
border-right: 1px #000 solid;
|
||||
height: 80%;
|
||||
z-index: 100;
|
||||
left: 50%;
|
||||
margin-left: -1px;
|
||||
top: 10%;
|
||||
opacity: .15;
|
||||
box-shadow: -2px 0 15px rgba(0, 0, 0, 1);
|
||||
display: none;
|
||||
}
|
||||
|
||||
#divider.show {
|
||||
display: block;
|
||||
}
|
||||
|
||||
#loader {
|
||||
position: absolute;
|
||||
z-index: 10;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
margin: -33px 0 0 -33px;
|
||||
}
|
||||
|
||||
.pull-left {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.pull-right {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.highlight {
|
||||
background-color: yellow;
|
||||
}
|
||||
|
||||
.overlay {
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
visibility: hidden;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 1000;
|
||||
opacity: 0;
|
||||
background: rgba(255,255,255,0.8);
|
||||
-webkit-transition: all 0.3s;
|
||||
-moz-transition: all 0.3s;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.hide {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.translucent {
|
||||
opacity: 0 !important;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 1040px) {
|
||||
/*
|
||||
#viewer{
|
||||
width: 50%;
|
||||
margin-left: 25%;
|
||||
}
|
||||
*/
|
||||
#divider,
|
||||
#divider.show {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 900px) {
|
||||
/*
|
||||
#viewer{
|
||||
width: 60%;
|
||||
margin-left: 20%;
|
||||
}
|
||||
*/
|
||||
#prev {
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
#next {
|
||||
padding-right: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 550px) {
|
||||
/*
|
||||
#viewer{
|
||||
width: 80%;
|
||||
margin-left: 10%;
|
||||
}
|
||||
*/
|
||||
#viewer {
|
||||
width: 95%;
|
||||
}
|
||||
|
||||
#prev {
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
#next {
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
.arrow div {
|
||||
text-indent: 100%;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/*
|
||||
#main {
|
||||
-webkit-transform: translate(0, 0);
|
||||
-moz-transform: translate(0, 0);
|
||||
-webkit-transition: -webkit-transform .3s;
|
||||
-moz-transition: -moz-transform .3s;
|
||||
}
|
||||
|
||||
#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:;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
505
files_reader/vendor/pdfjs/css/normalize.css
vendored
Normal file
505
files_reader/vendor/pdfjs/css/normalize.css
vendored
Normal file
|
@ -0,0 +1,505 @@
|
|||
/*! normalize.css v1.0.1 | MIT License | git.io/normalize */
|
||||
|
||||
/* ==========================================================================
|
||||
HTML5 display definitions
|
||||
========================================================================== */
|
||||
|
||||
/*
|
||||
* Corrects `block` display not defined in IE 6/7/8/9 and Firefox 3.
|
||||
*/
|
||||
|
||||
article,
|
||||
aside,
|
||||
details,
|
||||
figcaption,
|
||||
figure,
|
||||
footer,
|
||||
header,
|
||||
hgroup,
|
||||
nav,
|
||||
section,
|
||||
summary {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/*
|
||||
* Corrects `inline-block` display not defined in IE 6/7/8/9 and Firefox 3.
|
||||
*/
|
||||
|
||||
audio,
|
||||
canvas,
|
||||
video {
|
||||
display: inline-block;
|
||||
*display: inline;
|
||||
*zoom: 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Prevents modern browsers from displaying `audio` without controls.
|
||||
* Remove excess height in iOS 5 devices.
|
||||
*/
|
||||
|
||||
audio:not([controls]) {
|
||||
display: none;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Addresses styling for `hidden` attribute not present in IE 7/8/9, Firefox 3,
|
||||
* and Safari 4.
|
||||
* Known issue: no IE 6 support.
|
||||
*/
|
||||
|
||||
[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
Base
|
||||
========================================================================== */
|
||||
|
||||
/*
|
||||
* 1. Corrects text resizing oddly in IE 6/7 when body `font-size` is set using
|
||||
* `em` units.
|
||||
* 2. Prevents iOS text size adjust after orientation change, without disabling
|
||||
* user zoom.
|
||||
*/
|
||||
|
||||
html {
|
||||
font-size: 100%; /* 1 */
|
||||
-webkit-text-size-adjust: 100%; /* 2 */
|
||||
-ms-text-size-adjust: 100%; /* 2 */
|
||||
}
|
||||
|
||||
/*
|
||||
* Addresses `font-family` inconsistency between `textarea` and other form
|
||||
* elements.
|
||||
*/
|
||||
|
||||
html,
|
||||
button,
|
||||
input,
|
||||
select,
|
||||
textarea {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
/*
|
||||
* Addresses margins handled incorrectly in IE 6/7.
|
||||
*/
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
Links
|
||||
========================================================================== */
|
||||
|
||||
/*
|
||||
* Addresses `outline` inconsistency between Chrome and other browsers.
|
||||
*/
|
||||
|
||||
a:focus {
|
||||
outline: thin dotted;
|
||||
}
|
||||
|
||||
/*
|
||||
* Improves readability when focused and also mouse hovered in all browsers.
|
||||
*/
|
||||
|
||||
a:active,
|
||||
a:hover {
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
Typography
|
||||
========================================================================== */
|
||||
|
||||
/*
|
||||
* Addresses font sizes and margins set differently in IE 6/7.
|
||||
* Addresses font sizes within `section` and `article` in Firefox 4+, Safari 5,
|
||||
* and Chrome.
|
||||
*/
|
||||
|
||||
h1 {
|
||||
font-size: 2em;
|
||||
margin: 0.67em 0;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.5em;
|
||||
margin: 0.83em 0;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 1.17em;
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: 1em;
|
||||
margin: 1.33em 0;
|
||||
}
|
||||
|
||||
h5 {
|
||||
font-size: 0.83em;
|
||||
margin: 1.67em 0;
|
||||
}
|
||||
|
||||
h6 {
|
||||
font-size: 0.75em;
|
||||
margin: 2.33em 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Addresses styling not present in IE 7/8/9, Safari 5, and Chrome.
|
||||
*/
|
||||
|
||||
abbr[title] {
|
||||
border-bottom: 1px dotted;
|
||||
}
|
||||
|
||||
/*
|
||||
* Addresses style set to `bolder` in Firefox 3+, Safari 4/5, and Chrome.
|
||||
*/
|
||||
|
||||
b,
|
||||
strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
margin: 1em 40px;
|
||||
}
|
||||
|
||||
/*
|
||||
* Addresses styling not present in Safari 5 and Chrome.
|
||||
*/
|
||||
|
||||
dfn {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
/*
|
||||
* Addresses styling not present in IE 6/7/8/9.
|
||||
*/
|
||||
|
||||
mark {
|
||||
background: #ff0;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
/*
|
||||
* Addresses margins set differently in IE 6/7.
|
||||
*/
|
||||
|
||||
p,
|
||||
pre {
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Corrects font family set oddly in IE 6, Safari 4/5, and Chrome.
|
||||
*/
|
||||
|
||||
code,
|
||||
kbd,
|
||||
pre,
|
||||
samp {
|
||||
font-family: monospace, serif;
|
||||
_font-family: 'courier new', monospace;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
/*
|
||||
* Improves readability of pre-formatted text in all browsers.
|
||||
*/
|
||||
|
||||
pre {
|
||||
white-space: pre;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
/*
|
||||
* Addresses CSS quotes not supported in IE 6/7.
|
||||
*/
|
||||
|
||||
q {
|
||||
quotes: none;
|
||||
}
|
||||
|
||||
/*
|
||||
* Addresses `quotes` property not supported in Safari 4.
|
||||
*/
|
||||
|
||||
q:before,
|
||||
q:after {
|
||||
content: '';
|
||||
content: none;
|
||||
}
|
||||
|
||||
/*
|
||||
* Addresses inconsistent and variable font size in all browsers.
|
||||
*/
|
||||
|
||||
small {
|
||||
font-size: 80%;
|
||||
}
|
||||
|
||||
/*
|
||||
* Prevents `sub` and `sup` affecting `line-height` in all browsers.
|
||||
*/
|
||||
|
||||
sub,
|
||||
sup {
|
||||
font-size: 75%;
|
||||
line-height: 0;
|
||||
position: relative;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
sup {
|
||||
top: -0.5em;
|
||||
}
|
||||
|
||||
sub {
|
||||
bottom: -0.25em;
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
Lists
|
||||
========================================================================== */
|
||||
|
||||
/*
|
||||
* Addresses margins set differently in IE 6/7.
|
||||
*/
|
||||
|
||||
dl,
|
||||
menu,
|
||||
ol,
|
||||
ul {
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
dd {
|
||||
margin: 0 0 0 40px;
|
||||
}
|
||||
|
||||
/*
|
||||
* Addresses paddings set differently in IE 6/7.
|
||||
*/
|
||||
|
||||
menu,
|
||||
ol,
|
||||
ul {
|
||||
padding: 0 0 0 40px;
|
||||
}
|
||||
|
||||
/*
|
||||
* Corrects list images handled incorrectly in IE 7.
|
||||
*/
|
||||
|
||||
nav ul,
|
||||
nav ol {
|
||||
list-style: none;
|
||||
list-style-image: none;
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
Embedded content
|
||||
========================================================================== */
|
||||
|
||||
/*
|
||||
* 1. Removes border when inside `a` element in IE 6/7/8/9 and Firefox 3.
|
||||
* 2. Improves image quality when scaled in IE 7.
|
||||
*/
|
||||
|
||||
img {
|
||||
border: 0; /* 1 */
|
||||
-ms-interpolation-mode: bicubic; /* 2 */
|
||||
}
|
||||
|
||||
/*
|
||||
* Corrects overflow displayed oddly in IE 9.
|
||||
*/
|
||||
|
||||
svg:not(:root) {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
Figures
|
||||
========================================================================== */
|
||||
|
||||
/*
|
||||
* Addresses margin not present in IE 6/7/8/9, Safari 5, and Opera 11.
|
||||
*/
|
||||
|
||||
figure {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
Forms
|
||||
========================================================================== */
|
||||
|
||||
/*
|
||||
* Corrects margin displayed oddly in IE 6/7.
|
||||
*/
|
||||
|
||||
form {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Define consistent border, margin, and padding.
|
||||
*/
|
||||
|
||||
fieldset {
|
||||
border: 1px solid #c0c0c0;
|
||||
margin: 0 2px;
|
||||
padding: 0.35em 0.625em 0.75em;
|
||||
}
|
||||
|
||||
/*
|
||||
* 1. Corrects color not being inherited in IE 6/7/8/9.
|
||||
* 2. Corrects text not wrapping in Firefox 3.
|
||||
* 3. Corrects alignment displayed oddly in IE 6/7.
|
||||
*/
|
||||
|
||||
legend {
|
||||
border: 0; /* 1 */
|
||||
padding: 0;
|
||||
white-space: normal; /* 2 */
|
||||
*margin-left: -7px; /* 3 */
|
||||
}
|
||||
|
||||
/*
|
||||
* 1. Corrects font size not being inherited in all browsers.
|
||||
* 2. Addresses margins set differently in IE 6/7, Firefox 3+, Safari 5,
|
||||
* and Chrome.
|
||||
* 3. Improves appearance and consistency in all browsers.
|
||||
*/
|
||||
|
||||
button,
|
||||
input,
|
||||
select,
|
||||
textarea {
|
||||
font-size: 100%; /* 1 */
|
||||
margin: 0; /* 2 */
|
||||
vertical-align: baseline; /* 3 */
|
||||
*vertical-align: middle; /* 3 */
|
||||
}
|
||||
|
||||
/*
|
||||
* Addresses Firefox 3+ setting `line-height` on `input` using `!important` in
|
||||
* the UA stylesheet.
|
||||
*/
|
||||
|
||||
button,
|
||||
input {
|
||||
line-height: normal;
|
||||
}
|
||||
|
||||
/*
|
||||
* 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`
|
||||
* and `video` controls.
|
||||
* 2. Corrects inability to style clickable `input` types in iOS.
|
||||
* 3. Improves usability and consistency of cursor style between image-type
|
||||
* `input` and others.
|
||||
* 4. Removes inner spacing in IE 7 without affecting normal text inputs.
|
||||
* Known issue: inner spacing remains in IE 6.
|
||||
*/
|
||||
|
||||
button,
|
||||
html input[type="button"], /* 1 */
|
||||
input[type="reset"],
|
||||
input[type="submit"] {
|
||||
-webkit-appearance: button; /* 2 */
|
||||
cursor: pointer; /* 3 */
|
||||
*overflow: visible; /* 4 */
|
||||
}
|
||||
|
||||
/*
|
||||
* Re-set default cursor for disabled elements.
|
||||
*/
|
||||
|
||||
button[disabled],
|
||||
input[disabled] {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
/*
|
||||
* 1. Addresses box sizing set to content-box in IE 8/9.
|
||||
* 2. Removes excess padding in IE 8/9.
|
||||
* 3. Removes excess padding in IE 7.
|
||||
* Known issue: excess padding remains in IE 6.
|
||||
*/
|
||||
|
||||
input[type="checkbox"],
|
||||
input[type="radio"] {
|
||||
box-sizing: border-box; /* 1 */
|
||||
padding: 0; /* 2 */
|
||||
*height: 13px; /* 3 */
|
||||
*width: 13px; /* 3 */
|
||||
}
|
||||
|
||||
/*
|
||||
* 1. Addresses `appearance` set to `searchfield` in Safari 5 and Chrome.
|
||||
* 2. Addresses `box-sizing` set to `border-box` in Safari 5 and Chrome
|
||||
* (include `-moz` to future-proof).
|
||||
*/
|
||||
/*
|
||||
input[type="search"] {
|
||||
-webkit-appearance: textfield;
|
||||
-moz-box-sizing: content-box;
|
||||
-webkit-box-sizing: content-box;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* Removes inner padding and search cancel button in Safari 5 and Chrome
|
||||
* on OS X.
|
||||
*/
|
||||
|
||||
/* input[type="search"]::-webkit-search-cancel-button,
|
||||
input[type="search"]::-webkit-search-decoration {
|
||||
-webkit-appearance: none;
|
||||
} */
|
||||
|
||||
/*
|
||||
* Removes inner padding and border in Firefox 3+.
|
||||
*/
|
||||
|
||||
button::-moz-focus-inner,
|
||||
input::-moz-focus-inner {
|
||||
border: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* 1. Removes default vertical scrollbar in IE 6/7/8/9.
|
||||
* 2. Improves readability and alignment in all browsers.
|
||||
*/
|
||||
|
||||
textarea {
|
||||
overflow: auto; /* 1 */
|
||||
vertical-align: top; /* 2 */
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
Tables
|
||||
========================================================================== */
|
||||
|
||||
/*
|
||||
* Remove most spacing between table cells.
|
||||
*/
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
}
|
109
files_reader/vendor/pdfjs/css/popup.css
vendored
Normal file
109
files_reader/vendor/pdfjs/css/popup.css
vendored
Normal file
|
@ -0,0 +1,109 @@
|
|||
/* http://davidwalsh.name/css-tooltips */
|
||||
/* base CSS element */
|
||||
.popup {
|
||||
background: #eee;
|
||||
border: 1px solid #ccc;
|
||||
padding: 10px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
|
||||
position: fixed;
|
||||
max-width: 300px;
|
||||
font-size: 12px;
|
||||
|
||||
display: none;
|
||||
margin-left: 2px;
|
||||
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
.popup.above {
|
||||
margin-top: -10px;
|
||||
}
|
||||
|
||||
.popup.left {
|
||||
margin-left: -20px;
|
||||
}
|
||||
|
||||
.popup.right {
|
||||
margin-left: 40px;
|
||||
}
|
||||
|
||||
.pop_content {
|
||||
max-height: 225px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.pop_content > p {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
/* below */
|
||||
.popup:before {
|
||||
position: absolute;
|
||||
display: inline-block;
|
||||
border-bottom: 10px solid #eee;
|
||||
border-right: 10px solid transparent;
|
||||
border-left: 10px solid transparent;
|
||||
border-bottom-color: rgba(0, 0, 0, 0.2);
|
||||
left: 50%;
|
||||
top: -10px;
|
||||
margin-left: -6px;
|
||||
content: '';
|
||||
}
|
||||
|
||||
.popup:after {
|
||||
position: absolute;
|
||||
display: inline-block;
|
||||
border-bottom: 9px solid #eee;
|
||||
border-right: 9px solid transparent;
|
||||
border-left: 9px solid transparent;
|
||||
left: 50%;
|
||||
top: -9px;
|
||||
margin-left: -5px;
|
||||
content: '';
|
||||
}
|
||||
|
||||
/* above */
|
||||
.popup.above:before {
|
||||
border-bottom: none;
|
||||
border-top: 10px solid #eee;
|
||||
border-top-color: rgba(0, 0, 0, 0.2);
|
||||
top: 100%;
|
||||
}
|
||||
|
||||
.popup.above:after {
|
||||
border-bottom: none;
|
||||
border-top: 9px solid #eee;
|
||||
top: 100%;
|
||||
}
|
||||
|
||||
.popup.left:before,
|
||||
.popup.left:after
|
||||
{
|
||||
left: 20px;
|
||||
}
|
||||
|
||||
.popup.right:before,
|
||||
.popup.right:after
|
||||
{
|
||||
left: auto;
|
||||
right: 20px;
|
||||
}
|
||||
|
||||
|
||||
.popup.show, .popup.on {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.note-marker,
|
||||
.EPUBJS-CFI-MARKER,
|
||||
.EPUBJS-CFI-SPLIT {
|
||||
vertical-align: super;
|
||||
font-size: 0.75em;
|
||||
line-height: 1em;
|
||||
padding: 0.1em;
|
||||
background-color: #fffa96;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
494
files_reader/vendor/pdfjs/css/sidebar.css
vendored
Normal file
494
files_reader/vendor/pdfjs/css/sidebar.css
vendored
Normal file
|
@ -0,0 +1,494 @@
|
|||
/* sidebar */
|
||||
|
||||
.sidebar.open {
|
||||
box-shadow: 3px 0px 3px 0px rgba(0, 0, 0, 0.4);
|
||||
display: block;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
background: #6b6b6b;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
min-width: 25em;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
display: none;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.sidebar.wide {
|
||||
width: 20%;
|
||||
}
|
||||
|
||||
.toolbar,
|
||||
.panels {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 2em;
|
||||
background: #4e4e4e;
|
||||
/* above titlebar controls */
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.toolbar .metainfo {
|
||||
font-size: 1.2em;
|
||||
top: 0.5em;
|
||||
}
|
||||
|
||||
.toolbar div {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.toolbar .separator {
|
||||
/* border: solid 1px; */
|
||||
height: 1em;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.toolbar button, .sidebar button {
|
||||
color: white;
|
||||
border: none;
|
||||
background-color: transparent;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.sidebar div > button {
|
||||
/* font-size: 1.5em; */
|
||||
/* font-size: 1em; */
|
||||
padding: 0.4em;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.mobile .sidebar div > button {
|
||||
padding: 0.5em;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.sidebar div > button:hover {
|
||||
color: #8CC746;
|
||||
}
|
||||
|
||||
.panels .open {
|
||||
background-color: #6B6B6B;
|
||||
}
|
||||
|
||||
.view.open {
|
||||
display: block !important;
|
||||
}
|
||||
|
||||
.view {
|
||||
overflow-x: hidden;
|
||||
display: none !important;
|
||||
width: 100%;
|
||||
position: absolute;
|
||||
top: 2em;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
.list_item a {
|
||||
color: #AAA;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.list_item a.chapter {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.list_item a.section {
|
||||
font-size: .8em;
|
||||
}
|
||||
|
||||
.list_item.currentChapter > a,
|
||||
.list_item a:hover {
|
||||
color: #f1f1f1
|
||||
}
|
||||
|
||||
.list_item a:hover {
|
||||
color: #E2E2E2;
|
||||
}
|
||||
|
||||
.list_item ul {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.list_item.currentChapter > ul,
|
||||
.list_item.openChapter > ul {
|
||||
display: block;
|
||||
}
|
||||
|
||||
legend {
|
||||
margin-left: 1em;
|
||||
padding: 0.5em;
|
||||
box-shadow: 0 1px 10px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
.settings-container {
|
||||
text-align: left;
|
||||
margin: 1em;
|
||||
background: #F8F8F8;
|
||||
color: #111;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 1px 10px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
.settings-container > legend {
|
||||
position: relative;
|
||||
top: 1em;
|
||||
margin-bottom: 1em;
|
||||
text-align: center;
|
||||
font-weight: 600;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.settings-container label {
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
.center-box {
|
||||
text-align: center;
|
||||
margin: 1em;
|
||||
}
|
||||
|
||||
.font_example {
|
||||
margin: 1em;
|
||||
text-align: center;
|
||||
box-shadow: inset 0 1px 10px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
.font_example div {
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
.view .control-group input[type=range] {
|
||||
width: 90%;
|
||||
float: right;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.view .control-group {
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
.view .sliders {
|
||||
font-size: 1.5em;
|
||||
}
|
||||
|
||||
.view .control-group span {
|
||||
float: left;
|
||||
margin: 0 2px;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.view .control-group input[type=reset] {
|
||||
float: right;
|
||||
}
|
||||
.metadata {
|
||||
padding: 1em;
|
||||
margin: 1em;
|
||||
}
|
||||
|
||||
.metadata table {
|
||||
font-size: 1.2em;
|
||||
color: #F8F8F8;
|
||||
}
|
||||
|
||||
.metadata td:nth-child(1) {
|
||||
font-weight: bold;
|
||||
padding-right: 1em;
|
||||
}
|
||||
|
||||
/* panels */
|
||||
.panels a {
|
||||
visibility: hidden;
|
||||
overflow: hidden;
|
||||
display: inline-block;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.panels a::before {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.panels a:hover {
|
||||
color: #AAA;
|
||||
}
|
||||
|
||||
.panels a:active {
|
||||
color: #AAA;
|
||||
margin: 1px 0 -1px 6px;
|
||||
}
|
||||
|
||||
.panels a.active,
|
||||
.panels a.active:hover {
|
||||
color: #AAA;
|
||||
}
|
||||
|
||||
/* END panels */
|
||||
|
||||
/* TOC (and search, and bookmarks) */
|
||||
.toc_toggle {
|
||||
display: inline-block;
|
||||
width: 14px;
|
||||
cursor: pointer;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.toc_toggle:before {
|
||||
content: '▸';
|
||||
color: #fff;
|
||||
margin-right: -4px;
|
||||
}
|
||||
|
||||
.currentChapter > .toc_toggle:before,
|
||||
.openChapter > .toc_toggle:before {
|
||||
content: '▾';
|
||||
}
|
||||
|
||||
#toc-populate.open {
|
||||
display: inline-block !important;
|
||||
background-color: #4e4e4e;
|
||||
}
|
||||
|
||||
.toc-view li,
|
||||
.bookmarks-view li,
|
||||
.search-view li {
|
||||
margin: 1em;
|
||||
font-family: Georgia, "Times New Roman", Times, serif;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.toc-view li {
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
.toc-vew.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.bookmark_link_text {
|
||||
float: right;
|
||||
font-size: 75%;
|
||||
margin: 1em;
|
||||
color: #AAA;
|
||||
}
|
||||
|
||||
/* END TOC */
|
||||
|
||||
|
||||
/* search */
|
||||
|
||||
.search-view,
|
||||
.notes-view {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.search-results {
|
||||
overflow-y: scroll;
|
||||
height: 95%;
|
||||
height: calc(100vh - 5em);
|
||||
}
|
||||
|
||||
.search-input {
|
||||
padding-top: 1em;
|
||||
padding-bottom: 1em;
|
||||
box-shadow: 0 1px 10px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
.searchbox {
|
||||
width: 80%;
|
||||
float: left;
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
.searchbox + span {
|
||||
position: relative;
|
||||
left: -1em;
|
||||
visibility: hidden;
|
||||
font-weight: bold;
|
||||
font-family: sans-serif;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.searchbox + span:hover {
|
||||
color: red;
|
||||
}
|
||||
|
||||
#clear_search {
|
||||
padding: 0;
|
||||
padding-right: 0.5em;
|
||||
}
|
||||
|
||||
/* END search */
|
||||
|
||||
/* notes */
|
||||
|
||||
.notes-input {
|
||||
padding-top: 1em;
|
||||
padding-bottom: 2em;
|
||||
box-shadow: 0 1px 10px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
.notes {
|
||||
overflow-y: scroll;
|
||||
height: 95%;
|
||||
height: calc(100vh - 11em);
|
||||
}
|
||||
|
||||
.notes li,
|
||||
.bookmarks li {
|
||||
margin: 1em 1em 1em 0.5em;
|
||||
padding: 0.25em 0 0 0.5em;
|
||||
font-family: Georgia, "Times New Roman", Times, serif;
|
||||
/* border-top: 1px #eee dotted; */
|
||||
color: #ccc;
|
||||
padding-bottom: 0.5em;
|
||||
border-left: 0.5em solid transparent;
|
||||
}
|
||||
|
||||
.notes li:hover,
|
||||
.bookmarks li:hover {
|
||||
border-left: 0.5em solid #eee;
|
||||
}
|
||||
|
||||
.notes li:hover span,
|
||||
.notes li:hover a,
|
||||
.bookmarks li:hover span,
|
||||
.bookmarks li:hover a {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.item-date {
|
||||
text-align: right;
|
||||
font-size: 0.8em;
|
||||
padding-top: 0.5em;
|
||||
color: #bbb;
|
||||
}
|
||||
|
||||
.item-delete,
|
||||
.item-edit,
|
||||
.item-save,
|
||||
.item-cancel,
|
||||
.note-link {
|
||||
color: #999;
|
||||
display: inline-block;
|
||||
text-decoration: none;
|
||||
margin-right: 0.5em;
|
||||
margin-top: 0.5em;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.item-save,
|
||||
.item-cancel {
|
||||
background-color: #ccc;
|
||||
padding: 0.2em 0.4em;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 0.2em;
|
||||
}
|
||||
|
||||
.item-save:hover,
|
||||
.item-cancel:hover {
|
||||
background-color: #eee;
|
||||
border: 1px solid white;
|
||||
}
|
||||
|
||||
.item-save {
|
||||
color: green !important;
|
||||
}
|
||||
|
||||
.item-cancel {
|
||||
color: red !important;
|
||||
}
|
||||
|
||||
.note-link {
|
||||
float: right;
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.note-delete,
|
||||
.note-edit {
|
||||
float: left;
|
||||
}
|
||||
|
||||
div.editable {
|
||||
background-color: #EEE;
|
||||
color: #111;
|
||||
/* border: 1px dotted white; */
|
||||
border-radius: 0.2em;
|
||||
padding: 0.25em;
|
||||
box-shadow: inset 0 1px 10px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
.notes li a:hover,
|
||||
.bookmarks li a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.notes li img {
|
||||
}
|
||||
|
||||
.note-text {
|
||||
text-align: left;
|
||||
display: block;
|
||||
width: calc(100% - 2em);
|
||||
height: 6em;
|
||||
margin-left: 1em;
|
||||
margin-right: 1em;
|
||||
margin-bottom: 1em;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.note-text[disabled], #note-text[disabled="disabled"]{
|
||||
opacity: .5;
|
||||
}
|
||||
|
||||
.note-anchor {
|
||||
font-size: 1.5em;
|
||||
padding: 0 !important;
|
||||
margin-right: 0.5em !important;
|
||||
}
|
||||
|
||||
.note-marker {
|
||||
vertical-align: super;
|
||||
font-size: 0.75em;
|
||||
line-height: 1em;
|
||||
padding: 0.1em;
|
||||
background-color: #fffa96;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* END notes */
|
||||
|
||||
/* margins */
|
||||
|
||||
.margin-icon {
|
||||
float: none !important;
|
||||
font-size: 3em;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
/* media-specific rules */
|
||||
|
||||
@media only screen and (max-width: 25em) {
|
||||
|
||||
.sidebar {
|
||||
min-width: 10em;
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
#main.single {
|
||||
width: 100% !important;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* END sidebar */
|
||||
|
||||
|
6
files_reader/vendor/pdfjs/lib/pdf.js
vendored
Normal file
6
files_reader/vendor/pdfjs/lib/pdf.js
vendored
Normal file
File diff suppressed because one or more lines are too long
19
files_reader/vendor/pdfjs/lib/pdf.worker.js
vendored
Normal file
19
files_reader/vendor/pdfjs/lib/pdf.worker.js
vendored
Normal file
File diff suppressed because one or more lines are too long
312
files_reader/vendor/pdfjs/pdf.reader.js
vendored
Normal file
312
files_reader/vendor/pdfjs/pdf.reader.js
vendored
Normal file
|
@ -0,0 +1,312 @@
|
|||
PDFJS.reader = {};
|
||||
PDFJS.reader.plugins = {};
|
||||
|
||||
(function(root, $) {
|
||||
|
||||
var previousReader = root.pdfReader || {};
|
||||
|
||||
var pdfReader = root.pdfReader = function(path, options) {
|
||||
return new PDFJS.Reader(path, options);
|
||||
};
|
||||
|
||||
})(window, jQuery);
|
||||
|
||||
PDFJS.Reader = function(bookPath, _options) {
|
||||
|
||||
var reader = this,
|
||||
book,
|
||||
$viewer = $("#viewer"),
|
||||
search = window.location.search;
|
||||
|
||||
this.settings = this.defaults(_options || {}, {
|
||||
bookPath: bookPath,
|
||||
numPages: 0,
|
||||
currentPage: 1,
|
||||
scale: 1,
|
||||
sideBySide: true, // when true, render 2 pages side-by-side
|
||||
oddPageRight: true, // when true, odd pages render on the right side
|
||||
history: true,
|
||||
keyboard: {
|
||||
32: 'next', // space
|
||||
34: 'next', // page-down
|
||||
39: 'next', // cursor-right
|
||||
33: 'previous', // page-up
|
||||
37: 'previous', // cursor-left
|
||||
36: 'first', // home
|
||||
35: 'last', // end
|
||||
65: 'annotate', // a
|
||||
66: 'bookmark', // b
|
||||
82: 'reflow', // r
|
||||
83: 'toggleSidebar', // s
|
||||
84: 'toolbar', // t
|
||||
68: 'toggleDay', // d
|
||||
78: 'toggleNight', // n
|
||||
70: 'toggleFullscreen', // f
|
||||
27: 'closeSidebar' // esc
|
||||
},
|
||||
nightMode: false,
|
||||
dayMode: false,
|
||||
maxWidth: 72,
|
||||
pageArrows: false,
|
||||
annotations: {},
|
||||
customStyles: {},
|
||||
activeStyles: {},
|
||||
session: {}
|
||||
});
|
||||
|
||||
// used for annotations and bookmarks
|
||||
this.Annotation = function (type, anchor, body, id) {
|
||||
this.id = id || EPUBJS.core.uuid();
|
||||
this.type = type;
|
||||
this.date = Date.now();
|
||||
this.edited = this.date;
|
||||
this.anchor = anchor;
|
||||
this.body = body;
|
||||
};
|
||||
|
||||
// used for UI and book styles
|
||||
this.Style = function (name, selector, rules, extra) {
|
||||
this.name = name;
|
||||
this.selector = selector;
|
||||
this.rules = rules;
|
||||
this.extra = extra || null;
|
||||
};
|
||||
|
||||
this.canvaslst = [
|
||||
document.getElementById("left"),
|
||||
document.getElementById("right")
|
||||
];
|
||||
|
||||
this.contextlst = [
|
||||
document.getElementById("left").getContext('2d'),
|
||||
document.getElementById("right").getContext('2d')
|
||||
];
|
||||
|
||||
// Overide options with search parameters
|
||||
if(search) {
|
||||
parameters = search.slice(1).split("&");
|
||||
parameters.forEach(function(p){
|
||||
var split = p.split("=");
|
||||
var name = split[0];
|
||||
var value = split[1] || '';
|
||||
reader.settings[name] = decodeURIComponent(value);
|
||||
});
|
||||
}
|
||||
|
||||
//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.sideBySide = window.outerWidth > window.outerHeight ? true : false;
|
||||
this.sideBySide = false;
|
||||
this.pageNumPending = null;
|
||||
|
||||
PDFJS.getDocument(reader.settings.bookPath).then(function(_book) {
|
||||
reader.book = book = _book;
|
||||
console.log(book);
|
||||
reader.settings.numPages = reader.book.numPages;
|
||||
document.getElementById('total_pages').textContent = reader.settings.numPages;
|
||||
if(reader.settings.session.cursor !== {}) {
|
||||
reader.settings.currentPage = parseInt(reader.settings.session.cursor.anchor);
|
||||
}
|
||||
|
||||
reader.ReaderController = PDFJS.reader.ReaderController.call(reader, book);
|
||||
reader.SettingsController = PDFJS.reader.SettingsController.call(reader, book);
|
||||
reader.ControlsController = PDFJS.reader.ControlsController.call(reader, book);
|
||||
reader.SidebarController = PDFJS.reader.SidebarController.call(reader, book);
|
||||
// BookmarksController depends on NotesController so load NotesController first
|
||||
//reader.NotesController = PDFJS.reader.NotesController.call(reader, book);
|
||||
//reader.BookmarksController = PDFJS.reader.BookmarksController.call(reader, book);
|
||||
//reader.SearchController = PDFJS.reader.SearchController.call(reader, book);
|
||||
//reader.MetaController = EPUBJS.reader.MetaController.call(reader, meta);
|
||||
//reader.TocController = EPUBJS.reader.TocController.call(reader, toc);
|
||||
|
||||
//reader.queuePage(reader.settings.currentPage);
|
||||
var startPage = reader.settings.oddPageRight ? 0 : 1;
|
||||
reader.queuePage(startPage);
|
||||
reader.ReaderController.hideLoader();
|
||||
});
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
PDFJS.Reader.prototype.renderPage = function(pageNum) {
|
||||
|
||||
var reader = this,
|
||||
pageShift = this.settings.sideBySide ? 2 : 1,
|
||||
oddPageShift = this.settings.oddPageRight ? 0 : 1,
|
||||
i = (pageNum - oddPageShift) % pageShift,
|
||||
canvas = this.canvaslst[i],
|
||||
ctx = this.contextlst[i],
|
||||
pixelratio = window.devicePixelRatio,
|
||||
max_view_height = parseInt(window.outerHeight * 0.95),
|
||||
max_view_width = reader.settings.sideBySide
|
||||
? parseInt((window.outerWidth / 2) * 1)
|
||||
: parseInt(window.outerWidth * 1),
|
||||
scale,
|
||||
transform,
|
||||
$page_num = document.getElementById('page_num');
|
||||
|
||||
if (this.settings.sideBySide) {
|
||||
this.canvaslst[1].style.display = "block";
|
||||
} else {
|
||||
this.canvaslst[1].style.display = "none";
|
||||
}
|
||||
|
||||
if (pageNum <= this.settings.numPages && pageNum >= 1) {
|
||||
|
||||
this.pageRendering = true;
|
||||
|
||||
this.book.getPage(pageNum).then(function(page) {
|
||||
console.log(page);
|
||||
var page_width = page.pageInfo.view[2];
|
||||
var page_height = page.pageInfo.view[3];
|
||||
|
||||
var scale_height = parseFloat(max_view_height / page_height);
|
||||
var scale_width = parseFloat(max_view_width / page_width);
|
||||
var document_aspect = parseFloat(page_width / page_height);
|
||||
var view_aspect = parseFloat(max_view_width / max_view_height);
|
||||
|
||||
console.log(max_view_width
|
||||
+ " " + max_view_height
|
||||
+ " " + page_width
|
||||
+ " " + page_height
|
||||
+ " " + document_aspect
|
||||
+ " " + view_aspect
|
||||
+ " " + scale_width
|
||||
+ " " + scale_height
|
||||
+ " " + pixelratio);
|
||||
|
||||
scale = Math.min(scale_width, scale_height) / pixelratio;
|
||||
|
||||
if (scale_width < scale_height) {
|
||||
canvas.width = max_view_width;
|
||||
canvas.height = parseInt(page_height * scale_width);
|
||||
canvas.style.width = parseInt(max_view_width / pixelratio);
|
||||
scale = scale_width;
|
||||
} else {
|
||||
canvas.height = max_view_height;
|
||||
canvas.width = parseInt(page_width * scale_height);
|
||||
canvas.style.width = parseInt(max_view_width / pixelratio);
|
||||
scale = scale_height;
|
||||
}
|
||||
|
||||
if (document_aspect < view_aspect) {
|
||||
console.log("document aspect < view aspect, aspect ratio " + document_aspect);
|
||||
//canvas.height = parseInt(max_view_height / pixelratio);
|
||||
//canvas.width = parseInt(canvas.height * document_aspect);
|
||||
//scale = parseFloat(scale_height / pixelratio);
|
||||
transform = [ 1, 0, 0, 1, parseInt((canvas.width - (page_width*scale)) / 2), 0 ];
|
||||
} else {
|
||||
console.log("document aspect > view_aspect, aspect ratio " + document_aspect);
|
||||
|
||||
//canvas.height = parseInt(max_view_height / pixelratio);
|
||||
//canvas.width = parseInt(canvas.height * document_aspect);
|
||||
//canvas.width = parseInt(max_view_width / pixelratio);
|
||||
//canvas.height = parseInt(canvas.width * document_aspect);
|
||||
//scale = parseFloat(scale_width / pixelratio);
|
||||
canvas.style.top = parseInt((max_view_height - canvas.height) / 2);
|
||||
transform = [ 1, 0, 0, 1, 0, parseInt((canvas.height - (page_height*scale)) / 2) ];
|
||||
}
|
||||
console.log(canvas.width + " " + canvas.height);
|
||||
|
||||
var viewport = page.getViewport(scale);
|
||||
console.log(viewport);
|
||||
|
||||
var renderContext = {
|
||||
canvasContext: ctx,
|
||||
viewport: viewport
|
||||
//transform: transform
|
||||
};
|
||||
|
||||
var renderTask = page.render(renderContext);
|
||||
renderTask.promise.then(function() {
|
||||
reader.pageRendering = false;
|
||||
if (reader.pageNumPending !== null) {
|
||||
reader.renderPage(reader.pageNumPending);
|
||||
reader.pageNumPending = null;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
canvas.width = max_view_width;
|
||||
canvas.height = max_view_height;
|
||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
}
|
||||
|
||||
if (i === 0) {
|
||||
|
||||
if (pageNum > 0) {
|
||||
$page_num.textContent = pageNum.toString();
|
||||
}
|
||||
reader.settings.currentPage = pageNum;
|
||||
|
||||
} else {
|
||||
|
||||
if (pageNum === 1) {
|
||||
|
||||
$page_num.textContent = pageNum.toString();
|
||||
|
||||
} else {
|
||||
|
||||
var text = $page_num.textContent;
|
||||
text += "-" + pageNum.toString();
|
||||
$page_num.textContent = text;
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
PDFJS.Reader.prototype.queuePage = function(pageNum) {
|
||||
|
||||
var pageShift = this.settings.sideBySide ? 2 : 1;
|
||||
|
||||
if (this.pageRendering) {
|
||||
this.pageNumPending = pageNum;
|
||||
} else {
|
||||
for (var i = 0; i < pageShift; i++) {
|
||||
this.renderPage(pageNum + i);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
PDFJS.Reader.prototype.prevPage = function() {
|
||||
|
||||
var pageShift = this.settings.sideBySide ? 2 : 1;
|
||||
var oddPageShift = this.settings.oddPageRight ? 0 : 1;
|
||||
|
||||
if (this.settings.currentPage - pageShift < oddPageShift) {
|
||||
return;
|
||||
} else {
|
||||
this.queuePage(this.settings.currentPage - pageShift);
|
||||
}
|
||||
};
|
||||
|
||||
PDFJS.Reader.prototype.nextPage = function() {
|
||||
|
||||
var pageShift = this.settings.sideBySide ? 2 : 1;
|
||||
|
||||
if (this.settings.currentPage + pageShift > this.settings.numPages) {
|
||||
return;
|
||||
} else {
|
||||
this.queuePage(this.settings.currentPage + pageShift);
|
||||
}
|
||||
};
|
||||
|
||||
PDFJS.Reader.prototype.defaults = function (obj) {
|
||||
for (var i = 1, length = arguments.length; i < length; i++) {
|
||||
var source = arguments[i];
|
||||
for (var prop in source) {
|
||||
if (obj[prop] === void 0) obj[prop] = source[prop];
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
|
||||
PDFJS.Reader.prototype.setScale = function (scale) {
|
||||
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue