Check out the LimeSurvey source code on GitHub!

Empty div and span generated by core

More
2 years 7 months ago #110598 by tammo
Currently we are defining a Bootstrap based theme for Limesurvey (which we will gladly share with interested people here).

We ran into the problem that at several places in the generated HTML empty divs and spans are generated. For example: when you have a non-mandatory question and you do not want to display the question code nor the question number, the following HTML is generated.

For example:

<h3 class="panel-title">
<span class="text-danger"></span>
<span class="question-code">pops01</span>
<span class="question-text"><span class="question-number"></span>
<p>
Heeft u opvang thuis na de operatie?</p>
<p>
TEST</p>
</span>
</h3>

The problem is that when you want to position element very precise with padding/margin, these paddings/margins also show up when the elements are not there. For example: when a question is not-mandatory, the padding/margins that you declare for the class .text-danger still show up, because the empty element is generated.

We have tackled this with javascript, but this is actually bad practice: all empty HTML is still generated and transferred to be deleted later.

Would it be possible to change the code thus that empty divs and spans are not generated into the HTML?


Tammo ter Hark
Tools for Research
Haarlem/Amsterdam, The Netherlands

Please Log in to join the conversation.

More
2 years 7 months ago #110602 by DenisChenu
HI,

1st solution : use :empty css class : developer.mozilla.org/docs/Web/CSS/:empty
2nd : use EM to remove undeeded div and span git.sondages.pro/?p=skeletonquest.git/.g...5f8808f50;hb=HEAD#l8

Some empty div can not be removed : Javascrpt update it.

Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
The following user(s) said Thank You: tammo, Ben_V

Please Log in to join the conversation.

More
2 years 7 months ago #110610 by tammo
Hi Denis,

we did use Javascript and solved the problem, but still it is more elegant to build in a check if an element contains data and not render it when it does nor contain data. That way you avoid empty HTML which needs to be hidden by extra javascript.

Thanks for the :empty tip, I did not know that one.

Tammo


Tammo ter Hark
Tools for Research
Haarlem/Amsterdam, The Netherlands

Please Log in to join the conversation.

More
2 years 7 months ago #110611 by DenisChenu
But the <span class="text-danger"></span> is from your template, we don't use it.

For :
<span class="question-number"></span>
{if(!is_empty(QUESTION_NUMBER) or !is_empty(QUESTION_CODE),"<span class='qnumcode'>"+QUESTION_NUMBER+" "+QUESTION_CODE+"</span>","")}
It's not javascript : QUESTION_NUMBER and QUESTION_CODE are static value : then it's removed from HTML (if survey setings disable show).

Like the :
{if(!is_empty(QUESTION_MANDATORY),"<span class='asterisk'>"+QUESTION_MANDATORY+"</span>","")}

It's a template issue: not a LimeSUrvey issue : limesurvey just add *, nothing else.

We have a lot of problem elsewhere ... please : patch core ;)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
The following user(s) said Thank You: tpartner

Please Log in to join the conversation.

More
2 years 7 months ago #110629 by tpartner
Yes Denis, great tip about putting qualifiers around elements in the template files.

Note that :empty does not work in IE8 and earlier (if anyone cares).


.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

More
2 years 7 months ago #110635 by DenisChenu

tpartner wrote: Yes Denis, great tip about putting qualifiers around elements in the template files.

Thanks,

The only potential issue is : "More memory for PHP". Think using EM use a lot of memory, we really need to work on cache for templating and survey start.

Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form