Skip to content
This repository has been archived by the owner on Jun 8, 2018. It is now read-only.

Commit

Permalink
add turbolinks support
Browse files Browse the repository at this point in the history
  • Loading branch information
amenzhinsky committed Apr 28, 2014
1 parent d0dd564 commit 8f7797b
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions lib/jquery.pageless.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -59,16 +59,7 @@
var namespace = '.pageless'; var namespace = '.pageless';
var SCROLL = 'scroll' + namespace; var SCROLL = 'scroll' + namespace;
var RESIZE = 'resize' + namespace; var RESIZE = 'resize' + namespace;
var settings = { var settings = {};
container: window,
currentPage: 1,
distance: 100,
pagination: '.pagination',
params: {},
url: location.href,
loaderImage: "/images/load.gif",
method: 'get'
};
var container; var container;
var $container; var $container;


Expand All @@ -81,6 +72,8 @@
}; };


$.pagelessReset = function () { $.pagelessReset = function () {
var inited = settings.inited;

settings = { settings = {
container: window, container: window,
currentPage: 1, currentPage: 1,
Expand All @@ -91,7 +84,14 @@
loaderImage: "/images/load.gif", loaderImage: "/images/load.gif",
method: 'get' method: 'get'
}; };
stopListener();
container = settings.container;
$container = $(container);

if (inited) {
stopListener();
}

// if there is a afterStopListener callback we call it // if there is a afterStopListener callback we call it
if (settings.end) { if (settings.end) {
settings.end.call(); settings.end.call();
Expand All @@ -112,19 +112,16 @@


// settings params: totalPages // settings params: totalPages
function init(opts) { function init(opts) {
if (settings.inited) { $.pagelessReset();
return;
}


settings.inited = true; if (!settings.inited) {
settings.inited = true;
}


if (opts) { if (opts) {
$.extend(settings, opts); $.extend(settings, opts);
} }


container = settings.container;
$container = $(container);

// for accessibility we can keep pagination links // for accessibility we can keep pagination links
// but since we have javascript enabled we remove pagination links // but since we have javascript enabled we remove pagination links
if (settings.pagination) { if (settings.pagination) {
Expand Down

0 comments on commit 8f7797b

Please sign in to comment.