diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 11:46:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 11:46:43 +0000 |
commit | 3e02d5aff85babc3ffbfcf52313f2108e313aa23 (patch) | |
tree | b01f3923360c20a6a504aff42d45670c58af3ec5 /public/js/icinga/behavior/copy-to-clipboard.js | |
parent | Initial commit. (diff) | |
download | icingaweb2-upstream.tar.xz icingaweb2-upstream.zip |
Adding upstream version 2.12.1.upstream/2.12.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'public/js/icinga/behavior/copy-to-clipboard.js')
-rw-r--r-- | public/js/icinga/behavior/copy-to-clipboard.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/public/js/icinga/behavior/copy-to-clipboard.js b/public/js/icinga/behavior/copy-to-clipboard.js new file mode 100644 index 0000000..cdd2615 --- /dev/null +++ b/public/js/icinga/behavior/copy-to-clipboard.js @@ -0,0 +1,41 @@ +(function (Icinga) { + + "use strict"; + + try { + var CopyToClipboard = require('icinga/icinga-php-library/widget/CopyToClipboard'); + } catch (e) { + console.warn('Unable to provide copy to clipboard feature. Libraries not available:', e); + return; + } + + class CopyToClipboardBehavior extends Icinga.EventListener { + constructor(icinga) + { + super(icinga); + + this.on('rendered', '#main > .container', this.onRendered, this); + + /** + * Clipboard buttons + * + * @type {WeakMap<object, CopyToClipboard>} + * @private + */ + this._clipboards = new WeakMap(); + } + + onRendered(event) + { + let _this = event.data.self; + + event.currentTarget.querySelectorAll('[data-icinga-clipboard]').forEach(button => { + _this._clipboards.set(button, new CopyToClipboard(button)); + }); + } + } + + Icinga.Behaviors = Icinga.Behaviors || {}; + + Icinga.Behaviors.CopyToClipboardBehavior = CopyToClipboardBehavior; +})(Icinga); |