You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

clone_buttons.tmpl 1.8KB

1234567891011121314151617181920212223242526272829303132333435
  1. {{if not $.DisableHTTP}}
  2. <button class="ui basic clone button no-transition" id="repo-clone-https" data-link="{{if $.PageIsWiki}}{{$.WikiCloneLink.HTTPS}}{{else}}{{$.CloneLink.HTTPS}}{{end}}">
  3. {{if UseHTTPS}}HTTPS{{else}}HTTP{{end}}
  4. </button>
  5. {{end}}
  6. {{if and (not $.DisableSSH) (or $.IsSigned $.ExposeAnonSSH)}}
  7. <button class="ui basic clone button no-transition" id="repo-clone-ssh" data-link="{{if $.PageIsWiki}}{{$.WikiCloneLink.SSH}}{{else}}{{$.CloneLink.SSH}}{{end}}">
  8. SSH
  9. </button>
  10. {{end}}
  11. {{if not $.DisableHTTP}}
  12. <input id="repo-clone-url" value="{{if $.PageIsWiki}}{{$.WikiCloneLink.HTTPS}}{{else}}{{$.CloneLink.HTTPS}}{{end}}" readonly>
  13. {{else if and (not .DisableSSH) (or $.IsSigned $.ExposeAnonSSH)}}
  14. <input id="repo-clone-url" value="{{if $.PageIsWiki}}{{$.WikiCloneLink.SSH}}{{else}}{{$.CloneLink.SSH}}{{end}}" readonly>
  15. {{end}}
  16. {{if or (not $.DisableHTTP) (and (not $.DisableSSH) (or $.IsSigned $.ExposeAnonSSH))}}
  17. <button class="ui basic icon button tooltip" id="clipboard-btn" data-content="{{.i18n.Tr "copy_url"}}" data-clipboard-target="#repo-clone-url">
  18. {{svg "octicon-paste"}}
  19. </button>
  20. {{end}}
  21. {{if not (and $.DisableHTTP $.DisableSSH)}}
  22. <script defer>
  23. const isSSH = localStorage.getItem('repo-clone-protocol') === 'ssh';
  24. const sshButton = document.getElementById('repo-clone-ssh');
  25. const httpsButton = document.getElementById('repo-clone-https');
  26. const input = document.getElementById('repo-clone-url');
  27. if (input) input.value = (isSSH ? sshButton : httpsButton).getAttribute('data-link');
  28. if (sshButton) sshButton.classList[isSSH ? 'add' : 'remove']('primary');
  29. if (httpsButton) httpsButton.classList[isSSH ? 'remove' : 'add']('primary');
  30. setTimeout(() => {
  31. if (sshButton) sshButton.classList.remove('no-transition');
  32. if (httpsButton) httpsButton.classList.remove('no-transition');
  33. }, 100);
  34. </script>
  35. {{end}}