Skip to content

Commit

Permalink
New feature #10055: Hide question if all sub-questions are hidden (pa…
Browse files Browse the repository at this point in the history
…rtial : not for question by question mode)

Dev: core or template issue ?
  • Loading branch information
Shnoulle committed Nov 8, 2016
1 parent 097c175 commit b15dba5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
2 changes: 2 additions & 0 deletions application/core/packages/limesurvey/survey.js
Expand Up @@ -41,6 +41,7 @@ function triggerEmRelevanceQuestion(){
}
});
}
/* On Group */
function triggerEmRelevanceGroup(){
$("[id^='group-']").on('relevance:on',function(event,data) {
if(event.target != this) return;
Expand All @@ -51,6 +52,7 @@ function triggerEmRelevanceGroup(){
$(this).addClass("ls-unrelevant ls-hidden");
});
}
/* On sub-question and answers-list */
function triggerEmRelevanceSubQuestion(){
$("[id^='question']").on('relevance:on',"[id^='javatbd']",function(event,data) {
if(event.target != this) return; // not needed now, but after (2016-11-07)
Expand Down
29 changes: 26 additions & 3 deletions templates/default/scripts/template.js
Expand Up @@ -121,8 +121,7 @@ window.alert = function(message, title) {
* in endpage and in $(window).resize
*/
function fixBodyPadding(){
/* The 50 px is fixed in template.css */
console.log($(".navbar-fixed-top").height());
/* The 60 px is fixed in template.css */
$("body").css("padding-top",$(".navbar-fixed-top").height()+"px")
}
/**
Expand Down Expand Up @@ -203,5 +202,29 @@ function triggerEmClassChangeTemplate(){
$questionContainer = $(this).parents('div.question-container');
$questionContainer.removeClass('input-error');/* Not working with mandatory question ... */
});

}
/**
* Hide question if all sub-questions is hidden
* @see core/package/limesurvey/survey.js:triggerEmRelevanceSubQuestion
* @see https://bugs.limesurvey.org/view.php?id=10055 (partial)
* Must be before ready (event happen before ready)
*/
function hideQuestionWithRelevanceSubQuestion(){
$("[id^='question']").on('relevance:on',"[id^='javatbd']",function(event,data) {
if(event.target != this) return; // not needed now, but after (2016-11-07)
data = $.extend({style:'hidden'}, data);
if(data.style=='hidden'){
$(this).closest("[id^='question']:not(.ls-unrelevant)").removeClass("ls-hidden")
}
});
$("[id^='question']").on('relevance:off',"[id^='javatbd']",function(event,data) {
if(event.target != this) return; // not needed now, but after (2016-11-07)
data = $.extend({style:'hidden'}, data);
console.log(data.style);
if(data.style=='hidden'){
if($(this).closest("[id^='question']").find("[id^='javatbd']:visible").length==0){
$(this).closest("[id^='question']").addClass("ls-hidden");// ls-hidden only is used only for Equation question type actually (but think must fix and use another class)
}
}
});
}
1 change: 1 addition & 0 deletions templates/default/views/endpage.pstpl
Expand Up @@ -22,5 +22,6 @@
/*<![CDATA[*/
sliderSuffixClone();
fixBodyPadding();
hideQuestionWithRelevanceSubQuestion();
/*]]>*/
</script>

0 comments on commit b15dba5

Please sign in to comment.