summaryrefslogtreecommitdiffstats
path: root/public/js/module.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:46:47 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:46:47 +0000
commit4ada86876033fa171e2896d7e3d3c5645d8062db (patch)
treef0d1fee61877df200ccfb1c0af58a39cd551fb46 /public/js/module.js
parentInitial commit. (diff)
downloadicingaweb2-module-reporting-upstream.tar.xz
icingaweb2-module-reporting-upstream.zip
Adding upstream version 0.10.0.upstream/0.10.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'public/js/module.js')
-rw-r--r--public/js/module.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/public/js/module.js b/public/js/module.js
new file mode 100644
index 0000000..f65a2d9
--- /dev/null
+++ b/public/js/module.js
@@ -0,0 +1,50 @@
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+;(function (Icinga) {
+
+ 'use strict';
+
+ var Reporting = function(module) {
+ this.module = module;
+
+ this.initialize();
+ };
+
+ Reporting.prototype.initialize = function () {
+ if (typeof $().flatpickr === 'function') {
+ this.module.on('rendered', function (event) {
+ var $container = $('<div>');
+ event.target.insertAdjacentElement('beforeend', $container[0]);
+ $('[data-use-flatpickr-fallback]').each(function() {
+ var options = {
+ appendTo: $container[0],
+ dateFormat: 'Y-m-d H:i:S',
+ enableTime: true,
+ enableSeconds: true
+ };
+
+ for (name in this.dataset) {
+ if (name.length > 9 && name.substr(0, 9) === 'flatpickr') {
+ var value = this.dataset[name];
+ if (value === '') {
+ value = true;
+ }
+
+ options[name.charAt(9).toLowerCase() + name.substr(10)] = value;
+ }
+ }
+
+ var element = this;
+ if (!! options.wrap) {
+ element = this.parentNode;
+ }
+
+ $(element).flatpickr(options);
+ });
+ });
+ }
+ };
+
+ Icinga.availableModules.reporting = Reporting;
+
+}(Icinga));