@mclck/cloudsigns
v0.0.1
Published
Widget initialization class.
Downloads
1
Readme
cloudsigns_widget
Install
$ yarn install
$ npm run dev
$ npm run build
How to use
Build first.
Execute the file build/cloudsigns.min.js
in browser.
Create the instance, like:
const csw = new CloudsignsWidget();
Initialize widget call:
csw.startSign(
{
"clientKey": "some-client-key",
"templateKey": "some-template-key"
}
);
And then click on selected button;
Examples
HTML
<form id="form-id">
<input type="text" data-cs="birth" />
<input type="text" data-cs="name" />
<input type="text" data-cs="snils" />
</form>
<button id="button">
Start sign
</button>
Vanilla
const widget = new CloudsignsWidget("form-id");
const element = document.getElementById("button");
element.addEventListener("click", () => {
widget.startSign({
clientKey: "some-client-key",
templateKey: "some-template-key",
snils: "some-snils",
onStart: () => {
console.info("Request success!");
},
onError: (error) => {
console.error("Request error", error);
},
onSignSuccess: (data) => {
console.info("Sign success!", data);
},
onSignError: (error) => {
console.error("Sign error", error);
}
});
});
jQuery
const widget = new CloudsignsWidget("form-id");
const element = $("button");
element.on("click", () => {
widget.startSign({
clientKey: "some-client-key",
templateKey: "some-template-key",
snils: "some-snils",
onStart: () => {
console.info("Request success!");
},
onError: (error) => {
console.error("Request error", error);
},
onSignSuccess: (data) => {
console.info("Sign success!", data);
},
onSignError: (error) => {
console.error("Sign error", error);
}
});
});
NPM Module (React)
import CloudsignsWidget from "cloud-signs";
export const SignComponent = () => {
const handleStartSign = () => {
const widget = new CloudsignsWidget("form-id");
widget.startSign({
clientKey: "some-client-key",
templateKey: "some-template-key",
snils: "some-snils",
onStart: () => {
console.info("Request success!");
},
onError: (error) => {
console.error("Request error", error);
},
onSignSuccess: (data) => {
console.info("Sign success!", data);
},
onSignError: (error) => {
console.error("Sign error", error);
}
});
}
return (
<div>
<form id="form-id">
<input type="text" data-cs="birth" />
<input type="text" data-cs="name" />
<input type="text" data-cs="snils" />
</form>
<button onClick={handleStartSign}>
Start sign
</button>
</div>
)
}
Options
type ObjectRecord = Record<string, ObjectRecord>
type WidgetOptions = {
url: string,
clientKey: string,
templateKey: string,
documentParams: ObjectRecord,
snils: string,
onStart?(result: any): void,
onSignSuccess?(result: any): void,
onError?(error: jqXHR): void
onSignError?(error: ay): void
};
interface IWidget {
startSign(options: WidgetOptions): void
destroy(): void
};
LICENSE
MIT