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
48d84c2e
Commit
48d84c2e
authored
Oct 04, 2012
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support reordering of units inside subsection list
parent
d93bf63d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
2 deletions
+29
-2
cms/static/js/base.js
+27
-0
cms/templates/widgets/units.html
+2
-2
No files found.
cms/static/js/base.js
View file @
48d84c2e
...
...
@@ -26,8 +26,35 @@ $(document).ready(function() {
$
(
'.unit .item-actions .delete-button'
).
bind
(
'click'
,
deleteUnit
);
$
(
'.new-unit-item'
).
bind
(
'click'
,
createNewUnit
);
$
(
'.save-subsection'
).
bind
(
'click'
,
saveSubsection
);
// making the unit list sortable
$
(
'.sortable-unit-list'
).
sortable
();
$
(
'.sortable-unit-list'
).
disableSelection
();
$
(
'.sortable-unit-list'
).
bind
(
'sortstop'
,
onUnitReordered
);
});
// This method only changes the ordering of the child objects in a subsection
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'
);
}
// call into server to commit the new order
$
.
ajax
({
url
:
"/save_item"
,
type
:
"POST"
,
dataType
:
"json"
,
contentType
:
"application/json"
,
data
:
JSON
.
stringify
({
'id'
:
subsection_id
,
'metadata'
:
null
,
'data'
:
null
,
'children'
:
children
})
});
}
function
saveSubsection
(
e
)
{
e
.
preventDefault
();
...
...
cms/templates/widgets/units.html
View file @
48d84c2e
...
...
@@ -3,8 +3,8 @@
<!--
This def will enumerate through a passed in subsection and list all of the units
-->
<
%
def
name=
"enum_units(subsection, actions=True, selected=None)"
>
<ol>
<
%
def
name=
"enum_units(subsection, actions=True, selected=None
, sortable=True
)"
>
<ol
${'
class=
"sortable-unit-list"
'
if
sortable
else
''}
data-subsection-id=
"${subsection.location}"
>
% for unit in subsection.get_children():
<li
class=
"leaf unit"
data-id=
"${unit.location}"
>
<
%
...
...
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