2015-02-04 10:46:36 +01:00
|
|
|
/*! Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
2014-09-10 10:45:34 +02:00
|
|
|
|
|
|
|
(function(Icinga, $) {
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
Icinga.Behaviors = Icinga.Behaviors || {};
|
|
|
|
|
|
|
|
var Sparkline = function (icinga) {
|
2014-09-12 09:09:21 +02:00
|
|
|
Icinga.EventListener.call(this, icinga);
|
|
|
|
this.on('rendered', this.onRendered, this);
|
2014-09-10 10:45:34 +02:00
|
|
|
};
|
2014-09-12 09:09:21 +02:00
|
|
|
Sparkline.prototype = new Icinga.EventListener();
|
|
|
|
|
|
|
|
Sparkline.prototype.onRendered = function(evt) {
|
|
|
|
var el = evt.target;
|
2014-09-10 10:45:34 +02:00
|
|
|
|
2015-02-03 17:33:30 +01:00
|
|
|
$('.sparkline', el).each(function(i, element) {
|
2014-09-10 10:45:34 +02:00
|
|
|
// read custom options
|
2014-12-23 15:26:45 +01:00
|
|
|
var $spark = $(element);
|
|
|
|
var title = $spark.attr('title');
|
2014-12-18 16:44:55 +01:00
|
|
|
|
|
|
|
if ($spark.attr('labels')) {
|
|
|
|
$spark.removeAttr('original-title');
|
|
|
|
}
|
2014-12-23 15:26:45 +01:00
|
|
|
|
|
|
|
var options;
|
|
|
|
if ($spark.hasClass('sparkline-perfdata')) {
|
|
|
|
options = {
|
|
|
|
enableTagOptions: true,
|
2015-02-03 16:45:01 +01:00
|
|
|
width: 16,
|
|
|
|
height: 16,
|
2014-12-23 15:26:45 +01:00
|
|
|
title: title,
|
2015-02-03 16:45:01 +01:00
|
|
|
disableTooltips: true,
|
|
|
|
borderWidth: 1.4,
|
|
|
|
borderColor: '#FFF'
|
2014-12-23 15:26:45 +01:00
|
|
|
};
|
|
|
|
$spark.sparkline('html', options);
|
|
|
|
} else if ($spark.hasClass('sparkline-multi')) {
|
|
|
|
options = {
|
|
|
|
width: 100,
|
|
|
|
height: 100,
|
|
|
|
title: title,
|
|
|
|
enableTagOptions: true
|
|
|
|
};
|
|
|
|
$spark.sparkline('html', options);
|
|
|
|
}
|
|
|
|
|
2014-09-10 10:45:34 +02:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
Icinga.Behaviors.Sparkline = Sparkline;
|
|
|
|
|
|
|
|
}) (Icinga, jQuery);
|