From 1366742ab46eb5347f36845129ad0f504dc58ae2 Mon Sep 17 00:00:00 2001 From: Junle Li Date: Mon, 16 Jun 2014 01:23:02 +0800 Subject: [PATCH] Add definition and test for jquery.fn.pjax method. --- jquery.pjax/jquery.pjax-tests.ts | 9 ++++++++ jquery.pjax/jquery.pjax.d.ts | 35 ++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/jquery.pjax/jquery.pjax-tests.ts b/jquery.pjax/jquery.pjax-tests.ts index e69de29bb..710a8f9e7 100644 --- a/jquery.pjax/jquery.pjax-tests.ts +++ b/jquery.pjax/jquery.pjax-tests.ts @@ -0,0 +1,9 @@ +/// +/// + +function test_fn_pjax() { + $(document).pjax("a"); + $(document).pjax("a", "#pjax-container"); + $(document).pjax("a", {push: true}); + $(document).pjax("a", "#pjax-container", {push: true}); +} diff --git a/jquery.pjax/jquery.pjax.d.ts b/jquery.pjax/jquery.pjax.d.ts index e69de29bb..ccab8bee5 100644 --- a/jquery.pjax/jquery.pjax.d.ts +++ b/jquery.pjax/jquery.pjax.d.ts @@ -0,0 +1,35 @@ +// Type definitions for jquery-pjax +// Project: https://github.com/defunkt/jquery-pjax + +/// + +interface JQuery { + /* + * Tell PJAX to listen links with delegation selector that, when click on them, fetches the href with ajax into the container. + * Tries to make sure the back button and ctrl+click work the way you'd expect. + * If `options.container` is not defined, the `data-pjax` attribute of the link will be treated as container, + * If such an attribute is not defined too, the context runs with this statement will be treated as container. + * @param delegationSelector The selector to limit which links PJAX should listen on. + * @param options A valid jQuery ajax options object that may include these pjax specific options: + * - container: A jQuery selector indicates where to stick the response body. E.g., $(container).html(xhr.responseBody). + * - push: Whether to pushState the URL. Defaults to true (of course). + * - replace: Want to use replaceState instead? That's cool. + * @return Returns the jQuery object + */ + pjax(delegationSelector: string, options?: JQueryAjaxSettings): JQuery; + + /* + * Tell PJAX to listen links with delegation selector that, when click on them, fetches the href with ajax into the container. + * Tries to make sure the back button and ctrl+click work the way you'd expect. + * If `options.container` is not defined, the `data-pjax` attribute of the link will be treated as container, + * If such an attribute is not defined too, the context runs with this statement will be treated as container. + * @param delegationSelector The selector to limit which links PJAX should listen on. + * @param containerSelector A jQuery selector indicates where to stick the response body. E.g., $(container).html(xhr.responseBody). + * @param options A valid jQuery ajax options object that may include these pjax specific options: + * - container: A jQuery selector indicates where to stick the response body. The containerSelector has priority. + * - push: Whether to pushState the URL. Defaults to true (of course). + * - replace: Want to use replaceState instead? That's cool. + * @return Returns the jQuery object + */ + pjax(delegationSelector: string, containerSelector?: string, options?: JQueryAjaxSettings): JQuery; +}