Commit bed7dbdb by Brian Wilson

fix plumbing for anchors and chapters.

parent 49dee508
...@@ -69,7 +69,7 @@ def pdf_index(request, course_id, book_index, chapter=None, page=None): ...@@ -69,7 +69,7 @@ def pdf_index(request, course_id, book_index, chapter=None, page=None):
'staff_access': staff_access}) 'staff_access': staff_access})
@login_required @login_required
def html_index(request, course_id, book_index, chapter=None, page=None): def html_index(request, course_id, book_index, chapter=None, anchor_id=None):
course = get_course_with_access(request.user, course_id, 'load') course = get_course_with_access(request.user, course_id, 'load')
staff_access = has_access(request.user, course, 'staff') staff_access = has_access(request.user, course, 'staff')
...@@ -99,5 +99,5 @@ def html_index(request, course_id, book_index, chapter=None, page=None): ...@@ -99,5 +99,5 @@ def html_index(request, course_id, book_index, chapter=None, page=None):
'course': course, 'course': course,
'textbook': textbook, 'textbook': textbook,
'chapter': chapter, 'chapter': chapter,
'page': page, 'anchor_id': anchor_id,
'staff_access': staff_access}) 'staff_access': staff_access})
...@@ -27,35 +27,22 @@ ...@@ -27,35 +27,22 @@
chapterToLoad = options.chapterNum; chapterToLoad = options.chapterNum;
} }
var anchorToLoad = null; var anchorToLoad = null;
if (options.chapters) {
loadUrlAsIframe = function htmlViewLoadUrlAsIframe(url, anchorId) { anchorToLoad = options.anchor_id;
if (anchorId != null) {
var newurl = url + "#" + anchorId;
$("#bookpage").src = newurl;
} else {
// $("#bookpage").src = url;
// $("#bookpage").append("<iframe seamless id="bookpage-iframe" src=" + url + "\"></iframe>")
parentElement = document.getElementById('bookpage');
while (parentElement.hasChildNodes())
parentElement.removeChild(parentElement.lastChild);
$('<iframe id="bookpage-iframe" src="' + url + '"></iframe>"')
// .css({'height':'40px','width':'200px'})
.appendTo('#bookpage');
} }
};
loadUrl = function htmlViewLoadUrl(url, anchorId) { loadUrl = function htmlViewLoadUrl(url, anchorId) {
var newurl = url;
if (anchorId != null) {
newurl = url + "#" + anchorId;
}
// clear out previous load, if any: // clear out previous load, if any:
parentElement = document.getElementById('bookpage'); parentElement = document.getElementById('bookpage');
while (parentElement.hasChildNodes()) while (parentElement.hasChildNodes())
parentElement.removeChild(parentElement.lastChild); parentElement.removeChild(parentElement.lastChild);
// load new URL in:
$('#bookpage').load(url);
$('#bookpage').load(newurl); // if there is an anchor set, then go to that location:
if (anchorId != null) {
// TODO: add implementation....
}
}; };
...@@ -105,6 +92,9 @@ ...@@ -105,6 +92,9 @@
%if chapter is not None: %if chapter is not None:
options.chapterNum = ${chapter}; options.chapterNum = ${chapter};
%endif %endif
%if anchor_id is not None:
options.anchor_id = ${anchor_id};
%endif
$('#outerContainer').myHTMLViewer(options); $('#outerContainer').myHTMLViewer(options);
}); });
......
...@@ -287,7 +287,11 @@ if settings.COURSEWARE_ENABLED: ...@@ -287,7 +287,11 @@ if settings.COURSEWARE_ENABLED:
url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/htmlbook/(?P<book_index>[^/]*)/$', url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/htmlbook/(?P<book_index>[^/]*)/$',
'staticbook.views.html_index', name="html_book"), 'staticbook.views.html_index', name="html_book"),
url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/htmlbook/(?P<book_index>[^/]*)/(?P<page>[^/]*)$', url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/htmlbook/(?P<book_index>[^/]*)/chapter/(?P<chapter>[^/]*)/$',
'staticbook.views.html_index'),
url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/htmlbook/(?P<book_index>[^/]*)/chapter/(?P<chapter>[^/]*)/(?P<anchor_id>[^/]*)/$',
'staticbook.views.html_index'),
url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/htmlbook/(?P<book_index>[^/]*)/(?P<anchor_id>[^/]*)/$',
'staticbook.views.html_index'), 'staticbook.views.html_index'),
url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/courseware/?$', url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/courseware/?$',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment