Merge pull request #6080 from DotNetNerd/master

Added satnav
This commit is contained in:
Horiuchi_H
2015-10-01 18:01:30 +09:00
2 changed files with 46 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
/// <reference path="satnav.d.ts" />
Satnav({})
.navigate({
path: 'product/{required}/?{optional}',
directions: (params) => {
// Logic for product route
console.log(params.required);
console.log(params.hasOwnProperty('optional'));
}
})
.otherwise('/product/1')
.change(function (hash, params, old) {
// Logic for any change
console.log(hash);
console.log(params);
console.log(old);
})
.go(); //Resolve current route
+28
View File
@@ -0,0 +1,28 @@
// Type definitions for satnav
// Project: https://github.com/f5io/satnav-js
// Definitions by: Christian Holm Diget <https://github.com/DotNetNerd>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare type Callback = () => void;
interface ISatnavOptions {
html5?: boolean,
force?: boolean,
poll?: number,
matchAll?: boolean
}
interface INavigationOptions {
path?: string,
directions?: (params : any) => any,
title?: string | Callback
}
interface ISatnav {
navigate(navigationOptions: INavigationOptions): ISatnav;
otherwise(route: string): ISatnav;
change(onChange: (hash: string, params: any, old: any) => any): ISatnav;
go(): ISatnav;
}
declare function Satnav(options?: ISatnavOptions): ISatnav;