-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1287 from PJ-568/master
feat(core): Add preliminary support for PJAX
- Loading branch information
Showing
7 changed files
with
71 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "/plugin/pjax.json", | ||
"description": "Enable PJAX", | ||
"type": "boolean", | ||
"default": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const { Component, Fragment } = require('inferno'); | ||
|
||
class Pjax extends Component { | ||
render() { | ||
if (this.props.head) { | ||
return null; | ||
} | ||
const { helper } = this.props; | ||
const { url_for, cdn } = helper; | ||
|
||
return <Fragment> | ||
<script src={cdn('pjax', '0.2.8', 'pjax.min.js')}></script> | ||
<script src={url_for('/js/pjax.js')}></script> | ||
</Fragment>; | ||
} | ||
} | ||
|
||
module.exports = Pjax; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
(function() { | ||
// eslint-disable-next-line no-unused-vars | ||
let pjax; | ||
|
||
function initPjax() { | ||
try { | ||
const Pjax = window.Pjax || function() {}; | ||
pjax = new Pjax({ | ||
selectors: [ | ||
'head title', | ||
'.columns', | ||
'.navbar-start', | ||
'.navbar-end', | ||
'.searchbox', | ||
'#back-to-top', | ||
'[data-pjax]', | ||
'.pjax-reload' | ||
] | ||
}); | ||
} catch (e) { | ||
console.warn('PJAX error: ' + e); | ||
} | ||
} | ||
|
||
// // Listen for start of Pjax | ||
// document.addEventListener('pjax:send', function() { | ||
// return; | ||
// // TODO pace start loading animation | ||
// }) | ||
|
||
// // Listen for completion of Pjax | ||
// document.addEventListener('pjax:complete', function() { | ||
// return; | ||
// // TODO pace stop loading animation | ||
// }) | ||
|
||
document.addEventListener('DOMContentLoaded', () => initPjax()); | ||
}()); |