Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jakutis/navigate
A router for the browser (client-side JavaScript).
https://github.com/jakutis/navigate
Last synced: 6 days ago
JSON representation
A router for the browser (client-side JavaScript).
- Host: GitHub
- URL: https://github.com/jakutis/navigate
- Owner: jakutis
- License: mit
- Created: 2014-02-18T14:24:00.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2017-11-11T18:18:28.000Z (about 7 years ago)
- Last Synced: 2025-01-03T13:37:13.620Z (17 days ago)
- Language: JavaScript
- Homepage: https://www.npmjs.org/package/navigate
- Size: 18.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
- License: LICENSE
Awesome Lists containing this project
README
# navigate
A router for the browser (client-side JavaScript).
- [Overview](#overview)
- [Installation](#installation)
- [API](#api)
- [Development](#development)## Overview
* Has no dependencies.
* Supports Asynchronous Module Loader (AMD, RequireJS), CommonJS (Node.js require) and regular <script> loading.
* If HTML5 History API is not available, falls back to hashes.
* Handles click events on same origin links.
* Tested on these browsers:
- Mozilla Firefox 1.0+
- Opera 8.00+
- Google Chrome 1+
- Microsoft Internet Explorer 6+
- Apple Safari 3.0+## Installation
Install manually by adding to your HTML file:
Install with [npm](https://www.npmjs.org/package/navigate):
$ npm install --save navigate
Install with [component](http://component.io/jakutis/navigate):
$ component install jakutis/navigate
Install with [bower](http://bower.io):
$ bower install --save navigate
## API
// configure, can be called anytime at all (including never)
navigate({
// whether same origin a.href clicks are captured
clickHandlingEnabled : true,
// URL path prefix
basePath : ''
});// initialize
navigate();// get current page (also initialize, if not initialized)
navigate(function(entryPage) {
console.log('Entry page to this web app is ' + entryPage);
});// handle navigations to /user/* pages
navigate(/^\/user\/(.+)$/, function(args, from, to) {
console.log('Navigated from page ' + from + ' to ' + to);
console.log('Showing user ' + args[0]);
});// navigate to user's "tahu" page
navigate('/user/tahu');## Development
TODO