X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/1e31ae09539d8265820a2f75f8a981f7d415ef58..f1827e2044aff826e63826880b296a59c4a17e2a:/apps/workbench/app/assets/javascripts/tab_panes.js diff --git a/apps/workbench/app/assets/javascripts/tab_panes.js b/apps/workbench/app/assets/javascripts/tab_panes.js index 6565ea9f4c..ddc5576d43 100644 --- a/apps/workbench/app/assets/javascripts/tab_panes.js +++ b/apps/workbench/app/assets/javascripts/tab_panes.js @@ -106,8 +106,8 @@ $(document).on('arv:pane:reload', '[data-pane-content-url]', function(e) { var content_url = $pane.attr('data-pane-content-url'); $.ajax(content_url, {dataType: 'html', type: 'GET', context: $pane}). done(function(data, status, jqxhr) { - // Preserve collapsed state var $pane = this; + // Preserve collapsed state var collapsable = {}; $(".collapse", this).each(function(i, c) { collapsable[c.id] = $(c).hasClass('in'); @@ -133,7 +133,23 @@ $(document).on('arv:pane:reload', '[data-pane-content-url]', function(e) { var $pane = this; var errhtml; var contentType = jqxhr.getResponseHeader('Content-Type'); - if (contentType && contentType.match(/\btext\/html\b/)) { + if (jqxhr.readyState == 0 || jqxhr.status == 0) { + if ($pane.attr('data-loaded-at') > 0) { + // Stale content is already present. Leave it + // there while loading the next page. + $pane.removeClass('pane-loading'); + $pane.addClass('pane-loaded'); + // ...but schedule another refresh (after a + // throttle delay) in case the act of navigating + // away gets cancelled itself, leaving this page + // with content that we know is stale. + $pane.addClass('pane-stale'); + $pane.attr('data-loaded-at', (new Date()).getTime()); + $pane.trigger('arv:pane:reload'); + return; + } + errhtml = "Cancelled."; + } else if (contentType && contentType.match(/\btext\/html\b/)) { var $response = $(jqxhr.responseText); var $wrapper = $('div#page-wrapper', $response); if ($wrapper.length) { @@ -148,7 +164,7 @@ $(document).on('arv:pane:reload', '[data-pane-content-url]', function(e) { replace(//g, '>'); } - $pane.html('

' + + $pane.html('

' + '' + ' ' + 'Reload tab

');