MediaWiki:Common.js: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 440: | Строка 440: | ||
} | } | ||
// | // Подсветка всех ячеек в текущем ряду | ||
cells.forEach(function(innerCell, innerIndex) { | cells.forEach(function(innerCell, innerIndex) { | ||
innerCell.style.backgroundColor = brightenColor(getComputedStyle(innerCell).backgroundColor); | innerCell.style.backgroundColor = brightenColor(getComputedStyle(innerCell).backgroundColor); | ||
innerCell.style.color = brightenColor(getComputedStyle(innerCell).color); | innerCell.style.color = brightenColor(getComputedStyle(innerCell).color); | ||
}); | |||
// Подсветка ячеек, к которым прилегает rowspan ячейка | |||
cells.forEach(function(innerCell, innerIndex) { | |||
var spanTop = parseInt(innerCell.getAttribute('rowspan'), 10) || 1; | |||
for (var i = 1; i < spanTop; i++) { | |||
var adjacentRow = topLevelRows[rowIndex + i]; | |||
if (adjacentRow) { | |||
var adjacentCells = adjacentRow.querySelectorAll('td, th'); | |||
Array.prototype.forEach.call(adjacentCells, function(adjCell, adjIndex) { | |||
if (!adjCell.hasAttribute('rowspan') || adjCell.getAttribute('rowspan') == 1) { | |||
adjCell.style.backgroundColor = brightenColor(getComputedStyle(adjCell).backgroundColor); | |||
adjCell.style.color = brightenColor(getComputedStyle(adjCell).color); | |||
} | |||
}); | |||
} | |||
} | |||
}); | }); | ||
}); | }); | ||
// Добавляем обработчик события, когда мышь уходит с ячейки | |||
cell.addEventListener('mouseout', function() { | cell.addEventListener('mouseout', function() { | ||
// Восстанавливаем стили для всех строк, затронутых rowspan | |||
if (rowspan > 1) { | if (rowspan > 1) { | ||
for (var i = 0; i < rowspan; i++) { | for (var i = 0; i < rowspan; i++) { | ||
| Строка 462: | Строка 478: | ||
} | } | ||
} | } | ||
// Восстанавливаем стили в текущем ряду | |||
cells.forEach(function(innerCell, innerIndex) { | cells.forEach(function(innerCell, innerIndex) { | ||
innerCell.style.backgroundColor = originalStyles[rowIndex][innerIndex].backgroundColor; | innerCell.style.backgroundColor = originalStyles[rowIndex][innerIndex].backgroundColor; | ||