Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xblock-drag-and-drop-v2
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
OpenEdx
xblock-drag-and-drop-v2
Commits
1ace6d32
Commit
1ace6d32
authored
Dec 09, 2015
by
Tim Krones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update virtual DOM instead of DOM.
parent
09eeaf94
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
4 deletions
+13
-4
drag_and_drop_v2/public/js/drag_and_drop.js
+12
-3
drag_and_drop_v2/public/js/view.js
+1
-1
No files found.
drag_and_drop_v2/public/js/drag_and_drop.js
View file @
1ace6d32
...
...
@@ -27,7 +27,10 @@ function DragAndDropBlock(runtime, element) {
};
var
setItemsHeight
=
function
()
{
$
(
'.items'
,
element
).
height
(
$
(
'.items'
,
element
).
height
());
var
itemsHeight
=
$
(
'.items'
,
element
).
height
();
// Need to update the DOM here, otherwise .items will resize when first item is moved to target
$
(
'.items'
,
element
).
height
(
itemsHeight
);
__state
.
itemsHeight
=
itemsHeight
;
};
var
getState
=
function
()
{
...
...
@@ -35,6 +38,14 @@ function DragAndDropBlock(runtime, element) {
};
var
setState
=
function
(
new_state
)
{
var
itemsHeight
;
if
(
__state
===
undefined
)
{
itemsHeight
=
'auto'
;
}
else
{
itemsHeight
=
__state
.
itemsHeight
;
}
new_state
.
itemsHeight
=
itemsHeight
;
if
(
new_state
.
state
.
feedback
)
{
if
(
new_state
.
state
.
feedback
!==
__state
.
state
.
feedback
)
{
publishEvent
({
...
...
@@ -215,14 +226,12 @@ function DragAndDropBlock(runtime, element) {
};
var
resetExercise
=
function
()
{
$
(
'.items'
).
height
(
'auto'
);
$
.
ajax
({
type
:
'POST'
,
url
:
runtime
.
handlerUrl
(
element
,
'reset'
),
data
:
'{}'
,
success
:
function
(
new_state
)
{
setState
(
new_state
);
setItemsHeight
();
}
});
};
...
...
drag_and_drop_v2/public/js/view.js
View file @
1ace6d32
...
...
@@ -96,7 +96,7 @@
h
(
'p'
,
{
innerHTML
:
ctx
.
question_html
})
]),
h
(
'section.drag-container'
,
[
h
(
'div.items'
,
renderCollection
(
itemTemplate
,
ctx
.
items
,
ctx
)),
h
(
'div.items'
,
{
height
:
ctx
.
itemsHeight
},
renderCollection
(
itemTemplate
,
ctx
.
items
,
ctx
)),
h
(
'div.target'
,
[
h
(
'div.popup'
,
{
style
:
{
display
:
ctx
.
popup_html
?
'block'
:
'none'
}},
[
h
(
'div.close.icon-remove-sign.fa-times-circle'
),
...
...
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