Repository: wulfsolter/angular2-signaturepad
Branch: master
Commit: a016054b352f
Files: 24
Total size: 26.5 KB
Directory structure:
gitextract_blae03qp/
├── .editorconfig
├── .gitignore
├── .npmignore
├── LICENSE
├── README.md
├── angular.json
├── index.ts
├── package.json
├── projects/
│ └── angular2-signaturepad/
│ ├── README.md
│ ├── karma.conf.js
│ ├── ng-package.json
│ ├── package.json
│ ├── src/
│ │ ├── lib/
│ │ │ ├── angular2-signaturepad.component.spec.ts
│ │ │ ├── angular2-signaturepad.component.ts
│ │ │ └── angular2-signaturepad.module.ts
│ │ ├── public-api.ts
│ │ └── test.ts
│ ├── tsconfig.lib.json
│ ├── tsconfig.lib.prod.json
│ ├── tsconfig.spec.json
│ └── tslint.json
├── signature-pad.ts
├── tsconfig.json
└── tslint.json
================================================
FILE CONTENTS
================================================
================================================
FILE: .editorconfig
================================================
# Editor configuration, see https://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.ts]
quote_type = single
[*.md]
max_line_length = off
trim_trailing_whitespace = false
================================================
FILE: .gitignore
================================================
# See http://help.github.com/ignore-files/ for more about ignoring files.
# compiled output
/dist
/tmp
/out-tsc
# Only exists if Bazel was run
/bazel-out
# dependencies
/node_modules
# profiling files
chrome-profiler-events*.json
speed-measure-plugin*.json
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*
# misc
/.angular/cache
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings
# System Files
.DS_Store
Thumbs.db
================================================
FILE: .npmignore
================================================
# Node generated files
node_modules
npm-debug.log
# OS generated files
Thumbs.db
.DS_Store
# Ignored files
*.ts
!*.d.ts
# ngc generated files
ngfactory
================================================
FILE: LICENSE
================================================
The MIT License (MIT)
Copyright (c) 2016 Wulf Sölter
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# angular2-signaturepad
Angular 2 component for [szimek/signature_pad](https://www.npmjs.com/package/signature_pad).
# No Longer Maintained
<< THIS IS NO LONGER IN USE BY OWNER. PROBLEMS CAN AND DO EXIST. PRs ARE SUPER WELCOME, BUT I CAN NOT IDENTIFY WHAT YOUR ISSUES ARE, NOR WILL I CHANGE THINGS BECAUSE ANGULAR HAS CHANGED IN THE YEARS SINCE I WROTE THIS. I DO NOT USE THIS, I CAN'T HELP YOU WITH YOUR PROBLEMS. >>
## Install
`npm install angular2-signaturepad --save`
## Reference Implementation
* [Live Demo](http://lathonez.com/angular2-signaturepad-demo/)
* [Source](https://github.com/lathonez/angular2-signaturepad-demo)
## Usage example
API is identical to [szimek/signature_pad](https://www.npmjs.com/package/signature_pad).
Options are as per [szimek/signature_pad](https://www.npmjs.com/package/signature_pad) with the following additions:
* canvasWidth: width of the canvas (px)
* canvasHeight: height of the canvas (px)
The above options are provided to avoid accessing the DOM directly from your component to adjust the canvas size.
```typescript
// import into app module
import { SignaturePadModule } from 'angular2-signaturepad';
...
@NgModule({
declarations: [ ],
imports: [ SignaturePadModule ],
providers: [ ],
bootstrap: [ AppComponent ]
})
// then import for use in a component
import { Component, ViewChild } from 'angular2/core';
import { SignaturePad } from 'angular2-signaturepad/signature-pad';
@Component({
template: ''
})
export class SignaturePadPage{
@ViewChild(SignaturePad) signaturePad: SignaturePad;
signaturePadOptions: Object = { // passed through to szimek/signature_pad constructor
'minWidth': 5,
'canvasWidth': 500,
'canvasHeight': 300
};
constructor() {
// no-op
}
ngAfterViewInit() {
// this.signaturePad is now available
this.signaturePad.set('minWidth', 5); // set szimek/signature_pad options at runtime
this.signaturePad.clear(); // invoke functions from szimek/signature_pad API
}
drawComplete() {
// will be notified of szimek/signature_pad's onEnd event
console.log(this.signaturePad.toDataURL());
}
drawStart() {
// will be notified of szimek/signature_pad's onBegin event
console.log('begin drawing');
}
}
```
================================================
FILE: angular.json
================================================
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"angular2-signaturepad": {
"projectType": "library",
"root": "projects/angular2-signaturepad",
"sourceRoot": "projects/angular2-signaturepad/src",
"prefix": "lib",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:ng-packagr",
"options": {
"tsConfig": "projects/angular2-signaturepad/tsconfig.lib.json",
"project": "projects/angular2-signaturepad/ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "projects/angular2-signaturepad/tsconfig.lib.prod.json"
}
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "projects/angular2-signaturepad/src/test.ts",
"tsConfig": "projects/angular2-signaturepad/tsconfig.spec.json",
"karmaConfig": "projects/angular2-signaturepad/karma.conf.js"
}
}
}
}
},
"defaultProject": "angular2-signaturepad"
}
================================================
FILE: index.ts
================================================
import { NgModule } from '@angular/core';
import { SignaturePad } from './signature-pad';
@NgModule({
imports: [ ],
declarations: [ SignaturePad ],
exports: [ SignaturePad ],
})
export class SignaturePadModule { }
================================================
FILE: package.json
================================================
{
"name": "angular2-signaturepad",
"version": "4.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"dependencies": {
"@angular/animations": "~13.0.2",
"@angular/common": "~13.0.2",
"@angular/compiler": "~13.0.2",
"@angular/core": "~13.0.2",
"@angular/forms": "~13.0.2",
"@angular/platform-browser": "~13.0.2",
"@angular/platform-browser-dynamic": "~13.0.2",
"@angular/router": "~13.0.2",
"rxjs": "~6.6.0",
"signature_pad": "^2.3.2",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~13.0.3",
"@angular/cli": "~13.0.3",
"@angular/compiler-cli": "~13.0.2",
"@types/jasmine": "~3.6.0",
"@types/node": "^12.11.1",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~6.3.14",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"ng-packagr": "^13.0.6",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~4.4.4"
},
"whitelistedNonPeerDependencies": ["signature_pad"]
}
================================================
FILE: projects/angular2-signaturepad/README.md
================================================
# angular2-signaturepad
Angular 2 component for [szimek/signature_pad](https://www.npmjs.com/package/signature_pad).
<< THIS IS NO LONGER IN USE BY OWNER. PROBLEMS CAN AND DO EXIST. PRs ARE SUPER WELCOME, BUT I CAN NOT IDENTIFY WHAT YOUR ISSUES ARE, NOR WILL I CHANGE THINGS BECAUSE ANGULAR HAS CHANGED IN THE YEARS SINCE I WROTE THIS >>
## Install
`npm install angular2-signaturepad --save`
## Reference Implementation
* [Live Demo](http://lathonez.com/angular2-signaturepad-demo/)
* [Source](https://github.com/lathonez/angular2-signaturepad-demo)
## Usage example
API is identical to [szimek/signature_pad](https://www.npmjs.com/package/signature_pad).
Options are as per [szimek/signature_pad](https://www.npmjs.com/package/signature_pad) with the following additions:
* canvasWidth: width of the canvas (px)
* canvasHeight: height of the canvas (px)
The above options are provided to avoid accessing the DOM directly from your component to adjust the canvas size.
```typescript
// import into app module
import { SignaturePadModule } from 'angular2-signaturepad';
...
@NgModule({
declarations: [ ],
imports: [ SignaturePadModule ],
providers: [ ],
bootstrap: [ AppComponent ]
})
// then import for use in a component
import { Component, ViewChild } from 'angular2/core';
import { SignaturePad } from 'angular2-signaturepad/signature-pad';
@Component({
template: ''
})
export class SignaturePadPage{
@ViewChild(SignaturePad) signaturePad: SignaturePad;
private signaturePadOptions: Object = { // passed through to szimek/signature_pad constructor
'minWidth': 5,
'canvasWidth': 500,
'canvasHeight': 300
};
constructor() {
// no-op
}
ngAfterViewInit() {
// this.signaturePad is now available
this.signaturePad.set('minWidth', 5); // set szimek/signature_pad options at runtime
this.signaturePad.clear(); // invoke functions from szimek/signature_pad API
}
drawComplete() {
// will be notified of szimek/signature_pad's onEnd event
console.log(this.signaturePad.toDataURL());
}
drawStart() {
// will be notified of szimek/signature_pad's onBegin event
console.log('begin drawing');
}
}
```
================================================
FILE: projects/angular2-signaturepad/karma.conf.js
================================================
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
jasmineHtmlReporter: {
suppressAll: true // removes the duplicated traces
},
coverageReporter: {
dir: require('path').join(__dirname, '../../coverage/angular2-signaturepad'),
subdir: '.',
reporters: [
{ type: 'html' },
{ type: 'text-summary' }
]
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true
});
};
================================================
FILE: projects/angular2-signaturepad/ng-package.json
================================================
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/angular2-signaturepad",
"lib": {
"entryFile": "src/public-api.ts"
}
}
================================================
FILE: projects/angular2-signaturepad/package.json
================================================
{
"name": "angular2-signaturepad",
"version": "3.0.4",
"description": "Angular2 Component wrapper for szimek / signature_pad",
"repository": {
"type": "git",
"url": "git+https://github.com/wulfsolter/angular2-signaturepad.git"
},
"keywords": [
"signature",
"sign",
"finger",
"canvas"
],
"author": "Wulf Solter (http://wulf.co.nz)",
"license": "MIT",
"bugs": {
"url": "https://github.com/wulfsolter/angular2-signaturepad/issues"
},
"homepage": "https://github.com/wulfsolter/angular2-signaturepad#readme",
"peerDependencies": {
"@angular/common": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0",
"@angular/core": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0",
"signature_pad": "2.3.2"
},
"dependencies": {
"tslib": "^2.0.0"
}
}
================================================
FILE: projects/angular2-signaturepad/src/lib/angular2-signaturepad.component.spec.ts
================================================
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { SignaturePad } from './angular2-signaturepad.component';
describe('Angular2SignaturepadComponent', () => {
let component: SignaturePad;
let fixture: ComponentFixture;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [SignaturePad],
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(SignaturePad);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
================================================
FILE: projects/angular2-signaturepad/src/lib/angular2-signaturepad.component.ts
================================================
import {
AfterContentInit,
Component,
ElementRef,
EventEmitter,
Input,
Output,
OnDestroy,
} from '@angular/core';
import * as SignaturePadNative from 'signature_pad';
export interface Point {
x: number;
y: number;
time: number;
}
export type PointGroup = Array;
@Component({
template: '',
selector: 'signature-pad',
})
export class SignaturePad implements AfterContentInit, OnDestroy {
@Input() public options: any;
@Output() public onBeginEvent: EventEmitter;
@Output() public onEndEvent: EventEmitter;
private signaturePad: any;
private elementRef: ElementRef;
constructor(elementRef: ElementRef) {
// no op
this.elementRef = elementRef;
this.options = this.options || {};
this.onBeginEvent = new EventEmitter();
this.onEndEvent = new EventEmitter();
}
public ngAfterContentInit(): void {
const canvas: any = this.elementRef.nativeElement.querySelector('canvas');
if ((this.options as any).canvasHeight) {
canvas.height = (this.options as any).canvasHeight;
}
if ((this.options as any).canvasWidth) {
canvas.width = (this.options as any).canvasWidth;
}
this.signaturePad = new SignaturePadNative.default(canvas, this.options);
this.signaturePad.onBegin = this.onBegin.bind(this);
this.signaturePad.onEnd = this.onEnd.bind(this);
}
public ngOnDestroy(): void {
const canvas: any = this.elementRef.nativeElement.querySelector('canvas');
canvas.width = 0;
canvas.height = 0;
}
public resizeCanvas(): void {
// When zoomed out to less than 100%, for some very strange reason,
// some browsers report devicePixelRatio as less than 1
// and only part of the canvas is cleared then.
const ratio: number = Math.max(window.devicePixelRatio || 1, 1);
const canvas: any = this.signaturePad.canvas;
canvas.width = canvas.offsetWidth * ratio;
canvas.height = canvas.offsetHeight * ratio;
canvas.getContext('2d').scale(ratio, ratio);
this.signaturePad.clear(); // otherwise isEmpty() might return incorrect value
}
// Returns signature image as an array of point groups
public toData(): Array {
if (this.signaturePad) {
return this.signaturePad.toData();
} else {
return [];
}
}
// Draws signature image from an array of point groups
public fromData(points: Array): void {
this.signaturePad.fromData(points as any);
}
// Returns signature image as data URL (see https://mdn.io/todataurl for the list of possible paramters)
public toDataURL(imageType?: string, quality?: number): string {
return this.signaturePad.toDataURL(imageType, quality); // save image as data URL
}
// Draws signature image from data URL
public fromDataURL(dataURL: string, options: any = {}): void {
// set default height and width on read data from URL
if (
!options.hasOwnProperty('height') &&
(this.options as any).canvasHeight
) {
options.height = (this.options as any).canvasHeight;
}
if (!options.hasOwnProperty('width') && (this.options as any).canvasWidth) {
options.width = (this.options as any).canvasWidth;
}
this.signaturePad.fromDataURL(dataURL, options);
}
// Clears the canvas
public clear(): void {
this.signaturePad.clear();
}
// Returns true if canvas is empty, otherwise returns false
public isEmpty(): boolean {
return this.signaturePad.isEmpty();
}
// Unbinds all event handlers
public off(): void {
this.signaturePad.off();
}
// Rebinds all event handlers
public on(): void {
this.signaturePad.on();
}
// set an option on the signaturePad - e.g. set('minWidth', 50);
public set(option: string, value: any): void {
switch (option) {
case 'canvasHeight':
this.signaturePad.canvas.height = value;
break;
case 'canvasWidth':
this.signaturePad.canvas.width = value;
break;
default:
this.signaturePad[option] = value;
}
}
// notify subscribers on signature begin
public onBegin(): void {
this.onBeginEvent.emit(true);
}
// notify subscribers on signature end
public onEnd(): void {
this.onEndEvent.emit(true);
}
public queryPad(): any {
return this.signaturePad;
}
}
================================================
FILE: projects/angular2-signaturepad/src/lib/angular2-signaturepad.module.ts
================================================
import { NgModule } from '@angular/core';
import { SignaturePad } from './angular2-signaturepad.component';
@NgModule({
declarations: [SignaturePad],
imports: [],
exports: [SignaturePad],
})
export class SignaturePadModule {}
================================================
FILE: projects/angular2-signaturepad/src/public-api.ts
================================================
/*
* Public API Surface of angular2-signaturepad
*/
export * from './lib/angular2-signaturepad.component';
export * from './lib/angular2-signaturepad.module';
================================================
FILE: projects/angular2-signaturepad/src/test.ts
================================================
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
import 'zone.js';
import 'zone.js/testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';
declare const require: {
context(path: string, deep?: boolean, filter?: RegExp): {
keys(): string[];
(id: string): T;
};
};
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting(), {
teardown: { destroyAfterEach: false }
}
);
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);
================================================
FILE: projects/angular2-signaturepad/tsconfig.lib.json
================================================
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/lib",
"target": "es2015",
"declaration": true,
"declarationMap": true,
"inlineSources": true,
"types": [],
"lib": [
"dom",
"es2018"
]
},
"angularCompilerOptions": {
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"enableResourceInlining": true
},
"exclude": [
"src/test.ts",
"**/*.spec.ts"
]
}
================================================
FILE: projects/angular2-signaturepad/tsconfig.lib.prod.json
================================================
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "./tsconfig.lib.json",
"compilerOptions": {
"declarationMap": false
},
"angularCompilerOptions": {
"compilationMode": "partial"
}
}
================================================
FILE: projects/angular2-signaturepad/tsconfig.spec.json
================================================
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/spec",
"types": [
"jasmine"
]
},
"files": [
"src/test.ts"
],
"include": [
"**/*.spec.ts",
"**/*.d.ts"
]
}
================================================
FILE: projects/angular2-signaturepad/tslint.json
================================================
{
"extends": "../../tslint.json",
"rules": {
"directive-selector": [
true,
"attribute",
"lib",
"camelCase"
],
"component-selector": [
true,
"element",
"lib",
"kebab-case"
]
}
}
================================================
FILE: signature-pad.ts
================================================
'use strict';
import {AfterContentInit, Component, ElementRef, EventEmitter, Input, Output, OnDestroy} from '@angular/core';
declare var require: any;
export interface Point {
x: number;
y: number;
time: number;
}
export type PointGroup = Array;
@Component({
template: '',
selector: 'signature-pad',
})
export class SignaturePad implements AfterContentInit, OnDestroy {
@Input() public options: Object;
@Output() public onBeginEvent: EventEmitter;
@Output() public onEndEvent: EventEmitter;
private signaturePad: any;
private elementRef: ElementRef;
constructor(elementRef: ElementRef) {
// no op
this.elementRef = elementRef;
this.options = this.options || {};
this.onBeginEvent = new EventEmitter();
this.onEndEvent = new EventEmitter();
}
public ngAfterContentInit(): void {
const sp: any = require('signature_pad').default;
const canvas: any = this.elementRef.nativeElement.querySelector('canvas');
if ((this.options as any).canvasHeight) {
canvas.height = (this.options as any).canvasHeight;
}
if ((this.options as any).canvasWidth) {
canvas.width = (this.options as any).canvasWidth;
}
this.signaturePad = new sp(canvas, this.options);
this.signaturePad.onBegin = this.onBegin.bind(this);
this.signaturePad.onEnd = this.onEnd.bind(this);
}
public ngOnDestroy(): void {
const canvas: any = this.elementRef.nativeElement.querySelector('canvas');
canvas.width = 0;
canvas.height = 0;
}
public resizeCanvas(): void {
// When zoomed out to less than 100%, for some very strange reason,
// some browsers report devicePixelRatio as less than 1
// and only part of the canvas is cleared then.
const ratio: number = Math.max(window.devicePixelRatio || 1, 1);
const canvas: any = this.signaturePad._canvas;
canvas.width = canvas.offsetWidth * ratio;
canvas.height = canvas.offsetHeight * ratio;
canvas.getContext('2d').scale(ratio, ratio);
this.signaturePad.clear(); // otherwise isEmpty() might return incorrect value
}
// Returns signature image as an array of point groups
public toData(): Array {
if (this.signaturePad) {
return this.signaturePad.toData();
} else {
return [];
}
}
// Draws signature image from an array of point groups
public fromData(points: Array): void {
this.signaturePad.fromData(points);
}
// Returns signature image as data URL (see https://mdn.io/todataurl for the list of possible paramters)
public toDataURL(imageType?: string, quality?: number): string {
return this.signaturePad.toDataURL(imageType, quality); // save image as data URL
}
// Draws signature image from data URL
public fromDataURL(dataURL: string, options: any = {}): void {
// set default height and width on read data from URL
if (!options.hasOwnProperty('height') && (this.options as any).canvasHeight) {
options.height = (this.options as any).canvasHeight;
}
if (!options.hasOwnProperty('width') && (this.options as any).canvasWidth) {
options.width = (this.options as any).canvasWidth;
}
this.signaturePad.fromDataURL(dataURL, options);
}
// Clears the canvas
public clear(): void {
this.signaturePad.clear();
}
// Returns true if canvas is empty, otherwise returns false
public isEmpty(): boolean {
return this.signaturePad.isEmpty();
}
// Unbinds all event handlers
public off(): void {
this.signaturePad.off();
}
// Rebinds all event handlers
public on(): void {
this.signaturePad.on();
}
// set an option on the signaturePad - e.g. set('minWidth', 50);
public set(option: string, value: any): void {
switch (option) {
case 'canvasHeight':
this.signaturePad._canvas.height = value;
break;
case 'canvasWidth':
this.signaturePad._canvas.width = value;
break;
default:
this.signaturePad[option] = value;
}
}
// notify subscribers on signature begin
public onBegin(): void {
this.onBeginEvent.emit(true);
}
// notify subscribers on signature end
public onEnd(): void {
this.onEndEvent.emit(true);
}
public queryPad(): any {
return this.signaturePad;
}
}
================================================
FILE: tsconfig.json
================================================
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"module": "es2020",
"lib": ["es2018", "dom"],
"paths": {
"angular2-signaturepad": [
"dist/angular2-signaturepad/angular2-signaturepad",
"dist/angular2-signaturepad"
]
}
},
"angularCompilerOptions": {}
}
================================================
FILE: tslint.json
================================================
{
"extends": "tslint:recommended",
"rulesDirectory": [
"codelyzer"
],
"rules": {
"align": {
"options": [
"parameters",
"statements"
]
},
"array-type": false,
"arrow-return-shorthand": true,
"curly": true,
"deprecation": {
"severity": "warning"
},
"eofline": true,
"import-blacklist": [
true,
"rxjs/Rx"
],
"import-spacing": true,
"indent": {
"options": [
"spaces"
]
},
"max-classes-per-file": false,
"max-line-length": [
true,
140
],
"member-ordering": [
true,
{
"order": [
"static-field",
"instance-field",
"static-method",
"instance-method"
]
}
],
"no-console": [
true,
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-empty": false,
"no-inferrable-types": [
true,
"ignore-params"
],
"no-non-null-assertion": true,
"no-redundant-jsdoc": true,
"no-switch-case-fall-through": true,
"no-var-requires": false,
"object-literal-key-quotes": [
true,
"as-needed"
],
"quotemark": [
true,
"single"
],
"semicolon": {
"options": [
"always"
]
},
"space-before-function-paren": {
"options": {
"anonymous": "never",
"asyncArrow": "always",
"constructor": "never",
"method": "never",
"named": "never"
}
},
"typedef": [
true,
"call-signature"
],
"typedef-whitespace": {
"options": [
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
},
{
"call-signature": "onespace",
"index-signature": "onespace",
"parameter": "onespace",
"property-declaration": "onespace",
"variable-declaration": "onespace"
}
]
},
"variable-name": {
"options": [
"ban-keywords",
"check-format",
"allow-pascal-case"
]
},
"whitespace": {
"options": [
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type",
"check-typecast"
]
},
"component-class-suffix": true,
"contextual-lifecycle": true,
"directive-class-suffix": true,
"no-conflicting-lifecycle": true,
"no-host-metadata-property": true,
"no-input-rename": true,
"no-inputs-metadata-property": true,
"no-output-native": true,
"no-output-on-prefix": true,
"no-output-rename": true,
"no-outputs-metadata-property": true,
"template-banana-in-box": true,
"template-no-negated-async": true,
"use-lifecycle-interface": true,
"use-pipe-transform-interface": true
}
}