aboutsummaryrefslogtreecommitdiffstats
path: root/templates/repo/clone_buttons.tmpl
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2022-07-31 20:29:55 +0200
committerGitHub <noreply@github.com>2022-07-31 20:29:55 +0200
commit335e918b1129ef6e0dd03a4713de90e68fbb23e3 (patch)
tree82afb38535535754d3b307bddf04ff8dc5feed85 /templates/repo/clone_buttons.tmpl
parent589677fafb4b77112b7220a1c6089cec71d6db94 (diff)
downloadgitea-335e918b1129ef6e0dd03a4713de90e68fbb23e3.tar.gz
gitea-335e918b1129ef6e0dd03a4713de90e68fbb23e3.zip
Clean up and fix clone button script (#20415)
The button 'primary' class needs to be set in a synchronous script to prevent flicker of the button which was regressed recently, fixed that. Additionally, reduced the two script tags to just one, the previous scripts were actually initializing the buttons thrice on the empty repo page, now it only initializes once. Finally, removed duplicate code and re-used the inline function in the update code as well. I had to split out the script into a separate template as on the empty repo page, the script needs access to the clone URL span in the example text, which is rendered below the clone buttons, so buttons and script could not be combined.
Diffstat (limited to 'templates/repo/clone_buttons.tmpl')
-rw-r--r--templates/repo/clone_buttons.tmpl11
1 files changed, 1 insertions, 10 deletions
diff --git a/templates/repo/clone_buttons.tmpl b/templates/repo/clone_buttons.tmpl
index fb54b27c82..67a509835f 100644
--- a/templates/repo/clone_buttons.tmpl
+++ b/templates/repo/clone_buttons.tmpl
@@ -9,16 +9,7 @@
SSH
</button>
{{end}}
-<!-- the value will be updated by initRepoCloneLink, the code below is used to avoid UI flicking -->
-<input id="repo-clone-url" value="" size="1" readonly>
-<script>
- (() => {
- const proto = localStorage.getItem('repo-clone-protocol') || 'https';
- const btn = document.getElementById(`repo-clone-${proto}`);
- // it's ok if we don't find the btn here, initRepoCloneLink will take care of it
- document.getElementById('repo-clone-url').value = btn ? btn.getAttribute('data-link') : '';
- })();
-</script>
+<input id="repo-clone-url" class="js-clone-url" value="" size="1" readonly>
<button class="ui basic icon button tooltip" id="clipboard-btn" data-content="{{.locale.Tr "copy_url"}}" data-clipboard-target="#repo-clone-url" aria-label="{{.locale.Tr "copy_url"}}">
{{svg "octicon-paste"}}
</button>