Compare commits
1 Commits
0.2.7
...
feature/ya
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5bbeb31ca6 |
15
CHANGELOG.md
15
CHANGELOG.md
@@ -1,18 +1,3 @@
|
|||||||
# 0.2.7 - 2018-08-15
|
|
||||||
|
|
||||||
- Fixed: Parsing values of option elements in forms.
|
|
||||||
([#162](https://github.com/MoOx/pjax/pull/162) - @BehindTheMath)
|
|
||||||
- Fixed: Added index.d.ts to package.json so it will be installed by npm.
|
|
||||||
([c589ab9](https://github.com/MoOx/pjax/commit/c589ab9c25bee6161bf3e557eaca44e51c14fb89) - @BehindTheMath)
|
|
||||||
- Fixed: `options.history` to correctly parse being set to false.
|
|
||||||
([#165](https://github.com/MoOx/pjax/pull/165) - @BehindTheMath).
|
|
||||||
- Fixed: Pass the current `options` object to `loadContent()`.
|
|
||||||
([#171](https://github.com/MoOx/pjax/pull/171) - @BehindTheMath)
|
|
||||||
- Fixed: Ensure correct XHR encoding for multipart/form-data forms
|
|
||||||
([#174](https://github.com/MoOx/pjax/pull/174) - @BehindTheMath)
|
|
||||||
- Added: More documentation.
|
|
||||||
([#160](https://github.com/MoOx/pjax/pull/160), [#171](https://github.com/MoOx/pjax/pull/171) - @robinnorth, @BehindTheMath)
|
|
||||||
|
|
||||||
# 0.2.6 - 2018-04-30
|
# 0.2.6 - 2018-04-30
|
||||||
|
|
||||||
- Fixed: Form submission for GET requests.
|
- Fixed: Form submission for GET requests.
|
||||||
|
|||||||
25
README.md
25
README.md
@@ -172,7 +172,7 @@ pjax.loadUrl("/your-url")
|
|||||||
pjax.loadUrl("/your-other-url", {timeout: 10})
|
pjax.loadUrl("/your-other-url", {timeout: 10})
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `handleResponse(responseText, request, href, options)`
|
#### `handleResponse(responseText, request, href)`
|
||||||
|
|
||||||
This method takes the raw response, processes the URL, then calls `pjax.loadContent()` to actually load it into the DOM.
|
This method takes the raw response, processes the URL, then calls `pjax.loadContent()` to actually load it into the DOM.
|
||||||
|
|
||||||
@@ -181,7 +181,6 @@ It is passed the following arguments:
|
|||||||
* **responseText** (string): This is the raw response text. This is equivalent to `request.responseText`.
|
* **responseText** (string): This is the raw response text. This is equivalent to `request.responseText`.
|
||||||
* **request** (XMLHttpRequest): This is the XHR object.
|
* **request** (XMLHttpRequest): This is the XHR object.
|
||||||
* **href** (string): This is the URL that was passed to `loadUrl()`.
|
* **href** (string): This is the URL that was passed to `loadUrl()`.
|
||||||
* **options** (object): This is an object with the options for this request. The structure basically matches the regular options object, with a few extra internal properties.
|
|
||||||
|
|
||||||
You can override this if you want to process the data before, or instead of, it being loaded into the DOM.
|
You can override this if you want to process the data before, or instead of, it being loaded into the DOM.
|
||||||
|
|
||||||
@@ -192,33 +191,15 @@ var pjax = new Pjax();
|
|||||||
|
|
||||||
pjax._handleResponse = pjax.handleResponse;
|
pjax._handleResponse = pjax.handleResponse;
|
||||||
|
|
||||||
pjax.handleResponse = function(responseText, request, href, options) {
|
pjax.handleResponse = function(responseText, request, href) {
|
||||||
if (request.responseText.match("<html")) {
|
if (request.responseText.match("<html")) {
|
||||||
pjax._handleResponse(responseText, request, href, options);
|
pjax._handleResponse(responseText, request, href);
|
||||||
} else {
|
} else {
|
||||||
// handle response here
|
// handle response here
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
#### `refresh([el])`
|
|
||||||
|
|
||||||
Use this method to bind Pjax to children of a DOM element that didn't exist when Pjax was initialised e.g. content inserted dynamically by another library or script. If called with no arguments, Pjax will parse the entire document again to look for newly-inserted elements.
|
|
||||||
|
|
||||||
```js
|
|
||||||
// Inside a callback or Promise that runs after new DOM content has been inserted
|
|
||||||
var newContent = document.querySelector(".new-content");
|
|
||||||
|
|
||||||
pjax.refresh(newContent);
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
#### `reload()`
|
|
||||||
|
|
||||||
A helper shortcut for `window.location.reload()`. Used to force a page reload.
|
|
||||||
|
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
##### `elements` (String, default: `"a[href], form[action]"`)
|
##### `elements` (String, default: `"a[href], form[action]"`)
|
||||||
|
|||||||
1
index.js
1
index.js
@@ -36,7 +36,6 @@ var Pjax = function(options) {
|
|||||||
var opt = clone(this.options)
|
var opt = clone(this.options)
|
||||||
opt.url = st.state.url
|
opt.url = st.state.url
|
||||||
opt.title = st.state.title
|
opt.title = st.state.title
|
||||||
// Since state already exists, prevent it from being pushed again
|
|
||||||
opt.history = false
|
opt.history = false
|
||||||
opt.scrollPos = st.state.scrollPos
|
opt.scrollPos = st.state.scrollPos
|
||||||
if (st.state.uid < this.lastUid) {
|
if (st.state.uid < this.lastUid) {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ module.exports = function(options) {
|
|||||||
options.selectors = options.selectors || ["title", ".js-Pjax"]
|
options.selectors = options.selectors || ["title", ".js-Pjax"]
|
||||||
options.switches = options.switches || {}
|
options.switches = options.switches || {}
|
||||||
options.switchesOptions = options.switchesOptions || {}
|
options.switchesOptions = options.switchesOptions || {}
|
||||||
options.history = (typeof options.history === "undefined") ? true : options.history
|
options.history = options.history || true
|
||||||
options.analytics = (typeof options.analytics === "function" || options.analytics === false) ? options.analytics : defaultAnalytics
|
options.analytics = (typeof options.analytics === "function" || options.analytics === false) ? options.analytics : defaultAnalytics
|
||||||
options.scrollTo = (typeof options.scrollTo === "undefined") ? 0 : options.scrollTo
|
options.scrollTo = (typeof options.scrollTo === "undefined") ? 0 : options.scrollTo
|
||||||
options.scrollRestoration = (typeof options.scrollRestoration !== "undefined") ? options.scrollRestoration : true
|
options.scrollRestoration = (typeof options.scrollRestoration !== "undefined") ? options.scrollRestoration : true
|
||||||
|
|||||||
@@ -67,8 +67,8 @@ function parseFormElements(el) {
|
|||||||
|
|
||||||
for (var i = 0; i < element.options.length; i++) {
|
for (var i = 0; i < element.options.length; i++) {
|
||||||
opt = element.options[i]
|
opt = element.options[i]
|
||||||
if (opt.selected && !opt.disabled) {
|
if (opt.selected) {
|
||||||
values.push(opt.hasAttribute("value") ? opt.value : opt.text)
|
values.push(opt.value || opt.text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ module.exports = function(responseText, request, href, options) {
|
|||||||
this.state.options = options
|
this.state.options = options
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.loadContent(responseText, options)
|
this.loadContent(responseText, this.options)
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
trigger(document, "pjax:error", options)
|
trigger(document, "pjax:error", options)
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ module.exports = function(location, options, callback) {
|
|||||||
request.setRequestHeader("X-PJAX-Selectors", JSON.stringify(options.selectors))
|
request.setRequestHeader("X-PJAX-Selectors", JSON.stringify(options.selectors))
|
||||||
|
|
||||||
// Send the proper header information for POST forms
|
// Send the proper header information for POST forms
|
||||||
if (requestPayload && requestMethod === "POST" && !formData) {
|
if (requestPayload && requestMethod === "POST") {
|
||||||
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
|
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
6892
package-lock.json
generated
6892
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
15
package.json
15
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "pjax",
|
"name": "pjax",
|
||||||
"version": "0.2.7",
|
"version": "0.2.6",
|
||||||
"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",
|
||||||
@@ -22,8 +22,7 @@
|
|||||||
"index.js",
|
"index.js",
|
||||||
"lib",
|
"lib",
|
||||||
"pjax.js",
|
"pjax.js",
|
||||||
"pjax.min.js",
|
"pjax.min.js"
|
||||||
"index.d.ts"
|
|
||||||
],
|
],
|
||||||
"types": "index.d.ts",
|
"types": "index.d.ts",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -44,14 +43,14 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "jscs . && jshint . --exclude-path .gitignore",
|
"lint": "jscs . && jshint . --exclude-path .gitignore",
|
||||||
"standalone": "browserify index.js --standalone Pjax > pjax.js",
|
"standalone": "browserify index.js --standalone Pjax > pjax.js",
|
||||||
"build": "npm run standalone && uglifyjs pjax.js -o pjax.min.js",
|
"build": "yarn run standalone && uglifyjs pjax.js -o pjax.min.js",
|
||||||
"build-debug": "browserify index.js --debug --standalone Pjax > pjax.js",
|
"build-debug": "browserify index.js --debug --standalone Pjax > pjax.js",
|
||||||
"tests": "tape -r ./tests/setup.js \"./tests/**/*.js\"",
|
"tests": "tape -r ./tests/setup.js \"./tests/**/*.js\"",
|
||||||
"test": "npm run lint && npm run tests | tap-spec",
|
"test": "yarn run lint && yarn run tests | tap-spec",
|
||||||
"coverage-tests": "npm run tests | tap-nyc",
|
"coverage-tests": "yarn run tests | tap-nyc",
|
||||||
"coverage": "nyc -x \"tests/**\" npm run coverage-tests",
|
"coverage": "nyc -x \"tests/**\" yarn run coverage-tests",
|
||||||
"example": "opn http://localhost:3000/example/ && serve -p 3000 .",
|
"example": "opn http://localhost:3000/example/ && serve -p 3000 .",
|
||||||
"prepublish": "npm run build",
|
"prepublish": "yarn run build",
|
||||||
"release": "npmpub"
|
"release": "npmpub"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user