Commit a62272d9 by E. Kolpakov

Spinners for droppable elements

parent 4dc7aa13
...@@ -76,6 +76,16 @@ ...@@ -76,6 +76,16 @@
z-index: 10 !important; z-index: 10 !important;
} }
.xblock--drag-and-drop .drag-container .option .spinner-wrapper {
margin-right: 3px;
float: left;
display: none;
}
.xblock--drag-and-drop .drag-container .option .item-content {
display: inline-block;
}
/* Placed option */ /* Placed option */
.xblock--drag-and-drop .drag-container .target .option { .xblock--drag-and-drop .drag-container .target .option {
position: absolute; position: absolute;
......
...@@ -202,20 +202,26 @@ function DragAndDropBlock(runtime, element, configuration) { ...@@ -202,20 +202,26 @@ function DragAndDropBlock(runtime, element, configuration) {
x_percent: x_percent, x_percent: x_percent,
y_percent: y_percent, y_percent: y_percent,
}; };
$.post(url, JSON.stringify(data), 'json').done(function(data){ var $item = $root.find(".option[data-value='"+item_id+"']");
if (data.correct_location) { $item.find('.spinner-wrapper').show();
state.items[item_id].correct_input = Boolean(data.correct);
state.items[item_id].submitting_location = false; $.post(url, JSON.stringify(data), 'json')
} else { .done(function(data){
delete state.items[item_id]; if (data.correct_location) {
} state.items[item_id].correct_input = Boolean(data.correct);
state.feedback = data.feedback; state.items[item_id].submitting_location = false;
if (data.finished) { } else {
state.finished = true; delete state.items[item_id];
state.overall_feedback = data.overall_feedback; }
} state.feedback = data.feedback;
applyState(); if (data.finished) {
}); state.finished = true;
state.overall_feedback = data.overall_feedback;
}
$item.find('.spinner-wrapper').hide();
applyState();
})
.fail(function (data) { $item.find('.spinner-wrapper').hide(); });
}; };
var submitInput = function(evt) { var submitInput = function(evt) {
......
...@@ -18,6 +18,15 @@ ...@@ -18,6 +18,15 @@
}, 0); }, 0);
}; };
var itemSpinnerTemplate = function() {
return (h(
"div.spinner-wrapper",
[
h("i.fa.fa-spin.fa-spinner")
]
));
};
var renderCollection = function(template, collection, ctx) { var renderCollection = function(template, collection, ctx) {
return collection.map(function(item) { return collection.map(function(item) {
return template(item, ctx); return template(item, ctx);
...@@ -59,7 +68,8 @@ ...@@ -59,7 +68,8 @@
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
}, [ }, [
h('div', {innerHTML: item.content_html}), itemSpinnerTemplate(),
h('div', {innerHTML: item.content_html, className: "item-content"}),
itemInputTemplate(item.input) itemInputTemplate(item.input)
] ]
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment