1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-12-23 01:30:01 +01:00

kill infinite scroll

This commit is contained in:
Matthias Kretschmann 2015-05-31 21:56:40 +02:00
parent d2e2832da4
commit 1af2abd77d
8 changed files with 50 additions and 143 deletions

View File

@ -105,11 +105,10 @@ module.exports = function(grunt){
'node_modules/picturefill/dist/picturefill.js' 'node_modules/picturefill/dist/picturefill.js'
], ],
'<%= config.site %>/<%= config.assets.js %>/CustomElements.min.js': [ '<%= config.site %>/<%= config.assets.js %>/CustomElements.min.js': [
'node_modules/webcomponentsjs/CustomElements.js' 'node_modules/webcomponents.js/CustomElements.js'
], ],
'<%= config.site %>/<%= config.assets.js %>/kremalicious3.min.js': [ '<%= config.site %>/<%= config.assets.js %>/kremalicious3.min.js': [
'node_modules/jquery/dist/jquery.js', 'node_modules/jquery/dist/jquery.js',
'bower_components/jquery-infinite-scroll/jquery.infinitescroll.js',
'node_modules/masonry-layout/dist/masonry.pkgd.js', 'node_modules/masonry-layout/dist/masonry.pkgd.js',
'node_modules/imagesloaded/imagesloaded.js', 'node_modules/imagesloaded/imagesloaded.js',
'bower_components/simple-jekyll-search/dest/jekyll-search.js', 'bower_components/simple-jekyll-search/dest/jekyll-search.js',

View File

@ -23,7 +23,7 @@ author:
# -------------------- # --------------------
permalink: /:title/ permalink: /:title/
paginate: 15 paginate: 10
paginate_path: "/page/:num" paginate_path: "/page/:num"
category_dir: "/" category_dir: "/"
category_title_prefix: "" category_title_prefix: ""

View File

@ -30,7 +30,7 @@
<title> <title>
{% if paginator.previous_page %} {% if paginator.previous_page %}
Page {{ paginator.page }} &brvbar; {{ page.title }} Page {{ paginator.page }} &brvbar; {{ site.name }}
{% elsif page.title %} {% elsif page.title %}
{{ page.title }} &brvbar; {{ site.name }} {{ page.title }} &brvbar; {{ site.name }}
{% else %} {% else %}

View File

@ -2,49 +2,44 @@
<nav class="row paginator"> <nav class="row paginator">
<p class="paginator-previous col2">
{% if paginator.previous_page %} {% if paginator.previous_page %}
<p class="previous col2"> <a
<i class="icon-arrow-left"></i>
{% if page.category %} {% if page.category %}
{% if paginator.previous_page == 1 %} {% if paginator.previous_page == 1 %}
<a href="/{{ page.category }}/" rel="prev">Previous</a> href="/{{ page.category }}/"
{% else %} {% else %}
<a href="/{{ page.category }}/page/{{ paginator.previous_page }}/" rel="prev">Previous</a> href="/{{ page.category }}/page/{{ paginator.previous_page }}/"
{% endif %} {% endif %}
{% else %} {% else %}
{% if paginator.previous_page == 1 %} {% if paginator.previous_page == 1 %}
<a href="/" rel="prev">Previous</a> href="/"
{% else %} {% else %}
<a href="/page/{{ paginator.previous_page }}/" rel="prev">Previous</a> href="/page/{{ paginator.previous_page }}/"
{% endif %} {% endif %}
{% endif %} {% endif %}
rel="prev"><i class="icon icon-arrow-left"></i> Previous
</a>
{% endif %}
</p> </p>
{% endif %}
<p class="col2 pagenumber textcenter"> <p class="col2 pagenumber textcenter">
<span class="page_number ">Page {{ paginator.page }} of {{ paginator.total_pages }}</span> <span class="paginator-number ">Page {{ paginator.page }} of {{ paginator.total_pages }}</span>
</p> </p>
<p class="paginator-next col2">
{% if paginator.next_page %} {% if paginator.next_page %}
<p class="next col2"> <a
{% if page.category %} {% if page.category %}
<a href="/{{ page.category }}/page/{{ paginator.next_page }}/" rel="next">Next</a> href="/{{ page.category }}/page/{{ paginator.next_page }}/"
{% else %} {% else %}
<a href="/page/{{ paginator.next_page }}/" rel="next">Next</a> href="/page/{{ paginator.next_page }}/"
{% endif %} {% endif %}
<i class="icon-arrow-right"></i> rel="next">Next <i class="icon icon-arrow-right"></i>
</p> </a>
{% else %}
<p class="next col2">
The End
</p>
{% endif %} {% endif %}
</p>
</nav> </nav>

View File

@ -2,7 +2,6 @@ $(ASAP = function() {
siteNavigation.init(); siteNavigation.init();
siteEffects.init(); siteEffects.init();
infiniteScroll.init();
}); });
@ -156,81 +155,3 @@ var siteEffects = {
} }
} }
var infiniteScroll = {
infiniteScrollSetup: function() {
if ($('.page-photos').length > 0) {
var items = '#main .masonry';
} else {
var items = '#main article.hentry';
}
var $scrollContent = $('#main');
$scrollContent.infinitescroll({
loading: {
img: ''
},
itemSelector: items,
nextSelector: '.next a',
navSelector: '.paginator',
binder: $scrollContent,
behavior: 'krlc3',
}, function($scrollContent) {
// run picturefill over retrieved items
picturefill();
// run the photogrid over retrieved items
photoGrid.init();
});
},
init: function() {
this.infiniteScrollSetup();
}
}
/*
--------------------------------
Infinite Scroll Behavior
Manual mode with minimal loader
Usage: behavior: 'krlc3'
--------------------------------
*/
$.extend($.infinitescroll.prototype, {
_setup_krlc3: function infscr_setup_krlc3() {
var opts = this.options,
instance = this,
loader = $('<span class="loading"> ...</span>');
$(opts.nextSelector).parent().parent().addClass('infiniteLoader');
// Bind nextSelector link to retrieve
$(opts.nextSelector).click(function(e) {
if (e.which == 1 && !e.metaKey && !e.shiftKey) {
e.preventDefault();
instance.retrieve();
}
});
// custom start
instance.options.loading.start = function(opts) {
loader
.appendTo(opts.nextSelector)
.show(opts.loading.speed, function() {
instance.beginAjax(opts);
});
}
// custom finish
instance.options.loading.finished = function(opts) {
loader.detach();
};
}
});

