Commit 44832e42 by Xavier Antoviaque

Merge pull request #63 from dragonfi/close-feedback-popup

Close feedback popup on click to anywhere else
parents 57cee667 cdef641a
......@@ -5,6 +5,37 @@ function MentoringBlock(runtime, element) {
var children = [];
var step = data.step;
function publish_event(data) {
$.ajax({
type: "POST",
url: runtime.handlerUrl(element, 'publish_event'),
data: JSON.stringify(data)
});
}
$(document).on("click", function(event, ui) {
target = $(event.target);
feedback_box = ".mentoring .feedback";
if (target.is(feedback_box)) {
return;
};
if (target.parents(feedback_box).length>0) {
return;
};
$(feedback_box).each(function(i, el) {
el = $(el);
if (el.is(":hidden")) {
return;
}
el.hide();
publish_event({
event_type:'xblock.mentoring.feedback.closed',
content: el.text()
});
});
});
function callIfExists(obj, fn) {
if (typeof obj !== 'undefined' && typeof obj[fn] == 'function') {
return obj[fn].apply(obj, Array.prototype.slice.call(arguments, 2));
......@@ -94,7 +125,7 @@ function MentoringBlock(runtime, element) {
displayChildren: displayChildren,
getChildByName: getChildByName,
step: step,
event_url: runtime.handlerUrl(element, 'publish_event')
publish_event: publish_event
}
if (data.mode === 'standard') {
......@@ -104,9 +135,5 @@ function MentoringBlock(runtime, element) {
MentoringAssessmentView(runtime, element, mentoring);
}
$.ajax({
type: "POST",
url: runtime.handlerUrl(element, 'publish_event'),
data: JSON.stringify({event_type:"xblock.mentoring.loaded"})
});
publish_event({event_type:"xblock.mentoring.loaded"});
}
// TODO: Split in two files
function MessageView(element, mentoring) {
return {
messageDOM: $('.feedback', element),
......@@ -29,20 +30,17 @@ function MessageView(element, mentoring) {
popupDOM.show();
function publish_event(data) {
$.ajax({
type: "POST",
url: mentoring.event_url,
data: JSON.stringify(data)
});
}
publish_event({event_type:'xblock.mentoring.feedback.opened'});
mentoring.publish_event({
event_type:'xblock.mentoring.feedback.opened',
content: $(popupDOM).text()
});
$('.close', popupDOM).on('click', function() {
self.clearPopupEvents();
console.log(popupDOM);
publish_event({event_type:'xblock.mentoring.feedback.closed'});
mentoring.publish_event({
event_type:'xblock.mentoring.feedback.closed',
content: $(popupDOM).text()
});
});
},
showMessage: function(message) {
......
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