Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// eslint-disable-next-line no-undef
module.exports = {
"extends": [
"eslint:recommended"
],
"env": {
"es6": true,
"browser": true
},
"rules": {
"linebreak-style": "off",
"newline-per-chained-call": "off"
},
"plugins": [
]
}
10 changes: 5 additions & 5 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,8 @@ pip-log.txt
## NodeJS
#############

node_modules/
node_modules/

#VSCode
.vscode/*
!.vscode/settings.json
31 changes: 31 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"editor": {
"formatOnSave": true
},
"eslint": {
"enabled": true,
"autoFixOnSave": true,
"validate": [
"javascript"
],
"workingDirectories": [
{
"directory": "./",
"changeProcessCWD": true
}
]
},
"[javascript]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "vscode.typescript-language-features"
},
"javascript.updateImportsOnFileMove.enabled": "always",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": false
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.wordWrapColumn": 9999999,
"prettier.singleQuote": true
}
62 changes: 34 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
jQuery.navigate
===============
# jQuery.navigate

An abstraction on site navigation wrapped up in a jQuery plugin. When using website analytics, `window.location` is not sufficient due to the referer not being passed on the request. The plugin resolves this and allows for both aliased and parametrised URLs. I also provide an API helper method, which enables quick and simple ReSTful URL building capability.
An abstraction on site navigation wrapped up in a jQuery plugin. When using website analytics, `window.location` is not sufficient due to the referer not being passed on the request. The plugin resolves this and allows for both aliased and parametrised URLs. I also provide an API helper method, which enables quick and simple ReSTful URL building capability.

[![Build Status](https://travis-ci.org/michaelpapworth/jQuery.navigate.png?branch=master)](https://travis-ci.org/michaelpapworth/jQuery.navigate)

The Setup
---------
## The Setup

```js
$(document).ready(function() {
$.navigateSetup({
api : '/api/',
endpoints : {
'home' : '/michaelpapworth',
'myAwesomePlugin' : '/{user}/{repo}'
}
});
$(document).ready(function () {
$.navigateSetup({
api: '/api/',
endpoints: {
home: '/michaelpapworth',
myAwesomePlugin: '/{user}/{repo}',
},
});
});
```

Usage
-----
## Usage

The examples below are based on the setup above, let's assume the root of the site is http://github.com.

Expand All @@ -30,37 +27,46 @@ How to navigate to the preconfigured **endpoints**?
```js
// Address bar will read http://github.com/michaelpapworth
$.navigate('to', 'home');
$.navigate.to('home'); //alternative syntax

// Address bar will read http://github.com/michaelpapworth/jQuery.navigate
$.navigate('to', 'myAwesomePlugin', { user : 'michaelpapworth', repo : 'jQuery.navigate' });
$.navigate('to', 'myAwesomePlugin', {
user: 'michaelpapworth',
repo: 'jQuery.navigate',
});
$.navigate.to('myAwesomePlugin', {
user: 'michaelpapworth',
repo: 'jQuery.navigate',
});
```

Want to navigate to a **specific URL**?

```js
$.navigate('goTo', 'http://github.com/michaelpapworth/jQuery.navigate');
$.navigate('goTo', 'http://github.com/michaelpapworth/jQuery.navigate');
$.navigate.goTo('http://github.com/michaelpapworth/jQuery.navigate');
```

What about your **API**?

```js
$.ajax({ type : 'GET', url : $.navigate('api', 'resource', 123) })
.done(function(data) {
console.log('This data came from "http://github.com/api/resource/123"');
});
var url = $.navigate.api('resource', 123); // /api/resource/123
$.ajax({ type: 'GET', url: url }).done(function (data) {
console.log('This data came from "http://github.com/api/resource/123"');
});
```

I just want the **URL**?

```js
// Just use the endpoints to build the URL for me
var homepageUrl = $.navigate('url', 'home');
var homepageUrl1 = $.navigate('url', 'home');
var homepageUrl2 = $.navigate.url('home');
```

Want to roll your own or contribute?
----------------------
## Want to roll your own or contribute?

1. Fork this repository and create a new branch if you intend to contribute your work.
2. Clone the branch to your computer.
3. In the console `cd jQuery.navigate && npm run-script build`.
4. Enable the build as you save your work `npm start`.
1. Fork this repository and create a new branch if you intend to contribute your work.
2. Clone the branch to your computer.
3. In the console `cd jQuery.navigate && npm run-script build`.
4. Enable the build as you save your work `npm start`.
72 changes: 36 additions & 36 deletions navigate.jquery.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
{
"name" : "navigate",
"version" : "1.0.12",
"title" : "jQuery.navigate",
"author" : {
"name" : "Michael Papworth",
"url" : "http://stackoverflow.com/users/2955675/michaelpapworth"
},
"licenses": [
{
"type": "MIT",
"url": "http://raw.github.com/michaelpapworth/jQuery.navigate/master/LICENSE"
}
],
"dependencies" : {
"jquery": ">=1.4.2"
},
"description" : "An abstraction on site navigation. When using website analytics, window.location is not sufficient due to the referer not being passed on the request. The plugin resolves this and allows for both aliased and parametrised URLs. I also provide an API helper method, which enables quick and simple ReSTful URL building capability.",
"keywords" : [
"navigation",
"redirect",
"href",
"window.location",
"url",
"alias",
"parametrised"
],
"docs" : "http://github.com/michaelpapworth/jQuery.navigate/blob/master/README.md",
"download" : "http://github.com/michaelpapworth/jQuery.navigate/blob/master/src/navigate.js",
"homepage" : "http://github.com/michaelpapworth/jQuery.navigate",
"bugs": "http://github.com/michaelpapworth/jQuery.navigate/issues",
"maintainers" : [
{
"name" : "Michael Papworth",
"url" : "http://stackoverflow.com/users/2955675/michaelpapworth"
}
]
"name": "navigate",
"version": "1.0.15",
"title": "jQuery.navigate",
"author": {
"name": "Michael Papworth",
"url": "http://stackoverflow.com/users/2955675/michaelpapworth"
},
"licenses": [
{
"type": "MIT",
"url": "http://raw.github.com/michaelpapworth/jQuery.navigate/master/LICENSE"
}
],
"dependencies": {
"jquery": ">=1.4.2"
},
"description": "An abstraction on site navigation wrapped up in a jQuery plugin. When using website analytics, window.location is not sufficient due to the referer not being passed on the request. The plugin resolves this and allows for both aliased and parametrised URLs. It also provides an API helper method, which enables quick and simple ReSTful URL building capability.",
"keywords": [
"navigation",
"redirect",
"href",
"window.location",
"url",
"alias",
"parametrised"
],
"docs": "http://github.com/michaelpapworth/jQuery.navigate/blob/master/README.md",
"download": "http://github.com/michaelpapworth/jQuery.navigate/blob/master/src/navigate.js",
"homepage": "http://github.com/michaelpapworth/jQuery.navigate",
"bugs": "http://github.com/michaelpapworth/jQuery.navigate/issues",
"maintainers": [
{
"name": "Michael Papworth",
"url": "http://stackoverflow.com/users/2955675/michaelpapworth"
}
]
}
Loading