Skip to content

Commit b1fac59

Browse files
committed
Add clipboard action to Personal Settings Fed Cloud Id
1 parent 3a26def commit b1fac59

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

apps/federatedfilesharing/css/settings-personal.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
white-space: pre-wrap;
88
}
99

10+
#fileSharingSettings .icon {
11+
background-size: 16px 16px;
12+
display: inline-block;
13+
}
14+
1015
[class^="social-"], [class*=" social-"] {
1116
background-repeat: no-repeat;
1217
background-position: 2px;

apps/federatedfilesharing/js/settings-personal.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,35 @@ $(document).ready(function() {
1616
$('#oca-files-sharing-add-to-your-website-expanded').slideDown();
1717
});
1818

19+
// Clipboard!
20+
var clipboard = new Clipboard('.clipboardButton');
21+
clipboard.on('success', function(e) {
22+
$input = $(e.trigger);
23+
$input.tooltip({placement: 'bottom', trigger: 'manual', title: t('core', 'Copied!')});
24+
$input.tooltip('show');
25+
_.delay(function() {
26+
$input.tooltip('hide');
27+
}, 3000);
28+
});
29+
clipboard.on('error', function (e) {
30+
$input = $(e.trigger);
31+
var actionMsg = '';
32+
if (/iPhone|iPad/i.test(navigator.userAgent)) {
33+
actionMsg = t('core', 'Not supported!');
34+
} else if (/Mac/i.test(navigator.userAgent)) {
35+
actionMsg = t('core', 'Press ⌘-C to copy.');
36+
} else {
37+
actionMsg = t('core', 'Press Ctrl-C to copy.');
38+
}
39+
40+
$input.tooltip({
41+
placement: 'bottom',
42+
trigger: 'manual',
43+
title: actionMsg
44+
});
45+
$input.tooltip('show');
46+
_.delay(function () {
47+
$input.tooltip('hide');
48+
}, 3000);
49+
});
1950
});

apps/federatedfilesharing/templates/settings-personal.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515

1616
<p>
1717
<?php p($l->t('Your Federated Cloud ID:')); ?>
18-
<strong><?php p($_['cloudId']); ?></strong>
18+
<strong id="cloudid"><?php p($_['cloudId']); ?></strong>
19+
<a class="clipboardButton icon icon-clippy" data-clipboard-target="#cloudid"></a>
1920
</p>
2021

2122
<br>

0 commit comments

Comments
 (0)