Skip to content

Commit

Permalink
Dev: move template related function to template
Browse files Browse the repository at this point in the history
Dev: template can use :empty for help, for answer:
Dev: fix dual scale 'no answer' radio event
Dev: review some html to have empty cell if needed
  • Loading branch information
Shnoulle committed Oct 30, 2016
1 parent df2adeb commit a3b7fcf
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 81 deletions.
Expand Up @@ -33,10 +33,6 @@
</td>

<?php if ($right_exists): ?>
<th class='answertextright'>
<label>
<?php echo $answertextright; ?>
</label>
</th>
<th class='answertextright'><?php echo $answertextright; ?></th>
<?php endif; ?>
</tr>
Expand Up @@ -20,9 +20,7 @@
echo $answer_tds;
?>
<?php if ($right_exists): ?>
<th class='answertextright'>
<?php echo $answertextright; ?>
</th>
<th class='answertextright'><?php echo $answertextright; ?></th>
<?php endif; ?>

<?php
Expand Down
Expand Up @@ -22,7 +22,7 @@ class="answers-list radio-list <?php echo ($i % 2)?'ls-odd':'ls-even';?> <?php i
</colgroup>
<thead><!-- The global concept is hard to understand : must control if aria-labelledby for radio-group is OK and if we can add aria-hidden here -->
<tr class='ls-heading'><!-- unsure for ls-heading class here -->
<td>&nbsp;</td>
<td></td>
<?php
foreach ($aQuestions as $i=>$question): ?>
<th id="answertext<?php echo $question['myfname'];?>" class="answertext control-label <?php if($question['errormandatory']){ echo " has-error error-mandatory";} ?>">
Expand Down
12 changes: 5 additions & 7 deletions application/views/survey/questions/arrays/dualscale/answer.php
Expand Up @@ -33,18 +33,18 @@
<thead>
<?php if ($leftheader != '' || $rightheader !=''): ?>
<tr class="ls-heading groups header_row">
<th class="header_answer_text">&nbsp;</th>
<th class="header_answer_text"></th>
<th colspan="<?php echo count($labelans0); ?>" class="dsheader text-center"><?php echo $leftheader; ?></th>

<?php if (count($labelans1) > 0): ?>
<td class="header_separator">&nbsp;</td> <!-- // Separator -->
<td class="header_separator"></td> <!-- // Separator -->
<th colspan="<?php echo count($labelans1); ?>" class="dsheader text-center"><?php echo $rightheader; ?></th>
<?php endif; ?>

<?php if($shownoanswer || $rightexists): ?>
<td class="header_separator <?php echo $rigthclass; ?>">&nbsp;</td>
<td class="header_separator <?php echo $rigthclass; ?>"></td>
<?php if($shownoanswer): ?>
<th class="header_no_answer">&nbsp;</th>
<th class="header_no_answer"></th>
<?php endif; ?>
<?php endif; ?>
</tr>
Expand Down Expand Up @@ -168,9 +168,7 @@ class="answers-list radio-list <?php echo ($ansrow['odd']) ? "ls-odd" : "ls-even

<!-- Separator for no-answer -->
<?php if ($shownoanswer || $rightexists): ?>
<td class="answertextright dual_scale_separator information-item">
<?php echo $answertextright; ?>
</td>
<td class="answertextright dual_scale_separator information-item"><?php echo $answertextright; ?></td>
<?php endif; ?>

<!-- No answer column -->
Expand Down
Expand Up @@ -24,9 +24,9 @@

<thead>
<tr class="ls-heading">
<td>&nbsp;</td>
<td></td>
<th class='left-header'><?php echo $leftheader; ?></th>
<td>&nbsp;</td>
<td></td>
<th class='right-header'><?php echo $rightheader; ?></th>
</tr>
</thead>
Expand All @@ -38,18 +38,6 @@

<?php foreach ($aSubQuestions as $ansrow): ?>
<!-- <tr> -->
<?php
echo CHtml::tag(
"tr",
array(
'id'=> "javatbd{$ansrow['myfname']}",

'role'=>"group",
),
"",
false
);
?>
<tr id="javatbd<?php echo $ansrow['myfname']; ?>" role="group" class="answers-list radio-list <?php echo ($ansrow['odd']) ? "ls-odd" : "ls-even"; ?><?php echo ($ansrow['mandatoryviolation']) ? " has-error" : ""; ?>"
<!-- Answer text (actual question) -->

Expand Down Expand Up @@ -137,9 +125,7 @@ class='form-control'
<div class="ls-input-group">
<?php endif; ?>
<?php if ($ddprefix != ''): ?>
<div class="ddprefix ls-input-group-extra">
<?php echo $ddprefix; ?>
</div>
<div class="ddprefix ls-input-group-extra"><?php echo $ddprefix; ?></div>
<?php endif; ?>
<select class='form-control' name="<?php echo $ansrow['myfname1']; ?>" id="answer<?php echo $ansrow['myfid1']; ?>" aria-labelledby="label-<?php echo $ansrow['myfname']; ?>"">
<!-- Please choose... -->
Expand All @@ -165,9 +151,7 @@ class='form-control'

</select>
<?php if ($ddsuffix != ''): ?>
<div class="ddsuffix ls-input-group-extra">
<?php echo $ddsuffix; ?>
</div>
<div class="ddsuffix ls-input-group-extra"><?php echo $ddsuffix; ?></div>
<?php endif; ?>
<?php if ($ddprefix != '' || $ddsuffix != ''): ?>
</div>
Expand Down
Expand Up @@ -34,9 +34,7 @@

<!-- right -->
<?php if($rightTd): ?>
<td class="answertextright">
<?php echo $answertextright; ?>
</td>
<td class="answertextright"><?php echo $answertextright; ?></td>
<?php endif;?>
</tr>
<!-- end of answer_row -->
Expand Up @@ -32,11 +32,9 @@
<!-- Total -->
<?php if($rightTd): ?>
<?php if($rightTdEmpty): ?>
<td class="answertextright">&nbsp;</td>
<td class="answertextright"></td>
<?php else: ?>
<td class="answertextright">
<?php echo $answertext; ?>
</td>
<td class="answertextright"><?php echo $answertext; ?></td>
<?php endif; ?>
<?php endif;?>

