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
fc9ab346
Commit
fc9ab346
authored
Feb 26, 2013
by
Brian Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix loading of specific pages.
parent
dde2cd0b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
25 deletions
+40
-25
common/static/js/pdfviewer.js
+38
-23
lms/templates/static_pdfbook.html
+2
-2
No files found.
common/static/js/pdfviewer.js
View file @
fc9ab346
...
...
@@ -27,25 +27,28 @@ PDFJS.disableWorker = true;
var
pdfViewer
=
this
;
var
pdfDocument
=
null
;
var
url
=
null
;
var
url
ToLoad
=
null
;
if
(
options
.
url
)
{
url
=
options
.
url
;
url
ToLoad
=
options
.
url
;
}
var
chapter
_u
rls
=
null
;
var
chapter
U
rls
=
null
;
if
(
options
.
chapters
)
{
chapter
_u
rls
=
options
.
chapters
;
chapter
U
rls
=
options
.
chapters
;
}
var
chapter
Num
=
1
;
var
chapter
ToLoad
=
1
;
if
(
options
.
chapterNum
)
{
chapterNum
=
options
.
chapterNum
;
// TODO: this should only be specified if there are
// chapters, and it should be in-bounds.
chapterToLoad
=
options
.
chapterNum
;
}
var
page
Num
=
1
;
var
page
ToLoad
=
1
;
if
(
options
.
pageNum
)
{
page
Num
=
options
.
pageNum
;
page
ToLoad
=
options
.
pageNum
;
}
var
chapterNum
=
1
;
var
pageNum
=
1
;
var
viewerElement
=
document
.
getElementById
(
'viewer'
);
var
ANNOT_MIN_SIZE
=
10
;
var
DEFAULT_SCALE_DELTA
=
1.1
;
...
...
@@ -280,13 +283,21 @@ PDFJS.disableWorker = true;
//
// Asynchronously download PDF as an ArrayBuffer
//
loadUrl
=
function
pdfViewLoadUrl
(
url
_to_load
)
{
PDFJS
.
getDocument
(
url
_to_load
).
then
(
loadUrl
=
function
pdfViewLoadUrl
(
url
,
page
)
{
PDFJS
.
getDocument
(
url
).
then
(
function
getDocument
(
_pdfDocument
)
{
pdfDocument
=
_pdfDocument
;
// display the current page with a default scale value:
currentScale
=
UNKNOWN_SCALE
;
parseScale
(
DEFAULT_SCALE_VALUE
);
pageNum
=
page
;
// if the scale has not been set before, set it now.
// Otherwise, don't change the current scale,
// but make sure it gets refreshed.
if
(
currentScale
==
UNKNOWN_SCALE
)
{
parseScale
(
DEFAULT_SCALE_VALUE
);
}
else
{
var
preservedScale
=
currentScale
;
currentScale
=
UNKNOWN_SCALE
;
parseScale
(
preservedScale
);
}
},
function
getDocumentError
(
message
,
exception
)
{
// placeholder: don't expect errors :)
...
...
@@ -296,9 +307,12 @@ PDFJS.disableWorker = true;
});
};
loadChapterUrl
=
function
pdfViewLoadChapterUrl
(
chapter_index
)
{
var
chapter_url
=
chapter_urls
[
chapter_index
];
loadUrl
(
chapter_url
);
loadChapterUrl
=
function
pdfViewLoadChapterUrl
(
chapterNum
,
pageVal
)
{
if
(
chapterNum
<
1
||
chapterNum
>
chapterUrls
.
length
)
{
return
;
}
var
chapterUrl
=
chapterUrls
[
chapterNum
-
1
];
loadUrl
(
chapterUrl
,
pageVal
);
}
$
(
"#previous"
).
click
(
function
(
event
)
{
...
...
@@ -329,22 +343,23 @@ PDFJS.disableWorker = true;
});
// define navigation links for chapters:
if
(
chapter
_u
rls
!=
null
)
{
if
(
chapter
U
rls
!=
null
)
{
var
loadChapterUrlHelper
=
function
(
i
)
{
return
function
(
event
)
{
loadChapterUrl
(
i
);
// when opening a new chapter, always open the first page:
loadChapterUrl
(
i
,
1
);
};
};
for
(
var
index
=
1
;
index
<=
chapter
_u
rls
.
length
;
index
+=
1
)
{
for
(
var
index
=
1
;
index
<=
chapter
U
rls
.
length
;
index
+=
1
)
{
$
(
"#pdfchapter-"
+
index
).
click
(
loadChapterUrlHelper
(
index
));
}
}
// finally, load the appropriate page
if
(
url
!=
null
)
{
loadUrl
(
url
);
// finally, load the appropriate
url/
page
if
(
url
ToLoad
!=
null
)
{
loadUrl
(
url
ToLoad
,
pageToLoad
);
}
else
{
loadChapterUrl
(
chapter
Num
);
loadChapterUrl
(
chapter
ToLoad
,
pageToLoad
);
}
return
pdfViewer
;
...
...
lms/templates/static_pdfbook.html
View file @
fc9ab346
...
...
@@ -30,10 +30,10 @@
options
.
chapters
=
chptrs
;
%
endif
%
if
chapter
is
not
None
:
options
.
chapterNum
:
$
{
chapter
};
options
.
chapterNum
=
$
{
chapter
};
%
endif
%
if
page
is
not
None
:
options
.
pageNum
:
$
{
page
};
options
.
pageNum
=
$
{
page
};
%
endif
$
(
'#outerContainer'
).
PDFViewer
(
options
);
...
...
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