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
7fb5cfc9
Commit
7fb5cfc9
authored
Dec 22, 2015
by
E. Kolpakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Virtual DOM instead of explicit hide/show
parent
834fb7fc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
20 deletions
+16
-20
drag_and_drop_v2/public/css/drag_and_drop.css
+0
-2
drag_and_drop_v2/public/js/drag_and_drop.js
+10
-15
drag_and_drop_v2/public/js/view.js
+6
-3
No files found.
drag_and_drop_v2/public/css/drag_and_drop.css
View file @
7fb5cfc9
...
@@ -83,7 +83,6 @@
...
@@ -83,7 +83,6 @@
.xblock--drag-and-drop
.drag-container
.option
.spinner-wrapper
{
.xblock--drag-and-drop
.drag-container
.option
.spinner-wrapper
{
margin-right
:
3px
;
margin-right
:
3px
;
float
:
left
;
float
:
left
;
display
:
none
;
}
}
.xblock--drag-and-drop
.drag-container
.option
.item-content
{
.xblock--drag-and-drop
.drag-container
.option
.item-content
{
...
@@ -122,7 +121,6 @@
...
@@ -122,7 +121,6 @@
top
:
0
;
top
:
0
;
margin-right
:
5px
;
margin-right
:
5px
;
padding-top
:
6px
;
padding-top
:
6px
;
display
:
none
;
color
:
#333
;
color
:
#333
;
}
}
...
...
drag_and_drop_v2/public/js/drag_and_drop.js
View file @
7fb5cfc9
...
@@ -191,14 +191,6 @@ function DragAndDropBlock(runtime, element, configuration) {
...
@@ -191,14 +191,6 @@ function DragAndDropBlock(runtime, element, configuration) {
});
});
};
};
var
showSpinner
=
function
(
$item
)
{
$item
.
find
(
'.spinner-wrapper'
).
show
();
};
var
hideSpinner
=
function
(
$item
)
{
$item
.
find
(
'.spinner-wrapper'
).
hide
();
};
var
submitLocation
=
function
(
item_id
,
zone
,
x_percent
,
y_percent
)
{
var
submitLocation
=
function
(
item_id
,
zone
,
x_percent
,
y_percent
)
{
if
(
!
zone
)
{
if
(
!
zone
)
{
return
;
return
;
...
@@ -210,8 +202,6 @@ function DragAndDropBlock(runtime, element, configuration) {
...
@@ -210,8 +202,6 @@ function DragAndDropBlock(runtime, element, configuration) {
x_percent
:
x_percent
,
x_percent
:
x_percent
,
y_percent
:
y_percent
,
y_percent
:
y_percent
,
};
};
var
$item
=
$root
.
find
(
".option[data-value='"
+
item_id
+
"']"
);
showSpinner
(
$item
);
$
.
post
(
url
,
JSON
.
stringify
(
data
),
'json'
)
$
.
post
(
url
,
JSON
.
stringify
(
data
),
'json'
)
.
done
(
function
(
data
){
.
done
(
function
(
data
){
...
@@ -226,10 +216,12 @@ function DragAndDropBlock(runtime, element, configuration) {
...
@@ -226,10 +216,12 @@ function DragAndDropBlock(runtime, element, configuration) {
state
.
finished
=
true
;
state
.
finished
=
true
;
state
.
overall_feedback
=
data
.
overall_feedback
;
state
.
overall_feedback
=
data
.
overall_feedback
;
}
}
hideSpinner
(
$item
);
applyState
();
applyState
();
})
})
.
fail
(
function
(
data
)
{
hideSpinner
(
$item
);
});
.
fail
(
function
(
data
)
{
delete
state
.
items
[
item_id
];
applyState
();
});
};
};
var
submitInput
=
function
(
evt
)
{
var
submitInput
=
function
(
evt
)
{
...
@@ -244,7 +236,6 @@ function DragAndDropBlock(runtime, element, configuration) {
...
@@ -244,7 +236,6 @@ function DragAndDropBlock(runtime, element, configuration) {
return
;
return
;
}
}
showSpinner
(
input_div
);
state
.
items
[
item_id
].
input
=
input_value
;
state
.
items
[
item_id
].
input
=
input_value
;
state
.
items
[
item_id
].
submitting_input
=
true
;
state
.
items
[
item_id
].
submitting_input
=
true
;
applyState
();
applyState
();
...
@@ -260,10 +251,12 @@ function DragAndDropBlock(runtime, element, configuration) {
...
@@ -260,10 +251,12 @@ function DragAndDropBlock(runtime, element, configuration) {
state
.
finished
=
true
;
state
.
finished
=
true
;
state
.
overall_feedback
=
data
.
overall_feedback
;
state
.
overall_feedback
=
data
.
overall_feedback
;
}
}
hideSpinner
(
input_div
);
applyState
();
applyState
();
})
})
.
fail
(
function
(
data
)
{
hideSpinner
(
input_div
);
});
.
fail
(
function
(
data
)
{
state
.
items
[
item_id
].
submitting_input
=
false
;
applyState
();
});
};
};
var
closePopup
=
function
(
evt
)
{
var
closePopup
=
function
(
evt
)
{
...
@@ -311,6 +304,7 @@ function DragAndDropBlock(runtime, element, configuration) {
...
@@ -311,6 +304,7 @@ function DragAndDropBlock(runtime, element, configuration) {
has_value
:
Boolean
(
item_user_state
&&
'input'
in
item_user_state
),
has_value
:
Boolean
(
item_user_state
&&
'input'
in
item_user_state
),
value
:
(
item_user_state
&&
item_user_state
.
input
)
||
''
,
value
:
(
item_user_state
&&
item_user_state
.
input
)
||
''
,
class_name
:
undefined
,
class_name
:
undefined
,
xhr_active
:
(
item_user_state
&&
item_user_state
.
submitting_input
)
};
};
if
(
input
.
has_value
&&
!
item_user_state
.
submitting_input
)
{
if
(
input
.
has_value
&&
!
item_user_state
.
submitting_input
)
{
input
.
class_name
=
item_user_state
.
correct_input
?
'correct'
:
'incorrect'
;
input
.
class_name
=
item_user_state
.
correct_input
?
'correct'
:
'incorrect'
;
...
@@ -320,6 +314,7 @@ function DragAndDropBlock(runtime, element, configuration) {
...
@@ -320,6 +314,7 @@ function DragAndDropBlock(runtime, element, configuration) {
value
:
item
.
id
,
value
:
item
.
id
,
drag_disabled
:
Boolean
(
item_user_state
||
state
.
finished
),
drag_disabled
:
Boolean
(
item_user_state
||
state
.
finished
),
class_name
:
item_user_state
&&
(
'input'
in
item_user_state
||
item_user_state
.
correct_input
)
?
'fade'
:
undefined
,
class_name
:
item_user_state
&&
(
'input'
in
item_user_state
||
item_user_state
.
correct_input
)
?
'fade'
:
undefined
,
xhr_active
:
(
item_user_state
&&
item_user_state
.
submitting_location
),
input
:
input
,
input
:
input
,
content_html
:
item
.
backgroundImage
?
'<img src="'
+
item
.
backgroundImage
+
'"/>'
:
item
.
displayName
content_html
:
item
.
backgroundImage
?
'<img src="'
+
item
.
backgroundImage
+
'"/>'
:
item
.
displayName
};
};
...
...
drag_and_drop_v2/public/js/view.js
View file @
7fb5cfc9
...
@@ -18,7 +18,10 @@
...
@@ -18,7 +18,10 @@
},
0
);
},
0
);
};
};
var
itemSpinnerTemplate
=
function
()
{
var
itemSpinnerTemplate
=
function
(
xhr_active
)
{
if
(
!
xhr_active
)
{
return
null
;
}
return
(
h
(
return
(
h
(
"div.spinner-wrapper"
,
"div.spinner-wrapper"
,
[
[
...
@@ -43,7 +46,7 @@
...
@@ -43,7 +46,7 @@
style
:
{
display
:
input
.
is_visible
?
'block'
:
'none'
}},
[
style
:
{
display
:
input
.
is_visible
?
'block'
:
'none'
}},
[
h
(
'input.input'
,
{
type
:
'text'
,
value
:
input
.
value
,
disabled
:
input
.
has_value
,
h
(
'input.input'
,
{
type
:
'text'
,
value
:
input
.
value
,
disabled
:
input
.
has_value
,
focusHook
:
focus_hook
}),
focusHook
:
focus_hook
}),
itemSpinnerTemplate
(),
itemSpinnerTemplate
(
input
.
xhr_active
),
h
(
'button.submit-input'
,
{
disabled
:
input
.
has_value
},
gettext
(
'ok'
))
h
(
'button.submit-input'
,
{
disabled
:
input
.
has_value
},
gettext
(
'ok'
))
])
])
);
);
...
@@ -69,7 +72,7 @@
...
@@ -69,7 +72,7 @@
attributes
:
{
'data-value'
:
item
.
value
,
'data-drag-disabled'
:
item
.
drag_disabled
},
attributes
:
{
'data-value'
:
item
.
value
,
'data-drag-disabled'
:
item
.
drag_disabled
},
style
:
style
style
:
style
},
[
},
[
itemSpinnerTemplate
(),
itemSpinnerTemplate
(
item
.
xhr_active
),
h
(
'div'
,
{
innerHTML
:
item
.
content_html
,
className
:
"item-content"
}),
h
(
'div'
,
{
innerHTML
:
item
.
content_html
,
className
:
"item-content"
}),
itemInputTemplate
(
item
.
input
)
itemInputTemplate
(
item
.
input
)
]
]
...
...
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