From 23917010a778e8464ba8b5f080d3306fc28a489e Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 19 Apr 2018 08:00:54 -0400 Subject: [PATCH] psss doc to copy function --- .../components/password-generator-history.component.ts | 5 +++-- src/angular/components/password-generator.component.ts | 5 +++-- src/angular/components/view.component.ts | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/angular/components/password-generator-history.component.ts b/src/angular/components/password-generator-history.component.ts index fd2a7dc372e..a94f780a060 100644 --- a/src/angular/components/password-generator-history.component.ts +++ b/src/angular/components/password-generator-history.component.ts @@ -14,7 +14,7 @@ export class PasswordGeneratorHistoryComponent implements OnInit { constructor(protected passwordGenerationService: PasswordGenerationService, protected analytics: Angulartics2, protected platformUtilsService: PlatformUtilsService, protected i18nService: I18nService, - protected toasterService: ToasterService) { } + protected toasterService: ToasterService, private win: Window) { } async ngOnInit() { this.history = await this.passwordGenerationService.getHistory(); @@ -27,7 +27,8 @@ export class PasswordGeneratorHistoryComponent implements OnInit { copy(password: string) { this.analytics.eventTrack.next({ action: 'Copied Historical Password' }); - this.platformUtilsService.copyToClipboard(password); + const copyOptions = this.win != null ? { doc: this.win.document } : null; + this.platformUtilsService.copyToClipboard(password, copyOptions); this.toasterService.popAsync('info', null, this.i18nService.t('valueCopied', this.i18nService.t('password'))); } } diff --git a/src/angular/components/password-generator.component.ts b/src/angular/components/password-generator.component.ts index 7ca52070e07..e4a35c84455 100644 --- a/src/angular/components/password-generator.component.ts +++ b/src/angular/components/password-generator.component.ts @@ -23,7 +23,7 @@ export class PasswordGeneratorComponent implements OnInit { constructor(protected passwordGenerationService: PasswordGenerationService, protected analytics: Angulartics2, protected platformUtilsService: PlatformUtilsService, protected i18nService: I18nService, - protected toasterService: ToasterService) { } + protected toasterService: ToasterService, private win: Window) { } async ngOnInit() { this.options = await this.passwordGenerationService.getOptions(); @@ -61,7 +61,8 @@ export class PasswordGeneratorComponent implements OnInit { copy() { this.analytics.eventTrack.next({ action: 'Copied Generated Password' }); - this.platformUtilsService.copyToClipboard(this.password); + const copyOptions = this.win != null ? { doc: this.win.document } : null; + this.platformUtilsService.copyToClipboard(this.password, copyOptions); this.toasterService.popAsync('info', null, this.i18nService.t('valueCopied', this.i18nService.t('password'))); } diff --git a/src/angular/components/view.component.ts b/src/angular/components/view.component.ts index da63d5c69fb..4eb02cde784 100644 --- a/src/angular/components/view.component.ts +++ b/src/angular/components/view.component.ts @@ -116,7 +116,8 @@ export class ViewComponent implements OnDestroy { } this.analytics.eventTrack.next({ action: 'Copied ' + aType }); - this.platformUtilsService.copyToClipboard(value); + const copyOptions = this.win != null ? { doc: this.win.document } : null; + this.platformUtilsService.copyToClipboard(value, copyOptions); this.toasterService.popAsync('info', null, this.i18nService.t('valueCopied', this.i18nService.t(typeI18nKey))); }