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
19d65f81
Commit
19d65f81
authored
Jun 11, 2013
by
David Baumgold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Toggle show/hide chapters in textbook show view
parent
22e325af
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
2 deletions
+27
-2
cms/templates/js/textbook-show.underscore
+15
-1
cms/templates/textbooks.html
+12
-1
No files found.
cms/templates/js/textbook-show.underscore
View file @
19d65f81
<li class="textbook">
<span class="name"><%= name %></span>
<% if(chapters.length > 1) {%>
<%= chapters.length %> PDF Chapters
<a href="#" class="chapter-toggle
<% if(showChapters){ print('hide'); } else { print('show'); } %>-chapters">
<i class="icon-chevron-<% if(showChapters){ print('down'); } else { print('right'); } %>"></i>
<%= chapters.length %> PDF Chapters
</a>
<% } else if(chapters.length === 1) { %>
<%= chapters.at(0).get("asset_path") %>
<% } %>
<a href="#" class="view"><%= gettext("view in course") %></a>
<button class="edit"><%= gettext("Edit") %></button>
<button class="delete"><%= gettext("Delete") %></button>
<% if(showChapters) { %>
<hr>
<ol class="chapters">
<% chapters.each(function(chapter) { %>
<li><span class="chapter-name"><%= chapter.get('name') %></span>
<span class="chapter-asset-path"><%= chapter.get('asset_path') %></span>
</li>
<% }) %>
</ol>
<% } %>
</li>
cms/templates/textbooks.html
View file @
19d65f81
...
...
@@ -29,6 +29,7 @@ window.UPLOAD_ASSET_CALLBACK_URL = "${upload_asset_callback_url}"
CMS
.
Models
.
Textbook
=
Backbone
.
Model
.
extend
({
defaults
:
{
name
:
""
,
showChapters
:
false
},
initialize
:
function
()
{
this
.
chapters
=
new
CMS
.
Collections
.
ChapterSet
;
...
...
@@ -45,7 +46,9 @@ CMS.Views.TextbookShow = Backbone.View.extend({
},
events
:
{
"click .edit"
:
"editTextbook"
,
"click .delete"
:
"removeSelf"
"click .delete"
:
"removeSelf"
,
"click .show-chapters"
:
"showChapters"
,
"click .hide-chapters"
:
"hideChapters"
},
render
:
function
()
{
var
attrs
=
$
.
extend
({},
this
.
model
.
attributes
);
...
...
@@ -60,6 +63,14 @@ CMS.Views.TextbookShow = Backbone.View.extend({
removeSelf
:
function
(
e
)
{
if
(
e
&&
e
.
preventDefault
)
{
e
.
preventDefault
();
}
this
.
model
.
collection
.
remove
(
this
.
model
);
},
showChapters
:
function
(
e
)
{
if
(
e
&&
e
.
preventDefault
)
{
e
.
preventDefault
();
}
this
.
model
.
set
(
'showChapters'
,
true
);
},
hideChapters
:
function
(
e
)
{
if
(
e
&&
e
.
preventDefault
)
{
e
.
preventDefault
();
}
this
.
model
.
set
(
'showChapters'
,
false
);
}
})
CMS
.
Views
.
TextbookEdit
=
Backbone
.
View
.
extend
({
...
...
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