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
fd2f720a
Commit
fd2f720a
authored
Aug 05, 2013
by
Peter Fogg
Committed by
cahrens
Oct 07, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add auto-expand to overview lists.
parent
2d3cba06
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
18 deletions
+55
-18
cms/static/js/views/overview.js
+55
-18
No files found.
cms/static/js/views/overview.js
View file @
fd2f720a
...
@@ -12,7 +12,7 @@ $(document).ready(function() {
...
@@ -12,7 +12,7 @@ $(document).ready(function() {
'.id-holder'
,
'.id-holder'
,
'a.subsection-drag-handle'
,
'a.subsection-drag-handle'
,
'.subsection-list > ol'
,
'.subsection-list > ol'
,
'.
subsection-list > ol
'
'.
courseware-section
'
);
);
// Unit
// Unit
makeDraggable
(
makeDraggable
(
...
@@ -23,8 +23,9 @@ $(document).ready(function() {
...
@@ -23,8 +23,9 @@ $(document).ready(function() {
);
);
/*
/*
* Make `type` draggable using `handleClass`, and able to be
* Make `type` draggable using `handleClass`, able to be dropped
* dropped into `droppableClass`.
* into `droppableClass`, and with parent type
* `parentLocationSelector`.
*/
*/
function
makeDraggable
(
type
,
handleClass
,
droppableClass
,
parentLocationSelector
)
{
function
makeDraggable
(
type
,
handleClass
,
droppableClass
,
parentLocationSelector
)
{
_
.
each
(
_
.
each
(
...
@@ -61,23 +62,35 @@ $(document).ready(function() {
...
@@ -61,23 +62,35 @@ $(document).ready(function() {
var
siblings
=
container
.
children
().
filter
(
function
()
{
var
siblings
=
container
.
children
().
filter
(
function
()
{
return
$
(
this
).
data
(
'id'
)
!==
undefined
&&
!
$
(
this
).
is
(
ele
);
return
$
(
this
).
data
(
'id'
)
!==
undefined
&&
!
$
(
this
).
is
(
ele
);
});
});
// If the container is collapsed, check to see if the
// element is on top of its parent list -- don't check the
// position of the container
var
parentList
=
container
.
parents
(
ele
.
data
(
'parent-location-selector'
)).
first
();
if
(
parentList
.
hasClass
(
'collapsed'
))
{
if
(
Math
.
abs
(
eleY
-
parentList
.
offset
().
top
)
<
50
)
{
return
{
ele
:
container
,
attachMethod
:
'prepend'
,
parentList
:
parentList
};
}
}
// Otherwise, do check the container
else
{
// If the list is empty, we should prepend to it
// If the list is empty, we should prepend to it
if
(
siblings
.
length
==
0
)
{
if
(
siblings
.
length
==
0
&&
if
(
Math
.
abs
(
eleY
-
container
.
offset
().
top
)
<
50
)
{
Math
.
abs
(
eleY
-
container
.
offset
().
top
)
<
50
)
{
return
{
return
{
ele
:
container
,
ele
:
container
,
attachMethod
:
'prepend'
attachMethod
:
'prepend'
};
};
}
}
}
// Otherwise the list is populated, and we should attach before/after a sibling
// Otherwise the list is populated, and we should attach before/after a sibling
else
{
else
{
for
(
var
j
=
0
;
j
<
siblings
.
length
;
j
++
)
{
for
(
var
j
=
0
;
j
<
siblings
.
length
;
j
++
)
{
var
$sibling
=
$
(
siblings
[
j
]);
var
$sibling
=
$
(
siblings
[
j
]);
var
siblingHeight
=
$sibling
.
height
();
var
siblingY
=
$sibling
.
offset
().
top
;
var
siblingY
=
$sibling
.
offset
().
top
;
if
(
Math
.
abs
(
eleY
-
siblingY
)
<
$sibling
.
height
())
{
if
(
Math
.
abs
(
eleY
-
siblingY
)
<
siblingHeight
)
{
return
{
return
{
ele
:
$sibling
,
ele
:
$sibling
,
attachMethod
:
siblingY
>
eleY
?
'before'
:
'after'
attachMethod
:
siblingY
>
eleY
?
'before'
:
'after'
...
@@ -86,7 +99,7 @@ $(document).ready(function() {
...
@@ -86,7 +99,7 @@ $(document).ready(function() {
}
}
}
}
}
}
}
// Failed drag
// Failed drag
return
{
return
{
ele
:
null
,
ele
:
null
,
...
@@ -103,33 +116,56 @@ $(document).ready(function() {
...
@@ -103,33 +116,56 @@ $(document).ready(function() {
// Where we started, in case of a failed drag
// Where we started, in case of a failed drag
offset
:
ele
.
offset
(),
offset
:
ele
.
offset
(),
// Which element will be dropped into/onto on success
// Which element will be dropped into/onto on success
dropDestination
:
null
dropDestination
:
null
,
// Timer if we're hovering over a collapsed section
expandTimer
:
null
,
// The list which will be expanded on hover
toExpand
:
null
};
};
}
}
function
onDragMove
(
draggie
,
event
,
pointer
)
{
function
onDragMove
(
draggie
,
event
,
pointer
)
{
var
ele
=
$
(
draggie
.
element
);
var
ele
=
$
(
draggie
.
element
);
var
currentReplacement
=
findDestination
(
ele
).
ele
;
var
destinationInfo
=
findDestination
(
ele
);
var
destinationEle
=
destinationInfo
.
ele
;
var
parentList
=
destinationInfo
.
parentList
;
// Clear the timer if we're not hovering over any element
if
(
!
parentList
)
{
clearTimeout
(
dragState
.
expandTimer
);
}
// If we're hovering over a new element, clear the timer and
// set a new one
else
if
(
!
dragState
.
toExpand
||
parentList
[
0
]
!==
dragState
.
toExpand
[
0
])
{
clearTimeout
(
dragState
.
expandTimer
);
dragState
.
expandTimer
=
setTimeout
(
function
()
{
parentList
.
removeClass
(
'collapsed'
);
},
1000
);
dragState
.
toExpand
=
parentList
;
}
// Clear out the old destination
// Clear out the old destination
if
(
dragState
.
dropDestination
)
{
if
(
dragState
.
dropDestination
)
{
dragState
.
dropDestination
.
removeClass
(
'drop-destination'
);
dragState
.
dropDestination
.
removeClass
(
'drop-destination'
);
}
}
// Mark the new destination
// Mark the new destination
if
(
currentReplacement
)
{
if
(
destinationEle
)
{
currentReplacement
.
addClass
(
'drop-destination'
);
destinationEle
.
addClass
(
'drop-destination'
);
dragState
.
dropDestination
=
currentReplacement
;
dragState
.
dropDestination
=
destinationEle
;
}
}
}
}
function
onDragEnd
(
draggie
,
event
,
pointer
)
{
function
onDragEnd
(
draggie
,
event
,
pointer
)
{
var
ele
=
$
(
draggie
.
element
);
var
ele
=
$
(
draggie
.
element
);
var
intersect
=
findDestination
(
ele
);
var
destinationInfo
=
findDestination
(
ele
);
var
destination
=
intersect
.
ele
;
var
destination
=
destinationInfo
.
ele
;
var
method
=
intersect
.
attachMethod
;
// If the drag succeeded, rearrange the DOM and send the result.
// If the drag succeeded, rearrange the DOM and send the result.
if
(
destination
)
{
if
(
destination
)
{
// Make sure we don't drop into a collapsed element
if
(
destinationInfo
.
parentList
)
{
destinationInfo
.
parentList
.
removeClass
(
'collapsed'
);
}
var
method
=
destinationInfo
.
attachMethod
;
destination
[
method
](
ele
);
destination
[
method
](
ele
);
handleReorder
(
ele
);
handleReorder
(
ele
);
}
}
...
@@ -144,6 +180,7 @@ $(document).ready(function() {
...
@@ -144,6 +180,7 @@ $(document).ready(function() {
if
(
dragState
.
dropDestination
)
{
if
(
dragState
.
dropDestination
)
{
dragState
.
dropDestination
.
removeClass
(
'drop-destination'
);
dragState
.
dropDestination
.
removeClass
(
'drop-destination'
);
}
}
clearTimeout
(
dragState
.
expandTimer
);
dragState
=
{};
dragState
=
{};
}
}
...
...
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