diff --git a/.gitignore b/.gitignore
index c2658d7..075b5c2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,4 @@
+.DS_Store
node_modules/
+dist/
+tests/scripts/index.html
diff --git a/.jscs.json b/.jscs.json
index a03292c..e4169a9 100644
--- a/.jscs.json
+++ b/.jscs.json
@@ -1,112 +1,143 @@
{
- "excludeFiles": [
- ]
- , "requireCurlyBraces": [
- "if"
- , "else"
- , "for"
- , "while"
- , "do"
- , "try"
- , "catch"
- ]
- , "requireSpaceAfterKeywords": [
- "if"
- , "else"
- , "for"
- , "while"
- , "do"
- , "switch"
- , "return"
- , "try"
- , "catch"
- ]
- , "requireSpacesInFunctionExpression": {
- "beforeOpeningCurlyBrace": true
- }
- , "disallowSpacesInFunctionExpression": {
- "beforeOpeningRoundBrace": true
- }
- , "disallowEmptyBlocks": true
- , "disallowSpacesInsideObjectBrackets": true
- , "disallowSpacesInsideArrayBrackets": true
- , "disallowSpacesInsideParentheses": true
- , "disallowSpaceAfterObjectKeys": true
- , "disallowCommaBeforeLineBreak": true
- , "requireOperatorBeforeLineBreak": [
- "?"
- , "+"
- , "-"
- , "/"
- , "*"
- , "="
- , "=="
- , "==="
- , "!="
- , "!=="
- , ">"
- , ">="
- , "<"
- , "<="
- ]
- , "disallowSpaceAfterPrefixUnaryOperators": [
- "++"
- , "--"
- , "+"
- , "-"
- , "~"
- , "!"
- ]
- , "disallowSpaceBeforePostfixUnaryOperators": [
- "++"
- , "--"
- ]
- , "requireSpaceBeforeBinaryOperators": [
- "+"
- , "-"
- , "/"
- , "*"
- , "="
- , "=="
- , "==="
- , "!="
- , "!=="
- ]
- , "requireSpaceAfterBinaryOperators": [
- "+"
- , "-"
- , "/"
- , "*"
- , "="
- , "=="
- , "==="
- , "!="
- , "!=="
- ]
- , "disallowImplicitTypeConversion": [
- "numeric"
- , "boolean"
- , "binary"
- , "string"
- ]
- , "disallowKeywords": [
- "with"
- ]
- , "disallowMultipleLineStrings": true
-
- , "validateQuoteMarks": "\""
- , "disallowMixedSpacesAndTabs": true
- , "disallowTrailingWhitespace": true
-
- , "requireKeywordsOnNewLine": [
- ]
- , "requireLineFeedAtFileEnd": true
- , "requireCapitalizedConstructors": true
- , "safeContextKeyword": "that"
-
- , "validateJSDoc": {
- "checkParamNames": true
- , "checkRedundantParams": true
- , "requireParamTypes": true
+ "excludeFiles": [],
+ "requireCurlyBraces": [
+ "if",
+ "else",
+ "for",
+ "while",
+ "do",
+ "try",
+ "catch"
+ ],
+ "requireSpaceAfterKeywords": [
+ "if",
+ "else",
+ "for",
+ "while",
+ "do",
+ "switch",
+ "return",
+ "try",
+ "catch"
+ ],
+ "requireSpacesInFunctionExpression": {
+ "beforeOpeningCurlyBrace": true
+ },
+ "disallowSpacesInFunctionExpression": {
+ "beforeOpeningRoundBrace": true
+ },
+ "disallowEmptyBlocks": true,
+ "disallowSpacesInsideParentheses": true,
+ "disallowSpacesInsideObjectBrackets": true,
+ "disallowSpacesInsideArrayBrackets": true,
+ "disallowQuotedKeysInObjects": "allButReserved",
+ "disallowSpaceAfterObjectKeys": true,
+ "requireCommaBeforeLineBreak": true,
+ "requireOperatorBeforeLineBreak": [
+ "?",
+ "+",
+ "-",
+ "/",
+ "*",
+ "=",
+ "==",
+ "===",
+ "!=",
+ "!==",
+ ">",
+ ">=",
+ "<",
+ "<="
+ ],
+ "disallowLeftStickedOperators": [
+ "?",
+ "+",
+ "-",
+ "/",
+ "*",
+ "=",
+ "==",
+ "===",
+ "!=",
+ "!==",
+ ">",
+ ">=",
+ "<",
+ "<="
+ ],
+ "requireRightStickedOperators": [
+ "!"
+ ],
+ "disallowRightStickedOperators": [
+ "?",
+ "+",
+ "/",
+ "*",
+ ":",
+ "=",
+ "==",
+ "===",
+ "!=",
+ "!==",
+ ">",
+ ">=",
+ "<",
+ "<="
+ ],
+ "disallowSpaceAfterPrefixUnaryOperators": [
+ "++",
+ "--",
+ "+",
+ "-",
+ "~",
+ "!"
+ ],
+ "disallowSpaceBeforePostfixUnaryOperators": [
+ "++",
+ "--"
+ ],
+ "requireSpaceBeforeBinaryOperators": [
+ "+",
+ "-",
+ "/",
+ "*",
+ "=",
+ "==",
+ "===",
+ "!=",
+ "!=="
+ ],
+ "requireSpaceAfterBinaryOperators": [
+ "+",
+ "-",
+ "/",
+ "*",
+ "=",
+ "==",
+ "===",
+ "!=",
+ "!=="
+ ],
+ "disallowImplicitTypeConversion": [
+ "numeric",
+ "boolean",
+ "binary",
+ "string"
+ ],
+ "disallowKeywords": [
+ "with"
+ ],
+ "disallowMultipleLineStrings": true,
+ "validateQuoteMarks": "\"",
+ "disallowMixedSpacesAndTabs": true,
+ "disallowTrailingWhitespace": true,
+ "requireKeywordsOnNewLine": [],
+ "requireLineFeedAtFileEnd": true,
+ "requireCapitalizedConstructors": true,
+ "safeContextKeyword": "that",
+ "validateJSDoc": {
+ "checkParamNames": true,
+ "checkRedundantParams": true,
+ "requireParamTypes": true
}
}
diff --git a/.jshintrc b/.jshintrc
index 7568631..182e34d 100644
--- a/.jshintrc
+++ b/.jshintrc
@@ -1,4 +1,4 @@
{
- "asi": true
- , "laxcomma": true
+ "asi": true,
+ "laxcomma": true
}
diff --git a/README.md b/README.md
index e9f4ba0..efe5461 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# Pjax
-
+[](https://ci.testling.com/MoOx/pjax)
> Easily enable fast Ajax navigation on any website (using pushState + xhr)
@@ -15,12 +15,9 @@ Especially for user that have low bandwidth connection._
**No more full page reload. No more lots of HTTP request.**
-## No tests or Demo ?
+## Demo
-~~There is still some work to make this repo sexy with tests & simple demo.~~
-Actually there is a [WIP branch where I'm adding lot of tests](https://github.com/MoOx/pjax/tree/testling)
-
-For now [you can see this running on my website](http://moox.io), with sexy CSS animations when switching pages.
+[You can see this running on my website](http://moox.io), with sexy CSS animations when switching pages.
## How Pjax works
@@ -135,8 +132,8 @@ Let's talk more about the most basic way to get started:
```js
new Pjax({
- elements: "a" // default is "a[href], form[action]"
-, selectors: ["title", ".my-Header", ".my-Content", ".my-Sidebar"]
+ elements: "a", // default is "a[href], form[action]"
+ selectors: ["title", ".my-Header", ".my-Content", ".my-Sidebar"]
})
```
@@ -203,8 +200,8 @@ Examples:
```js
new Pjax({
- selectors: ["title", ".Navbar", ".js-Pjax"]
-, switches: {
+ selectors: ["title", ".Navbar", ".js-Pjax"],
+ switches: {
// "title": Pjax.switches.outerHTML // default behavior
".Navbar": function(oldEl, newEl, options) {
// here it's a stupid example since it's the default behavior too
@@ -249,23 +246,23 @@ with or without [WOW.js](https://github.com/matthieua/WOW).
```js
new Pjax({
- selectors: ["title", ".js-Pjax"]
-, switches: {
+ selectors: ["title", ".js-Pjax"],
+ switches: {
".js-Pjax": Pjax.switches.sideBySide
- }
-, switchesOptions: {
+ },
+ switchesOptions: {
".js-Pjax": {
classNames: {
// class added on the element that will be removed
- remove: "Animated Animated--reverse Animate--fast Animate--noDelay"
+ remove: "Animated Animated--reverse Animate--fast Animate--noDelay",
// class added on the element that will be added
- , add: "Animated"
+ add: "Animated",
// class added on the element when it go backward
- , backward: "Animate--slideInRight"
+ backward: "Animate--slideInRight",
// class added on the element when it go forward (used for new page too)
- , forward: "Animate--slideInLeft"
- }
- , callbacks: {
+ forward: "Animate--slideInLeft"
+ },
+ callbacks: {
// to make a nice transition with 2 pages as the same time
// we are playing with absolute positioning for element we are removing
// & we need live metrics to have something great
@@ -399,14 +396,6 @@ Pjax behavior, as you wish.
Here is a summary of functions:
-- `Pjax.isSupported` (`function()`): return wheter or not the browser handle pushState correctly
-- `Pjax.on` (`function(els, events, listener, useCapture)`): addEventListener, that handles NodeList & supports space separated event name
-- `Pjax.off` (`function(els, events, listener, useCapture)`): removeEventListener, that handles NodeList & supports space separated event name
-- `Pjax.trigger` (`function(els, events)`): fireEvent, that handles NodeList & supports space separated event name
-- `Pjax.clone` (`function(obj)`): clone object
-- `Pjax.executeScripts` (`function(el)`): execute scripts that are inside an element (script src or inline scripts through `Pjax.evalScript`)
-- `Pjax.evalScript` (`function(el)`): execute inline script. Don't execute a script if it contains `document.write`.
-
- `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`
@@ -495,9 +484,9 @@ wrapper on each page (to avoid differences of DOM between pages)
```html