-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcopy.js
39 lines (32 loc) · 896 Bytes
/
copy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* @file
* Attaches behaviors for the Media URL module.
*/
(function ($) {
Drupal.behaviors.mediaUrlCopy = {
attach: function (context) {
$('#edit-media-url-copy').click(function(event) {
event.preventDefault();
copyToClipboard();
});
$('#edit-media-url-encode').click(function(event) {
var input = $('#edit-media-url-uri');
if(input.hasClass('encoded')) {
decoded = decodeURIComponent(input.val());
input.val(decoded);
input.removeClass('encoded');
} else {
encoded = encodeURIComponent(input.val());
input.val(encoded);
input.addClass('encoded');
}
});
// Copy text to the Clipboard function
function copyToClipboard()
{
var input = document.getElementById('edit-media-url-uri');
window.prompt("Copy to clipboard: Ctrl+C, Enter", input.value);
}
}
};
})(jQuery);