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
14b4b6a2
Commit
14b4b6a2
authored
Aug 22, 2013
by
Brian Talbot
Committed by
cahrens
Oct 07, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds in minimally revised drag and drop styling.
Add CSS classes and fix drop destination bug.
parent
85be9b42
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
37 deletions
+47
-37
cms/static/coffee/spec/views/overview_spec.coffee
+3
-2
cms/static/js/views/overview.js
+18
-10
cms/static/sass/views/_outline.scss
+26
-25
No files found.
cms/static/coffee/spec/views/overview_spec.coffee
View file @
14b4b6a2
...
@@ -167,10 +167,11 @@ describe "Course Overview", ->
...
@@ -167,10 +167,11 @@ describe "Course Overview", ->
null
null
)
)
expect
(
CMS
.
Views
.
Draggabilly
.
dragState
).
toEqual
(
expect
(
CMS
.
Views
.
Draggabilly
.
dragState
).
toEqual
(
offset
:
$
(
'#unit-1'
).
offset
()
dropDestination
:
null
,
dropDestination
:
null
,
expandTimer
:
null
,
expandTimer
:
null
,
toExpand
:
null
toExpand
:
null
,
attachMethod
:
''
,
parentList
:
null
)
)
describe
"onDragMove"
,
->
describe
"onDragMove"
,
->
...
...
cms/static/js/views/overview.js
View file @
14b4b6a2
...
@@ -77,14 +77,16 @@ CMS.Views.Draggabilly = {
...
@@ -77,14 +77,16 @@ CMS.Views.Draggabilly = {
onDragStart
:
function
(
draggie
,
event
,
pointer
)
{
onDragStart
:
function
(
draggie
,
event
,
pointer
)
{
var
ele
=
$
(
draggie
.
element
);
var
ele
=
$
(
draggie
.
element
);
this
.
dragState
=
{
this
.
dragState
=
{
// Where we started, in case of a failed drag
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
// Timer if we're hovering over a collapsed section
expandTimer
:
null
,
expandTimer
:
null
,
// The list which will be expanded on hover
// The list which will be expanded on hover
toExpand
:
null
toExpand
:
null
,
// How we attach to the destination: 'before', 'after', 'prepend'
attachMethod
:
''
,
// If dragging to an empty section, the parent section
parentList
:
null
};
};
},
},
...
@@ -92,7 +94,7 @@ CMS.Views.Draggabilly = {
...
@@ -92,7 +94,7 @@ CMS.Views.Draggabilly = {
var
ele
=
$
(
draggie
.
element
);
var
ele
=
$
(
draggie
.
element
);
var
destinationInfo
=
this
.
findDestination
(
ele
);
var
destinationInfo
=
this
.
findDestination
(
ele
);
var
destinationEle
=
destinationInfo
.
ele
;
var
destinationEle
=
destinationInfo
.
ele
;
var
parentList
=
destinationInfo
.
parentList
;
var
parentList
=
this
.
dragState
.
parentList
=
destinationInfo
.
parentList
;
// Clear the timer if we're not hovering over any element
// Clear the timer if we're not hovering over any element
if
(
!
parentList
)
{
if
(
!
parentList
)
{
clearTimeout
(
this
.
dragState
.
expandTimer
);
clearTimeout
(
this
.
dragState
.
expandTimer
);
...
@@ -113,27 +115,33 @@ CMS.Views.Draggabilly = {
...
@@ -113,27 +115,33 @@ CMS.Views.Draggabilly = {
}
}
// Mark the new destination
// Mark the new destination
if
(
destinationEle
)
{
if
(
destinationEle
)
{
ele
.
addClass
(
'valid-drop'
);
destinationEle
.
addClass
(
'drop-target drop-target-'
+
destinationInfo
.
attachMethod
);
destinationEle
.
addClass
(
'drop-target drop-target-'
+
destinationInfo
.
attachMethod
);
this
.
dragState
.
attachMethod
=
destinationInfo
.
attachMethod
;
this
.
dragState
.
dropDestination
=
destinationEle
;
this
.
dragState
.
dropDestination
=
destinationEle
;
}
}
},
},
onDragEnd
:
function
(
draggie
,
event
,
pointer
)
{
onDragEnd
:
function
(
draggie
,
event
,
pointer
)
{
var
ele
=
$
(
draggie
.
element
);
var
ele
=
$
(
draggie
.
element
);
var
destination
=
this
.
dragState
.
dropDestination
;
var
destinationInfo
=
this
.
findDestination
(
ele
);
var
destination
=
destinationInfo
.
ele
;
// If the drag succeeded, rearrange the DOM and send the result.
// If the drag succeeded, rearrange the DOM and send the result.
if
(
destination
&&
pointer
.
x
>=
ele
.
offset
().
left
if
(
destination
&&
pointer
.
x
>=
ele
.
offset
().
left
&&
pointer
.
x
<
ele
.
offset
().
left
+
ele
.
width
())
{
&&
pointer
.
x
<
ele
.
offset
().
left
+
ele
.
width
())
{
// Make sure we don't drop into a collapsed element
// Make sure we don't drop into a collapsed element
if
(
destinationInfo
.
parentList
)
{
if
(
this
.
dragState
.
parentList
)
{
destinationInfo
.
parentList
.
removeClass
(
'collapsed'
);
this
.
dragState
.
parentList
.
removeClass
(
'collapsed'
);
}
}
var
method
=
destinationInfo
.
attachMethod
;
var
method
=
this
.
dragState
.
attachMethod
;
destination
[
method
](
ele
);
destination
[
method
](
ele
);
this
.
handleReorder
(
ele
);
this
.
handleReorder
(
ele
);
ele
.
removeClass
(
'valid-drop'
);
}
// If the drag failed, send it back
else
{
$
(
'.was-dragging'
).
removeClass
(
'was-dragging'
);
ele
.
addClass
(
'was-dragging'
);
}
}
// Everything in its right place
// Everything in its right place
...
...
cms/static/sass/views/_outline.scss
View file @
14b4b6a2
...
@@ -675,35 +675,36 @@
...
@@ -675,35 +675,36 @@
color
:
$darkGrey
;
color
:
$darkGrey
;
}
}
// sort/drag and drop
// ====================
.ui-droppable
{
@include
transition
(
padding
0
.5s
ease-in-out
0s
);
min-height
:
20px
;
padding
:
0
;
&
.dropover
{
// UI: drag handles
padding
:
15px
0
;
.section-drag-handle
,
.draggable
{
}
}
.ui-draggable-dragging
{
&
:hover
,
&
:focus
{
box-shadow
:
0
1px
2px
rgba
(
0
,
0
,
0
,
.3
);
cursor
:
move
;
border
:
1px
solid
$darkGrey
;
}
opacity
:
0
.2
;
}
&
:hover
{
opacity
:
1
.0
;
.section-item
{
background
:
$yellow
!
important
;
}
}
// hiding unit button - temporary fix until this semantically corrected
// UI: drag states
.new-unit-item
{
.is-dragging
{
display
:
none
;
@extend
.ui-depth4
;
}
box-shadow
:
0
1px
2px
0
$blue-t2
;
cursor
:
move
;
opacity
:
0
.80
;
border-color
:
$blue
;
}
}
ol
.ui-droppable
.branch
:first-child
.section-item
{
// UI: drag target
border-top
:
none
;
.drop-target
{
background
:
$blue-t0
!
important
;
&
.drop-target-before
{
border-top
:
(
$baseline
/
5
)
solid
$blue
;
}
&
.drop-target-after
{
border-bottom
:
(
$baseline
/
5
)
solid
$blue
;
}
}
}
}
}
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