diff --git a/common/static/js/pdfviewer.js b/common/static/js/pdfviewer.js index c25b1b2e4e..720d3fe6d6 100644 --- a/common/static/js/pdfviewer.js +++ b/common/static/js/pdfviewer.js @@ -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); diff --git a/lms/djangoapps/staticbook/views.py b/lms/djangoapps/staticbook/views.py index be7e272596..319e2a9074 100644 --- a/lms/djangoapps/staticbook/views.py +++ b/lms/djangoapps/staticbook/views.py @@ -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}) diff --git a/lms/templates/static_pdfbook.html b/lms/templates/static_pdfbook.html index 386d921b90..051e752bdd 100644 --- a/lms/templates/static_pdfbook.html +++ b/lms/templates/static_pdfbook.html @@ -17,6 +17,7 @@ <%block name="js_extra"> @@ -35,6 +64,7 @@
+
@@ -88,6 +118,31 @@
+%if 'chapters' in textbook: +
+ +
    + <%def name="print_entry(entry)"> +
  • + + + ${entry.get('title')} + + +
  • + + + % 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. +
  • +
+
+%endif +
diff --git a/lms/urls.py b/lms/urls.py index 4d9798f360..e8b4b17c3c 100644 --- a/lms/urls.py +++ b/lms/urls.py @@ -280,11 +280,10 @@ if settings.COURSEWARE_ENABLED: url(r'^courses/(?P[^/]+/[^/]+/[^/]+)/pdfbook/(?P[^/]*)/(?P[^/]*)$', 'staticbook.views.pdf_index'), -# Doesn't yet support loading individual chapters... -# url(r'^courses/(?P[^/]+/[^/]+/[^/]+)/pdfbook/(?P[^/]*)/chapter/(?P[^/]*)/$', -# 'staticbook.views.pdf_index'), -# url(r'^courses/(?P[^/]+/[^/]+/[^/]+)/pdfbook/(?P[^/]*)/chapter/(?P[^/]*)/(?P[^/]*)$', -# 'staticbook.views.pdf_index'), + url(r'^courses/(?P[^/]+/[^/]+/[^/]+)/pdfbook/(?P[^/]*)/chapter/(?P[^/]*)/$', + 'staticbook.views.pdf_index'), + url(r'^courses/(?P[^/]+/[^/]+/[^/]+)/pdfbook/(?P[^/]*)/chapter/(?P[^/]*)/(?P[^/]*)$', + 'staticbook.views.pdf_index'), url(r'^courses/(?P[^/]+/[^/]+/[^/]+)/courseware/?$', 'courseware.views.index', name="courseware"),