proxy-based Twister client written with react-js
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.6 KiB

10 years ago
'use strict';
10 years ago
var PropTypes = require('./PropTypes');
/**
* A mixin for components that modify the URL.
*
* Example:
*
* var MyLink = React.createClass({
* mixins: [ Router.Navigation ],
* handleClick(event) {
* event.preventDefault();
* this.transitionTo('aRoute', { the: 'params' }, { the: 'query' });
* },
* render() {
* return (
* <a onClick={this.handleClick}>Click me!</a>
* );
* }
* });
*/
var Navigation = {
contextTypes: {
router: PropTypes.router.isRequired
},
/**
* Returns an absolute URL path created from the given route
* name, URL parameters, and query values.
*/
10 years ago
makePath: function makePath(to, params, query) {
return this.context.router.makePath(to, params, query);
10 years ago
},
/**
* Returns a string that may safely be used as the href of a
* link to the route with the given name.
*/
10 years ago
makeHref: function makeHref(to, params, query) {
return this.context.router.makeHref(to, params, query);
10 years ago
},
/**
* Transitions to the URL specified in the arguments by pushing
* a new URL onto the history stack.
*/
10 years ago
transitionTo: function transitionTo(to, params, query) {
this.context.router.transitionTo(to, params, query);
10 years ago
},
/**
* Transitions to the URL specified in the arguments by replacing
* the current URL in the history stack.
*/
10 years ago
replaceWith: function replaceWith(to, params, query) {
this.context.router.replaceWith(to, params, query);
10 years ago
},
/**
* Transitions to the previous URL.
*/
10 years ago
goBack: function goBack() {
return this.context.router.goBack();
10 years ago
}
};
module.exports = Navigation;