From 7bc0c8cff66d42c9aa01d2ec107edac60d4a08f3 Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 26 Nov 2020 21:31:09 +0100 Subject: Prevent clone protocol button flash on page load (#13626) * Prevent clone protocol button flash on page load Previously, the saved active buttons would flash on page load because if delay involved in JS execution. Prevent these flashes bydisabling transitions on page load and run the script right after. It's not an ideal solution (which would require server-side storage of user settings like this) but I'd say better than before. * add defer Co-authored-by: zeripath --- web_src/js/index.js | 24 ++++-------------------- web_src/less/helpers.less | 2 ++ 2 files changed, 6 insertions(+), 20 deletions(-) (limited to 'web_src') diff --git a/web_src/js/index.js b/web_src/js/index.js index fc49195607..85e1fb082c 100644 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -1138,16 +1138,16 @@ async function initRepository() { $('#repo-clone-ssh').on('click', function () { $('.clone-url').text($(this).data('link')); $('#repo-clone-url').val($(this).data('link')); - $(this).addClass('blue'); - $('#repo-clone-https').removeClass('blue'); + $(this).addClass('primary'); + $('#repo-clone-https').removeClass('primary'); localStorage.setItem('repo-clone-protocol', 'ssh'); }); $('#repo-clone-https').on('click', function () { $('.clone-url').text($(this).data('link')); $('#repo-clone-url').val($(this).data('link')); - $(this).addClass('blue'); + $(this).addClass('primary'); if ($('#repo-clone-ssh').length > 0) { - $('#repo-clone-ssh').removeClass('blue'); + $('#repo-clone-ssh').removeClass('primary'); localStorage.setItem('repo-clone-protocol', 'https'); } }); @@ -2520,22 +2520,6 @@ $(document).ready(async () => { initTableSort(); initNotificationsTable(); - // Repo clone url. - if ($('#repo-clone-url').length > 0) { - switch (localStorage.getItem('repo-clone-protocol')) { - case 'ssh': - if ($('#repo-clone-ssh').length > 0) { - $('#repo-clone-ssh').trigger('click'); - } else { - $('#repo-clone-https').trigger('click'); - } - break; - default: - $('#repo-clone-https').trigger('click'); - break; - } - } - const routes = { 'div.user.settings': initUserSettings, 'div.repository.settings.collaboration': initRepositoryCollaboration diff --git a/web_src/less/helpers.less b/web_src/less/helpers.less index 60d50883c5..f5c5d710f2 100644 --- a/web_src/less/helpers.less +++ b/web_src/less/helpers.less @@ -24,6 +24,8 @@ .rounded-left { border-radius: var(--border-radius) 0 0 var(--border-radius) !important; } .rounded-right { border-radius: 0 var(--border-radius) var(--border-radius) 0 !important; } +.no-transition { transition: none !important; } + .bg-red { background: var(--color-red) !important; } .bg-orange { background: var(--color-orange) !important; } .bg-yellow { background: var(--color-yellow) !important; } -- cgit v1.2.3