Skip to content

Commit

Permalink
Refactor multiSelect and highlight
Browse files Browse the repository at this point in the history
refs #6705
  • Loading branch information
Alexander Fuhr committed Aug 19, 2014
1 parent 6fe47bf commit ba748cb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
Expand Up @@ -109,7 +109,7 @@ if ($hosts->count() === 0) {
<?php endif; ?>
<?= implode(' ', $icons) ?>
<?php endif ?>
<a class="select-click" href="<?= $this->compact ? $hostLink : $this->href(
<a href="<?= $this->compact ? $hostLink : $this->href(
'monitoring/show/host',
array('host' => $host->host_name)
) ?>"><?= $host->host_name ?></a>
Expand Down
Expand Up @@ -99,7 +99,7 @@ foreach ($services as $service):
<?php if ($service->service_icon_image && ! preg_match('/[\'"]/', $service->service_icon_image)): ?>
<?= $this->icon($this->resolveMacros($service->service_icon_image, $service)) ?>
<?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): ?>
(<?= ucfirst($helper->monitoringState($service, 'host')); ?>)
<?php endif ?>
Expand Down
26 changes: 19 additions & 7 deletions public/js/icinga/events.js
Expand Up @@ -134,7 +134,6 @@

// Select a table row
$(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);

Expand Down Expand Up @@ -475,12 +474,20 @@
return true;
}

// Ignore clicks on multiselect table inner links while key pressed
if ((event.ctrlKey || event.metaKey || event.shiftKey) &&
! $a.is('tr[href]') && $a.closest('table.multiselect').length > 0 &&
$a.closest('tr[href]').length > 0)
{
return self.rowSelected.call($a.closest('tr[href]'), event);
// Special checks for link clicks in multiselect rows
if (! $a.is('tr[href]') && $a.closest('tr[href]').length > 0 && $a.closest('table.multiselect').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);
}

// 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
Expand All @@ -494,6 +501,11 @@
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
if ($a.is('tr') && $a.closest('table.multiselect').length > 0) {
return;
Expand Down

0 comments on commit ba748cb

Please sign in to comment.