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
49dee508
Commit
49dee508
authored
Mar 07, 2013
by
Brian Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first pass at chapter navigation
parent
aee7d856
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
101 additions
and
27 deletions
+101
-27
lms/templates/static_htmlbook.html
+101
-27
No files found.
lms/templates/static_htmlbook.html
View file @
49dee508
<
%
inherit
file=
"main.html"
/>
<
%
inherit
file=
"main.html"
/>
<
%
namespace
name=
'static'
file=
'static_content.html'
/>
<
%
namespace
name=
'static'
file=
'static_content.html'
/>
<
%
block
name=
"title"
>
<
%
block
name=
"title"
><title>
${course.number} Textbook
</title>
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1, maximum-scale=1"
>
<title>
${course.number} Textbook
</title>
</
%
block>
</
%
block>
<
%
block
name=
"headextra"
>
<
%
block
name=
"headextra"
>
...
@@ -13,6 +10,85 @@
...
@@ -13,6 +10,85 @@
<
%
block
name=
"js_extra"
>
<
%
block
name=
"js_extra"
>
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
(
function
(
$
)
{
$
.
fn
.
myHTMLViewer
=
function
(
options
)
{
var
urlToLoad
=
null
;
if
(
options
.
url
)
{
urlToLoad
=
options
.
url
;
}
var
chapterUrls
=
null
;
if
(
options
.
chapters
)
{
chapterUrls
=
options
.
chapters
;
}
var
chapterToLoad
=
1
;
if
(
options
.
chapterNum
)
{
// TODO: this should only be specified if there are
// chapters, and it should be in-bounds.
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'
);
}
};
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
);
$
(
'#bookpage'
).
load
(
newurl
);
};
loadChapterUrl
=
function
htmlViewLoadChapterUrl
(
chapterNum
,
anchorId
)
{
if
(
chapterNum
<
1
||
chapterNum
>
chapterUrls
.
length
)
{
return
;
}
var
chapterUrl
=
chapterUrls
[
chapterNum
-
1
];
loadUrl
(
chapterUrl
,
anchorId
);
};
// define navigation links for chapters:
if
(
chapterUrls
!=
null
)
{
var
loadChapterUrlHelper
=
function
(
i
)
{
return
function
(
event
)
{
// when opening a new chapter, always open to the top:
loadChapterUrl
(
i
,
null
);
};
};
for
(
var
index
=
1
;
index
<=
chapterUrls
.
length
;
index
+=
1
)
{
$
(
"#htmlchapter-"
+
index
).
click
(
loadChapterUrlHelper
(
index
));
}
}
// finally, load the appropriate url/page
if
(
urlToLoad
!=
null
)
{
loadUrl
(
urlToLoad
,
anchorToLoad
);
}
else
{
loadChapterUrl
(
chapterToLoad
,
anchorToLoad
);
}
}
})(
jQuery
);
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
var
options
=
{};
var
options
=
{};
...
@@ -29,10 +105,8 @@
...
@@ -29,10 +105,8 @@
%
if
chapter
is
not
None
:
%
if
chapter
is
not
None
:
options
.
chapterNum
=
$
{
chapter
};
options
.
chapterNum
=
$
{
chapter
};
%
endif
%
endif
%
if
page
is
not
None
:
options
.
pageNum
=
$
{
page
};
%
endif
$
(
'#outerContainer'
).
myHTMLViewer
(
options
);
});
});
</script>
</script>
</
%
block>
</
%
block>
...
@@ -43,29 +117,29 @@
...
@@ -43,29 +117,29 @@
<div
id=
"mainContainer"
class=
"book-wrapper"
>
<div
id=
"mainContainer"
class=
"book-wrapper"
>
%if 'chapters' in textbook:
%if 'chapters' in textbook:
<section
aria-label=
"Textbook Navigation"
class=
"book-sidebar"
>
<section
aria-label=
"Textbook Navigation"
class=
"book-sidebar"
>
<ul
id=
"booknav"
class=
"treeview-booknav"
>
<ul
id=
"booknav"
class=
"treeview-booknav"
>
<
%
def
name=
"print_entry(entry, index_value)"
>
<
%
def
name=
"print_entry(entry, index_value)"
>
<li
id=
"htmlchapter-${index_value}"
>
<li
id=
"htmlchapter-${index_value}"
>
<a
class=
"chapter"
>
<a
class=
"chapter"
>
${entry.get('title')}
${entry.get('title')}
</a>
</a>
</li>
</li>
</
%
def>
</
%
def>
%
for (index, entry) in enumerate(textbook['chapters']):
%
for (index, entry) in enumerate(textbook['chapters']):
${print_entry(entry, index+1)}
${print_entry(entry, index+1)}
% endfor
% endfor
</ul>
</ul>
</section>
</section>
%endif
%endif
<section
id=
"viewerContainer"
class=
"book"
>
<section
id=
"viewerContainer"
class=
"book"
>
<!-- <section class="page"> -->
<section
class=
"page"
>
<
iframe
class=
"page"
id=
"bookpage"
src=
"${ textbook['chapters'][0]['url'] }"
>
<
div
id=
"bookpage"
/
>
<!-- </section> -->
</section>
</section>
</section>
</div>
<!-- mainContainer -->
</div>
</div>
</div>
<!-- outerContainer -->
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