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
623c756b
Commit
623c756b
authored
Oct 12, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable section and subsection reordering (with no drag between them)
parent
a160f614
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
13 deletions
+56
-13
cms/static/js/base.js
+52
-9
cms/templates/overview.html
+4
-4
No files found.
cms/static/js/base.js
View file @
623c756b
...
...
@@ -32,9 +32,11 @@ $(document).ready(function() {
$
(
'.save-subsection'
).
bind
(
'click'
,
saveSubsection
);
// making the unit list sortable
$
(
'.sortable-unit-list'
).
sortable
();
$
(
'.sortable-unit-list'
).
disableSelection
();
$
(
'.sortable-unit-list'
).
bind
(
'sortstop'
,
onUnitReordered
);
$
(
'.sortable-unit-list'
).
sortable
({
axis
:
'y'
,
handle
:
'.drag-handle'
,
update
:
onUnitReordered
});
// expand/collapse methods for optional date setters
$
(
'.set-date'
).
bind
(
'click'
,
showDateSetter
);
...
...
@@ -58,6 +60,20 @@ $(document).ready(function() {
e
.
preventDefault
();
$
(
'.import .file-input'
).
click
();
});
// Subsection reordering
$
(
'.unit-list ol'
).
sortable
({
axis
:
'y'
,
handle
:
'.section-item .drag-handle'
,
update
:
onSubsectionReordered
});
// Section reordering
$
(
'.courseware-overview'
).
sortable
({
axis
:
'y'
,
handle
:
'header .drag-handle'
,
update
:
onSectionReordered
});
});
function
showImportSubmit
(
e
)
{
...
...
@@ -110,12 +126,7 @@ function onUnitReordered() {
var
subsection_id
=
$
(
this
).
data
(
'subsection-id'
);
var
_els
=
$
(
this
).
children
(
'li:.leaf'
);
var
children
=
new
Array
();
for
(
var
i
=
0
;
i
<
_els
.
length
;
i
++
)
{
el
=
_els
[
i
];
children
[
i
]
=
$
(
el
).
data
(
'id'
);
}
var
children
=
_els
.
map
(
function
(
idx
,
el
)
{
return
$
(
el
).
data
(
'id'
);
}).
get
();
// call into server to commit the new order
$
.
ajax
({
...
...
@@ -127,6 +138,38 @@ function onUnitReordered() {
});
}
function
onSubsectionReordered
()
{
var
section_id
=
$
(
this
).
data
(
'section-id'
);
var
_els
=
$
(
this
).
children
(
'li:.branch'
);
var
children
=
_els
.
map
(
function
(
idx
,
el
)
{
return
$
(
el
).
data
(
'id'
);
}).
get
();
// call into server to commit the new order
$
.
ajax
({
url
:
"/save_item"
,
type
:
"POST"
,
dataType
:
"json"
,
contentType
:
"application/json"
,
data
:
JSON
.
stringify
({
'id'
:
section_id
,
'metadata'
:
null
,
'data'
:
null
,
'children'
:
children
})
});
}
function
onSectionReordered
()
{
var
course_id
=
$
(
this
).
data
(
'course-id'
);
var
_els
=
$
(
this
).
children
(
'section:.branch'
);
var
children
=
_els
.
map
(
function
(
idx
,
el
)
{
return
$
(
el
).
data
(
'id'
);
}).
get
();
// call into server to commit the new order
$
.
ajax
({
url
:
"/save_item"
,
type
:
"POST"
,
dataType
:
"json"
,
contentType
:
"application/json"
,
data
:
JSON
.
stringify
({
'id'
:
course_id
,
'metadata'
:
null
,
'data'
:
null
,
'children'
:
children
})
});
}
function
getEdxTimeFromDateTimeInputs
(
date_id
,
time_id
,
format
)
{
var
input_date
=
$
(
'#'
+
date_id
).
val
();
var
input_time
=
$
(
'#'
+
time_id
).
val
();
...
...
cms/templates/overview.html
View file @
623c756b
...
...
@@ -46,7 +46,7 @@
<div
class=
"inner-wrapper"
>
<h1>
Courseware
</h1>
<div
class=
"page-actions"
></div>
<article
class=
"courseware-overview"
>
<article
class=
"courseware-overview"
data-course-id=
"${context_course.location.url()}"
>
<a
href=
"#"
class=
"new-courseware-section-button"
><span
class=
"plus-icon"
></span>
New Section
</a>
% for section in sections:
<section
class=
"courseware-section branch"
data-id=
"${section.location}"
>
...
...
@@ -58,7 +58,7 @@
</div>
<div
class=
"item-actions"
>
<a
href=
"#"
class=
"delete-button delete-section-button"
><span
class=
"delete-icon"
></span></a>
<a
href=
"#"
class=
"drag-handle
wip
"
></a>
<a
href=
"#"
class=
"drag-handle"
></a>
</div>
</header>
<div
class=
"unit-list"
>
...
...
@@ -67,7 +67,7 @@
<span
class=
"new-folder-icon"
></span>
New Subsection
</a>
</div>
<ol>
<ol
data-section-id=
"${section.location.url()}"
>
% for subsection in section.get_children():
<li
class=
"branch collapsed"
data-id=
"${subsection.location}"
>
<div
class=
"section-item"
>
...
...
@@ -80,7 +80,7 @@
</div>
<div
class=
"item-actions"
>
<a
href=
"#"
class=
"delete-button delete-subsection-button"
><span
class=
"delete-icon"
></span></a>
<a
href=
"#"
class=
"drag-handle
wip
"
></a>
<a
href=
"#"
class=
"drag-handle"
></a>
</div>
</div>
${units.enum_units(subsection)}
...
...
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