Generalize lazy tabs

This commit is contained in:
Eelco Dolstra 2013-02-22 13:36:15 +01:00
parent e2e973578f
commit 47d2ee0dab
2 changed files with 24 additions and 21 deletions

View file

@ -513,32 +513,14 @@
[% END %] [% END %]
[% IF drvAvailable %] [% IF drvAvailable %]
<div id="tabs-build-deps" class="tab-pane"> [% INCLUDE makeLazyTab tabName="tabs-build-deps" uri=c.uri_for('/build' build.id 'build-deps') %]
<center><img src="/static/images/ajax-loader.gif" alt="Loading..." /></center>
</div>
[% END %] [% END %]
[% IF available %] [% IF available %]
<div id="tabs-runtime-deps" class="tab-pane"> [% INCLUDE makeLazyTab tabName="tabs-runtime-deps" uri=c.uri_for('/build' build.id 'runtime-deps') %]
<center><img src="/static/images/ajax-loader.gif" alt="Loading..." /></center>
</div>
[% END %] [% END %]
</div> </div>
<script>
$(function() {
$('.nav-tabs').bind('show', function(e) {
var pattern = /#.+/gi;
var id = e.target.toString().match(pattern)[0];
if (id == "#tabs-runtime-deps") {
$('#tabs-runtime-deps').load("[% c.uri_for('/build' build.id 'runtime-deps') %]");
} else if (id == "#tabs-build-deps") {
$('#tabs-build-deps').load("[% c.uri_for('/build' build.id 'build-deps') %]");
}
});
});
</script>
[% END %] [% END %]

View file

@ -448,4 +448,25 @@ BLOCK renderEvals %]
BLOCK renderLogLinks %] BLOCK renderLogLinks %]
(<a href="[% url %]">log</a>, <a href="[% "$url/raw" %]">raw</a>, <a href="[% "$url/tail-reload" %]">tail</a>) (<a href="[% url %]">log</a>, <a href="[% "$url/raw" %]">raw</a>, <a href="[% "$url/tail-reload" %]">tail</a>)
[% END %] [% END;
BLOCK makeLazyTab %]
<div id="[% tabName %]" class="tab-pane">
<center><img src="/static/images/ajax-loader.gif" alt="Loading..." /></center>
</div>
<script>
$(function() {
$('.nav-tabs').bind('show', function(e) {
var pattern = /#.+/gi;
var id = e.target.toString().match(pattern)[0];
if (id == "#[% tabName %]") {
$('#[% tabName %]').load("[% uri %]");
}
});
});
</script>
[% END;
%]