Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several addons [GSoC] #40

Merged
merged 21 commits into from
Oct 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,4 @@ var Common = /*#__PURE__*/function () {

exports.Common = Common;

_defineProperty(Common, "DEFAULT_PIXEL", 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=');
_defineProperty(Common, "DEFAULT_PIXEL", 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdj+P///38ACfsD/QVDRcoAAAAASUVORK5CYII=');
18 changes: 18 additions & 0 deletions dist/interfaces/accessibility.interface.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface IAccessibility {
readonly recognition: any;
alterTextSize(isIncrease: boolean): void;
alterTextSpace(isIncrease: boolean): void;
alterLineHeight(isIncrease: boolean): void;
speechToText(): void;
textToSpeech(text: string): void;
listen(): void;
Expand All @@ -23,6 +24,7 @@ export interface IAccessibility {
updateReadGuide(e: Event | TouchEvent | any): void;
resetIfDefined(src: string, dest: any, prop: string): void;
onChange(updateSession: boolean): void;
createScreenShot(url: string): Promise<string>;
}
export interface IAccessibilityOptions {
icon?: IAccessibilityIconOptions;
Expand All @@ -40,6 +42,9 @@ export interface IAccessibilityOptions {
session?: IAccessibilitySessionOptions;
iframeModals?: Array<IIframeModal>;
customFunctions?: Array<ICustomFunction>;
statement?: IAccessibilityUrlOptions;
feedback?: IAccessibilityUrlOptions;
language?: IAccessibilityLanguageOptions;
}
export interface ICustomFunction {
method: Function;
Expand Down Expand Up @@ -69,6 +74,7 @@ export interface IAccessibilityIconOptions {
useEmojis?: boolean;
fontFamily?: string;
forceFont?: boolean;
tabIndex?: number;
}
export interface IAccessibilityIconPositionOptions {
top?: IUnitsDim;
Expand Down Expand Up @@ -129,6 +135,9 @@ export interface IAccessibilityMenuLabelsOptions {
textToSpeech: string;
speechToText: string;
disableAnimations: string;
increaseLineHeight: string;
decreaseLineHeight: string;
screenReader: string;
}
export interface IAccessibilityAnimationsOptions {
buttons: boolean;
Expand All @@ -150,9 +159,17 @@ export interface IAccessibilityModulesOptions {
export interface IAccessibilitySessionOptions {
persistent: boolean;
}
export interface IAccessibilityUrlOptions {
url: string;
}
export interface IAccessibilityLanguageOptions {
textToSpeechLang: string;
speechToTextLang: string;
}
export interface ISessionState {
textSize: number;
textSpace: number;
lineHeight: number;
invertColors: boolean;
grayHues: boolean;
underlineLinks: boolean;
Expand All @@ -168,6 +185,7 @@ export interface IStateValues {
grayHues?: boolean;
speechToText?: boolean;
disableAnimations?: boolean;
speechRate?: number;
body: any;
html: any;
}
2 changes: 1 addition & 1 deletion dist/main.bundle.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions dist/main.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,20 @@ export declare class Accessibility implements IAccessibility {
injectIcon(): HTMLElement;
parseKeys(arr: Array<any>): string;
injectMenu(): HTMLElement;
getVoices(): Promise<SpeechSynthesisVoice[]>;
injectTts(): Promise<void>;
addListeners(): void;
disableUnsupportedModules(): void;
resetAll(): void;
resetTextSize(): void;
resetLineHeight(): void;
resetTextSpace(): void;
alterTextSize(isIncrease: boolean): void;
alterLineHeight(isIncrease: boolean): void;
alterTextSpace(isIncrease: boolean): void;
speechToText(): void;
textToSpeech(text: string): void;
createScreenShot(url: string): Promise<string>;
listen(): void;
read(e: Event): void;
runHotkey(name: string): void;
Expand Down
467 changes: 420 additions & 47 deletions dist/main.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions dist/menu-interface.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ export declare class MenuInterface implements IMenuInterface {
disableAnimations(destroy: boolean): void;
iframeModals(destroy?: boolean, button?: HTMLElement): void;
customFunctions(destroy?: boolean, button?: HTMLElement): void;
increaseLineHeight(): void;
decreaseLineHeight(): void;
}
102 changes: 94 additions & 8 deletions dist/menu-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ var MenuInterface = /*#__PURE__*/function () {
return;
}

if (this._acc.stateValues.invertColors && this._acc.stateValues.textToSpeech) {
this._acc.textToSpeech('Colors Set To Normal');
}

document.querySelector('._access-menu [data-access-action="invertColors"]').classList.toggle('active');
this._acc.stateValues.invertColors = !this._acc.stateValues.invertColors;
this._acc.sessionState.invertColors = this._acc.stateValues.invertColors;
Expand All @@ -83,6 +87,10 @@ var MenuInterface = /*#__PURE__*/function () {
if (this._acc.stateValues.invertColors) {
if (this._acc.stateValues.grayHues) this._acc.menuInterface.grayHues(true);
this._acc.html.style.filter = 'invert(1)';

if (this._acc.stateValues.textToSpeech) {
this._acc.textToSpeech('Colors Inverted');
}
} else {
this._acc.html.style.filter = '';
}
Expand Down Expand Up @@ -119,11 +127,19 @@ var MenuInterface = /*#__PURE__*/function () {

this._acc.onChange(true);

if (this._acc.stateValues.textToSpeech && !this._acc.stateValues.grayHues) this._acc.textToSpeech('Gray Hues Disabled.');
var val;

if (this._acc.stateValues.grayHues) {
val = 'grayscale(1)';
if (this._acc.stateValues.invertColors) this._acc.menuInterface.invertColors(true);

if (this._acc.stateValues.invertColors) {
this.invertColors(true);
}

if (this._acc.stateValues.textToSpeech) {
this._acc.textToSpeech('Gray Hues Enabled.');
}
} else {
val = '';
}
Expand Down Expand Up @@ -174,7 +190,15 @@ var MenuInterface = /*#__PURE__*/function () {
});

this._acc.common.deployedObjects.set('.' + className, true);

if (this._acc.stateValues.textToSpeech) {
this._acc.textToSpeech('Links UnderLined');
}
} else {
if (this._acc.stateValues.textToSpeech) {
this._acc.textToSpeech('Links UnderLine Removed');
}

remove();
}
}
Expand All @@ -200,6 +224,9 @@ var MenuInterface = /*#__PURE__*/function () {
this._acc.onChange(true);

this._acc.html.classList.toggle('_access_cursor');

if (this._acc.stateValues.textToSpeech && this._acc.stateValues.bigCursor) this._acc.textToSpeech('Big Cursor Enabled');
if (this._acc.stateValues.textToSpeech && !this._acc.stateValues.bigCursor) this._acc.textToSpeech('Big Cursor Disabled');
}
}, {
key: "readingGuide",
Expand All @@ -217,6 +244,7 @@ var MenuInterface = /*#__PURE__*/function () {

document.body.removeEventListener('touchmove', this._acc.updateReadGuide, false);
document.body.removeEventListener('mousemove', this._acc.updateReadGuide, false);
if (this._acc.stateValues.textToSpeech) this._acc.textToSpeech('Reading Guide Enabled');
return;
}

Expand All @@ -240,6 +268,7 @@ var MenuInterface = /*#__PURE__*/function () {

document.body.removeEventListener('touchmove', this._acc.updateReadGuide, false);
document.body.removeEventListener('mousemove', this._acc.updateReadGuide, false);
if (this._acc.stateValues.textToSpeech) this._acc.textToSpeech('Reading Guide Disabled');
}
}
}, {
Expand All @@ -248,6 +277,11 @@ var MenuInterface = /*#__PURE__*/function () {
var _this2 = this;

// this.sessionState.textToSpeech = typeof destroy === 'undefined' ? true : false;
var tSpeechList = document.querySelector('._access-menu [data-access-action="textToSpeech"]');
var step1 = document.getElementsByClassName('screen-reader-wrapper-step-1');
var step2 = document.getElementsByClassName('screen-reader-wrapper-step-2');
var step3 = document.getElementsByClassName('screen-reader-wrapper-step-3');

this._acc.onChange(false);

var className = '_access-text-to-speech';
Expand All @@ -258,6 +292,7 @@ var MenuInterface = /*#__PURE__*/function () {
if (style) {
style.parentElement.removeChild(style);
document.removeEventListener('click', _this2.readBind, false);
document.removeEventListener('keyup', _this2.readBind, false);

_this2._acc.common.deployedObjects.remove('.' + className);
}
Expand All @@ -268,25 +303,67 @@ var MenuInterface = /*#__PURE__*/function () {

if (destroy) {
document.querySelector('._access-menu [data-access-action="textToSpeech"]').classList.remove('active');
step1[0].style.background = '#ffffff';
step2[0].style.background = '#ffffff';
step3[0].style.background = '#ffffff';
this._acc.stateValues.textToSpeech = false;
window.speechSynthesis.cancel();
return remove();
}

document.querySelector('._access-menu [data-access-action="textToSpeech"]').classList.toggle('active');
this._acc.stateValues.textToSpeech = !this._acc.stateValues.textToSpeech;
if (this._acc.stateValues.speechRate === 1 && !tSpeechList.classList.contains('active')) {
this._acc.stateValues.textToSpeech = true;

this._acc.textToSpeech('Screen Reader enabled. Reading Pace - Normal');

tSpeechList.classList.add('active');
step1[0].style.background = '#000000';
step2[0].style.background = '#000000';
step3[0].style.background = '#000000';
} else if (this._acc.stateValues.speechRate === 1 && tSpeechList.classList.contains('active')) {
this._acc.stateValues.speechRate = 1.5;

this._acc.textToSpeech('Reading Pace - Fast');

if (this._acc.stateValues.textToSpeech) {
var css = "\n *:hover {\n box-shadow: 2px 2px 2px rgba(180,180,180,0.7);\n }\n ";
step1[0].style.background = '#ffffff';
} else if (this._acc.stateValues.speechRate === 1.5 && tSpeechList.classList.contains('active')) {
this._acc.stateValues.speechRate = 0.7;

this._acc.textToSpeech('Reading Pace - Slow');

step2[0].style.background = '#ffffff';
} else {
this._acc.stateValues.speechRate = 1;

this._acc.textToSpeech('Screen Reader - Disabled');

tSpeechList.classList.remove('active');
step3[0].style.background = '#ffffff';
var timeout = setInterval(function () {
console.log(_this2._acc);

if (_this2._acc.isReading) {
return;
}

_this2._acc.stateValues.textToSpeech = false;
remove();
clearTimeout(timeout);
}, 500);
return;
}

var css = "\n *:hover {\n box-shadow: 2px 2px 2px rgba(180,180,180,0.7);\n }\n ";

if (tSpeechList.classList.contains('active') && this._acc.stateValues.speechRate === 1) {
this._acc.common.injectStyle(css, {
className: className
});

this._acc.common.deployedObjects.set('.' + className, true);

document.addEventListener('click', this.readBind, false);
} else {
remove();
document.addEventListener('keyup', this.readBind, false);
}
}
}, {
Expand Down Expand Up @@ -328,7 +405,6 @@ var MenuInterface = /*#__PURE__*/function () {
return remove();
}

document.querySelector('._access-menu [data-access-action="speechToText"]').classList.toggle('active');
this._acc.stateValues.speechToText = !this._acc.stateValues.speechToText;

if (this._acc.stateValues.speechToText) {
Expand Down Expand Up @@ -574,6 +650,16 @@ var MenuInterface = /*#__PURE__*/function () {
cf.method(cf, true);
}
}
}, {
key: "increaseLineHeight",
value: function increaseLineHeight() {
this._acc.alterLineHeight(true);
}
}, {
key: "decreaseLineHeight",
value: function decreaseLineHeight() {
this._acc.alterLineHeight(false);
}
}]);

return MenuInterface;
Expand Down
Loading