Add tingle.js (#27361)

This commit is contained in:
Klaus Meinhardt
2018-07-23 20:18:51 +02:00
committed by Andy
parent 9d1ab49fcf
commit 11b7aa55c8
4 changed files with 84 additions and 0 deletions

36
types/tingle.js/index.d.ts vendored Normal file
View File

@@ -0,0 +1,36 @@
// Type definitions for tingle.js 0.13
// Project: https://github.com/robinparisi/tingle#readme
// Definitions by: Klaus Meinhardt <https://github.com/ajafff>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
export interface Options {
onOpen?: (this: modal) => void;
onClose?: (this: modal) => void;
beforeOpen?: () => void;
beforeClose?: (this: modal) => boolean | undefined;
stickyFooter?: boolean;
footer?: boolean;
cssClass?: string[];
closeLabel?: string;
closeMethods?: string[];
}
export class modal {
constructor(options?: Options);
setContent(content: string | Element): void;
getContent(): HTMLDivElement;
destroy(): void;
open(): void;
isOpen(): boolean;
close(): void;
setFooterContent(content: string): void;
getFooterContent(): HTMLDivElement | undefined;
setStickyFooter(sticky: boolean): void;
addFooterBtn(
label: string,
cssClass: string | undefined,
listener: HTMLElement['onclick'],
): HTMLButtonElement;
isOverflow(): boolean;
checkOverflow(): void;
}

View File

@@ -0,0 +1,23 @@
import { modal } from 'tingle.js';
let instance = new modal();
instance.open();
instance.checkOverflow();
instance.close();
instance.close();
instance = new modal({
onOpen() {
this.checkOverflow();
},
beforeClose() {
return this.isOverflow();
},
});
instance.addFooterBtn('text', undefined, function(e) {
e.x;
this.innerText;
});
instance.setStickyFooter(false);

View File

@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"strictFunctionTypes": true
},
"files": [
"index.d.ts",
"tingle.js-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }