1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
<?php
/*
** Zabbix
** Copyright (C) 2001-2014 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
class CSeverity extends CTag {
/**
* @param string $options['id']
* @param string $options['name']
* @param int $options['value']
*/
public function __construct(array $options = array()) {
parent::__construct('div', 'yes');
$this->attr('id', isset($options['id']) ? $options['id'] : zbx_formatDomId($options['name']));
$this->addClass('jqueryinputset control-severity');
if (!isset($options['value'])) {
$options['value'] = TRIGGER_SEVERITY_NOT_CLASSIFIED;
}
$items = array();
$jsIds = '';
$jsLabels = '';
foreach (getSeverityCaption() as $severity => $caption) {
$items[] = new CRadioButton(
$options['name'],
$severity,
null,
$options['name'].'_'.$severity,
($options['value'] == $severity)
);
$css = getSeverityStyle($severity);
$label = new CLabel($caption, $options['name'].'_'.$severity, $options['name'].'_label_'.$severity);
$label->attr('data-severity', $severity);
$label->attr('data-severity-style', $css);
if ($options['value'] == $severity) {
$label->attr('aria-pressed', 'true');
$label->addClass($css);
}
else {
$label->attr('aria-pressed', 'false');
}
$items[] = $label;
$jsIds .= ', #'.$options['name'].'_'.$severity;
$jsLabels .= ', #'.$options['name'].'_label_'.$severity;
}
if ($jsIds) {
$jsIds = substr($jsIds, 2);
$jsLabels = substr($jsLabels, 2);
}
$this->addItem($items);
insert_js('
jQuery("'.$jsLabels.'").mouseenter(function() {
jQuery("'.$jsLabels.'").each(function() {
var obj = jQuery(this);
if (obj.attr("aria-pressed") == "false") {
obj.removeClass("ui-state-hover " + obj.data("severityStyle"));
}
});
var obj = jQuery(this);
obj.addClass(obj.data("severityStyle"));
})
.mouseleave(function() {
jQuery("#'.$this->getAttribute('id').' [aria-pressed=\"true\"]").trigger("mouseenter");
});
jQuery("'.$jsIds.'").change(function() {
jQuery("#'.$this->getAttribute('id').' [aria-pressed=\"true\"]").trigger("mouseenter");
});'
, true);
}
}
|