Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add loading indicator to kaminari page links

  • Loading branch information...
commit 77b75aa216d32ccb9cf1b0f7ef685b903ca75305 1 parent 5b07e8f
@vhochstein authored
View
16 frontends/default/javascripts/jquery/active_scaffold.js
@@ -159,19 +159,27 @@ $(document).ready(function() {
ActiveScaffold.report_500_response(as_scaffold);
return true;
});
- $('a.as_paginate').live('ajax:before',function(event) {
+ $('nav.pagination a').live('ajax:before',function(event) {
var as_paginate = $(this);
+ var loading_indicator = as_paginate.closest('nav.pagination').find('img.loading-indicator').first();
var history_controller_id = as_paginate.attr('data-page-history');
if (history_controller_id) addActiveScaffoldPageToHistory(as_paginate.attr('href'), history_controller_id);
- as_paginate.prevAll('img.loading-indicator').css('visibility','visible');
+
+ if (loading_indicator == null || loading_indicator.length == 0) {
+ var table_loading_indicator = as_paginate.closest('div.active-scaffold').find('div.actions img.loading-indicator').first();
+ loading_indicator = table_loading_indicator.clone();
+ loading_indicator.attr('id', null);
+ as_paginate.closest('nav.pagination').prepend(loading_indicator);
+ }
+ loading_indicator.css('visibility','visible');
return true;
});
- $('a.as_paginate').live('ajax:failure', function(event) {
+ $('nav.pagination a').live('ajax:failure', function(event) {
var as_scaffold = $(this).closest('.active-scaffold');
ActiveScaffold.report_500_response(as_scaffold);
return true;
});
- $('a.as_paginate').live('ajax:complete', function(event) {
+ $('nav.pagination a').live('ajax:complete', function(event) {
$(this).prevAll('img.loading-indicator').css('visibility','hidden');
return true;
});
View
16 frontends/default/javascripts/prototype/active_scaffold.js
@@ -209,21 +209,27 @@ document.observe("dom:loaded", function() {
}
return true;
});
- document.on('ajax:before', 'a.as_paginate', function(event) {
+ document.on('ajax:before', 'nav.pagination a', function(event) {
var as_paginate = event.findElement();
- var loading_indicator = as_paginate.up().down('img.loading-indicator');
+ var loading_indicator = as_paginate.up(1).down('img.loading-indicator');
var history_controller_id = as_paginate.readAttribute('data-page-history');
if (history_controller_id) addActiveScaffoldPageToHistory(as_paginate.readAttribute('href'), history_controller_id);
- if (loading_indicator) loading_indicator.style.visibility = 'visible';
+ if (loading_indicator == null) {
+ var table_loading_indicator = as_paginate.up('div.active-scaffold').down('div.actions').down('img.loading-indicator');
+ loading_indicator = table_loading_indicator.cloneNode(true);
+ loading_indicator.id = null;
+ as_paginate.up(1).insert({top: loading_indicator});
+ }
+ loading_indicator.style.visibility = 'visible';
return true;
});
- document.on('ajax:failure', 'a.as_paginate', function(event) {
+ document.on('ajax:failure', 'nav.pagination a', function(event) {
var as_scaffold = event.findElement('.active-scaffold');
ActiveScaffold.report_500_response(as_scaffold);
return true;
});
- document.on('ajax:complete', 'a.as_paginate', function(event) {
+ document.on('ajax:complete', 'nav.pagination a', function(event) {
var as_paginate = event.findElement();
var loading_indicator = as_paginate.up().down('img.loading-indicator');
Please sign in to comment.
Something went wrong with that request. Please try again.