mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
N°4619 table-selectable-lines.js : handles better all click types
* Set one click handler instead of two * Remove the now useless test on input:radio in updateLines() * If clicking in a cell that have one input:radio or input:checkbox, and isn't located in the first column : - click on the cell input - don't select the line
This commit is contained in:
@@ -28,12 +28,14 @@ $(document).ready(function () {
|
||||
|
||||
var FIRST_CELL_WITH_INPUT_SELECTOR = 'td:first-child>'+INPUT_SELECTOR;
|
||||
var LINE_WITH_INPUT_IN_FIRST_CELL_SELECTOR = "tbody>tr>"+FIRST_CELL_WITH_INPUT_SELECTOR;
|
||||
var CELLS_WITH_INPUT_SELECTOR = 'td:not(:first-child)>'+INPUT_SELECTOR;
|
||||
var CELLS_WITH_INPUT_SELECTOR = 'td>'+INPUT_SELECTOR;
|
||||
var LINE_WITH_INPUTS_SELECTOR = "tbody>tr>"+CELLS_WITH_INPUT_SELECTOR;
|
||||
|
||||
|
||||
// Handler that will allow to select a radio or checkbox by clicking anywhere in the cell
|
||||
// since 3.0.1 N°4619 we are stopping propagation to prevent selecting the line in such case
|
||||
// Set a click handler on all tables containing inputs
|
||||
// since 3.0.1 N°4619 we are using only one handler for both cases :
|
||||
// - clicking in a cell that is not the first child, and that contains one input:radio or input:checkbox
|
||||
// -
|
||||
$(document).on('click', TABLE_SELECTOR+':has('+LINE_WITH_INPUTS_SELECTOR+')', function (event) {
|
||||
var $eventTarget = $(event.target);
|
||||
if (shouldExitHandler($eventTarget)) {
|
||||
@@ -46,17 +48,10 @@ $(document).ready(function () {
|
||||
&& ($cellClickedInput.is("input:radio") || $cellClickedInput.is("input:checkbox"))
|
||||
) {
|
||||
$cellClickedInput.click();
|
||||
$eventTarget.stopPropagation();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Tables with one input in the first cell to select lines
|
||||
// When clicking anywhere in the line (but on certain specific markup) we will click on the radio/checkbox input in the first cell
|
||||
$(document).on('click', TABLE_SELECTOR+':has('+LINE_WITH_INPUT_IN_FIRST_CELL_SELECTOR+')', function (event) {
|
||||
var $eventTarget = $(event.target);
|
||||
if (shouldExitHandler($eventTarget)) {
|
||||
return;
|
||||
if ($cellClicked.not(":first-child")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var $lineClicked = $eventTarget.closest("tr");
|
||||
@@ -127,16 +122,13 @@ $(document).ready(function () {
|
||||
|
||||
|
||||
function updateLines($inputChanged) {
|
||||
var $selectedCell = $inputChanged.closest("td");
|
||||
if (false === $selectedCell.is("tr>td:first-child")) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $selectedLine = $inputChanged.closest("tr");
|
||||
|
||||
// didn't find a proper event fired when radio is deselected... so doing this !
|
||||
if ($inputChanged.is('input:radio'))
|
||||
{
|
||||
$selectedLine
|
||||
.closest('table')
|
||||
.find('tr')
|
||||
.removeClass(SELECTED_CLASS);
|
||||
}
|
||||
if($inputChanged.prop('checked')) {
|
||||
$selectedLine.addClass(SELECTED_CLASS);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user