From bac013f67bfbd5ce48e0477741ef2eb340c181df Mon Sep 17 00:00:00 2001 From: Patrizio Bekerle <patrizio.bekerle@tugraz.at> Date: Tue, 17 May 2022 11:07:53 +0200 Subject: [PATCH] Set attribute to signal that the login page was loaded --- package.json | 2 +- src/ext-sign-iframe.js | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3c58317..986bde1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@dbp-topics/signature", "internalName": "dbp-signature", - "version": "2.1.2", + "version": "2.1.3", "main": "src/dbp-signature.js", "license": "LGPL-2.1-or-later", "repository": { diff --git a/src/ext-sign-iframe.js b/src/ext-sign-iframe.js index a8bb341..5ae5e2d 100644 --- a/src/ext-sign-iframe.js +++ b/src/ext-sign-iframe.js @@ -14,6 +14,8 @@ export class ExternalSignIFrame extends ScopedElementsMixin(LitElement) { constructor() { super(); this._loading = false; + this.locationCount = 0; + this.loginPageLoaded = false; this._onReceiveIframeMessage = this._onReceiveIframeMessage.bind(this); } @@ -26,6 +28,8 @@ export class ExternalSignIFrame extends ScopedElementsMixin(LitElement) { static get properties() { return { _loading: {type: Boolean, attribute: false}, + locationCount: {type: Number, attribute: 'location-count', reflect: true}, + loginPageLoaded: {type: Boolean, attribute: 'login-page-loaded', reflect: true}, }; } @@ -68,10 +72,12 @@ export class ExternalSignIFrame extends ScopedElementsMixin(LitElement) { let iframe = this.renderRoot.querySelector('#iframe'); this._loading = true; iframe.src = url; + this.locationCount = 0; } reset() { this.setUrl('about:blank'); + this.locationCount = 0; } static get styles() { @@ -95,9 +101,26 @@ export class ExternalSignIFrame extends ScopedElementsMixin(LitElement) { `; } + update(changedProperties) { + changedProperties.forEach((oldValue, propName) => { + switch (propName) { + case 'locationCount': + this.loginPageLoaded = this.locationCount > 1; + break; + } + }); + + super.update(changedProperties); + } + render() { let onDone = (event) => { this._loading = false; + this.locationCount++; + }; + + let onError = (event) => { + this._loading = false; }; return html` @@ -111,7 +134,7 @@ export class ExternalSignIFrame extends ScopedElementsMixin(LitElement) { id="iframe" class=${classMap({hidden: this._loading})} @load="${onDone}" - @error="${onDone}" + @error="${onError}" scrolling="no"></iframe> `; } -- GitLab