Created
January 13, 2022 20:45
-
-
Save charlesfries/0bb35e7ceddc2e4d740942bdb8a600cc to your computer and use it in GitHub Desktop.
Ember.js Adobe Sign Component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Component from '@glimmer/component'; | |
import { assert } from '@ember/debug'; | |
import { typeOf } from '@ember/utils'; | |
export interface AdobeSignComponentArgs { | |
url: string; | |
onChange: () => void; | |
} | |
export default class AdobeSignComponent extends Component<AdobeSignComponentArgs> { | |
constructor(owner: unknown, args: AdobeSignComponentArgs) { | |
super(owner, args); | |
assert('<AdobeSign />: Must pass a url string', typeOf(this.args.url) === 'string'); | |
assert('<AdobeSign />: Must pass an onChange function', typeOf(this.args.onChange) === 'function'); | |
window.addEventListener('message', (event) => { | |
if (event.origin === 'https://na2.documents.adobe.com' && JSON.parse(event.data).type === 'ESIGN') { | |
this.args.onChange(); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment