From b5ad8ed044d94ef05f3a6a3d4b0adc6cd7dcb34d Mon Sep 17 00:00:00 2001 From: Junle Li Date: Sun, 15 Jun 2014 23:47:40 +0800 Subject: [PATCH 01/15] Add empty jquery.pjax definition and test file. --- jquery.pjax/jquery.pjax-tests.ts | 0 jquery.pjax/jquery.pjax.d.ts | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 jquery.pjax/jquery.pjax-tests.ts create mode 100644 jquery.pjax/jquery.pjax.d.ts diff --git a/jquery.pjax/jquery.pjax-tests.ts b/jquery.pjax/jquery.pjax-tests.ts new file mode 100644 index 000000000..e69de29bb diff --git a/jquery.pjax/jquery.pjax.d.ts b/jquery.pjax/jquery.pjax.d.ts new file mode 100644 index 000000000..e69de29bb From 1366742ab46eb5347f36845129ad0f504dc58ae2 Mon Sep 17 00:00:00 2001 From: Junle Li Date: Mon, 16 Jun 2014 01:23:02 +0800 Subject: [PATCH 02/15] 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; +} From 3487faa4eac104bcc886057cdbd8bbcd06435f6c Mon Sep 17 00:00:00 2001 From: Junle Date: Mon, 16 Jun 2014 01:53:56 +0800 Subject: [PATCH 03/15] Fix the asterisk bug and a trivial bug. --- jquery.pjax/jquery.pjax.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jquery.pjax/jquery.pjax.d.ts b/jquery.pjax/jquery.pjax.d.ts index ccab8bee5..96db1a525 100644 --- a/jquery.pjax/jquery.pjax.d.ts +++ b/jquery.pjax/jquery.pjax.d.ts @@ -4,10 +4,10 @@ /// 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 `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: @@ -18,10 +18,10 @@ interface JQuery { */ 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 `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). From baca62733abd8b23755838c0b9d4a2bbbc27beaa Mon Sep 17 00:00:00 2001 From: Junle Date: Mon, 16 Jun 2014 02:00:21 +0800 Subject: [PATCH 04/15] Add PjaxSettings extending from JQueryAjaxSettings. --- jquery.pjax/jquery.pjax.d.ts | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/jquery.pjax/jquery.pjax.d.ts b/jquery.pjax/jquery.pjax.d.ts index 96db1a525..e4f7bedc2 100644 --- a/jquery.pjax/jquery.pjax.d.ts +++ b/jquery.pjax/jquery.pjax.d.ts @@ -3,6 +3,25 @@ /// +interface PjaxSettings extends JQueryAjaxSettings { + /** + * A jQuery selector indicates where to stick the response body. E.g., $(container).html(xhr.responseBody). + * If it 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 will be treated as container. + */ + container?: string; + + /** + * Whether to pushState the URL. Defaults to true. + */ + push?: boolean; + + /** + * Whether to replaceState the URL. Defaults to false. + */ + replace?: boolean; +} + interface JQuery { /** * Tell PJAX to listen links with delegation selector that, when click on them, fetches the href with ajax into the container. @@ -16,7 +35,7 @@ interface JQuery { * - replace: Want to use replaceState instead? That's cool. * @return Returns the jQuery object */ - pjax(delegationSelector: string, options?: JQueryAjaxSettings): JQuery; + pjax(delegationSelector: string, options?: PjaxSettings): JQuery; /** * Tell PJAX to listen links with delegation selector that, when click on them, fetches the href with ajax into the container. @@ -31,5 +50,5 @@ interface JQuery { * - replace: Want to use replaceState instead? That's cool. * @return Returns the jQuery object */ - pjax(delegationSelector: string, containerSelector?: string, options?: JQueryAjaxSettings): JQuery; + pjax(delegationSelector: string, containerSelector?: string, options?: PjaxSettings): JQuery; } From 019525512bf31c8880d653971226274bac64b514 Mon Sep 17 00:00:00 2001 From: Junle Date: Mon, 16 Jun 2014 02:09:24 +0800 Subject: [PATCH 05/15] Format the test file. --- jquery.pjax/jquery.pjax-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jquery.pjax/jquery.pjax-tests.ts b/jquery.pjax/jquery.pjax-tests.ts index 710a8f9e7..c0a9de43b 100644 --- a/jquery.pjax/jquery.pjax-tests.ts +++ b/jquery.pjax/jquery.pjax-tests.ts @@ -4,6 +4,6 @@ function test_fn_pjax() { $(document).pjax("a"); $(document).pjax("a", "#pjax-container"); - $(document).pjax("a", {push: true}); - $(document).pjax("a", "#pjax-container", {push: true}); + $(document).pjax("a", { push: true }); + $(document).pjax("a", "#pjax-container", { push: true }); } From 6da3e2f5751f8c9e0a192d139192e3a6ee2d810b Mon Sep 17 00:00:00 2001 From: Junle Date: Wed, 18 Jun 2014 16:12:26 +0800 Subject: [PATCH 06/15] Refine the definition of $.fn.pjax method. --- jquery.pjax/jquery.pjax.d.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/jquery.pjax/jquery.pjax.d.ts b/jquery.pjax/jquery.pjax.d.ts index e4f7bedc2..e9932f465 100644 --- a/jquery.pjax/jquery.pjax.d.ts +++ b/jquery.pjax/jquery.pjax.d.ts @@ -29,10 +29,10 @@ interface JQuery { * 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. + * @param options PJAX settings, which is a superset of jQuery AJAX settings. It includes the following specific options: + * - container: a jQuery selector indicates where to stick the response body. E.g., $(container).html(xhr.responseBody). + * - push: a boolean indicates whether to pushState the URL. Default is true. + * - replace: a boolean indicates whether to use replaceState instead of pushState. Default is false. * @return Returns the jQuery object */ pjax(delegationSelector: string, options?: PjaxSettings): JQuery; @@ -43,11 +43,11 @@ interface JQuery { * 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. + * @param containerSelector A jQuery selector indicates where to stick the response body. E.g., $(containerSelector).html(xhr.responseBody). + * @param options PJAX settings, which is a superset of jQuery AJAX settings. It includes the following specific options: + * - container: a jQuery selector indicates where to stick the response body. The `containerSelector` parameter has priority. + * - push: a boolean indicates whether to pushState the URL. Default is true. + * - replace: a boolean indicates whether to use replaceState instead of pushState. Default is false. * @return Returns the jQuery object */ pjax(delegationSelector: string, containerSelector?: string, options?: PjaxSettings): JQuery; From 0e5cb0478f5ad936b8dc7f9addfb6a763148513b Mon Sep 17 00:00:00 2001 From: Junle Date: Wed, 18 Jun 2014 16:12:59 +0800 Subject: [PATCH 07/15] Add definition and test for $.pjax.click function. --- jquery.pjax/jquery.pjax-tests.ts | 7 +++++++ jquery.pjax/jquery.pjax.d.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/jquery.pjax/jquery.pjax-tests.ts b/jquery.pjax/jquery.pjax-tests.ts index c0a9de43b..e5076a5a9 100644 --- a/jquery.pjax/jquery.pjax-tests.ts +++ b/jquery.pjax/jquery.pjax-tests.ts @@ -7,3 +7,10 @@ function test_fn_pjax() { $(document).pjax("a", { push: true }); $(document).pjax("a", "#pjax-container", { push: true }); } + +function test_click() { + var event = $.Event("click"); + $.pjax.click(event, "#pjax-container"); + $.pjax.click(event, { container: "#pjax-container" }); + $.pjax.click(event, "#pjax-container", { push: true }); +} diff --git a/jquery.pjax/jquery.pjax.d.ts b/jquery.pjax/jquery.pjax.d.ts index e9932f465..aaeecf7d5 100644 --- a/jquery.pjax/jquery.pjax.d.ts +++ b/jquery.pjax/jquery.pjax.d.ts @@ -52,3 +52,30 @@ interface JQuery { */ pjax(delegationSelector: string, containerSelector?: string, options?: PjaxSettings): JQuery; } + +interface JQueryStatic { + pjax: PjaxStatic; +} + +interface PjaxStatic { + /** + * PJAX on click handler. + * @param event A jQuery click event. + * @param options PJAX settings, which is a superset of jQuery AJAX settings. It includes the following specific options: + * - container: a jQuery selector indicates where to stick the response body. E.g., $(container).html(xhr.responseBody). + * - push: a boolean indicates whether to pushState the URL. Default is true. + * - replace: a boolean indicates whether to use replaceState instead of pushState. Default is false. + */ + click(event: JQueryEventObject, options?: PjaxSettings): void; + + /** + * PJAX on click handler. + * @param event A jQuery click event. + * @param containerSelector A jQuery selector indicates where to stick the response body. E.g., $(containerSelector).html(xhr.responseBody). + * @param options PJAX settings, which is a superset of jQuery AJAX settings. It includes the following specific options: + * - container: a jQuery selector indicates where to stick the response body. The `containerSelector` parameter has priority. + * - push: a boolean indicates whether to pushState the URL. Default is true. + * - replace: a boolean indicates whether to use replaceState instead of pushState. Default is false. + */ + click(event: JQueryEventObject, containerSelector?: string, options?: PjaxSettings): void; +} From 37d2280a3d4441610ba1419111260d963ec905d1 Mon Sep 17 00:00:00 2001 From: Junle Date: Wed, 18 Jun 2014 16:16:01 +0800 Subject: [PATCH 08/15] Add definition and test for $.pjax.submit function. It is nearly same with $.pjax.click function. --- jquery.pjax/jquery.pjax-tests.ts | 7 +++++++ jquery.pjax/jquery.pjax.d.ts | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/jquery.pjax/jquery.pjax-tests.ts b/jquery.pjax/jquery.pjax-tests.ts index e5076a5a9..4d3c18591 100644 --- a/jquery.pjax/jquery.pjax-tests.ts +++ b/jquery.pjax/jquery.pjax-tests.ts @@ -14,3 +14,10 @@ function test_click() { $.pjax.click(event, { container: "#pjax-container" }); $.pjax.click(event, "#pjax-container", { push: true }); } + +function test_submit() { + var event = $.Event("submit"); + $.pjax.submit(event, "#pjax-container"); + $.pjax.submit(event, { container: "#pjax-container" }); + $.pjax.submit(event, "#pjax-container", { push: true }); +} diff --git a/jquery.pjax/jquery.pjax.d.ts b/jquery.pjax/jquery.pjax.d.ts index aaeecf7d5..b773dd461 100644 --- a/jquery.pjax/jquery.pjax.d.ts +++ b/jquery.pjax/jquery.pjax.d.ts @@ -78,4 +78,25 @@ interface PjaxStatic { * - replace: a boolean indicates whether to use replaceState instead of pushState. Default is false. */ click(event: JQueryEventObject, containerSelector?: string, options?: PjaxSettings): void; + + /** + * PJAX on form submit handler + * @param event A jQuery click event. + * @param options PJAX settings, which is a superset of jQuery AJAX settings. It includes the following specific options: + * - container: a jQuery selector indicates where to stick the response body. E.g., $(container).html(xhr.responseBody). + * - push: a boolean indicates whether to pushState the URL. Default is true. + * - replace: a boolean indicates whether to use replaceState instead of pushState. Default is false. + */ + submit(event: JQueryEventObject, options?: PjaxSettings): void; + + /** + * PJAX on form submit handler + * @param event A jQuery click event. + * @param containerSelector A jQuery selector indicates where to stick the response body. E.g., $(containerSelector).html(xhr.responseBody). + * @param options PJAX settings, which is a superset of jQuery AJAX settings. It includes the following specific options: + * - container: a jQuery selector indicates where to stick the response body. The `containerSelector` parameter has priority. + * - push: a boolean indicates whether to pushState the URL. Default is true. + * - replace: a boolean indicates whether to use replaceState instead of pushState. Default is false. + */ + submit(event: JQueryEventObject, containerSelector?: string, options?: PjaxSettings): void; } From 2b42566ccac817280e5742626b225851b889c5b3 Mon Sep 17 00:00:00 2001 From: Junle Date: Wed, 18 Jun 2014 16:31:28 +0800 Subject: [PATCH 09/15] Add definition and test for $.pjax function. --- jquery.pjax/jquery.pjax-tests.ts | 8 ++++++++ jquery.pjax/jquery.pjax.d.ts | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/jquery.pjax/jquery.pjax-tests.ts b/jquery.pjax/jquery.pjax-tests.ts index 4d3c18591..f394e7030 100644 --- a/jquery.pjax/jquery.pjax-tests.ts +++ b/jquery.pjax/jquery.pjax-tests.ts @@ -8,6 +8,14 @@ function test_fn_pjax() { $(document).pjax("a", "#pjax-container", { push: true }); } +function test_pjax() { + $.pjax(); + $.pjax({ + url: "hello.html", + container: "#main" + }); +} + function test_click() { var event = $.Event("click"); $.pjax.click(event, "#pjax-container"); diff --git a/jquery.pjax/jquery.pjax.d.ts b/jquery.pjax/jquery.pjax.d.ts index b773dd461..88118224d 100644 --- a/jquery.pjax/jquery.pjax.d.ts +++ b/jquery.pjax/jquery.pjax.d.ts @@ -58,6 +58,16 @@ interface JQueryStatic { } interface PjaxStatic { + /** + * Loads a URL with ajax, puts the response body inside a container, then pushState()'s the loaded URL. + * Works just like $.ajax in that it accepts a jQuery ajax settings object (with keys like url, type, data, etc). + * @param options PJAX settings, which is a superset of jQuery AJAX settings. It includes the following specific options: + * - container: a jQuery selector indicates where to stick the response body. E.g., $(container).html(xhr.responseBody). + * - push: a boolean indicates whether to pushState the URL. Default is true. + * - replace: a boolean indicates whether to use replaceState instead of pushState. Default is false. + */ + (options?: PjaxSettings): JQueryXHR; + /** * PJAX on click handler. * @param event A jQuery click event. From 1912ed033413465999718abb03ec06e9f7f8ced1 Mon Sep 17 00:00:00 2001 From: Junle Date: Wed, 18 Jun 2014 16:37:18 +0800 Subject: [PATCH 10/15] Add definition for $.pjax.enable and $.pjax.disable. --- jquery.pjax/jquery.pjax-tests.ts | 8 ++++++++ jquery.pjax/jquery.pjax.d.ts | 13 ++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/jquery.pjax/jquery.pjax-tests.ts b/jquery.pjax/jquery.pjax-tests.ts index f394e7030..d5a9e1bb1 100644 --- a/jquery.pjax/jquery.pjax-tests.ts +++ b/jquery.pjax/jquery.pjax-tests.ts @@ -29,3 +29,11 @@ function test_submit() { $.pjax.submit(event, { container: "#pjax-container" }); $.pjax.submit(event, "#pjax-container", { push: true }); } + +function test_enable() { + $.pjax.enable(); +} + +function test_disable() { + $.pjax.disable(); +} diff --git a/jquery.pjax/jquery.pjax.d.ts b/jquery.pjax/jquery.pjax.d.ts index 88118224d..f26d69443 100644 --- a/jquery.pjax/jquery.pjax.d.ts +++ b/jquery.pjax/jquery.pjax.d.ts @@ -88,7 +88,7 @@ interface PjaxStatic { * - replace: a boolean indicates whether to use replaceState instead of pushState. Default is false. */ click(event: JQueryEventObject, containerSelector?: string, options?: PjaxSettings): void; - + /** * PJAX on form submit handler * @param event A jQuery click event. @@ -109,4 +109,15 @@ interface PjaxStatic { * - replace: a boolean indicates whether to use replaceState instead of pushState. Default is false. */ submit(event: JQueryEventObject, containerSelector?: string, options?: PjaxSettings): void; + + /** + * Install pjax functions on $.pjax to enable pushState behavior. Does nothing if already enabled. + */ + enable(): void; + + /** + * Disable pushState behavior. + * This is the case when a browser doesn't support pushState. It is sometimes useful to disable pushState for debugging on a modern browser. + */ + disable(): void; } From 0af5dfd73ba3fc4071492be0ab0657aa4aaa5f5f Mon Sep 17 00:00:00 2001 From: Junle Date: Wed, 18 Jun 2014 16:40:00 +0800 Subject: [PATCH 11/15] Add definition and test for $.pjax.reload method. --- jquery.pjax/jquery.pjax-tests.ts | 4 ++++ jquery.pjax/jquery.pjax.d.ts | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/jquery.pjax/jquery.pjax-tests.ts b/jquery.pjax/jquery.pjax-tests.ts index d5a9e1bb1..b821ee14d 100644 --- a/jquery.pjax/jquery.pjax-tests.ts +++ b/jquery.pjax/jquery.pjax-tests.ts @@ -37,3 +37,7 @@ function test_enable() { function test_disable() { $.pjax.disable(); } + +function test_reload() { + $.pjax.reload(); +} diff --git a/jquery.pjax/jquery.pjax.d.ts b/jquery.pjax/jquery.pjax.d.ts index f26d69443..51e059a2b 100644 --- a/jquery.pjax/jquery.pjax.d.ts +++ b/jquery.pjax/jquery.pjax.d.ts @@ -120,4 +120,9 @@ interface PjaxStatic { * This is the case when a browser doesn't support pushState. It is sometimes useful to disable pushState for debugging on a modern browser. */ disable(): void; + + /** + * Reload current page with pjax. + */ + reload(): JQueryXHR; } From 0040e5a97e8add789c9e7271b2a9a11bc9f53ba0 Mon Sep 17 00:00:00 2001 From: Junle Date: Wed, 18 Jun 2014 16:43:24 +0800 Subject: [PATCH 12/15] Add definition and test for $.pjax.defaults property. --- jquery.pjax/jquery.pjax-tests.ts | 13 +++++++++++++ jquery.pjax/jquery.pjax.d.ts | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/jquery.pjax/jquery.pjax-tests.ts b/jquery.pjax/jquery.pjax-tests.ts index b821ee14d..796b4bf91 100644 --- a/jquery.pjax/jquery.pjax-tests.ts +++ b/jquery.pjax/jquery.pjax-tests.ts @@ -41,3 +41,16 @@ function test_disable() { function test_reload() { $.pjax.reload(); } + +function test_defauluts() { + $.pjax.defaults = { + timeout: 650, + push: true, + replace: false, + type: 'GET', + dataType: 'html', + scrollTo: 0, + maxCacheLength: 20, + version: $.noop + }; +} diff --git a/jquery.pjax/jquery.pjax.d.ts b/jquery.pjax/jquery.pjax.d.ts index 51e059a2b..82ab34020 100644 --- a/jquery.pjax/jquery.pjax.d.ts +++ b/jquery.pjax/jquery.pjax.d.ts @@ -58,6 +58,11 @@ interface JQueryStatic { } interface PjaxStatic { + /** + * PJAX default settings. + */ + defaults: PjaxSettings; + /** * Loads a URL with ajax, puts the response body inside a container, then pushState()'s the loaded URL. * Works just like $.ajax in that it accepts a jQuery ajax settings object (with keys like url, type, data, etc). From 5e08d655f17aa3d8ad979782cdb9e110c6d0f523 Mon Sep 17 00:00:00 2001 From: Junle Date: Wed, 18 Jun 2014 16:46:16 +0800 Subject: [PATCH 13/15] Add definition and test for $.support.pjax property. --- jquery.pjax/jquery.pjax-tests.ts | 4 ++++ jquery.pjax/jquery.pjax.d.ts | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/jquery.pjax/jquery.pjax-tests.ts b/jquery.pjax/jquery.pjax-tests.ts index 796b4bf91..214bb3922 100644 --- a/jquery.pjax/jquery.pjax-tests.ts +++ b/jquery.pjax/jquery.pjax-tests.ts @@ -54,3 +54,7 @@ function test_defauluts() { version: $.noop }; } + +function test_support() { + console.log($.support.pjax); +} diff --git a/jquery.pjax/jquery.pjax.d.ts b/jquery.pjax/jquery.pjax.d.ts index 82ab34020..cb9ed59c2 100644 --- a/jquery.pjax/jquery.pjax.d.ts +++ b/jquery.pjax/jquery.pjax.d.ts @@ -131,3 +131,10 @@ interface PjaxStatic { */ reload(): JQueryXHR; } + +interface JQuerySupport { + /** + * A boolean value indicates if pjax is supported by the browser. + */ + pjax: boolean; +} From 1eff13e6075e53399e1c5c8a0daa556c6f1a2644 Mon Sep 17 00:00:00 2001 From: Junle Date: Wed, 18 Jun 2014 16:56:57 +0800 Subject: [PATCH 14/15] Update definition file header. --- jquery.pjax/jquery.pjax.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jquery.pjax/jquery.pjax.d.ts b/jquery.pjax/jquery.pjax.d.ts index cb9ed59c2..621d87d21 100644 --- a/jquery.pjax/jquery.pjax.d.ts +++ b/jquery.pjax/jquery.pjax.d.ts @@ -1,5 +1,7 @@ // Type definitions for jquery-pjax // Project: https://github.com/defunkt/jquery-pjax +// Definitions by: Junle Li +// Definitions: https://github.com/borisyankov/DefinitelyTyped /// From 7d85fd5e1c7c76872d06b4ee2f3c944fc2e337fb Mon Sep 17 00:00:00 2001 From: Junle Date: Thu, 19 Jun 2014 14:04:13 +0800 Subject: [PATCH 15/15] Write my name on CONTRIBUTORS.md :) --- CONTRIBUTORS.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 4c2fbc8e1..04a81d6ca 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -155,9 +155,11 @@ All definitions files include a header with the author and editors, so at some p * [jQuery.joyride](http://zurb.com/playground/jquery-joyride-feature-tour-plugin) (by [Vincent Bortone](https://github.com/vbortone)) * [jQuery.jSignature](https://github.com/willowsystems/jSignature) (by [Patrick Magee](https://github.com/pjmagee)) * [jQuery.noty](http://needim.github.io/noty/) (by [Aaron King](https://github.com/kingdango/)) -* [jQuery.pickadate](https://github.com/amsul/pickadate.js) (by [Theodore Brown](https://github.com/theodorejb)) * [jQuery.payment](http://needim.github.io/noty/) (by [Eric J. Smith](https://github.com/ejsmith/)) +* [jQuery.pickadate](https://github.com/amsul/pickadate.js) (by [Theodore Brown](https://github.com/theodorejb)) +* [jQuery.pjax](https://github.com/defunkt/jquery-pjax) (by [Junle Li](https://github.com/lijunle)) * [jQuery.pnotify](http://sciactive.github.io/pnotify/) (by [David Sichau](https://github.com/DavidSichau/)) +* [jQuery.postMessage](http://benalman.com/projects/jquery-postmessage-plugin/) (by [Junle Li](https://github.com/lijunle)) * [jQuery.scrollTo](https://github.com/flesler/jquery.scrollTo) (by [Neil Stalker](https://github.com/nestalk/)) * [jQuery.simplePagination](https://github.com/flaviusmatis/simplePagination.js) (by [Natan Vivo](https://github.com/nvivo/)) * [jquery.superLink](http://james.padolsey.com/demos/plugins/jQuery/superLink/superlink.jquery.js) (by [Blake Niemyjski](https://github.com/niemyjski))