Added visual feedback after copy information into clipboard
* Added visual feedback to inform the user that information is already copied * Change the image to a check-mark temporarily Signed-off-by: Darshan-upadhyay1110 <darshan.upadhyay@collabora.com> Change-Id: I41debc2421841e4f2235f2d31c49d3687a096339pull/6980/head
parent
2ac7183e44
commit
16bb328456
|
@ -0,0 +1,5 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-clipboard-check" viewBox="0 0 16 16">
|
||||
<path fill-rule="evenodd" d="M10.854 7.146a.5.5 0 0 1 0 .708l-3 3a.5.5 0 0 1-.708 0l-1.5-1.5a.5.5 0 1 1 .708-.708L7.5 9.793l2.646-2.647a.5.5 0 0 1 .708 0z"/>
|
||||
<path d="M4 1.5H3a2 2 0 0 0-2 2V14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V3.5a2 2 0 0 0-2-2h-1v1h1a1 1 0 0 1 1 1V14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3.5a1 1 0 0 1 1-1h1v-1z"/>
|
||||
<path d="M9.5 1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-1a.5.5 0 0 1 .5-.5h3zm-3-1A1.5 1.5 0 0 0 5 1.5v1A1.5 1.5 0 0 0 6.5 4h3A1.5 1.5 0 0 0 11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 662 B |
|
@ -475,6 +475,7 @@ L.Control.JSDialog = L.Control.extend({
|
|||
instance.callback = e.callback;
|
||||
instance.isSnackbar = e.data.type === 'snackbar';
|
||||
instance.isModalPopUp = e.data.type === 'modalpopup';
|
||||
instance.snackbarTimeout = e.data.timeout || this.options.snackbarTimeout;
|
||||
instance.isOnlyChild = false;
|
||||
instance.that = this;
|
||||
instance.startX = e.data.posx;
|
||||
|
@ -555,7 +556,7 @@ L.Control.JSDialog = L.Control.extend({
|
|||
this.dialogs[instance.id] = instance;
|
||||
|
||||
if (instance.isSnackbar) {
|
||||
setTimeout(function () { instance.that.closePopover(instance.id, false); }, this.options.snackbarTimeout);
|
||||
setTimeout(function () { instance.that.closePopover(instance.id, false); }, instance.snackbarTimeout);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -557,7 +557,7 @@ L.Control.MobileWizardWindow = L.Control.extend({
|
|||
if (data.type === 'snackbar') {
|
||||
var that = this;
|
||||
this.isSnackBar = true;
|
||||
this.snackBarTimout = setTimeout(function () { that.parent.removeWindow(that); }, this.options.snackbarTimeout);
|
||||
this.snackBarTimout = setTimeout(function () { that.parent.removeWindow(that); }, data.timeout ? data.timeout : this.options.snackbarTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -879,7 +879,7 @@ L.Control.UIManager = L.Control.extend({
|
|||
|
||||
// Snack bar
|
||||
|
||||
showSnackbar: function(label, action, callback) {
|
||||
showSnackbar: function(label, action, callback, timeout) {
|
||||
if (!app.socket)
|
||||
return;
|
||||
|
||||
|
@ -896,6 +896,7 @@ L.Control.UIManager = L.Control.extend({
|
|||
id: 'snackbar',
|
||||
jsontype: 'dialog',
|
||||
type: 'snackbar',
|
||||
timeout: timeout,
|
||||
children: [
|
||||
{
|
||||
type: 'container',
|
||||
|
|
|
@ -698,7 +698,8 @@ L.Map.include({
|
|||
navigator.clipboard.writeText(text)
|
||||
.then(function() {
|
||||
window.console.log('Text copied to clipboard');
|
||||
})
|
||||
this.contentHasBeenCopiedShowSnackbar();
|
||||
}.bind(this))
|
||||
.catch(function(error) {
|
||||
window.console.error('Error copying text to clipboard:', error);
|
||||
});
|
||||
|
@ -712,6 +713,7 @@ L.Map.include({
|
|||
try {
|
||||
document.execCommand('copy');
|
||||
window.console.log('Text copied to clipboard');
|
||||
this.contentHasBeenCopiedShowSnackbar();
|
||||
} catch (error) {
|
||||
window.console.error('Error copying text to clipboard:', error);
|
||||
} finally {
|
||||
|
@ -720,6 +722,16 @@ L.Map.include({
|
|||
}
|
||||
},
|
||||
|
||||
contentHasBeenCopiedShowSnackbar: function() {
|
||||
var timeout = 1000;
|
||||
this.uiManager.showSnackbar('Version information has been copied', null, null, timeout);
|
||||
var copybutton = document.querySelector('#modal-dialog-about-dialog-box-copybutton > img');
|
||||
L.LOUtil.setImage(copybutton, 'lc_clipboard-check.svg', this._docLayer._docType);
|
||||
setTimeout(function () {
|
||||
L.LOUtil.setImage(copybutton, 'lc_copy.svg', this._docLayer._docType);
|
||||
}.bind(this), timeout);
|
||||
},
|
||||
|
||||
extractContent: function(html) {
|
||||
var parser = new DOMParser;
|
||||
return parser.parseFromString(html, 'text/html').documentElement.getElementsByTagName('body')[0].textContent;
|
||||
|
|
Loading…
Reference in New Issue