add first pass at multi-chapter support.
This commit is contained in:
@@ -44,9 +44,6 @@ PDFJS.disableWorker = true;
|
||||
var currentScaleValue = "0";
|
||||
var DEFAULT_SCALE_VALUE = "1";
|
||||
|
||||
// TESTING:
|
||||
var destinations = null;
|
||||
|
||||
var setupText = function setupText(textdiv, content, viewport) {
|
||||
|
||||
function getPageNumberFromDest(dest) {
|
||||
@@ -270,7 +267,8 @@ PDFJS.disableWorker = true;
|
||||
//
|
||||
// Asynchronously download PDF as an ArrayBuffer
|
||||
//
|
||||
PDFJS.getDocument(url).then(
|
||||
loadUrl = function pdfViewLoadUrl(url_to_load) {
|
||||
PDFJS.getDocument(url).then(
|
||||
function getDocument(_pdfDocument) {
|
||||
pdfDocument = _pdfDocument;
|
||||
// display the current page with a default scale value:
|
||||
@@ -282,6 +280,9 @@ PDFJS.disableWorker = true;
|
||||
function getDocumentProgress(progressData) {
|
||||
// placeholder: not yet ready to display loading progress
|
||||
});
|
||||
};
|
||||
|
||||
loadUrl(url);
|
||||
|
||||
$("#previous").click(function(event) {
|
||||
prevPage();
|
||||
@@ -308,5 +309,6 @@ PDFJS.disableWorker = true;
|
||||
renderPage(newPageVal);
|
||||
}
|
||||
});
|
||||
return pdfViewer;
|
||||
}
|
||||
})(jQuery);
|
||||
|
||||
@@ -52,13 +52,19 @@ def pdf_index(request, course_id, book_index, chapter=None, page=None):
|
||||
# strip off the quotes again...
|
||||
return output_url[1:-1]
|
||||
|
||||
textbook['url'] = remap_static_url(textbook['url'], course)
|
||||
if 'url' in textbook:
|
||||
textbook['url'] = remap_static_url(textbook['url'], course)
|
||||
# then remap all the chapter URLs as well, if they are provided.
|
||||
|
||||
if 'chapters' in textbook:
|
||||
for entry in textbook['chapters']:
|
||||
entry['url'] = remap_static_url(entry['url'], course)
|
||||
|
||||
|
||||
return render_to_response('static_pdfbook.html',
|
||||
{'book_index': book_index,
|
||||
'course': course,
|
||||
'textbook': textbook,
|
||||
'chapter': chapter,
|
||||
'page': page,
|
||||
'chapter': chapter,
|
||||
'staff_access': staff_access})
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
<%block name="js_extra">
|
||||
<script type="text/javascript">
|
||||
|
||||
%if 'url' in textbook:
|
||||
var url = "${textbook['url']}";
|
||||
|
||||
$(document).ready(function() {
|
||||
@@ -27,6 +28,34 @@
|
||||
'url' : url
|
||||
});
|
||||
});
|
||||
%else:
|
||||
|
||||
var my_pdfviewer = null;
|
||||
|
||||
function load_url(url_to_load, page_to_load) {
|
||||
// $('#outerContainer').PDFViewer( {
|
||||
// 'pageNum' : page_to_load,
|
||||
// 'url' : url_to_load
|
||||
// });
|
||||
my_pdfviewer.loadUrl(url_to_load, page_to_load);
|
||||
}
|
||||
// since we have no url, we must rely on chapter display,
|
||||
// so make sure we have a value.
|
||||
var url = "${ textbook['chapters'][chapter-1 if chapter is not None else 0]['url'] }";
|
||||
|
||||
$(document).ready(function() {
|
||||
// load_url(url, ${page if page is not None else 1});
|
||||
var my_pdfviewer = $('#outerContainer').PDFViewer( {
|
||||
'pageNum' : ${page if page is not None else 1},
|
||||
'url' : url
|
||||
});
|
||||
if (my_pdfviewer) {
|
||||
|
||||
}
|
||||
|
||||
} );
|
||||
%endif
|
||||
|
||||
</script>
|
||||
</%block>
|
||||
|
||||
@@ -35,6 +64,7 @@
|
||||
|
||||
<div id="outerContainer">
|
||||
<div id="mainContainer">
|
||||
|
||||
<div class="toolbar">
|
||||
<div id="toolbarContainer">
|
||||
<div id="toolbarViewer">
|
||||
@@ -88,6 +118,31 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
%if 'chapters' in textbook:
|
||||
<section aria-label="Textbook Navigation" class="book-sidebar">
|
||||
|
||||
<ul id="pdfbooknav" class="treeview-booknav">
|
||||
<%def name="print_entry(entry)">
|
||||
<li>
|
||||
<a href="javascript:load_url(${entry.get('url')}, 1)">
|
||||
<span class="chapter">
|
||||
${entry.get('title')}
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</%def>
|
||||
|
||||
% for entry in textbook['chapters']:
|
||||
${print_entry(entry)}
|
||||
% endfor
|
||||
|
||||
## Don't delete this empty list item. Without it, Jquery.TreeView won't
|
||||
## render the last list item as expandable.
|
||||
<li></li>
|
||||
</ul>
|
||||
</section>
|
||||
%endif
|
||||
|
||||
<div id="viewerContainer">
|
||||
<div id="viewer" contextmenu="viewerContextMenu"></div>
|
||||
</div>
|
||||
|
||||
@@ -280,11 +280,10 @@ if settings.COURSEWARE_ENABLED:
|
||||
url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/pdfbook/(?P<book_index>[^/]*)/(?P<page>[^/]*)$',
|
||||
'staticbook.views.pdf_index'),
|
||||
|
||||
# Doesn't yet support loading individual chapters...
|
||||
# url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/pdfbook/(?P<book_index>[^/]*)/chapter/(?P<chapter>[^/]*)/$',
|
||||
# 'staticbook.views.pdf_index'),
|
||||
# url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/pdfbook/(?P<book_index>[^/]*)/chapter/(?P<chapter>[^/]*)/(?P<page>[^/]*)$',
|
||||
# 'staticbook.views.pdf_index'),
|
||||
url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/pdfbook/(?P<book_index>[^/]*)/chapter/(?P<chapter>[^/]*)/$',
|
||||
'staticbook.views.pdf_index'),
|
||||
url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/pdfbook/(?P<book_index>[^/]*)/chapter/(?P<chapter>[^/]*)/(?P<page>[^/]*)$',
|
||||
'staticbook.views.pdf_index'),
|
||||
|
||||
url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/courseware/?$',
|
||||
'courseware.views.index', name="courseware"),
|
||||
|
||||
Reference in New Issue
Block a user