diff --git a/types/accessibility/accessibility-tests.ts b/types/accessibility/accessibility-tests.ts new file mode 100644 index 0000000000..5deeb35736 --- /dev/null +++ b/types/accessibility/accessibility-tests.ts @@ -0,0 +1,50 @@ +let options: Accessibility.Options = { + icon: { + position: { + bottom: { size: 50, units: 'px' }, + right: { size: 0, units: 'px' }, + type: 'fixed', + }, + circular: false, + img: 'accessible', + }, + session: { + persistent: false, + }, +}; +new Accessibility(options); + +options = { + icon: { + position: { + top: { size: 2, units: 'vh' }, + left: { size: 2, units: '%' }, + type: 'absolute', + }, + }, +}; +new Accessibility(options); + +const instance = new Accessibility(options); + +instance.menuInterface.increaseText(); + +instance.menuInterface.decreaseText(); + +instance.menuInterface.increaseTextSpacing(); + +instance.menuInterface.decreaseTextSpacing(); + +instance.menuInterface.invertColors(); + +instance.menuInterface.grayHues(); + +instance.menuInterface.underlineLinks(); + +instance.menuInterface.bigCursor(); + +instance.menuInterface.readingGuide(); + +instance.menuInterface.textToSpeech(); + +instance.menuInterface.speechToText(); diff --git a/types/accessibility/index.d.ts b/types/accessibility/index.d.ts new file mode 100644 index 0000000000..8814543f14 --- /dev/null +++ b/types/accessibility/index.d.ts @@ -0,0 +1,204 @@ +// Type definitions for accessibility 3.0 +// Project: https://github.com/ranbuch/accessibility#readme +// Definitions by: Piotr Błażejewicz +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export as namespace Accessibility; + +/** + * Adaptive Accessibility Menu + */ +declare class Accessibility { + readonly menuInterface: Accessibility.MenuInterface; + /** @deprecated */ + static init(options?: Accessibility.Options): Accessibility; + + constructor(options?: Accessibility.Options); + + alterTextSpace(isIncrease: boolean): void; + build(): void; + deleteOppositesIfDefined(options: Accessibility.Options): Accessibility.Options; + destroy(): void; + disabledUnsupportedFeatures(): void; + fontFallback(): void; + initFontSize(): void; + injectCss(): void; + invoke(action: () => void): void; + listen(): void; + onChange(updateSession: boolean): void; + read(): void; + resetIfDefined(src: any, dest: any, prop: string): void; + runHotkey(name: string): void; + saveSession(): void; + setSessionFromCache(): void; + speechToText(): void; + textToSpeech(text: string): void; + toggleMenu(): void; +} + +/** + * Add accessibility to your website + */ +declare namespace Accessibility { + interface MenuInterface { + increaseText: () => void; + decreaseText: () => void; + increaseTextSpacing: () => void; + decreaseTextSpacing: () => void; + invertColors: (destroy?: boolean) => void; + grayHues: (destroy?: boolean) => void; + underlineLinks: (destroy?: boolean) => void; + bigCursor: (destroy?: boolean) => void; + readingGuide: (destroy?: boolean) => void; + textToSpeech: (destroy?: boolean) => void; + speechToText: (destroy?: boolean) => void; + } + interface Options { + icon?: Icon; + hotkeys?: HotKeys; + buttons?: { + font: SizeOrPosition; + }; + guide?: { + /** @default '#20ff69' */ + cBorder?: string; + /** @default '#000000' */ + cBackground?: string; + /** @default '12px' */ + height?: string; + }; + menu?: { + dimensions?: Dimensions; + fontFamily?: string; + }; + labels?: Labels; + /** @default 'en-US' */ + textToSpeechLang?: string; + /** @default 'en-US' */ + speechToTextLang?: string; + /** @default false */ + textPixelMode?: boolean; + /** @default true */ + textEmlMode?: boolean; + animations?: { + /** @default true */ + buttons?: boolean; + }; + modules?: Modules; + session?: { + /** @default true */ + persistent?: boolean; + }; + } + + interface Icon { + position?: Position; + dimensions?: Dimensions; + /** @default '9999' */ + zIndex?: string | number; + /** @default '#4054b2' */ + backgroundColor?: string; + /** @default '#fff' */ + color?: string; + /** @default 'accessible' */ + img?: string; + /** @default false */ + circular?: boolean; + /** @default false */ + circularBorder?: boolean; + /** @default ['https://fonts.googleapis.com/icon?family=Material+Icons'] */ + fontFaceSrc?: string[]; + /** @default 'Material Icons' */ + fontFamily?: string; + /** @default 'Material Icons' */ + fontClass?: string; + /** @default false */ + useEmojis?: boolean; + } + + interface Labels { + /** @default 'Reset' */ + resetTitle?: string; + /** @default 'Close' */ + closeTitle?: string; + /** @default 'Accessibility Options' */ + menuTitle?: string; + /** @default 'increase text size' */ + increaseText?: string; + /** @default 'decrease text size' */ + decreaseText?: string; + /** @default 'increase text spacing' */ + increaseTextSpacing?: string; + /** @default 'decrease text spacing' */ + decreaseTextSpacing?: string; + /** @default 'invert colors' */ + invertColors?: string; + /** @default 'gray hues' */ + grayHues?: string; + /** @default 'gray hues' */ + bigCursor?: string; + /** @default 'reading guide' */ + readingGuide?: string; + /** @default 'underline links' */ + underlineLinks?: string; + /** @default 'underline links' */ + textToSpeech?: string; + /** @default 'speech to text' */ + speechToText?: string; + } + + interface Modules { + /** @default true */ + increaseText?: boolean; + /** @default true */ + decreaseText?: boolean; + /** @default true */ + increaseTextSpacing?: boolean; + /** @default true */ + decreaseTextSpacing?: boolean; + /** @default true */ + invertColors?: boolean; + /** @default true */ + grayHues?: boolean; + /** @default true */ + bigCursor?: boolean; + /** @default true */ + readingGuide?: boolean; + /** @default true */ + underlineLinks?: boolean; + /** @default true */ + textToSpeech?: boolean; + /** @default true */ + speechToText?: true; + } + + interface HotKeys { + /** @default false */ + enabled?: boolean; + /** @default true */ + helpTitles?: boolean; + keys?: { + [key: string]: HotKeyDefinition; + }; + } + + type HotKeyDefinition = [number, number, string]; + interface Dimensions { + width?: SizeOrPosition; + height?: SizeOrPosition; + } + + interface Position { + top?: SizeOrPosition; + right?: SizeOrPosition; + bottom?: SizeOrPosition; + left?: SizeOrPosition; + type: string; + } + + interface SizeOrPosition { + size: number | string; + units?: string; + } +} +export = Accessibility; diff --git a/types/accessibility/tsconfig.json b/types/accessibility/tsconfig.json new file mode 100644 index 0000000000..f4a3b08997 --- /dev/null +++ b/types/accessibility/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "accessibility-tests.ts" + ] +} diff --git a/types/accessibility/tslint.json b/types/accessibility/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/accessibility/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }