fix plumbing for anchors and chapters.

This commit is contained in:
Brian Wilson
2013-03-08 18:25:33 -05:00
parent 49dee5080a
commit bed7dbdb6b
3 changed files with 19 additions and 25 deletions

View File

@@ -69,7 +69,7 @@ def pdf_index(request, course_id, book_index, chapter=None, page=None):
'staff_access': staff_access})
@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')
staff_access = has_access(request.user, course, 'staff')
@@ -99,5 +99,5 @@ def html_index(request, course_id, book_index, chapter=None, page=None):
'course': course,
'textbook': textbook,
'chapter': chapter,
'page': page,
'anchor_id': anchor_id,
'staff_access': staff_access})

View File

@@ -27,35 +27,22 @@
chapterToLoad = options.chapterNum;
}
var anchorToLoad = null;
loadUrlAsIframe = function htmlViewLoadUrlAsIframe(url, anchorId) {
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');
}
};
if (options.chapters) {
anchorToLoad = options.anchor_id;
}
loadUrl = function htmlViewLoadUrl(url, anchorId) {
var newurl = url;
if (anchorId != null) {
newurl = url + "#" + anchorId;
}
// clear out previous load, if any:
parentElement = document.getElementById('bookpage');
while (parentElement.hasChildNodes())
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 @@
%if chapter is not None:
options.chapterNum = ${chapter};
%endif
%if anchor_id is not None:
options.anchor_id = ${anchor_id};
%endif
$('#outerContainer').myHTMLViewer(options);
});

View File

@@ -287,7 +287,11 @@ if settings.COURSEWARE_ENABLED:
url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/htmlbook/(?P<book_index>[^/]*)/$',
'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'),
url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/courseware/?$',