Skip to content

Commit

Permalink
PJAX
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang committed Jul 29, 2019
1 parent 999f0f7 commit 84d8f35
Show file tree
Hide file tree
Showing 11 changed files with 220 additions and 168 deletions.
10 changes: 10 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,10 @@ math:
copy_tex_js: //cdn.jsdelivr.net/npm/katex@0/dist/contrib/copy-tex.min.js
copy_tex_css: //cdn.jsdelivr.net/npm/katex@0/dist/contrib/copy-tex.min.css

# Easily enable fast Ajax navigation on your website.
# Dependencies: https://github.com/theme-next/theme-next-pjax
pjax: false

# Fancybox. There is support for old version 2 and new version 3.
# Choose only one variant, do not need to install both.
# To install 2.x: https://github.com/theme-next/theme-next-fancybox
Expand Down Expand Up @@ -1012,6 +1016,12 @@ vendors:
# fontawesome: //cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css
fontawesome:

# Internal version: 0.2.8
# See: https://github.com/MoOx/pjax
# Example:
# pjax: //cdn.jsdelivr.net/npm/pjax@2/pjax.min.js
pjax:

# Internal version: 2.1.5 & 3.5.7
# See: https://fancyapps.com/fancybox
# Example:
Expand Down
36 changes: 34 additions & 2 deletions layout/_layout.swig
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
{%- set container_class = container_class + ' sidebar-position-' + theme.sidebar.position %}
{%- endif %}

<div class="{{ container_class }} {% block page_class %}{% endblock %}">
<div class="{{ container_class }}">
<div class="headband"></div>

<header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
Expand All @@ -48,7 +48,7 @@
{%- if theme.scheme === 'Pisces' || theme.scheme === 'Gemini' %}
{% include '_partials/header/sub-menu.swig' %}
{%- endif %}
<div id="content" class="content">
<div id="content" class="content {% block page_class %}{% endblock %}">
{% block content %}{% endblock %}
</div>
{% include '_partials/comments.swig' %}
Expand All @@ -62,7 +62,13 @@
<footer id="footer" class="footer">
<div class="footer-inner">
{{ partial('_partials/footer.swig', {}, {cache: theme.cache.enable}) }}
{%- if theme.pjax %}
<div id="reboot-analytics">
{%- endif %}
{% include '_partials/analytics/index.swig' %}
{%- if theme.pjax %}
</div>
{%- endif %}
{% block footer %}{% endblock %}
</div>
</footer>
Expand Down Expand Up @@ -92,11 +98,37 @@
{% include '_scripts/exturl.swig' %}
{% include '_scripts/three.swig' %}

{%- if theme.pjax %}
<div id="reboot-services">
{%- endif %}
{% include '_third-party/index.swig' %}

{%- for inject_item in theme.injects.bodyEnd %}
{{ partial(inject_item.layout, inject_item.locals, inject_item.options) }}
{%- endfor %}

{%- if theme.pjax %}
</div>
<script>
var pjax = new Pjax({
selectors: [
'title',
'meta[name=description]',
'#main'
]
});
$(document).on('pjax:success', function() {
$('#reboot-analytics script').remove().appendTo('#reboot-analytics');
$('#reboot-services script').remove().appendTo('#reboot-services');
$(document).trigger('ready');
// Define Motion Sequence & Bootstrap Motion.
CONFIG.motion.enable && NexT.motion.integrator
.init()
.add(NexT.motion.middleWares.postList)
.add(NexT.motion.middleWares.sidebar)
.bootstrap();
});
</script>
{%- endif %}
</body>
</html>
4 changes: 4 additions & 0 deletions layout/_scripts/vendors.swig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
{%- set js_defer_vendors = {} %}
{%- set js_vendors.jquery = 'jquery/index.js?v=3.4.1' %}

{%- if theme.pjax %}
{%- set js_vendors.pjax = 'pjax/pjax.min.js?v=0.2.8' %}
{%- endif %}

{%- if theme.fancybox %}
{%- set js_vendors.fancybox = 'fancybox/source/jquery.fancybox.pack.js' %}
{%- endif %}
Expand Down
2 changes: 1 addition & 1 deletion source/js/algolia-search.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* global instantsearch, CONFIG */

$(document).ready(function() {
$(document).on('ready', function() {
var algoliaSettings = CONFIG.algolia;
var isAlgoliaSettingsValid = algoliaSettings.applicationID
&& algoliaSettings.apiKey
Expand Down
2 changes: 1 addition & 1 deletion source/js/exturl.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion source/js/local-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

'use strict';

$(document).ready(function() {
$(document).on('ready', function() {
// Popup Window
var isfetched = false;
var datas;
Expand Down
Loading

0 comments on commit 84d8f35

Please sign in to comment.