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
d5e34b0a
Commit
d5e34b0a
authored
Feb 21, 2013
by
Brian Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix initialization of scale dropdown, and check for valid values of page number
parent
00e31c01
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
13 deletions
+49
-13
common/static/css/pdfviewer.css
+1
-1
common/static/js/pdfviewer.js
+48
-12
No files found.
common/static/css/pdfviewer.css
View file @
d5e34b0a
...
...
@@ -590,7 +590,7 @@ select {
margin
:
4px
2px
4px
0
;
border
:
1px
solid
transparent
;
border-radius
:
2px
;
/* color: hsl(0,0%,85%); can't get background to work, so let this be black... */
color
:
hsl
(
0
,
0%
,
85%
);
font-size
:
12px
;
line-height
:
14px
;
text-align
:
left
;
...
...
common/static/js/pdfviewer.js
View file @
d5e34b0a
...
...
@@ -32,8 +32,6 @@ PDFJS.disableWorker = true;
if
(
options
.
pageNum
)
{
pageNum
=
options
.
pageNum
;
}
var
currentScale
=
1.0
;
var
currentScaleValue
=
"1"
;
var
viewerElement
=
document
.
getElementById
(
'viewer'
);
var
ANNOT_MIN_SIZE
=
10
;
...
...
@@ -42,15 +40,41 @@ PDFJS.disableWorker = true;
var
MIN_SCALE
=
0.25
;
var
MAX_SCALE
=
4.0
;
var
currentScale
=
UNKNOWN_SCALE
;
var
currentScaleValue
=
"0"
;
var
DEFAULT_SCALE_VALUE
=
"1"
;
// TESTING:
var
destinations
=
null
;
var
setupText
=
function
setupText
(
textdiv
,
content
,
viewport
)
{
function
getPageNumberFromDest
(
dest
)
{
var
destPage
=
1
;
if
(
dest
instanceof
Array
)
{
var
destRef
=
dest
[
0
];
if
(
destRef
instanceof
Object
)
{
// we would need to look this up in the
// list of all pages that have been loaded,
// but we're trying to not have to load all the pages
// right now.
// destPage = this.pagesRefMap[destRef.num + ' ' + destRef.gen + ' R'];
}
else
{
destPage
=
(
destRef
+
1
);
}
}
return
destPage
;
}
function
bindLink
(
link
,
dest
)
{
// TODO: get this to work for document-internal links
// link.href = PDFView.getDestinationHash(dest);
// link.onclick = function pageViewSetupLinksOnclick() {
// if (dest)
// PDFView.navigateTo(dest);
// return false;
// };
// get page number from dest:
destPage
=
getPageNumberFromDest
(
dest
);
link
.
href
=
'#page='
+
destPage
;
link
.
onclick
=
function
pageViewSetupLinksOnclick
()
{
if
(
dest
&&
dest
instanceof
Array
)
renderPage
(
destPage
);
return
false
;
};
}
function
createElementWithStyle
(
tagName
,
item
,
rect
)
{
...
...
@@ -109,11 +133,16 @@ PDFJS.disableWorker = true;
}
});
}
//
// Get page info from document, resize canvas accordingly, and render page
//
// function renderPage(num) {
renderPage
=
function
(
num
)
{
// don't try to render a page that cannot be rendered
if
(
num
<
1
||
num
>
pdfDocument
.
numPages
)
{
return
;
}
// Update logging:
log_event
(
"book"
,
{
"type"
:
"gotopage"
,
"old"
:
pageNum
,
"new"
:
num
});
...
...
@@ -176,7 +205,6 @@ PDFJS.disableWorker = true;
log_event
(
"book"
,
{
"type"
:
"nextpage"
,
"new"
:
pageNum
});
}
// Check to see if
selectScaleOption
=
function
(
value
)
{
var
options
=
$
(
'#scaleSelect options'
);
var
predefinedValueFound
=
false
;
...
...
@@ -245,7 +273,8 @@ PDFJS.disableWorker = true;
PDFJS
.
getDocument
(
url
).
then
(
function
getDocument
(
_pdfDocument
)
{
pdfDocument
=
_pdfDocument
;
renderPage
(
pageNum
);
// display the current page with a default scale value:
parseScale
(
DEFAULT_SCALE_VALUE
);
},
function
getDocumentError
(
message
,
exception
)
{
// placeholder: don't expect errors :)
...
...
@@ -272,5 +301,12 @@ PDFJS.disableWorker = true;
$
(
'#scaleSelect'
).
change
(
function
(
event
)
{
parseScale
(
this
.
value
);
});
$
(
'#pageNumber'
).
change
(
function
(
event
)
{
var
newPageVal
=
parseInt
(
this
.
value
);
if
(
newPageVal
)
{
renderPage
(
newPageVal
);
}
});
}
})(
jQuery
);
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