diff --git a/types/homeworks/homeworks-tests.ts b/types/homeworks/homeworks-tests.ts new file mode 100644 index 0000000000..16bce6d106 --- /dev/null +++ b/types/homeworks/homeworks-tests.ts @@ -0,0 +1,93 @@ +const element: JQuery = $('#element'); +const target: JQuery = $('#target'); + +element.checkbox({ + /* Empty options */ +}).bind('change', (event: HomeWorksEventObject) => { + /* HomeWorks native event */ +}); + +element.converter({ + /* Empty options */ +}); + +element.dropdown({ + /* Empty options */ +}); + +const dropdownHandlerTarget: JQuery = element.addHandler(target); + +element.input({ + /* Empty options */ +}).bind('change', (event: HomeWorksEventObject) => { + /* HomeWorks native event */ +}); + +element.modal({ + /* Any options */ +}).each(() => { + /* Chaining */ +}); +element.modal('show'); +element.modal('hide'); +element.modal('open'); +element.modal('close'); + +notification('title', 'content', 'url', 'success'); + +element.ripple({ + /* Object options */ +}); +element.start({ + x: 1, + y: 2 +}); + +element.spinner({ + type: 'any', + empty: 'any' +}).bind('change', (event: HomeWorksEventObject) => { + /* HomeWorks native event */ +}); + +element.step('method'); +element.step({ + active: 0 +}).bind('move', (event: HomeWorksStepEventObject) => { + /* HomeWorks step event */ +}); + +element.tab('method'); +element.tab({ + active: 0 +}).bind('move', (event: HomeWorksTabEventObject) => { + /* HomeWorks step event */ +}); + +toast('hello homeworks'); +toast({ + message: 'hello homeworks' +}); + +element.toggle({ + placeholder: 'placeholder' +}).bind('change', (event: HomeWorksEventObject) => { + /* HomeWorks native event */ +}); + +element.upload({ + url: 'url', + type: 'type', + data: {}, + dest: 'dest', + isBtn: true, + beforeStart() { + }, + complete(data: any) { + }, + success(data?: any, state?: any, xhr?: any) { + }, + error(xhr?: any, state?: any, error?: any) { + }, + extensions: 'any' +}); diff --git a/types/homeworks/index.d.ts b/types/homeworks/index.d.ts new file mode 100644 index 0000000000..87affa65e5 --- /dev/null +++ b/types/homeworks/index.d.ts @@ -0,0 +1,212 @@ +// Type definitions for homeworks 1.0 +// Project: https://github.com/IGAWorksDev/homeworks/ +// Definitions by: Kenneth Ceyer +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +/** + * * [MAIN] + * @ EVENT + * + */ + +declare interface HomeWorksEventObject { + element: JQuery; + value: string; + checked?: boolean; +} + +declare interface JQuery { + bind(eventType: string, handler: (...parameters: any[]) => void): JQuery; + knock(): JQuery; +} + +/** + * * [COMPONENT] + * @ CHECKBOX + * + */ +interface CheckboxOptions { +} + +declare interface JQuery { + checkbox(options?: CheckboxOptions): JQuery; +} + +/** + * * [COMPONENT] + * @ CONVERTER + * + */ + +interface ConverterOptions { +} + +declare interface JQuery { + converter(options?: ConverterOptions): JQuery; +} + +/** + * * [COMPONENT] + * @ DROPDOIWN + * + */ + +interface DropdownOptions { +} + +declare interface JQuery { + dropdown(options?: DropdownOptions): JQuery; + addHandler(target: JQuery): JQuery; +} + +/** + * * [COMPONENT] + * @ INPUT + * + */ + +interface InputOptions { +} + +declare interface JQuery { + input(options?: InputOptions): JQuery; +} + +/** + * * [COMPONENT] + * @ MODAL + * + */ + +declare interface JQuery { + modal(options?: any): JQuery; + modal(method?: string, options?: any): JQuery; +} + +/** + * * [COMPONENT] + * @ NOTIFICATION + * + */ + +declare function notification(title: string, content: string, url: string, status?: string): void; + +/** + * * [COMPONENT] + * @ RIPPLE + * + */ + +interface RippleStartOptions { + x: number; + y: number; +} + +declare interface JQuery { + ripple(options?: any): JQuery; + start(options?: RippleStartOptions): JQuery; +} + +/** + * * [COMPONENT] + * @ SPINNER + * + */ + +interface SpinnerOptions { + type?: any; + empty?: any; +} + +declare interface JQuery { + spinner(options?: SpinnerOptions): JQuery; +} + +/** + * * [COMPONENT] + * @ STEP + * + */ + +interface StepOptions { + active?: number; +} + +declare interface JQuery { + step(method?: string): JQuery; + step(options?: StepOptions): JQuery; +} + +declare interface HomeWorksStepEventObject { + header: JQuery[]; + index: number; + length: number; +} + +/** + * * [COMPONENT] + * @ TAB + * + */ + +interface TabOptions { + active?: number; +} + +declare interface JQuery { + tab(method?: string): JQuery; + tab(options?: TabOptions): JQuery; +} + +declare interface HomeWorksTabEventObject { + header: JQuery[]; + index: number; + length: number; +} + +/** + * * [COMPONENT] + * @ TOAST + * + */ + +declare function toast(message: any): void; + +/** + * * [COMPONENT] + * @ TOGGLE + * + */ + +interface ToggleOptions { + placeholder?: string; +} + +declare interface JQuery { + toggle(options: ToggleOptions): JQuery; +} + +/** + * * [COMPONENT] + * @ UPLOAD + * + */ + +interface UploadOptions { + url: string; + type?: string; + data?: any; + dest?: string; + isBtn?: boolean; + beforeStart?: () => void; + complete?: (data?: any) => void; + success?: (data?: any, state?: any, xhr?: any) => void; + error?: (xhr?: any, state?: any, error?: any) => void; + extensions?: any; +} + +declare interface JQuery { + upload(options?: UploadOptions): JQuery; +} diff --git a/types/homeworks/tsconfig.json b/types/homeworks/tsconfig.json new file mode 100644 index 0000000000..65f6fc4f01 --- /dev/null +++ b/types/homeworks/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "homeworks-tests.ts" + ] +} \ No newline at end of file diff --git a/types/homeworks/tslint.json b/types/homeworks/tslint.json new file mode 100644 index 0000000000..626d0c5922 --- /dev/null +++ b/types/homeworks/tslint.json @@ -0,0 +1,9 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "no-empty-interface": false, + "strict-export-declare-modifiers": false, + "prefer-method-signature": false, + "unified-signatures": false + } +}