Fix lazy tab loading

[?]
Sep 21, 2013, 5:25 PM
6Q2JPSWGL4KKQEBYB3TNZIHAFHGOA47OH7MQM3RMKM72HIZSFCAQC

Dependencies

  • [2] 2P7VNAAC Move common Javascript code into a separate file
  • [3] 2G63HKCH Fix some wellformedness issues
  • [4] 4XVYHFDL Show an error message if tab loading fails
  • [5] OIBSCXGI Use a popover to show how to use the build reproduction script
  • [6] YPDYBK5G Show dependencies as a tree rather than a list
  • [7] BIVZGPUT Optimise clickable rows
  • [8] QCGCX2BR Generalize lazy tabs
  • [9] RDSPL26C Load a tab only once
  • [*] IK53RV4V

Change contents

  • replacement in src/root/common.tt at line 462
    [4.388][4.388:407](),[4.407][4.0:27](),[4.27][4.407:542](),[4.407][4.407:542](),[4.542][3.705:770](),[3.770][4.85:115](),[4.85][4.85:115](),[4.115][4.0:288](),[4.580][4.0:288](),[4.288][4.629:657](),[4.629][4.629:657]()
    $(function() {
    var tabsLoaded = {};
    $('.nav-tabs').bind('show', function(e) {
    var pattern = /#.+/gi;
    var id = e.target.toString().match(pattern)[0];
    if (id == "#[% tabName %]" && !tabsLoaded[id]) {
    tabsLoaded[id] = 1;
    $('#[% tabName %]').load("[% uri %]", function(response, status, xhr) {
    if (status == "error") {
    $('#[% tabName %]').html("<div class='alert alert-error'>Error loading tab: " + xhr.status + " " + xhr.statusText + "</div>");
    }
    });
    }
    });
    });
    [4.388]
    [4.657]
    $(function() { makeLazyTab("[% tabName %]", "[% uri %]"); });
  • edit in src/root/static/js/common.js at line 74
    [2.2155]
    var tabsLoaded = {};
    var makeLazyTab = function(tabName, uri) {
    $('.nav-tabs').bind('show', function(e) {
    var pattern = /#.+/gi;
    var id = e.target.toString().match(pattern)[0];
    if (id == '#' + tabName && !tabsLoaded[id]) {
    tabsLoaded[id] = 1;
    $('#' + tabName).load(uri, function(response, status, xhr) {
    if (status == "error") {
    $('#' + tabName).html("<div class='alert alert-error'>Error loading tab: " + xhr.status + " " + xhr.statusText + "</div>");
    }
    });
    }
    });
    }