From 24b9fe5e4841e29f4cc90a9586ff1af5a26475f3 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Tue, 31 Mar 2015 14:40:34 -0400 Subject: [PATCH] Fix tabs in the repo view --- static/js/app.js | 17 ++++++++++++----- static/partials/repo-view.html | 4 ++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/static/js/app.js b/static/js/app.js index bc721d769..63e4ab5c3 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -333,11 +333,14 @@ quayApp.run(['$location', '$rootScope', 'Restangular', 'UserService', 'PlanServi }); var activeTab = $location.search()['tab']; + var checkTabs = function() { + var tabs = $('a[data-toggle="tab"]'); + if (tabs.length == 0) { + $timeout(checkTabs, 50); + return; + } - // Setup deep linking of tabs. This will change the search field of the URL whenever a tab - // is changed in the UI. - $timeout(function() { - $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { + tabs.on('shown.bs.tab', function (e) { var tabName = e.target.getAttribute('data-target').substr(1); $rootScope.$apply(function() { var isDefaultTab = $('a[data-toggle="tab"]')[0] == e.target; @@ -357,7 +360,11 @@ quayApp.run(['$location', '$rootScope', 'Restangular', 'UserService', 'PlanServi if (activeTab) { changeTab(activeTab); } - }, 400); // 400ms to make sure angular has rendered. + }; + + // Setup deep linking of tabs. This will change the search field of the URL whenever a tab + // is changed in the UI. + $timeout(checkTabs, 50); }); var initallyChecked = false; diff --git a/static/partials/repo-view.html b/static/partials/repo-view.html index 4a9967697..b51016bc5 100644 --- a/static/partials/repo-view.html +++ b/static/partials/repo-view.html @@ -37,12 +37,12 @@ + ng-show="viewScope.repository.can_admin"> + ng-show="viewScope.repository.can_admin">