From 904af6f7468b33b98a8460eadc55a674a8795cdb Mon Sep 17 00:00:00 2001 From: Daniel Ferreira Monteiro Alves Date: Thu, 14 Nov 2013 01:50:40 -0200 Subject: [PATCH] Added purl.js typings --- purl/purl-jquery.d.ts | 32 +++++++++++++++++++++++++++ purl/purl.d.ts | 50 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 purl/purl-jquery.d.ts create mode 100644 purl/purl.d.ts diff --git a/purl/purl-jquery.d.ts b/purl/purl-jquery.d.ts new file mode 100644 index 0000000000..55753a1229 --- /dev/null +++ b/purl/purl-jquery.d.ts @@ -0,0 +1,32 @@ +// Type definitions for Purl 2.3.1 +// Project: https://github.com/allmarkedup/purl +// Definitions by: Daniel Ferreira Monteiro Alves +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +interface JQueryStatic { + + /** + * Parse the current page URL + */ + url(): purl.Url; + + /** + * Pass in a URI as a string and parse that + * + * @param someUrl the url to be parsed + */ + url(someUrl: string): purl.Url; + +} + +interface JQuery { + + /** + * extract the URL from the selected element and parse that - will work on any element with a `src`, `href` or `action` attribute. + */ + url(): purl.Url; + +} diff --git a/purl/purl.d.ts b/purl/purl.d.ts new file mode 100644 index 0000000000..e937a68f44 --- /dev/null +++ b/purl/purl.d.ts @@ -0,0 +1,50 @@ +// Type definitions for Purl 2.3.1 +// Project: https://github.com/allmarkedup/purl +// Definitions by: Daniel Ferreira Monteiro Alves +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module purl { + + export interface Url { + + /** + * The .attr() method is used to return information on various parts of the URL. + */ + attr(option: string): string; + + /** + * The .param() method is used to return the values of querystring parameters. + */ + param(parameterName: string): string; + + /** + * The .segment() method is used to return values of individual segments from the URL's path. + * Pass in an integer value to get the value of that segment - note however that the count is not zero-indexed like an array - i.e. .segment(1) returns the first segment, not the second one. + * You can also pass in negative values, in which case it will count back from the end of the path rather than forwards from the start. + */ + segment(position: number): string; + + /** + * Gets a parameter from the fragment segment + */ + fparam(parameterName: string): string; + + /** + * Gets the fragment segment at the especified position. + */ + fsegment(position: number): string; + } + +} + +/** + * Parse the current page URL + */ +declare function purl(): purl.Url; + +/** + * Pass in a URI as a string and parse that + * + * @param someUrl the url to be parsed + */ +declare function purl(someUrl: string): purl.Url;