Permalink
Browse files

add turbolinks support

  • Loading branch information...
1 parent d0dd564 commit 8f7797be3a29612f5aad703b803bef7416fa576a @amenzhinsky amenzhinsky committed Apr 28, 2014
Showing with 15 additions and 18 deletions.
  1. +15 −18 lib/jquery.pageless.js
View
33 lib/jquery.pageless.js
@@ -59,16 +59,7 @@
var namespace = '.pageless';
var SCROLL = 'scroll' + namespace;
var RESIZE = 'resize' + namespace;
- var settings = {
- container: window,
- currentPage: 1,
- distance: 100,
- pagination: '.pagination',
- params: {},
- url: location.href,
- loaderImage: "/images/load.gif",
- method: 'get'
- };
+ var settings = {};
var container;
var $container;
@@ -81,6 +72,8 @@
};
$.pagelessReset = function () {
+ var inited = settings.inited;
+
settings = {
container: window,
currentPage: 1,
@@ -91,7 +84,14 @@
loaderImage: "/images/load.gif",
method: 'get'
};
- stopListener();
+
+ container = settings.container;
+ $container = $(container);
+
+ if (inited) {
+ stopListener();
+ }
+
// if there is a afterStopListener callback we call it
if (settings.end) {
settings.end.call();
@@ -112,19 +112,16 @@
// settings params: totalPages
function init(opts) {
- if (settings.inited) {
- return;
- }
+ $.pagelessReset();
- settings.inited = true;
+ if (!settings.inited) {
+ settings.inited = true;
+ }
if (opts) {
$.extend(settings, opts);
}
- container = settings.container;
- $container = $(container);
-
// for accessibility we can keep pagination links
// but since we have javascript enabled we remove pagination links
if (settings.pagination) {

0 comments on commit 8f7797b

Please sign in to comment.