mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 21:00:01 +08:00
Added purl.js typings
This commit is contained in:
32
purl/purl-jquery.d.ts
vendored
Normal file
32
purl/purl-jquery.d.ts
vendored
Normal 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
50
purl/purl.d.ts
vendored
Normal 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;
|
||||
Reference in New Issue
Block a user