Expand Down
9 changes: 4 additions & 5 deletions scripts/dualscale.js
Expand Up @@ -21,10 +21,8 @@
*/
function doDualScaleRadio(qID) {
// We can do it before document ready, because function come after answers and we use delegate
$("#question"+qID+" .jshide").hide();

// Lauch EM with hidden input
$("#question"+qID+" table.question").delegate(".noanswer-item :radio","click",function(){
$("#question"+qID+" .ls-answers").delegate(".noanswer-item :radio","click",function(){
$(this).closest(".answers-list").find(":radio[value='']").prop("checked", true);
name=$(this).attr("name");
name0=name.replace("#1","_0");
Expand All @@ -34,7 +32,7 @@ function doDualScaleRadio(qID) {
ExprMgr_process_relevance_and_tailoring('change',name0,'hidden');
ExprMgr_process_relevance_and_tailoring('change',name1,'hidden');
});
$("#question"+qID+" table.question").delegate(".answer-item:not(.noanswer-item) :radio","click",function(){
$("#question"+qID+" .ls-answers").delegate(".answer-item:not(.noanswer-item) :radio","click",function(){
$(this).closest(".answers-list").find(":radio[value='']").prop("checked", false);
name=$(this).attr("name");
name=name.replace('#','_');
Expand All @@ -49,9 +47,10 @@ function doDualScaleRadio(qID) {
*
* @author Denis Chenu (Shnoulle)
* @param {number} qId The qid of the question where apply.
* @todo : control if it's needed since em_javascript have his own function (or fix em_javascript function)
*/
function doDualScaleDropDown(qID) {
$("#question"+qID+" table.question").delegate("select","change",function(){
$("#question"+qID+" .ls-answers").delegate("select","change",function(){
name=$(this).attr("name");
name=name.replace('#','_');
value=""+$(this).val();
Expand Down
20 changes: 1 addition & 19 deletions scripts/survey_runtime.js
Expand Up @@ -442,22 +442,4 @@ function doToolTipTable()
}
});
}
//Hide the Answer and the helper field in an : template related , no ?
$(document).ready(
function(){
$('.question-container').each(function(){
if($(this).find('div.answer-container').find('input').length == 1)
{
if($(this).find('div.answer-container').find('input[type=hidden]').length >0
&& $(this).find('div.answer-container').find('select').length < 1)
{
$(this).find('div.answer-container').css({display: 'none'});
}
if(trim($(this).find('div.question-help-container').find('div').html()) == "")
{
$(this).find('div.question-help-container').css({display: 'none'});
}
}
});
}
);

20 changes: 10 additions & 10 deletions templates/basic/css/template-core.css
Expand Up @@ -26,13 +26,11 @@ li.radio-item,li.checkbox-item{display:block}
table.ls-answers{table-layout:fixed}
table.ls-answers{width:100%}
/* Basic alignment */
.ls-answers > tbody > tr > td
.ls-answers > tbody > tr > td,.ls-answers > tbody > tr > th
{vertical-align:middle}
.ls-answers tbody td
{text-align:center}
.ls-answers tbody th
{vertical-align:middle}
.ls-answers thead th
.ls-answers > thead > tr > th
{text-align:center;vertical-align:bottom}

.ls-answers .answertextright{text-align:left}
Expand Down Expand Up @@ -80,11 +78,15 @@ margin: 0;
height:1px;
overflow:hidden;
}
/* Some specif question review */
/* Some specific question review */
.yesno-button .btn,.gender-button .btn{
white-space: normal;
}

.boilerplate .answers-wrapper,.equation .answers-wrapper{
display:none;
}
/* Hide emty question-help */
.question-help:empty{display:none}
/*
Max width before this PARTICULAR table gets nasty
For iPads specifically : add this : (min-device-width: 768px) and (max-device-width: 1024px)
Expand All @@ -99,9 +101,7 @@ only screen and (max-width: 760px),
table.ls-answers{border:0 none}
.ls-answers tr {margin-bottom:1em;}
.ls-answers thead{display:none} /* We don't need it for accessibility : we already have the label */



.ls-answers tbody >tr >th:empty{display:none}
.ls-answers > tbody > tr > td.radio-item{padding:4px;padding-left: 24px;}
/* Show the label */
label.ls-label-xs-visibility
Expand All @@ -122,7 +122,7 @@ only screen and (max-width: 760px),
line-height: initial;
text-indent: initial;
}
.question label.ls-label-xs-visibility > *
.ls-answers label.ls-label-xs-visibility > *
{
position:relative;
left:auto;
Expand Down
4 changes: 0 additions & 4 deletions templates/basic/css/template.css
Expand Up @@ -26,10 +26,6 @@ html {
/**
* Some specific
*/
.boilerplate .answers-wrapper,.equation .answers-wrapper{
display:none;
}
.question-help:empty{display:none}

@media
only screen and (max-width: 760px),
Expand Down
19 changes: 19 additions & 0 deletions templates/flatmodern/scripts/template.js
Expand Up @@ -182,3 +182,22 @@ function fixBodyPadding(){
/* The 50 px is fixed in template.css */
$("body").css("padding-top",$(".navbar-fixed-top").height+"px")
}
//Hide the Answer and the helper field
$(document).ready(
function(){
$('.question-container').each(function(){
if($(this).find('div.answer-container').find('input').length == 1)
{
if($(this).find('div.answer-container').find('input[type=hidden]').length >0
&& $(this).find('div.answer-container').find('select').length < 1)
{
$(this).find('div.answer-container').css({display: 'none'});
}
if(trim($(this).find('div.question-help-container').find('div').html()) == "")
{
$(this).find('div.question-help-container').css({display: 'none'});
}
}
});
}
);

0 comments on commit a3b7fcf

Please sign in to comment.