Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
fa00ea44
Commit
fa00ea44
authored
Feb 25, 2013
by
Brian Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add first pass at multi-chapter support.
parent
ff35d3e6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
11 deletions
+73
-11
common/static/js/pdfviewer.js
+6
-4
lms/djangoapps/staticbook/views.py
+8
-2
lms/templates/static_pdfbook.html
+55
-0
lms/urls.py
+4
-5
No files found.
common/static/js/pdfviewer.js
View file @
fa00ea44
...
@@ -44,9 +44,6 @@ PDFJS.disableWorker = true;
...
@@ -44,9 +44,6 @@ PDFJS.disableWorker = true;
var
currentScaleValue
=
"0"
;
var
currentScaleValue
=
"0"
;
var
DEFAULT_SCALE_VALUE
=
"1"
;
var
DEFAULT_SCALE_VALUE
=
"1"
;
// TESTING:
var
destinations
=
null
;
var
setupText
=
function
setupText
(
textdiv
,
content
,
viewport
)
{
var
setupText
=
function
setupText
(
textdiv
,
content
,
viewport
)
{
function
getPageNumberFromDest
(
dest
)
{
function
getPageNumberFromDest
(
dest
)
{
...
@@ -270,7 +267,8 @@ PDFJS.disableWorker = true;
...
@@ -270,7 +267,8 @@ PDFJS.disableWorker = true;
//
//
// Asynchronously download PDF as an ArrayBuffer
// Asynchronously download PDF as an ArrayBuffer
//
//
PDFJS
.
getDocument
(
url
).
then
(
loadUrl
=
function
pdfViewLoadUrl
(
url_to_load
)
{
PDFJS
.
getDocument
(
url
).
then
(
function
getDocument
(
_pdfDocument
)
{
function
getDocument
(
_pdfDocument
)
{
pdfDocument
=
_pdfDocument
;
pdfDocument
=
_pdfDocument
;
// display the current page with a default scale value:
// display the current page with a default scale value:
...
@@ -282,6 +280,9 @@ PDFJS.disableWorker = true;
...
@@ -282,6 +280,9 @@ PDFJS.disableWorker = true;
function
getDocumentProgress
(
progressData
)
{
function
getDocumentProgress
(
progressData
)
{
// placeholder: not yet ready to display loading progress
// placeholder: not yet ready to display loading progress
});
});
};
loadUrl
(
url
);
$
(
"#previous"
).
click
(
function
(
event
)
{
$
(
"#previous"
).
click
(
function
(
event
)
{
prevPage
();
prevPage
();
...
@@ -308,5 +309,6 @@ PDFJS.disableWorker = true;
...
@@ -308,5 +309,6 @@ PDFJS.disableWorker = true;
renderPage
(
newPageVal
);
renderPage
(
newPageVal
);
}
}
});
});
return
pdfViewer
;
}
}
})(
jQuery
);
})(
jQuery
);
lms/djangoapps/staticbook/views.py
View file @
fa00ea44
...
@@ -52,13 +52,19 @@ def pdf_index(request, course_id, book_index, chapter=None, page=None):
...
@@ -52,13 +52,19 @@ def pdf_index(request, course_id, book_index, chapter=None, page=None):
# strip off the quotes again...
# strip off the quotes again...
return
output_url
[
1
:
-
1
]
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.
# 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'
,
return
render_to_response
(
'static_pdfbook.html'
,
{
'book_index'
:
book_index
,
{
'book_index'
:
book_index
,
'course'
:
course
,
'course'
:
course
,
'textbook'
:
textbook
,
'textbook'
:
textbook
,
'chapter'
:
chapter
,
'page'
:
page
,
'page'
:
page
,
'chapter'
:
chapter
,
'chapter'
:
chapter
,
'staff_access'
:
staff_access
})
'staff_access'
:
staff_access
})
lms/templates/static_pdfbook.html
View file @
fa00ea44
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
<
%
block
name=
"js_extra"
>
<
%
block
name=
"js_extra"
>
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
%
if
'url'
in
textbook
:
var
url
=
"${textbook['url']}"
;
var
url
=
"${textbook['url']}"
;
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
...
@@ -27,6 +28,34 @@
...
@@ -27,6 +28,34 @@
'url'
:
url
'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>
</script>
</
%
block>
</
%
block>
...
@@ -35,6 +64,7 @@
...
@@ -35,6 +64,7 @@
<div
id=
"outerContainer"
>
<div
id=
"outerContainer"
>
<div
id=
"mainContainer"
>
<div
id=
"mainContainer"
>
<div
class=
"toolbar"
>
<div
class=
"toolbar"
>
<div
id=
"toolbarContainer"
>
<div
id=
"toolbarContainer"
>
<div
id=
"toolbarViewer"
>
<div
id=
"toolbarViewer"
>
...
@@ -88,6 +118,31 @@
...
@@ -88,6 +118,31 @@
</div>
</div>
</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=
"viewerContainer"
>
<div
id=
"viewer"
contextmenu=
"viewerContextMenu"
></div>
<div
id=
"viewer"
contextmenu=
"viewerContextMenu"
></div>
</div>
</div>
...
...
lms/urls.py
View file @
fa00ea44
...
@@ -280,11 +280,10 @@ if settings.COURSEWARE_ENABLED:
...
@@ -280,11 +280,10 @@ if settings.COURSEWARE_ENABLED:
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/pdfbook/(?P<book_index>[^/]*)/(?P<page>[^/]*)$'
,
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/pdfbook/(?P<book_index>[^/]*)/(?P<page>[^/]*)$'
,
'staticbook.views.pdf_index'
),
'staticbook.views.pdf_index'
),
# Doesn't yet support loading individual chapters...
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/pdfbook/(?P<book_index>[^/]*)/chapter/(?P<chapter>[^/]*)/$'
,
# url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/pdfbook/(?P<book_index>[^/]*)/chapter/(?P<chapter>[^/]*)/$',
'staticbook.views.pdf_index'
),
# 'staticbook.views.pdf_index'),
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/pdfbook/(?P<book_index>[^/]*)/chapter/(?P<chapter>[^/]*)/(?P<page>[^/]*)$'
,
# url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/pdfbook/(?P<book_index>[^/]*)/chapter/(?P<chapter>[^/]*)/(?P<page>[^/]*)$',
'staticbook.views.pdf_index'
),
# 'staticbook.views.pdf_index'),
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/courseware/?$'
,
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/courseware/?$'
,
'courseware.views.index'
,
name
=
"courseware"
),
'courseware.views.index'
,
name
=
"courseware"
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment