/// import "../scss/OnOffSwitch.scss"; export interface IOnOffSwitchParams { /** * Reference to checkbox element */ el: JQuery; /** * Text for "on" state */ textOn: string; /** * Test for "off" state */ textOff: string; /** * Width of On/Off switch - default: measured by text width */ width?: number; /** * Height of On/Off switch - default = 30 */ height?: number; trackBorderWidth?: number; trackColorOn?: string; trackColorOff?: string; /** * Optional text color for "on" state */ textColorOn?: string; /** * Optional text color for "off" state */ textColorOff?: string; trackBorderColor?: string; /** * Fine tuning of text size. default: 0.4 */ textSizeRatio?: number; /** * Check/Uncheck listener */ listener: (checked: boolean, name: string) => void; } export default class OnOffSwitch { private static switches; private inputEl; private el; private track; private thumb; private thumbColor; private trackOff; private onTextEl; private onOffTrackContainer; private trackOn; private offTextEl; private name; private _checked; private isCheckbox; private innerTrackWidth; private params; private maxX; private borderSize; private minX; private dragListener; private dragEndListener; hasBeenDragged: boolean; private dragCurrentX; private startCoordinates; constructor(params: IOnOffSwitchParams); private width; private readonly trackBorderWidth; private readonly height; private readonly trackBorderColor; private readonly textColorOff; private readonly textColorOn; private readonly textSizeRatio; private readonly trackColorOff; private readonly trackColorOn; private render; private addEvents; private listenToClickEvent; private enterThumb; leaveThumb(): void; renderTrack(): void; private styleText; renderThumb(): void; getBorderSize(): number; private applyStyles; private startDragging; private drag; private getX; private endDrag; private getTrackPosUnchecked; private animateLeft; private animateRight; private check; private uncheck; private toggle; private notifyListeners; /** * checked setter */ checked: boolean; readonly $: JQuery; }