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
30c87be2
Commit
30c87be2
authored
Jan 17, 2013
by
Don Mitchell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Subsection drag between sections should work now.
parent
ac09e18b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
22 deletions
+19
-22
cms/static/js/base.js
+19
-22
No files found.
cms/static/js/base.js
View file @
30c87be2
...
@@ -55,16 +55,6 @@ $(document).ready(function() {
...
@@ -55,16 +55,6 @@ $(document).ready(function() {
$
(
"#start_date, #start_time, #due_date, #due_time"
).
bind
(
'change'
,
autosaveInput
);
$
(
"#start_date, #start_time, #due_date, #due_time"
).
bind
(
'change'
,
autosaveInput
);
$
(
'.sync-date, .remove-date'
).
bind
(
'click'
,
autosaveInput
);
$
(
'.sync-date, .remove-date'
).
bind
(
'click'
,
autosaveInput
);
var
cachedHesitation
=
new
CMS
.
HesitateEvent
(
expandSection
,
$
(
'.branch .collapsed'
),
'mouseLeave'
);
// making the unit list sortable
$
(
'.sortable-unit-list'
).
sortable
({
axis
:
'y'
,
handle
:
'.drag-handle'
,
update
:
onUnitReordered
,
connectWith
:
'.sortable-unit-list'
,
revert
:
true
});
// expand/collapse methods for optional date setters
// expand/collapse methods for optional date setters
$
(
'.set-date'
).
bind
(
'click'
,
showDateSetter
);
$
(
'.set-date'
).
bind
(
'click'
,
showDateSetter
);
$
(
'.remove-date'
).
bind
(
'click'
,
removeDateSetter
);
$
(
'.remove-date'
).
bind
(
'click'
,
removeDateSetter
);
...
@@ -90,6 +80,16 @@ $(document).ready(function() {
...
@@ -90,6 +80,16 @@ $(document).ready(function() {
$
(
'.import .file-input'
).
click
();
$
(
'.import .file-input'
).
click
();
});
});
var
cachedHesitation
=
new
CMS
.
HesitateEvent
(
expandSection
,
$
(
'.branch .collapsed'
),
'mouseLeave'
);
// making the unit list sortable
$
(
'.sortable-unit-list'
).
sortable
({
axis
:
'y'
,
handle
:
'.drag-handle'
,
update
:
onUnitReordered
,
connectWith
:
'.sortable-unit-list'
,
revert
:
true
});
// Subsection reordering
// Subsection reordering
$
(
'.subsection-list > ol'
).
sortable
({
$
(
'.subsection-list > ol'
).
sortable
({
axis
:
'y'
,
axis
:
'y'
,
...
@@ -254,9 +254,8 @@ function expandSection(event) {
...
@@ -254,9 +254,8 @@ function expandSection(event) {
}
}
function
checkDropValidity
(
event
,
ui
)
{
function
checkDropValidity
(
event
,
ui
)
{
var
posInDestination
=
ui
.
position
.
top
-
$
(
event
.
target
).
position
().
top
;
var
posInDestination
=
ui
.
item
.
position
()
.
top
-
$
(
event
.
target
).
position
().
top
;
if
(
posInDestination
<=
-
ui
.
item
.
height
()
||
posInDestination
>=
$
(
event
.
target
).
height
())
{
if
(
posInDestination
<=
-
ui
.
item
.
height
()
||
posInDestination
>=
$
(
event
.
target
).
height
())
{
// May need to call on ui.sender
$
(
event
.
target
).
sortable
(
"cancel"
);
$
(
event
.
target
).
sortable
(
"cancel"
);
return
false
;
return
false
;
}
}
...
@@ -297,11 +296,13 @@ function onUnitReordered(event, ui) {
...
@@ -297,11 +296,13 @@ function onUnitReordered(event, ui) {
}
}
function
onSubsectionReordered
(
event
,
ui
)
{
function
onSubsectionReordered
(
event
,
ui
)
{
// see onUnitReordered for pattern and comments
var
section_id
=
$
(
event
.
target
).
data
(
'section-id'
);
var
section_id
=
$
(
event
.
target
).
data
(
'section-id'
);
var
_els
=
$
(
event
.
target
).
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
();
// if it believes the element belongs in this section, check that it was dropped w/in the bounds
if
(
_
.
contains
(
children
,
ui
.
item
.
data
(
'id'
)))
{
if
(
checkDropValidity
(
event
,
ui
))
{
// call into server to commit the new order
// call into server to commit the new order
$
.
ajax
({
$
.
ajax
({
url
:
"/save_item"
,
url
:
"/save_item"
,
...
@@ -310,21 +311,17 @@ function onSubsectionReordered(event, ui) {
...
@@ -310,21 +311,17 @@ function onSubsectionReordered(event, ui) {
contentType
:
"application/json"
,
contentType
:
"application/json"
,
data
:
JSON
.
stringify
({
'id'
:
section_id
,
'children'
:
children
})
data
:
JSON
.
stringify
({
'id'
:
section_id
,
'children'
:
children
})
});
});
}
// remove from old container
}
if
(
ui
.
sender
&&
section_id
!==
ui
.
sender
.
data
(
'section-id'
))
{
else
{
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
// 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
(
'section-id'
)
,
'children'
:
children
})
data
:
JSON
.
stringify
({
'id'
:
section_id
,
'children'
:
children
})
});
});
}
}
}
}
...
...
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