View File

@ -91,35 +91,24 @@
.paginator .paginator
@extend .clearfix @extend .clearfix
p .icon
position: relative vertical-align: middle
a
display: block
i .paginator-next
position: absolute
left: 0
top: 0
.next
@extend .alignright @extend .alignright
text-align: right text-align: right
a .paginator-previous
margin-right: 1.5em
i
margin-left: .5em
left: auto
right: 0
.previous
@extend .alignleft @extend .alignleft
a .paginator-number
margin-left: 1.5em font-size: $font-size-small
i color: $brand-grey-light
margin-right: .5em
.paginator-title
@extend .h3, .heading-band
color: $brand-grey-light
margin-bottom: 0
// Infinite Loader // Infinite Loader

View File

@ -15,6 +15,10 @@ redirect_from:
<section role="main" id="main" class="row"> <section role="main" id="main" class="row">
{% if paginator.previous_page %}
<h1 class="paginator-title">Page {{ paginator.page }}</h1>
{% endif %}
{% for post in paginator.posts %} {% for post in paginator.posts %}
{% include articles.html %} {% include articles.html %}

View File

@ -8,7 +8,6 @@
"description": "Blog of Matthias Kretschmann", "description": "Blog of Matthias Kretschmann",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"jquery-infinite-scroll": ">=2.0.2",
"simple-jekyll-search": ">=1.0.6", "simple-jekyll-search": ">=1.0.6",
"time-elements": ">=0.4.0" "time-elements": ">=0.4.0"
}, },