diff --git a/package.json b/package.json index 3c583171d76b7f559952fb34331283c28cda8594..986bde19ef71024e771d00a004face66995b91f0 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 a8bb341e3bd40a427f387ee0db098d7a94d05e15..5ae5e2dd36c71177c49d25b16bbe9b717704f027 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> `; }