Compare commits

...

5 Commits
0.2.2 ... 0.2.3

Author SHA1 Message Date
Maxime Thirouin
4877bac2ae 0.2.3 2016-03-24 12:39:07 +01:00
Maxime Thirouin
afe0ddb6b9 Fixed: `this.reload` is now a Function
Closes #65
2016-03-24 12:38:15 +01:00
Maxime Thirouin
a5d36d28f8 Update README.md 2016-03-15 11:36:53 +01:00
Maxime Thirouin
7a4056fd77 Update README.md 2016-03-15 11:35:13 +01:00
Maxime Thirouin
ba6ef126c0 Internal: add "npm run release" command
—skip-test is used because of tesling (it does not like to be spawned
or something like that)…
2016-03-12 07:52:52 +01:00
7 changed files with 29 additions and 39 deletions

View File

@@ -1,3 +1,9 @@
# 0.2.3 - 2016-03-24
- Fixed: ``currentUrlFullReload`` option now works
- Fixed: ``this.reload`` is now a Function
([#65](https://github.com/MoOx/pjax/issues/65))
# 0.2.2 - 2016-03-12 # 0.2.2 - 2016-03-12
- Fixed: added back standalone version in `./pjax.js` - Fixed: added back standalone version in `./pjax.js`

View File

@@ -1,7 +1,6 @@
# Pjax [![Build Status](http://img.shields.io/travis/MoOx/pjax.svg)](https://travis-ci.org/MoOx/pjax) # Pjax
[![Build Status](http://img.shields.io/travis/MoOx/pjax.svg)](https://travis-ci.org/MoOx/pjax) [@todo fix CI](https://github.com/MoOx/pjax/issues/63).
[![browser support](https://ci.testling.com/MoOx/pjax.png)](https://ci.testling.com/MoOx/pjax)
> Easily enable fast Ajax navigation on any website (using pushState + xhr) > Easily enable fast Ajax navigation on any website (using pushState + xhr)
@@ -16,9 +15,6 @@ Especially for user that have low bandwidth connection._
**No more full page reload. No more lots of HTTP request.** **No more full page reload. No more lots of HTTP request.**
# Note: current master is WIP.
Checkout [v0.1.4](https://github.com/MoOx/pjax/tree/a17a6b90bebefd8f5209e6a6f7d8c5d59296232a) for latest "stable" (no tests so kind of funny to call that stable).
## Demo ## Demo
@@ -394,25 +390,6 @@ Useful to debug page layout differences.
When set to true, clicking on a link that point the current url trigger a full page reload. When set to true, clicking on a link that point the current url trigger a full page reload.
#### Extend Pjax
Pjax prototype & utilities methods can be used & changed so you can patch or hack
Pjax behavior, as you wish.
Here is a summary of functions:
- `Pjax.prototype.log` (`function()`): console.log function that is enable/disabled by `debug` option
- `Pjax.prototype.getElements` (`function(el)`): retrieve elements to attach Pjax behavior
- `Pjax.prototype.parseDOM` (`function(el)`): parse DOM to attach behavior using `Pjax.prototype.getElements` & `Pjax.prototype.attachLink`
- `Pjax.prototype.attachLink` (`function(el)`): attach Pjax behavior to a link
- `Pjax.prototype.forEachSelectors` (`function(cb, context, DOMcontext)`): call a function for each selectors defined
- `Pjax.prototype.switchSelectors` (`function(selectors, fromEl, toEl, options)`): loop on selectors to switch elements
- `Pjax.prototype.latestChance` (`function(href)`): when everything is fucked up, it's our only hope (just call `window.location = href`)
- `Pjax.prototype.onSwitch` (`function()`): callback triggered when elements are switched, for now it's just trigger a window resize event (lots of lib are listening to this event to draw stuff)
- `Pjax.prototype.loadContent` (`function(html, options)`): switch elements for each selectors
- `Pjax.prototype.doRequest` (`function(location, callback)`): make the ajax request to grab page from the server
- `Pjax.prototype.loadUrl` (`function(href, options)`): do the ajax request, handle html results & eventually handle browser history, analytics & scroll.
### Events ### Events
Pjax fires a number of events regardless of how its invoked. Pjax fires a number of events regardless of how its invoked.
@@ -543,15 +520,13 @@ Clone this repository and run `npm run example`, then open `http://localhost:300
--- ---
## Contributing ## CONTRIBUTING
Work on a branch, install dev-dependencies, respect coding style & run tests before submitting a bug fix or a feature. * ⇄ Pull requests and ★ Stars are always welcome.
* For bugs and feature requests, please create an issue.
* Pull requests must be accompanied by passing automated tests (`$ npm test`).
$ git clone https://github.com/MoOx/pjax.git ## [CHANGELOG](CHANGELOG.md)
$ git checkout -b patch-1
$ npm install
$ npm test
## [Changelog](CHANGELOG.md) ## [LICENSE](LICENSE)
## [License](LICENSE)

View File

@@ -19,8 +19,8 @@ document.addEventListener("pjax:success", function() {
document.addEventListener("DOMContentLoaded", function() { document.addEventListener("DOMContentLoaded", function() {
var pjax = new Pjax({ var pjax = new Pjax({
selectors: [".body"] selectors: [".body"],
// currentUrlFullReload: true,
}) })
console.log("Pjax initialized.", pjax) console.log("Pjax initialized.", pjax)
}) })

View File

@@ -9,7 +9,9 @@
<body> <body>
<div class='body'> <div class='body'>
<h1>Index</h1> <h1>Index</h1>
hello. Go to <a href='page2.html'>Page 2</a> and view your console to see Pjax events. Hello.
Go to <a href='page2.html'>Page 2</a> and view your console to see Pjax events.
Clicking on <a href='index.html'>this page</a> will just reload the page entierly.
</div> </div>
</body> </body>
</html> </html>

View File

@@ -51,6 +51,8 @@ Pjax.prototype = {
refresh: require("./lib/proto/refresh.js"), refresh: require("./lib/proto/refresh.js"),
reload: require("./lib/reload.js"),
attachLink: require("./lib/proto/attach-link.js"), attachLink: require("./lib/proto/attach-link.js"),
forEachSelectors: function(cb, context, DOMcontext) { forEachSelectors: function(cb, context, DOMcontext) {

View File

@@ -43,7 +43,10 @@ var linkAction = function(el, event) {
event.preventDefault() event.preventDefault()
// dont do "nothing" if user try to reload the page by clicking the same link twice // dont do "nothing" if user try to reload the page by clicking the same link twice
if (el.href === window.location.href.split("#")[0]) { if (
this.options.currentUrlFullReload &&
el.href === window.location.href.split("#")[0]
) {
el.setAttribute(attrClick, "reload") el.setAttribute(attrClick, "reload")
this.reload() this.reload()
return return

View File

@@ -1,6 +1,6 @@
{ {
"name": "pjax", "name": "pjax",
"version": "0.2.2", "version": "0.2.3",
"description": "Easily enable fast Ajax navigation on any website (using pushState + xhr)", "description": "Easily enable fast Ajax navigation on any website (using pushState + xhr)",
"keywords": [ "keywords": [
"pjax", "pjax",
@@ -25,6 +25,7 @@
"coverify": "^1.0.6", "coverify": "^1.0.6",
"jscs": "^1.6.2", "jscs": "^1.6.2",
"jshint": "^2.5.6", "jshint": "^2.5.6",
"npmpub": "^3.1.0",
"serve": "1.4.0", "serve": "1.4.0",
"tape": "^3.0.0", "tape": "^3.0.0",
"testling": "^1.6.1" "testling": "^1.6.1"
@@ -37,7 +38,8 @@
"test--html": "testling --html > tests/scripts/index.html", "test--html": "testling --html > tests/scripts/index.html",
"coverage": "browserify -t coverify tests/**/*.js | testling | coverify", "coverage": "browserify -t coverify tests/**/*.js | testling | coverify",
"example": "echo '\n==> Open http://localhost:3000/example in your browser.'; serve .", "example": "echo '\n==> Open http://localhost:3000/example in your browser.'; serve .",
"prepublish": "npm run standalone" "prepublish": "npm run standalone",
"release": "npm test && npmpub --skip-test"
}, },
"testling": { "testling": {
"files": "tests/**/*.js", "files": "tests/**/*.js",