mirror of
https://github.com/wekan/wekan.git
synced 2026-01-03 16:18:49 +01:00
Moved "copied!" code to Utils
- same implementation in all files, so it's better to have one function for it
This commit is contained in:
parent
6d3ecdea55
commit
7444c11c82
3 changed files with 24 additions and 23 deletions
|
|
@ -326,13 +326,9 @@ BlazeComponent.extendComponent({
|
||||||
'click .js-copy-link'(event) {
|
'click .js-copy-link'(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const promise = Utils.copyTextToClipboard(event.target.href);
|
const promise = Utils.copyTextToClipboard(event.target.href);
|
||||||
if (promise) {
|
|
||||||
promise.then(() => {
|
const $tooltip = this.$('.copied-tooltip');
|
||||||
const $tooltip = this.$('span.copied-tooltip');
|
Utils.showCopied(promise, $tooltip);
|
||||||
$tooltip.show(100);
|
|
||||||
setTimeout(() => $tooltip.hide(100), 1000);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
'click .js-open-card-details-menu': Popup.open('cardDetailsActions'),
|
'click .js-open-card-details-menu': Popup.open('cardDetailsActions'),
|
||||||
'submit .js-card-description'(event) {
|
'submit .js-card-description'(event) {
|
||||||
|
|
@ -1076,13 +1072,9 @@ BlazeComponent.extendComponent({
|
||||||
{
|
{
|
||||||
'click .js-copy-card-link-to-clipboard'(event) {
|
'click .js-copy-card-link-to-clipboard'(event) {
|
||||||
const promise = Utils.copyTextToClipboard(location.origin + document.getElementById('cardURL').value);
|
const promise = Utils.copyTextToClipboard(location.origin + document.getElementById('cardURL').value);
|
||||||
if (promise) {
|
|
||||||
promise.then(() => {
|
const $tooltip = this.$('.copied-tooltip');
|
||||||
const $tooltip = this.$('.copied-tooltip');
|
Utils.showCopied(promise, $tooltip);
|
||||||
$tooltip.show(100);
|
|
||||||
setTimeout(() => $tooltip.hide(100), 1000);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
'click .js-delete': Popup.afterConfirm('cardDelete', function () {
|
'click .js-delete': Popup.afterConfirm('cardDelete', function () {
|
||||||
Popup.close();
|
Popup.close();
|
||||||
|
|
|
||||||
|
|
@ -289,15 +289,9 @@ BlazeComponent.extendComponent({
|
||||||
'click a.fa.fa-copy'(event) {
|
'click a.fa.fa-copy'(event) {
|
||||||
const $editor = this.$('textarea.editor');
|
const $editor = this.$('textarea.editor');
|
||||||
const promise = Utils.copyTextToClipboard($editor[0].value);
|
const promise = Utils.copyTextToClipboard($editor[0].value);
|
||||||
if (promise) {
|
|
||||||
promise.then(() => {
|
const $tooltip = this.$('.copied-tooltip');
|
||||||
const $tooltip = this.$('.copied-tooltip');
|
Utils.showCopied(promise, $tooltip);
|
||||||
$tooltip.show(100);
|
|
||||||
setTimeout(() => $tooltip.hide(100), 1000);
|
|
||||||
}, (err) => {
|
|
||||||
console.error("error: ", err);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -506,6 +506,21 @@ Utils = {
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** show the "copied!" message
|
||||||
|
* @param promise the promise of Utils.copyTextToClipboard
|
||||||
|
* @param $tooltip jQuery tooltip element
|
||||||
|
*/
|
||||||
|
showCopied(promise, $tooltip) {
|
||||||
|
if (promise) {
|
||||||
|
promise.then(() => {
|
||||||
|
$tooltip.show(100);
|
||||||
|
setTimeout(() => $tooltip.hide(100), 1000);
|
||||||
|
}, (err) => {
|
||||||
|
console.error("error: ", err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// A simple tracker dependency that we invalidate every time the window is
|
// A simple tracker dependency that we invalidate every time the window is
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue