Skip to content
Snippets Groups Projects
Commit bcf867be authored by André Holger Hanke's avatar André Holger Hanke
Browse files

set inital focus to cookie dialog

parent d5efcbce
Branches
Tags
No related merge requests found
......@@ -8,7 +8,7 @@
</div>
<mat-divider></mat-divider>
<mat-dialog-content tabindex="0">
<mat-dialog-content tabindex="-1">
<app-cookies-de *ngIf="currentLang=='de'"></app-cookies-de>
<app-cookies-en *ngIf="currentLang=='en'"></app-cookies-en>
......
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { DataProtectionComponent } from '../data-protection/data-protection.component';
import { MatDialog, MatDialogRef } from '@angular/material';
import { DialogConfirmActionButtonType } from '../../../shared/dialog/dialog-action-buttons/dialog-action-buttons.component';
......@@ -8,7 +8,7 @@ import { DialogConfirmActionButtonType } from '../../../shared/dialog/dialog-act
templateUrl: './cookies.component.html',
styleUrls: ['./cookies.component.scss']
})
export class CookiesComponent implements OnInit {
export class CookiesComponent implements OnInit, AfterViewInit {
@ViewChild('header')
dialogTitle: ElementRef;
......@@ -18,21 +18,28 @@ export class CookiesComponent implements OnInit {
confirmButtonType: DialogConfirmActionButtonType = DialogConfirmActionButtonType.Primary;
constructor(private dialog: MatDialog, private dialogRef: MatDialogRef<CookiesComponent>) {
constructor(private dialog: MatDialog, private dialogRef: MatDialogRef<CookiesComponent>, private ref: ElementRef) {
}
ngOnInit() {
this.currentLang = localStorage.getItem('currentLang');
// not really the nicest way but should do its job until a better or native solution was found
setTimeout(() => document.getElementById('cookie-header').focus(), 400);
}
ngAfterViewInit() {
setTimeout(() => {
(<HTMLElement>(<HTMLElement>this.ref.nativeElement).getElementsByClassName('mat-dialog-title')[0]).focus();
}, 500);
}
acceptCookies() {
localStorage.setItem('cookieAccepted', 'true');
localStorage.setItem('dataProtectionConsent', 'true');
this.dialogRef.close(true);
setTimeout( () => {
setTimeout(() => {
document.getElementById('live_announcer-button').focus();
}, 500);
}
......@@ -44,10 +51,10 @@ export class CookiesComponent implements OnInit {
}
openDataProtection() {
const dialogRef = this.dialog.open(DataProtectionComponent, {
width: '90%'
});
dialogRef.componentInstance.deviceType = this.deviceType;
const dialogRef = this.dialog.open(DataProtectionComponent, {
width: '90%'
});
dialogRef.componentInstance.deviceType = this.deviceType;
}
/**
......
<p>
<p tabindex="0">
Deine Fragen und Bewertungen sind anonym.
Ein »frag.jetzt«-Konto ist nur erforderlich,
wenn du als Dozent deine Sitzung für 180 Tage nach dem letzten Besuch speichern willst.
</p>
<p>
Mit Anklicken des Buttons »Akzeptieren« erklärst du dich mit der Verwendung der
<a href="https://de.wikipedia.org/wiki/Web_Storage" target="_blank" rel="noreferrer">Web-Storage-Technik</a>
<a href="https://de.wikipedia.org/wiki/Web_Storage" target="_blank" rel="noreferrer" tabindex="-1">Web-Storage-Technik</a>
und unserer Daten&shy;schutz&shy;erklärung einverstanden.
Diese kannst du über das Datenschutz-Symbol einsehen.
</p>
<p>
<p tabindex="0">
Your questions and votes are anonymous.
A »frag.&shy;jetzt« account is only required,
if you as a lecturer want to save your session for 180 days after the last visit.
</p>
<p>
<p tabindex="0">
By clicking the button »Accept« you agree to the use of a
<a href="https://en.wikipedia.org/wiki/Web_storage" target="_blank" rel="noreferrer">web storage</a>
<a href="https://en.wikipedia.org/wiki/Web_storage" target="_blank" rel="noreferrer" tabindex="-1">web storage</a>
and our privacy policy.
You can view our policy by clicking on the data protection symbol above.
</p>
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment