Merge pull request #7036 from JakubOnderka/event-tooltips

Event tooltips
pull/7848/head
Jakub Onderka 2021-10-16 09:34:11 +02:00 committed by GitHub
commit e734349f85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 7 deletions

View File

@ -64,7 +64,7 @@
);
if (!empty($tag['Tag']['id'])) {
$span_tag = sprintf(
'<a href="%s" style="%s" class="%s" title="%s" data-tag-id="%s">%s</a>',
'<a href="%s" style="%s" class="%s"%s data-tag-id="%s">%s</a>',
sprintf(
'%s%s%s',
$baseurl,
@ -73,7 +73,7 @@
),
$aStyle,
$aClass,
$aText,
isset($aTextModified) ? ' title="' . $aText . '"' : '',
h($tag['Tag']['id']),
isset($aTextModified) ? $aTextModified : $aText
);

View File

@ -574,10 +574,13 @@ $(function () {
queryEventLock('<?= h($event['Event']['id']); ?>', <?= (int)$event['Event']['timestamp'] ?>);
popoverStartup();
$("th, td, dt, div, span, li").tooltip({
'placement': 'top',
'container' : 'body',
$(document.body).tooltip({
selector: 'span[title], td[title], time[title]',
placement: 'top',
container: 'body',
delay: { show: 500, hide: 100 }
}).on('shown', function() {
$('.tooltip').not(":last").remove();
});
$.get("<?php echo $baseurl; ?>/threads/view/<?php echo h($event['Event']['id']); ?>/true", function(data) {

View File

@ -3,6 +3,10 @@ App::uses('AppHelper', 'View/Helper');
class TimeHelper extends AppHelper
{
/**
* @param string|int $time
* @return string
*/
public function time($time)
{
if (empty($time)) {
@ -10,9 +14,16 @@ class TimeHelper extends AppHelper
}
if (is_numeric($time)) {
$time = date('Y-m-d H:i:s', $time);
} else if (is_string($time)) { // time string with timezone
$timezonePosition = strpos($time, '+00:00'); // first and last seen format
if ($timezonePosition === false) {
$timezonePosition = strpos($time, '+0000'); // datetime attribute format
}
if ($timezonePosition !== false) {
return '<time title="' . __('In UTC') . '">' . h(substr($time, 0, $timezonePosition)) . '</time>';
}
}
$time = h($time);
return '<time>' . $time . '</time>';
return '<time>' . h($time) . '</time>';
}
}