diff --git a/index.d.ts b/index.d.ts
index 513ea39..f7e8ccc 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -5,6 +5,9 @@ declare class Pjax {
[key in DefaultSwitches]: Pjax.Switch
};
+ /**
+ * Checks if Pjax is supported by the environment.
+ */
static isSupported: () => boolean;
log: VoidFunction;
@@ -29,36 +32,139 @@ declare class Pjax {
onSwitch: VoidFunction;
+ /**
+ * Loads the HTML from the response into the DOM.
+ *
+ * @param {string} html
+ * @param {Pjax.IOptions} options
+ */
loadContent(html: string, options: Pjax.IOptions): void;
+ /**
+ * Aborts an ongoing XHR request.
+ *
+ * @param {XMLHttpRequest} request
+ */
abortRequest(request: XMLHttpRequest): void;
+ /**
+ * Makes the XHR request.
+ *
+ * @param {string} location The URI for the request.
+ * @param {Pjax.IOptions | null} options
+ * @param {(requestText: string, request: XMLHttpRequest, href: string) => void} callback The callback to call when
+ * the response is received. The signature should match that of handleResponse.
+ * @returns {XMLHttpRequest}
+ */
doRequest(location: string, options: Pjax.IOptions | null,
callback: (requestText: string, request: XMLHttpRequest, href: string) => void): XMLHttpRequest;
+ /**
+ * Saves the state, updates the URL if there were any redirects, then calls loadContent().
+ *
+ * @param {string} requestText The raw text of the response. Same as request.responseText.
+ * @param {XMLHttpRequest} request The XHR object.
+ * @param {string} href The original URI used to initiate the request.
+ */
handleResponse(requestText: string, request: XMLHttpRequest, href: string): void;
+ /**
+ * Initiates the request by calling doRequest().
+ * @param {string} href
+ * @param {Pjax.IOptions} options
+ */
loadUrl(href: string, options?: Pjax.IOptions): void;
+ /**
+ * Called after all switches complete (even async).
+ */
afterAllSwitches: VoidFunction;
- // Allows reassignment of existing prototype functions to be able to do something before calling the original function
+ /**
+ * Allows reassignment of existing prototype functions to be able to do something before calling the original function.
+ * For example:
+ *
+ *
+ * pjax._handleResponse = pjax.handleResponse;
+ * pjax.handleResponse = (requestText: string, request: XMLHttpRequest, href: string) => {
+ * return pjax._handleResponse(requestText, request, href);
+ * }
+ *
+ */
[key: string]: Function;
}
declare namespace Pjax {
export interface IOptions {
+ /**
+ * CSS selector to use to retrieve links to apply Pjax to.
+ */
elements: string;
+
+ /**
+ * CSS selectors for the elements to replace.
+ */
selectors: string[];
+
+ /**
+ * Objects containing callbacks that can be used to switch old elements with new elements.
+ * Keys should be one of the defined selectors.
+ */
switches: StringKeyedObject