$container.append(spinner);
$container.attr('data-infinite-serial', serial);
- // Combine infiniteContentParams from multiple
- // sources. filterable.js might put its params in
- // infiniteContentParamsFilterable, etc.
+ // Combine infiniteContentParams from multiple sources. This
+ // mechanism allows each of several components to set and
+ // update its own set of filters, without having to worry
+ // about stomping on some other component's filters.
+ //
+ // For example, filterable.js writes filters in
+ // infiniteContentParamsFilterable ("search for text foo")
+ // without worrying about clobbering the filters set up by the
+ // tab pane ("only show jobs and pipelines in this tab").
params = {};
$.each($container.data(), function(datakey, datavalue) {
+ // Note: We attach these data to DOM elements using
+ // <element data-foo-bar="baz">. We store/retrieve them
+ // using $('element').data('foo-bar'), although
+ // .data('fooBar') would also work. The "all data" hash
+ // returned by $('element').data(), however, always has
+ // keys like 'fooBar'. In other words, where we have a
+ // choice, we stick with the 'foo-bar' style to be
+ // consistent with HTML. Here, our only option is
+ // 'fooBar'.
if (/^infiniteContentParams/.exec(datakey)) {
if (datavalue instanceof Object) {
$.each(datavalue, function(hkey, hvalue) {
}
}
+function ping_all_scrollers() {
+ // Send a scroll event to all scroll listeners that might need
+ // updating. Adding infinite-scroller class to the window element
+ // doesn't work, so we add it explicitly here.
+ $('.infinite-scroller').add(window).trigger('scroll');
+}
+
$(document).
on('click', 'div.infinite-retry button', function() {
var $retry_div = $(this).closest('.infinite-retry');
$retry_div.attr('data-infinite-content-href'));
$retry_div.
replaceWith('<div class="spinner spinner-32px spinner-h-center" />');
- $('.infinite-scroller').trigger('scroll');
+ ping_all_scrollers();
}).
on('refresh-content', '[data-infinite-scroller]', function() {
// Clear all rows, reset source href to initial state, and
$(this).
html('').
attr('data-infinite-content-href', first_page_href);
- $('.infinite-scroller').
- trigger('scroll');
+ ping_all_scrollers();
}).
on('ready ajax:complete', function() {
$('[data-infinite-scroller]').each(function() {