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
1782c54e
Commit
1782c54e
authored
Jan 17, 2013
by
Don Mitchell
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/dhm/drag' of github.com:MITx/mitx into feature/dhm/drag
parents
db4455e6
244584ce
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
5 deletions
+43
-5
cms/static/js/base.js
+43
-5
No files found.
cms/static/js/base.js
View file @
1782c54e
...
...
@@ -60,7 +60,9 @@ $(document).ready(function() {
$
(
'.sortable-unit-list'
).
sortable
({
axis
:
'y'
,
handle
:
'.drag-handle'
,
update
:
onUnitReordered
update
:
onUnitReordered
,
connectWith
:
'.sortable-unit-list'
,
revert
:
true
});
// expand/collapse methods for optional date setters
...
...
@@ -92,14 +94,17 @@ $(document).ready(function() {
$
(
'.subsection-list > ol'
).
sortable
({
axis
:
'y'
,
handle
:
'.section-item .drag-handle'
,
update
:
onSubsectionReordered
update
:
onSubsectionReordered
,
connectWith
:
'.subsection-list > ol'
,
revert
:
true
});
// Section reordering
$
(
'.courseware-overview'
).
sortable
({
axis
:
'y'
,
handle
:
'header .drag-handle'
,
update
:
onSectionReordered
update
:
onSectionReordered
,
revert
:
true
});
$
(
'.new-course-button'
).
bind
(
'click'
,
addNewCourse
);
...
...
@@ -249,7 +254,7 @@ function expandSection(event) {
}
// This method only changes the ordering of the child objects in a subsection
function
onUnitReordered
()
{
function
onUnitReordered
(
event
,
ui
)
{
var
subsection_id
=
$
(
this
).
data
(
'subsection-id'
);
var
_els
=
$
(
this
).
children
(
'li:.leaf'
);
...
...
@@ -263,9 +268,26 @@ function onUnitReordered() {
contentType
:
"application/json"
,
data
:
JSON
.
stringify
({
'id'
:
subsection_id
,
'children'
:
children
})
});
// remove from old container
if
(
ui
.
sender
&&
subsection_id
!==
ui
.
sender
.
data
(
'subsection-id'
))
{
var
_els
=
ui
.
sender
.
children
(
'li:.leaf'
);
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'
:
ui
.
sender
.
data
(
'subsection-id'
),
'children'
:
children
})
});
}
}
function
onSubsectionReordered
()
{
function
onSubsectionReordered
(
event
,
ui
)
{
var
section_id
=
$
(
this
).
data
(
'section-id'
);
var
_els
=
$
(
this
).
children
(
'li:.branch'
);
...
...
@@ -279,6 +301,22 @@ function onSubsectionReordered() {
contentType
:
"application/json"
,
data
:
JSON
.
stringify
({
'id'
:
section_id
,
'children'
:
children
})
});
// remove from old container
if
(
ui
.
sender
&&
section_id
!==
ui
.
sender
.
data
(
'section-id'
))
{
var
_els
=
ui
.
sender
.
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'
:
ui
.
sender
.
data
(
'section-id'
),
'children'
:
children
})
});
}
}
function
onSectionReordered
()
{
...
...
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