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
ac09e18b
Commit
ac09e18b
authored
Jan 17, 2013
by
Don Mitchell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Now traps out of bounds as implying no change. Seems very slow.
parent
1782c54e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
26 deletions
+35
-26
cms/static/js/base.js
+35
-26
No files found.
cms/static/js/base.js
View file @
ac09e18b
...
@@ -253,44 +253,53 @@ function expandSection(event) {
...
@@ -253,44 +253,53 @@ function expandSection(event) {
$
(
event
.
currentTarget
).
find
(
'.expand-collapse-icon'
).
removeClass
(
'expand'
).
addClass
(
'collapse'
);
$
(
event
.
currentTarget
).
find
(
'.expand-collapse-icon'
).
removeClass
(
'expand'
).
addClass
(
'collapse'
);
}
}
function
checkDropValidity
(
event
,
ui
)
{
var
posInDestination
=
ui
.
position
.
top
-
$
(
event
.
target
).
position
().
top
;
if
(
posInDestination
<=
-
ui
.
item
.
height
()
||
posInDestination
>=
$
(
event
.
target
).
height
())
{
// May need to call on ui.sender
$
(
event
.
target
).
sortable
(
"cancel"
);
return
false
;
}
return
true
;
}
// This method only changes the ordering of the child objects in a subsection
// This method only changes the ordering of the child objects in a subsection
function
onUnitReordered
(
event
,
ui
)
{
function
onUnitReordered
(
event
,
ui
)
{
var
subsection_id
=
$
(
this
).
data
(
'subsection-id'
);
// This is called 2x when moving from one subsection to another: once for the sender and once
// for the receiver. The sender's call has ui.sender == null
var
_els
=
$
(
this
).
children
(
'li:.leaf'
);
var
subsection_id
=
$
(
event
.
target
).
data
(
'subsection-id'
);
var
_els
=
$
(
event
.
target
).
children
(
'li:.leaf'
);
var
children
=
_els
.
map
(
function
(
idx
,
el
)
{
return
$
(
el
).
data
(
'id'
);
}).
get
();
var
children
=
_els
.
map
(
function
(
idx
,
el
)
{
return
$
(
el
).
data
(
'id'
);
}).
get
();
// if it believes the element belongs in this section, check that it was dropped w/in the bounds
// call into server to commit the new order
if
(
_
.
contains
(
children
,
ui
.
item
.
data
(
'id'
)))
{
$
.
ajax
({
if
(
checkDropValidity
(
event
,
ui
))
{
url
:
"/save_item"
,
// call into server to commit the new order
type
:
"POST"
,
$
.
ajax
({
dataType
:
"json"
,
url
:
"/save_item"
,
contentType
:
"application/json"
,
type
:
"POST"
,
data
:
JSON
.
stringify
({
'id'
:
subsection_id
,
'children'
:
children
})
dataType
:
"json"
,
});
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'
);
else
{
var
children
=
_els
.
map
(
function
(
idx
,
el
)
{
return
$
(
el
).
data
(
'id'
);
}).
get
();
// recording the removal (as element is not in the collection)
// call into server to commit the new order
$
.
ajax
({
$
.
ajax
({
url
:
"/save_item"
,
url
:
"/save_item"
,
type
:
"POST"
,
type
:
"POST"
,
dataType
:
"json"
,
dataType
:
"json"
,
contentType
:
"application/json"
,
contentType
:
"application/json"
,
data
:
JSON
.
stringify
({
'id'
:
ui
.
sender
.
data
(
'subsection-id'
)
,
'children'
:
children
})
data
:
JSON
.
stringify
({
'id'
:
subsection_id
,
'children'
:
children
})
});
});
}
}
}
}
function
onSubsectionReordered
(
event
,
ui
)
{
function
onSubsectionReordered
(
event
,
ui
)
{
var
section_id
=
$
(
this
).
data
(
'section-id'
);
var
section_id
=
$
(
event
.
target
).
data
(
'section-id'
);
var
_els
=
$
(
this
).
children
(
'li:.branch'
);
var
_els
=
$
(
event
.
target
).
children
(
'li:.branch'
);
var
children
=
_els
.
map
(
function
(
idx
,
el
)
{
return
$
(
el
).
data
(
'id'
);
}).
get
();
var
children
=
_els
.
map
(
function
(
idx
,
el
)
{
return
$
(
el
).
data
(
'id'
);
}).
get
();
// call into server to commit the new order
// call into server to commit the new order
...
@@ -320,9 +329,9 @@ function onSubsectionReordered(event, ui) {
...
@@ -320,9 +329,9 @@ function onSubsectionReordered(event, ui) {
}
}
function
onSectionReordered
()
{
function
onSectionReordered
()
{
var
course_id
=
$
(
this
).
data
(
'course-id'
);
var
course_id
=
$
(
event
.
target
).
data
(
'course-id'
);
var
_els
=
$
(
this
).
children
(
'section:.branch'
);
var
_els
=
$
(
event
.
target
).
children
(
'section:.branch'
);
var
children
=
_els
.
map
(
function
(
idx
,
el
)
{
return
$
(
el
).
data
(
'id'
);
}).
get
();
var
children
=
_els
.
map
(
function
(
idx
,
el
)
{
return
$
(
el
).
data
(
'id'
);
}).
get
();
// call into server to commit the new order
// call into server to commit the new order
...
...
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