mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-29 08:44:10 +02:00
Javascript: Add copy-to-clipboard
behavior
Utilizes `CopyToClipboard.js` from ipl-web
This commit is contained in:
parent
65b9024bc5
commit
f74041e00a
@ -42,7 +42,8 @@ class JavaScript
|
|||||||
'js/icinga/behavior/selectable.js',
|
'js/icinga/behavior/selectable.js',
|
||||||
'js/icinga/behavior/modal.js',
|
'js/icinga/behavior/modal.js',
|
||||||
'js/icinga/behavior/input-enrichment.js',
|
'js/icinga/behavior/input-enrichment.js',
|
||||||
'js/icinga/behavior/datetime-picker.js'
|
'js/icinga/behavior/datetime-picker.js',
|
||||||
|
'js/icinga/behavior/copy-to-clipboard.js'
|
||||||
];
|
];
|
||||||
|
|
||||||
protected static $vendorFiles = [];
|
protected static $vendorFiles = [];
|
||||||
|
41
public/js/icinga/behavior/copy-to-clipboard.js
Normal file
41
public/js/icinga/behavior/copy-to-clipboard.js
Normal file
@ -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);
|
Loading…
x
Reference in New Issue
Block a user