ajax_pagination 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,6 +7,12 @@
7
7
  *
8
8
  * Copyright (c) 2012 Ronald Ping Man Chan
9
9
  * Distributed under the LGPL license
10
+ *
11
+ * Although the ajax_pagination gem as a whole is distributed under LGPL, I am expressly permitting users to minify and concatenate this javascript file
12
+ * with other javascript files, as long as it is through an automatic asset management process (eg. Sprockets), and the automatic asset
13
+ * management process obtains this javascript file as a separate file via dynamically linked means (ie. with this file left in the separately
14
+ * installed ajax_pagination gem).
15
+ * ~ Ronald Chan
10
16
  */
11
17
  jQuery(document).ready(function () {
12
18
  function minVersion(version) {
@@ -29,37 +35,124 @@ jQuery(document).ready(function () {
29
35
  var missing = "";
30
36
  if (!History) missing += "\nHistory.js not installed";
31
37
  if (!minVersion('<%= minjQuery %>')) missing += "\njQuery version <%= minjQuery %>+ not installed. Currently installed: jQuery " + window.jQuery.fn.jquery;
32
- alert("AJAX Pagination warning:" + missing);
38
+ alert("AJAX Pagination MISSING_DEPENDENCIES:" + missing);
33
39
  }
34
40
  <% end %>
35
- if (History && History.enabled && minVersion('<%= minjQuery %>')) {
36
- (function( $ ) {
41
+ (function( $ ) { // on document ready
42
+ if (History && History.enabled && minVersion('<%= minjQuery %>')) {
43
+ ///////////////////////////////////
44
+ ////// $.ajax_pagination API //////
45
+ ///////////////////////////////////
46
+ // selector function for pagination object
47
+ $.ajax_pagination = function (pagination_name) {
48
+ return new pagination_object(pagination_name);
49
+ };
50
+ $.ajax_pagination.version = '<%= AjaxPagination::VERSION %>';
51
+ $.ajax_pagination.enabled = true;
52
+ function pagination_object(pagination_name) {
53
+ this.get = function(url,options) {
54
+ if (options === undefined) options = {};
55
+ if (options.history === undefined) options.history = true;
56
+ swapPage(pagination_name,url,options.history);
57
+ }
58
+ this.exists = function() {
59
+ return $('#' + pagination_name + '_paginated_section').length == 1;
60
+ }
61
+ }
62
+ /////////////////////////////
63
+ ////// Basic Internals //////
64
+ /////////////////////////////
37
65
  var pagination_loader_state = new Array(); // the page we are waiting for
38
66
  var pagination_url = location.href; // url we came from, so we can see transitions of the url
67
+ var history_state = {ajax_pagination_set:true}; // current history state
39
68
 
40
69
  function display_pagination_loader(pagination_name) {
41
- if (pagination_loader_state[pagination_name] != undefined) return; // if already loading, don't reshow loader
42
- var paginated_section = $('#' + pagination_name + '_paginated_section');
43
- var paginated_content;
44
- if (paginated_section.hasClass("paginated_content")) paginated_content = paginated_section; // if the whole section is a loading zone
45
- else paginated_content = paginated_section.children(".paginated_content").first(); // don't want to support multiple loader images
46
- var height = paginated_content.height();
47
- // setup loading look
48
- var img = document.createElement("IMG");
49
- if (paginated_section.data("pagination") !== undefined && paginated_section.data("pagination").image !== undefined) img.src = paginated_section.data("pagination").image;
50
- else img.src = "<%= asset_path AjaxPagination.loading_image %>";
51
- var margin = Math.round(height>400?100:(height/4));
52
- $(img).css({'margin': margin + 'px', 'max-height': (3*height/4) + 'px'}).addClass('ajaxloader');
53
- var div = document.createElement("DIV");
54
- $(div).append(img);
55
- $(div).css({'position': 'absolute', 'left': 0, 'top': 0, 'width': '100%', 'height': '100%', 'text-align': 'center', 'opacity': 0.9});
56
- paginated_content.children().css({'opacity': 0.4});
57
- paginated_content.append(div);
58
-
59
- // scroll to top of paginated_section if it is not visible
60
- if ($(document).scrollTop() > paginated_section.offset().top - <%= AjaxPagination.scroll_margin %>) {
61
- $(document).scrollTop(paginated_section.offset().top - <%= AjaxPagination.scroll_margin %>);
70
+ var paginated_section = getSection(pagination_name);
71
+ if (pagination_loader_state[pagination_name] === undefined) { // show loader if not already shown
72
+ if ($.rails.fire(getSection(pagination_name),"ajaxp:loading")) {
73
+ var paginated_content;
74
+ if (paginated_section.hasClass("paginated_content")) paginated_content = paginated_section; // if the whole section is a loading zone
75
+ else paginated_content = paginated_section.children(".paginated_content").first(); // don't want to support multiple loader images
76
+ var height = paginated_content.height();
77
+ // setup loading look
78
+ var img = document.createElement("IMG");
79
+ if (paginated_section.data("pagination") !== undefined && paginated_section.data("pagination").image !== undefined) img.src = paginated_section.data("pagination").image;
80
+ else img.src = "<%= asset_path AjaxPagination.loading_image %>";
81
+ var margin = Math.round(height>400?50:(height/8));
82
+ $(img).addClass('ajaxpagination-loader');
83
+ var div = document.createElement("DIV");
84
+ $(div).addClass('ajaxpagination-loadzone');
85
+ $(div).append("<div class=\"margin-top\" />").append(img);
86
+ paginated_content.wrapInner("<div class=\"ajaxpagination-oldcontent\" />");
87
+ paginated_content.append(div);
88
+ }
89
+ }
90
+ if ($.rails.fire(getSection(pagination_name),"ajaxp:focus")) {
91
+ // scroll to top of paginated_section if it is not visible
92
+ if ($(document).scrollTop() > paginated_section.offset().top - <%= AjaxPagination.scroll_margin %>) {
93
+ $(document).scrollTop(paginated_section.offset().top - <%= AjaxPagination.scroll_margin %>);
94
+ }
95
+ }
96
+ }
97
+ function getSection(pagination_name) {
98
+ var id = "#" + pagination_name + "_paginated_section"; // element id we are looking for
99
+ return $(id);
100
+ }
101
+ function getSectionName(section) {
102
+ var id = section.attr("id");
103
+ if (id === undefined) return undefined; // no name
104
+ var pagination_name = /^(.*)_paginated_section$/.exec(id)[1];
105
+ if (pagination_name == null || pagination_name === undefined) return undefined; // pagination not set up properly
106
+ return pagination_name;
107
+ }
108
+ function getSectionNames(sections) {
109
+ var names = new Array();
110
+ sections.each(function () {
111
+ names.push(getSectionName($(this)));
112
+ });
113
+ return names;
114
+ }
115
+ function intersects(a,b) { // do the arrays a and b intersect?
116
+ var i=0, j=0;
117
+ while (i < a.length && j < b.length) {
118
+ if (a[i]<b[j]) i++;
119
+ else if (a[i]>b[j]) j++;
120
+ else return true; // intersects
121
+ }
122
+ return false; // doesn't intersect
123
+ }
124
+ // whether change of state is a reload
125
+ function isReload(pagination_name,from,to) {
126
+ if (from == to) return true; // same url - always a reload
127
+ var section = getSection(pagination_name);
128
+ if (section.length == 0) return false;
129
+
130
+ // if data-pagination is not defined, then no reload can be detected
131
+ if (section.data('pagination') === undefined || section.data('pagination').reload === undefined) return false;
132
+
133
+ var reload = section.data('pagination').reload;
134
+ if (!(reload instanceof Array)) reload = new Array(reload);
135
+ for (i=0;i<reload.length;i++) {
136
+ if (reload[i].query !== undefined) {
137
+ if ($.deparam.querystring(from)[reload[i].query] !== $.deparam.querystring(to)[reload[i].query]) return false;
138
+ }
139
+ if (reload[i].urlregex !== undefined) {
140
+ var fstr = from, tstr = to;
141
+ if (reload[i].urlpart !== undefined) {
142
+ fstr = $.url(from,true).attr(reload[i].urlpart);
143
+ tstr = $.url(to,true).attr(reload[i].urlpart);
144
+ if (typeof(fstr)!="string" || typeof(tstr)!="string") continue; // skip
145
+ }
146
+ var index = 0;
147
+ if (reload[i].regexindex !== undefined) index = reload[i].regexindex;
148
+ var regex = new RegExp(reload[i].urlregex);
149
+ var frommatch = regex.exec(fstr), tomatch = regex.exec(tstr);
150
+ if (frommatch != null && frommatch.length>=index) frommatch = frommatch[index];
151
+ if (tomatch != null && tomatch.length>=index) tomatch = tomatch[index];
152
+ if (frommatch !== tomatch) return false;
153
+ }
62
154
  }
155
+ return true;
63
156
  }
64
157
  // when this function is used beforeSend of an AJAX request, will use the resulting content in a section of the page
65
158
  // this event handler has the same arguments as for jquery and jquery-ujs, except it also takes the name of the section to put the content into as first argument
@@ -67,12 +160,14 @@ jQuery(document).ready(function () {
67
160
  function beforeSendHandler(pagination_name,jqXHR,settings) {
68
161
  var id = "#" + pagination_name + "_paginated_section"; // element id we are looking for
69
162
  var requesturl = settings.url;
70
- if ($(id).length != 1) { // something wrong, cannot find unique section to load page into
163
+ var countid = $('[id="' + pagination_name + '_paginated_section"]').length;
164
+ if (countid != 1) { // something wrong, cannot find unique section to load page into
71
165
  <% if AjaxPagination.warnings %>
72
- alert("AJAX Pagination warning:\nExpected one pagination section called " + pagination_name + ", found " + $("#" + pagination_name + "_paginated_section").length);
166
+ alert("AJAX Pagination UNIQUE_SECTION_NOT_FOUND:\nExpected one pagination section called " + pagination_name + ", found " + countid);
73
167
  <% end %>
74
168
  return false; // continue AJAX normally
75
169
  }
170
+ if (!$.rails.fire(getSection(pagination_name),"ajaxp:beforeSend",[jqXHR,settings])) return false;
76
171
  display_pagination_loader(pagination_name);
77
172
  // register callbacks for other events
78
173
  jqXHR.done(function(data, textStatus, jqXHR) {
@@ -81,47 +176,81 @@ jQuery(document).ready(function () {
81
176
  var redirecturl = jqXHR.getResponseHeader('Location');
82
177
  swapPage(pagination_name,redirecturl);
83
178
  pagination_url = redirecturl;
84
- History.replaceState(null,document.title,redirecturl);
179
+ History.replaceState(history_state,document.title,redirecturl); // state not changed
85
180
  return;
86
181
  }
87
182
  // find matching element id in data, after removing script tags
88
- var page = $("<div>").append(data.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,""));
183
+ var page = $("<div />");
184
+ page[0].innerHTML = data; // put response in DOM without executing scripts
185
+
186
+ // if page contains a title, use it
187
+ var title = page.find("title");
188
+ if (title.length>0) History.replaceState(history_state,title.html(),location.href);
189
+
190
+ // get page contents
89
191
  var content = page.find(id);
90
192
  if (content.length>0) {
91
- $(id).html(content.html());
193
+ content = content.html();
92
194
  <% if AjaxPagination.warnings %>
93
- alert("AJAX Pagination warning:\nExtra content returned by AJAX request ignored. Only a portion of the page content returned by the server was required. To fix this, explicitly call ajax_pagination for :pagination => \"" + pagination_name + "\" to render only the partial view required. This warning can be turned off in the ajax_pagination initializer file.");
195
+ alert("AJAX Pagination EXTRA_CONTENT_DISCARDED:\nExtra content returned by AJAX request ignored. Only a portion of the page content returned by the server was required. To fix this, explicitly call ajax_pagination for :pagination => \"" + pagination_name + "\" to render only the partial view required. This warning can be turned off in the ajax_pagination initializer file.");
94
196
  <% end %>
95
197
  }
96
198
  else { // otherwise use all the content, including any scripts - we consider scripts specifically returned in the partial probably should be re-run
97
- page = $("<div>").append(data);
98
- content = page.find("body");
99
- if (content.length>0) $(id).html(content.html()); // if it has a body tag, only include its contents (for full html structure), leaving out <head> etc sections.
100
- else $(id).html(page.html()); // otherwise include the whole html snippet
199
+ content = page.find("body"); // does not tend to work since browsers strip out the html, head, body tags
200
+ if (content.length>0) content = content.html(); // if it has a body tag, only include its contents (for full html structure), leaving out <head> etc sections.
201
+ else content = page.html(); // otherwise include the whole html snippet
101
202
  }
102
- // if page contains a title, use it
103
- content = page.find("title");
104
- if (content.length>0) History.replaceState(null,content.html(),location.href);
203
+
204
+ if ($.rails.fire(getSection(pagination_name),"ajaxp:done",[content])) $(id).html(content);
205
+
105
206
  delete pagination_loader_state[pagination_name]; // not waiting for page anymore
207
+
208
+ $.rails.fire(getSection(pagination_name),"ajaxp:loaded");
106
209
  });
107
210
  jqXHR.fail(function(jqXHR, textStatus, errorThrown) {
108
211
  if (requesturl != pagination_loader_state[pagination_name]) return; // ignore stale content
109
- $(id).html(jqXHR.responseText);
212
+ if ($.rails.fire(getSection(pagination_name),"ajaxp:fail",[jqXHR.responseText])) $(id).html(jqXHR.responseText);
213
+
110
214
  delete pagination_loader_state[pagination_name]; // not waiting for page anymore
215
+
216
+ $.rails.fire(getSection(pagination_name),"ajaxp:loaded");
111
217
  });
112
218
  return true;
113
219
  }
114
- function swapPage(pagination_name,requesturl) { // swaps the page at pagination_name to that from requesturl (used by History.popState, therefore no remote link has been clicked)
220
+ function swapPage(pagination_name, requesturl, history) { // swaps the page at pagination_name to that from requesturl (used by History.popState, therefore no remote link has been clicked)
221
+ if (history === undefined) history = false;
115
222
  // send our own ajax request, and tie it into the beforeSendHandler used for jquery-ujs as well
223
+ if (!$.rails.fire(getSection(pagination_name),"ajaxp:before",[requesturl,undefined])) return false;
116
224
  $.ajax({url: requesturl, data: {pagination:pagination_name},
117
225
  dataType: 'html',
118
226
  beforeSend: function (jqXHR,settings) {
119
227
  var result = beforeSendHandler(pagination_name,jqXHR,settings);
120
- pagination_loader_state[pagination_name] = settings.url; // remember which page number we are waiting for
228
+ if (result) {
229
+ if (history) pushHistory(pagination_name,settings.url);
230
+ pagination_loader_state[pagination_name] = settings.url; // remember which page number we are waiting for
231
+ }
121
232
  return result;
122
233
  }
123
234
  });
124
235
  }
236
+ function pushHistory(pagination_name,url) {
237
+ var data = $("#" + pagination_name + "_paginated_section").data("pagination");
238
+ if (data === undefined || data.history === undefined || data.history) { // check that history is not disabled
239
+ // construct visible url
240
+ var data = $.deparam.querystring($.url(url).attr('query'));
241
+ delete data['pagination'];
242
+ pagination_url = $.param.querystring(url,data,2);
243
+ if (isReload(pagination_name,url,location.href)) History.replaceState(history_state,document.title,pagination_url);
244
+ else { // not just a reload of current page, so do actual pushState
245
+ // change current history state, and push it on
246
+ if (history_state.ajax_pagination === undefined) history_state.ajax_pagination = new Array();
247
+ var fieldname = "_" + pagination_name;
248
+ if (history_state.ajax_pagination[fieldname] === undefined) history_state.ajax_pagination[fieldname]=1;
249
+ else history_state.ajax_pagination[fieldname]++;
250
+ History.pushState(history_state,document.title,pagination_url); // push state
251
+ }
252
+ }
253
+ }
125
254
  // these special containers are for convenience only, to apply the required data-remote, data-pagination attributes to all links inside
126
255
  $(document).on("click", ".pagination a, .ajaxpagination a, a.ajaxpagination", function(e) {
127
256
  // ignore if already selected by jquery-ujs
@@ -133,7 +262,7 @@ jQuery(document).ready(function () {
133
262
  pagination_name = /^(.*)_paginated_section$/.exec($(this).closest(".paginated_section").attr("id")); // if data-pagination not present, search up the tree for a suitable section
134
263
  if (pagination_name == null) {
135
264
  <% if AjaxPagination.warnings %>
136
- alert("AJAX Pagination warning:\nNo pagination section name given for link, and none could be implicitly assigned, AJAX cancelled for this request");
265
+ alert("AJAX Pagination MISSING_REFERENCE:\nNo pagination section name given for link, and none could be implicitly assigned, AJAX cancelled for this request");
137
266
  <% end %>
138
267
  return true; // pagination not set up properly
139
268
  }
@@ -149,83 +278,103 @@ jQuery(document).ready(function () {
149
278
  // stop this event from having further effect (because we do not know if jquery-ujs's event handler executed before or after us)
150
279
  e.preventDefault();
151
280
  e.stopImmediatePropagation();
152
- // click element again to dispatch the event all over again - thus ensuring it is handled by jquery-ujs
153
- $(this).click();
281
+ // pass it on the jquery-ujs
282
+ $.rails.handleRemote($(this));
154
283
  return false;
155
284
  });
156
285
  $(document).on("ajax:before","a, " + $.rails.inputChangeSelector, function() {
157
286
  var pagination_name = $(this).data('pagination');
158
287
  if (pagination_name === undefined) return true; // this is not an AJAX Pagination AJAX request
159
288
  $(this).data('params',$.extend($(this).data('params'),{'pagination':pagination_name})); // add data-pagination to the params data
160
- return true;
289
+ return $.rails.fire(getSection(pagination_name),"ajaxp:before",[this.href,$(this).data('method')]);
161
290
  });
162
291
  $(document).on("ajax:before","form", function() {
292
+ var pagination_name = $(this).data('pagination');
293
+ if (pagination_name === undefined) return true; // this is not an AJAX Pagination AJAX request
163
294
  // alter action to include pagination parameter in the GET part of the action url
164
- $(this).attr('action',$.param.querystring($(this).attr('action'),{pagination:$(this).data('pagination')}));
295
+ $(this).attr('action',$.param.querystring($(this).attr('action'),{pagination:pagination_name}));
296
+ return $.rails.fire(getSection(pagination_name),"ajaxp:before",[$(this).attr('action'),$(this).data('method')]);
165
297
  });
166
298
  $(document).on("ajax:beforeSend","a, form, " + $.rails.inputChangeSelector, function (e,jqXHR,settings) {
167
299
  var pagination_name = $(this).data('pagination');
168
300
  if (pagination_name === undefined) return true; // this is not an AJAX Pagination AJAX request
169
301
  if (beforeSendHandler(pagination_name,jqXHR,settings)) {
170
- var data = $("#" + pagination_name + "_paginated_section").data("pagination");
171
- if (data === undefined || data.history === undefined || data.history) {
172
- var data = $.deparam.querystring($.url(settings.url).attr('query'));
173
- delete data['pagination'];
174
- pagination_url = $.param.querystring(settings.url,data,2);
175
- History.pushState(null,document.title,pagination_url);
176
- }
302
+ pushHistory(pagination_name,settings.url);
177
303
  pagination_loader_state[pagination_name] = settings.url;
178
304
  }
179
305
  return true;
180
306
  });
307
+ History.Adapter.bind(window,'popstate',function(e){ // popstate, but can work with hash changes as well
308
+ //var from = pagination_url, to = location.href; // from what state to what other state
309
+ var state = History.getState().data || {};
310
+ state.ajax_pagination = state.ajax_pagination || {};
311
+ history_state.ajax_pagination = history_state.ajax_pagination || {};
312
+ if (!state.ajax_pagination_set) { // page first visited (if refresh, state remains)
313
+ state.ajax_pagination = history_state.ajax_pagination; // put current known state in
314
+ state.ajax_pagination_set = true; // special flag so that we know its touched
315
+ History.replaceState(state,document.title,location.href);
316
+ return;
317
+ }
318
+ var allsections = {};
319
+ for (var field in state.ajax_pagination) {
320
+ //if (getSection(field.substr(1)).length == 0) delete state.ajax_pagination[field]; // section no longer exists in current page, so can be deleted
321
+ // edit it cannot be deleted anymore, because if history changes, section tree node not necessarily reloaded
322
+ allsections[field] = true;
323
+ }
324
+ for (var field in history_state.ajax_pagination) allsections[field] = true;
181
325
 
182
- History.Adapter.bind(window,'popstate',function(){ // popstate, but can work with hash changes as well
183
- var from = pagination_url, to = location.href; // from what state to what other state
184
-
185
- $(".paginated_section").each(function(){
186
- var pagination_name = /^(.*)_paginated_section$/.exec($(this).attr("id"))[1];
187
- if (pagination_name == null) return; // pagination not set up properly
188
-
189
- // if data-pagination is not defined, the use default reload test
190
- if ($(this).data('pagination') === undefined || $(this).data('pagination').reload === undefined) {
191
- // if ?pagination_name=ABC, where ABC is the same for both urls, then don't need to reload
192
- if ($.deparam.querystring(from)[pagination_name] === $.deparam.querystring(to)[pagination_name]) return;
326
+ var changedsections = new Array();
327
+ for (var section in allsections) {
328
+ var from = history_state.ajax_pagination[section] || 0;
329
+ var to = state.ajax_pagination[section] || 0;
330
+ if (from != to) {
331
+ // schedule for loading only if not a refresh (changing browser history does not cause a refresh unless it is explicitly requested)
332
+ //alert('testing ' + section);
333
+ if (!isReload(section.substr(1),location.href,pagination_url)) changedsections.push(section.substr(1)); // this section changed
193
334
  }
194
- else { // otherwise parse json and perform tests
195
- var reload = $(this).data('pagination').reload;
196
- if (!(reload instanceof Array)) reload = new Array(reload);
197
- var changed = false;
198
- for (i=0;i<reload.length;i++) {
199
- if (reload[i].query !== undefined) {
200
- if ($.deparam.querystring(from)[reload[i].query] !== $.deparam.querystring(to)[reload[i].query]) changed = true;
201
- }
202
- if (reload[i].urlregex !== undefined) {
203
- var fstr = from, tstr = to;
204
- if (reload[i].urlpart !== undefined) {
205
- fstr = $.url(from,true).attr(reload[i].urlpart);
206
- tstr = $.url(to,true).attr(reload[i].urlpart);
207
- if (typeof(fstr)!="string" || typeof(tstr)!="string") continue; // skip
208
- }
209
- var index = 0;
210
- if (reload[i].regexindex !== undefined) index = reload[i].regexindex;
211
- var regex = new RegExp(reload[i].urlregex);
212
- var frommatch = regex.exec(fstr), tomatch = regex.exec(tstr);
213
- if (frommatch != null && frommatch.length>=index) frommatch = frommatch[index];
214
- if (tomatch != null && tomatch.length>=index) tomatch = tomatch[index];
215
- if (frommatch !== tomatch) changed = true;
216
- }
217
- if (changed) break;
218
- }
219
- if (!changed) return; // otherwise it has changed, and we must reload
335
+ }
336
+ history_state = state; // we can update our view of the state now
337
+
338
+ changedsections.sort(); // sort the pagination_names stored in array
339
+ for (var i = 0; i < changedsections.length; i++) {
340
+ var section = getSection(changedsections[i]);
341
+ if (section.length == 0) continue; // no longer exists on page (meaning it does not need reloading)
342
+ var parentsections = getSectionNames(section.parents(".paginated_section"));
343
+ parentsections.sort();
344
+ // check for intersection
345
+ if (!intersects(changedsections,parentsections)) { // no intersection, load new content in this section
346
+ swapPage(changedsections[i],location.href);
220
347
  }
221
- swapPage(pagination_name,location.href);
222
- });
348
+ }
223
349
 
224
350
  pagination_url = location.href; // update url (new url recognised)
225
351
  });
226
352
 
227
353
  History.Adapter.trigger(window,"popstate"); // update stuff on page load
228
- })( jQuery );
229
- }
354
+
355
+ // trigger a loaded event on each section on initial page load
356
+ $.rails.fire($(".paginated_section"),"ajaxp:loaded");
357
+ }
358
+ else {
359
+ // AJAX Pagination is disabled, we need to tidy up a few things to keep things working
360
+
361
+ // remove remote attribute globally
362
+ $("a[data-pagination]").removeData('remote');
363
+ $("a[data-pagination]").removeAttr('data-remote');
364
+ $("form[data-pagination]").removeData('remote');
365
+ $("form[data-pagination]").removeAttr('data-remote');
366
+
367
+ // set an event handler to remove the remote attribute if new content is loaded with AJAX Pagination
368
+ $(document).children().add(".paginated_section").delegate("a, input, form","click.rails change.rails submit.rails", function(event) {
369
+ var element = $(event.target);
370
+ if (element.data('pagination') === undefined) return true;
371
+ else {
372
+ element.removeData('remote');
373
+ element.removeAttr('data-remote');
374
+ }
375
+ }); // note using delegate for this instance for backwards compatibility, since might be disabled due to old jQuery version
376
+
377
+ }
378
+ })( jQuery );
230
379
  });
231
380
 
@@ -0,0 +1,24 @@
1
+ .ajaxpagination-loadzone > .margin-top {
2
+ height: 50px;
3
+ max-height: 12.5%;
4
+ width: 100%;
5
+ }
6
+
7
+ .ajaxpagination-loader {
8
+ max-height: 87.5%;
9
+ }
10
+
11
+ .ajaxpagination-oldcontent {
12
+ opacity: 0.4;
13
+ }
14
+
15
+ .ajaxpagination-loadzone {
16
+ position: absolute;
17
+ left: 0;
18
+ top: 0;
19
+ width: 100%;
20
+ height: 100%;
21
+ text-align: center;
22
+ opacity: 0.9;
23
+ }
24
+