Skip to content

Commit

Permalink
Fixed issue: colors were not updated in dynamic tables if repeatheadi…
Browse files Browse the repository at this point in the history
…ngs was disabled

Dev: separated updateHeadings into updateHeadings and updateColors, the latter is called even if repeatheadings is 0
  • Loading branch information
Grapsus committed Oct 28, 2013
1 parent f03ef3f commit 93277f6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
7 changes: 5 additions & 2 deletions application/helpers/expressions/em_manager_helper.php
Expand Up @@ -6727,10 +6727,13 @@ static function GetRelevanceAndTailoringJavaScript()
{
$rowdividList[$sq['rowdivid']] = $sq['result'];

// make sure to update array_filter headings
// make sure to update array_filter headings and colors
if( ! empty($LEM->qattr[$arg['qid']]['array_filter'])) {
// js to fix colors
$relParts[] = "updateColors($('#question".$arg['qid']."').find('table.question'));\n";
// js to fix headings
$repeatheadings = Yii::app()->getConfig("repeatheadings");
if( ! empty($LEM->qattr[$arg['qid']]['repeat_headings'])) {
if(isset($LEM->qattr[$arg['qid']]['repeat_headings']) && $LEM->qattr[$arg['qid']]['repeat_headings'] !== "") {
$repeatheadings = $LEM->qattr[$arg['qid']]['repeat_headings'];
}
if($repeatheadings > 0)
Expand Down
15 changes: 12 additions & 3 deletions scripts/expressions/em_javascript.js
Expand Up @@ -2917,20 +2917,29 @@ function time () {
return Math.floor(new Date().getTime() / 1000);
}

// updates the deadings of a dynamic table
// updates the repeated headings in a dynamic table
function updateHeadings(tab, rep)
{
tab.find('.repeat').remove();
var header = tab.find('thead>tr');
var trs = tab.find('tr:visible');
trs.each(function(i, tr)
{
// fix line colors
$(tr).removeClass('array1').removeClass('array2').addClass('array' + (1 + i % 2));
// add heading but not for the first and the last rows
if(i != 0 && i % rep == 0 && i != trs.length-1)
{
header.clone().addClass('repeat').addClass('headings').insertAfter(tr);
}
});
}

// updates the colors in a dynamic table
function updateColors(tab)
{
var trs = tab.find('tr:visible');
trs.each(function(i, tr)
{
// fix line colors
$(tr).removeClass('array1').removeClass('array2').addClass('array' + (1 + i % 2));
});
}

0 comments on commit 93277f6

Please sign in to comment.