1
0
Fork 0
mirror of synced 2024-10-03 19:53:33 +13:00
appwrite/public/scripts/views/forms/copy.js

41 lines
1.3 KiB
JavaScript
Raw Normal View History

2019-05-09 18:54:39 +12:00
(function (window) {
"use strict";
2019-05-09 20:01:51 +12:00
window.ls.container.get('view').add(
2019-05-09 18:54:39 +12:00
{
selector: 'data-forms-copy',
controller: function(element, alerts, document, window) {
var button = window.document.createElement('i');
button.type = 'button';
button.className = 'icon-docs note copy';
button.style.cursor = 'pointer';
element.parentNode.insertBefore(button, element.nextSibling);
var copy = function(event) {
2019-09-11 06:13:19 +12:00
element.disabled = false;
element.focus();
element.select();
document.execCommand('Copy');
if (document.selection) {
document.selection.empty();
}
else if (window.getSelection) {
window.getSelection().removeAllRanges();
2019-05-09 18:54:39 +12:00
}
2019-09-11 06:13:19 +12:00
element.disabled = true;
alerts.add({text: 'Copied to clipboard', class: ''}, 3000);
2019-05-09 18:54:39 +12:00
};
button.addEventListener('click', copy);
}
}
);
})(window);