diff options
author | Patrik Kernstock <info@pkern.at> | 2018-07-19 00:05:36 +0300 |
---|---|---|
committer | Patrik Kernstock <info@pkern.at> | 2018-07-19 00:05:36 +0300 |
commit | 8ab6157f9c239f95196a082eab258e0bf99f17f5 (patch) | |
tree | d919b5d6f62419a232832bd10ef30f79229266f4 /js | |
parent | 0752b4d29ad86c9a68bb29f00053147bfd27fa0f (diff) |
Added clipboard copy button for endpoint link
Signed-off-by: Patrik Kernstock <info@pkern.at>
Diffstat (limited to 'js')
-rw-r--r-- | js/script.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/js/script.js b/js/script.js index 24f6d08..9acf393 100644 --- a/js/script.js +++ b/js/script.js @@ -37,6 +37,7 @@ setHumanReadableSizeToElement("dataBaseSize"); setHumanReadableSizeToElement("phpUploadMaxSize"); + initMonitoringLinkToClipboard(); $("#monitoring-endpoint-url").on('click', function() { $(this).select(); }); @@ -250,4 +251,48 @@ mem_canvas.height = newHeight; } + function initMonitoringLinkToClipboard() { + var monAPIBox = $("#ocsEndPoint"); + /* reused from settings/js/authtoken_view.js */ + monAPIBox.find('.clipboardButton').tooltip({placement: 'bottom', title: t('core', 'Copy'), trigger: 'hover'}); + + // Clipboard! + var clipboard = new Clipboard('.clipboardButton'); + clipboard.on('success', function(e) { + var $input = $(e.trigger); + $input.tooltip('hide') + .attr('data-original-title', t('core', 'Copied!')) + .tooltip('fixTitle') + .tooltip({placement: 'bottom', trigger: 'manual'}) + .tooltip('show'); + _.delay(function() { + $input.tooltip('hide') + .attr('data-original-title', t('core', 'Copy')) + .tooltip('fixTitle'); + }, 3000); + }); + clipboard.on('error', function (e) { + var $input = $(e.trigger); + var actionMsg = ''; + if (/iPhone|iPad/i.test(navigator.userAgent)) { + actionMsg = t('core', 'Not supported!'); + } else if (/Mac/i.test(navigator.userAgent)) { + actionMsg = t('core', 'Press ⌘-C to copy.'); + } else { + actionMsg = t('core', 'Press Ctrl-C to copy.'); + } + + $input.tooltip('hide') + .attr('data-original-title', actionMsg) + .tooltip('fixTitle') + .tooltip({placement: 'bottom', trigger: 'manual'}) + .tooltip('show'); + _.delay(function () { + $input.tooltip('hide') + .attr('data-original-title', t('core', 'Copy')) + .tooltip('fixTitle'); + }, 3000); + }); + } + })(jQuery, OC); |