]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/eg2/src/app/share/clipboard/clipboard-dialog.component.ts
LP2045292 Color contrast for AngularJS patron bills
[Evergreen.git] / Open-ILS / src / eg2 / src / app / share / clipboard / clipboard-dialog.component.ts
1 import {Component, Input, ViewChild, TemplateRef} from '@angular/core';
2 import {DialogComponent} from '@eg/share/dialog/dialog.component';
3
4 interface ClipboardValues {
5     label: string;
6     value: string;
7 }
8
9 @Component({
10   selector: 'eg-clipboard-dialog',
11   templateUrl: './clipboard-dialog.component.html'
12 })
13
14 /**
15  * Copy To Clipboard dialog
16  */
17 export class ClipboardDialogComponent extends DialogComponent {
18
19     @Input() values: ClipboardValues[];
20
21     copyValue(value: string) {
22
23         const node =
24             document.getElementById('clipboard-textarea') as HTMLTextAreaElement;
25
26         // Un-hide the textarea just long enough to copy its data.
27         // Using node.style instead of *ngIf for snappier show/hide.
28         node.style.visibility = 'visible';
29         node.style.display = 'block';
30         node.value = value;
31         node.focus();
32         node.select();
33
34         document.execCommand('copy');
35
36         node.style.visibility = 'hidden';
37         node.style.display = 'none';
38
39         this.close();
40     }
41 }
42
43