From 322d589b4e166dcc2d75345243c525041e76b36e Mon Sep 17 00:00:00 2001 From: AndersonFriaca Date: Sat, 17 Feb 2018 23:15:03 -0300 Subject: [PATCH 1/2] Types for jquery-lazyload --- types/jquery-lazyload/index.d.ts | 26 +++++++++++++++++++ .../jquery-lazyload/jquery-lazyload-tests.ts | 20 ++++++++++++++ types/jquery-lazyload/tsconfig.json | 25 ++++++++++++++++++ types/jquery-lazyload/tslint.json | 1 + 4 files changed, 72 insertions(+) create mode 100644 types/jquery-lazyload/index.d.ts create mode 100644 types/jquery-lazyload/jquery-lazyload-tests.ts create mode 100644 types/jquery-lazyload/tsconfig.json create mode 100644 types/jquery-lazyload/tslint.json diff --git a/types/jquery-lazyload/index.d.ts b/types/jquery-lazyload/index.d.ts new file mode 100644 index 0000000000..a48759dac7 --- /dev/null +++ b/types/jquery-lazyload/index.d.ts @@ -0,0 +1,26 @@ +// Type definitions for jQuery Lazy Load 1.9 +// Project: https://github.com/tuupola/jquery_lazyload +// Definitions by: Anderson Friaça +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// + +declare namespace jQueryLazyLoad { + interface Options { + threshold?: number; + failure_limit?: number; + event?: string; + effect?: string; + container?: JQuery; + data_attribute?: string; + skip_invisible?: boolean; + appear?: null; + load?: (elementsLeft?: number, options?: Options) => void; + placeholder?: string; + } +} +interface JQuery { + lazyload(options?: jQueryLazyLoad.Options): JQuery; + on(event: 'load', callback: ((options?: jQueryLazyLoad.Options) => void)): JQuery; +} diff --git a/types/jquery-lazyload/jquery-lazyload-tests.ts b/types/jquery-lazyload/jquery-lazyload-tests.ts new file mode 100644 index 0000000000..5fee2eec1f --- /dev/null +++ b/types/jquery-lazyload/jquery-lazyload-tests.ts @@ -0,0 +1,20 @@ +$(document).ready(() => { + // basic usage + $('.lazyload').lazyload(); + + // with options + const options: jQueryLazyLoad.Options = { + threshold: 200, + event: 'click', + effect: 'fadeIn', + container: $('#container'), + failure_limit: 10, + skip_invisible: true + }; + $('.lazyload').lazyload(options); + + // event on load + $('.lazyload').on('load', () => { + $("img.lazy").trigger("click"); + }); +}); diff --git a/types/jquery-lazyload/tsconfig.json b/types/jquery-lazyload/tsconfig.json new file mode 100644 index 0000000000..857bd1b9f5 --- /dev/null +++ b/types/jquery-lazyload/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "esModuleInterop": true + }, + "files": [ + "index.d.ts", + "jquery-lazyload-tests.ts" + ] +} \ No newline at end of file diff --git a/types/jquery-lazyload/tslint.json b/types/jquery-lazyload/tslint.json new file mode 100644 index 0000000000..d04fe2e1fa --- /dev/null +++ b/types/jquery-lazyload/tslint.json @@ -0,0 +1 @@ +{"extends": "dtslint/dt.json"} \ No newline at end of file From 76fb5a78b15e6a2aad562266a53beb38f1661849 Mon Sep 17 00:00:00 2001 From: AndersonFriaca Date: Mon, 19 Feb 2018 07:37:16 -0400 Subject: [PATCH 2/2] Adjustments --- types/jquery-lazyload/index.d.ts | 8 ++++---- types/jquery-lazyload/jquery-lazyload-tests.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/types/jquery-lazyload/index.d.ts b/types/jquery-lazyload/index.d.ts index a48759dac7..5505c247f5 100644 --- a/types/jquery-lazyload/index.d.ts +++ b/types/jquery-lazyload/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for jQuery Lazy Load 1.9 +// Type definitions for JQuery Lazy Load 1.9 // Project: https://github.com/tuupola/jquery_lazyload // Definitions by: Anderson Friaça // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -6,7 +6,7 @@ /// -declare namespace jQueryLazyLoad { +declare namespace JQueryLazyLoad { interface Options { threshold?: number; failure_limit?: number; @@ -21,6 +21,6 @@ declare namespace jQueryLazyLoad { } } interface JQuery { - lazyload(options?: jQueryLazyLoad.Options): JQuery; - on(event: 'load', callback: ((options?: jQueryLazyLoad.Options) => void)): JQuery; + lazyload(options?: JQueryLazyLoad.Options): JQuery; + on(event: 'load', callback: ((options?: JQueryLazyLoad.Options) => void)): JQuery; } diff --git a/types/jquery-lazyload/jquery-lazyload-tests.ts b/types/jquery-lazyload/jquery-lazyload-tests.ts index 5fee2eec1f..086069d11d 100644 --- a/types/jquery-lazyload/jquery-lazyload-tests.ts +++ b/types/jquery-lazyload/jquery-lazyload-tests.ts @@ -3,7 +3,7 @@ $(document).ready(() => { $('.lazyload').lazyload(); // with options - const options: jQueryLazyLoad.Options = { + const options: JQueryLazyLoad.Options = { threshold: 200, event: 'click', effect: 'fadeIn',