mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Merge branch 'master' into rename-repo-url
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/// <reference path="navigation.d.ts" />
|
||||
|
||||
module NavigationTests {
|
||||
namespace NavigationTests {
|
||||
// History Manager
|
||||
class LogHistoryManager extends Navigation.HashHistoryManager {
|
||||
addHistory(state: Navigation.State, url: string) {
|
||||
@@ -8,20 +8,20 @@ module NavigationTests {
|
||||
super.addHistory(state, url);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Crumb Trail Persister
|
||||
class LogCrumbTrailPersister extends Navigation.CrumbTrailPersister {
|
||||
load(crumbTrail: string): string {
|
||||
console.log('load');
|
||||
return crumbTrail;
|
||||
}
|
||||
|
||||
|
||||
save(crumbTrail: string): string {
|
||||
console.log('save');
|
||||
return crumbTrail;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// State Router
|
||||
class LogStateRouter extends Navigation.StateRouter {
|
||||
getData(route: string): { state: Navigation.State; data: any } {
|
||||
@@ -29,13 +29,13 @@ module NavigationTests {
|
||||
return super.getData(route);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Settings
|
||||
Navigation.settings.router = new LogStateRouter();
|
||||
Navigation.settings.historyManager = new LogHistoryManager();
|
||||
Navigation.settings.crumbTrailPersister = new LogCrumbTrailPersister();
|
||||
Navigation.settings.stateIdKey = 'state';
|
||||
|
||||
|
||||
// Configuration
|
||||
Navigation.StateInfoConfig.build([
|
||||
{ key: 'home', initial: 'page', help: 'home.htm', states: [
|
||||
@@ -48,7 +48,7 @@ module NavigationTests {
|
||||
{ key: 'details', route: 'person/{id}', trackTypes: false, defaultTypes: { id: 'number' } }
|
||||
]}
|
||||
]);
|
||||
|
||||
|
||||
// StateInfo
|
||||
var dialogs = Navigation.StateInfoConfig.dialogs;
|
||||
var home = dialogs['home'];
|
||||
@@ -64,7 +64,7 @@ module NavigationTests {
|
||||
personDetails = personListSelect.to;
|
||||
var pageDefault = personList.defaults.page;
|
||||
var idDefaultType = personDetails.defaultTypes.id;
|
||||
|
||||
|
||||
// StateNavigator
|
||||
personList.dispose = () => {};
|
||||
personList.navigating = (data, url, navigate) => {
|
||||
@@ -75,7 +75,7 @@ module NavigationTests {
|
||||
navigate();
|
||||
};
|
||||
personDetails.navigated = (data) => {};
|
||||
|
||||
|
||||
// State Handler
|
||||
class LogStateHandler extends Navigation.StateHandler {
|
||||
getNavigationLink(state: Navigation.State, data: any): string {
|
||||
@@ -96,14 +96,14 @@ module NavigationTests {
|
||||
homePage.stateHandler = new LogStateHandler();
|
||||
personList.stateHandler = new LogStateHandler();
|
||||
personDetails.stateHandler = new LogStateHandler();
|
||||
|
||||
|
||||
// Navigation Event
|
||||
var navigationListener =
|
||||
var navigationListener =
|
||||
(oldState: Navigation.State, state: Navigation.State, data: any) => {
|
||||
Navigation.StateController.offNavigate(navigationListener);
|
||||
};
|
||||
Navigation.StateController.onNavigate(navigationListener);
|
||||
|
||||
|
||||
// Navigation
|
||||
Navigation.start('home');
|
||||
Navigation.StateController.navigate('person');
|
||||
@@ -115,7 +115,7 @@ module NavigationTests {
|
||||
var canGoBack: boolean = Navigation.StateController.canNavigateBack(1);
|
||||
Navigation.StateController.navigateBack(1);
|
||||
Navigation.StateController.clearStateContext();
|
||||
|
||||
|
||||
// Navigation Link
|
||||
var link = Navigation.StateController.getNavigationLink('person');
|
||||
link = Navigation.StateController.getRefreshLink();
|
||||
@@ -129,7 +129,7 @@ module NavigationTests {
|
||||
var crumb = Navigation.StateController.crumbs[0];
|
||||
link = crumb.navigationLink;
|
||||
Navigation.StateController.navigateLink(link, true, Navigation.HistoryAction.None);
|
||||
|
||||
|
||||
// StateContext
|
||||
Navigation.StateController.navigate('home');
|
||||
Navigation.StateController.navigate('person');
|
||||
@@ -145,7 +145,7 @@ module NavigationTests {
|
||||
personList = Navigation.StateContext.oldState;
|
||||
page = Navigation.StateContext.oldData.page;
|
||||
page = Navigation.StateContext.previousData.page;
|
||||
|
||||
|
||||
// Navigation Data
|
||||
var data = Navigation.StateContext.includeCurrentData({ sort: 'name' }, ['page']);
|
||||
Navigation.StateController.refresh(data);
|
||||
@@ -154,4 +154,4 @@ module NavigationTests {
|
||||
Navigation.StateController.refresh(data);
|
||||
Navigation.StateContext.clear();
|
||||
Navigation.StateController.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+43
-43
@@ -4,9 +4,9 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
declare module 'navigation' {
|
||||
export = Navigation;
|
||||
}
|
||||
}
|
||||
|
||||
declare module Navigation {
|
||||
declare namespace Navigation {
|
||||
/**
|
||||
* Defines a contract a class must implement in order to represent a
|
||||
* logical grouping of child State elements. Navigating across different
|
||||
@@ -38,7 +38,7 @@ declare module Navigation {
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a contract a class must implement in order to configure state
|
||||
* Defines a contract a class must implement in order to configure state
|
||||
* information. A child of a Dialog element, it represents the endpoint of
|
||||
* a navigation
|
||||
*/
|
||||
@@ -69,9 +69,9 @@ declare module Navigation {
|
||||
*/
|
||||
route: string | string[];
|
||||
/**
|
||||
* Gets a value that indicates whether to maintain crumb trail
|
||||
* Gets a value that indicates whether to maintain crumb trail
|
||||
* information e.g PreviousState. This can be used together with Route
|
||||
* to produce user friendly Urls
|
||||
* to produce user friendly Urls
|
||||
*/
|
||||
trackCrumbTrail?: boolean;
|
||||
/**
|
||||
@@ -86,7 +86,7 @@ declare module Navigation {
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a contract a class must implement in order to configure
|
||||
* Defines a contract a class must implement in order to configure
|
||||
* transition information. A child of a State element it represents a
|
||||
* possible navigation from its Parent to a sibling State
|
||||
*/
|
||||
@@ -102,9 +102,9 @@ declare module Navigation {
|
||||
*/
|
||||
key: string;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Configures dialog information. Represents a logical grouping of child
|
||||
* Configures dialog information. Represents a logical grouping of child
|
||||
* State elements. Navigating across different dialogs will initialise the
|
||||
* crumb trail
|
||||
*/
|
||||
@@ -124,7 +124,7 @@ declare module Navigation {
|
||||
*/
|
||||
index: number;
|
||||
/**
|
||||
* Gets the state to navigate to if the Key is passed as an action
|
||||
* Gets the state to navigate to if the Key is passed as an action
|
||||
* parameter to the StateController
|
||||
*/
|
||||
initial: State;
|
||||
@@ -140,7 +140,7 @@ declare module Navigation {
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures state information. A child of a Dialog element, it
|
||||
* Configures state information. A child of a Dialog element, it
|
||||
* represents the endpoint of a navigation
|
||||
*/
|
||||
class State implements IState<{ [index: string]: Transition; }> {
|
||||
@@ -192,9 +192,9 @@ declare module Navigation {
|
||||
*/
|
||||
route: string | string[];
|
||||
/**
|
||||
* Gets a value that indicates whether to maintain crumb trail
|
||||
* Gets a value that indicates whether to maintain crumb trail
|
||||
* information e.g PreviousState. This can be used together with Route
|
||||
* to produce user friendly Urls
|
||||
* to produce user friendly Urls
|
||||
*/
|
||||
trackCrumbTrail: boolean;
|
||||
/**
|
||||
@@ -208,7 +208,7 @@ declare module Navigation {
|
||||
*/
|
||||
stateHandler: IStateHandler;
|
||||
/**
|
||||
* Called on the old State (this is not the same as the previous
|
||||
* Called on the old State (this is not the same as the previous
|
||||
* State) before navigating to a different State
|
||||
* @param state The new State
|
||||
* @param data The new NavigationData
|
||||
@@ -218,7 +218,7 @@ declare module Navigation {
|
||||
*/
|
||||
unloading: (state: State, data: any, url: string, unload: () => void, history?: boolean) => void;
|
||||
/**
|
||||
* Called on the old State (this is not the same as the previous
|
||||
* Called on the old State (this is not the same as the previous
|
||||
* State) after navigating to a different State
|
||||
*/
|
||||
dispose: () => void;
|
||||
@@ -286,7 +286,7 @@ declare module Navigation {
|
||||
*/
|
||||
static build(dialogs: IDialog<string, IState<ITransition<string>[]>[]>[]): void;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determines the effect on browser history after a successful navigation
|
||||
*/
|
||||
@@ -303,7 +303,7 @@ declare module Navigation {
|
||||
* Leaves browser history unchanged
|
||||
*/
|
||||
None = 2,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a contract a class must implement in order to manage the browser
|
||||
@@ -341,7 +341,7 @@ declare module Navigation {
|
||||
*/
|
||||
getHref(url: string): string;
|
||||
/**
|
||||
* Gets a Url from the anchor
|
||||
* Gets a Url from the anchor
|
||||
*/
|
||||
getUrl(anchor: HTMLAnchorElement): string;
|
||||
}
|
||||
@@ -354,7 +354,7 @@ declare module Navigation {
|
||||
class HashHistoryManager implements IHistoryManager {
|
||||
/**
|
||||
* Gets or sets a value indicating whether to disable browser history.
|
||||
* Set to true if used in a browser without the hashchange event or
|
||||
* Set to true if used in a browser without the hashchange event or
|
||||
* outside of a browser environment
|
||||
*/
|
||||
disabled: boolean;
|
||||
@@ -370,13 +370,13 @@ declare module Navigation {
|
||||
/**
|
||||
* Sets the browser Url's hash to the url
|
||||
* @param state The State navigated to
|
||||
* @param url The current url
|
||||
* @param url The current url
|
||||
*/
|
||||
addHistory(state: State, url: string): void;
|
||||
/**
|
||||
* Sets the browser Url's hash to the url
|
||||
* @param state The State navigated to
|
||||
* @param url The current url
|
||||
* @param url The current url
|
||||
* @param replace A value indicating whether to replace the current
|
||||
* browser history entry
|
||||
*/
|
||||
@@ -390,7 +390,7 @@ declare module Navigation {
|
||||
*/
|
||||
getHref(url: string): string;
|
||||
/**
|
||||
* Gets a Url from the anchor
|
||||
* Gets a Url from the anchor
|
||||
*/
|
||||
getUrl(anchor: HTMLAnchorElement): string;
|
||||
}
|
||||
@@ -403,7 +403,7 @@ declare module Navigation {
|
||||
class HTML5HistoryManager implements IHistoryManager {
|
||||
/**
|
||||
* Gets or sets a value indicating whether to disable browser history.
|
||||
* Set to true if used in a browser without the HTML5 history api or
|
||||
* Set to true if used in a browser without the HTML5 history api or
|
||||
* outside of a browser environment
|
||||
*/
|
||||
disabled: boolean;
|
||||
@@ -414,13 +414,13 @@ declare module Navigation {
|
||||
/**
|
||||
* Sets the browser Url to the url using pushState
|
||||
* @param state The State navigated to
|
||||
* @param url The current url
|
||||
* @param url The current url
|
||||
*/
|
||||
addHistory(state: State, url: string): void;
|
||||
/**
|
||||
* Sets the browser Url to the url using pushState
|
||||
* @param state The State navigated to
|
||||
* @param url The current url
|
||||
* @param url The current url
|
||||
* @param replace A value indicating whether to replace the current
|
||||
* browser history entry
|
||||
*/
|
||||
@@ -434,34 +434,34 @@ declare module Navigation {
|
||||
*/
|
||||
getHref(url: string): string;
|
||||
/**
|
||||
* Gets a Url from the anchor
|
||||
* Gets a Url from the anchor
|
||||
*/
|
||||
getUrl(anchor: HTMLAnchorElement): string;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Provides the base functionality for crumb trail persistence mechanisms
|
||||
*/
|
||||
class CrumbTrailPersister {
|
||||
/**
|
||||
* Overridden by derived classes to return the persisted crumb trail
|
||||
* @param crumbTrail The key, returned from the save function, to
|
||||
* @param crumbTrail The key, returned from the save function, to
|
||||
* identify the persisted crumb trail
|
||||
* @returns The crumb trail holding navigation and data information
|
||||
*/
|
||||
load(crumbTrail: string): string;
|
||||
/**
|
||||
* Overridden by derived classes to persist the crumb trail
|
||||
* @param crumbTrail The crumb trail holding navigation and data
|
||||
* @param crumbTrail The crumb trail holding navigation and data
|
||||
* information
|
||||
* @returns The key to be passed to load function for crumb trail
|
||||
* retrieval
|
||||
*/
|
||||
save(crumbTrail: string): string;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Persists crumb trails, over a specified length, in localStorage.
|
||||
* Persists crumb trails, over a specified length, in localStorage.
|
||||
* Prevents the creation of unmanageably long Urls. If used in a browser
|
||||
* without localStorage or outside of a browser environment, then in memory
|
||||
* storage is used
|
||||
@@ -503,11 +503,11 @@ declare module Navigation {
|
||||
* crumb trail from storage. If retrieved from storage it may be null
|
||||
* @param Key generated by the save function
|
||||
* @returns Either the crumbTrail or the one retrieved value from
|
||||
* storage; can be null if retrieved from storage
|
||||
* storage; can be null if retrieved from storage
|
||||
*/
|
||||
load(crumbTrail: string): string;
|
||||
/**
|
||||
* If the crumbTrail is not over the maxLength it is returned.
|
||||
* If the crumbTrail is not over the maxLength it is returned.
|
||||
* Otherwise the crumbTrail is stored in storage using a short key,
|
||||
* unique within a given storage session. Also expunges old items from
|
||||
* storage, if the historySize is breached when a new item is added
|
||||
@@ -671,7 +671,7 @@ declare module Navigation {
|
||||
combineCrumbTrail: boolean;
|
||||
/**
|
||||
* Gets or sets a value indicating whether to track PreviousData when
|
||||
* navigating back or refreshing and combineCrumbTrail is false
|
||||
* navigating back or refreshing and combineCrumbTrail is false
|
||||
*/
|
||||
trackAllPreviousData: boolean;
|
||||
/**
|
||||
@@ -731,13 +731,13 @@ declare module Navigation {
|
||||
* Gets or sets the current title
|
||||
*/
|
||||
static title: string;
|
||||
/**
|
||||
/**
|
||||
* Combines the data with all the current NavigationData
|
||||
* @param The data to add to the current NavigationData
|
||||
* @returns The combined data
|
||||
*/
|
||||
static includeCurrentData(data: any): any;
|
||||
/**
|
||||
/**
|
||||
* Combines the data with a subset of the current NavigationData
|
||||
* @param The data to add to the current NavigationData
|
||||
* @returns The combined data
|
||||
@@ -874,7 +874,7 @@ declare module Navigation {
|
||||
*/
|
||||
static navigateBack(distance: number, historyAction: HistoryAction): void;
|
||||
/**
|
||||
* Gets a Url to navigate to a Crumb contained in the crumb trail,
|
||||
* Gets a Url to navigate to a Crumb contained in the crumb trail,
|
||||
* represented by the Crumbs collection, as specified by the distance.
|
||||
* In the crumb trail no two crumbs can have the same State but all
|
||||
* must have the same Dialog
|
||||
@@ -905,7 +905,7 @@ declare module Navigation {
|
||||
*/
|
||||
static refresh(toData: any, historyAction: HistoryAction): void;
|
||||
/**
|
||||
* Gets a Url to navigate to the current State passing no
|
||||
* Gets a Url to navigate to the current State passing no
|
||||
* NavigationData
|
||||
*/
|
||||
static getRefreshLink(): string;
|
||||
@@ -1049,7 +1049,7 @@ declare module Navigation {
|
||||
*/
|
||||
class StateRouter implements IRouter {
|
||||
/**
|
||||
* Gets the underlying Navigation Router
|
||||
* Gets the underlying Navigation Router
|
||||
*/
|
||||
router: Router;
|
||||
/**
|
||||
@@ -1097,13 +1097,13 @@ declare module Navigation {
|
||||
params: { name: string; optional: boolean; }[];
|
||||
/**
|
||||
* Initializes a new instance of the Route class
|
||||
* @param path The route pattern
|
||||
* @param path The route pattern
|
||||
*/
|
||||
constructor(path: string);
|
||||
/**
|
||||
* Initializes a new instance of the Route class
|
||||
* @param path The route pattern
|
||||
* @param defaults The default parameter values
|
||||
* @param path The route pattern
|
||||
* @param defaults The default parameter values
|
||||
*/
|
||||
constructor(path: string, defaults: any);
|
||||
/**
|
||||
@@ -1184,7 +1184,7 @@ declare module Navigation {
|
||||
/**
|
||||
* Initializes the history manager and navigates to the current location.
|
||||
* If used outside of a browser environment, pass in the Url to navigate to
|
||||
* @param url If used outside of a browser, the url to navigate to
|
||||
* @param url If used outside of a browser, the url to navigate to
|
||||
*/
|
||||
export var start: (url?: string) => void;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user