Fix structure of TS definition file
This commit is contained in:
41
pjax.d.ts
vendored
41
pjax.d.ts
vendored
@@ -1,8 +1,8 @@
|
|||||||
export = class Pjax {
|
declare class Pjax {
|
||||||
constructor(options?: Partial<IOptions>);
|
constructor(options?: Partial<Pjax.IOptions>);
|
||||||
|
|
||||||
static switches: {
|
static switches: {
|
||||||
[key: string]: Switch
|
[key in DefaultSwitches]: Pjax.Switch
|
||||||
};
|
};
|
||||||
|
|
||||||
static isSupported: () => boolean;
|
static isSupported: () => boolean;
|
||||||
@@ -23,30 +23,30 @@ export = class Pjax {
|
|||||||
|
|
||||||
forEachSelectors(cb: ElementFunction, context: Pjax, DOMcontext?: Element | Document): void;
|
forEachSelectors(cb: ElementFunction, context: Pjax, DOMcontext?: Element | Document): void;
|
||||||
|
|
||||||
switchesSelectors(selectors: string[], fromEl: Element | Document, toEl: Element | Document, options: IOptions): void;
|
switchesSelectors(selectors: string[], fromEl: Element | Document, toEl: Element | Document, options: Pjax.IOptions): void;
|
||||||
|
|
||||||
latestChance(href: string): void;
|
latestChance(href: string): void;
|
||||||
|
|
||||||
onSwitch: VoidFunction;
|
onSwitch: VoidFunction;
|
||||||
|
|
||||||
loadContent(html: string, options: IOptions): void;
|
loadContent(html: string, options: Pjax.IOptions): void;
|
||||||
|
|
||||||
abortRequest(request: XMLHttpRequest): void;
|
abortRequest(request: XMLHttpRequest): void;
|
||||||
|
|
||||||
doRequest(location: string, options: IOptions | null,
|
doRequest(location: string, options: Pjax.IOptions | null,
|
||||||
callback: (requestText: string, request: XMLHttpRequest, href: string) => void): XMLHttpRequest;
|
callback: (requestText: string, request: XMLHttpRequest, href: string) => void): XMLHttpRequest;
|
||||||
|
|
||||||
handleResponse(requestText: string, request: XMLHttpRequest, href: string): void;
|
handleResponse(requestText: string, request: XMLHttpRequest, href: string): void;
|
||||||
|
|
||||||
loadUrl(href: string, options?: IOptions): void;
|
loadUrl(href: string, options?: Pjax.IOptions): void;
|
||||||
|
|
||||||
afterAllSwitches: VoidFunction;
|
afterAllSwitches: VoidFunction;
|
||||||
|
|
||||||
|
// Allows reassignment of existing prototype functions to be able to do something before calling the original function
|
||||||
|
[key: string]: Function;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface StringKeyedObject<T = any> {
|
declare namespace Pjax {
|
||||||
[key: string]: T
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IOptions {
|
export interface IOptions {
|
||||||
elements: string;
|
elements: string;
|
||||||
selectors: string[];
|
selectors: string[];
|
||||||
@@ -54,14 +54,27 @@ export interface IOptions {
|
|||||||
switchesOptions: StringKeyedObject;
|
switchesOptions: StringKeyedObject;
|
||||||
history: boolean;
|
history: boolean;
|
||||||
analytics: Function | false;
|
analytics: Function | false;
|
||||||
scrollTo: number | number[] | false;
|
scrollTo: number | [number, number] | false;
|
||||||
scrollRestoration: boolean;
|
scrollRestoration: boolean;
|
||||||
cacheBust: boolean;
|
cacheBust: boolean;
|
||||||
debug: boolean;
|
debug: boolean;
|
||||||
timeout: number
|
timeout: number;
|
||||||
currentUrlFullReload: boolean;
|
currentUrlFullReload: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Switch = (oldEl: Element, newEl: Element, options?: IOptions, switchesOptions?: StringKeyedObject) => void;
|
export type Switch = (oldEl: Element, newEl: Element, options?: IOptions, switchesOptions?: StringKeyedObject) => void;
|
||||||
|
}
|
||||||
|
|
||||||
export type ElementFunction = (el: Element) => void;
|
interface StringKeyedObject<T = any> {
|
||||||
|
[key: string]: T
|
||||||
|
}
|
||||||
|
|
||||||
|
type ElementFunction = (el: Element) => void;
|
||||||
|
|
||||||
|
declare enum DefaultSwitches {
|
||||||
|
innerHTML = "innerHTML",
|
||||||
|
ouetrHTML = "outerHTML",
|
||||||
|
sideBySide = "sideBySide"
|
||||||
|
}
|
||||||
|
|
||||||
|
export = Pjax;
|
||||||
|
|||||||
Reference in New Issue
Block a user