Added purl.js typings

This commit is contained in:
Daniel Ferreira Monteiro Alves
2013-11-14 01:50:40 -02:00
parent 66217f714d
commit 904af6f746
2 changed files with 82 additions and 0 deletions

32
purl/purl-jquery.d.ts vendored Normal file
View File

@@ -0,0 +1,32 @@
// Type definitions for Purl 2.3.1
// Project: https://github.com/allmarkedup/purl
// Definitions by: Daniel Ferreira Monteiro Alves <https://github.com/danfma>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../jquery/jquery.d.ts" />
/// <reference path="purl.d.ts" />
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;
}

50
purl/purl.d.ts vendored Normal file
View File

@@ -0,0 +1,50 @@
// Type definitions for Purl 2.3.1
// Project: https://github.com/allmarkedup/purl
// Definitions by: Daniel Ferreira Monteiro Alves <https://github.com/danfma>
// 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;