Refactor multiSelect and highlight

refs #6705
This commit is contained in:
Alexander Fuhr 2014-08-19 18:33:28 +02:00
parent 6fe47bf5b0
commit ba748cbc4a
3 changed files with 21 additions and 9 deletions

View File

@ -109,7 +109,7 @@ if ($hosts->count() === 0) {
<?php endif; ?> <?php endif; ?>
<?= implode(' ', $icons) ?> <?= implode(' ', $icons) ?>
<?php endif ?> <?php endif ?>
<a class="select-click" href="<?= $this->compact ? $hostLink : $this->href( <a href="<?= $this->compact ? $hostLink : $this->href(
'monitoring/show/host', 'monitoring/show/host',
array('host' => $host->host_name) array('host' => $host->host_name)
) ?>"><?= $host->host_name ?></a> ) ?>"><?= $host->host_name ?></a>

View File

@ -99,7 +99,7 @@ foreach ($services as $service):
<?php if ($service->service_icon_image && ! preg_match('/[\'"]/', $service->service_icon_image)): ?> <?php if ($service->service_icon_image && ! preg_match('/[\'"]/', $service->service_icon_image)): ?>
<?= $this->icon($this->resolveMacros($service->service_icon_image, $service)) ?> <?= $this->icon($this->resolveMacros($service->service_icon_image, $service)) ?>
<?php endif ?> <?php endif ?>
<a class="select-click" href="<?= $serviceLink ?>"><?= $service->service_display_name ?></a><?php if ($this->showHost): ?> on <a href="<?= $hostLink ?>"><?= $service->host_name; ?> <a href="<?= $serviceLink ?>"><?= $service->service_display_name ?></a><?php if ($this->showHost): ?> on <a href="<?= $hostLink ?>"><?= $service->host_name; ?>
<?php if ($service->host_state != 0): ?> <?php if ($service->host_state != 0): ?>
(<?= ucfirst($helper->monitoringState($service, 'host')); ?>) (<?= ucfirst($helper->monitoringState($service, 'host')); ?>)
<?php endif ?> <?php endif ?>

View File

@ -134,7 +134,6 @@
// Select a table row // Select a table row
$(document).on('click', 'table.multiselect tr[href]', { self: this }, this.rowSelected); $(document).on('click', 'table.multiselect tr[href]', { self: this }, this.rowSelected);
$(document).on('click', 'table.multiselect .select-click', { self: this }, this.rowSelected);
$(document).on('click', 'button', { self: this }, this.submitForm); $(document).on('click', 'button', { self: this }, this.submitForm);
@ -475,14 +474,22 @@
return true; return true;
} }
// Ignore clicks on multiselect table inner links while key pressed // Special checks for link clicks in multiselect rows
if ((event.ctrlKey || event.metaKey || event.shiftKey) && if (! $a.is('tr[href]') && $a.closest('tr[href]').length > 0 && $a.closest('table.multiselect').length > 0) {
! $a.is('tr[href]') && $a.closest('table.multiselect').length > 0 &&
$a.closest('tr[href]').length > 0) // Forward clicks to ANY link with special key pressed to rowSelected
if (event.ctrlKey || event.metaKey || event.shiftKey)
{ {
return self.rowSelected.call($a.closest('tr[href]'), event); return self.rowSelected.call($a.closest('tr[href]'), event);
} }
// Forward inner links matching the row URL to rowSelected
if ($a.attr('href') === $a.closest('tr[href]').attr('href'))
{
return self.rowSelected.call($a.closest('tr[href]'), event);
}
}
// Let remote links pass through // Let remote links pass through
if (href.match(remote)) { if (href.match(remote)) {
return true; return true;
@ -494,6 +501,11 @@
return false; return false;
} }
// ignore multiselect table row clicks
if ($a.closest('tr[href]').length > 0 && $a.closest('table.action').length > 0) {
return;
}
// ignore multiselect table row clicks // ignore multiselect table row clicks
if ($a.is('tr') && $a.closest('table.multiselect').length > 0) { if ($a.is('tr') && $a.closest('table.multiselect').length > 0) {
return; return;