Skip to content
Snippets Groups Projects
Commit c8f7e987 authored by Anthony's avatar Anthony
Browse files

Extract method to create memento related event

parent 1ba10fe8
No related branches found
No related tags found
No related merge requests found
Pipeline #2080 passed
...@@ -11,20 +11,7 @@ $(document).ready(function() { ...@@ -11,20 +11,7 @@ $(document).ready(function() {
// $('.commentaireInfo').prop('popover', 'auto'); // $('.commentaireInfo').prop('popover', 'auto');
$('.commentaireInfoGroup').show(); $('.commentaireInfoGroup').show();
// Comment popover
$('[spanid]').addClass('comment-trigger').each(function (){
const spanid = $(this).attr('spanid');
if($("[commentaireid=" + spanid + "]").length !== 0) {
$(this).popover({
trigger: 'click',
html: true,
placement: 'auto',
content: $("[commentaireid=" + spanid + "]")
});
$("[commentaireid=" + spanid + "]").toggle()
}
});
// $(document).on('click', function() { // $(document).on('click', function() {
// $('[spanid]').popover('hide'); // $('[spanid]').popover('hide');
...@@ -46,3 +33,25 @@ $(document).ready(function() { ...@@ -46,3 +33,25 @@ $(document).ready(function() {
$('.book-icon').hide(); $('.book-icon').hide();
} }
}); });
// Memento popover
// This function adds a popover to elements with the attribute spanid
// that have a corresponding commentaireid element.
const addMementoEvent = function(){
$('[spanid]:not(.comment-trigger)').addClass('comment-trigger').each(function (){
const spanid = $(this).attr('spanid');
if($("[commentaireid=" + spanid + "]").length !== 0) {
$(this).popover({
trigger: 'click',
html: true,
placement: 'auto',
content: $("[commentaireid=" + spanid + "]")
});
$("[commentaireid=" + spanid + "]").toggle()
}
});
}
// Add addMementoEvent to the global scope
window.addMementoEvent = addMementoEvent;
...@@ -17,6 +17,8 @@ function checkAllQuestions(questions, surveyConfig, converter) { ...@@ -17,6 +17,8 @@ function checkAllQuestions(questions, surveyConfig, converter) {
surveyConfig.incorrectComment = surveyConfig.incorrectComment.replace(/\n\n/g, "<br>"); surveyConfig.incorrectComment = surveyConfig.incorrectComment.replace(/\n\n/g, "<br>");
correctIndic.commentNode.innerHTML = converter.renderInline(surveyConfig.incorrectComment) || "Some answers are incorrect!"; correctIndic.commentNode.innerHTML = converter.renderInline(surveyConfig.incorrectComment) || "Some answers are incorrect!";
} }
window.addMementoEvent();
} }
/** /**
...@@ -152,6 +154,11 @@ $(function () { ...@@ -152,6 +154,11 @@ $(function () {
} }
}); });
survey.onAfterRenderSurvey.add((survey, options) => {
window.addMementoEvent();
});
// Add "Check answers" button // Add "Check answers" button
survey.addNavigationItem({ survey.addNavigationItem({
id: "sv-nav-check", id: "sv-nav-check",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment